- Revision
- 99067
- Author
- [email protected]
- Date
- 2011-11-02 09:22:47 -0700 (Wed, 02 Nov 2011)
Log Message
REGRESSION(r96870): WebKit generates background: transparent on blogger.com
https://bugs.webkit.org/show_bug.cgi?id=71203
Reviewed by Ojan Vafai.
Source/WebCore:
Remove the transparent background color from inline style declarations in the pasted content.
Also fixed a bug in removeStyleFromRulesAndContext that it removes properties in inline style
declarations even if those properties were overridden.
Tests: editing/deleting/merge-paragraphs-with-transparent-background.html
editing/deleting/paste-with-transparent-background-color.html
* editing/EditingStyle.cpp:
(WebCore::removePropertiesInStyle):
(WebCore::EditingStyle::removeStyleFromRulesAndContext):
(WebCore::EditingStyle::removePropertiesInElementDefaultStyle):
LayoutTests:
Added a test to merge paragraphs inside a document with background: transparent, and a test to
cut and paste contents with background: transparent, which is overriding a style rule background: blue.
WebKit should preserve the appearance of the pasted content but should not add a redundant
background: transparent.
* editing/deleting/merge-paragraphs-with-transparent-background-expected.txt: Added.
* editing/deleting/merge-paragraphs-with-transparent-background.html: Added.
* editing/deleting/paste-with-transparent-background-color-expected.txt: Added.
* editing/deleting/paste-with-transparent-background-color.html: Added.
Modified Paths
Added Paths
Diff
Modified: trunk/LayoutTests/ChangeLog (99066 => 99067)
--- trunk/LayoutTests/ChangeLog 2011-11-02 16:14:39 UTC (rev 99066)
+++ trunk/LayoutTests/ChangeLog 2011-11-02 16:22:47 UTC (rev 99067)
@@ -1,3 +1,21 @@
+2011-11-02 Ryosuke Niwa <[email protected]>
+
+ REGRESSION(r96870): WebKit generates background: transparent on blogger.com
+ https://bugs.webkit.org/show_bug.cgi?id=71203
+
+ Reviewed by Ojan Vafai.
+
+ Added a test to merge paragraphs inside a document with background: transparent, and a test to
+ cut and paste contents with background: transparent, which is overriding a style rule background: blue.
+
+ WebKit should preserve the appearance of the pasted content but should not add a redundant
+ background: transparent.
+
+ * editing/deleting/merge-paragraphs-with-transparent-background-expected.txt: Added.
+ * editing/deleting/merge-paragraphs-with-transparent-background.html: Added.
+ * editing/deleting/paste-with-transparent-background-color-expected.txt: Added.
+ * editing/deleting/paste-with-transparent-background-color.html: Added.
+
2011-11-02 Stephen Chenney <[email protected]>
printing layout test failures after r98634
Added: trunk/LayoutTests/editing/deleting/merge-paragraphs-with-transparent-background-expected.txt (0 => 99067)
--- trunk/LayoutTests/editing/deleting/merge-paragraphs-with-transparent-background-expected.txt (rev 0)
+++ trunk/LayoutTests/editing/deleting/merge-paragraphs-with-transparent-background-expected.txt 2011-11-02 16:22:47 UTC (rev 99067)
@@ -0,0 +1,10 @@
+This tests merging paragraphs inside a document with background: transparent in html element's inline style declaration.
+WebKit should not generate a span with background-color property in such cases.
+| "
+"
+| <p>
+| id="destination"
+| "hello<#selection-caret>"
+| "world"
+| "
+"
Added: trunk/LayoutTests/editing/deleting/merge-paragraphs-with-transparent-background.html (0 => 99067)
--- trunk/LayoutTests/editing/deleting/merge-paragraphs-with-transparent-background.html (rev 0)
+++ trunk/LayoutTests/editing/deleting/merge-paragraphs-with-transparent-background.html 2011-11-02 16:22:47 UTC (rev 99067)
@@ -0,0 +1,24 @@
+<!DOCTYPE html>
+<html style="background: transparent; text-decoration: none">
+<body>
+<p id="description">This tests merging paragraphs inside a document with background: transparent in html element's inline style declaration.
+WebKit should not generate a span with background-color property in such cases.</p>
+<div id="container" contenteditable>
+<p id="destination">hello</p>
+<p id="target">world</p>
+</div>
+<script src=""
+<script>
+
+Markup.description(document.getElementById('description').textContent);
+
+document.getElementById('container').focus();
+var target = document.getElementById('target');
+getSelection().collapse(target, 0);
+document.execCommand('Delete', false, null);
+
+Markup.dump(document.getElementById('container'));
+
+</script>
+</body>
+</html>
Added: trunk/LayoutTests/editing/deleting/paste-with-transparent-background-color-expected.txt (0 => 99067)
--- trunk/LayoutTests/editing/deleting/paste-with-transparent-background-color-expected.txt (rev 0)
+++ trunk/LayoutTests/editing/deleting/paste-with-transparent-background-color-expected.txt 2011-11-02 16:22:47 UTC (rev 99067)
@@ -0,0 +1,21 @@
+This tests cutting and pasting a content with inline "background: transparent;" into a document with a style rule that overrides this style.
+WebKit should preserve the inline style declaration. To manually test, cut and paste "hello world WebKit" below. "world" should not be highlighted in blue.
+
+Before cut and paste:
+| "<#selection-anchor>hello "
+| <span>
+| class="test"
+| style="background: transparent;"
+| "world"
+| " WebKit<#selection-focus>"
+
+After cut and paste:
+| "hello"
+| " "
+| <span>
+| class="test"
+| style="background-color: transparent; "
+| "world"
+| " "
+| "WebKit<#selection-caret>"
+| <br>
Added: trunk/LayoutTests/editing/deleting/paste-with-transparent-background-color.html (0 => 99067)
--- trunk/LayoutTests/editing/deleting/paste-with-transparent-background-color.html (rev 0)
+++ trunk/LayoutTests/editing/deleting/paste-with-transparent-background-color.html 2011-11-02 16:22:47 UTC (rev 99067)
@@ -0,0 +1,29 @@
+<!DOCTYPE html>
+<html style="background: transparent; text-decoration: none">
+<body>
+<p id="description">This tests cutting and pasting a content with inline "background: transparent;" into a document with a style rule that overrides this style.
+WebKit should preserve the inline style declaration. To manually test, cut and paste "hello world WebKit" below. "world" should not be highlighted in blue.</p>
+<style>
+.test {
+ background: blue;
+}
+</style>
+<div id="container" contenteditable>hello <span class=test style="background: transparent;">world</span> WebKit</div>
+<script src=""
+<script>
+
+Markup.description(document.getElementById('description').textContent);
+
+document.getElementById('container').focus();
+document.execCommand('SelectAll', false, null);
+
+Markup.dump(document.getElementById('container'), 'Before cut and paste');
+
+document.execCommand('Cut', false, null);
+document.execCommand('Paste', false, null);
+
+Markup.dump(document.getElementById('container'), 'After cut and paste');
+
+</script>
+</body>
+</html>
Modified: trunk/Source/WebCore/ChangeLog (99066 => 99067)
--- trunk/Source/WebCore/ChangeLog 2011-11-02 16:14:39 UTC (rev 99066)
+++ trunk/Source/WebCore/ChangeLog 2011-11-02 16:22:47 UTC (rev 99067)
@@ -1,3 +1,22 @@
+2011-11-02 Ryosuke Niwa <[email protected]>
+
+ REGRESSION(r96870): WebKit generates background: transparent on blogger.com
+ https://bugs.webkit.org/show_bug.cgi?id=71203
+
+ Reviewed by Ojan Vafai.
+
+ Remove the transparent background color from inline style declarations in the pasted content.
+ Also fixed a bug in removeStyleFromRulesAndContext that it removes properties in inline style
+ declarations even if those properties were overridden.
+
+ Tests: editing/deleting/merge-paragraphs-with-transparent-background.html
+ editing/deleting/paste-with-transparent-background-color.html
+
+ * editing/EditingStyle.cpp:
+ (WebCore::removePropertiesInStyle):
+ (WebCore::EditingStyle::removeStyleFromRulesAndContext):
+ (WebCore::EditingStyle::removePropertiesInElementDefaultStyle):
+
2011-11-02 Andreas Kling <[email protected]>
CSSStyleRule: Devirtualize selectorText()
Modified: trunk/Source/WebCore/editing/EditingStyle.cpp (99066 => 99067)
--- trunk/Source/WebCore/editing/EditingStyle.cpp 2011-11-02 16:14:39 UTC (rev 99066)
+++ trunk/Source/WebCore/editing/EditingStyle.cpp 2011-11-02 16:22:47 UTC (rev 99067)
@@ -1059,6 +1059,17 @@
m_mutableStyle->merge(fromComputedStyle.get());
}
+static void removePropertiesInStyle(CSSMutableStyleDeclaration* styleToRemovePropertiesFrom, CSSMutableStyleDeclaration* style)
+{
+ Vector<int> propertiesToRemove(style->length());
+ size_t i = 0;
+ CSSMutableStyleDeclaration::const_iterator end = style->end();
+ for (CSSMutableStyleDeclaration::const_iterator it = style->begin(); it != end; ++it, ++i)
+ propertiesToRemove[i] = it->id();
+
+ styleToRemovePropertiesFrom->removePropertiesInSet(propertiesToRemove.data(), propertiesToRemove.size());
+}
+
void EditingStyle::removeStyleFromRulesAndContext(StyledElement* element, Node* context)
{
ASSERT(element);
@@ -1073,7 +1084,10 @@
// 2. Remove style present in context and not overriden by matched rules.
RefPtr<EditingStyle> computedStyle = EditingStyle::create(context, EditingPropertiesInEffect);
if (computedStyle->m_mutableStyle) {
- computedStyle->removePropertiesInElementDefaultStyle(element);
+ if (!computedStyle->m_mutableStyle->getPropertyCSSValue(CSSPropertyBackgroundColor))
+ computedStyle->m_mutableStyle->setProperty(CSSPropertyBackgroundColor, CSSValueTransparent);
+
+ removePropertiesInStyle(computedStyle->m_mutableStyle.get(), styleFromMatchedRules.get());
m_mutableStyle = getPropertiesNotIn(m_mutableStyle.get(), computedStyle->m_mutableStyle.get());
}
@@ -1094,13 +1108,7 @@
RefPtr<CSSMutableStyleDeclaration> defaultStyle = styleFromMatchedRulesForElement(element, CSSStyleSelector::UAAndUserCSSRules);
- Vector<int> propertiesToRemove(defaultStyle->length());
- size_t i = 0;
- CSSMutableStyleDeclaration::const_iterator end = defaultStyle->end();
- for (CSSMutableStyleDeclaration::const_iterator it = defaultStyle->begin(); it != end; ++it, ++i)
- propertiesToRemove[i] = it->id();
-
- m_mutableStyle->removePropertiesInSet(propertiesToRemove.data(), propertiesToRemove.size());
+ removePropertiesInStyle(m_mutableStyle.get(), defaultStyle.get());
}
void EditingStyle::forceInline()