Changeset 158540 in webkit


Ignore:
Timestamp:
Nov 3, 2013 1:32:00 PM (10 years ago)
Author:
Antti Koivisto
Message:

LiveNodeLists should have non-null ContainerNode as root
https://bugs.webkit.org/show_bug.cgi?id=123709

Reviewed by Andreas Kling.

After moving ChildNodeList off from LiveNodeList the root is now always at least a ContainerNode.

  • dom/ContainerNode.cpp:

(WebCore::ContainerNode::getElementsByTagName):
(WebCore::ContainerNode::getElementsByTagNameNS):
(WebCore::ContainerNode::getElementsByName):
(WebCore::ContainerNode::getElementsByClassName):
(WebCore::ContainerNode::radioNodeList):

Also these move from Node to ContainerNode to make tighter typing work.

Location:
trunk/Source/WebCore
Files:
29 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r158537 r158540  
     12013-11-03  Antti Koivisto  <antti@apple.com>
     2
     3        LiveNodeLists should have non-null ContainerNode as root
     4        https://bugs.webkit.org/show_bug.cgi?id=123709
     5
     6        Reviewed by Andreas Kling.
     7
     8        After moving ChildNodeList off from LiveNodeList the root is now always at least a ContainerNode.
     9
     10        * dom/ContainerNode.cpp:
     11        (WebCore::ContainerNode::getElementsByTagName):
     12        (WebCore::ContainerNode::getElementsByTagNameNS):
     13        (WebCore::ContainerNode::getElementsByName):
     14        (WebCore::ContainerNode::getElementsByClassName):
     15        (WebCore::ContainerNode::radioNodeList):
     16       
     17            Also these move from Node to ContainerNode to make tighter typing work.
     18
    1192013-11-03  Antti Koivisto  <antti@apple.com>
    220
  • trunk/Source/WebCore/dom/ClassNodeList.cpp

    r157365 r158540  
    3737namespace WebCore {
    3838
    39 ClassNodeList::ClassNodeList(Node& rootNode, const String& classNames)
     39ClassNodeList::ClassNodeList(ContainerNode& rootNode, const String& classNames)
    4040    : LiveNodeList(rootNode, ClassNodeListType, InvalidateOnClassAttrChange)
    4141    , m_classNames(classNames, document().inQuirksMode())
  • trunk/Source/WebCore/dom/ClassNodeList.h

    r157065 r158540  
    4040class ClassNodeList : public LiveNodeList {
    4141public:
    42     static PassRefPtr<ClassNodeList> create(Node& rootNode, const String& classNames)
     42    static PassRefPtr<ClassNodeList> create(ContainerNode& rootNode, const String& classNames)
    4343    {
    4444        return adoptRef(new ClassNodeList(rootNode, classNames));
     
    5050
    5151private:
    52     ClassNodeList(Node& rootNode, const String& classNames);
     52    ClassNodeList(ContainerNode& rootNode, const String& classNames);
    5353
    5454    virtual bool nodeMatches(Element*) const;
  • trunk/Source/WebCore/dom/ContainerNode.cpp

    r157971 r158540  
    2828#include "Chrome.h"
    2929#include "ChromeClient.h"
     30#include "ClassNodeList.h"
    3031#include "ContainerNodeAlgorithms.h"
    3132#include "Editor.h"
     
    4243#include "JSLazyEventListener.h"
    4344#include "JSNode.h"
     45#include "LabelsNodeList.h"
     46#include "LiveNodeList.h"
    4447#include "LoaderStrategy.h"
    4548#include "MemoryCache.h"
    4649#include "MutationEvent.h"
     50#include "NameNodeList.h"
     51#include "NodeRareData.h"
    4752#include "NodeRenderStyle.h"
    4853#include "NodeTraversal.h"
    4954#include "Page.h"
    5055#include "PlatformStrategies.h"
     56#include "RadioNodeList.h"
    5157#include "RenderBox.h"
    5258#include "RenderTheme.h"
     
    5561#include "RootInlineBox.h"
    5662#include "SelectorQuery.h"
     63#include "TagNodeList.h"
    5764#include "TemplateContentDocumentFragment.h"
    5865#include "Text.h"
     
    11281135}
    11291136
     1137PassRefPtr<NodeList> ContainerNode::getElementsByTagName(const AtomicString& localName)
     1138{
     1139    if (localName.isNull())
     1140        return 0;
     1141
     1142    if (document().isHTMLDocument())
     1143        return ensureRareData().ensureNodeLists().addCacheWithAtomicName<HTMLTagNodeList>(*this, HTMLTagNodeListType, localName);
     1144    return ensureRareData().ensureNodeLists().addCacheWithAtomicName<TagNodeList>(*this, TagNodeListType, localName);
     1145}
     1146
     1147PassRefPtr<NodeList> ContainerNode::getElementsByTagNameNS(const AtomicString& namespaceURI, const AtomicString& localName)
     1148{
     1149    if (localName.isNull())
     1150        return 0;
     1151
     1152    if (namespaceURI == starAtom)
     1153        return getElementsByTagName(localName);
     1154
     1155    return ensureRareData().ensureNodeLists().addCacheWithQualifiedName(*this, namespaceURI.isEmpty() ? nullAtom : namespaceURI, localName);
     1156}
     1157
     1158PassRefPtr<NodeList> ContainerNode::getElementsByName(const String& elementName)
     1159{
     1160    return ensureRareData().ensureNodeLists().addCacheWithAtomicName<NameNodeList>(*this, NameNodeListType, elementName);
     1161}
     1162
     1163PassRefPtr<NodeList> ContainerNode::getElementsByClassName(const String& classNames)
     1164{
     1165    return ensureRareData().ensureNodeLists().addCacheWithName<ClassNodeList>(*this, ClassNodeListType, classNames);
     1166}
     1167
     1168PassRefPtr<RadioNodeList> ContainerNode::radioNodeList(const AtomicString& name)
     1169{
     1170    ASSERT(hasTagName(HTMLNames::formTag) || hasTagName(HTMLNames::fieldsetTag));
     1171    return ensureRareData().ensureNodeLists().addCacheWithAtomicName<RadioNodeList>(*this, RadioNodeListType, name);
     1172}
     1173
    11301174} // namespace WebCore
  • trunk/Source/WebCore/dom/ContainerNode.h

    r157653 r158540  
    133133    RefPtr<NodeList> querySelectorAll(const AtomicString& selectors, ExceptionCode&);
    134134
     135    PassRefPtr<NodeList> getElementsByTagName(const AtomicString&);
     136    PassRefPtr<NodeList> getElementsByTagNameNS(const AtomicString& namespaceURI, const AtomicString& localName);
     137    PassRefPtr<NodeList> getElementsByName(const String& elementName);
     138    PassRefPtr<NodeList> getElementsByClassName(const String& classNames);
     139    PassRefPtr<RadioNodeList> radioNodeList(const AtomicString&);
     140
    135141protected:
    136142    explicit ContainerNode(Document*, ConstructionType = CreateContainer);
  • trunk/Source/WebCore/dom/LiveNodeList.cpp

    r158536 r158540  
    3030namespace WebCore {
    3131
    32 Node& LiveNodeListBase::rootNode() const
     32ContainerNode& LiveNodeListBase::rootNode() const
    3333{
    3434    if (isRootedAtDocument() && ownerNode().inDocument())
     
    3636
    3737    return ownerNode();
    38 }
    39 
    40 ContainerNode* LiveNodeListBase::rootContainerNode() const
    41 {
    42     Node& rootNode = this->rootNode();
    43     if (!rootNode.isContainerNode())
    44         return 0;
    45     return &toContainerNode(rootNode);
    4638}
    4739
  • trunk/Source/WebCore/dom/LiveNodeList.h

    r158536 r158540  
    4949    };
    5050
    51     LiveNodeListBase(Node& ownerNode, NodeListRootType rootType, NodeListInvalidationType invalidationType,
     51    LiveNodeListBase(ContainerNode& ownerNode, NodeListRootType rootType, NodeListInvalidationType invalidationType,
    5252        bool shouldOnlyIncludeDirectChildren, CollectionType collectionType, ItemAfterOverrideType itemAfterOverrideType)
    5353        : m_ownerNode(ownerNode)
     
    8484    ALWAYS_INLINE NodeListInvalidationType invalidationType() const { return static_cast<NodeListInvalidationType>(m_invalidationType); }
    8585    ALWAYS_INLINE CollectionType type() const { return static_cast<CollectionType>(m_collectionType); }
    86     Node& ownerNode() const { return const_cast<Node&>(m_ownerNode.get()); }
     86    ContainerNode& ownerNode() const { return const_cast<ContainerNode&>(m_ownerNode.get()); }
    8787    ALWAYS_INLINE void invalidateCache(const QualifiedName* attrName) const
    8888    {
     
    9999protected:
    100100    Document& document() const { return m_ownerNode->document(); }
    101     Node& rootNode() const;
    102     ContainerNode* rootContainerNode() const;
     101    ContainerNode& rootNode() const;
    103102    bool overridesItemAfter() const { return m_overridesItemAfter; }
    104103
     
    142141    Node* itemBefore(Node* previousItem) const;
    143142
    144     Ref<Node> m_ownerNode;
     143    Ref<ContainerNode> m_ownerNode;
    145144    mutable Node* m_cachedItem;
    146145    mutable unsigned m_cachedLength;
     
    185184class LiveNodeList : public LiveNodeListBase {
    186185public:
    187     LiveNodeList(Node& ownerNode, CollectionType collectionType, NodeListInvalidationType invalidationType, NodeListRootType rootType = NodeListIsRootedAtNode)
     186    LiveNodeList(ContainerNode& ownerNode, CollectionType collectionType, NodeListInvalidationType invalidationType, NodeListRootType rootType = NodeListIsRootedAtNode)
    188187        : LiveNodeListBase(ownerNode, rootType, invalidationType, /*shouldOnlyIncludeDirectChildren*/ false, collectionType, DoesNotOverrideItemAfter)
    189188    { }
  • trunk/Source/WebCore/dom/NameNodeList.cpp

    r157065 r158540  
    3333using namespace HTMLNames;
    3434
    35 NameNodeList::NameNodeList(Node& rootNode, const AtomicString& name)
     35NameNodeList::NameNodeList(ContainerNode& rootNode, const AtomicString& name)
    3636    : LiveNodeList(rootNode, NameNodeListType, InvalidateOnNameAttrChange)
    3737    , m_name(name)
  • trunk/Source/WebCore/dom/NameNodeList.h

    r157065 r158540  
    3434class NameNodeList : public LiveNodeList {
    3535public:
    36     static PassRefPtr<NameNodeList> create(Node& rootNode, CollectionType type, const AtomicString& name)
     36    static PassRefPtr<NameNodeList> create(ContainerNode& rootNode, CollectionType type, const AtomicString& name)
    3737    {
    3838        ASSERT_UNUSED(type, type == NameNodeListType);
     
    4343
    4444private:
    45     NameNodeList(Node& rootNode, const AtomicString& name);
     45    NameNodeList(ContainerNode& rootNode, const AtomicString& name);
    4646
    4747    virtual bool nodeMatches(Element*) const;
  • trunk/Source/WebCore/dom/Node.cpp

    r158536 r158540  
    4040#include "CSSStyleSheet.h"
    4141#include "ChildNodeList.h"
    42 #include "ClassNodeList.h"
    4342#include "ContainerNodeAlgorithms.h"
    4443#include "ContextMenuController.h"
     
    7069#include "InspectorCounters.h"
    7170#include "KeyboardEvent.h"
    72 #include "LabelsNodeList.h"
    73 #include "LiveNodeList.h"
    7471#include "Logging.h"
    7572#include "MouseEvent.h"
    7673#include "MutationEvent.h"
    77 #include "NameNodeList.h"
    7874#include "NamedNodeMap.h"
    7975#include "NodeRareData.h"
     
    8480#include "ProcessingInstruction.h"
    8581#include "ProgressEvent.h"
    86 #include "RadioNodeList.h"
    8782#include "RegisteredEventListener.h"
    8883#include "RenderBlock.h"
     
    9590#include "StorageEvent.h"
    9691#include "StyleResolver.h"
    97 #include "TagNodeList.h"
    9892#include "TemplateContentDocumentFragment.h"
    9993#include "Text.h"
     
    10561050// FIXME: End of obviously misplaced HTML editing functions.  Try to move these out of Node.
    10571051
    1058 PassRefPtr<NodeList> Node::getElementsByTagName(const AtomicString& localName)
    1059 {
    1060     if (localName.isNull())
    1061         return 0;
    1062 
    1063     if (document().isHTMLDocument())
    1064         return ensureRareData().ensureNodeLists().addCacheWithAtomicName<HTMLTagNodeList>(*this, HTMLTagNodeListType, localName);
    1065     return ensureRareData().ensureNodeLists().addCacheWithAtomicName<TagNodeList>(*this, TagNodeListType, localName);
    1066 }
    1067 
    1068 PassRefPtr<NodeList> Node::getElementsByTagNameNS(const AtomicString& namespaceURI, const AtomicString& localName)
    1069 {
    1070     if (localName.isNull())
    1071         return 0;
    1072 
    1073     if (namespaceURI == starAtom)
    1074         return getElementsByTagName(localName);
    1075 
    1076     return ensureRareData().ensureNodeLists().addCacheWithQualifiedName(*this, namespaceURI.isEmpty() ? nullAtom : namespaceURI, localName);
    1077 }
    1078 
    1079 PassRefPtr<NodeList> Node::getElementsByName(const String& elementName)
    1080 {
    1081     return ensureRareData().ensureNodeLists().addCacheWithAtomicName<NameNodeList>(*this, NameNodeListType, elementName);
    1082 }
    1083 
    1084 PassRefPtr<NodeList> Node::getElementsByClassName(const String& classNames)
    1085 {
    1086     return ensureRareData().ensureNodeLists().addCacheWithName<ClassNodeList>(*this, ClassNodeListType, classNames);
    1087 }
    1088 
    1089 PassRefPtr<RadioNodeList> Node::radioNodeList(const AtomicString& name)
    1090 {
    1091     ASSERT(hasTagName(formTag) || hasTagName(fieldsetTag));
    1092     return ensureRareData().ensureNodeLists().addCacheWithAtomicName<RadioNodeList>(*this, RadioNodeListType, name);
    1093 }
    1094 
    10951052Document* Node::ownerDocument() const
    10961053{
  • trunk/Source/WebCore/dom/Node.h

    r158461 r158540  
    500500    void clearNodeLists();
    501501
    502     PassRefPtr<NodeList> getElementsByTagName(const AtomicString&);
    503     PassRefPtr<NodeList> getElementsByTagNameNS(const AtomicString& namespaceURI, const AtomicString& localName);
    504     PassRefPtr<NodeList> getElementsByName(const String& elementName);
    505     PassRefPtr<NodeList> getElementsByClassName(const String& classNames);
    506     PassRefPtr<RadioNodeList> radioNodeList(const AtomicString&);
    507 
    508502    virtual bool willRespondToMouseMoveEvents();
    509503    virtual bool willRespondToMouseClickEvents();
  • trunk/Source/WebCore/dom/NodeRareData.h

    r158536 r158540  
    107107
    108108    template<typename T>
    109     PassRefPtr<T> addCacheWithAtomicName(Node& node, CollectionType collectionType, const AtomicString& name)
     109    PassRefPtr<T> addCacheWithAtomicName(ContainerNode& node, CollectionType collectionType, const AtomicString& name)
    110110    {
    111111        NodeListAtomicNameCacheMap::AddResult result = m_atomicNameCaches.add(namedNodeListKey(collectionType, name), nullptr);
     
    120120    // FIXME: This function should be renamed since it doesn't have an atomic name.
    121121    template<typename T>
    122     PassRefPtr<T> addCacheWithAtomicName(Node& node, CollectionType collectionType)
     122    PassRefPtr<T> addCacheWithAtomicName(ContainerNode& node, CollectionType collectionType)
    123123    {
    124124        NodeListAtomicNameCacheMap::AddResult result = m_atomicNameCaches.add(namedNodeListKey(collectionType, starAtom), nullptr);
     
    138138
    139139    template<typename T>
    140     PassRefPtr<T> addCacheWithName(Node& node, CollectionType collectionType, const String& name)
     140    PassRefPtr<T> addCacheWithName(ContainerNode& node, CollectionType collectionType, const String& name)
    141141    {
    142142        NodeListNameCacheMap::AddResult result = m_nameCaches.add(namedNodeListKey(collectionType, name), nullptr);
     
    149149    }
    150150
    151     PassRefPtr<TagNodeList> addCacheWithQualifiedName(Node& node, const AtomicString& namespaceURI, const AtomicString& localName)
     151    PassRefPtr<TagNodeList> addCacheWithQualifiedName(ContainerNode& node, const AtomicString& namespaceURI, const AtomicString& localName)
    152152    {
    153153        QualifiedName name(nullAtom, localName, namespaceURI);
  • trunk/Source/WebCore/dom/TagNodeList.cpp

    r157065 r158540  
    3131namespace WebCore {
    3232
    33 TagNodeList::TagNodeList(Node& rootNode, CollectionType type, const AtomicString& namespaceURI, const AtomicString& localName)
     33TagNodeList::TagNodeList(ContainerNode& rootNode, CollectionType type, const AtomicString& namespaceURI, const AtomicString& localName)
    3434    : LiveNodeList(rootNode, type, DoNotInvalidateOnAttributeChanges)
    3535    , m_namespaceURI(namespaceURI)
     
    5656}
    5757
    58 HTMLTagNodeList::HTMLTagNodeList(Node& rootNode, const AtomicString& localName)
     58HTMLTagNodeList::HTMLTagNodeList(ContainerNode& rootNode, const AtomicString& localName)
    5959    : TagNodeList(rootNode, HTMLTagNodeListType, starAtom, localName)
    6060    , m_loweredLocalName(localName.lower())
  • trunk/Source/WebCore/dom/TagNodeList.h

    r157065 r158540  
    3434class TagNodeList : public LiveNodeList {
    3535public:
    36     static PassRefPtr<TagNodeList> create(Node& rootNode, const AtomicString& namespaceURI, const AtomicString& localName)
     36    static PassRefPtr<TagNodeList> create(ContainerNode& rootNode, const AtomicString& namespaceURI, const AtomicString& localName)
    3737    {
    3838        ASSERT(namespaceURI != starAtom);
     
    4040    }
    4141
    42     static PassRefPtr<TagNodeList> create(Node& rootNode, CollectionType type, const AtomicString& localName)
     42    static PassRefPtr<TagNodeList> create(ContainerNode& rootNode, CollectionType type, const AtomicString& localName)
    4343    {
    4444        ASSERT_UNUSED(type, type == TagNodeListType);
     
    4949
    5050protected:
    51     TagNodeList(Node& rootNode, CollectionType, const AtomicString& namespaceURI, const AtomicString& localName);
     51    TagNodeList(ContainerNode& rootNode, CollectionType, const AtomicString& namespaceURI, const AtomicString& localName);
    5252
    5353    virtual bool nodeMatches(Element*) const OVERRIDE;
     
    5959class HTMLTagNodeList : public TagNodeList {
    6060public:
    61     static PassRefPtr<HTMLTagNodeList> create(Node& rootNode, CollectionType type, const AtomicString& localName)
     61    static PassRefPtr<HTMLTagNodeList> create(ContainerNode& rootNode, CollectionType type, const AtomicString& localName)
    6262    {
    6363        ASSERT_UNUSED(type, type == HTMLTagNodeListType);
     
    6868
    6969private:
    70     HTMLTagNodeList(Node& rootNode, const AtomicString& localName);
     70    HTMLTagNodeList(ContainerNode& rootNode, const AtomicString& localName);
    7171
    7272    virtual bool nodeMatches(Element*) const OVERRIDE;
  • trunk/Source/WebCore/html/HTMLAllCollection.cpp

    r157065 r158540  
    3131namespace WebCore {
    3232
    33 PassRefPtr<HTMLAllCollection> HTMLAllCollection::create(Node& node, CollectionType type)
     33PassRefPtr<HTMLAllCollection> HTMLAllCollection::create(ContainerNode& node, CollectionType type)
    3434{
    3535    return adoptRef(new HTMLAllCollection(node, type));
    3636}
    3737
    38 HTMLAllCollection::HTMLAllCollection(Node& node, CollectionType type)
     38HTMLAllCollection::HTMLAllCollection(ContainerNode& node, CollectionType type)
    3939    : HTMLCollection(node, type, DoesNotOverrideItemAfter)
    4040{
  • trunk/Source/WebCore/html/HTMLAllCollection.h

    r157065 r158540  
    3333class HTMLAllCollection : public HTMLCollection {
    3434public:
    35     static PassRefPtr<HTMLAllCollection> create(Node&, CollectionType);
     35    static PassRefPtr<HTMLAllCollection> create(ContainerNode&, CollectionType);
    3636    virtual ~HTMLAllCollection();
    3737
     
    3939
    4040private:
    41     HTMLAllCollection(Node&, CollectionType);
     41    HTMLAllCollection(ContainerNode&, CollectionType);
    4242};
    4343
  • trunk/Source/WebCore/html/HTMLCollection.cpp

    r158536 r158540  
    156156}
    157157
    158 HTMLCollection::HTMLCollection(Node& ownerNode, CollectionType type, ItemAfterOverrideType itemAfterOverrideType)
     158HTMLCollection::HTMLCollection(ContainerNode& ownerNode, CollectionType type, ItemAfterOverrideType itemAfterOverrideType)
    159159    : LiveNodeListBase(ownerNode, rootTypeFromCollectionType(type), invalidationTypeExcludingIdAndNameAttributes(type),
    160160        WebCore::shouldOnlyIncludeDirectChildren(type), type, itemAfterOverrideType)
     
    162162}
    163163
    164 PassRefPtr<HTMLCollection> HTMLCollection::create(Node& base, CollectionType type)
     164PassRefPtr<HTMLCollection> HTMLCollection::create(ContainerNode& base, CollectionType type)
    165165{
    166166    return adoptRef(new HTMLCollection(base, type, DoesNotOverrideItemAfter));
     
    391391        return 0;
    392392
    393     ContainerNode* root = rootContainerNode();
    394     if (!root) {
    395         // FIMXE: In someTextNode.childNodes case the root is Text. We shouldn't even make a LiveNodeList for that.
    396         setLengthCache(0);
    397         return 0;
    398     }
     393    ContainerNode& root = rootNode();
    399394
    400395    if (isLengthCacheValid() && !overridesItemAfter() && isLastItemCloserThanLastOrCachedItem(offset)) {
     
    406401        Node* firstItem;
    407402        if (isNodeList(type()))
    408             firstItem = traverseLiveNodeListFirstElement(root);
     403            firstItem = traverseLiveNodeListFirstElement(&root);
    409404        else
    410             firstItem = static_cast<const HTMLCollection*>(this)->traverseFirstElement(offsetInArray, root);
     405            firstItem = static_cast<const HTMLCollection*>(this)->traverseFirstElement(offsetInArray, &root);
    411406
    412407        if (!firstItem) {
     
    421416        return cachedItem();
    422417
    423     return itemBeforeOrAfterCachedItem(offset, root);
     418    return itemBeforeOrAfterCachedItem(offset, &root);
    424419}
    425420
     
    544539    // that are allowed a name attribute.
    545540
    546     ContainerNode* root = rootContainerNode();
    547     if (name.isEmpty() || !root)
     541    if (name.isEmpty())
    548542        return 0;
    549543
    550     if (!overridesItemAfter() && root->isInTreeScope()) {
    551         TreeScope& treeScope = root->treeScope();
     544    ContainerNode& root = rootNode();
     545    if (!overridesItemAfter() && root.isInTreeScope()) {
     546        TreeScope& treeScope = root.treeScope();
    552547        Element* candidate = 0;
    553548        if (treeScope.hasElementWithId(*name.impl())) {
     
    565560        if (candidate
    566561            && isMatchingElement(this, candidate)
    567             && (shouldOnlyIncludeDirectChildren() ? candidate->parentNode() == root : candidate->isDescendantOf(root)))
     562            && (shouldOnlyIncludeDirectChildren() ? candidate->parentNode() == &root : candidate->isDescendantOf(&root)))
    568563            return candidate;
    569564    }
     
    590585        return;
    591586
    592     ContainerNode* root = rootContainerNode();
    593     if (!root)
    594         return;
     587    ContainerNode& root = rootNode();
    595588
    596589    unsigned arrayOffset = 0;
    597     for (Element* element = traverseFirstElement(arrayOffset, root); element; element = traverseNextElement(arrayOffset, element, root)) {
     590    for (Element* element = traverseFirstElement(arrayOffset, &root); element; element = traverseNextElement(arrayOffset, element, &root)) {
    598591        const AtomicString& idAttrVal = element->getIdAttribute();
    599592        if (!idAttrVal.isEmpty())
  • trunk/Source/WebCore/html/HTMLCollection.h

    r157653 r158540  
    3535class HTMLCollection : public LiveNodeListBase {
    3636public:
    37     static PassRefPtr<HTMLCollection> create(Node& base, CollectionType);
     37    static PassRefPtr<HTMLCollection> create(ContainerNode& base, CollectionType);
    3838    virtual ~HTMLCollection();
    3939
     
    6868
    6969protected:
    70     HTMLCollection(Node& base, CollectionType, ItemAfterOverrideType);
     70    HTMLCollection(ContainerNode& base, CollectionType, ItemAfterOverrideType);
    7171
    7272    virtual void updateNameCache() const;
  • trunk/Source/WebCore/html/HTMLFormControlsCollection.cpp

    r157357 r158540  
    3737// calculation every time if anything has changed.
    3838
    39 HTMLFormControlsCollection::HTMLFormControlsCollection(Node& ownerNode)
     39HTMLFormControlsCollection::HTMLFormControlsCollection(ContainerNode& ownerNode)
    4040    : HTMLCollection(ownerNode, FormControls, OverridesItemAfter)
    4141{
     
    4343}
    4444
    45 PassRefPtr<HTMLFormControlsCollection> HTMLFormControlsCollection::create(Node& ownerNode, CollectionType)
     45PassRefPtr<HTMLFormControlsCollection> HTMLFormControlsCollection::create(ContainerNode& ownerNode, CollectionType)
    4646{
    4747    return adoptRef(new HTMLFormControlsCollection(ownerNode));
  • trunk/Source/WebCore/html/HTMLFormControlsCollection.h

    r157065 r158540  
    3838class HTMLFormControlsCollection : public HTMLCollection {
    3939public:
    40     static PassRefPtr<HTMLFormControlsCollection> create(Node&, CollectionType);
     40    static PassRefPtr<HTMLFormControlsCollection> create(ContainerNode&, CollectionType);
    4141
    4242    virtual ~HTMLFormControlsCollection();
     
    4545
    4646private:
    47     explicit HTMLFormControlsCollection(Node&);
     47    explicit HTMLFormControlsCollection(ContainerNode&);
    4848
    4949    virtual void updateNameCache() const;
  • trunk/Source/WebCore/html/HTMLNameCollection.cpp

    r157065 r158540  
    3737using namespace HTMLNames;
    3838
    39 HTMLNameCollection::HTMLNameCollection(Node& document, CollectionType type, const AtomicString& name)
     39HTMLNameCollection::HTMLNameCollection(ContainerNode& document, CollectionType type, const AtomicString& name)
    4040    : HTMLCollection(document, type, DoesNotOverrideItemAfter)
    4141    , m_name(name)
  • trunk/Source/WebCore/html/HTMLNameCollection.h

    r157065 r158540  
    3737
    3838protected:
    39     HTMLNameCollection(Node&, CollectionType, const AtomicString& name);
     39    HTMLNameCollection(ContainerNode&, CollectionType, const AtomicString& name);
    4040
    4141    AtomicString m_name;
     
    4444class WindowNameCollection : public HTMLNameCollection {
    4545public:
    46     static PassRefPtr<WindowNameCollection> create(Node& document, CollectionType type, const AtomicString& name)
     46    static PassRefPtr<WindowNameCollection> create(ContainerNode& document, CollectionType type, const AtomicString& name)
    4747    {
    4848        return adoptRef(new WindowNameCollection(document, type, name));
     
    5656
    5757private:
    58     WindowNameCollection(Node& document, CollectionType type, const AtomicString& name)
     58    WindowNameCollection(ContainerNode& document, CollectionType type, const AtomicString& name)
    5959        : HTMLNameCollection(document, type, name)
    6060    {
     
    6565class DocumentNameCollection : public HTMLNameCollection {
    6666public:
    67     static PassRefPtr<DocumentNameCollection> create(Node& document, CollectionType type, const AtomicString& name)
     67    static PassRefPtr<DocumentNameCollection> create(ContainerNode& document, CollectionType type, const AtomicString& name)
    6868    {
    6969        return adoptRef(new DocumentNameCollection(document, type, name));
     
    7777
    7878private:
    79     DocumentNameCollection(Node& document, CollectionType type, const AtomicString& name)
     79    DocumentNameCollection(ContainerNode& document, CollectionType type, const AtomicString& name)
    8080        : HTMLNameCollection(document, type, name)
    8181    {
  • trunk/Source/WebCore/html/HTMLOptionsCollection.cpp

    r157065 r158540  
    2828namespace WebCore {
    2929
    30 HTMLOptionsCollection::HTMLOptionsCollection(Node& select)
     30HTMLOptionsCollection::HTMLOptionsCollection(ContainerNode& select)
    3131    : HTMLCollection(select, SelectOptions, DoesNotOverrideItemAfter)
    3232{
     
    3434}
    3535
    36 PassRefPtr<HTMLOptionsCollection> HTMLOptionsCollection::create(Node& select, CollectionType)
     36PassRefPtr<HTMLOptionsCollection> HTMLOptionsCollection::create(ContainerNode& select, CollectionType)
    3737{
    3838    return adoptRef(new HTMLOptionsCollection(select));
  • trunk/Source/WebCore/html/HTMLOptionsCollection.h

    r157065 r158540  
    3636class HTMLOptionsCollection : public HTMLCollection {
    3737public:
    38     static PassRefPtr<HTMLOptionsCollection> create(Node&, CollectionType);
     38    static PassRefPtr<HTMLOptionsCollection> create(ContainerNode&, CollectionType);
    3939
    4040    void add(PassRefPtr<HTMLOptionElement>, ExceptionCode&);
     
    4949
    5050private:
    51     explicit HTMLOptionsCollection(Node&);
     51    explicit HTMLOptionsCollection(ContainerNode&);
    5252};
    5353
  • trunk/Source/WebCore/html/LabelsNodeList.cpp

    r157065 r158540  
    3434using namespace HTMLNames;
    3535
    36 LabelsNodeList::LabelsNodeList(Node& forNode)
     36LabelsNodeList::LabelsNodeList(ContainerNode& forNode)
    3737    : LiveNodeList(forNode, LabelsNodeListType, InvalidateOnForAttrChange, NodeListIsRootedAtDocument)
    3838{
  • trunk/Source/WebCore/html/LabelsNodeList.h

    r157065 r158540  
    3333class LabelsNodeList : public LiveNodeList {
    3434public:
    35     static PassRefPtr<LabelsNodeList> create(Node& forNode, CollectionType type, const AtomicString&)
     35    static PassRefPtr<LabelsNodeList> create(ContainerNode& forNode, CollectionType type, const AtomicString&)
    3636    {
    3737        ASSERT_UNUSED(type, type == LabelsNodeListType);
     
    4141
    4242protected:
    43     explicit LabelsNodeList(Node& forNode);
     43    explicit LabelsNodeList(ContainerNode& forNode);
    4444
    4545    virtual bool nodeMatches(Element*) const;
  • trunk/Source/WebCore/html/MediaDocument.cpp

    r156980 r158540  
    137137}
    138138
    139 static inline HTMLVideoElement* descendentVideoElement(Node* node)
    140 {
    141     ASSERT(node);
    142 
    143     if (node->hasTagName(videoTag))
    144         return toHTMLVideoElement(node);
    145 
    146     RefPtr<NodeList> nodeList = node->getElementsByTagNameNS(videoTag.namespaceURI(), videoTag.localName());
     139static inline HTMLVideoElement* descendentVideoElement(ContainerNode& node)
     140{
     141    if (isHTMLVideoElement(node))
     142        return toHTMLVideoElement(&node);
     143
     144    RefPtr<NodeList> nodeList = node.getElementsByTagNameNS(videoTag.namespaceURI(), videoTag.localName());
    147145   
    148146    if (nodeList.get()->length() > 0)
     
    182180    }
    183181
     182    if (!targetNode->isContainerNode())
     183        return;
     184    ContainerNode& targetContainer = toContainerNode(*targetNode);
    184185    if (event->type() == eventNames().keydownEvent && event->isKeyboardEvent()) {
    185         HTMLVideoElement* video = descendentVideoElement(targetNode);
     186        HTMLVideoElement* video = descendentVideoElement(targetContainer);
    186187        if (!video)
    187188            return;
     
    219220    htmlBody->setAttribute(marginheightAttr, "0");
    220221
    221     if (HTMLVideoElement* videoElement = descendentVideoElement(htmlBody)) {
     222    if (HTMLVideoElement* videoElement = descendentVideoElement(*htmlBody)) {
    222223        RefPtr<Element> element = Document::createElement(embedTag, false);
    223224        HTMLEmbedElement* embedElement = static_cast<HTMLEmbedElement*>(element.get());
  • trunk/Source/WebCore/html/RadioNodeList.cpp

    r157065 r158540  
    3838using namespace HTMLNames;
    3939
    40 RadioNodeList::RadioNodeList(Node& rootNode, const AtomicString& name)
     40RadioNodeList::RadioNodeList(ContainerNode& rootNode, const AtomicString& name)
    4141    : LiveNodeList(rootNode, RadioNodeListType, InvalidateForFormControls, isHTMLFormElement(rootNode) ? NodeListIsRootedAtDocument : NodeListIsRootedAtNode)
    4242    , m_name(name)
  • trunk/Source/WebCore/html/RadioNodeList.h

    r157065 r158540  
    3535class RadioNodeList : public LiveNodeList {
    3636public:
    37     static PassRefPtr<RadioNodeList> create(Node& rootNode, CollectionType type, const AtomicString& name)
     37    static PassRefPtr<RadioNodeList> create(ContainerNode& rootNode, CollectionType type, const AtomicString& name)
    3838    {
    3939        ASSERT_UNUSED(type, type == RadioNodeListType);
     
    5050
    5151private:
    52     RadioNodeList(Node&, const AtomicString& name);
     52    RadioNodeList(ContainerNode&, const AtomicString& name);
    5353    bool checkElementMatchesRadioNodeListFilter(Element*) const;
    5454
Note: See TracChangeset for help on using the changeset viewer.