REGRESSION (r102262): iAd Producer relies on CSSStyleDeclaration property setters...
authoraestes@apple.com <aestes@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 12 Apr 2012 23:58:44 +0000 (23:58 +0000)
committeraestes@apple.com <aestes@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 12 Apr 2012 23:58:44 +0000 (23:58 +0000)
https://bugs.webkit.org/show_bug.cgi?id=83832

Reviewed by Alexey Proskuryakov.

Source/WebCore:

Shipping versions of iAd Producer rely on the pre-r102262 behavior of
respecting '!important' when specified in a CSSStyleDeclaration
property setter. Restore this quirky behavior for versions of the app
that expect it.

* WebCore.exp.in: Export
Settings::setShouldRespectPriorityInCSSAttributeSetters().
* bindings/js/JSCSSStyleDeclarationCustom.cpp:
(WebCore::JSCSSStyleDeclaration::putDelegate): If
setShouldRespectPriorityInCSSAttributeSetters() is true, restore the
pre-r102262 behavior wherein we attempt to parse '!important' out of
the property value.
* page/Settings.cpp:
(WebCore::Settings::setShouldRespectPriorityInCSSAttributeSetters):
(WebCore::Settings::shouldRespectPriorityInCSSAttributeSetters):
* page/Settings.h:

Source/WebKit/mac:

* Misc/WebKitVersionChecks.h: Indicate that 535.13.0 was the first
version of WebKit.framework to ignore '!important' in
CSSStyleDeclaration property setters.
* WebView/WebView.mm:
(shouldRespectPriorityInCSSAttributeSetters):
(-[WebView _commonInitializationWithFrameName:groupName:]): Enable a
quirk to restore pre-r102262 behavior if the application is iAd Producer
and was linked against a version of WebKit.framework that had the old behavior.

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

Source/WebCore/ChangeLog
Source/WebCore/WebCore.exp.in
Source/WebCore/bindings/js/JSCSSStyleDeclarationCustom.cpp
Source/WebCore/page/Settings.cpp
Source/WebCore/page/Settings.h
Source/WebKit/mac/ChangeLog
Source/WebKit/mac/Misc/WebKitVersionChecks.h
Source/WebKit/mac/WebView/WebView.mm

index 40a2024..18926ca 100644 (file)
@@ -1,3 +1,27 @@
+2012-04-12  Andy Estes  <aestes@apple.com>
+
+        REGRESSION (r102262): iAd Producer relies on CSSStyleDeclaration property setters respecting '!important'
+        https://bugs.webkit.org/show_bug.cgi?id=83832
+
+        Reviewed by Alexey Proskuryakov.
+
+        Shipping versions of iAd Producer rely on the pre-r102262 behavior of
+        respecting '!important' when specified in a CSSStyleDeclaration
+        property setter. Restore this quirky behavior for versions of the app
+        that expect it.
+
+        * WebCore.exp.in: Export
+        Settings::setShouldRespectPriorityInCSSAttributeSetters().
+        * bindings/js/JSCSSStyleDeclarationCustom.cpp:
+        (WebCore::JSCSSStyleDeclaration::putDelegate): If
+        setShouldRespectPriorityInCSSAttributeSetters() is true, restore the
+        pre-r102262 behavior wherein we attempt to parse '!important' out of
+        the property value.
+        * page/Settings.cpp:
+        (WebCore::Settings::setShouldRespectPriorityInCSSAttributeSetters):
+        (WebCore::Settings::shouldRespectPriorityInCSSAttributeSetters):
+        * page/Settings.h:
+
 2012-04-12  Alexandru Chiculita  <achicu@adobe.com>
 
         REGRESSION(112745) [CSS Filters] Memory use explosion for offscreen filtered elements
index d317454..b8d8d8e 100644 (file)
@@ -1048,6 +1048,7 @@ __ZN7WebCore8Settings40setJavaScriptCanOpenWindowsAutomaticallyEb
 __ZN7WebCore8Settings40setTextDirectionSubmenuInclusionBehaviorENS_37TextDirectionSubmenuInclusionBehaviorE
 __ZN7WebCore8Settings41setNeedsKeyboardEventDisambiguationQuirksEb
 __ZN7WebCore8Settings44setLoadsSiteIconsIgnoringImageLoadingSettingEb
+__ZN7WebCore8Settings45setShouldRespectPriorityInCSSAttributeSettersEb
 __ZN7WebCore8blankURLEv
 __ZN7WebCore8makeRGBAEiiii
 __ZN7WebCore8openFileERKN3WTF6StringENS_12FileOpenModeE
index bb9b44e..2c72fec 100644 (file)
@@ -34,6 +34,7 @@
 #include "JSCSSValue.h"
 #include "JSNode.h"
 #include "PlatformString.h"
+#include "Settings.h"
 #include "StylePropertySet.h"
 #include <runtime/StringPrototype.h>
 #include <wtf/ASCIICType.h>
@@ -356,8 +357,18 @@ bool JSCSSStyleDeclaration::putDelegate(ExecState* exec, const Identifier& prope
     String propValue = valueToStringWithNullCheck(exec, value);
     if (propertyInfo.hadPixelOrPosPrefix)
         propValue += "px";
+
+    bool important = false;
+    if (Settings::shouldRespectPriorityInCSSAttributeSetters()) {
+        size_t importantIndex = propValue.find("!important", 0, false);
+        if (importantIndex != notFound) {
+            important = true;
+            propValue = propValue.left(importantIndex - 1);
+        }
+    }
+
     ExceptionCode ec = 0;
-    impl()->setPropertyInternal(static_cast<CSSPropertyID>(propertyInfo.propertyID), propValue, false, ec);
+    impl()->setPropertyInternal(static_cast<CSSPropertyID>(propertyInfo.propertyID), propValue, important, ec);
     setDOMException(exec, ec);
     return true;
 }
