[webkit-changes] cvs commit: WebCore/khtml/ecma kjs_html.cpp
kjs_html.h
Anders
andersca at opensource.apple.com
Thu Dec 29 00:20:38 PST 2005
andersca 05/12/29 00:20:38
Modified: . ChangeLog
khtml/ecma kjs_html.cpp kjs_html.h
Log:
2005-12-28 Anders Carlsson <andersca at mac.com>
Reviewed by Maciej.
- Fix http://bugzilla.opendarwin.org/show_bug.cgi?id=6268
Add undetectable document.all
* khtml/ecma/kjs_html.cpp:
(KJS::HTMLDocument::getValueProperty):
If "all" has been set to a new value, return the new value.
(KJS::KJS::HTMLDocument::putValueProperty):
Allow "all" to be set to a new value.
(KJS::HTMLAllCollection::toPrimitive):
Return jsNull() if the preferred type is NullType.
(KJS::getAllHTMLCollection):
* khtml/ecma/kjs_html.h:
(KJS::HTMLAllCollection::HTMLAllCollection):
Add HTMLAllCollection, a subclass of HTMLCollection which should
be undetectable.
(KJS::HTMLAllCollection::toBoolean):
Return false.
Revision Changes Path
1.52 +26 -0 WebCore/ChangeLog
Index: ChangeLog
===================================================================
RCS file: /cvs/root/WebCore/ChangeLog,v
retrieving revision 1.51
retrieving revision 1.52
diff -u -r1.51 -r1.52
--- ChangeLog 28 Dec 2005 18:59:50 -0000 1.51
+++ ChangeLog 29 Dec 2005 08:20:36 -0000 1.52
@@ -1,3 +1,29 @@
+2005-12-28 Anders Carlsson <andersca at mac.com>
+
+ Reviewed by Maciej.
+
+ - Fix http://bugzilla.opendarwin.org/show_bug.cgi?id=6268
+ Add undetectable document.all
+
+ * khtml/ecma/kjs_html.cpp:
+ (KJS::HTMLDocument::getValueProperty):
+ If "all" has been set to a new value, return the new value.
+
+ (KJS::KJS::HTMLDocument::putValueProperty):
+ Allow "all" to be set to a new value.
+
+ (KJS::HTMLAllCollection::toPrimitive):
+ Return jsNull() if the preferred type is NullType.
+
+ (KJS::getAllHTMLCollection):
+ * khtml/ecma/kjs_html.h:
+ (KJS::HTMLAllCollection::HTMLAllCollection):
+ Add HTMLAllCollection, a subclass of HTMLCollection which should
+ be undetectable.
+
+ (KJS::HTMLAllCollection::toBoolean):
+ Return false.
+
2005-12-28 Mitz Pettel <opendarwin.org at mitzpettel.com>
Reviewed by Eric, landed by ap.
1.161 +24 -10 WebCore/khtml/ecma/kjs_html.cpp
Index: kjs_html.cpp
===================================================================
RCS file: /cvs/root/WebCore/khtml/ecma/kjs_html.cpp,v
retrieving revision 1.160
retrieving revision 1.161
diff -u -r1.160 -r1.161
--- kjs_html.cpp 24 Dec 2005 22:45:58 -0000 1.160
+++ kjs_html.cpp 29 Dec 2005 08:20:37 -0000 1.161
@@ -224,12 +224,7 @@
forms HTMLDocument::Forms DontDelete|ReadOnly
anchors HTMLDocument::Anchors DontDelete|ReadOnly
scripts HTMLDocument::Scripts DontDelete|ReadOnly
-# We want no document.all at all, not just a function that returns undefined.
-# That means we lose the "document.all when spoofing as IE" feature, but we don't spoof in Safari.
-# And this makes sites that set document.all explicitly work when they otherwise wouldn't,
-# e.g. https://corporateexchange.airborne.com
-# (Not in APPLE_CHANGES since we can't do #if in KJS identifier lists.)
-# all HTMLDocument::All DontDelete|ReadOnly
+ all HTMLDocument::All
clear HTMLDocument::Clear DontDelete|Function 0
open HTMLDocument::Open DontDelete|Function 0
close HTMLDocument::Close DontDelete|Function 0
@@ -332,10 +327,11 @@
return obj;
}
case All:
- // Disable document.all when we try to be Netscape-compatible
- if (exec->dynamicInterpreter()->compatMode() == Interpreter::NetscapeCompat)
- return jsUndefined();
- return getHTMLCollection(exec, doc.all().get());
+ // If "all" has been overwritten, return the overwritten value
+ if (JSValue *v = getDirect("all"))
+ return v;
+ else
+ return getAllHTMLCollection(exec, doc.all().get());
case BgColor:
if (!bodyElement)
return jsUndefined();
@@ -494,6 +490,10 @@
doc.setDesignMode(mode);
break;
}
+ case All:
+ // Add "all" to the property map.
+ putDirect("all", value);
+ break;
default:
kdWarning() << "HTMLDocument::putValueProperty unhandled token " << token << endl;
}
@@ -3426,6 +3426,16 @@
// -------------------------------------------------------------------------
+JSValue *HTMLAllCollection::toPrimitive(ExecState *exec, Type preferredType) const
+{
+ if (preferredType == NullType)
+ return jsNull();
+ else
+ return HTMLCollection::toPrimitive(exec, preferredType);
+}
+
+// -------------------------------------------------------------------------
+
HTMLSelectCollection::HTMLSelectCollection(ExecState *exec, HTMLCollectionImpl *c, HTMLSelectElementImpl *e)
: HTMLCollection(exec, c), m_element(e)
{
@@ -5285,6 +5295,10 @@
////////////////////////////////////////////////////////////////
+JSValue *getAllHTMLCollection(ExecState *exec, HTMLCollectionImpl *c)
+{
+ return cacheDOMObject<HTMLCollectionImpl, HTMLAllCollection>(exec, c);
+}
JSValue *getHTMLCollection(ExecState *exec, HTMLCollectionImpl *c)
{
1.66 +9 -0 WebCore/khtml/ecma/kjs_html.h
Index: kjs_html.h
===================================================================
RCS file: /cvs/root/WebCore/khtml/ecma/kjs_html.h,v
retrieving revision 1.65
retrieving revision 1.66
diff -u -r1.65 -r1.66
--- kjs_html.h 24 Dec 2005 22:45:59 -0000 1.65
+++ kjs_html.h 29 Dec 2005 08:20:37 -0000 1.66
@@ -330,6 +330,14 @@
RefPtr<DOM::HTMLSelectElementImpl> m_element;
};
+ class HTMLAllCollection : public HTMLCollection {
+ public:
+ HTMLAllCollection(ExecState *exec, DOM::HTMLCollectionImpl *c) :
+ HTMLCollection(exec, c) { }
+ virtual bool toBoolean(ExecState *) const { return false; }
+ virtual JSValue *toPrimitive(ExecState *exec, Type preferredType) const;
+ };
+
////////////////////// Option Object ////////////////////////
class OptionConstructorImp : public JSObject {
@@ -550,6 +558,7 @@
JSValue *getHTMLCollection(ExecState *exec, DOM::HTMLCollectionImpl *c);
JSValue *getSelectHTMLCollection(ExecState *exec, DOM::HTMLCollectionImpl *c, DOM::HTMLSelectElementImpl *e);
+ JSValue *getAllHTMLCollection(ExecState *exec, DOM::HTMLCollectionImpl *c);
} // namespace
More information about the webkit-changes
mailing list