Changeset 10935 in webkit


Ignore:
Timestamp:
Oct 24, 2005 2:42:15 PM (19 years ago)
Author:
harrison
Message:

Reviewed by Darin. Committed by David Harrison.

http://bugzilla.opendarwin.org/show_bug.cgi?id=5449
"OBJECT should be accessible by id/name as document property only if its only children are PARAMs"

Test added:

  • fast/js/object-by-name-or-id-expected.txt: Added.
  • fast/js/object-by-name-or-id.html: Added.

Files changed:

  • khtml/html/html_miscimpl.cpp: (DOM::HTMLNameCollectionImpl::traverseNextItem):
  • khtml/html/html_objectimpl.cpp: (DOM::HTMLObjectElementImpl::HTMLObjectElementImpl): (DOM::HTMLObjectElementImpl::parseMappedAttribute): (DOM::HTMLObjectElementImpl::insertedIntoDocument): (DOM::HTMLObjectElementImpl::removedFromDocument): (DOM::HTMLObjectElementImpl::childrenChanged): (DOM::HTMLObjectElementImpl::updateDocNamedItem):
  • khtml/html/html_objectimpl.h: (DOM::HTMLObjectElementImpl::isDocNamedItem):
  • manual-tests/drag_select_highlighting.html: Added.