index 47e4fff..1c71c7a 100644 (file)
@@ -92,6 +92,10 @@ bool Settings::gMockScrollbarsEnabled = false;
 #if PLATFORM(WIN) || (OS(WINDOWS) && PLATFORM(WX))
 bool Settings::gShouldUseHighResolutionTimers = true;
 #endif
+    
+#if USE(JSC)
+bool Settings::gShouldRespectPriorityInCSSAttributeSetters = false;
+#endif
 
 // NOTEs
 //  1) EditingMacBehavior comprises Tiger, Leopard, SnowLeopard and iOS builds, as well QtWebKit and Chromium when built on Mac;
@@ -893,4 +897,16 @@ bool Settings::mockScrollbarsEnabled()
     return gMockScrollbarsEnabled;
 }
 
+#if USE(JSC)
+void Settings::setShouldRespectPriorityInCSSAttributeSetters(bool flag)
+{
+    gShouldRespectPriorityInCSSAttributeSetters = flag;
+}
+
+bool Settings::shouldRespectPriorityInCSSAttributeSetters()
+{
+    return gShouldRespectPriorityInCSSAttributeSetters;
+}
+#endif
+
 } // namespace WebCore
index 5ea74ca..e13f282 100644 (file)
@@ -551,6 +551,11 @@ namespace WebCore {
 
         void setShouldRespectImageOrientation(bool enabled) { m_shouldRespectImageOrientation = enabled; }
         bool shouldRespectImageOrientation() const { return m_shouldRespectImageOrientation; }
+        
+#if USE(JSC)
+        static void setShouldRespectPriorityInCSSAttributeSetters(bool);
+        static bool shouldRespectPriorityInCSSAttributeSetters();
+#endif
 
     private:
         Settings(Page*);
@@ -724,6 +729,9 @@ namespace WebCore {
 #if PLATFORM(WIN) || (OS(WINDOWS) && PLATFORM(WX))
         static bool gShouldUseHighResolutionTimers;
 #endif
+#if USE(JSC)
+        static bool gShouldRespectPriorityInCSSAttributeSetters;
+#endif
     };
 
 } // namespace WebCore
index 58da8af..f09e978 100644 (file)
@@ -1,5 +1,21 @@
 2012-04-12  Andy Estes  <aestes@apple.com>
 
+        REGRESSION (r102262): iAd Producer relies on CSSStyleDeclaration property setters respecting '!important'
+        https://bugs.webkit.org/show_bug.cgi?id=83832
+
+        Reviewed by Alexey Proskuryakov.
+
+        * Misc/WebKitVersionChecks.h: Indicate that 535.13.0 was the first
+        version of WebKit.framework to ignore '!important' in
+        CSSStyleDeclaration property setters.
+        * WebView/WebView.mm:
+        (shouldRespectPriorityInCSSAttributeSetters):
+        (-[WebView _commonInitializationWithFrameName:groupName:]): Enable a
+        quirk to restore pre-r102262 behavior if the application is iAd Producer
+        and was linked against a version of WebKit.framework that had the old behavior.
+
+2012-04-12  Andy Estes  <aestes@apple.com>
+
         Remove unused WebKit1 SPI for suppressing incremental rendering.
         https://bugs.webkit.org/show_bug.cgi?id=83801
 
index 9d59665..a772424 100644 (file)
@@ -56,6 +56,7 @@
 #define WEBKIT_FIRST_VERSION_WITHOUT_LINK_ELEMENT_TEXT_CSS_QUIRK 0x02130200 // 531.2.0
 #define WEBKIT_FIRST_VERSION_WITH_HTML5_PARSER 0x02160900 // 534.9.0
 #define WEBKIT_FIRST_VERSION_WITH_GET_MATCHED_CSS_RULES_RESTRICTIONS 0x02160B00 // 534.11.0
+#define WEBKIT_FIRST_VERSION_WITH_CSS_ATTRIBUTE_SETTERS_IGNORING_PRIORITY 0x02170D00 // 535.13.0
 
 #ifdef __cplusplus
 extern "C" {
index 7e8dea3..4fb5df9 100644 (file)
@@ -687,6 +687,13 @@ static NSString *leakOutlookQuirksUserScriptContents()
         outlookQuirksScriptContents, KURL(), nullptr, nullptr, InjectAtDocumentEnd, InjectInAllFrames);
 }
 
+static bool shouldRespectPriorityInCSSAttributeSetters()
+{
+    static bool isIAdProducerNeedingAttributeSetterQuirk = !WebKitLinkedOnOrAfter(WEBKIT_FIRST_VERSION_WITH_CSS_ATTRIBUTE_SETTERS_IGNORING_PRIORITY)
+        && [[[NSBundle mainBundle] bundleIdentifier] isEqualToString:@"com.apple.iAdProducer"];
+    return isIAdProducerNeedingAttributeSetterQuirk;
+}
+
 - (void)_commonInitializationWithFrameName:(NSString *)frameName groupName:(NSString *)groupName
 {
     WebCoreThreadViolationCheckRoundTwo();
@@ -727,6 +734,8 @@ static NSString *leakOutlookQuirksUserScriptContents()
         // Initialize our platform strategies.
         WebPlatformStrategies::initialize();
         Settings::setDefaultMinDOMTimerInterval(0.004);
+        
+        Settings::setShouldRespectPriorityInCSSAttributeSetters(shouldRespectPriorityInCSSAttributeSetters());
 
         didOneTimeInitialization = true;
     }