2011-05-20 Ryosuke Niwa <rniwa@webkit.org>
authorRyosuke Niwa <rniwa@webkit.org>
Mon, 23 May 2011 18:07:41 +0000 (18:07 +0000)
committerAdemar de Souza Reis Jr <ademar.reis@openbossa.org>
Mon, 23 May 2011 20:09:38 +0000 (17:09 -0300)
commitca2dab5b8026aff72d5260374c7d5cd13c83ebc0
tree3fe3b8d0bbb6f2dc982ead7a88119a39c1725092
parentcff17777ff2fdb87aa09956fbb18683513ce5458
2011-05-20  Ryosuke Niwa  <rniwa@webkit.org>

        Reviewed by Enrica Casucci.

        REGRESSION(r84311): WebKit copies too much styles when copying
        https://bugs.webkit.org/show_bug.cgi?id=60914

        Added a test to ensure WebKit does not clone hierarchy to preserve background color.

        Also renamed editing/pasteboard/do-not-copy-body-color.html to do-no-clone-unnecessary-styles.html
        and updated the description to match new behavior. While this test ensures WebKit does not copy
        body's background color when it's not fully selected, this isn't a necessary requirement for us
        not to duplicate borders so new expected result is correct.

        * editing/pasteboard/copy-text-with-backgroundcolor-expected.txt: Some spans became style spans.
        * editing/pasteboard/do-no-clone-unnecessary-styles-2-expected.txt: Added.
        * editing/pasteboard/do-no-clone-unnecessary-styles-2.html: Added.
        * editing/pasteboard/do-no-clone-unnecessary-styles-expected.txt: Renamed from
        LayoutTests/editing/pasteboard/do-not-copy-body-color-expected.txt.
        * editing/pasteboard/do-no-clone-unnecessary-styles.html: Renamed from
        LayoutTests/editing/pasteboard/do-not-copy-body-color.html.
2011-05-20  Ryosuke Niwa  <rniwa@webkit.org>

        Reviewed by Enrica Casucci.

        REGRESSION(r84311): WebKit copies too much styles when copying
        https://bugs.webkit.org/show_bug.cgi?id=60914

        The bug was caused by WebKit's cloning node hierarchy up until the node that has background color.
        Fixed the bug by not cloning background color and adding the effective background color to the wrapping
        style span.

        Tests: editing/pasteboard/do-no-clone-unnecessary-styles-2.html
               editing/pasteboard/do-no-clone-unnecessary-styles.html

        * editing/EditingStyle.cpp:
        (WebCore::cssValueToRGBA): Extracted from getRGBAFontColor.
        (WebCore::getRGBAFontColor): Moved.
        (WebCore::rgbaBackgroundColorInEffect): Added.
        (WebCore::EditingStyle::init): Added support for InheritablePropertiesAndBackgroundColorInEffect.
        (WebCore::EditingStyle::prepareToApplyAt): Include the effective background color at the given position.
        Also remove the background color property when the effective background color is equal to the background
        color property (in terms of RGBA value) of the editing style.
        (WebCore::hasTransparentBackgroundColor): Moved from Editor class.
        (WebCore::backgroundColorInEffect): Extracted from Editor::selectionStartCSSPropertyValue.
        * editing/EditingStyle.h: Added prototypes for hasTransparentBackgroundColor and backgroundColorInEffect.
        * editing/Editor.cpp:
        (WebCore::Editor::selectionStartCSSPropertyValue): Calls backgroundColorInEffect.
        * editing/Editor.h: Removed hasTransparentBackgroundColor.
        * editing/markup.cpp:
        (WebCore::isElementPresentational): Reverted r85090 and r84311.
        (WebCore::createMarkup): Include the background color in effect when computing the editing style.

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@87082 268f45cc-cd09-0410-ab3c-d52691b4dbfc
14 files changed:
LayoutTests/ChangeLog
LayoutTests/editing/pasteboard/copy-text-with-backgroundcolor-expected.txt
LayoutTests/editing/pasteboard/do-not-copy-body-color-expected.txt [deleted file]
LayoutTests/editing/pasteboard/do-not-copy-body-color.html [deleted file]
LayoutTests/editing/pasteboard/do-not-copy-unnecessary-styles-2-expected.txt [new file with mode: 0644]
LayoutTests/editing/pasteboard/do-not-copy-unnecessary-styles-2.html [new file with mode: 0644]
LayoutTests/editing/pasteboard/do-not-copy-unnecessary-styles-expected.txt [new file with mode: 0644]
LayoutTests/editing/pasteboard/do-not-copy-unnecessary-styles.html [new file with mode: 0644]
Source/WebCore/ChangeLog
Source/WebCore/editing/EditingStyle.cpp
Source/WebCore/editing/EditingStyle.h
Source/WebCore/editing/Editor.cpp
Source/WebCore/editing/Editor.h
Source/WebCore/editing/markup.cpp