JavaScriptCore:
authorggaren <ggaren@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 21 Jul 2006 18:50:24 +0000 (18:50 +0000)
committerggaren <ggaren@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 21 Jul 2006 18:50:24 +0000 (18:50 +0000)
        Reviewed by Darin.

        - Added support for strings that masquerade as undefined. Currently used
        by WebCore to implement undetectable style.filter.

        The name is a little long, but it's only used in one line of code, so I
        thought clarity should win over brevity.

        * JavaScriptCore.exp:
        * JavaScriptCore.xcodeproj/project.pbxproj:
        * kjs/object.h:
        * kjs/string_object.h:
        (KJS::StringInstanceThatMasqueradesAsUndefined::StringInstanceThatMasqueradesAsUndefined):
        (KJS::StringInstanceThatMasqueradesAsUndefined::masqueradeAsUndefined):
        (KJS::StringInstanceThatMasqueradesAsUndefined::toBoolean):

LayoutTests:

        Test for undetectable style.filter property.

        * fast/dom/undetectable-style-filter-expected.txt: Added.
        * fast/dom/undetectable-style-filter.html: Added.

WebCore:

        Reviewed by Darin.

        - Fixed <rdar://problem/4507265> REGRESSION: overlays don't work on
        HousingMaps.com (Google Maps-based site)

        - Made style.filter undetectable, like document.all.

        Unfortunately, the SVG spec-makers invented a CSS attribute named 'filter',
        which conflicts with IE's custom CSS attribute by the same name. Web programs
        like the Google maps API test for style.filter, and assume it's the IE
        style.filter if they find it, so we need to make style.filter undetectable
        to avoid breaking them.

        An alternative solution would be to hotwire a delorean, go back in time,
        and beg the web standards makers to make standards that work on the web.

        * bindings/js/kjs_css.cpp:
        (KJS::DOMCSSStyleDeclaration::cssPropertyGetter):

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

JavaScriptCore/ChangeLog
JavaScriptCore/JavaScriptCore.exp
JavaScriptCore/kjs/object.h
JavaScriptCore/kjs/string_object.h
LayoutTests/ChangeLog
LayoutTests/fast/dom/undetectable-style-filter-expected.txt [new file with mode: 0644]
LayoutTests/fast/dom/undetectable-style-filter.html [new file with mode: 0644]
WebCore/ChangeLog
WebCore/ForwardingHeaders/kjs/string_object.h [new file with mode: 0644]
WebCore/bindings/js/kjs_css.cpp

index 84d3765f14466c5dcc5d52557b1e3f5614d13a28..f910b38871360339f515bc1b4f47dc327186ef3f 100644 (file)
@@ -1,3 +1,21 @@
+2006-07-21  Geoffrey Garen  <ggaren@apple.com>
+
+        Reviewed by Darin.
+
+        - Added support for strings that masquerade as undefined. Currently used
+        by WebCore to implement undetectable style.filter.
+        
+        The name is a little long, but it's only used in one line of code, so I
+        thought clarity should win over brevity.
+
+        * JavaScriptCore.exp:
+        * JavaScriptCore.xcodeproj/project.pbxproj:
+        * kjs/object.h:
+        * kjs/string_object.h:
+        (KJS::StringInstanceThatMasqueradesAsUndefined::StringInstanceThatMasqueradesAsUndefined):
+        (KJS::StringInstanceThatMasqueradesAsUndefined::masqueradeAsUndefined):
+        (KJS::StringInstanceThatMasqueradesAsUndefined::toBoolean):
+
 2006-07-20  Steve Falkenburg  <sfalken@apple.com>
 
         Fix the build
index cbdcb2eccfe940638f18625055b7aa2fe2de66b7..d1413bff940e2de04f337a1d825393493915d239 100644 (file)
@@ -1,3 +1,4 @@
+
 _JSCheckScriptSyntax
 _JSClassCreate
 _JSClassRelease
@@ -143,6 +144,13 @@ __ZN3KJS12PropertySlot15undefinedGetterEPNS_9ExecStateEPNS_8JSObjectERKNS_10Iden
 __ZN3KJS12jsNumberCellEd
 __ZN3KJS13SavedBuiltinsC1Ev
 __ZN3KJS13SavedBuiltinsD1Ev
