[webkit-changes] cvs commit: WebCore/layout-tests/fast/dom/Window
window-special-properties-expected.txt
window-special-properties.html
Maciej
mjs at opensource.apple.com
Tue Jul 19 19:35:34 PDT 2005
mjs 05/07/19 19:35:34
Modified: . ChangeLog
khtml/ecma kjs_html.cpp kjs_window.cpp
khtml/html html_documentimpl.cpp html_documentimpl.h
html_formimpl.cpp html_formimpl.h
html_imageimpl.cpp html_imageimpl.h
html_miscimpl.cpp html_miscimpl.h
html_objectimpl.cpp html_objectimpl.h
khtml/xml dom_docimpl.cpp dom_docimpl.h
Added: layout-tests/fast/dom/Window
window-special-properties-expected.txt
window-special-properties.html
Log:
Reviewed by Darin.
- fix handling of special properties of the Window object. now we
almost completely match Win IE.
Test cases added:
* layout-tests/fast/dom/Window/window-special-properties-expected.txt: Added.
* layout-tests/fast/dom/Window/window-special-properties.html: Added.
* khtml/ecma/kjs_html.cpp:
(KJS::HTMLDocument::hasOwnProperty):
(KJS::HTMLDocument::tryGet):
* khtml/ecma/kjs_window.cpp:
(KJS::Window::get):
(KJS::Window::hasOwnProperty):
* khtml/html/html_documentimpl.cpp:
(DOM::HTMLDocumentImpl::addNamedItem):
(DOM::HTMLDocumentImpl::removeNamedItem):
(DOM::HTMLDocumentImpl::hasNamedItem):
* khtml/html/html_documentimpl.h:
* khtml/html/html_formimpl.cpp:
(DOM::HTMLFormElementImpl::attach):
(DOM::HTMLFormElementImpl::insertedIntoDocument):
(DOM::HTMLFormElementImpl::removedFromDocument):
(DOM::HTMLFormElementImpl::parseMappedAttribute):
* khtml/html/html_formimpl.h:
* khtml/html/html_imageimpl.cpp:
(HTMLImageElementImpl::parseMappedAttribute):
(HTMLImageElementImpl::attach):
(HTMLImageElementImpl::insertedIntoDocument):
(HTMLImageElementImpl::removedFromDocument):
* khtml/html/html_imageimpl.h:
* khtml/html/html_miscimpl.cpp:
(DOM::HTMLCollectionImpl::HTMLCollectionImpl):
(DOM::HTMLCollectionImpl::traverseNextItem):
(DOM::HTMLCollectionImpl::namedItem):
(DOM::HTMLNameCollectionImpl::HTMLNameCollectionImpl):
(DOM::HTMLNameCollectionImpl::traverseNextItem):
(DOM::HTMLFormCollectionImpl::getNamedFormItem):
(DOM::HTMLFormCollectionImpl::nextNamedItem):
* khtml/html/html_miscimpl.h:
(DOM::HTMLCollectionImpl::):
* khtml/html/html_objectimpl.cpp:
(DOM::HTMLAppletElementImpl::parseMappedAttribute):
(DOM::HTMLAppletElementImpl::insertedIntoDocument):
(DOM::HTMLAppletElementImpl::removedFromDocument):
(DOM::HTMLEmbedElementImpl::parseMappedAttribute):
(DOM::HTMLEmbedElementImpl::attach):
(DOM::HTMLEmbedElementImpl::insertedIntoDocument):
(DOM::HTMLEmbedElementImpl::removedFromDocument):
(DOM::HTMLObjectElementImpl::parseMappedAttribute):
(DOM::HTMLObjectElementImpl::detach):
(DOM::HTMLObjectElementImpl::insertedIntoDocument):
(DOM::HTMLObjectElementImpl::removedFromDocument):
* khtml/html/html_objectimpl.h:
* khtml/xml/dom_docimpl.cpp:
(DocumentImpl::windowNamedItems):
* khtml/xml/dom_docimpl.h:
Revision Changes Path
1.4448 +61 -0 WebCore/ChangeLog
Index: ChangeLog
===================================================================
RCS file: /cvs/root/WebCore/ChangeLog,v
retrieving revision 1.4447
retrieving revision 1.4448
diff -u -r1.4447 -r1.4448
--- ChangeLog 20 Jul 2005 02:04:38 -0000 1.4447
+++ ChangeLog 20 Jul 2005 02:35:26 -0000 1.4448
@@ -1,3 +1,64 @@
+2005-07-18 Maciej Stachowiak <mjs at apple.com>
+
+ Reviewed by Darin.
+
+ - fix handling of special properties of the Window object. now we
+ almost completely match Win IE.
+
+ Test cases added:
+ * layout-tests/fast/dom/Window/window-special-properties-expected.txt: Added.
+ * layout-tests/fast/dom/Window/window-special-properties.html: Added.
+
+ * khtml/ecma/kjs_html.cpp:
+ (KJS::HTMLDocument::hasOwnProperty):
+ (KJS::HTMLDocument::tryGet):
+ * khtml/ecma/kjs_window.cpp:
+ (KJS::Window::get):
+ (KJS::Window::hasOwnProperty):
+ * khtml/html/html_documentimpl.cpp:
+ (DOM::HTMLDocumentImpl::addNamedItem):
+ (DOM::HTMLDocumentImpl::removeNamedItem):
+ (DOM::HTMLDocumentImpl::hasNamedItem):
+ * khtml/html/html_documentimpl.h:
+ * khtml/html/html_formimpl.cpp:
+ (DOM::HTMLFormElementImpl::attach):
+ (DOM::HTMLFormElementImpl::insertedIntoDocument):
+ (DOM::HTMLFormElementImpl::removedFromDocument):
+ (DOM::HTMLFormElementImpl::parseMappedAttribute):
+ * khtml/html/html_formimpl.h:
+ * khtml/html/html_imageimpl.cpp:
+ (HTMLImageElementImpl::parseMappedAttribute):
+ (HTMLImageElementImpl::attach):
+ (HTMLImageElementImpl::insertedIntoDocument):
+ (HTMLImageElementImpl::removedFromDocument):
+ * khtml/html/html_imageimpl.h:
+ * khtml/html/html_miscimpl.cpp:
+ (DOM::HTMLCollectionImpl::HTMLCollectionImpl):
+ (DOM::HTMLCollectionImpl::traverseNextItem):
+ (DOM::HTMLCollectionImpl::namedItem):
+ (DOM::HTMLNameCollectionImpl::HTMLNameCollectionImpl):
+ (DOM::HTMLNameCollectionImpl::traverseNextItem):
+ (DOM::HTMLFormCollectionImpl::getNamedFormItem):
+ (DOM::HTMLFormCollectionImpl::nextNamedItem):
+ * khtml/html/html_miscimpl.h:
+ (DOM::HTMLCollectionImpl::):
+ * khtml/html/html_objectimpl.cpp:
+ (DOM::HTMLAppletElementImpl::parseMappedAttribute):
+ (DOM::HTMLAppletElementImpl::insertedIntoDocument):
+ (DOM::HTMLAppletElementImpl::removedFromDocument):
+ (DOM::HTMLEmbedElementImpl::parseMappedAttribute):
+ (DOM::HTMLEmbedElementImpl::attach):
+ (DOM::HTMLEmbedElementImpl::insertedIntoDocument):
+ (DOM::HTMLEmbedElementImpl::removedFromDocument):
+ (DOM::HTMLObjectElementImpl::parseMappedAttribute):
+ (DOM::HTMLObjectElementImpl::detach):
+ (DOM::HTMLObjectElementImpl::insertedIntoDocument):
+ (DOM::HTMLObjectElementImpl::removedFromDocument):
+ * khtml/html/html_objectimpl.h:
+ * khtml/xml/dom_docimpl.cpp:
+ (DocumentImpl::windowNamedItems):
+ * khtml/xml/dom_docimpl.h:
+
2005-07-19 Geoffrey Garen <ggaren at apple.com>
-rolled in patch by Anders Carlsson <andersca at mac.com> for
1.126 +3 -3 WebCore/khtml/ecma/kjs_html.cpp
Index: kjs_html.cpp
===================================================================
RCS file: /cvs/root/WebCore/khtml/ecma/kjs_html.cpp,v
retrieving revision 1.125
retrieving revision 1.126
diff -u -r1.125 -r1.126
--- kjs_html.cpp 19 Jul 2005 19:52:49 -0000 1.125
+++ kjs_html.cpp 20 Jul 2005 02:35:30 -0000 1.126
@@ -275,7 +275,7 @@
//kdDebug(6070) << "HTMLDocument::hasProperty " << p.qstring() << endl;
#endif
HTMLDocumentImpl *doc = static_cast<HTMLDocumentImpl *>(impl());
- return DOMDocument::hasOwnProperty(exec, p) || doc->haveNamedImageOrForm(p.qstring());
+ return DOMDocument::hasOwnProperty(exec, p) || doc->hasNamedItem(p.qstring());
}
Value HTMLDocument::get(ExecState *exec, const Identifier &propertyName) const
@@ -409,7 +409,7 @@
if (NodeImpl *object = doc.objects()->namedItem(propertyName.string()))
return getDOMNode(exec, object);
- if (!doc.haveNamedImageOrForm(propertyName.qstring()))
+ if (!doc.hasNamedItem(propertyName.qstring()))
return Undefined();
return HTMLCollection(exec, doc.nameableItems().get()).getNamedItems(exec, propertyName); // Get all the items with the same name
@@ -3313,7 +3313,7 @@
ScriptInterpreter::forgetDOMObject(m_impl.get());
}
-// We have to implement hasProperty since we don't use a hashtable for 'selectedIndex' and 'length'
+// We have to implement hasOwnProperty since we don't use a hashtable for 'selectedIndex' and 'length'
// ## this breaks "for (..in..)" though.
bool KJS::HTMLCollection::hasOwnProperty(ExecState *exec, const Identifier &p) const
{
1.166 +21 -6 WebCore/khtml/ecma/kjs_window.cpp
Index: kjs_window.cpp
===================================================================
RCS file: /cvs/root/WebCore/khtml/ecma/kjs_window.cpp,v
retrieving revision 1.165
retrieving revision 1.166
diff -u -r1.165 -r1.166
--- kjs_window.cpp 19 Jul 2005 19:52:49 -0000 1.165
+++ kjs_window.cpp 20 Jul 2005 02:35:30 -0000 1.166
@@ -68,6 +68,7 @@
#include "html/html_documentimpl.h"
#include "css/css_ruleimpl.h"
#include "css/css_stylesheetimpl.h"
+#include "misc/shared.h"
// Must include <cmath> instead of <math.h> because of a bug in the
// gcc 3.3 library version of <math.h> where if you include both
@@ -80,10 +81,12 @@
using DOM::ElementImpl;
using DOM::EventImpl;
using DOM::HTMLCollectionImpl;
+using DOM::HTMLDocumentImpl;
using DOM::HTMLElementImpl;
using DOM::NodeImpl;
using DOM::Position;
+using khtml::SharedPtr;
using khtml::TypingCommand;
using KParts::ReadOnlyPart;
@@ -710,7 +713,10 @@
}
// Check for child frames by name before built-in properties to
- // match behavior of other browsers.
+ // match Mozilla. This does not match IE, but some sites end up
+ // naming frames things that conflict with window properties that
+ // are in Moz but not IE. Since we have some of these, we have to do
+ // it the Moz way.
KHTMLPart *childFrame = m_part->childFrameNamed(p.ustring().qstring());
if (childFrame)
return retrieve(childFrame);
@@ -1094,10 +1100,16 @@
// allow shortcuts like 'Image1' instead of document.images.Image1
DocumentImpl *doc = m_part->xmlDocImpl();
- if (isSafeScript(exec) && doc && doc->isHTMLDocument()) { // might be XML
- NodeImpl *element = doc->all()->namedItem(p.string());
- if (element)
- return getDOMNode(exec, element);
+ if (isSafeScript(exec) && doc && doc->isHTMLDocument()) {
+ DOMString name = p.string();
+ if (static_cast<HTMLDocumentImpl *>(doc)->hasNamedItem(name) ||
+ doc->getElementById(name)) {
+ SharedPtr<DOM::HTMLCollectionImpl> collection = doc->windowNamedItems(name);
+ if (collection->length() == 1)
+ return getDOMNode(exec, collection->firstItem());
+ else
+ return getHTMLCollection(exec, &*collection);
+ }
}
// This isn't necessarily a bug. Some code uses if(!window.blah) window.blah=1
@@ -1130,7 +1142,10 @@
if (isSafeScript(exec)) {
DocumentImpl *doc = m_part->xmlDocImpl();
- if (doc && doc->isHTMLDocument() && doc->all()->namedItem(p.string()))
+ DOMString name = p.string();
+ if (doc && doc->isHTMLDocument() &&
+ (static_cast<HTMLDocumentImpl *>(doc)->hasNamedItem(name) ||
+ doc->getElementById(name)))
return true;
}
1.64 +22 -19 WebCore/khtml/html/html_documentimpl.cpp
Index: html_documentimpl.cpp
===================================================================
RCS file: /cvs/root/WebCore/khtml/html/html_documentimpl.cpp,v
retrieving revision 1.63
retrieving revision 1.64
diff -u -r1.63 -r1.64
--- html_documentimpl.cpp 18 Jul 2005 21:52:24 -0000 1.63
+++ html_documentimpl.cpp 20 Jul 2005 02:35:31 -0000 1.64
@@ -264,36 +264,39 @@
m_render->repaint();
}
-void HTMLDocumentImpl::addNamedImageOrForm(const QString &name)
+void HTMLDocumentImpl::addNamedItem(const DOMString &name)
{
- if (name.length() == 0) {
+ if (name.length() == 0)
return;
- }
- int oldCount = (int)namedImageAndFormCounts.find(name);
- namedImageAndFormCounts.insert(name, (char *)(oldCount + 1));
+ NameCountMap::iterator it = namedItemCounts.find(name.implementation());
+ if (it == namedItemCounts.end())
+ namedItemCounts.insert(name.implementation(), 1);
+ else
+ ++(it->second);
}
-void HTMLDocumentImpl::removeNamedImageOrForm(const QString &name)
+void HTMLDocumentImpl::removeNamedItem(const DOMString &name)
{
- if (name.length() == 0) {
+ if (name.length() == 0)
return;
- }
- int oldVal = (int)(namedImageAndFormCounts.find(name));
- if (oldVal != 0) {
- int newVal = oldVal - 1;
- if (newVal == 0) {
- namedImageAndFormCounts.remove(name);
- } else {
- namedImageAndFormCounts.insert(name, (char *)newVal);
- }
- }
+ NameCountMap::iterator it = namedItemCounts.find(name.implementation());
+ if (it == namedItemCounts.end())
+ return;
+
+ int oldVal = it->second;
+ assert(oldVal != 0);
+ int newVal = oldVal - 1;
+ if (newVal == 0)
+ namedItemCounts.remove(it);
+ else
+ it->second = newVal;
}
-bool HTMLDocumentImpl::haveNamedImageOrForm(const QString &name)
+bool HTMLDocumentImpl::hasNamedItem(const DOMString &name)
{
- return namedImageAndFormCounts.find(name) != NULL;
+ return namedItemCounts.get(name.implementation()) != 0;
}
const int PARSEMODE_HAVE_DOCTYPE = (1<<0);
1.31 +14 -7 WebCore/khtml/html/html_documentimpl.h
Index: html_documentimpl.h
===================================================================
RCS file: /cvs/root/WebCore/khtml/html/html_documentimpl.h,v
retrieving revision 1.30
retrieving revision 1.31
diff -u -r1.30 -r1.31
--- html_documentimpl.h 9 Jul 2005 20:19:09 -0000 1.30
+++ html_documentimpl.h 20 Jul 2005 02:35:31 -0000 1.31
@@ -28,6 +28,7 @@
#include "xml/dom_docimpl.h"
#include "misc/loader_client.h"
#include "html/html_miscimpl.h"
+#include "misc/hashmap.h"
class KHTMLView;
class QString;
@@ -61,11 +62,16 @@
virtual void determineParseMode( const QString &str );
- void addNamedImageOrForm(const QString &name);
- void removeNamedImageOrForm(const QString &name);
- bool haveNamedImageOrForm(const QString &name);
-
- HTMLCollectionImpl::CollectionInfo *collectionInfo(int type) { return m_collection_info+type; }
+ void addNamedItem(const DOMString &name);
+ void removeNamedItem(const DOMString &name);
+ bool hasNamedItem(const DOMString &name);
+
+ HTMLCollectionImpl::CollectionInfo *collectionInfo(int type)
+ {
+ if (type < HTMLCollectionImpl::NUM_CACHEABLE_TYPES)
+ return m_collection_info+type;
+ return 0;
+ }
virtual DocumentTypeImpl *doctype() const;
@@ -79,10 +85,11 @@
*/
void slotHistoryChanged();
private:
- HTMLCollectionImpl::CollectionInfo m_collection_info[HTMLCollectionImpl::LAST_TYPE];
+ HTMLCollectionImpl::CollectionInfo m_collection_info[HTMLCollectionImpl::NUM_CACHEABLE_TYPES];
// we actually store ints inside the pointer value itself; would use void *
// but that makes the template unhappy.
- QDict<char> namedImageAndFormCounts;
+ typedef khtml::HashMap<DOMStringImpl *, int> NameCountMap;
+ NameCountMap namedItemCounts;
};
}; //namespace
1.176 +17 -23 WebCore/khtml/html/html_formimpl.cpp
Index: html_formimpl.cpp
===================================================================
RCS file: /cvs/root/WebCore/khtml/html/html_formimpl.cpp,v
retrieving revision 1.175
retrieving revision 1.176
diff -u -r1.175 -r1.176
--- html_formimpl.cpp 20 Jul 2005 02:04:42 -0000 1.175
+++ html_formimpl.cpp 20 Jul 2005 02:35:31 -0000 1.176
@@ -145,12 +145,6 @@
{
HTMLElementImpl::attach();
- if (getDocument()->isHTMLDocument()) {
- HTMLDocumentImpl *document = static_cast<HTMLDocumentImpl *>(getDocument());
- document->addNamedImageOrForm(oldNameAttr);
- document->addNamedImageOrForm(oldIdAttr);
- }
-
#if APPLE_CHANGES
// note we don't deal with calling secureFormRemoved() on detach, because the timing
// was such that it cleared our state too early
@@ -159,15 +153,24 @@
#endif
}
-void HTMLFormElementImpl::detach()
+void HTMLFormElementImpl::insertedIntoDocument()
{
if (getDocument()->isHTMLDocument()) {
HTMLDocumentImpl *document = static_cast<HTMLDocumentImpl *>(getDocument());
- document->removeNamedImageOrForm(oldNameAttr);
- document->removeNamedImageOrForm(oldIdAttr);
+ document->addNamedItem(oldNameAttr);
}
- HTMLElementImpl::detach();
+ HTMLElementImpl::insertedIntoDocument();
+}
+
+void HTMLFormElementImpl::removedFromDocument()
+{
+ if (getDocument()->isHTMLDocument()) {
+ HTMLDocumentImpl *document = static_cast<HTMLDocumentImpl *>(getDocument());
+ document->removeNamedItem(oldNameAttr);
+ }
+
+ HTMLElementImpl::removedFromDocument();
}
long HTMLFormElementImpl::length() const
@@ -662,22 +665,13 @@
setHTMLEventListener(EventImpl::RESET_EVENT,
getDocument()->createHTMLEventListener(attr->value().string(), this));
} else if (attr->name() == HTMLAttributes::name()) {
- QString newNameAttr = attr->value().string();
- if (attached() && getDocument()->isHTMLDocument()) {
+ DOMString newNameAttr = attr->value();
+ if (inDocument() && getDocument()->isHTMLDocument()) {
HTMLDocumentImpl *document = static_cast<HTMLDocumentImpl *>(getDocument());
- document->removeNamedImageOrForm(oldNameAttr);
- document->addNamedImageOrForm(newNameAttr);
+ document->removeNamedItem(oldNameAttr);
+ document->addNamedItem(newNameAttr);
}
oldNameAttr = newNameAttr;
- } else if (attr->name() == HTMLAttributes::idAttr()) {
- QString newIdAttr = attr->value().string();
- if (attached() && getDocument()->isHTMLDocument()) {
- HTMLDocumentImpl *document = static_cast<HTMLDocumentImpl *>(getDocument());
- document->removeNamedImageOrForm(oldIdAttr);
- document->addNamedImageOrForm(newIdAttr);
- }
- oldIdAttr = newIdAttr;
- HTMLElementImpl::parseMappedAttribute(attr);
} else
HTMLElementImpl::parseMappedAttribute(attr);
}
1.80 +4 -4 WebCore/khtml/html/html_formimpl.h
Index: html_formimpl.h
===================================================================
RCS file: /cvs/root/WebCore/khtml/html/html_formimpl.h,v
retrieving revision 1.79
retrieving revision 1.80
diff -u -r1.79 -r1.80
--- html_formimpl.h 20 Jul 2005 02:04:42 -0000 1.79
+++ html_formimpl.h 20 Jul 2005 02:35:31 -0000 1.80
@@ -71,8 +71,9 @@
virtual int tagPriority() const { return 3; }
virtual void attach();
- virtual void detach();
-
+ virtual void insertedIntoDocument();
+ virtual void removedFromDocument();
+
SharedPtr<HTMLCollectionImpl> elements();
long length() const;
@@ -150,8 +151,7 @@
unsigned formElementIndex(HTMLGenericFormElementImpl *);
- QString oldIdAttr;
- QString oldNameAttr;
+ DOMString oldNameAttr;
};
// -------------------------------------------------------------------------
1.47 +13 -20 WebCore/khtml/html/html_imageimpl.cpp
Index: html_imageimpl.cpp
===================================================================
RCS file: /cvs/root/WebCore/khtml/html/html_imageimpl.cpp,v
retrieving revision 1.46
retrieving revision 1.47
diff -u -r1.46 -r1.47
--- html_imageimpl.cpp 18 Jul 2005 21:52:25 -0000 1.46
+++ html_imageimpl.cpp 20 Jul 2005 02:35:31 -0000 1.47
@@ -229,23 +229,13 @@
_compositeOperator = attr->value().string();
#endif
else if (attr->name() == HTMLAttributes::name()) {
- QString newNameAttr = attr->value().string();
- if (attached() && getDocument()->isHTMLDocument()) {
+ DOMString newNameAttr = attr->value();
+ if (inDocument() && getDocument()->isHTMLDocument()) {
HTMLDocumentImpl *document = static_cast<HTMLDocumentImpl *>(getDocument());
- document->removeNamedImageOrForm(oldNameAttr);
- document->addNamedImageOrForm(newNameAttr);
+ document->removeNamedItem(oldNameAttr);
+ document->addNamedItem(newNameAttr);
}
oldNameAttr = newNameAttr;
- }
- else if (attr->name() == HTMLAttributes::idAttr()) {
- QString newIdAttr = attr->value().string();
- if (attached() && getDocument()->isHTMLDocument()) {
- HTMLDocumentImpl *document = static_cast<HTMLDocumentImpl *>(getDocument());
- document->removeNamedImageOrForm(oldIdAttr);
- document->addNamedImageOrForm(newIdAttr);
- }
- oldIdAttr = newIdAttr;
- HTMLElementImpl::parseMappedAttribute(attr);
} else
HTMLElementImpl::parseMappedAttribute(attr);
}
@@ -275,23 +265,26 @@
RenderImage* imageObj = static_cast<RenderImage*>(renderer());
imageObj->setImage(m_imageLoader.image());
}
+}
+void HTMLImageElementImpl::insertedIntoDocument()
+{
if (getDocument()->isHTMLDocument()) {
HTMLDocumentImpl *document = static_cast<HTMLDocumentImpl *>(getDocument());
- document->addNamedImageOrForm(oldIdAttr);
- document->addNamedImageOrForm(oldNameAttr);
+ document->addNamedItem(oldNameAttr);
}
+
+ HTMLElementImpl::insertedIntoDocument();
}
-void HTMLImageElementImpl::detach()
+void HTMLImageElementImpl::removedFromDocument()
{
if (getDocument()->isHTMLDocument()) {
HTMLDocumentImpl *document = static_cast<HTMLDocumentImpl *>(getDocument());
- document->removeNamedImageOrForm(oldIdAttr);
- document->removeNamedImageOrForm(oldNameAttr);
+ document->removeNamedItem(oldNameAttr);
}
- HTMLElementImpl::detach();
+ HTMLElementImpl::removedFromDocument();
}
long HTMLImageElementImpl::width(bool ignorePendingStylesheets) const
1.24 +3 -3 WebCore/khtml/html/html_imageimpl.h
Index: html_imageimpl.h
===================================================================
RCS file: /cvs/root/WebCore/khtml/html/html_imageimpl.h,v
retrieving revision 1.23
retrieving revision 1.24
diff -u -r1.23 -r1.24
--- html_imageimpl.h 18 Jul 2005 21:44:20 -0000 1.23
+++ html_imageimpl.h 20 Jul 2005 02:35:31 -0000 1.24
@@ -86,7 +86,8 @@
virtual void attach();
virtual khtml::RenderObject *createRenderer(RenderArena *, khtml::RenderStyle *);
- virtual void detach();
+ virtual void insertedIntoDocument();
+ virtual void removedFromDocument();
long width(bool ignorePendingStylesheets = false) const;
long height(bool ignorePendingStylesheets = false) const;
@@ -146,8 +147,7 @@
DOMString usemap;
bool ismap;
HTMLFormElementImpl *m_form;
- QString oldIdAttr;
- QString oldNameAttr;
+ DOMString oldNameAttr;
QString _compositeOperator;
};
1.30 +51 -9 WebCore/khtml/html/html_miscimpl.cpp
Index: html_miscimpl.cpp
===================================================================
RCS file: /cvs/root/WebCore/khtml/html/html_miscimpl.cpp,v
retrieving revision 1.29
retrieving revision 1.30
diff -u -r1.29 -r1.30
--- html_miscimpl.cpp 18 Jul 2005 21:52:26 -0000 1.29
+++ html_miscimpl.cpp 20 Jul 2005 02:35:31 -0000 1.30
@@ -71,11 +71,13 @@
// -------------------------------------------------------------------------
HTMLCollectionImpl::HTMLCollectionImpl(NodeImpl *_base, int _type)
- : m_base(_base)
+ : m_base(_base),
+ type(_type),
+ info(0),
+ idsDone(false)
{
- type = _type;
- idsDone = false;
- info = _base->isDocumentNode() && _base->getDocument()->isHTMLDocument() ? static_cast<HTMLDocumentImpl*>(_base->getDocument())->collectionInfo(type) : 0;
+ if (_base->isDocumentNode() && _base->getDocument()->isHTMLDocument())
+ info = static_cast<HTMLDocumentImpl*>(_base->getDocument())->collectionInfo(type);
}
HTMLCollectionImpl::~HTMLCollectionImpl()
@@ -124,12 +126,12 @@
assert(current);
if (type == NODE_CHILDREN && m_base.get() != current)
- current = current -> nextSibling();
+ current = current->nextSibling();
else
current = current->traverseNextNode(m_base.get());
while (current) {
- if(current->nodeType() == Node::ELEMENT_NODE) {
+ if (current->isElementNode()) {
bool found = false;
bool deep = true;
HTMLElementImpl *e = static_cast<HTMLElementImpl *>(current);
@@ -328,7 +330,7 @@
}
-NodeImpl *HTMLCollectionImpl::namedItem( const DOMString &name, bool caseSensitive ) const
+NodeImpl *HTMLCollectionImpl::namedItem(const DOMString &name, bool caseSensitive) const
{
// http://msdn.microsoft.com/workshop/author/dhtml/reference/methods/nameditem.asp
// This method first searches for an object with a matching id
@@ -360,6 +362,46 @@
return info->current;
}
+HTMLNameCollectionImpl::HTMLNameCollectionImpl(DocumentImpl* _base, int _type, DOMString &name)
+ : HTMLCollectionImpl(_base, _type),
+ m_name(name)
+{
+}
+
+NodeImpl *HTMLNameCollectionImpl::traverseNextItem(NodeImpl *current) const
+{
+ assert(current);
+
+ current = current->traverseNextNode(m_base.get());
+
+ while (current) {
+ if (current->isElementNode()) {
+ bool found = false;
+ ElementImpl *e = static_cast<ElementImpl *>(current);
+ switch(type) {
+ case WINDOW_NAMED_ITEMS:
+ // find only images, forms, applets, embeds and objects by name,
+ // but anything by id
+ if (e->hasTagName(HTMLTags::img()) ||
+ e->hasTagName(HTMLTags::form()) ||
+ e->hasTagName(HTMLTags::applet()) ||
+ e->hasTagName(HTMLTags::embed()) ||
+ e->hasTagName(HTMLTags::object()))
+ found = e->getAttribute(HTMLAttributes::name()) == m_name;
+ found |= e->getAttribute(HTMLAttributes::idAttr()) == m_name;
+ break;
+ default:
+ assert(0);
+ }
+
+ if (found)
+ return current;
+ }
+ current = current->traverseNextNode(m_base.get());
+ }
+ return 0;
+}
+
template<class T> static void appendToVector(QPtrVector<T> *vec, T *item)
{
unsigned size = vec->size();
@@ -530,7 +572,7 @@
NodeImpl* HTMLFormCollectionImpl::getNamedFormItem(const QualifiedName& attrName, const DOMString& name, int duplicateNumber, bool caseSensitive) const
{
- if (m_base->nodeType() == Node::ELEMENT_NODE) {
+ if (m_base->isElementNode()) {
HTMLElementImpl* baseElement = static_cast<HTMLElementImpl*>(m_base.get());
bool foundInputElements = false;
if (baseElement->hasLocalName(HTMLTags::form())) {
@@ -626,7 +668,7 @@
bool ok = false;
while (impl && !ok)
{
- if(impl->nodeType() == Node::ELEMENT_NODE)
+ if(impl->isElementNode())
{
HTMLElementImpl *e = static_cast<HTMLElementImpl *>(impl);
ok = (e->getAttribute(HTMLAttributes::idAttr()) != name);
1.19 +19 -5 WebCore/khtml/html/html_miscimpl.h
Index: html_miscimpl.h
===================================================================
RCS file: /cvs/root/WebCore/khtml/html/html_miscimpl.h,v
retrieving revision 1.18
retrieving revision 1.19
diff -u -r1.18 -r1.19
--- html_miscimpl.h 18 Jul 2005 21:44:21 -0000 1.18
+++ html_miscimpl.h 20 Jul 2005 02:35:31 -0000 1.19
@@ -80,21 +80,25 @@
NODE_CHILDREN, // first-level children (IE)
DOC_NAMEABLE_ITEMS, // all IMG, FORM, APPLET, EMBED and OBJECT elements, used to look
// up element name as document property
- LAST_TYPE
+ WINDOW_NAMED_ITEMS
};
- HTMLCollectionImpl(NodeImpl *_base, int _tagId);
+ enum {
+ NUM_CACHEABLE_TYPES = DOC_NAMEABLE_ITEMS + 1
+ };
+
+ HTMLCollectionImpl(NodeImpl *_base, int _type);
virtual ~HTMLCollectionImpl();
unsigned long length() const;
- virtual NodeImpl *item ( unsigned long index ) const;
+ virtual NodeImpl *item(unsigned long index) const;
virtual NodeImpl *firstItem() const;
virtual NodeImpl *nextItem() const;
- virtual NodeImpl *namedItem ( const DOMString &name, bool caseSensitive = true ) const;
+ virtual NodeImpl *namedItem(const DOMString &name, bool caseSensitive = true) const;
// In case of multiple items named the same way
- virtual NodeImpl *nextNamedItem( const DOMString &name ) const;
+ virtual NodeImpl *nextNamedItem(const DOMString &name) const;
QValueList< SharedPtr<NodeImpl> > namedItems(const DOMString &name) const;
@@ -131,6 +135,16 @@
mutable bool idsDone;
};
+class HTMLNameCollectionImpl : public HTMLCollectionImpl
+{
+public:
+ HTMLNameCollectionImpl(DocumentImpl* _base, int _type, DOMString &name);
+
+ virtual NodeImpl *traverseNextItem(NodeImpl *start) const;
+ private:
+ DOMString m_name;
+};
+
// this whole class is just a big hack to find form elements even in
// malformed HTML elements
// the famous <table><tr><form><td> problem
1.71 +88 -1 WebCore/khtml/html/html_objectimpl.cpp
Index: html_objectimpl.cpp
===================================================================
RCS file: /cvs/root/WebCore/khtml/html/html_objectimpl.cpp,v
retrieving revision 1.70
retrieving revision 1.71
diff -u -r1.70 -r1.71
--- html_objectimpl.cpp 18 Jul 2005 21:52:26 -0000 1.70
+++ html_objectimpl.cpp 20 Jul 2005 02:35:31 -0000 1.71
@@ -36,6 +36,7 @@
#include "css/cssproperties.h"
#include "css/cssvalues.h"
#include "html/html_formimpl.h"
+#include "html/html_documentimpl.h"
#include "rendering/render_applet.h"
#include "rendering/render_frames.h"
#include "rendering/render_image.h"
@@ -113,10 +114,38 @@
addCSSLength(attr, CSS_PROP_MARGIN_RIGHT, attr->value());
} else if (attr->name() == HTMLAttributes::align()) {
addHTMLAlignment(attr);
+ } else if (attr->name() == HTMLAttributes::name()) {
+ DOMString newNameAttr = attr->value();
+ if (inDocument() && getDocument()->isHTMLDocument()) {
+ HTMLDocumentImpl *document = static_cast<HTMLDocumentImpl *>(getDocument());
+ document->removeNamedItem(oldNameAttr);
+ document->addNamedItem(newNameAttr);
+ }
+ oldNameAttr = newNameAttr;
} else
HTMLElementImpl::parseMappedAttribute(attr);
}
+void HTMLAppletElementImpl::insertedIntoDocument()
+{
+ if (getDocument()->isHTMLDocument()) {
+ HTMLDocumentImpl *document = static_cast<HTMLDocumentImpl *>(getDocument());
+ document->addNamedItem(oldNameAttr);
+ }
+
+ HTMLElementImpl::insertedIntoDocument();
+}
+
+void HTMLAppletElementImpl::removedFromDocument()
+{
+ if (getDocument()->isHTMLDocument()) {
+ HTMLDocumentImpl *document = static_cast<HTMLDocumentImpl *>(getDocument());
+ document->removeNamedItem(oldNameAttr);
+ }
+
+ HTMLElementImpl::removedFromDocument();
+}
+
bool HTMLAppletElementImpl::rendererIsNeeded(RenderStyle *style)
{
return !getAttribute(HTMLAttributes::code()).isNull();
@@ -446,6 +475,14 @@
addCSSLength( attr, CSS_PROP_WIDTH, "0" );
addCSSLength( attr, CSS_PROP_HEIGHT, "0" );
}
+ } else if (attr->name() == HTMLAttributes::name()) {
+ DOMString newNameAttr = attr->value();
+ if (inDocument() && getDocument()->isHTMLDocument()) {
+ HTMLDocumentImpl *document = static_cast<HTMLDocumentImpl *>(getDocument());
+ document->removeNamedItem(oldNameAttr);
+ document->addNamedItem(newNameAttr);
+ }
+ oldNameAttr = newNameAttr;
} else
HTMLElementImpl::parseMappedAttribute(attr);
}
@@ -466,11 +503,32 @@
void HTMLEmbedElementImpl::attach()
{
HTMLElementImpl::attach();
+
if (m_render) {
static_cast<RenderPartObject*>(m_render)->updateWidget();
}
}
+void HTMLEmbedElementImpl::insertedIntoDocument()
+{
+ if (getDocument()->isHTMLDocument()) {
+ HTMLDocumentImpl *document = static_cast<HTMLDocumentImpl *>(getDocument());
+ document->addNamedItem(oldNameAttr);
+ }
+
+ HTMLElementImpl::insertedIntoDocument();
+}
+
+void HTMLEmbedElementImpl::removedFromDocument()
+{
+ if (getDocument()->isHTMLDocument()) {
+ HTMLDocumentImpl *document = static_cast<HTMLDocumentImpl *>(getDocument());
+ document->removeNamedItem(oldNameAttr);
+ }
+
+ HTMLElementImpl::removedFromDocument();
+}
+
bool HTMLEmbedElementImpl::isURLAttribute(AttributeImpl *attr) const
{
return attr->name() == HTMLAttributes::src();
@@ -602,6 +660,15 @@
} else if (attr->name() == HTMLAttributes::onunload()) {
setHTMLEventListener(EventImpl::UNLOAD_EVENT,
getDocument()->createHTMLEventListener(attr->value().string(), this));
+ } else if (attr->name() == HTMLAttributes::name()) {
+ DOMString newNameAttr = attr->value();
+ if (inDocument() && getDocument()->isHTMLDocument()) {
+ HTMLDocumentImpl *document = static_cast<HTMLDocumentImpl *>(getDocument());
+ document->removeNamedItem(oldNameAttr);
+ document->addNamedItem(newNameAttr);
+ }
+ oldNameAttr = newNameAttr;
+
} else
HTMLElementImpl::parseMappedAttribute(attr);
}
@@ -678,7 +745,27 @@
// ### do this when we are actualy removed from document instead
dispatchHTMLEvent(EventImpl::UNLOAD_EVENT,false,false);
- HTMLElementImpl::detach();
+ HTMLElementImpl::detach();
+}
+
+void HTMLObjectElementImpl::insertedIntoDocument()
+{
+ if (getDocument()->isHTMLDocument()) {
+ HTMLDocumentImpl *document = static_cast<HTMLDocumentImpl *>(getDocument());
+ document->addNamedItem(oldNameAttr);
+ }
+
+ HTMLElementImpl::insertedIntoDocument();
+}
+
+void HTMLObjectElementImpl::removedFromDocument()
+{
+ if (getDocument()->isHTMLDocument()) {
+ HTMLDocumentImpl *document = static_cast<HTMLDocumentImpl *>(getDocument());
+ document->removeNamedItem(oldNameAttr);
+ }
+
+ HTMLElementImpl::removedFromDocument();
}
void HTMLObjectElementImpl::recalcStyle(StyleChange ch)
1.34 +12 -2 WebCore/khtml/html/html_objectimpl.h
Index: html_objectimpl.h
===================================================================
RCS file: /cvs/root/WebCore/khtml/html/html_objectimpl.h,v
retrieving revision 1.33
retrieving revision 1.34
diff -u -r1.33 -r1.34
--- html_objectimpl.h 18 Jul 2005 21:44:21 -0000 1.33
+++ html_objectimpl.h 20 Jul 2005 02:35:31 -0000 1.34
@@ -97,10 +97,14 @@
KJS::Bindings::Instance *getAppletInstance() const;
#endif
+ virtual void insertedIntoDocument();
+ virtual void removedFromDocument();
+
protected:
khtml::VAlign valign;
private:
+ DOMString oldNameAttr;
#if APPLE_CHANGES
mutable KJS::Bindings::Instance *appletInstance;
bool m_allParamsAvailable;
@@ -125,6 +129,8 @@
virtual void attach();
virtual bool rendererIsNeeded(khtml::RenderStyle *);
virtual khtml::RenderObject *createRenderer(RenderArena *, khtml::RenderStyle *);
+ virtual void insertedIntoDocument();
+ virtual void removedFromDocument();
virtual bool isURLAttribute(AttributeImpl *attr) const;
@@ -136,8 +142,9 @@
QString pluginPage;
QString serviceType;
-#if APPLE_CHANGES
private:
+ DOMString oldNameAttr;
+#if APPLE_CHANGES
mutable KJS::Bindings::Instance *embedInstance;
#endif
};
@@ -163,6 +170,8 @@
virtual bool rendererIsNeeded(khtml::RenderStyle *);
virtual khtml::RenderObject *createRenderer(RenderArena *, khtml::RenderStyle *);
virtual void detach();
+ virtual void insertedIntoDocument();
+ virtual void removedFromDocument();
virtual void recalcStyle(StyleChange ch);
virtual void childrenChanged();
@@ -237,8 +246,9 @@
bool m_useFallbackContent : 1;
HTMLImageLoader* m_imageLoader;
-#if APPLE_CHANGES
private:
+ DOMString oldNameAttr;
+#if APPLE_CHANGES
mutable KJS::Bindings::Instance *objectInstance;
#endif
};
1.239 +5 -0 WebCore/khtml/xml/dom_docimpl.cpp
Index: dom_docimpl.cpp
===================================================================
RCS file: /cvs/root/WebCore/khtml/xml/dom_docimpl.cpp,v
retrieving revision 1.238
retrieving revision 1.239
diff -u -r1.238 -r1.239
--- dom_docimpl.cpp 18 Jul 2005 21:52:34 -0000 1.238
+++ dom_docimpl.cpp 20 Jul 2005 02:35:33 -0000 1.239
@@ -3055,6 +3055,11 @@
return SharedPtr<HTMLCollectionImpl>(new HTMLCollectionImpl(this, HTMLCollectionImpl::DOC_NAMEABLE_ITEMS));
}
+SharedPtr<HTMLCollectionImpl> DocumentImpl::windowNamedItems(DOMString &name)
+{
+ return SharedPtr<HTMLCollectionImpl>(new HTMLNameCollectionImpl(this, HTMLCollectionImpl::WINDOW_NAMED_ITEMS, name));
+}
+
SharedPtr<NameNodeListImpl> DocumentImpl::getElementsByName(const DOMString &elementName)
{
return SharedPtr<NameNodeListImpl>(new NameNodeListImpl(this, elementName));
1.119 +1 -0 WebCore/khtml/xml/dom_docimpl.h
Index: dom_docimpl.h
===================================================================
RCS file: /cvs/root/WebCore/khtml/xml/dom_docimpl.h,v
retrieving revision 1.118
retrieving revision 1.119
diff -u -r1.118 -r1.119
--- dom_docimpl.h 18 Jul 2005 21:44:28 -0000 1.118
+++ dom_docimpl.h 20 Jul 2005 02:35:33 -0000 1.119
@@ -207,6 +207,7 @@
SharedPtr<HTMLCollectionImpl> all();
SharedPtr<HTMLCollectionImpl> objects();
SharedPtr<HTMLCollectionImpl> nameableItems();
+ SharedPtr<HTMLCollectionImpl> windowNamedItems(DOMString &name);
// DOM methods overridden from parent classes
1.1 WebCore/layout-tests/fast/dom/Window/window-special-properties-expected.txt
Index: window-special-properties-expected.txt
===================================================================
This test covers the various ways of accessing DOM elements through the window object by name, id or index, directly as properties of the window object. This lookup is supposed to include applet, embed, form, image and object by name, and all elements by id. It should give the element itself in the case of a single match, or an HTMLCollection in the case of multiple matches; except that when iframes are involved, it will give the window object for the first iframe match.
Our results match WinIE in all respects but one. We allow child frame names to take precedence over built-in and custom properties of the window object. This is the Mozilla behavior and is required to make some sites work because they use frame names that collide with built-in properties in Mozilla but not IE.
Results:
Nonexistent image name: undefined
Image by name (unique): single IMG(name)
Image by name (multiple): collection(2) IMG(name) IMG(name)
Image by id (unique): single IMG(id)
Image by id (multiple): collection(2) IMG(id) IMG(id)
Image by id/name mixed: collection(4) IMG(id) IMG(name) IMG(name) IMG(id)
Nonexistent form name: undefined
Form by name (unique): single FORM(name)
Form by name (multiple): collection(2) FORM(name) FORM(name)
Form by id (unique): single FORM(id)
Form by id (multiple): collection(2) FORM(id) FORM(id)
Form by id/name mixed: collection(4) FORM(id) FORM(name) FORM(name) FORM(id)
Nonexistent applet name: undefined
Applet by name (unique): single APPLET(name)
Applet by name (multiple): collection(2) APPLET(name) APPLET(name)
Applet by id (unique): single APPLET(id)
Applet by id (multiple): collection(2) APPLET(id) APPLET(id)
Applet by id/name mixed: collection(4) APPLET(id) APPLET(name) APPLET(name) APPLET(id)
Nonexistent object name: undefined
Object by name (unique): single OBJECT(name)
Object by name (multiple): collection(2) OBJECT(name) OBJECT(name)
Object by id (unique): single OBJECT(id)
Object by id (multiple): collection(2) OBJECT(id) OBJECT(id)
Object by id/name mixed: collection(4) OBJECT(id) OBJECT(name) OBJECT(name) OBJECT(id)
Nonexistent embed name: undefined
Embed by name (unique): single EMBED(name)
Embed by name (multiple): collection(2) EMBED(name) EMBED(name)
Embed by id (unique): single EMBED(id)
Embed by id (multiple): collection(2) EMBED(id) EMBED(id)
Embed by id/name mixed: collection(4) EMBED(id) EMBED(name) EMBED(name) EMBED(id)
Nonexistent iframe name: undefined
Iframe by name (unique): single WINDOW
Iframe by name (multiple): single WINDOW
Iframe by id (unique): single WINDOW
Iframe by id (multiple): single WINDOW
Iframe by id/name mixed: single WINDOW
Nonexistent span name: undefined
Span by name (unique): undefined
Span by name (multiple): undefined
Span by id (unique): single SPAN(id)
Span by id (multiple): collection(2) SPAN(id) SPAN(id)
Span by id/name mixed: collection(2) SPAN(id) SPAN(id)
Mixed by id: single WINDOW
Mixed by name: single WINDOW
Mixed by id (no iframe): collection(6) IMG(id) FORM(id) APPLET(id) EMBED(id) OBJECT(id) SPAN(id)
Mixed by name (no iframe): collection(5) IMG(name) FORM(name) APPLET(name) EMBED(name) OBJECT(name)
Numeric 0: single WINDOW
Numeric 12: single WINDOW
Numeric 13: undefined
Conflicting image: single OTHER
Conflicting image (custom property): single OTHER
Conflicting iframe: single WINDOW
1.1 WebCore/layout-tests/fast/dom/Window/window-special-properties.html
Index: window-special-properties.html
===================================================================
<body>
<p>This test covers the various ways of accessing DOM elements through
the window object by name, id or index, directly as properties of the
window object. This lookup is supposed to include applet, embed, form,
image and object by name, and all elements by id. It should give the
element itself in the case of a single match, or an HTMLCollection in
the case of multiple matches; except that when iframes are involved,
it will give the window object for the first iframe match.
</p>
<p>Our results match WinIE in all respects but one. We allow child
frame names to take precedence over built-in and custom properties of
the window object. This is the Mozilla behavior and is required to
make some sites work because they use frame names that collide with
built-in properties in Mozilla but not IE - specifically "toobar". See
<a href="rdar://problem/3870317">Radar 3870317</a>.</p>
<hr>
<script>
window.custom=new Object();
if (window.layoutTestController)
window.layoutTestController.dumpAsText();
</script>
<div style="visibility: hidden; width: 0px; height: 0px;">
<img name="image1" width="0" height="0">
<img name="image2" width="0" height="0">
<img name="image2" width="0" height="0">
<img id="image3" width="0" height="0">
<img id="image4" width="0" height="0">
<img id="image4" width="0" height="0">
<img id="image5" width="0" height="0">
<img name="image5" width="0" height="0">
<img name="image5" width="0" height="0">
<img id="image5" width="0" height="0">
<form name="form1" width="0" height="0"></form>
<form name="form2" width="0" height="0"></form>
<form name="form2" width="0" height="0"></form>
<form id="form3" width="0" height="0"></form>
<form id="form4" width="0" height="0"></form>
<form id="form4" width="0" height="0"></form>
<form id="form5" width="0" height="0"></form>
<form name="form5" width="0" height="0"></form>
<form name="form5" width="0" height="0"></form>
<form id="form5" width="0" height="0"></form>
<applet name="applet1" width="0" height="0"></applet>
<applet name="applet2" width="0" height="0"></applet>
<applet name="applet2" width="0" height="0"></applet>
<applet id="applet3" width="0" height="0"></applet>
<applet id="applet4" width="0" height="0"></applet>
<applet id="applet4" width="0" height="0"></applet>
<applet id="applet5" width="0" height="0"></applet>
<applet name="applet5" width="0" height="0"></applet>
<applet name="applet5" width="0" height="0"></applet>
<applet id="applet5" width="0" height="0"></applet>
<embed name="embed1" width="0" height="0"></embed>
<embed name="embed2" width="0" height="0"></embed>
<embed name="embed2" width="0" height="0"></embed>
<embed id="embed3" width="0" height="0"></embed>
<embed id="embed4" width="0" height="0"></embed>
<embed id="embed4" width="0" height="0"></embed>
<embed id="embed5" width="0" height="0"></embed>
<embed name="embed5" width="0" height="0"></embed>
<embed name="embed5" width="0" height="0"></embed>
<embed id="embed5" width="0" height="0"></embed>
<object name="object1" width="0" height="0"></object>
<object name="object2" width="0" height="0"></object>
<object name="object2" width="0" height="0"></object>
<object id="object3" width="0" height="0"></object>
<object id="object4" width="0" height="0"></object>
<object id="object4" width="0" height="0"></object>
<object id="object5" width="0" height="0"></object>
<object name="object5" width="0" height="0"></object>
<object name="object5" width="0" height="0"></object>
<object id="object5" width="0" height="0"></object>
<iframe name="iframe1" width="0" height="0"></iframe>
<iframe name="iframe2" width="0" height="0"></iframe>
<iframe name="iframe2" width="0" height="0"></iframe>
<iframe id="iframe3" width="0" height="0"></iframe>
<iframe id="iframe4" width="0" height="0"></iframe>
<iframe id="iframe4" width="0" height="0"></iframe>
<iframe id="iframe5" width="0" height="0"></iframe>
<iframe name="iframe5" width="0" height="0"></iframe>
<iframe name="iframe5" width="0" height="0"></iframe>
<iframe id="iframe5" width="0" height="0"></iframe>
<span name="span1" width="0" height="0"></span>
<span name="span2" width="0" height="0"></span>
<span name="span2" width="0" height="0"></span>
<span id="span3" width="0" height="0"></span>
<span id="span4" width="0" height="0"></span>
<span id="span4" width="0" height="0"></span>
<span id="span5" width="0" height="0"></span>
<span name="span5" width="0" height="0"></span>
<span name="span5" width="0" height="0"></span>
<span id="span5" width="0" height="0"></span>
<img id="mixed1" width="0" height="0">
<form id="mixed1" width="0" height="0"></form>
<applet id="mixed1" width="0" height="0"></applet>
<embed id="mixed1" width="0" height="0"></embed>
<object id="mixed1" width="0" height="0"></object>
<iframe id="mixed1" width="0" height="0"></iframe>
<span id="mixed1" width="0" height="0"></span>
<img name="mixed2" width="0" height="0">
<form name="mixed2" width="0" height="0"></form>
<applet name="mixed2" width="0" height="0"></applet>
<embed name="mixed2" width="0" height="0"></embed>
<object name="mixed2" width="0" height="0"></object>
<iframe name="mixed2" width="0" height="0"></iframe>
<span name="mixed2" width="0" height="0"></span>
<img id="mixed3" width="0" height="0">
<form id="mixed3" width="0" height="0"></form>
<applet id="mixed3" width="0" height="0"></applet>
<embed id="mixed3" width="0" height="0"></embed>
<object id="mixed3" width="0" height="0"></object>
<span id="mixed3" width="0" height="0"></span>
<img name="mixed4" width="0" height="0">
<form name="mixed4" width="0" height="0"></form>
<applet name="mixed4" width="0" height="0"></applet>
<embed name="mixed4" width="0" height="0"></embed>
<object name="mixed4" width="0" height="0"></object>
<span name="mixed4" width="0" height="0"></span>
<img name="navigator" with="0" height="0">
<img name="custom" with="0" height="0">
<iframe name="location" with="0" height="0"></iframe>
</div>
<pre id="results">
Results:<br>
</pre>
<script>
function print(x)
{
document.getElementById("results").innerHTML += x;
}
function printElement(e)
{
if (e.tagName) {
print(" " + e.tagName);
if (e.name && e.id) {
print("(id,name)");
} else if (e.name) {
print("(name)");
} else if (e.id) {
print("(id)");
}
} else if (e.navigator) {
print(" WINDOW");
} else {
print(" OTHER");
}
}
function testProperty(description, propName) {
print(description);
print(":");
var propVal = window[propName];
if (!propVal) {
print(" undefined");
} else if (propVal.length) {
print(" collection(" + propVal.length + ")");
for (var i = 0; i < propVal.length; i++) {
printElement(propVal[i]);
}
} else {
print(" single");
printElement(propVal);
}
print("<br>");
}
testProperty("Nonexistent image name", "image0");
testProperty("Image by name (unique)", "image1");
testProperty("Image by name (multiple)", "image2");
testProperty("Image by id (unique)", "image3");
testProperty("Image by id (multiple)", "image4");
testProperty("Image by id/name mixed", "image5");
print("<br>");
testProperty("Nonexistent form name", "form0");
testProperty("Form by name (unique)", "form1");
testProperty("Form by name (multiple)", "form2");
testProperty("Form by id (unique)", "form3");
testProperty("Form by id (multiple)", "form4");
testProperty("Form by id/name mixed", "form5");
print("<br>");
testProperty("Nonexistent applet name", "applet0");
testProperty("Applet by name (unique)", "applet1");
testProperty("Applet by name (multiple)", "applet2");
testProperty("Applet by id (unique)", "applet3");
testProperty("Applet by id (multiple)", "applet4");
testProperty("Applet by id/name mixed", "applet5");
print("<br>");
testProperty("Nonexistent object name", "object0");
testProperty("Object by name (unique)", "object1");
testProperty("Object by name (multiple)", "object2");
testProperty("Object by id (unique)", "object3");
testProperty("Object by id (multiple)", "object4");
testProperty("Object by id/name mixed", "object5");
print("<br>");
testProperty("Nonexistent embed name", "embed0");
testProperty("Embed by name (unique)", "embed1");
testProperty("Embed by name (multiple)", "embed2");
testProperty("Embed by id (unique)", "embed3");
testProperty("Embed by id (multiple)", "embed4");
testProperty("Embed by id/name mixed", "embed5");
print("<br>");
testProperty("Nonexistent iframe name", "iframe0");
testProperty("Iframe by name (unique)", "iframe1");
testProperty("Iframe by name (multiple)", "iframe2");
testProperty("Iframe by id (unique)", "iframe3");
testProperty("Iframe by id (multiple)", "iframe4");
testProperty("Iframe by id/name mixed", "iframe5");
print("<br>");
testProperty("Nonexistent span name", "span0");
testProperty("Span by name (unique)", "span1");
testProperty("Span by name (multiple)", "span2");
testProperty("Span by id (unique)", "span3");
testProperty("Span by id (multiple)", "span4");
testProperty("Span by id/name mixed", "span5");
print("<br>");
testProperty("Mixed by id", "mixed1");
testProperty("Mixed by name", "mixed2");
testProperty("Mixed by id (no iframe)", "mixed3");
testProperty("Mixed by name (no iframe)", "mixed4");
print("<br>");
testProperty("Numeric 0", 0);
testProperty("Numeric 12", 12);
testProperty("Numeric 13", 13);
print("<br>");
testProperty("Conflicting image", "navigator");
testProperty("Conflicting image (custom property)", "custom");
testProperty("Conflicting iframe", "location");
</script>
</body>
\ No newline at end of file
More information about the webkit-changes
mailing list