Location:
trunk/WebCore
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/WebCore/ChangeLog-2005-12-19

    r10934 r10935  
     12005-10-24  Mitz Pettel  <opendarwin.org@mitzpettel.com>
     2
     3        Reviewed by Darin.  Committed by David Harrison.
     4
     5        http://bugzilla.opendarwin.org/show_bug.cgi?id=5449
     6        "OBJECT should be accessible by id/name as document property only if its only children are PARAMs"
     7
     8        Test added:
     9        * fast/js/object-by-name-or-id-expected.txt: Added.
     10        * fast/js/object-by-name-or-id.html: Added.
     11
     12        Files changed:
     13        * khtml/html/html_miscimpl.cpp:
     14        (DOM::HTMLNameCollectionImpl::traverseNextItem):
     15        * khtml/html/html_objectimpl.cpp:
     16        (DOM::HTMLObjectElementImpl::HTMLObjectElementImpl):
     17        (DOM::HTMLObjectElementImpl::parseMappedAttribute):
     18        (DOM::HTMLObjectElementImpl::insertedIntoDocument):
     19        (DOM::HTMLObjectElementImpl::removedFromDocument):
     20        (DOM::HTMLObjectElementImpl::childrenChanged):
     21        (DOM::HTMLObjectElementImpl::updateDocNamedItem):
     22        * khtml/html/html_objectimpl.h:
     23        (DOM::HTMLObjectElementImpl::isDocNamedItem):
     24        * manual-tests/drag_select_highlighting.html: Added.
     25
    1262005-10-24  Mitz Pettel  <opendarwin.org@mitzpettel.com>
    227
  • trunk/WebCore/khtml/html/html_miscimpl.cpp

    r10701 r10935  
    2828#include "html/html_imageimpl.h"
    2929#include "html/html_documentimpl.h"
     30#include "html/html_objectimpl.h"
    3031
    3132#include "dom/dom_node.h"
     
    394395                    e->hasTagName(iframeTag))
    395396                    found = e->getAttribute(nameAttr) == m_name;
    396                 else if (e->hasTagName(appletTag) ||
    397                          e->hasTagName(objectTag))
     397                else if (e->hasTagName(appletTag))
    398398                    found = e->getAttribute(nameAttr) == m_name ||
    399399                        e->getAttribute(idAttr) == m_name;
     400                else if (e->hasTagName(objectTag))
     401                    found = (e->getAttribute(nameAttr) == m_name || e->getAttribute(idAttr) == m_name) &&
     402                        static_cast<HTMLObjectElementImpl *>(e)->isDocNamedItem();
    400403                break;
    401404            default:
  • trunk/WebCore/khtml/html/html_objectimpl.cpp

    r10930 r10935  
    4343#include "rendering/render_image.h"
    4444#include "xml/dom2_eventsimpl.h"
     45#include "xml/dom_textimpl.h"
    4546#include "xml/EventNames.h"
    4647
     
    562563    needWidgetUpdate = false;
    563564    m_useFallbackContent = false;
     565    m_docNamedItem = true;
    564566}
    565567
     
    679681    } else if (attr->name() == nameAttr) {
    680682            DOMString newNameAttr = attr->value();
    681             if (inDocument() && getDocument()->isHTMLDocument()) {
     683            if (isDocNamedItem() && inDocument() && getDocument()->isHTMLDocument()) {
    682684                HTMLDocumentImpl *document = static_cast<HTMLDocumentImpl *>(getDocument());
    683685                document->removeNamedItem(oldNameAttr);
     
    687689    } else if (attr->name() == idAttr) {
    688690        DOMString newIdAttr = attr->value();
    689         if (inDocument() && getDocument()->isHTMLDocument()) {
     691        if (isDocNamedItem() && inDocument() && getDocument()->isHTMLDocument()) {
    690692            HTMLDocumentImpl *document = static_cast<HTMLDocumentImpl *>(getDocument());
    691693            document->removeDocExtraNamedItem(oldIdAttr);
     
    780782void HTMLObjectElementImpl::insertedIntoDocument()
    781783{
    782     if (getDocument()->isHTMLDocument()) {
     784    if (isDocNamedItem() && getDocument()->isHTMLDocument()) {
    783785        HTMLDocumentImpl *document = static_cast<HTMLDocumentImpl *>(getDocument());
    784786        document->addNamedItem(oldNameAttr);
     
    791793void HTMLObjectElementImpl::removedFromDocument()
    792794{
    793     if (getDocument()->isHTMLDocument()) {
     795    if (isDocNamedItem() && getDocument()->isHTMLDocument()) {
    794796        HTMLDocumentImpl *document = static_cast<HTMLDocumentImpl *>(getDocument());
    795797        document->removeNamedItem(oldNameAttr);
     
    811813void HTMLObjectElementImpl::childrenChanged()
    812814{
     815    updateDocNamedItem();
    813816    if (inDocument() && !m_useFallbackContent) {
    814817        needWidgetUpdate = true;
     
    853856    detach();
    854857    attach();
     858}
     859
     860void HTMLObjectElementImpl::updateDocNamedItem()
     861{
     862    // The rule is "<object> elements with no children other than
     863    // <param> elements and whitespace can be found by name in a
     864    // document, and other <object> elements cannot."
     865    bool wasNamedItem = m_docNamedItem;
     866    bool isNamedItem = true;
     867    NodeImpl *child = firstChild();
     868    while (child && isNamedItem) {
     869        if (child->isElementNode()) {
     870            if (!static_cast<ElementImpl *>(child)->hasTagName(paramTag))
     871                isNamedItem = false;
     872        } else if (child->isTextNode()) {
     873            if (!static_cast<TextImpl *>(child)->containsOnlyWhitespace())
     874                isNamedItem = false;
     875        } else
     876            isNamedItem = false;
     877        child = child->nextSibling();
     878    }
     879    if (isNamedItem != wasNamedItem && getDocument()->isHTMLDocument()) {
     880        HTMLDocumentImpl *document = static_cast<HTMLDocumentImpl *>(getDocument());
     881        if (isNamedItem) {
     882            document->addNamedItem(oldNameAttr);
     883            document->addDocExtraNamedItem(oldIdAttr);
     884        } else {
     885            document->removeNamedItem(oldNameAttr);
     886            document->removeDocExtraNamedItem(oldIdAttr);
     887        }
     888    }
     889    m_docNamedItem = isNamedItem;
    855890}
    856891
  • trunk/WebCore/khtml/html/html_objectimpl.h

    r10556 r10935  
    237237    void setWidth(const DOMString &);
    238238
     239    bool isDocNamedItem() const { return m_docNamedItem; }
    239240#if APPLE_CHANGES
    240241    KJS::Bindings::Instance *getObjectInstance() const;
     
    249250
    250251private:
     252    void updateDocNamedItem();
    251253    DOMString oldIdAttr;
    252254    DOMString oldNameAttr;
     
    254256    mutable KJS::Bindings::Instance *objectInstance;
    255257#endif
     258    bool m_docNamedItem;
    256259};
    257260
Note: See TracChangeset for help on using the changeset viewer.