+__ZN3KJS14StringInstance14deletePropertyEPNS_9ExecStateERKNS_10IdentifierE
+__ZN3KJS14StringInstance16getPropertyNamesEPNS_9ExecStateERNS_17PropertyNameArrayE
+__ZN3KJS14StringInstance18getOwnPropertySlotEPNS_9ExecStateERKNS_10IdentifierERNS_12PropertySlotE
+__ZN3KJS14StringInstance3putEPNS_9ExecStateERKNS_10IdentifierEPNS_7JSValueEi
+__ZN3KJS14StringInstance4infoE
+__ZN3KJS14StringInstanceC1EPNS_8JSObjectERKNS_7UStringE
+__ZN3KJS14StringInstanceC2EPNS_8JSObjectERKNS_7UStringE
 __ZN3KJS15SavedPropertiesC1Ev
 __ZN3KJS15SavedPropertiesD1Ev
 __ZN3KJS16RuntimeObjectImp4infoE
@@ -222,6 +230,7 @@ __ZNK3KJS11Interpreter12globalObjectEv
 __ZNK3KJS11Interpreter12saveBuiltinsERNS_13SavedBuiltinsE
 __ZNK3KJS11Interpreter15builtinFunctionEv
 __ZNK3KJS11Interpreter22builtinObjectPrototypeEv
+__ZNK3KJS11Interpreter22builtinStringPrototypeEv
 __ZNK3KJS11Interpreter24builtinFunctionPrototypeEv
 __ZNK3KJS11PropertyMap3getERKNS_10IdentifierE
 __ZNK3KJS11PropertyMap4saveERNS_15SavedPropertiesE
@@ -259,6 +268,7 @@ __ZNK3KJS8JSObject9classInfoEv
 __ZNK3KJS8JSObject9classNameEv
 __ZNK3KJS8JSObject9toBooleanEPNS_9ExecStateE
 __ZNK3KJS9ExecState18lexicalInterpreterEv
+__ZTVN3KJS14StringInstanceE
 __ZTVN3KJS19InternalFunctionImpE
 __ZTVN3KJS8JSObjectE
 _kJSClassDefinitionEmpty
