WebCore:
authorjustin.garcia@apple.com <justin.garcia@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 28 Feb 2008 20:42:27 +0000 (20:42 +0000)
committerjustin.garcia@apple.com <justin.garcia@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 28 Feb 2008 20:42:27 +0000 (20:42 +0000)
commitce992593d898314bd2a6bfe4d5d558e9da373a1e
treeb25995854cd988ad5caa01b6a890d79432eba0e0
parent91664180bdbd2b31b0b205a164527b4e82575546
WebCore:

        Reviewed by Darin Adler.

        <rdar://problem/4930986> REGRESSION: Paste As Quotation pastes black text instead of blue

        Add a second style span at copy time to hold document default styles.  This helps us
        differentiate between those and user applied styles at paste time, where we'll want
        to let Mail's Paste As Quotation blockquote override document default styles, but
        not others.

        * css/CSSComputedStyleDeclaration.cpp:
        (WebCore::CSSComputedStyleDeclaration::getPropertyCSSValue): Changed the unit type used
        for -webkit-text-stroke-width from CSS_NUMBER to CSS_PX, to match other properties that
        are thick | medium | thin | <length>.  Before, there was a mismatch between the unit
        type of -webkit-text-stroke-width property values in a CSSComputedStyleDeclaration for
        an element and that element's inlineStyleDecl(), causing identical values to always appear
        different to diff().
        * editing/ReplaceSelectionCommand.cpp:
        (WebCore::ReplaceSelectionCommand::handlePasteAsQuotationNode): Fixed.  Don't just change
        the class to an empty string, completely remove it, it's no longer needed.
        (WebCore::handleStyleSpansBeforeInsertion): Moved the optimization from doApply here.
        (WebCore::ReplaceSelectionCommand::handleStyleSpans):
        Added, replaces removeRedundantStyles.
        We aren't (yet) removing all redundant styles, just those on style spans, so I removed the
        unused code and renamed the function.
        There won't be more than two style spans that we need to consider, the one with the
        source document's default styles and styles on the commonAncestor of the copied Range,
        so don't look for more than two.
        Let elements that wrap the incoming fragment override the source document's styles.
        (WebCore::ReplaceSelectionCommand::doApply): Moved code to handleStyleSpansBeforeInsertion
        and call the renamed handleStyleSpans.
        * editing/ReplaceSelectionCommand.h:
        * editing/markup.cpp:
        (WebCore::removeDefaultStyles): Added.  Don't add document defaults to the style span
        that holds user applied styles, since they'll be added to their own style span.
        (WebCore::createMarkup):
        Add a second style span that holds just the document defaults. This lets us differentiate
        between those and user applied styles at paste time.
        Mail blockquotes are just another type of special element, moved their handling there. This
        also lets paste code make assumptions about the position of the two style spans (they are
        *always* parent-child).

LayoutTests:

        Reviewed by Darin Adler.

        <rdar://problem/4930986> REGRESSION: Paste As Quotation pastes black text instead of blue

        Demonstrates the bug:
        * editing/pasteboard/4930986-1-expected.txt: Added.
        * editing/pasteboard/4930986-1.html: Added.
        * editing/pasteboard/4930986-2-expected.txt: Added.
        * editing/pasteboard/4930986-2.html: Added.

        Demonstrates a problem with the first version of the patch:
        * editing/pasteboard/4930986-3-expected.txt: Added.
        * editing/pasteboard/4930986-3.html: Added.

        Visual problem fixed.  An anonymous renderer changed position, DOM remains unchanged:
        * editing/execCommand/5144139-1.html:
        * platform/mac/editing/execCommand/5144139-1-expected.checksum:
        * platform/mac/editing/execCommand/5144139-1-expected.png:
        * platform/mac/editing/execCommand/5144139-1-expected.txt:

        Removed unnecessary style spans, visual result unchanged:
        * platform/mac/editing/pasteboard/merge-end-blockquote-expected.checksum:
        * platform/mac/editing/pasteboard/merge-end-blockquote-expected.png:
        * platform/mac/editing/pasteboard/merge-end-blockquote-expected.txt:
        * platform/mac/editing/style/font-family-with-space-expected.checksum:
        * platform/mac/editing/style/font-family-with-space-expected.png:
        * platform/mac/editing/style/font-family-with-space-expected.txt:

        A style span isn't removed because at paste time because we don't anticipate
        encountering styles on style spans that are non-inheritable, because we don't
        create style spans like that at copy time. Turned this into a text only
        test. Test remains visually unchanged:
        * editing/pasteboard/5245519-expected.txt: Added.
        * editing/pasteboard/5245519.html:
        * platform/mac/editing/pasteboard/5245519-expected.checksum: Removed.
        * platform/mac/editing/pasteboard/5245519-expected.png: Removed.
        * platform/mac/editing/pasteboard/5245519-expected.txt: Removed.

        Added an extra empty anonymous renderer, DOM and visual result remain unchanged:
        * platform/mac/editing/execCommand/create-list-with-hr-expected.checksum:
        * platform/mac/editing/execCommand/create-list-with-hr-expected.png:
        * platform/mac/editing/execCommand/create-list-with-hr-expected.txt:
        * platform/mac/editing/pasteboard/paste-list-001-expected.checksum:
        * platform/mac/editing/pasteboard/paste-list-001-expected.png:
        * platform/mac/editing/pasteboard/paste-list-001-expected.txt:
        * platform/mac/editing/pasteboard/paste-table-001-expected.checksum:
        * platform/mac/editing/pasteboard/paste-table-001-expected.png:
        * platform/mac/editing/pasteboard/paste-table-001-expected.txt:
        * platform/mac/editing/pasteboard/paste-text-003-expected.checksum:
        * platform/mac/editing/pasteboard/paste-text-003-expected.png:
        * platform/mac/editing/pasteboard/paste-text-003-expected.txt:

        Reflects changes to CSSComputedStyleDeclaration::getPropertyCSSValue:
        * fast/css/computed-style-expected.txt:
        * fast/css/computed-style-without-renderer-expected.txt:

        We don't remove styles from style spans that are overridden by all of their
        children, even though they are unnecessary. We've never done this, but now
        that there can be two style spans at paste time we are more likely to have
        a style span left over because of this problem.  Mentioned this in the test
        case and turned this into a text only test:
        * editing/pasteboard/4840662.html:
        * editing/pasteboard/4840662-expected.txt: Added.
        * platform/mac/editing/pasteboard/4840662-expected.checksum: Removed.
        * platform/mac/editing/pasteboard/4840662-expected.png: Removed.
        * platform/mac/editing/pasteboard/4840662-expected.txt: Removed.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@30649 268f45cc-cd09-0410-ab3c-d52691b4dbfc
