Title: [102262] trunk
Revision
102262
Author
[email protected]
Date
2011-12-07 11:53:37 -0800 (Wed, 07 Dec 2011)

Log Message

        Handling of !important in inline style sets is broken
        https://bugs.webkit.org/show_bug.cgi?id=73941

        Reviewed by Dave Hyatt.

        This behavior was introduced in bug 8223 to match IE and Firefox. But it doesn't appear that we're matching
        any browser today, and CSSOM spec agrees with them.

        * WebCore.exp.in: Don't export CSSStyleDeclaration::setProperty(), no one is using it.

        * bindings/js/JSCSSStyleDeclarationCustom.cpp: (WebCore::JSCSSStyleDeclaration::putDelegate): Use regular
        setProperty(), not the incorrect version that's being removed. Properties set via IDL attributes are never
        important.

        * bindings/v8/custom/V8CSSStyleDeclarationCustom.cpp: (WebCore::V8CSSStyleDeclaration::namedPropertySetter):
        Made the same fix for v8. Why did v8 bindings authors copy/paste the code?!

        * css/CSSStyleDeclaration.cpp:
        * css/CSSStyleDeclaration.h:
        Removed a version of setProperty() that attempted to parse the value and extract !important from it.

        * html/ImageDocument.cpp:
        (WebCore::ImageDocument::resizeImageToFit):
        (WebCore::ImageDocument::restoreImageSize):
        (WebCore::ImageDocument::windowSizeChanged):
        * page/DragController.cpp:
        (WebCore::DragController::concludeEditDrag):
        We never needed to use this version of setProperty() here, it was just unnecessarily slower.

Modified Paths

Added Paths

Removed Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (102261 => 102262)


--- trunk/LayoutTests/ChangeLog	2011-12-07 19:52:01 UTC (rev 102261)
+++ trunk/LayoutTests/ChangeLog	2011-12-07 19:53:37 UTC (rev 102262)
@@ -1,3 +1,29 @@
+2011-12-07  Alexey Proskuryakov  <[email protected]>
+
+        Handling of !important in inline style sets is broken
+        https://bugs.webkit.org/show_bug.cgi?id=73941
+
+        Reviewed by Dave Hyatt.
+
+        Converted the test to text only, and reversed expectations.
+
+        * fast/dom/css-inline-style-important-expected.txt: Added.
+        * fast/dom/css-inline-style-important.html:
+        * platform/chromium-linux/fast/dom/css-inline-style-important-expected.png: Removed.
+        * platform/chromium-mac-leopard/fast/dom/css-inline-style-important-expected.png: Removed.
+        * platform/chromium-mac/fast/dom/css-inline-style-important-expected.png: Removed.
+        * platform/chromium-win/fast/dom/css-inline-style-important-expected.png: Removed.
+        * platform/chromium-win/fast/dom/css-inline-style-important-expected.txt: Removed.
+        * platform/efl/fast/dom/css-inline-style-important-expected.png: Removed.
+        * platform/efl/fast/dom/css-inline-style-important-expected.txt: Removed.
+        * platform/gtk/fast/dom/css-inline-style-important-expected.png: Removed.
+        * platform/gtk/fast/dom/css-inline-style-important-expected.txt: Removed.
+        * platform/mac-leopard/fast/dom/css-inline-style-important-expected.png: Removed.
+        * platform/mac/fast/dom/css-inline-style-important-expected.png: Removed.
+        * platform/mac/fast/dom/css-inline-style-important-expected.txt: Removed.
+        * platform/qt/fast/dom/css-inline-style-important-expected.png: Removed.
+        * platform/qt/fast/dom/css-inline-style-important-expected.txt: Removed.
+
 2011-12-07  Joshua Bell  <[email protected]>
 
         IndexedDB objectStoreNames not updated after aborted transaction

Added: trunk/LayoutTests/fast/dom/css-inline-style-important-expected.txt (0 => 102262)