index b8306318e316c67f485e9b421715c1dbceb5240b..6a05fa74e6c39c61962b1f2715f222e479bc07ae 100644 (file)
@@ -470,7 +470,7 @@ namespace KJS {
     
     bool getPropertyAttributes(const Identifier& propertyName, unsigned& attributes) const;
     
-    // Returns whether the object should be treated as undefined when doing equality comparisons
+    // WebCore uses this to make document.all and style.filter undetectable
     virtual bool masqueradeAsUndefined() const { return false; }
     
     // This get function only looks at the property map.
index a4e208ad7d26a2e11fc8796983b6cc97e4ffebef..afa214b009c10c63a14b168fbdc89358eb191820 100644 (file)
@@ -43,6 +43,15 @@ namespace KJS {
     static JSValue *indexGetter(ExecState *exec, JSObject *, const Identifier&, const PropertySlot &slot);
   };
 
+  // WebCore uses this to make style.filter undetectable
+  class StringInstanceThatMasqueradesAsUndefined : public StringInstance {
+  public:
+      StringInstanceThatMasqueradesAsUndefined(JSObject* proto, const UString& string)
+          : StringInstance(proto, string) { }
+      virtual bool masqueradeAsUndefined() const { return true; }
+      virtual bool toBoolean(ExecState*) const { return false; }
+  };
+
   /**
    * @internal
    *
index c3be3b090ddea5a6ed7c80e76b27750c45bacc1d..ec51531b0e6f6624475628b327f92b821b086175 100644 (file)
@@ -1,3 +1,10 @@
+2006-07-21  Geoffrey Garen  <ggaren@apple.com>
+
+        Test for undetectable style.filter property.
+
+        * fast/dom/undetectable-style-filter-expected.txt: Added.
+        * fast/dom/undetectable-style-filter.html: Added.
+
 2006-07-21  Justin Garcia  <justin.garcia@apple.com>
 
         Reviewed by john
diff --git a/LayoutTests/fast/dom/undetectable-style-filter-expected.txt b/LayoutTests/fast/dom/undetectable-style-filter-expected.txt
new file mode 100644 (file)
index 0000000..a6e1f22
--- /dev/null
@@ -0,0 +1,6 @@
+This page tests whether the CSS 'filter' property is undetectable. If the test passes, you'll see a series of 'PASS' messages below.
+
+PASS: typeof document.body.style.filter should be undefined and is.
+PASS: document.body.style.filter ? true : false should be false and is.
+PASS: document.body.style.filter == undefined should be true and is.
+
diff --git a/LayoutTests/fast/dom/undetectable-style-filter.html b/LayoutTests/fast/dom/undetectable-style-filter.html
new file mode 100644 (file)
index 0000000..0e5a7ee
--- /dev/null
@@ -0,0 +1,48 @@
+<html>
+<head>
+<script>
+function print(message, color) 
+{
+    var paragraph = document.createElement("div");
+    paragraph.appendChild(document.createTextNode(message));
+    paragraph.style.fontFamily = "monospace";
+    if (color)
+        paragraph.style.color = color;
+    document.getElementById("console").appendChild(paragraph);
+}
+
+function shouldBe(a, b)
+{
+    var evalA;
+    try {
+        evalA = eval(a);
+    } catch(e) {
+        evalA = e;
+    }
+    
+    if (evalA == b)
+        print("PASS: " + a + " should be " + b + " and is.", "green");
+    else
+        print("FAIL: " + a + " should be " + b + " but instead is " + evalA + ".", "red");
+}
+
+function test() 
+{
+    if (window.layoutTestController)
+        layoutTestController.dumpAsText();
+    
+    shouldBe("typeof document.body.style.filter", "undefined");
+    shouldBe("document.body.style.filter ? true : false", false);
+    shouldBe("document.body.style.filter == undefined", true);
+}
+</script>
+</head>
+
+<body onload="test();">
+<p>This page tests whether the CSS 'filter' property is undetectable. If the test passes, you'll see a series of 'PASS' messages below.</p>
+<hr>
+
+<div id='console'></div>
+
+</body>
+</html>
index f9920a71e052f74d130534cdd0058b536c42a15d..974d86ab5bf6facd24ea941d9599a76c53fa2bfe 100644 (file)
@@ -1,3 +1,24 @@
+2006-07-21  Geoffrey Garen  <ggaren@apple.com>
+
+        Reviewed by Darin.
+        
+        - Fixed <rdar://problem/4507265> REGRESSION: overlays don't work on 
+        HousingMaps.com (Google Maps-based site)
+        
+        - Made style.filter undetectable, like document.all.
+        
+        Unfortunately, the SVG spec-makers invented a CSS attribute named 'filter',
+        which conflicts with IE's custom CSS attribute by the same name. Web programs 
+        like the Google maps API test for style.filter, and assume it's the IE 
+        style.filter if they find it, so we need to make style.filter undetectable 
+        to avoid breaking them.
+        
+        An alternative solution would be to hotwire a delorean, go back in time,
+        and beg the web standards makers to make standards that work on the web.
+
+        * bindings/js/kjs_css.cpp:
+        (KJS::DOMCSSStyleDeclaration::cssPropertyGetter):
+
 2006-07-20  Justin Garcia  <justin.garcia@apple.com>
 
         Reviewed by john
diff --git a/WebCore/ForwardingHeaders/kjs/string_object.h b/WebCore/ForwardingHeaders/kjs/string_object.h
new file mode 100644 (file)
index 0000000..26f026a
--- /dev/null
@@ -0,0 +1 @@
+#include <JavaScriptCore/string_object.h>
index 5435b6c43a1744bde916e212d805bec2079d6e42..59fcb3e1cc89d631ee42c386f8d4a99ace719166 100644 (file)
@@ -45,6 +45,8 @@
 #include "StyleSheetList.h"
 #include "kjs_dom.h"
 
+#include <kjs/string_object.h>
+
 #include "kjs_css.lut.h"
 
 using namespace WebCore;
@@ -146,8 +148,14 @@ JSValue* DOMCSSStyleDeclaration::cssPropertyGetter(ExecState* exec, JSObject* or
       return jsNumber(static_pointer_cast<CSSPrimitiveValue>(v)->getFloatValue(CSSPrimitiveValue::CSS_PX));
     return jsStringOrNull(v->cssText());
   }
+
   // If the property is a shorthand property (such as "padding"), 
   // it can only be accessed using getPropertyValue.
+  
+  // Make the SVG 'filter' attribute undetectable, to avoid confusion with the IE 'filter' attribute.
+  if (propertyName == "filter")
+      return new StringInstanceThatMasqueradesAsUndefined(exec->lexicalInterpreter()->builtinStringPrototype(), thisObj->m_impl->getPropertyValue(prop));
+
   return jsString(thisObj->m_impl->getPropertyValue(prop));
 }