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