--- trunk/LayoutTests/fast/dom/css-inline-style-important-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/fast/dom/css-inline-style-important-expected.txt	2011-12-07 19:53:37 UTC (rev 102262)
@@ -0,0 +1,10 @@
+This test checks to see whether setting a CSS value including !important on an inline style property fails (as it should).
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS window.getComputedStyle(e).color is "rgb(255, 0, 0)"
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
Property changes on: trunk/LayoutTests/fast/dom/css-inline-style-important-expected.txt
___________________________________________________________________

Added: svn:mime-type

Added: svn:eol-style

Modified: trunk/LayoutTests/fast/dom/css-inline-style-important.html (102261 => 102262)


--- trunk/LayoutTests/fast/dom/css-inline-style-important.html	2011-12-07 19:52:01 UTC (rev 102261)
+++ trunk/LayoutTests/fast/dom/css-inline-style-important.html	2011-12-07 19:53:37 UTC (rev 102262)
@@ -1,27 +1,24 @@
+<!DOCTYPE html>
 <html>
 <head>
+<meta charset="utf-8">
+<script src=""
 <style type="text/css">
-#e { color:red; }
+#e { color:red; visibility: hidden;}
 </style>
-<script>
-function log(message)
-{
-    var item = document.createElement("li");
-    item.appendChild(document.createTextNode(message));
-    document.getElementById("console").appendChild(item);
-}
-function test()
-{
-    var e = document.getElementById('e');
-    e.style.color = "green !important";
-}
-</script>
 </head>
-<body _onload_="test();">
-<p>This test checks to see whether setting a css value including !important on an inline style property works. The text should be green if successful.
-<hr>
+<body>
 <p id="e">This is the test element.</p>
-<hr>
-<ol id="console"></ol>
+<script>
+
+description("This test checks to see whether setting a CSS value including !important on an inline style property fails (as it should).");
+
+var e = document.getElementById('e');
+e.style.color = "green !important";
+
+shouldBe('window.getComputedStyle(e).color', '"rgb(255, 0, 0)"');
+
+</script>
+<script src=""
 </body>
 </html>

Deleted: trunk/LayoutTests/platform/chromium-linux/fast/dom/css-inline-style-important-expected.png


(Binary files differ)

Deleted: trunk/LayoutTests/platform/chromium-mac/fast/dom/css-inline-style-important-expected.png


(Binary files differ)

Deleted: trunk/LayoutTests/platform/chromium-mac-leopard/fast/dom/css-inline-style-important-expected.png


(Binary files differ)

Deleted: trunk/LayoutTests/platform/chromium-win/fast/dom/css-inline-style-important-expected.png


(Binary files differ)

Deleted: trunk/LayoutTests/platform/chromium-win/fast/dom/css-inline-style-important-expected.txt (102261 => 102262)


