Changeset 103116 in webkit


Ignore:
Timestamp:
Dec 16, 2011 3:15:10 PM (12 years ago)
Author:
rniwa@webkit.org
Message:

invalidateNodeListsCacheAfterAttributeChanged has too many callers
https://bugs.webkit.org/show_bug.cgi?id=74692

Reviewed by Sam Weinig.

Source/WebCore:

Call invalidateNodeListsCacheAfterAttributeChanged in Element::updateAfterAttributeChanged instead of
parsedMappedAttribute of various elements. Also make invalidateNodeListsCacheAfterAttributeChanged take
the qualified name of the changed attribute so that we can exit early when the changed attribute isn't
one of attributes we care.

In addition, added a missing call to invalidateNodeListsCacheAfterAttributeChanged in Attr::setValue.

Test: fast/dom/Attr/invalidate-nodelist-after-attr-setvalue.html

  • dom/Attr.cpp:

(WebCore::Attr::childrenChanged):

  • dom/Element.cpp:

(WebCore::Element::updateAfterAttributeChanged):

  • dom/NamedNodeMap.cpp:

(WebCore::NamedNodeMap::addAttribute):
(WebCore::NamedNodeMap::removeAttribute):

  • dom/Node.cpp:

(WebCore::Node::invalidateNodeListsCacheAfterAttributeChanged):

  • dom/Node.h:
  • dom/StyledElement.cpp:

(WebCore::StyledElement::classAttributeChanged):

  • html/HTMLAnchorElement.cpp:

(WebCore::HTMLAnchorElement::parseMappedAttribute):

  • html/HTMLAppletElement.cpp:

(WebCore::HTMLAppletElement::parseMappedAttribute):

  • html/HTMLElement.cpp:

(WebCore::HTMLElement::parseMappedAttribute):

  • html/HTMLEmbedElement.cpp:

(WebCore::HTMLEmbedElement::parseMappedAttribute):

  • html/HTMLFormElement.cpp:

(WebCore::HTMLFormElement::parseMappedAttribute):

  • html/HTMLFrameElementBase.cpp:

(WebCore::HTMLFrameElementBase::parseMappedAttribute):

  • html/HTMLIFrameElement.cpp:

(WebCore::HTMLIFrameElement::parseMappedAttribute):

  • html/HTMLImageElement.cpp:

(WebCore::HTMLImageElement::parseMappedAttribute):

  • html/HTMLMapElement.cpp:

(WebCore::HTMLMapElement::parseMappedAttribute):

  • html/HTMLMetaElement.cpp:

(WebCore::HTMLMetaElement::parseMappedAttribute):

  • html/HTMLObjectElement.cpp:

(WebCore::HTMLObjectElement::parseMappedAttribute):

  • html/HTMLParamElement.cpp:

(WebCore::HTMLParamElement::parseMappedAttribute):

LayoutTests:

Add a regression test for setting Attr's value. WebKit should invalidate the cache as needed.

  • fast/dom/Attr/invalidate-nodelist-after-attr-setvalue-expected.txt: Added.
  • fast/dom/Attr/invalidate-nodelist-after-attr-setvalue.html: Added.