46 files changed:
LayoutTests/ChangeLog
LayoutTests/editing/execCommand/5144139-1.html
LayoutTests/editing/pasteboard/4840662-expected.txt [new file with mode: 0644]
LayoutTests/editing/pasteboard/4840662.html
LayoutTests/editing/pasteboard/4930986-1-expected.txt [new file with mode: 0644]
LayoutTests/editing/pasteboard/4930986-1.html [new file with mode: 0644]
LayoutTests/editing/pasteboard/4930986-2-expected.txt [new file with mode: 0644]
LayoutTests/editing/pasteboard/4930986-2.html [new file with mode: 0644]
LayoutTests/editing/pasteboard/4930986-3-expected.txt [new file with mode: 0644]
LayoutTests/editing/pasteboard/4930986-3.html [new file with mode: 0644]
LayoutTests/editing/pasteboard/5245519-expected.txt [new file with mode: 0644]
LayoutTests/editing/pasteboard/5245519.html
LayoutTests/fast/css/computed-style-expected.txt
LayoutTests/fast/css/computed-style-without-renderer-expected.txt
LayoutTests/platform/mac/editing/execCommand/5144139-1-expected.checksum
LayoutTests/platform/mac/editing/execCommand/5144139-1-expected.png
LayoutTests/platform/mac/editing/execCommand/5144139-1-expected.txt
LayoutTests/platform/mac/editing/execCommand/create-list-with-hr-expected.checksum
LayoutTests/platform/mac/editing/execCommand/create-list-with-hr-expected.png
LayoutTests/platform/mac/editing/execCommand/create-list-with-hr-expected.txt
LayoutTests/platform/mac/editing/pasteboard/4840662-expected.checksum [deleted file]
LayoutTests/platform/mac/editing/pasteboard/4840662-expected.png [deleted file]
LayoutTests/platform/mac/editing/pasteboard/4840662-expected.txt [deleted file]
LayoutTests/platform/mac/editing/pasteboard/5245519-expected.checksum [deleted file]
LayoutTests/platform/mac/editing/pasteboard/5245519-expected.png [deleted file]
LayoutTests/platform/mac/editing/pasteboard/5245519-expected.txt [deleted file]
LayoutTests/platform/mac/editing/pasteboard/merge-end-blockquote-expected.checksum
LayoutTests/platform/mac/editing/pasteboard/merge-end-blockquote-expected.png
LayoutTests/platform/mac/editing/pasteboard/merge-end-blockquote-expected.txt
LayoutTests/platform/mac/editing/pasteboard/paste-list-001-expected.checksum
LayoutTests/platform/mac/editing/pasteboard/paste-list-001-expected.png
LayoutTests/platform/mac/editing/pasteboard/paste-list-001-expected.txt
LayoutTests/platform/mac/editing/pasteboard/paste-table-001-expected.checksum
LayoutTests/platform/mac/editing/pasteboard/paste-table-001-expected.png
LayoutTests/platform/mac/editing/pasteboard/paste-table-001-expected.txt
LayoutTests/platform/mac/editing/pasteboard/paste-text-003-expected.checksum
LayoutTests/platform/mac/editing/pasteboard/paste-text-003-expected.png
LayoutTests/platform/mac/editing/pasteboard/paste-text-003-expected.txt
LayoutTests/platform/mac/editing/style/font-family-with-space-expected.checksum
LayoutTests/platform/mac/editing/style/font-family-with-space-expected.png
LayoutTests/platform/mac/editing/style/font-family-with-space-expected.txt
WebCore/ChangeLog
WebCore/css/CSSComputedStyleDeclaration.cpp
WebCore/editing/ReplaceSelectionCommand.cpp
WebCore/editing/ReplaceSelectionCommand.h
WebCore/editing/markup.cpp