--- trunk/LayoutTests/platform/chromium-win/fast/dom/css-inline-style-important-expected.txt	2011-12-07 19:52:01 UTC (rev 102261)
+++ trunk/LayoutTests/platform/chromium-win/fast/dom/css-inline-style-important-expected.txt	2011-12-07 19:53:37 UTC (rev 102262)
@@ -1,15 +0,0 @@
-layer at (0,0) size 800x600
-  RenderView at (0,0) size 800x600
-layer at (0,0) size 800x600
-  RenderBlock {HTML} at (0,0) size 800x600
-    RenderBody {BODY} at (8,8) size 784x576
-      RenderBlock {P} at (0,0) size 784x40
-        RenderText {#text} at (0,0) size 777x39
-          text run at (0,0) width 777: "This test checks to see whether setting a css value including !important on an inline style property works. The text should be green"
-          text run at (0,20) width 75: "if successful."
-      RenderBlock {HR} at (0,56) size 784x2 [border: (1px inset #000000)]
-      RenderBlock {P} at (0,74) size 784x20 [color=#008000]
-        RenderText {#text} at (0,0) size 139x19
-          text run at (0,0) width 139: "This is the test element."
-      RenderBlock {HR} at (0,110) size 784x2 [border: (1px inset #000000)]
-      RenderBlock {OL} at (0,128) size 784x0

Deleted: trunk/LayoutTests/platform/efl/fast/dom/css-inline-style-important-expected.png


(Binary files differ)

Deleted: trunk/LayoutTests/platform/efl/fast/dom/css-inline-style-important-expected.txt (102261 => 102262)


--- trunk/LayoutTests/platform/efl/fast/dom/css-inline-style-important-expected.txt	2011-12-07 19:52:01 UTC (rev 102261)
+++ trunk/LayoutTests/platform/efl/fast/dom/css-inline-style-important-expected.txt	2011-12-07 19:53:37 UTC (rev 102262)
@@ -1,15 +0,0 @@
-layer at (0,0) size 800x600
-  RenderView at (0,0) size 800x600
-layer at (0,0) size 800x600
-  RenderBlock {HTML} at (0,0) size 800x600
-    RenderBody {BODY} at (8,8) size 784x576
-      RenderBlock {P} at (0,0) size 784x38
-        RenderText {#text} at (0,0) size 780x38
-          text run at (0,0) width 780: "This test checks to see whether setting a css value including !important on an inline style property works. The text should be"
-          text run at (0,19) width 120: "green if successful."
-      RenderBlock {HR} at (0,54) size 784x2 [border: (1px inset #000000)]
-      RenderBlock {P} at (0,72) size 784x19 [color=#008000]
-        RenderText {#text} at (0,0) size 147x19
-          text run at (0,0) width 147: "This is the test element."
-      RenderBlock {HR} at (0,107) size 784x2 [border: (1px inset #000000)]
-      RenderBlock {OL} at (0,125) size 784x0

Deleted: trunk/LayoutTests/platform/gtk/fast/dom/css-inline-style-important-expected.png


(Binary files differ)

Deleted: trunk/LayoutTests/platform/gtk/fast/dom/css-inline-style-important-expected.txt (102261 => 102262)


--- trunk/LayoutTests/platform/gtk/fast/dom/css-inline-style-important-expected.txt	2011-12-07 19:52:01 UTC (rev 102261)
+++ trunk/LayoutTests/platform/gtk/fast/dom/css-inline-style-important-expected.txt	2011-12-07 19:53:37 UTC (rev 102262)
@@ -1,15 +0,0 @@
-layer at (0,0) size 800x600
-  RenderView at (0,0) size 800x600
-layer at (0,0) size 800x600
-  RenderBlock {HTML} at (0,0) size 800x600
-    RenderBody {BODY} at (8,8) size 784x576
-      RenderBlock {P} at (0,0) size 784x36
-        RenderText {#text} at (0,0) size 778x35
-          text run at (0,0) width 778: "This test checks to see whether setting a css value including !important on an inline style property works. The text should"
-          text run at (0,18) width 143: "be green if successful."
-      RenderBlock {HR} at (0,52) size 784x2 [border: (1px inset #000000)]
-      RenderBlock {P} at (0,70) size 784x18 [color=#008000]
-        RenderText {#text} at (0,0) size 152x17
-          text run at (0,0) width 152: "This is the test element."
-      RenderBlock {HR} at (0,104) size 784x2 [border: (1px inset #000000)]
-      RenderBlock {OL} at (0,122) size 784x0

Deleted: trunk/LayoutTests/platform/mac/fast/dom/css-inline-style-important-expected.png


(Binary files differ)

Deleted: trunk/LayoutTests/platform/mac/fast/dom/css-inline-style-important-expected.txt (102261 => 102262)


--- trunk/LayoutTests/platform/mac/fast/dom/css-inline-style-important-expected.txt	2011-12-07 19:52:01 UTC (rev 102261)
+++ trunk/LayoutTests/platform/mac/fast/dom/css-inline-style-important-expected.txt	2011-12-07 19:53:37 UTC (rev 102262)
@@ -1,15 +0,0 @@
-layer at (0,0) size 800x600
-  RenderView at (0,0) size 800x600
-layer at (0,0) size 800x600
-  RenderBlock {HTML} at (0,0) size 800x600
-    RenderBody {BODY} at (8,8) size 784x576
-      RenderBlock {P} at (0,0) size 784x36
-        RenderText {#text} at (0,0) size 780x36
-          text run at (0,0) width 780: "This test checks to see whether setting a css value including !important on an inline style property works. The text should be"
-          text run at (0,18) width 120: "green if successful."
-      RenderBlock {HR} at (0,52) size 784x2 [border: (1px inset #000000)]
-      RenderBlock {P} at (0,70) size 784x18 [color=#008000]
-        RenderText {#text} at (0,0) size 147x18
-          text run at (0,0) width 147: "This is the test element."
-      RenderBlock {HR} at (0,104) size 784x2 [border: (1px inset #000000)]
-      RenderBlock {OL} at (0,122) size 784x0

Deleted: trunk/LayoutTests/platform/mac-leopard/fast/dom/css-inline-style-important-expected.png


(Binary files differ)

Deleted: trunk/LayoutTests/platform/qt/fast/dom/css-inline-style-important-expected.png


(Binary files differ)

Deleted: trunk/LayoutTests/platform/qt/fast/dom/css-inline-style-important-expected.txt (102261 => 102262)


--- trunk/LayoutTests/platform/qt/fast/dom/css-inline-style-important-expected.txt	2011-12-07 19:52:01 UTC (rev 102261)
+++ trunk/LayoutTests/platform/qt/fast/dom/css-inline-style-important-expected.txt	2011-12-07 19:53:37 UTC (rev 102262)
@@ -1,15 +0,0 @@
-layer at (0,0) size 800x600
-  RenderView at (0,0) size 800x600
-layer at (0,0) size 800x600
-  RenderBlock {HTML} at (0,0) size 800x600
-    RenderBody {BODY} at (8,8) size 784x576
-      RenderBlock {P} at (0,0) size 784x42
-        RenderText {#text} at (0,0) size 768x42
-          text run at (0,0) width 768: "This test checks to see whether setting a css value including !important on an inline style property works. The"
-          text run at (0,21) width 239: "text should be green if successful."
-      RenderBlock {HR} at (0,58) size 784x2 [border: (1px inset #000000)]
-      RenderBlock {P} at (0,76) size 784x21 [color=#008000]
-        RenderText {#text} at (0,0) size 167x21
-          text run at (0,0) width 167: "This is the test element."
-      RenderBlock {HR} at (0,113) size 784x2 [border: (1px inset #000000)]
-      RenderBlock {OL} at (0,131) size 784x0

Modified: trunk/Source/WebCore/ChangeLog (102261 => 102262)


--- trunk/Source/WebCore/ChangeLog	2011-12-07 19:52:01 UTC (rev 102261)
+++ trunk/Source/WebCore/ChangeLog	2011-12-07 19:53:37 UTC (rev 102262)
@@ -1,3 +1,34 @@
+2011-12-07  Alexey Proskuryakov  <[email protected]>
+
+        Handling of !important in inline style sets is broken
+        https://bugs.webkit.org/show_bug.cgi?id=73941
+
+        Reviewed by Dave Hyatt.
+
+        This behavior was introduced in bug 8223 to match IE and Firefox. But it doesn't appear that we're matching
+        any browser today, and CSSOM spec agrees with them.
+
+        * WebCore.exp.in: Don't export CSSStyleDeclaration::setProperty(), no one is using it.
+
+        * bindings/js/JSCSSStyleDeclarationCustom.cpp: (WebCore::JSCSSStyleDeclaration::putDelegate): Use regular
+        setProperty(), not the incorrect version that's being removed. Properties set via IDL attributes are never
+        important.
+
+        * bindings/v8/custom/V8CSSStyleDeclarationCustom.cpp: (WebCore::V8CSSStyleDeclaration::namedPropertySetter):
+        Made the same fix for v8. Why did v8 bindings authors copy/paste the code?!
+
+        * css/CSSStyleDeclaration.cpp:
+        * css/CSSStyleDeclaration.h:
+        Removed a version of setProperty() that attempted to parse the value and extract !important from it.
+
+        * html/ImageDocument.cpp:
+        (WebCore::ImageDocument::resizeImageToFit):
+        (WebCore::ImageDocument::restoreImageSize):
+        (WebCore::ImageDocument::windowSizeChanged):
+        * page/DragController.cpp:
+        (WebCore::DragController::concludeEditDrag):
+        We never needed to use this version of setProperty() here, it was just unnecessarily slower.
+
 2011-12-07  Xianzhu Wang  <[email protected]>
 
         In FontCacheAndroid.cpp should keep the pointer valid returned from CString::data()

Modified: trunk/Source/WebCore/WebCore.exp.in (102261 => 102262)


--- trunk/Source/WebCore/WebCore.exp.in	2011-12-07 19:52:01 UTC (rev 102261)
+++ trunk/Source/WebCore/WebCore.exp.in	2011-12-07 19:53:37 UTC (rev 102262)
@@ -567,7 +567,6 @@
 __ZN7WebCore19BackForwardListImpl8capacityEv
 __ZN7WebCore19BackForwardListImpl9goForwardEv
 __ZN7WebCore19BackForwardListImplC1EPNS_4PageE
-__ZN7WebCore19CSSStyleDeclaration11setPropertyERKN3WTF6StringES4_Ri
 __ZN7WebCore19LayerFlushScheduler10invalidateEv
 __ZN7WebCore19LayerFlushScheduler6resumeEv
 __ZN7WebCore19LayerFlushScheduler7suspendEv

Modified: trunk/Source/WebCore/bindings/js/JSCSSStyleDeclarationCustom.cpp (102261 => 102262)


--- trunk/Source/WebCore/bindings/js/JSCSSStyleDeclarationCustom.cpp	2011-12-07 19:52:01 UTC (rev 102261)
+++ trunk/Source/WebCore/bindings/js/JSCSSStyleDeclarationCustom.cpp	2011-12-07 19:53:37 UTC (rev 102262)
@@ -176,7 +176,7 @@
     if (pixelOrPos)
         propValue += "px";
     ExceptionCode ec = 0;
-    impl()->setProperty(prop, propValue, ec);
+    impl()->setProperty(prop, propValue, emptyString(), ec);
     setDOMException(exec, ec);
     return true;
 }

Modified: trunk/Source/WebCore/bindings/v8/custom/V8CSSStyleDeclarationCustom.cpp (102261 => 102262)


--- trunk/Source/WebCore/bindings/v8/custom/V8CSSStyleDeclarationCustom.cpp	2011-12-07 19:52:01 UTC (rev 102261)
+++ trunk/Source/WebCore/bindings/v8/custom/V8CSSStyleDeclarationCustom.cpp	2011-12-07 19:53:37 UTC (rev 102262)
@@ -203,13 +203,7 @@
         propertyValue.append("px");
 
     ExceptionCode ec = 0;
-    int importantIndex = propertyValue.find("!important", 0, false);
-    bool important = false;
-    if (importantIndex != -1) {
-        important = true;
-        propertyValue = propertyValue.left(importantIndex - 1);
-    }
-    imp->setProperty(propInfo->propID, propertyValue, important, ec);
+    imp->setProperty(propInfo->propID, propertyValue, false, ec);
 
     if (ec)
         throwError(ec);

Modified: trunk/Source/WebCore/css/CSSStyleDeclaration.cpp (102261 => 102262)


--- trunk/Source/WebCore/css/CSSStyleDeclaration.cpp	2011-12-07 19:52:01 UTC (rev 102261)
+++ trunk/Source/WebCore/css/CSSStyleDeclaration.cpp	2011-12-07 19:53:37 UTC (rev 102262)
@@ -101,18 +101,6 @@
     return isPropertyImplicit(propID);
 }
 
-void CSSStyleDeclaration::setProperty(const String& propertyName, const String& value, ExceptionCode& ec)
-{
-    size_t important = value.find("!important", 0, false);
-    int propertyID = cssPropertyID(propertyName);
-    if (!propertyID)
-        return;
-    if (important == notFound)
-        setProperty(propertyID, value, false, ec);
-    else
-        setProperty(propertyID, value.left(important - 1), true, ec);
-}
-
 void CSSStyleDeclaration::setProperty(const String& propertyName, const String& value, const String& priority, ExceptionCode& ec)
 {
     int propID = cssPropertyID(propertyName);

Modified: trunk/Source/WebCore/css/CSSStyleDeclaration.h (102261 => 102262)


--- trunk/Source/WebCore/css/CSSStyleDeclaration.h	2011-12-07 19:52:01 UTC (rev 102261)
+++ trunk/Source/WebCore/css/CSSStyleDeclaration.h	2011-12-07 19:53:37 UTC (rev 102262)
@@ -65,7 +65,6 @@
     virtual int getPropertyShorthand(int propertyID) const = 0;
     virtual bool isPropertyImplicit(int propertyID) const = 0;
 
-    void setProperty(const String& propertyName, const String& value, ExceptionCode&);
     void setProperty(const String& propertyName, const String& value, const String& priority, ExceptionCode&);
     String removeProperty(const String& propertyName, ExceptionCode&);
     virtual void setProperty(int propertyId, const String& value, bool important, ExceptionCode&) = 0;

Modified: trunk/Source/WebCore/html/ImageDocument.cpp (102261 => 102262)


--- trunk/Source/WebCore/html/ImageDocument.cpp	2011-12-07 19:52:01 UTC (rev 102261)
+++ trunk/Source/WebCore/html/ImageDocument.cpp	2011-12-07 19:53:37 UTC (rev 102262)
@@ -254,7 +254,7 @@
     m_imageElement->setHeight(static_cast<int>(imageSize.height() * scale));
     
     ExceptionCode ec;
-    m_imageElement->style()->setProperty("cursor", "-webkit-zoom-in", ec);
+    m_imageElement->style()->setProperty(CSSPropertyCursor, "-webkit-zoom-in", false, ec);
 }
 
 void ImageDocument::imageClicked(int x, int y)
@@ -309,9 +309,9 @@
     
     ExceptionCode ec;
     if (imageFitsInWindow())
-        m_imageElement->style()->removeProperty("cursor", ec);
+        m_imageElement->style()->removeProperty(CSSPropertyCursor, ec);
     else
-        m_imageElement->style()->setProperty("cursor", "-webkit-zoom-out", ec);
+        m_imageElement->style()->setProperty(CSSPropertyCursor, "-webkit-zoom-out", false, ec);
         
     m_didShrinkImage = false;
 }
@@ -344,9 +344,9 @@
         ExceptionCode ec;
         
         if (fitsInWindow)
-            m_imageElement->style()->removeProperty("cursor", ec);
+            m_imageElement->style()->removeProperty(CSSPropertyCursor, ec);
         else
-            m_imageElement->style()->setProperty("cursor", "-webkit-zoom-out", ec);
+            m_imageElement->style()->setProperty(CSSPropertyCursor, "-webkit-zoom-out", false, ec);
         return;
     }
     

Modified: trunk/Source/WebCore/page/DragController.cpp (102261 => 102262)


--- trunk/Source/WebCore/page/DragController.cpp	2011-12-07 19:52:01 UTC (rev 102261)
+++ trunk/Source/WebCore/page/DragController.cpp	2011-12-07 19:53:37 UTC (rev 102262)
@@ -440,7 +440,7 @@
         RefPtr<Range> innerRange = innerFrame->selection()->toNormalizedRange();
         RefPtr<CSSStyleDeclaration> style = m_documentUnderMouse->createCSSStyleDeclaration();
         ExceptionCode ec;
-        style->setProperty("color", color.serialized(), ec);
+        style->setProperty(CSSPropertyColor, color.serialized(), false, ec);
         if (!innerFrame->editor()->shouldApplyStyle(style.get(), innerRange.get()))
             return false;
         m_client->willPerformDragDestinationAction(DragDestinationActionEdit, dragData);
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to