Location:
trunk
Files:
2 added
20 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r103115 r103116  
     12011-12-16  Ryosuke Niwa  <rniwa@webkit.org>
     2
     3        invalidateNodeListsCacheAfterAttributeChanged has too many callers
     4        https://bugs.webkit.org/show_bug.cgi?id=74692
     5
     6        Reviewed by Sam Weinig.
     7
     8        Add a regression test for setting Attr's value. WebKit should invalidate the cache as needed.
     9
     10        * fast/dom/Attr/invalidate-nodelist-after-attr-setvalue-expected.txt: Added.
     11        * fast/dom/Attr/invalidate-nodelist-after-attr-setvalue.html: Added.
     12
    1132011-12-16  Andreas Kling  <kling@webkit.org>
    214
  • trunk/Source/WebCore/ChangeLog

    r103115 r103116  
     12011-12-16  Ryosuke Niwa  <rniwa@webkit.org>
     2
     3        invalidateNodeListsCacheAfterAttributeChanged has too many callers
     4        https://bugs.webkit.org/show_bug.cgi?id=74692
     5
     6        Reviewed by Sam Weinig.
     7
     8        Call invalidateNodeListsCacheAfterAttributeChanged in Element::updateAfterAttributeChanged instead of
     9        parsedMappedAttribute of various elements. Also make invalidateNodeListsCacheAfterAttributeChanged take
     10        the qualified name of the changed attribute so that we can exit early when the changed attribute isn't
     11        one of attributes we care.
     12
     13        In addition, added a missing call to invalidateNodeListsCacheAfterAttributeChanged in Attr::setValue.
     14
     15        Test: fast/dom/Attr/invalidate-nodelist-after-attr-setvalue.html
     16
     17        * dom/Attr.cpp:
     18        (WebCore::Attr::childrenChanged):
     19        * dom/Element.cpp:
     20        (WebCore::Element::updateAfterAttributeChanged):
     21        * dom/NamedNodeMap.cpp:
     22        (WebCore::NamedNodeMap::addAttribute):
     23        (WebCore::NamedNodeMap::removeAttribute):
     24        * dom/Node.cpp:
     25        (WebCore::Node::invalidateNodeListsCacheAfterAttributeChanged):
     26        * dom/Node.h:
     27        * dom/StyledElement.cpp:
     28        (WebCore::StyledElement::classAttributeChanged):
     29        * html/HTMLAnchorElement.cpp:
     30        (WebCore::HTMLAnchorElement::parseMappedAttribute):
     31        * html/HTMLAppletElement.cpp:
     32        (WebCore::HTMLAppletElement::parseMappedAttribute):
     33        * html/HTMLElement.cpp:
     34        (WebCore::HTMLElement::parseMappedAttribute):
     35        * html/HTMLEmbedElement.cpp:
     36        (WebCore::HTMLEmbedElement::parseMappedAttribute):
     37        * html/HTMLFormElement.cpp:
     38        (WebCore::HTMLFormElement::parseMappedAttribute):
     39        * html/HTMLFrameElementBase.cpp:
     40        (WebCore::HTMLFrameElementBase::parseMappedAttribute):
     41        * html/HTMLIFrameElement.cpp:
     42        (WebCore::HTMLIFrameElement::parseMappedAttribute):
     43        * html/HTMLImageElement.cpp:
     44        (WebCore::HTMLImageElement::parseMappedAttribute):
     45        * html/HTMLMapElement.cpp:
     46        (WebCore::HTMLMapElement::parseMappedAttribute):
     47        * html/HTMLMetaElement.cpp:
     48        (WebCore::HTMLMetaElement::parseMappedAttribute):
     49        * html/HTMLObjectElement.cpp:
     50        (WebCore::HTMLObjectElement::parseMappedAttribute):
     51        * html/HTMLParamElement.cpp:
     52        (WebCore::HTMLParamElement::parseMappedAttribute):
     53
    1542011-12-16  Andreas Kling  <kling@webkit.org>
    255
  • trunk/Source/WebCore/dom/Attr.cpp

    r102814 r103116  
    127127    createTextChild();
    128128    m_ignoreChildrenChanged--;
     129
     130    invalidateNodeListsCacheAfterAttributeChanged(m_attribute->name());
    129131}
    130132
     
    181183    Node::childrenChanged(changedByParser, beforeChange, afterChange, childCountDelta);
    182184
    183     invalidateNodeListsCacheAfterAttributeChanged();
     185    invalidateNodeListsCacheAfterAttributeChanged(m_attribute->name());
    184186
    185187    // FIXME: We should include entity references in the value
    186    
     188
    187189    String val = "";
    188190    for (Node *n = firstChild(); n; n = n->nextSibling()) {
  • trunk/Source/WebCore/dom/Element.cpp

    r103017 r103116  
    698698void Element::updateAfterAttributeChanged(Attribute* attr)
    699699{
     700    invalidateNodeListsCacheAfterAttributeChanged(attr->name());
     701
    700702    if (!AXObjectCache::accessibilityEnabled())
    701703        return;
  • trunk/Source/WebCore/dom/NamedNodeMap.cpp

    r102814 r103116  
    265265        // Because of our updateStyleAttribute() style modification events are never sent at the right time, so don't bother sending them.
    266266        if (attribute->name() != styleAttr) {
    267             m_element->invalidateNodeListsCacheAfterAttributeChanged();
    268267            m_element->dispatchAttrAdditionEvent(attribute.get());
    269268            m_element->dispatchSubtreeModifiedEvent();
     
    302301    }
    303302    if (m_element) {
    304         m_element->invalidateNodeListsCacheAfterAttributeChanged();
    305303        m_element->dispatchAttrRemovalEvent(attr.get());
    306304        m_element->dispatchSubtreeModifiedEvent();
  • trunk/Source/WebCore/dom/Node.cpp

    r103001 r103116  
    10211021}
    10221022
    1023 void Node::invalidateNodeListsCacheAfterAttributeChanged()
     1023void Node::invalidateNodeListsCacheAfterAttributeChanged(const QualifiedName& attrName)
    10241024{
    10251025    if (hasRareData() && isAttributeNode()) {
     
    10281028        data->clearChildNodeListCache();
    10291029    }
     1030
     1031    // This list should be sync'ed with NodeListsNodeData.
     1032    if (attrName != classAttr
     1033#if ENABLE(MICRODATA)
     1034        && attrName != itemscopeAttr
     1035        && attrName != itempropAttr
     1036#endif
     1037        && attrName != nameAttr)
     1038        return;
    10301039
    10311040    if (!treeScope()->hasNodeListCaches())
  • trunk/Source/WebCore/dom/Node.h

    r103001 r103116  
    520520    void registerDynamicSubtreeNodeList(DynamicSubtreeNodeList*);
    521521    void unregisterDynamicSubtreeNodeList(DynamicSubtreeNodeList*);
    522     void invalidateNodeListsCacheAfterAttributeChanged();
     522    void invalidateNodeListsCacheAfterAttributeChanged(const QualifiedName&);
    523523    void invalidateNodeListsCacheAfterChildrenChanged();
    524524    void notifyLocalNodeListsLabelChanged();
  • trunk/Source/WebCore/dom/StyledElement.cpp

    r102431 r103116  
    229229        attributeMap()->clearClass();
    230230    setNeedsStyleRecalc();
    231     invalidateNodeListsCacheAfterAttributeChanged();
    232231    dispatchSubtreeModifiedEvent();
    233232}
  • trunk/Source/WebCore/html/HTMLAnchorElement.cpp

    r102606 r103116  
    224224        }
    225225        invalidateCachedVisitedLinkHash();
    226     } else if (attr->name() == nameAttr) {
    227         invalidateNodeListsCacheAfterAttributeChanged();
    228     } else if (attr->name() == titleAttr) {
     226    } else if (attr->name() == nameAttr || attr->name() == titleAttr) {
    229227        // Do nothing.
    230228    } else if (attr->name() == relAttr)
  • trunk/Source/WebCore/html/HTMLAppletElement.cpp

    r102511 r103116  
    6565        }
    6666        m_name = newName;
    67         invalidateNodeListsCacheAfterAttributeChanged();
    6867    } else if (isIdAttributeName(attr->name())) {
    6968        const AtomicString& newId = attr->value();
  • trunk/Source/WebCore/html/HTMLElement.cpp

    r102511 r103116  
    211211        } else if (equalIgnoringCase(value, "false"))
    212212            addCSSProperty(attr, CSSPropertyWebkitUserDrag, CSSValueNone);
    213     } else if (attr->name() == nameAttr) {
    214         invalidateNodeListsCacheAfterAttributeChanged();
    215213#if ENABLE(MICRODATA)
    216214    } else if (attr->name() == itempropAttr) {
  • trunk/Source/WebCore/html/HTMLEmbedElement.cpp

    r102983 r103116  
    119119        }
    120120        m_name = value;
    121         invalidateNodeListsCacheAfterAttributeChanged();
    122121    } else
    123122        HTMLPlugInImageElement::parseMappedAttribute(attr);
  • trunk/Source/WebCore/html/HTMLFormElement.cpp

    r102511 r103116  
    393393        }
    394394        m_name = newName;
    395         invalidateNodeListsCacheAfterAttributeChanged();
    396395    } else
    397396        HTMLElement::parseMappedAttribute(attr);
  • trunk/Source/WebCore/html/HTMLFrameElementBase.cpp

    r102511 r103116  
    142142    } else if (attr->name() == nameAttr) {
    143143        m_frameName = attr->value();
    144         invalidateNodeListsCacheAfterAttributeChanged();
    145144        // FIXME: If we are already attached, this doesn't actually change the frame's name.
    146145        // FIXME: If we are already attached, this doesn't check for frame name
  • trunk/Source/WebCore/html/HTMLIFrameElement.cpp

    r102511 r103116  
    8585        }
    8686        m_name = newName;
    87         invalidateNodeListsCacheAfterAttributeChanged();
    8887    } else if (attr->name() == frameborderAttr) {
    8988        // Frame border doesn't really match the HTML4 spec definition for iframes.  It simply adds
  • trunk/Source/WebCore/html/HTMLImageElement.cpp

    r102511 r103116  
    142142        }
    143143        m_name = newName;
    144         invalidateNodeListsCacheAfterAttributeChanged();
    145144    } else if (isIdAttributeName(attr->name())) {
    146145        const AtomicString& newId = attr->value();
  • trunk/Source/WebCore/html/HTMLMapElement.cpp

    r102511 r103116  
    121121            treeScope()->addImageMap(this);
    122122
    123         if (attrName == nameAttr)
    124             invalidateNodeListsCacheAfterAttributeChanged();
    125123        return;
    126124    }
  • trunk/Source/WebCore/html/HTMLMetaElement.cpp

    r102511 r103116  
    5050        process();
    5151    else if (attr->name() == nameAttr) {
    52         invalidateNodeListsCacheAfterAttributeChanged();
     52        // Do nothing
    5353    } else
    5454        HTMLElement::parseMappedAttribute(attr);
  • trunk/Source/WebCore/html/HTMLObjectElement.cpp

    r102983 r103116  
    123123        }
    124124        m_name = newName;
    125         invalidateNodeListsCacheAfterAttributeChanged();
    126125    } else if (attr->name() == borderAttr)
    127126        applyBorderAttribute(attr);
  • trunk/Source/WebCore/html/HTMLParamElement.cpp

    r102511 r103116  
    5858    } else if (attr->name() == nameAttr) {
    5959        m_name = attr->value();
    60         invalidateNodeListsCacheAfterAttributeChanged();
    6160    } else if (attr->name() == valueAttr) {
    6261        m_value = attr->value();
Note: See TracChangeset for help on using the changeset viewer.