2011-05-20 Ryosuke Niwa <rniwa@webkit.org>
authorRyosuke Niwa <rniwa@webkit.org>
Fri, 20 May 2011 21:23:23 +0000 (21:23 +0000)
committerAdemar de Souza Reis Jr <ademar.reis@openbossa.org>
Mon, 23 May 2011 20:09:33 +0000 (17:09 -0300)
commitcff17777ff2fdb87aa09956fbb18683513ce5458
tree35c23e0f24177028103e5837bd4599f7fc005bff
parent326f93c29ccee2f560d0731b0d642183551693ab
2011-05-20  Ryosuke Niwa  <rniwa@webkit.org>

        Reviewed by Enrica Casucci.

        Wrap copied contents by one style span instead of two
        https://bugs.webkit.org/show_bug.cgi?id=60988

        Rebaselined tests due to the change in how WebKit preserves style in copy and paste.

        * editing/pasteboard/4930986-2-expected.txt: Whitespace change.
        * editing/pasteboard/5065605-expected.txt: No longer adds redundant inline style declaration.
        * editing/pasteboard/paste-4039777-fix-expected.txt: Progression; Now we hit the list merging logic
        in ReplaceSelectionCommand: isStyleSpan(refNode.get()) && isListElement(refNode->firstChild()).
        * editing/pasteboard/paste-list-001-expected.txt: Ditto.
        * editing/pasteboard/paste-text-011-expected.txt: An extra style span was added.
        * editing/pasteboard/paste-text-012-expected.txt: Ditto.
        * editing/pasteboard/smart-paste-003-trailing-whitespace-expected.txt: No longer adds redundant style span.
        * platform/chromium-win/editing/pasteboard/paste-text-003-expected.txt: No longer adds empty anonymous nodes.
        * platform/chromium-win/editing/pasteboard/paste-text-011-expected.txt: Ditto.
        * platform/gtk/editing/pasteboard/paste-text-003-expected.txt: Ditto.
        * platform/mac/editing/pasteboard/paste-text-003-expected.txt: Ditto.
        * platform/qt/editing/pasteboard/paste-text-003-expected.txt: Ditto.
2011-05-20  Ryosuke Niwa  <rniwa@webkit.org>

        Reviewed by Enrica Casucci.

        Wrap copied contents by one style span instead of two
        https://bugs.webkit.org/show_bug.cgi?id=60988

        Replaced sourceDocumentStyleSpan and copiedRangeStyleSpan by one wrapping style span. Instead
        of wrapping the copied contents by user-applied style and document default style in serialization,
        take the difference with the document default's style in paste code.

        This will dramatically simplify our copy and paste code and pave a way to fix the bug 60914.

        No new tests because copy & paste is tested by existing layout tests.

        * editing/EditingStyle.cpp:
        (WebCore::EditingStyle::prepareToApplyAt): Remove the color property if RGBA values of color
        matches that of the computed style at the specified position.
        * editing/ReplaceSelectionCommand.cpp:
        (WebCore::ReplaceSelectionCommand::handleStyleSpans): Replaced sourceDocumentStyleSpan and
        copiedRangeStyleSpan by wrappingStyleSpan. When pasting as a quotation, compare style against
        the document's default style to avoid keeping the document default style (tested by
        editing/pasteboard/4930986-3.html).
        * editing/ReplaceSelectionCommand.h:
        * editing/markup.cpp:
        (WebCore::createMarkup): Only use one style span to wrap the serialized contents.

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@86983 268f45cc-cd09-0410-ab3c-d52691b4dbfc
18 files changed:
LayoutTests/ChangeLog
LayoutTests/editing/pasteboard/4930986-2-expected.txt
LayoutTests/editing/pasteboard/5065605-expected.txt
LayoutTests/editing/pasteboard/paste-4039777-fix-expected.txt
LayoutTests/editing/pasteboard/paste-list-001-expected.txt
LayoutTests/editing/pasteboard/paste-text-011-expected.txt
LayoutTests/editing/pasteboard/paste-text-012-expected.txt
LayoutTests/editing/pasteboard/smart-paste-003-trailing-whitespace-expected.txt
LayoutTests/platform/chromium-win/editing/pasteboard/paste-text-003-expected.txt
LayoutTests/platform/chromium-win/editing/pasteboard/paste-text-011-expected.txt
LayoutTests/platform/gtk/editing/pasteboard/paste-text-003-expected.txt
LayoutTests/platform/mac/editing/pasteboard/paste-text-003-expected.txt
LayoutTests/platform/qt/editing/pasteboard/paste-text-003-expected.txt
Source/WebCore/ChangeLog
Source/WebCore/editing/EditingStyle.cpp
Source/WebCore/editing/ReplaceSelectionCommand.cpp
Source/WebCore/editing/ReplaceSelectionCommand.h
Source/WebCore/editing/markup.cpp