| Differences between
and this patch
- Source/WebCore/ChangeLog +23 lines
Lines 1-3 Source/WebCore/ChangeLog_sec1
1
2011-12-06  Ryosuke Niwa  <rniwa@webkit.org>
2
3
        The code to create a NodeListsNodeData is duplicated everywhere
4
        https://bugs.webkit.org/show_bug.cgi?id=73961
5
6
        Reviewed by NOBODY (OOPS!).
7
8
        Extracted the logic to create NodeListsNodeData as NodeRareData::ensureNodeLists.
9
10
        * dom/Document.cpp:
11
        (WebCore::Document::getItems):
12
        * dom/Node.cpp:
13
        (WebCore::Node::childNodes):
14
        (WebCore::Node::registerDynamicNodeList):
15
        (WebCore::Node::getElementsByTagName):
16
        (WebCore::Node::getElementsByTagNameNS):
17
        (WebCore::Node::getElementsByName):
18
        (WebCore::Node::getElementsByClassName):
19
        * dom/NodeRareData.h:
20
        (WebCore::NodeRareData::ensureNodeLists):
21
        * html/HTMLFormControlElement.cpp:
22
        (WebCore::HTMLFormControlElement::labels):
23
1
2011-12-06  Luke Macpherson   <macpherson@chromium.org>
24
2011-12-06  Luke Macpherson   <macpherson@chromium.org>
2
25
3
        Implement remaining border-image and webkit-maskbox-image properties in CSSStyleApplyProperty.
26
        Implement remaining border-image and webkit-maskbox-image properties in CSSStyleApplyProperty.
