2010-11-03 Tony Chang <tony@chromium.org>
authortony@chromium.org <tony@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 3 Nov 2010 18:29:56 +0000 (18:29 +0000)
committertony@chromium.org <tony@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 3 Nov 2010 18:29:56 +0000 (18:29 +0000)
        Reviewed by Ojan Vafai.

        Undo r54932 which inappropriately adjusts font sizes on zoomed pages
        https://bugs.webkit.org/show_bug.cgi?id=48890

        When copying zoomed text, we used to write to the clipboard the zoomed
        font size.  r54932 worked around this at paste time by scaling the
        font size based on the zoom.

        In r67568, Erik fixed getComputedStyle to return the original value
        rather than the zoomed font size.  This makes the work around added
        by r54932 unnecessary.

        The code in r54932 was busted in the first place since it only worked
        when in quirks mode since it didn't add units to the font size.

        * editing/inserting/page-zoom-font-size-expected.txt: Added.
        * editing/inserting/page-zoom-font-size.html: Added.
2010-11-03  Tony Chang  <tony@chromium.org>

        Reviewed by Ojan Vafai.

        Undo r54932 which inappropriately adjusts font sizes on zoomed pages
        https://bugs.webkit.org/show_bug.cgi?id=48890

        Test: editing/inserting/page-zoom-font-size.html

        * editing/ReplaceSelectionCommand.cpp:
        (WebCore::ReplaceSelectionCommand::negateStyleRulesThatAffectAppearance):

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

LayoutTests/ChangeLog
LayoutTests/editing/inserting/page-zoom-font-size-expected.txt [new file with mode: 0644]
LayoutTests/editing/inserting/page-zoom-font-size.html [new file with mode: 0644]
WebCore/ChangeLog
WebCore/editing/ReplaceSelectionCommand.cpp

index a6b7532..951121f 100644 (file)
@@ -1,3 +1,24 @@
+2010-11-03  Tony Chang  <tony@chromium.org>
+
+        Reviewed by Ojan Vafai.
+
+        Undo r54932 which inappropriately adjusts font sizes on zoomed pages
+        https://bugs.webkit.org/show_bug.cgi?id=48890
+
+        When copying zoomed text, we used to write to the clipboard the zoomed
+        font size.  r54932 worked around this at paste time by scaling the
+        font size based on the zoom.
+
+        In r67568, Erik fixed getComputedStyle to return the original value
+        rather than the zoomed font size.  This makes the work around added
+        by r54932 unnecessary.
+
+        The code in r54932 was busted in the first place since it only worked
+        when in quirks mode since it didn't add units to the font size.
+
+        * editing/inserting/page-zoom-font-size-expected.txt: Added.
+        * editing/inserting/page-zoom-font-size.html: Added.
+
 2010-11-03  Adam Roben  <aroben@apple.com>
 
         Add a plugin test that evaluates JS after removing the plugin element
 2010-11-03  Adam Roben  <aroben@apple.com>
 
         Add a plugin test that evaluates JS after removing the plugin element
diff --git a/LayoutTests/editing/inserting/page-zoom-font-size-expected.txt b/LayoutTests/editing/inserting/page-zoom-font-size-expected.txt
new file mode 100644 (file)
index 0000000..32be72d
--- /dev/null
@@ -0,0 +1,7 @@
+Test to make sure that pasting text with a font size into a quirks mode document that is zoomed does not alter the font size.
+
+Paste Here:This font is size 16px.
+Paste Here:<span style="font-size: 16px; " class="Apple-style-span">This font is size 16px.</span>
+document.compatMode: BackCompat
+PASS
+
diff --git a/LayoutTests/editing/inserting/page-zoom-font-size.html b/LayoutTests/editing/inserting/page-zoom-font-size.html
new file mode 100644 (file)
index 0000000..31371ec
--- /dev/null
@@ -0,0 +1,29 @@
+<!DOCTYPE HTML FORCE QUIRKSMODE>
+<body style="zoom: 200%">
+<p style="font-size:16px">Test to make sure that pasting text with a font size into a quirks mode
+document that is zoomed does not alter the font size.</p>
+<div contentEditable="true" id="test">Paste Here: </div>
+<div id="results"></div>
+</body>
+<script src="../editing.js"></script>
+<script>
+function editingTest()
+{
+    var target = document.getElementById("test");
+    var selection = window.getSelection();
+    selection.setPosition(target, 12);
+    document.execCommand("insertHTML", false, "<span style='font-size: 16px' class='Apple-style-span'>This font is size 16px.</span>");
+
+    var results = document.getElementById("results");
+
+    results.innerText = target.innerHTML;
+
+    results.innerHTML += "<br>document.compatMode: " + document.compatMode;
+    if (target.innerHTML.indexOf("font-size: 16px") == -1) {
+        results.innerHTML += "<br>FAIL";
+    } else
+        results.innerHTML += "<br>PASS";
+}
+
+runDumpAsTextEditingTest(false);
+</script>
index 0a1f2bb..f08d1e0 100644 (file)
@@ -1,3 +1,15 @@
+2010-11-03  Tony Chang  <tony@chromium.org>
+
+        Reviewed by Ojan Vafai.
+
+        Undo r54932 which inappropriately adjusts font sizes on zoomed pages
+        https://bugs.webkit.org/show_bug.cgi?id=48890
+
+        Test: editing/inserting/page-zoom-font-size.html
+
+        * editing/ReplaceSelectionCommand.cpp:
+        (WebCore::ReplaceSelectionCommand::negateStyleRulesThatAffectAppearance):
+
 2010-11-03  Dan Bernstein  <mitz@apple.com>
 
         Reviewed by Dave Hyatt.
 2010-11-03  Dan Bernstein  <mitz@apple.com>
 
         Reviewed by Dave Hyatt.
index 056ab70..53ab70f 100644 (file)
@@ -484,17 +484,6 @@ void ReplaceSelectionCommand::negateStyleRulesThatAffectAppearance()
                 e->getInlineStyleDecl()->setProperty(CSSPropertyDisplay, CSSValueInline);
             if (e->renderer() && e->renderer()->style()->floating() != FNONE)
                 e->getInlineStyleDecl()->setProperty(CSSPropertyFloat, CSSValueNone);
                 e->getInlineStyleDecl()->setProperty(CSSPropertyDisplay, CSSValueInline);
             if (e->renderer() && e->renderer()->style()->floating() != FNONE)
                 e->getInlineStyleDecl()->setProperty(CSSPropertyFloat, CSSValueNone);
-
-            // Undo the effects of page zoom if we have an absolute font size.  When we copy, we
-            // compute the new font size as an absolute size so pasting will cause the zoom to be
-            // applied twice.
-            if (e->renderer() && e->renderer()->style() && e->renderer()->style()->effectiveZoom() != 1.0
-                && e->renderer()->style()->fontDescription().isAbsoluteSize()) {
-                float newSize = e->renderer()->style()->fontDescription().specifiedSize() / e->renderer()->style()->effectiveZoom();
-                ExceptionCode ec = 0;
-                e->style()->setProperty(CSSPropertyFontSize, String::number(newSize), false, ec);
-                ASSERT(!ec);
-            }
         }
         if (node == m_lastLeafInserted)
             break;
         }
         if (node == m_lastLeafInserted)
             break;