Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
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. Canonical link: https://commits.webkit.org/76669@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@87082 268f45cc-cd09-0410-ab3c-d52691b4dbfc
- Loading branch information
Showing
with
182 additions
and 72 deletions.
- +22 −0 LayoutTests/ChangeLog
- +3 −1 LayoutTests/editing/pasteboard/copy-text-with-backgroundcolor-expected.txt
- +0 −11 LayoutTests/editing/pasteboard/do-not-copy-body-color-expected.txt
- +8 −0 LayoutTests/editing/pasteboard/do-not-copy-unnecessary-styles-2-expected.txt
- +28 −0 LayoutTests/editing/pasteboard/do-not-copy-unnecessary-styles-2.html
- +11 −0 LayoutTests/editing/pasteboard/do-not-copy-unnecessary-styles-expected.txt
- +2 −3 LayoutTests/editing/pasteboard/{do-not-copy-body-color.html → do-not-copy-unnecessary-styles.html}
- +32 −0 Source/WebCore/ChangeLog
- +65 −29 Source/WebCore/editing/EditingStyle.cpp
- +7 −4 Source/WebCore/editing/EditingStyle.h
- +2 −21 Source/WebCore/editing/Editor.cpp
- +0 −1 Source/WebCore/editing/Editor.h
- +2 −2 Source/WebCore/editing/markup.cpp
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@@ -0,0 +1,8 @@ | ||
This test verifies that WebKit does not erroneously clone nodes hierarchy when copying text with background color. | ||
"Hello" should be blue and has yellow background but you should not see red border. | ||
|
||
You should not see any borders: | ||
| <span> | ||
| class="Apple-style-span" | ||
| style="color: rgb(0, 0, 255); background-color: rgb(255, 255, 0); " | ||
| "Hello<#selection-caret>" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@@ -0,0 +1,28 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<body> | ||
<p>This test verifies that WebKit does not erroneously clone nodes hierarchy when copying text with background color. | ||
"Hello" should be blue and has yellow background but you should not see red border.</p> | ||
<p>To manually this test, copy "Hello" and paste it on the black box below.</p> | ||
<div style="padding: 10px;"><span style="color: blue; background-color: yellow; padding: 5px;"><div><span style="border: 2px solid red; border-radius: 15px;"> | ||
<span id="source">Hello</span> | ||
</span></div></span></div> | ||
<div id="destination" style="border: solid 1px black; padding: 20px;" contenteditable></div> | ||
<script src="../../resources/dump-as-markup.js"></script> | ||
<script> | ||
|
||
if (window.layoutTestController) { | ||
window.getSelection().setBaseAndExtent(document.getElementById('source'), 0, document.getElementById('source'), 1); | ||
document.execCommand("Copy"); | ||
|
||
window.getSelection().setPosition(document.getElementById('destination'), 0); | ||
document.execCommand("Paste"); | ||
|
||
Markup.description(document.getElementsByTagName('p')[0].textContent); | ||
Markup.dump('destination', 'You should not see any borders'); | ||
} else | ||
Markup.noAutoDump(); | ||
|
||
</script> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@@ -0,0 +1,11 @@ | ||
|
||
<div> | ||
This test verifies that WebKit does not erroneously clone nodes hierarchy when copying text with background color. | ||
To manually this test, select the text inside the div with the border, cut and paste it back. You should not see an additional red border. | ||
<div style="border: 2px solid red"> | ||
<div id="test"><span class="Apple-style-span" style="background-color: rgb(187, 187, 187); ">Select this text</span><br></div> | ||
</div> | ||
</div> | ||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.