[webkit-changes] cvs commit: WebCore/layout-tests/fast/dom/HTMLDocument document-special-properties-expected.txt document-special-properties.html

Maciej mjs at opensource.apple.com
Wed Jul 20 21:10:55 PDT 2005


mjs         05/07/20 21:10:55

  Modified:    .        ChangeLog
               khtml/ecma kjs_html.cpp kjs_window.cpp
               khtml/html html_baseimpl.cpp html_baseimpl.h
                        html_documentimpl.cpp html_documentimpl.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/HTMLDocument
                        document-special-properties-expected.txt
                        document-special-properties.html
  Log:
          Reviewed by Geoff.
  
  	- fix handling of special properties of the HTML document object. Now we
  	completely match IE.
  
          Test cases added:
  	* layout-tests/fast/dom/HTMLDocument/document-special-properties.html:
  	Added; new exhaustive test case.
          * layout-tests/fast/dom/HTMLDocument/document-special-properties-expected.txt: Added.
  
          * khtml/ecma/kjs_html.cpp:
          (KJS::HTMLDocument::hasOwnProperty): Check for named and doc extra named
  	items.
          (KJS::HTMLDocument::get): Return the appropriate element, window or collection
  	by name; give such named items precedence over built-in and custom properties.
          * khtml/ecma/kjs_window.cpp:
          (KJS::Window::get): Replace quirky &* idiom with call to get().
          * khtml/html/html_baseimpl.cpp:
          (HTMLIFrameElementImpl::parseMappedAttribute): Track by name as a doc
  	extra named item.
          (HTMLIFrameElementImpl::insertedIntoDocument): ditto
          (HTMLIFrameElementImpl::removedFromDocument): ditto
          * khtml/html/html_baseimpl.h:
          * khtml/html/html_documentimpl.cpp:
          (DOM::addItemToMap): Factored out from addNamedItem
          (DOM::removeItemFromMap): Factored out from removeNamedItem
          (DOM::HTMLDocumentImpl::addNamedItem): refactored
          (DOM::HTMLDocumentImpl::removeNamedItem): refactored
          (DOM::HTMLDocumentImpl::addDocExtraNamedItem): new method - maintains
  	a hashtable of the "extra" named items for a document, which are
  	iframes by name and applets and embeds by id.
          (DOM::HTMLDocumentImpl::removeDocExtraNamedItem): ditto
          (DOM::HTMLDocumentImpl::hasDocExtraNamedItem): ditto
          * khtml/html/html_documentimpl.h:
          * khtml/html/html_miscimpl.cpp:
          (DOM::HTMLCollectionImpl::traverseNextItem): Remove support for
  	DOC_NAMEABLE_ITEMS collection - no longer needed.
          (DOM::HTMLNameCollectionImpl::traverseNextItem): Add support for
  	DOCUMENT_NAMED_ITEMS, implementing the correct document rule.
          * khtml/html/html_miscimpl.h:
          (DOM::HTMLCollectionImpl::):
          * khtml/html/html_objectimpl.cpp:
          (DOM::HTMLAppletElementImpl::parseMappedAttribute): Track by id
  	as doc extra named item
          (DOM::HTMLAppletElementImpl::insertedIntoDocument): ditto
          (DOM::HTMLAppletElementImpl::removedFromDocument): ditto
          (DOM::HTMLObjectElementImpl::parseMappedAttribute): ditto
          (DOM::HTMLObjectElementImpl::insertedIntoDocument): ditto
          (DOM::HTMLObjectElementImpl::removedFromDocument): ditto
          * khtml/html/html_objectimpl.h:
          * khtml/xml/dom_docimpl.cpp:
          (DocumentImpl::nameableItems): removed - no longer used
          (DocumentImpl::documentNamedItems): added
          * khtml/xml/dom_docimpl.h:
  
  Revision  Changes    Path
  1.4454    +57 -0     WebCore/ChangeLog
  
  Index: ChangeLog
  ===================================================================
  RCS file: /cvs/root/WebCore/ChangeLog,v
  retrieving revision 1.4453
  retrieving revision 1.4454
  diff -u -r1.4453 -r1.4454
  --- ChangeLog	20 Jul 2005 22:54:55 -0000	1.4453
  +++ ChangeLog	21 Jul 2005 04:10:47 -0000	1.4454
  @@ -1,3 +1,60 @@
  +2005-07-20  Maciej Stachowiak  <mjs at apple.com>
  +
  +        Reviewed by Geoff.
  +
  +	- fix handling of special properties of the HTML document object. Now we
  +	completely match IE.
  +
  +        Test cases added:
  +	* layout-tests/fast/dom/HTMLDocument/document-special-properties.html:
  +	Added; new exhaustive test case.
  +        * layout-tests/fast/dom/HTMLDocument/document-special-properties-expected.txt: Added.
  +
  +        * khtml/ecma/kjs_html.cpp:
  +        (KJS::HTMLDocument::hasOwnProperty): Check for named and doc extra named
  +	items.
  +        (KJS::HTMLDocument::get): Return the appropriate element, window or collection
  +	by name; give such named items precedence over built-in and custom properties.
  +        * khtml/ecma/kjs_window.cpp:
  +        (KJS::Window::get): Replace quirky &* idiom with call to get().
  +        * khtml/html/html_baseimpl.cpp:
  +        (HTMLIFrameElementImpl::parseMappedAttribute): Track by name as a doc
  +	extra named item.
  +        (HTMLIFrameElementImpl::insertedIntoDocument): ditto
  +        (HTMLIFrameElementImpl::removedFromDocument): ditto
  +        * khtml/html/html_baseimpl.h:
  +        * khtml/html/html_documentimpl.cpp:
  +        (DOM::addItemToMap): Factored out from addNamedItem
  +        (DOM::removeItemFromMap): Factored out from removeNamedItem
  +        (DOM::HTMLDocumentImpl::addNamedItem): refactored
  +        (DOM::HTMLDocumentImpl::removeNamedItem): refactored
  +        (DOM::HTMLDocumentImpl::addDocExtraNamedItem): new method - maintains
  +	a hashtable of the "extra" named items for a document, which are
  +	iframes by name and applets and embeds by id.
  +        (DOM::HTMLDocumentImpl::removeDocExtraNamedItem): ditto
  +        (DOM::HTMLDocumentImpl::hasDocExtraNamedItem): ditto
  +        * khtml/html/html_documentimpl.h:
  +        * khtml/html/html_miscimpl.cpp:
  +        (DOM::HTMLCollectionImpl::traverseNextItem): Remove support for
  +	DOC_NAMEABLE_ITEMS collection - no longer needed.
  +        (DOM::HTMLNameCollectionImpl::traverseNextItem): Add support for
  +	DOCUMENT_NAMED_ITEMS, implementing the correct document rule.
  +        * khtml/html/html_miscimpl.h:
  +        (DOM::HTMLCollectionImpl::):
  +        * khtml/html/html_objectimpl.cpp:
  +        (DOM::HTMLAppletElementImpl::parseMappedAttribute): Track by id
  +	as doc extra named item
  +        (DOM::HTMLAppletElementImpl::insertedIntoDocument): ditto
  +        (DOM::HTMLAppletElementImpl::removedFromDocument): ditto
  +        (DOM::HTMLObjectElementImpl::parseMappedAttribute): ditto
  +        (DOM::HTMLObjectElementImpl::insertedIntoDocument): ditto
  +        (DOM::HTMLObjectElementImpl::removedFromDocument): ditto
  +        * khtml/html/html_objectimpl.h:
  +        * khtml/xml/dom_docimpl.cpp:
  +        (DocumentImpl::nameableItems): removed - no longer used
  +        (DocumentImpl::documentNamedItems): added
  +        * khtml/xml/dom_docimpl.h:
  +
   2005-07-20  John Sullivan  <sullivan at apple.com>
   
           Reviewed by Vicki Murley.
  
  
  
  1.127     +21 -24    WebCore/khtml/ecma/kjs_html.cpp
  
  Index: kjs_html.cpp
  ===================================================================
  RCS file: /cvs/root/WebCore/khtml/ecma/kjs_html.cpp,v
  retrieving revision 1.126
  retrieving revision 1.127
  diff -u -r1.126 -r1.127
  --- kjs_html.cpp	20 Jul 2005 02:35:30 -0000	1.126
  +++ kjs_html.cpp	21 Jul 2005 04:10:51 -0000	1.127
  @@ -274,8 +274,12 @@
   #ifdef KJS_VERBOSE
     //kdDebug(6070) << "HTMLDocument::hasProperty " << p.qstring() << endl;
   #endif
  +  if (DOMDocument::hasOwnProperty(exec, p))
  +    return true;
  +
     HTMLDocumentImpl *doc = static_cast<HTMLDocumentImpl *>(impl());
  -  return DOMDocument::hasOwnProperty(exec, p) || doc->hasNamedItem(p.qstring());
  +  DOMString name = p.string();
  +  return doc->hasNamedItem(name) || doc->hasDocExtraNamedItem(name);
   }
   
   Value HTMLDocument::get(ExecState *exec, const Identifier &propertyName) const
  @@ -289,6 +293,21 @@
     KHTMLView *view = doc.view();
     KHTMLPart *part = doc.part();
   
  +  DOMString name = propertyName.string();
  +  if (doc.hasNamedItem(name) || doc.hasDocExtraNamedItem(name)) {
  +    SharedPtr<DOM::HTMLCollectionImpl> collection = doc.documentNamedItems(name);
  +    if (collection->length() == 1) {
  +      NodeImpl *node = collection->firstItem();
  +      if (node->hasTagName(HTMLTags::iframe())) {
  +        KHTMLPart *part = static_cast<DOM::HTMLIFrameElementImpl *>(node)->contentPart();
  +        if (part)
  +          return Window::retrieve(part);
  +      }
  +      return getDOMNode(exec, node);
  +    } else 
  +      return getHTMLCollection(exec, collection.get());
  +  }
  +    
     const HashEntry* entry = Lookup::findEntry(&HTMLDocumentTable, propertyName);
     if (entry) {
       switch (entry->value) {
  @@ -390,29 +409,7 @@
       }
     }
   
  -  ValueImp *proto = prototype().imp();
  -  if (DOMDocument::hasOwnProperty(exec, propertyName) || (proto->dispatchType() == ObjectType && static_cast<ObjectImp *>(proto)->hasProperty(exec, propertyName)))
  -    return DOMDocument::get(exec, propertyName);
  -
  -  //kdDebug(6070) << "KJS::HTMLDocument::get " << propertyName.qstring() << " not found, returning element" << endl;
  -  // image and form elements with the name p will be looked up last
  -
  -  // Look for named applets.
  -  // FIXME: Factor code that creates RuntimeObjectImp for applet. It's also located in applets[0].
  -
  -  if (NodeImpl *applet = doc.applets()->namedItem(propertyName.string()))
  -    return getDOMNode(exec, applet);
  -
  -  if (NodeImpl *embed = doc.embeds()->namedItem(propertyName.string()))
  -    return getDOMNode(exec, embed);
  -
  -  if (NodeImpl *object = doc.objects()->namedItem(propertyName.string()))
  -    return getDOMNode(exec, object);
  -
  -  if (!doc.hasNamedItem(propertyName.qstring()))
  -    return Undefined();
  -
  -  return HTMLCollection(exec, doc.nameableItems().get()).getNamedItems(exec, propertyName); // Get all the items with the same name
  +  return DOMDocument::get(exec, propertyName);
   }
   
   void KJS::HTMLDocument::put(ExecState *exec, const Identifier &propertyName, const Value& value, int attr)
  
  
  
  1.167     +1 -1      WebCore/khtml/ecma/kjs_window.cpp
  
  Index: kjs_window.cpp
  ===================================================================
  RCS file: /cvs/root/WebCore/khtml/ecma/kjs_window.cpp,v
  retrieving revision 1.166
  retrieving revision 1.167
  diff -u -r1.166 -r1.167
  --- kjs_window.cpp	20 Jul 2005 02:35:30 -0000	1.166
  +++ kjs_window.cpp	21 Jul 2005 04:10:52 -0000	1.167
  @@ -1108,7 +1108,7 @@
         if (collection->length() == 1)
           return getDOMNode(exec, collection->firstItem());
         else 
  -        return getHTMLCollection(exec, &*collection);
  +        return getHTMLCollection(exec, collection.get());
       }
     }
   
  
  
  
  1.77      +30 -2     WebCore/khtml/html/html_baseimpl.cpp
  
  Index: html_baseimpl.cpp
  ===================================================================
  RCS file: /cvs/root/WebCore/khtml/html/html_baseimpl.cpp,v
  retrieving revision 1.76
  retrieving revision 1.77
  diff -u -r1.76 -r1.77
  --- html_baseimpl.cpp	18 Jul 2005 21:52:23 -0000	1.76
  +++ html_baseimpl.cpp	21 Jul 2005 04:10:52 -0000	1.77
  @@ -864,8 +864,36 @@
           addCSSLength(attr, CSS_PROP_HEIGHT, attr->value());
       else if (attr->name() == HTMLAttributes::align())
           addHTMLAlignment(attr);
  -    else
  -      HTMLFrameElementImpl::parseMappedAttribute(attr);
  +    else if (attr->name() == HTMLAttributes::name()) {
  +        DOMString newNameAttr = attr->value();
  +        if (inDocument() && getDocument()->isHTMLDocument()) {
  +            HTMLDocumentImpl *document = static_cast<HTMLDocumentImpl *>(getDocument());
  +            document->removeDocExtraNamedItem(oldNameAttr);
  +            document->addDocExtraNamedItem(newNameAttr);
  +        }
  +        oldNameAttr = newNameAttr;
  +    } else
  +        HTMLFrameElementImpl::parseMappedAttribute(attr);
  +}
  +
  +void HTMLIFrameElementImpl::insertedIntoDocument()
  +{
  +    if (getDocument()->isHTMLDocument()) {
  +        HTMLDocumentImpl *document = static_cast<HTMLDocumentImpl *>(getDocument());
  +        document->addDocExtraNamedItem(oldNameAttr);
  +    }
  +
  +    HTMLElementImpl::insertedIntoDocument();
  +}
  +
  +void HTMLIFrameElementImpl::removedFromDocument()
  +{
  +    if (getDocument()->isHTMLDocument()) {
  +        HTMLDocumentImpl *document = static_cast<HTMLDocumentImpl *>(getDocument());
  +        document->removeDocExtraNamedItem(oldNameAttr);
  +    }
  +
  +    HTMLElementImpl::removedFromDocument();
   }
   
   bool HTMLIFrameElementImpl::rendererIsNeeded(RenderStyle *style)
  
  
  
  1.30      +6 -0      WebCore/khtml/html/html_baseimpl.h
  
  Index: html_baseimpl.h
  ===================================================================
  RCS file: /cvs/root/WebCore/khtml/html/html_baseimpl.h,v
  retrieving revision 1.29
  retrieving revision 1.30
  diff -u -r1.29 -r1.30
  --- html_baseimpl.h	18 Jul 2005 21:44:20 -0000	1.29
  +++ html_baseimpl.h	21 Jul 2005 04:10:52 -0000	1.30
  @@ -261,6 +261,9 @@
       virtual bool mapToEntry(const QualifiedName& attrName, MappedAttributeEntry& result) const;
       virtual void parseMappedAttribute(MappedAttributeImpl *attr);
   
  +    virtual void insertedIntoDocument();
  +    virtual void removedFromDocument();
  +
       virtual void attach();
       virtual bool rendererIsNeeded(khtml::RenderStyle *);
       virtual khtml::RenderObject *createRenderer(RenderArena *, khtml::RenderStyle *);
  @@ -283,6 +286,9 @@
       virtual void openURL();
   
       bool needWidgetUpdate;
  +
  + private:
  +    DOMString oldNameAttr;
   };
   
   } //namespace
  
  
  
  1.65      +35 -10    WebCore/khtml/html/html_documentimpl.cpp
  
  Index: html_documentimpl.cpp
  ===================================================================
  RCS file: /cvs/root/WebCore/khtml/html/html_documentimpl.cpp,v
  retrieving revision 1.64
  retrieving revision 1.65
  diff -u -r1.64 -r1.65
  --- html_documentimpl.cpp	20 Jul 2005 02:35:31 -0000	1.64
  +++ html_documentimpl.cpp	21 Jul 2005 04:10:52 -0000	1.65
  @@ -264,41 +264,66 @@
       m_render->repaint();
   }
   
  -void HTMLDocumentImpl::addNamedItem(const DOMString &name)
  +static void addItemToMap(HTMLDocumentImpl::NameCountMap& map, const DOMString& name)
   {
       if (name.length() == 0)
   	return;
    
  -    NameCountMap::iterator it = namedItemCounts.find(name.implementation()); 
  -    if (it == namedItemCounts.end())
  -        namedItemCounts.insert(name.implementation(), 1);
  +    HTMLDocumentImpl::NameCountMap::iterator it = map.find(name.implementation()); 
  +    if (it == map.end())
  +        map.insert(name.implementation(), 1);
       else
           ++(it->second);
   }
   
  -void HTMLDocumentImpl::removeNamedItem(const DOMString &name)
  -{ 
  +static void removeItemFromMap(HTMLDocumentImpl::NameCountMap& map, const DOMString& name)
  +{
       if (name.length() == 0)
   	return;
    
  -    NameCountMap::iterator it = namedItemCounts.find(name.implementation()); 
  -    if (it == namedItemCounts.end())
  +    HTMLDocumentImpl::NameCountMap::iterator it = map.find(name.implementation()); 
  +    if (it == map.end())
           return;
   
       int oldVal = it->second;
       assert(oldVal != 0);
       int newVal = oldVal - 1;
       if (newVal == 0)
  -        namedItemCounts.remove(it);
  +        map.remove(it);
       else
           it->second = newVal;
   }
   
  -bool HTMLDocumentImpl::hasNamedItem(const DOMString &name)
  +void HTMLDocumentImpl::addNamedItem(const DOMString& name)
  +{
  +    addItemToMap(namedItemCounts, name);
  +}
  +
  +void HTMLDocumentImpl::removeNamedItem(const DOMString &name)
  +{ 
  +    removeItemFromMap(namedItemCounts, name);
  +}
  +
  +bool HTMLDocumentImpl::hasNamedItem(const DOMString& name)
   {
       return namedItemCounts.get(name.implementation()) != 0;
   }
   
  +void HTMLDocumentImpl::addDocExtraNamedItem(const DOMString& name)
  +{
  +    addItemToMap(docExtraNamedItemCounts, name);
  +}
  +
  +void HTMLDocumentImpl::removeDocExtraNamedItem(const DOMString& name)
  +{ 
  +    removeItemFromMap(docExtraNamedItemCounts, name);
  +}
  +
  +bool HTMLDocumentImpl::hasDocExtraNamedItem(const DOMString& name)
  +{
  +    return docExtraNamedItemCounts.get(name.implementation()) != 0;
  +}
  +
   const int PARSEMODE_HAVE_DOCTYPE	=	(1<<0);
   const int PARSEMODE_HAVE_PUBLIC_ID	=	(1<<1);
   const int PARSEMODE_HAVE_SYSTEM_ID	=	(1<<2);
  
  
  
  1.32      +11 -6     WebCore/khtml/html/html_documentimpl.h
  
  Index: html_documentimpl.h
  ===================================================================
  RCS file: /cvs/root/WebCore/khtml/html/html_documentimpl.h,v
  retrieving revision 1.31
  retrieving revision 1.32
  diff -u -r1.31 -r1.32
  --- html_documentimpl.h	20 Jul 2005 02:35:31 -0000	1.31
  +++ html_documentimpl.h	21 Jul 2005 04:10:52 -0000	1.32
  @@ -62,9 +62,13 @@
   
       virtual void determineParseMode( const QString &str );
   
  -    void addNamedItem(const DOMString &name);
  -    void removeNamedItem(const DOMString &name);
  -    bool hasNamedItem(const DOMString &name);
  +    void addNamedItem(const DOMString& name);
  +    void removeNamedItem(const DOMString& name);
  +    bool hasNamedItem(const DOMString& name);
  +
  +    void addDocExtraNamedItem(const DOMString& name);
  +    void removeDocExtraNamedItem(const DOMString& name);
  +    bool hasDocExtraNamedItem(const DOMString& name);
   
       HTMLCollectionImpl::CollectionInfo *collectionInfo(int type)
       { 
  @@ -75,6 +79,8 @@
   
       virtual DocumentTypeImpl *doctype() const;
   
  +    typedef khtml::HashMap<DOMStringImpl *, int> NameCountMap;
  +
   protected:
       HTMLElementImpl *bodyElement;
       HTMLElementImpl *htmlElement;
  @@ -86,10 +92,9 @@
       void slotHistoryChanged();
   private:
       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.
  -    typedef khtml::HashMap<DOMStringImpl *, int> NameCountMap;
  +
       NameCountMap namedItemCounts;
  +    NameCountMap docExtraNamedItemCounts;
   };
   
   }; //namespace
  
  
  
  1.31      +13 -12    WebCore/khtml/html/html_miscimpl.cpp
  
  Index: html_miscimpl.cpp
  ===================================================================
  RCS file: /cvs/root/WebCore/khtml/html/html_miscimpl.cpp,v
  retrieving revision 1.30
  retrieving revision 1.31
  diff -u -r1.30 -r1.31
  --- html_miscimpl.cpp	20 Jul 2005 02:35:31 -0000	1.30
  +++ html_miscimpl.cpp	21 Jul 2005 04:10:52 -0000	1.31
  @@ -144,18 +144,6 @@
                   if(e->hasLocalName(HTMLTags::form()))
                       found = true;
                   break;
  -            case DOC_NAMEABLE_ITEMS:
  -                if (e->hasLocalName(HTMLTags::img()))
  -                    found = true;
  -                if (e->hasLocalName(HTMLTags::form()))
  -                    found = true;
  -                if (e->hasLocalName(HTMLTags::applet()))
  -                    found = true;
  -                if (e->hasLocalName(HTMLTags::embed()))
  -                    found = true;
  -                if (e->hasLocalName(HTMLTags::object()))
  -                    found = true;
  -                break;
               case TABLE_TBODIES:
                   if (e->hasLocalName(HTMLTags::tbody()))
                       found = true;
  @@ -390,6 +378,19 @@
                       found = e->getAttribute(HTMLAttributes::name()) == m_name;
                   found |= e->getAttribute(HTMLAttributes::idAttr()) == m_name;
                   break;
  +            case DOCUMENT_NAMED_ITEMS:
  +                // find images, forms, applets, embeds, objects and iframes by name, 
  +                // but only applets and object by id (this strange rule matches IE)
  +                if (e->hasTagName(HTMLTags::img()) ||
  +                    e->hasTagName(HTMLTags::form()) ||
  +                    e->hasTagName(HTMLTags::embed()) ||
  +                    e->hasTagName(HTMLTags::iframe()))
  +                    found = e->getAttribute(HTMLAttributes::name()) == m_name;
  +                else if (e->hasTagName(HTMLTags::applet()) ||
  +                         e->hasTagName(HTMLTags::object()))
  +                    found = e->getAttribute(HTMLAttributes::name()) == m_name ||
  +                        e->getAttribute(HTMLAttributes::idAttr()) == m_name;
  +                break;
               default:
                   assert(0);
               }
  
  
  
  1.20      +3 -4      WebCore/khtml/html/html_miscimpl.h
  
  Index: html_miscimpl.h
  ===================================================================
  RCS file: /cvs/root/WebCore/khtml/html/html_miscimpl.h,v
  retrieving revision 1.19
  retrieving revision 1.20
  diff -u -r1.19 -r1.20
  --- html_miscimpl.h	20 Jul 2005 02:35:31 -0000	1.19
  +++ html_miscimpl.h	21 Jul 2005 04:10:52 -0000	1.20
  @@ -78,13 +78,12 @@
           MAP_AREAS,
           DOC_ALL,        // "all" elements (IE)
           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
  -        WINDOW_NAMED_ITEMS
  +        WINDOW_NAMED_ITEMS,
  +        DOCUMENT_NAMED_ITEMS
       };
   
       enum {
  -        NUM_CACHEABLE_TYPES = DOC_NAMEABLE_ITEMS + 1
  +        NUM_CACHEABLE_TYPES = NODE_CHILDREN + 1
       };
   
       HTMLCollectionImpl(NodeImpl *_base, int _type);
  
  
  
  1.73      +24 -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.72
  retrieving revision 1.73
  diff -u -r1.72 -r1.73
  --- html_objectimpl.cpp	20 Jul 2005 04:04:53 -0000	1.72
  +++ html_objectimpl.cpp	21 Jul 2005 04:10:52 -0000	1.73
  @@ -121,6 +121,16 @@
               document->addNamedItem(newNameAttr);
           }
           oldNameAttr = newNameAttr;
  +    } else if (attr->name() == HTMLAttributes::idAttr()) {
  +        DOMString newIdAttr = attr->value();
  +        if (inDocument() && getDocument()->isHTMLDocument()) {
  +            HTMLDocumentImpl *document = static_cast<HTMLDocumentImpl *>(getDocument());
  +            document->removeDocExtraNamedItem(oldIdAttr);
  +            document->addDocExtraNamedItem(newIdAttr);
  +        }
  +        oldIdAttr = newIdAttr;
  +        // also call superclass
  +        HTMLElementImpl::parseMappedAttribute(attr);
       } else
           HTMLElementImpl::parseMappedAttribute(attr);
   }
  @@ -130,6 +140,7 @@
       if (getDocument()->isHTMLDocument()) {
           HTMLDocumentImpl *document = static_cast<HTMLDocumentImpl *>(getDocument());
           document->addNamedItem(oldNameAttr);
  +        document->addDocExtraNamedItem(oldIdAttr);
       }
   
       HTMLElementImpl::insertedIntoDocument();
  @@ -140,6 +151,7 @@
       if (getDocument()->isHTMLDocument()) {
           HTMLDocumentImpl *document = static_cast<HTMLDocumentImpl *>(getDocument());
           document->removeNamedItem(oldNameAttr);
  +        document->removeDocExtraNamedItem(oldIdAttr);
       }
   
       HTMLElementImpl::removedFromDocument();
  @@ -667,7 +679,16 @@
   		document->addNamedItem(newNameAttr);
   	    }
   	    oldNameAttr = newNameAttr;
  -
  +    } else if (attr->name() == HTMLAttributes::idAttr()) {
  +        DOMString newIdAttr = attr->value();
  +        if (inDocument() && getDocument()->isHTMLDocument()) {
  +            HTMLDocumentImpl *document = static_cast<HTMLDocumentImpl *>(getDocument());
  +            document->removeDocExtraNamedItem(oldIdAttr);
  +            document->addDocExtraNamedItem(newIdAttr);
  +        }
  +        oldIdAttr = newIdAttr;
  +        // also call superclass
  +        HTMLElementImpl::parseMappedAttribute(attr);
       } else
           HTMLElementImpl::parseMappedAttribute(attr);
   }
  @@ -752,6 +773,7 @@
       if (getDocument()->isHTMLDocument()) {
           HTMLDocumentImpl *document = static_cast<HTMLDocumentImpl *>(getDocument());
           document->addNamedItem(oldNameAttr);
  +        document->addDocExtraNamedItem(oldIdAttr);
       }
   
       HTMLElementImpl::insertedIntoDocument();
  @@ -762,6 +784,7 @@
       if (getDocument()->isHTMLDocument()) {
           HTMLDocumentImpl *document = static_cast<HTMLDocumentImpl *>(getDocument());
           document->removeNamedItem(oldNameAttr);
  +        document->removeDocExtraNamedItem(oldIdAttr);
       }
   
       HTMLElementImpl::removedFromDocument();
  
  
  
  1.35      +2 -0      WebCore/khtml/html/html_objectimpl.h
  
  Index: html_objectimpl.h
  ===================================================================
  RCS file: /cvs/root/WebCore/khtml/html/html_objectimpl.h,v
  retrieving revision 1.34
  retrieving revision 1.35
  diff -u -r1.34 -r1.35
  --- html_objectimpl.h	20 Jul 2005 02:35:31 -0000	1.34
  +++ html_objectimpl.h	21 Jul 2005 04:10:53 -0000	1.35
  @@ -105,6 +105,7 @@
   
   private:
       DOMString oldNameAttr;
  +    DOMString oldIdAttr;
   #if APPLE_CHANGES
       mutable KJS::Bindings::Instance *appletInstance;
       bool m_allParamsAvailable;
  @@ -247,6 +248,7 @@
       HTMLImageLoader* m_imageLoader;
   
   private:
  +    DOMString oldIdAttr;
       DOMString oldNameAttr;
   #if APPLE_CHANGES
       mutable KJS::Bindings::Instance *objectInstance;
  
  
  
  1.240     +4 -4      WebCore/khtml/xml/dom_docimpl.cpp
  
  Index: dom_docimpl.cpp
  ===================================================================
  RCS file: /cvs/root/WebCore/khtml/xml/dom_docimpl.cpp,v
  retrieving revision 1.239
  retrieving revision 1.240
  diff -u -r1.239 -r1.240
  --- dom_docimpl.cpp	20 Jul 2005 02:35:33 -0000	1.239
  +++ dom_docimpl.cpp	21 Jul 2005 04:10:54 -0000	1.240
  @@ -3050,14 +3050,14 @@
       return SharedPtr<HTMLCollectionImpl>(new HTMLCollectionImpl(this, HTMLCollectionImpl::DOC_ALL));
   }
   
  -SharedPtr<HTMLCollectionImpl> DocumentImpl::nameableItems()
  +SharedPtr<HTMLCollectionImpl> DocumentImpl::windowNamedItems(DOMString &name)
   {
  -    return SharedPtr<HTMLCollectionImpl>(new HTMLCollectionImpl(this, HTMLCollectionImpl::DOC_NAMEABLE_ITEMS));
  +    return SharedPtr<HTMLCollectionImpl>(new HTMLNameCollectionImpl(this, HTMLCollectionImpl::WINDOW_NAMED_ITEMS, name));
   }
   
  -SharedPtr<HTMLCollectionImpl> DocumentImpl::windowNamedItems(DOMString &name)
  +SharedPtr<HTMLCollectionImpl> DocumentImpl::documentNamedItems(DOMString &name)
   {
  -    return SharedPtr<HTMLCollectionImpl>(new HTMLNameCollectionImpl(this, HTMLCollectionImpl::WINDOW_NAMED_ITEMS, name));
  +    return SharedPtr<HTMLCollectionImpl>(new HTMLNameCollectionImpl(this, HTMLCollectionImpl::DOCUMENT_NAMED_ITEMS, name));
   }
   
   SharedPtr<NameNodeListImpl> DocumentImpl::getElementsByName(const DOMString &elementName)
  
  
  
  1.120     +1 -1      WebCore/khtml/xml/dom_docimpl.h
  
  Index: dom_docimpl.h
  ===================================================================
  RCS file: /cvs/root/WebCore/khtml/xml/dom_docimpl.h,v
  retrieving revision 1.119
  retrieving revision 1.120
  diff -u -r1.119 -r1.120
  --- dom_docimpl.h	20 Jul 2005 02:35:33 -0000	1.119
  +++ dom_docimpl.h	21 Jul 2005 04:10:54 -0000	1.120
  @@ -206,8 +206,8 @@
       SharedPtr<HTMLCollectionImpl> anchors();
       SharedPtr<HTMLCollectionImpl> all();
       SharedPtr<HTMLCollectionImpl> objects();
  -    SharedPtr<HTMLCollectionImpl> nameableItems();
       SharedPtr<HTMLCollectionImpl> windowNamedItems(DOMString &name);
  +    SharedPtr<HTMLCollectionImpl> documentNamedItems(DOMString &name);
   
       // DOM methods overridden from  parent classes
   
  
  
  
  1.1                  WebCore/layout-tests/fast/dom/HTMLDocument/document-special-properties-expected.txt
  
  Index: document-special-properties-expected.txt
  ===================================================================
  This test covers the various ways of accessing DOM elements through the document object by name, id or index, directly as properties of the document object. This lookup is supposed to include applet, embed, form, image, object and iframe by name, but only applet and object 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 exactly one item that is an iframe matches, it will give the window object for that iframe.
  
  Our results match 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): undefined
  Image by id (multiple): undefined
  Image by id/name mixed: collection(2) IMG(name) IMG(name)
  
  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): undefined
  Form by id (multiple): undefined
  Form by id/name mixed: collection(2) FORM(name) FORM(name)
  
  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): undefined
  Embed by id (multiple): undefined
  Embed by id/name mixed: collection(2) EMBED(name) EMBED(name)
  
  Nonexistent iframe name: undefined
  Iframe by name (unique): single WINDOW
  Iframe by name (multiple): collection(2) IFRAME(name) IFRAME(name)
  Iframe by id (unique): undefined
  Iframe by id (multiple): undefined
  Iframe by id/name mixed: collection(2) IFRAME(name) IFRAME(name)
  
  Nonexistent span name: undefined
  Span by name (unique): undefined
  Span by name (multiple): undefined
  Span by id (unique): undefined
  Span by id (multiple): undefined
  Span by id/name mixed: undefined
  
  Mixed by id: collection(2) APPLET(id) OBJECT(id)
  Mixed by name: collection(6) IMG(name) FORM(name) APPLET(name) EMBED(name) OBJECT(name) IFRAME(name)
  Mixed by id (no iframe): collection(2) APPLET(id) OBJECT(id)
  Mixed by name (no iframe): collection(5) IMG(name) FORM(name) APPLET(name) EMBED(name) OBJECT(name)
  
  Numeric 0: undefined
  Numeric 12: undefined
  Numeric 13: undefined
  
  Conflicting image: single IMG(name)
  Conflicting image (custom property): single IMG(name)
  Conflicting iframe: single WINDOW
  
  
  
  
  1.1                  WebCore/layout-tests/fast/dom/HTMLDocument/document-special-properties.html
  
  Index: document-special-properties.html
  ===================================================================
  <body>
  
  <p>This test covers the various ways of accessing DOM elements through
  the document object by name, id or index, directly as properties of
  the document object. This lookup is supposed to include applet, embed,
  form, image, object and iframe by name, but only applet and object 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
  exactly one item that is an iframe matches, it will give the window
  object for that iframe.
  </p>
  
  <p>Our results match IE.</p>
  
  <hr>
  
  <script>
  document.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="body" 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 = document[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", "body");
  testProperty("Conflicting image (custom property)", "custom");
  testProperty("Conflicting iframe", "location");
  
  </script>
  </body>
  
  
  



More information about the webkit-changes mailing list