- Source/WebCore/dom/Document.cpp -6 / +2 lines
Lines 5156-5172 DocumentLoader* Document::loader() const Source/WebCore/dom/Document.cpp_sec1
5156
#if ENABLE(MICRODATA)
5156
#if ENABLE(MICRODATA)
5157
PassRefPtr<NodeList> Document::getItems(const String& typeNames)
5157
PassRefPtr<NodeList> Document::getItems(const String& typeNames)
5158
{
5158
{
5159
    NodeRareData* data = ensureRareData();
5159
    NodeListsNodeData* nodeLists = ensureRareData()->ensureNodeLists();
5160
    if (!data->nodeLists()) {
5161
        data->setNodeLists(NodeListsNodeData::create());
5162
        treeScope()->addNodeListCache();
5163
    }
5164
5160
5165
    // Since documet.getItem() is allowed for microdata, typeNames will be null string.
5161
    // Since documet.getItem() is allowed for microdata, typeNames will be null string.
5166
    // In this case we need to create an unique string identifier to map such request in the cache.
5162
    // In this case we need to create an unique string identifier to map such request in the cache.
5167
    String localTypeNames = typeNames.isNull() ? String("http://webkit.org/microdata/undefinedItemType") : typeNames;
5163
    String localTypeNames = typeNames.isNull() ? String("http://webkit.org/microdata/undefinedItemType") : typeNames;
5168
5164
5169
    pair<NodeListsNodeData::MicroDataItemListCache::iterator, bool> result = data->nodeLists()->m_microDataItemListCache.add(localTypeNames, 0);
5165
    pair<NodeListsNodeData::MicroDataItemListCache::iterator, bool> result = nodeLists->m_microDataItemListCache.add(localTypeNames, 0);
5170
    if (!result.second)
5166
    if (!result.second)
5171
        return PassRefPtr<NodeList>(result.first->second);
5167
        return PassRefPtr<NodeList>(result.first->second);
5172
5168
- Source/WebCore/dom/Node.cpp -45 / +13 lines
Lines 623-638 void Node::setNodeValue(const String& /* Source/WebCore/dom/Node.cpp_sec1
623
623
624
PassRefPtr<NodeList> Node::childNodes()
624
PassRefPtr<NodeList> Node::childNodes()
625
{
625
{
626
    NodeRareData* data = ensureRareData();
626
    NodeListsNodeData* nodeLists = ensureRareData()->ensureNodeLists(this);
627
    if (!data->nodeLists()) {
627
    if (!nodeLists->m_childNodeListCaches)
628
        data->setNodeLists(NodeListsNodeData::create());
628
        nodeLists->m_childNodeListCaches = DynamicNodeList::Caches::create();
629
        if (treeScope())
629
    return ChildNodeList::create(this, nodeLists->m_childNodeListCaches.get());
630
            treeScope()->addNodeListCache();
631
    }
632
633
    if (!data->nodeLists()->m_childNodeListCaches)
634
        data->nodeLists()->m_childNodeListCaches = DynamicNodeList::Caches::create();
635
    return ChildNodeList::create(this, data->nodeLists()->m_childNodeListCaches.get());
636
}
630
}
637
631
638
Node *Node::lastDescendant() const
632
Node *Node::lastDescendant() const
Lines 1005-1020 unsigned Node::nodeIndex() const Source/WebCore/dom/Node.cpp_sec2
1005
void Node::registerDynamicNodeList(DynamicNodeList* list)
999
void Node::registerDynamicNodeList(DynamicNodeList* list)
1006
{
1000
{
1007
    NodeRareData* data = ensureRareData();
1001
    NodeRareData* data = ensureRareData();
1008
    if (!data->nodeLists()) {
1002
    // We haven't been receiving notifications while there were no registered lists, so the cache is invalid now.
1009
        data->setNodeLists(NodeListsNodeData::create());
1003
    if (data->nodeLists() && (!treeScope() || !treeScope()->hasNodeListCaches()))
1010
        treeScope()->addNodeListCache();
1011
    } else if (!treeScope() || !treeScope()->hasNodeListCaches()) {
1012
        // We haven't been receiving notifications while there were no registered lists, so the cache is invalid now.
1013
        data->nodeLists()->invalidateCaches();
1004
        data->nodeLists()->invalidateCaches();
1014
    }
1015
1005
1016
    if (list->hasOwnCaches())
1006
    if (list->hasOwnCaches())
1017
        data->nodeLists()->m_listsWithCaches.add(list);
1007
        data->ensureNodeLists(this)->m_listsWithCaches.add(list);
1018
}
1008
}
1019
1009
1020
void Node::unregisterDynamicNodeList(DynamicNodeList* list)
1010
void Node::unregisterDynamicNodeList(DynamicNodeList* list)
Lines 1667-1685 PassRefPtr<NodeList> Node::getElementsBy Source/WebCore/dom/Node.cpp_sec3
1667
    if (localName.isNull())
1657
    if (localName.isNull())
1668
        return 0;
1658
        return 0;
1669
1659
1670
    NodeRareData* data = ensureRareData();
1671
    if (!data->nodeLists()) {
1672
        data->setNodeLists(NodeListsNodeData::create());
1673
        treeScope()->addNodeListCache();
1674
    }
1675
1676
    String name = localName;
1660
    String name = localName;
1677
    if (document()->isHTMLDocument())
1661
    if (document()->isHTMLDocument())
1678
        name = localName.lower();
1662
        name = localName.lower();
1679
1663
1680
    AtomicString localNameAtom = name;
1664
    AtomicString localNameAtom = name;
1681
1665
1682
    pair<NodeListsNodeData::TagNodeListCache::iterator, bool> result = data->nodeLists()->m_tagNodeListCache.add(localNameAtom, 0);
1666
    pair<NodeListsNodeData::TagNodeListCache::iterator, bool> result = ensureRareData()->ensureNodeLists(this)->m_tagNodeListCache.add(localNameAtom, 0);
1683
    if (!result.second)
1667
    if (!result.second)
1684
        return PassRefPtr<TagNodeList>(result.first->second);
1668
        return PassRefPtr<TagNodeList>(result.first->second);
1685
1669
Lines 1696-1714 PassRefPtr<NodeList> Node::getElementsBy Source/WebCore/dom/Node.cpp_sec4
1696
    if (namespaceURI == starAtom)
1680
    if (namespaceURI == starAtom)
1697
        return getElementsByTagName(localName);
1681
        return getElementsByTagName(localName);
1698
1682
1699
    NodeRareData* data = ensureRareData();
1700
    if (!data->nodeLists()) {
1701
        data->setNodeLists(NodeListsNodeData::create());
1702
        treeScope()->addNodeListCache();
1703
    }
1704
1705
    String name = localName;
1683
    String name = localName;
1706
    if (document()->isHTMLDocument())
1684
    if (document()->isHTMLDocument())
1707
        name = localName.lower();
1685
        name = localName.lower();
1708
1686
1709
    AtomicString localNameAtom = name;
1687
    AtomicString localNameAtom = name;
1710
1688
1711
    pair<NodeListsNodeData::TagNodeListCacheNS::iterator, bool> result = data->nodeLists()->m_tagNodeListCacheNS.add(QualifiedName(nullAtom, localNameAtom, namespaceURI).impl(), 0);
1689
    pair<NodeListsNodeData::TagNodeListCacheNS::iterator, bool> result
1690
        = ensureRareData()->ensureNodeLists(this)->m_tagNodeListCacheNS.add(QualifiedName(nullAtom, localNameAtom, namespaceURI).impl(), 0);
1712
    if (!result.second)
1691
    if (!result.second)
1713
        return PassRefPtr<TagNodeList>(result.first->second);
1692
        return PassRefPtr<TagNodeList>(result.first->second);
1714
1693
Lines 1719-1731 PassRefPtr<NodeList> Node::getElementsBy Source/WebCore/dom/Node.cpp_sec5
1719
1698
1720
PassRefPtr<NodeList> Node::getElementsByName(const String& elementName)
1699
PassRefPtr<NodeList> Node::getElementsByName(const String& elementName)
1721
{
1700
{
1722
    NodeRareData* data = ensureRareData();
1701
    pair<NodeListsNodeData::NameNodeListCache::iterator, bool> result = ensureRareData()->ensureNodeLists(this)->m_nameNodeListCache.add(elementName, 0);
1723
    if (!data->nodeLists()) {
1724
        data->setNodeLists(NodeListsNodeData::create());
1725
        treeScope()->addNodeListCache();
1726
    }
1727
1728
    pair<NodeListsNodeData::NameNodeListCache::iterator, bool> result = data->nodeLists()->m_nameNodeListCache.add(elementName, 0);
1729
    if (!result.second)
1702
    if (!result.second)
1730
        return PassRefPtr<NodeList>(result.first->second);
1703
        return PassRefPtr<NodeList>(result.first->second);
1731
1704
Lines 1736-1748 PassRefPtr<NodeList> Node::getElementsBy Source/WebCore/dom/Node.cpp_sec6
1736
1709
1737
PassRefPtr<NodeList> Node::getElementsByClassName(const String& classNames)
1710
PassRefPtr<NodeList> Node::getElementsByClassName(const String& classNames)
1738
{
1711
{
1739
    NodeRareData* data = ensureRareData();
1712
    pair<NodeListsNodeData::ClassNodeListCache::iterator, bool> result
1740
    if (!data->nodeLists()) {
1713
        = ensureRareData()->ensureNodeLists(this)->m_classNodeListCache.add(classNames, 0);
1741
        data->setNodeLists(NodeListsNodeData::create());
1742
        treeScope()->addNodeListCache();
1743
    }
1744
1745
    pair<NodeListsNodeData::ClassNodeListCache::iterator, bool> result = data->nodeLists()->m_classNodeListCache.add(classNames, 0);
1746
    if (!result.second)
1714
    if (!result.second)
1747
        return PassRefPtr<NodeList>(result.first->second);
1715
        return PassRefPtr<NodeList>(result.first->second);
1748
1716
- Source/WebCore/dom/NodeRareData.h +10 lines
Lines 126-131 public: Source/WebCore/dom/NodeRareData.h_sec1
126
    void clearNodeLists() { m_nodeLists.clear(); }
126
    void clearNodeLists() { m_nodeLists.clear(); }
127
    void setNodeLists(PassOwnPtr<NodeListsNodeData> lists) { m_nodeLists = lists; }
127
    void setNodeLists(PassOwnPtr<NodeListsNodeData> lists) { m_nodeLists = lists; }
128
    NodeListsNodeData* nodeLists() const { return m_nodeLists.get(); }
128
    NodeListsNodeData* nodeLists() const { return m_nodeLists.get(); }
129
    NodeListsNodeData* ensureNodeLists(Node* node)
130
    {
131
        ASSERT(node);
132
        if (!m_nodeLists) {
133
            setNodeLists(NodeListsNodeData::create());
134
            if (TreeScope* treeScope = node->treeScope())
135
                treeScope->addNodeListCache();
136
        }
137
        return m_nodeLists.get();
138
    }
129
139
130
    short tabIndex() const { return m_tabIndex; }
140
    short tabIndex() const { return m_tabIndex; }
131
    void setTabIndexExplicitly(short index) { m_tabIndex = index; m_tabIndexWasSetExplicitly = true; }
141
    void setTabIndexExplicitly(short index) { m_tabIndex = index; m_tabIndexWasSetExplicitly = true; }
- Source/WebCore/html/HTMLFormControlElement.cpp -9 / +4 lines
Lines 492-508 PassRefPtr<NodeList> HTMLFormControlElem Source/WebCore/html/HTMLFormControlElement.cpp_sec1
492
    if (!document())
492
    if (!document())
493
        return 0;
493
        return 0;
494
494
495
    NodeRareData* data = Node::ensureRareData();
495
    NodeListsNodeData* nodeLists = Node::ensureRareData()->ensureNodeLists(this);
496
    if (!data->nodeLists()) {
496
    if (nodeLists->m_labelsNodeListCache)
497
        data->setNodeLists(NodeListsNodeData::create());
497
        return nodeLists->m_labelsNodeListCache;
498
        treeScope()->addNodeListCache();
499
    }
500
501
    if (data->nodeLists()->m_labelsNodeListCache)
502
        return data->nodeLists()->m_labelsNodeListCache;
503
498
504
    RefPtr<LabelsNodeList> list = LabelsNodeList::create(this);
499
    RefPtr<LabelsNodeList> list = LabelsNodeList::create(this);
505
    data->nodeLists()->m_labelsNodeListCache = list.get();
500
    nodeLists->m_labelsNodeListCache = list.get();
506
    return list.release();
501
    return list.release();
507
}
502
}
508
503

Return to Bug 73961