Diff
Modified: trunk/LayoutTests/ChangeLog (104067 => 104068)
--- trunk/LayoutTests/ChangeLog 2012-01-04 22:05:07 UTC (rev 104067)
+++ trunk/LayoutTests/ChangeLog 2012-01-04 22:05:18 UTC (rev 104068)
@@ -1,3 +1,15 @@
+2012-01-03 Ryosuke Niwa <[email protected]>
+
+ REGRESSION (r92823): Background color not preserved when copying and pasting a table row
+ https://bugs.webkit.org/show_bug.cgi?id=75330
+
+ Reviewed by Tony Chang.
+
+ Add a regression test.
+
+ * editing/pasteboard/copy-element-with-conflicting-background-color-from-rule-expected.html: Added.
+ * editing/pasteboard/copy-element-with-conflicting-background-color-from-rule.html: Added.
+
2012-01-04 Alpha Lam <[email protected]>
Not reviewed. Update Chromium port test expectations.
Added: trunk/LayoutTests/editing/pasteboard/copy-element-with-conflicting-background-color-from-rule-expected.html (0 => 104068)
--- trunk/LayoutTests/editing/pasteboard/copy-element-with-conflicting-background-color-from-rule-expected.html (rev 0)
+++ trunk/LayoutTests/editing/pasteboard/copy-element-with-conflicting-background-color-from-rule-expected.html 2012-01-04 22:05:18 UTC (rev 104068)
@@ -0,0 +1,16 @@
+<!DOCTYPE html>
+<html>
+<body>
+<p>This tests copying an element with a background color specified in a style rule that conflicts with the background color of a wrapping style.
+The pasted text should have lightgreen background color.</p>
+Paste here:
+<div contenteditable><div style="background-color: lightgreen;">Copy this line</div>
+<span id="target"></span><br>
+</div>
+<script>
+var target = document.getElementById('target');
+target.parentNode.focus();
+getSelection().collapse(target, 0);
+</script>
+</body>
+</html>
Added: trunk/LayoutTests/editing/pasteboard/copy-element-with-conflicting-background-color-from-rule.html (0 => 104068)
--- trunk/LayoutTests/editing/pasteboard/copy-element-with-conflicting-background-color-from-rule.html (rev 0)
+++ trunk/LayoutTests/editing/pasteboard/copy-element-with-conflicting-background-color-from-rule.html 2012-01-04 22:05:18 UTC (rev 104068)
@@ -0,0 +1,41 @@
+<!DOCTYPE html>
+<html>
+<body _onpaste_="finish()">
+<p>This tests copying an element with a background color specified in a style rule that conflicts with the background color of a wrapping style.
+The pasted text should have lightgreen background color.</p>
+<style>
+.add { background-color: lightgreen; }
+</style>
+<div style="background-color: red;">
+<div id="target" class='add'>
+Copy this line
+</div>
+<div>some other text</div>
+</div>
+
+Paste here:
+<div id="destination" contenteditable></div>
+
+<script>
+
+function finish() {
+ document.body.removeChild(document.querySelector('style'));
+ document.body.removeChild(target.parentNode);
+}
+
+document.body.focus();
+var target = document.getElementById('target');
+getSelection().setPosition(target, 0);
+getSelection().modify('move', 'forward', 'line');
+getSelection().modify('move', 'backward', 'lineboundary');
+getSelection().modify('extend', 'backward', 'line');
+
+if (window.layoutTestController) {
+ document.execCommand('Copy', false, null);
+ document.getElementById('destination').focus();
+ document.execCommand('Paste', false, null);
+}
+
+</script>
+</body>
+</html>
Modified: trunk/Source/WebCore/ChangeLog (104067 => 104068)
--- trunk/Source/WebCore/ChangeLog 2012-01-04 22:05:07 UTC (rev 104067)
+++ trunk/Source/WebCore/ChangeLog 2012-01-04 22:05:18 UTC (rev 104068)
@@ -1,3 +1,22 @@
+2012-01-03 Ryosuke Niwa <[email protected]>
+
+ REGRESSION (r92823): Background color not preserved when copying and pasting a table row
+ https://bugs.webkit.org/show_bug.cgi?id=75330
+
+ Reviewed by Tony Chang.
+
+ The bug was caused by the background color of the wrapping style overriding the background color
+ in a matched rule of a highest element to be serialized. Fixed the bug by removing the conflicting
+ background color prior to the merge.
+
+ Tests: editing/pasteboard/copy-element-with-conflicting-background-color-from-rule-expected.html
+ editing/pasteboard/copy-element-with-conflicting-background-color-from-rule.html
+
+ * editing/EditingStyle.cpp:
+ (WebCore::editingStyleFromComputedStyle):
+ (WebCore::EditingStyle::removeStyleAddedByNode):
+ (WebCore::EditingStyle::removeStyleConflictingWithStyleOfNode):
+
2012-01-03 Antti Koivisto <[email protected]>
Reviewed by Dave Hyatt.
Modified: trunk/Source/WebCore/dom/Element.cpp (104067 => 104068)
--- trunk/Source/WebCore/dom/Element.cpp 2012-01-04 22:05:07 UTC (rev 104067)
+++ trunk/Source/WebCore/dom/Element.cpp 2012-01-04 22:05:18 UTC (rev 104068)
@@ -706,7 +706,10 @@
void Element::recalcStyleIfNeededAfterAttributeChanged(Attribute* attr)
{
- if (document()->attached() && document()->styleSelector()->hasSelectorForAttribute(attr->name().localName()))
+ if (!needsStyleRecalc())
+ return;
+
+ if (document()->attached() && document()->styleSelectorIfExists() && document()->styleSelectorIfExists()->hasSelectorForAttribute(attr->name().localName()))
setNeedsStyleRecalc();
}
Modified: trunk/Source/WebCore/editing/EditingStyle.cpp (104067 => 104068)
--- trunk/Source/WebCore/editing/EditingStyle.cpp 2012-01-04 22:05:07 UTC (rev 104067)
+++ trunk/Source/WebCore/editing/EditingStyle.cpp 2012-01-04 22:05:18 UTC (rev 104068)
@@ -80,9 +80,11 @@
CSSPropertyWebkitTextStrokeWidth,
};
-static PassRefPtr<CSSMutableStyleDeclaration> copyEditingProperties(CSSStyleDeclaration* style, bool includeNonInheritableProperties = false)
+enum EditingPropertiesType { OnlyInheritableEditingProperties, AllEditingProperties };
+
+static PassRefPtr<CSSMutableStyleDeclaration> copyEditingProperties(CSSStyleDeclaration* style, EditingPropertiesType type = OnlyInheritableEditingProperties)
{
- if (includeNonInheritableProperties)
+ if (type == AllEditingProperties)
return style->copyPropertiesInSet(editingProperties, WTF_ARRAY_LENGTH(editingProperties));
return style->copyPropertiesInSet(editingProperties + 2, WTF_ARRAY_LENGTH(editingProperties) - 2);
}
@@ -96,11 +98,11 @@
return false;
}
-static PassRefPtr<CSSMutableStyleDeclaration> editingStyleFromComputedStyle(PassRefPtr<CSSComputedStyleDeclaration> style)
+static PassRefPtr<CSSMutableStyleDeclaration> editingStyleFromComputedStyle(PassRefPtr<CSSComputedStyleDeclaration> style, EditingPropertiesType type = OnlyInheritableEditingProperties)
{
if (!style)
return CSSMutableStyleDeclaration::create();
- return copyEditingProperties(style.get());
+ return copyEditingProperties(style.get(), type);
}
static RefPtr<CSSMutableStyleDeclaration> getPropertiesNotIn(CSSStyleDeclaration* styleWithRedundantProperties, CSSStyleDeclaration* baseStyle);
@@ -543,8 +545,8 @@
{
if (!node || !node->parentNode())
return;
- RefPtr<CSSMutableStyleDeclaration> parentStyle = editingStyleFromComputedStyle(computedStyle(node->parentNode()));
- RefPtr<CSSMutableStyleDeclaration> nodeStyle = editingStyleFromComputedStyle(computedStyle(node));
+ RefPtr<CSSMutableStyleDeclaration> parentStyle = editingStyleFromComputedStyle(computedStyle(node->parentNode()), AllEditingProperties);
+ RefPtr<CSSMutableStyleDeclaration> nodeStyle = editingStyleFromComputedStyle(computedStyle(node), AllEditingProperties);
parentStyle->diff(nodeStyle.get());
nodeStyle->diff(m_mutableStyle.get());
}
@@ -553,8 +555,9 @@
{
if (!node || !node->parentNode() || !m_mutableStyle)
return;
- RefPtr<CSSMutableStyleDeclaration> parentStyle = editingStyleFromComputedStyle(computedStyle(node->parentNode()));
- RefPtr<CSSMutableStyleDeclaration> nodeStyle = editingStyleFromComputedStyle(computedStyle(node));
+
+ RefPtr<CSSMutableStyleDeclaration> parentStyle = editingStyleFromComputedStyle(computedStyle(node->parentNode()), AllEditingProperties);
+ RefPtr<CSSMutableStyleDeclaration> nodeStyle = editingStyleFromComputedStyle(computedStyle(node), AllEditingProperties);
parentStyle->diff(nodeStyle.get());
CSSMutableStyleDeclaration::const_iterator end = nodeStyle->end();
@@ -903,8 +906,10 @@
mergeStyle(element->inlineStyleDecl(), mode);
return;
case OnlyEditingInheritableProperties:
+ mergeStyle(copyEditingProperties(element->inlineStyleDecl(), OnlyInheritableEditingProperties).get(), mode);
+ return;
case EditingPropertiesInEffect:
- mergeStyle(copyEditingProperties(element->inlineStyleDecl(), propertiesToInclude == EditingPropertiesInEffect).get(), mode);
+ mergeStyle(copyEditingProperties(element->inlineStyleDecl(), AllEditingProperties).get(), mode);
return;
}
}