WebCore:
authorjustin.garcia@apple.com <justin.garcia@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 6 Mar 2008 04:07:05 +0000 (04:07 +0000)
committerjustin.garcia@apple.com <justin.garcia@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 6 Mar 2008 04:07:05 +0000 (04:07 +0000)
        Reviewed by Darin.

        One part of fix for:
        <rdar://problem/5780697> Copying content with percentage based rules in a style sheet will cause fidelity issues

        * editing/markup.cpp:
        (WebCore::appendStartMarkup): Styles from matched rules should take precedence over those in
        inline style declarations, not the other way around.

LayoutTests:

        Reviewed by Darin.

        <rdar://problem/5780697> Copying content with CSS property values that are percentages can cause fidelity issues

        * editing/pasteboard/5780697-1-expected.txt: Added.
        * editing/pasteboard/5780697-1.html: Added.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@30820 268f45cc-cd09-0410-ab3c-d52691b4dbfc

LayoutTests/ChangeLog
LayoutTests/editing/pasteboard/5780697-1-expected.txt [new file with mode: 0644]
LayoutTests/editing/pasteboard/5780697-1.html [new file with mode: 0644]
WebCore/ChangeLog
WebCore/editing/markup.cpp

index 7b1dd526dbfdf64b72d52b4bb7fc2a0cf4d30a1b..2f2ab1471136db18e6b006e6afee6fbd8de6fe77 100644 (file)
@@ -1,3 +1,12 @@
+2008-03-05  Justin Garcia  <justin.garcia@apple.com>
+
+        Reviewed by Darin.
+        
+        <rdar://problem/5780697> Copying content with CSS property values that are percentages can cause fidelity issues
+
+        * editing/pasteboard/5780697-1-expected.txt: Added.
+        * editing/pasteboard/5780697-1.html: Added.
+
 2008-03-05  Brady Eidson  <beidson@apple.com>
 
         Reviewed by Alexey + Mark Rowe
diff --git a/LayoutTests/editing/pasteboard/5780697-1-expected.txt b/LayoutTests/editing/pasteboard/5780697-1-expected.txt
new file mode 100644 (file)
index 0000000..61bfa9b
--- /dev/null
@@ -0,0 +1,7 @@
+This tests for a copy bug where styles from matched rules would be placed on elements and take precedence over styles from their inline style declarations. When run manually, you must do a Paste. The text in the bottom region should be blue.
+
+
+<p style="color: blue;">This text</p>
+<p style="color: blue;">should be</p>
+<p style="color: blue;">blue</p>
+
diff --git a/LayoutTests/editing/pasteboard/5780697-1.html b/LayoutTests/editing/pasteboard/5780697-1.html
new file mode 100644 (file)
index 0000000..63738b4
--- /dev/null
@@ -0,0 +1,33 @@
+<html>
+<head>
+<style>
+p {
+    color: red;
+}
+</style>
+</head>
+<body>
+<div id="description">This tests for a copy bug where styles from matched rules would be placed on elements and take precedence over styles from their inline style declarations. When run manually, you must do a Paste.  The text in the bottom region should be blue.</div>
+<div id="copy" contenteditable="true">
+<p style="color: blue;">This text</p>
+<p style="color: blue;">should be</p>
+<p style="color: blue;">blue</p>
+</div>
+
+<div id="paste" contenteditable="true"></div>
+
+<script>
+copy = document.getElementById("copy");
+copy.focus();
+document.execCommand("selectall");
+document.execCommand("copy");
+paste = document.getElementById("paste");
+paste.focus();
+document.execCommand("paste");
+if (window.layoutTestController) {
+    window.layoutTestController.dumpAsText();
+    document.body.innerText = document.getElementById("description").innerText + "\n\n" + copy.innerHTML;
+}
+</script>
+</body>
+</html>
index 6eebecd52fbb6e81c3657765dc2ee3202b7376c7..a8f9d6003930b6aae1f98b12feec6b914ef3e8b2 100644 (file)
@@ -1,3 +1,14 @@
+2008-03-05  Justin Garcia  <justin.garcia@apple.com>
+
+        Reviewed by Darin.
+
+        One part of fix for:
+        <rdar://problem/5780697> Copying content with percentage based rules in a style sheet will cause fidelity issues
+
+        * editing/markup.cpp:
+        (WebCore::appendStartMarkup): Styles from matched rules should take precedence over those in
+        inline style declarations, not the other way around. 
+
 2008-03-05  Anders Carlsson  <andersca@apple.com>
 
         Reviewed by Darin.
index 4dad8ca86f0aaa09658f2685f07132b320e0989b..604f0042be3a98a64024241496cddad15af3bdc5 100644 (file)
@@ -431,7 +431,10 @@ static void appendStartMarkup(Vector<UChar>& result, const Node *node, const Ran
                 RefPtr<CSSMutableStyleDeclaration> style = static_cast<HTMLElement*>(element)->getInlineStyleDecl()->copy();
                 if (annotate) {
                     RefPtr<CSSMutableStyleDeclaration> styleFromMatchedRules = styleFromMatchedRulesForElement(const_cast<Element*>(el));
-                    style->merge(styleFromMatchedRules.get());
+                    // Styles from the inline style declaration, held in the variable "style", take precedence 
+                    // over those from matched rules.
+                    styleFromMatchedRules->merge(style.get());
+                    style = styleFromMatchedRules;
                 }
                 if (convert)
                     style->setProperty(CSS_PROP_DISPLAY, CSS_VAL_INLINE, true);