OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) | 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) |
3 * (C) 1999 Antti Koivisto (koivisto@kde.org) | 3 * (C) 1999 Antti Koivisto (koivisto@kde.org) |
4 * (C) 2001 Dirk Mueller (mueller@kde.org) | 4 * (C) 2001 Dirk Mueller (mueller@kde.org) |
5 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All r
ights reserved. | 5 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All r
ights reserved. |
6 * Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies) | 6 * Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies) |
7 * Copyright (C) 2009 Torch Mobile Inc. All rights reserved. (http://www.torchmo
bile.com/) | 7 * Copyright (C) 2009 Torch Mobile Inc. All rights reserved. (http://www.torchmo
bile.com/) |
8 * | 8 * |
9 * This library is free software; you can redistribute it and/or | 9 * This library is free software; you can redistribute it and/or |
10 * modify it under the terms of the GNU Library General Public | 10 * modify it under the terms of the GNU Library General Public |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
89 #include "platform/Partitions.h" | 89 #include "platform/Partitions.h" |
90 #include "platform/TraceEvent.h" | 90 #include "platform/TraceEvent.h" |
91 #include "platform/TracedValue.h" | 91 #include "platform/TracedValue.h" |
92 #include "wtf/HashSet.h" | 92 #include "wtf/HashSet.h" |
93 #include "wtf/PassOwnPtr.h" | 93 #include "wtf/PassOwnPtr.h" |
94 #include "wtf/RefCountedLeakCounter.h" | 94 #include "wtf/RefCountedLeakCounter.h" |
95 #include "wtf/Vector.h" | 95 #include "wtf/Vector.h" |
96 #include "wtf/text/CString.h" | 96 #include "wtf/text/CString.h" |
97 #include "wtf/text/StringBuilder.h" | 97 #include "wtf/text/StringBuilder.h" |
98 | 98 |
99 using namespace std; | |
100 | |
101 namespace WebCore { | 99 namespace WebCore { |
102 | 100 |
103 using namespace HTMLNames; | 101 using namespace HTMLNames; |
104 | 102 |
105 #if !ENABLE(OILPAN) | 103 #if !ENABLE(OILPAN) |
106 void* Node::operator new(size_t size) | 104 void* Node::operator new(std::size_t size) |
107 { | 105 { |
108 ASSERT(isMainThread()); | 106 ASSERT(isMainThread()); |
109 return partitionAlloc(Partitions::getObjectModelPartition(), size); | 107 return partitionAlloc(Partitions::getObjectModelPartition(), size); |
110 } | 108 } |
111 | 109 |
112 void Node::operator delete(void* ptr) | 110 void Node::operator delete(void* ptr) |
113 { | 111 { |
114 ASSERT(isMainThread()); | 112 ASSERT(isMainThread()); |
115 partitionFree(ptr); | 113 partitionFree(ptr); |
116 } | 114 } |
117 #endif | 115 #endif |
118 | 116 |
119 #if DUMP_NODE_STATISTICS | 117 #if DUMP_NODE_STATISTICS |
120 static HashSet<Node*>& liveNodeSet() | 118 static HashSet<Node*>& liveNodeSet() |
121 { | 119 { |
122 DEFINE_STATIC_LOCAL(HashSet<Node*>, s_liveNodeSet, ()); | 120 DEFINE_STATIC_LOCAL(HashSet<Node*>, s_liveNodeSet, ()); |
123 return s_liveNodeSet; | 121 return s_liveNodeSet; |
124 } | 122 } |
125 #endif | 123 #endif |
126 | 124 |
127 void Node::dumpStatistics() | 125 void Node::dumpStatistics() |
128 { | 126 { |
129 #if DUMP_NODE_STATISTICS | 127 #if DUMP_NODE_STATISTICS |
130 size_t nodesWithRareData = 0; | 128 std::size_t nodesWithRareData = 0; |
131 | 129 |
132 size_t elementNodes = 0; | 130 std::size_t elementNodes = 0; |
133 size_t attrNodes = 0; | 131 std::size_t attrNodes = 0; |
134 size_t textNodes = 0; | 132 std::size_t textNodes = 0; |
135 size_t cdataNodes = 0; | 133 std::size_t cdataNodes = 0; |
136 size_t commentNodes = 0; | 134 std::size_t commentNodes = 0; |
137 size_t piNodes = 0; | 135 std::size_t piNodes = 0; |
138 size_t documentNodes = 0; | 136 std::size_t documentNodes = 0; |
139 size_t docTypeNodes = 0; | 137 std::size_t docTypeNodes = 0; |
140 size_t fragmentNodes = 0; | 138 std::size_t fragmentNodes = 0; |
141 size_t shadowRootNodes = 0; | 139 std::size_t shadowRootNodes = 0; |
142 | 140 |
143 HashMap<String, size_t> perTagCount; | 141 HashMap<String, std::size_t> perTagCount; |
144 | 142 |
145 size_t attributes = 0; | 143 std::size_t attributes = 0; |
146 size_t elementsWithAttributeStorage = 0; | 144 std::size_t elementsWithAttributeStorage = 0; |
147 size_t elementsWithRareData = 0; | 145 std::size_t elementsWithRareData = 0; |
148 size_t elementsWithNamedNodeMap = 0; | 146 std::size_t elementsWithNamedNodeMap = 0; |
149 | 147 |
150 for (HashSet<Node*>::iterator it = liveNodeSet().begin(); it != liveNodeSet(
).end(); ++it) { | 148 for (HashSet<Node*>::iterator it = liveNodeSet().begin(); it != liveNodeSet(
).end(); ++it) { |
151 Node* node = *it; | 149 Node* node = *it; |
152 | 150 |
153 if (node->hasRareData()) { | 151 if (node->hasRareData()) { |
154 ++nodesWithRareData; | 152 ++nodesWithRareData; |
155 if (node->isElementNode()) { | 153 if (node->isElementNode()) { |
156 ++elementsWithRareData; | 154 ++elementsWithRareData; |
157 if (toElement(node)->hasNamedNodeMap()) | 155 if (toElement(node)->hasNamedNodeMap()) |
158 ++elementsWithNamedNodeMap; | 156 ++elementsWithNamedNodeMap; |
159 } | 157 } |
160 } | 158 } |
161 | 159 |
162 switch (node->nodeType()) { | 160 switch (node->nodeType()) { |
163 case ELEMENT_NODE: { | 161 case ELEMENT_NODE: { |
164 ++elementNodes; | 162 ++elementNodes; |
165 | 163 |
166 // Tag stats | 164 // Tag stats |
167 Element* element = toElement(node); | 165 Element* element = toElement(node); |
168 HashMap<String, size_t>::AddResult result = perTagCount.add(elem
ent->tagName(), 1); | 166 HashMap<String, std::size_t>::AddResult result = perTagCount.add
(element->tagName(), 1); |
169 if (!result.isNewEntry) | 167 if (!result.isNewEntry) |
170 result.storedValue->value++; | 168 result.storedValue->value++; |
171 | 169 |
172 if (const ElementData* elementData = element->elementData()) { | 170 if (const ElementData* elementData = element->elementData()) { |
173 attributes += elementData->length(); | 171 attributes += elementData->length(); |
174 ++elementsWithAttributeStorage; | 172 ++elementsWithAttributeStorage; |
175 } | 173 } |
176 break; | 174 break; |
177 } | 175 } |
178 case ATTRIBUTE_NODE: { | 176 case ATTRIBUTE_NODE: { |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
222 printf(" Number of Text nodes: %zu\n", textNodes); | 220 printf(" Number of Text nodes: %zu\n", textNodes); |
223 printf(" Number of CDATASection nodes: %zu\n", cdataNodes); | 221 printf(" Number of CDATASection nodes: %zu\n", cdataNodes); |
224 printf(" Number of Comment nodes: %zu\n", commentNodes); | 222 printf(" Number of Comment nodes: %zu\n", commentNodes); |
225 printf(" Number of ProcessingInstruction nodes: %zu\n", piNodes); | 223 printf(" Number of ProcessingInstruction nodes: %zu\n", piNodes); |
226 printf(" Number of Document nodes: %zu\n", documentNodes); | 224 printf(" Number of Document nodes: %zu\n", documentNodes); |
227 printf(" Number of DocumentType nodes: %zu\n", docTypeNodes); | 225 printf(" Number of DocumentType nodes: %zu\n", docTypeNodes); |
228 printf(" Number of DocumentFragment nodes: %zu\n", fragmentNodes); | 226 printf(" Number of DocumentFragment nodes: %zu\n", fragmentNodes); |
229 printf(" Number of ShadowRoot nodes: %zu\n", shadowRootNodes); | 227 printf(" Number of ShadowRoot nodes: %zu\n", shadowRootNodes); |
230 | 228 |
231 printf("Element tag name distibution:\n"); | 229 printf("Element tag name distibution:\n"); |
232 for (HashMap<String, size_t>::iterator it = perTagCount.begin(); it != perTa
gCount.end(); ++it) | 230 for (HashMap<String, std::size_t>::iterator it = perTagCount.begin(); it !=
perTagCount.end(); ++it) |
233 printf(" Number of <%s> tags: %zu\n", it->key.utf8().data(), it->value)
; | 231 printf(" Number of <%s> tags: %zu\n", it->key.utf8().data(), it->value)
; |
234 | 232 |
235 printf("Attributes:\n"); | 233 printf("Attributes:\n"); |
236 printf(" Number of Attributes (non-Node and Node): %zu [%zu]\n", attributes
, sizeof(Attribute)); | 234 printf(" Number of Attributes (non-Node and Node): %zu [%zu]\n", attributes
, sizeof(Attribute)); |
237 printf(" Number of Elements with attribute storage: %zu [%zu]\n", elementsW
ithAttributeStorage, sizeof(ElementData)); | 235 printf(" Number of Elements with attribute storage: %zu [%zu]\n", elementsW
ithAttributeStorage, sizeof(ElementData)); |
238 printf(" Number of Elements with RareData: %zu\n", elementsWithRareData); | 236 printf(" Number of Elements with RareData: %zu\n", elementsWithRareData); |
239 printf(" Number of Elements with NamedNodeMap: %zu [%zu]\n", elementsWithNa
medNodeMap, sizeof(NamedNodeMap)); | 237 printf(" Number of Elements with NamedNodeMap: %zu [%zu]\n", elementsWithNa
medNodeMap, sizeof(NamedNodeMap)); |
240 #endif | 238 #endif |
241 } | 239 } |
242 | 240 |
(...skipping 382 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
625 // is non-empty, since this is a faster check and almost always returns true
. | 623 // is non-empty, since this is a faster check and almost always returns true
. |
626 RenderBoxModelObject* box = renderBoxModelObject(); | 624 RenderBoxModelObject* box = renderBoxModelObject(); |
627 if (!box) | 625 if (!box) |
628 return false; | 626 return false; |
629 if (!box->borderBoundingBox().isEmpty()) | 627 if (!box->borderBoundingBox().isEmpty()) |
630 return true; | 628 return true; |
631 | 629 |
632 Vector<IntRect> rects; | 630 Vector<IntRect> rects; |
633 FloatPoint absPos = renderer()->localToAbsolute(); | 631 FloatPoint absPos = renderer()->localToAbsolute(); |
634 renderer()->absoluteRects(rects, flooredLayoutPoint(absPos)); | 632 renderer()->absoluteRects(rects, flooredLayoutPoint(absPos)); |
635 size_t n = rects.size(); | 633 std::size_t n = rects.size(); |
636 for (size_t i = 0; i < n; ++i) | 634 for (std::size_t i = 0; i < n; ++i) |
637 if (!rects[i].isEmpty()) | 635 if (!rects[i].isEmpty()) |
638 return true; | 636 return true; |
639 | 637 |
640 return false; | 638 return false; |
641 } | 639 } |
642 | 640 |
643 #ifndef NDEBUG | 641 #ifndef NDEBUG |
644 inline static ShadowRoot* oldestShadowRootFor(const Node* node) | 642 inline static ShadowRoot* oldestShadowRootFor(const Node* node) |
645 { | 643 { |
646 if (!node->isElementNode()) | 644 if (!node->isElementNode()) |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
697 } | 695 } |
698 | 696 |
699 namespace { | 697 namespace { |
700 | 698 |
701 PassRefPtr<JSONArray> jsStackAsJSONArray() | 699 PassRefPtr<JSONArray> jsStackAsJSONArray() |
702 { | 700 { |
703 RefPtr<JSONArray> jsonArray = JSONArray::create(); | 701 RefPtr<JSONArray> jsonArray = JSONArray::create(); |
704 RefPtr<ScriptCallStack> stack = createScriptCallStack(10); | 702 RefPtr<ScriptCallStack> stack = createScriptCallStack(10); |
705 if (!stack) | 703 if (!stack) |
706 return jsonArray.release(); | 704 return jsonArray.release(); |
707 for (size_t i = 0; i < stack->size(); i++) | 705 for (std::size_t i = 0; i < stack->size(); i++) |
708 jsonArray->pushString(stack->at(i).functionName()); | 706 jsonArray->pushString(stack->at(i).functionName()); |
709 return jsonArray.release(); | 707 return jsonArray.release(); |
710 } | 708 } |
711 | 709 |
712 PassRefPtr<JSONObject> jsonObjectForStyleInvalidation(unsigned nodeCount, const
Node* rootNode) | 710 PassRefPtr<JSONObject> jsonObjectForStyleInvalidation(unsigned nodeCount, const
Node* rootNode) |
713 { | 711 { |
714 RefPtr<JSONObject> jsonObject = JSONObject::create(); | 712 RefPtr<JSONObject> jsonObject = JSONObject::create(); |
715 jsonObject->setNumber("node_count", nodeCount); | 713 jsonObject->setNumber("node_count", nodeCount); |
716 jsonObject->setString("root_node", rootNode->debugName()); | 714 jsonObject->setString("root_node", rootNode->debugName()); |
717 jsonObject->setArray("js_stack", jsStackAsJSONArray()); | 715 jsonObject->setArray("js_stack", jsStackAsJSONArray()); |
(...skipping 897 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1615 | 1613 |
1616 // If the two elements don't have a common root, they're not in the same tre
e. | 1614 // If the two elements don't have a common root, they're not in the same tre
e. |
1617 if (chain1[index1 - 1] != chain2[index2 - 1]) { | 1615 if (chain1[index1 - 1] != chain2[index2 - 1]) { |
1618 unsigned short direction = (this > otherNode) ? DOCUMENT_POSITION_PRECED
ING : DOCUMENT_POSITION_FOLLOWING; | 1616 unsigned short direction = (this > otherNode) ? DOCUMENT_POSITION_PRECED
ING : DOCUMENT_POSITION_FOLLOWING; |
1619 return DOCUMENT_POSITION_DISCONNECTED | DOCUMENT_POSITION_IMPLEMENTATION
_SPECIFIC | direction; | 1617 return DOCUMENT_POSITION_DISCONNECTED | DOCUMENT_POSITION_IMPLEMENTATION
_SPECIFIC | direction; |
1620 } | 1618 } |
1621 | 1619 |
1622 unsigned connection = start1->treeScope() != start2->treeScope() ? DOCUMENT_
POSITION_DISCONNECTED | DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC : 0; | 1620 unsigned connection = start1->treeScope() != start2->treeScope() ? DOCUMENT_
POSITION_DISCONNECTED | DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC : 0; |
1623 | 1621 |
1624 // Walk the two chains backwards and look for the first difference. | 1622 // Walk the two chains backwards and look for the first difference. |
1625 for (unsigned i = min(index1, index2); i; --i) { | 1623 for (unsigned i = std::min(index1, index2); i; --i) { |
1626 const Node* child1 = chain1[--index1]; | 1624 const Node* child1 = chain1[--index1]; |
1627 const Node* child2 = chain2[--index2]; | 1625 const Node* child2 = chain2[--index2]; |
1628 if (child1 != child2) { | 1626 if (child1 != child2) { |
1629 // If one of the children is an attribute, it wins. | 1627 // If one of the children is an attribute, it wins. |
1630 if (child1->nodeType() == ATTRIBUTE_NODE) | 1628 if (child1->nodeType() == ATTRIBUTE_NODE) |
1631 return DOCUMENT_POSITION_FOLLOWING | connection; | 1629 return DOCUMENT_POSITION_FOLLOWING | connection; |
1632 if (child2->nodeType() == ATTRIBUTE_NODE) | 1630 if (child2->nodeType() == ATTRIBUTE_NODE) |
1633 return DOCUMENT_POSITION_PRECEDING | connection; | 1631 return DOCUMENT_POSITION_PRECEDING | connection; |
1634 | 1632 |
1635 // If one of the children is a shadow root, | 1633 // If one of the children is a shadow root, |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1701 name.append(nodeName()); | 1699 name.append(nodeName()); |
1702 | 1700 |
1703 if (hasID()) { | 1701 if (hasID()) { |
1704 name.appendLiteral(" id=\'"); | 1702 name.appendLiteral(" id=\'"); |
1705 name.append(toElement(this)->getIdAttribute()); | 1703 name.append(toElement(this)->getIdAttribute()); |
1706 name.append('\''); | 1704 name.append('\''); |
1707 } | 1705 } |
1708 | 1706 |
1709 if (hasClass()) { | 1707 if (hasClass()) { |
1710 name.appendLiteral(" class=\'"); | 1708 name.appendLiteral(" class=\'"); |
1711 for (size_t i = 0; i < toElement(this)->classNames().size(); ++i) { | 1709 for (std::size_t i = 0; i < toElement(this)->classNames().size(); ++i) { |
1712 if (i > 0) | 1710 if (i > 0) |
1713 name.append(' '); | 1711 name.append(' '); |
1714 name.append(toElement(this)->classNames()[i]); | 1712 name.append(toElement(this)->classNames()[i]); |
1715 } | 1713 } |
1716 name.append('\''); | 1714 name.append('\''); |
1717 } | 1715 } |
1718 | 1716 |
1719 return name.toString(); | 1717 return name.toString(); |
1720 } | 1718 } |
1721 | 1719 |
(...skipping 228 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1950 } | 1948 } |
1951 } | 1949 } |
1952 if (oldDocument.frameHost() != document().frameHost()) { | 1950 if (oldDocument.frameHost() != document().frameHost()) { |
1953 if (oldDocument.frameHost()) | 1951 if (oldDocument.frameHost()) |
1954 oldDocument.frameHost()->eventHandlerRegistry().didMoveOutOfFrameHos
t(*this); | 1952 oldDocument.frameHost()->eventHandlerRegistry().didMoveOutOfFrameHos
t(*this); |
1955 if (document().frameHost()) | 1953 if (document().frameHost()) |
1956 document().frameHost()->eventHandlerRegistry().didMoveIntoFrameHost(
*this); | 1954 document().frameHost()->eventHandlerRegistry().didMoveIntoFrameHost(
*this); |
1957 } | 1955 } |
1958 | 1956 |
1959 if (WillBeHeapVector<OwnPtrWillBeMember<MutationObserverRegistration> >* reg
istry = mutationObserverRegistry()) { | 1957 if (WillBeHeapVector<OwnPtrWillBeMember<MutationObserverRegistration> >* reg
istry = mutationObserverRegistry()) { |
1960 for (size_t i = 0; i < registry->size(); ++i) { | 1958 for (std::size_t i = 0; i < registry->size(); ++i) { |
1961 document().addMutationObserverTypes(registry->at(i)->mutationTypes()
); | 1959 document().addMutationObserverTypes(registry->at(i)->mutationTypes()
); |
1962 } | 1960 } |
1963 } | 1961 } |
1964 | 1962 |
1965 if (WillBeHeapHashSet<RawPtrWillBeMember<MutationObserverRegistration> >* tr
ansientRegistry = transientMutationObserverRegistry()) { | 1963 if (WillBeHeapHashSet<RawPtrWillBeMember<MutationObserverRegistration> >* tr
ansientRegistry = transientMutationObserverRegistry()) { |
1966 for (WillBeHeapHashSet<RawPtrWillBeMember<MutationObserverRegistration>
>::iterator iter = transientRegistry->begin(); iter != transientRegistry->end();
++iter) { | 1964 for (WillBeHeapHashSet<RawPtrWillBeMember<MutationObserverRegistration>
>::iterator iter = transientRegistry->begin(); iter != transientRegistry->end();
++iter) { |
1967 document().addMutationObserverTypes((*iter)->mutationTypes()); | 1965 document().addMutationObserverTypes((*iter)->mutationTypes()); |
1968 } | 1966 } |
1969 } | 1967 } |
1970 } | 1968 } |
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2106 for (Node* node = parentNode(); node; node = node->parentNode()) { | 2104 for (Node* node = parentNode(); node; node = node->parentNode()) { |
2107 collectMatchingObserversForMutation(observers, node->mutationObserverReg
istry(), *this, type, attributeName); | 2105 collectMatchingObserversForMutation(observers, node->mutationObserverReg
istry(), *this, type, attributeName); |
2108 collectMatchingObserversForMutation(observers, node->transientMutationOb
serverRegistry(), *this, type, attributeName); | 2106 collectMatchingObserversForMutation(observers, node->transientMutationOb
serverRegistry(), *this, type, attributeName); |
2109 } | 2107 } |
2110 } | 2108 } |
2111 | 2109 |
2112 void Node::registerMutationObserver(MutationObserver& observer, MutationObserver
Options options, const HashSet<AtomicString>& attributeFilter) | 2110 void Node::registerMutationObserver(MutationObserver& observer, MutationObserver
Options options, const HashSet<AtomicString>& attributeFilter) |
2113 { | 2111 { |
2114 MutationObserverRegistration* registration = 0; | 2112 MutationObserverRegistration* registration = 0; |
2115 WillBeHeapVector<OwnPtrWillBeMember<MutationObserverRegistration> >& registr
y = ensureRareData().ensureMutationObserverData().registry; | 2113 WillBeHeapVector<OwnPtrWillBeMember<MutationObserverRegistration> >& registr
y = ensureRareData().ensureMutationObserverData().registry; |
2116 for (size_t i = 0; i < registry.size(); ++i) { | 2114 for (std::size_t i = 0; i < registry.size(); ++i) { |
2117 if (®istry[i]->observer() == &observer) { | 2115 if (®istry[i]->observer() == &observer) { |
2118 registration = registry[i].get(); | 2116 registration = registry[i].get(); |
2119 registration->resetObservation(options, attributeFilter); | 2117 registration->resetObservation(options, attributeFilter); |
2120 } | 2118 } |
2121 } | 2119 } |
2122 | 2120 |
2123 if (!registration) { | 2121 if (!registration) { |
2124 registry.append(MutationObserverRegistration::create(observer, this, opt
ions, attributeFilter)); | 2122 registry.append(MutationObserverRegistration::create(observer, this, opt
ions, attributeFilter)); |
2125 registration = registry.last().get(); | 2123 registration = registry.last().get(); |
2126 } | 2124 } |
2127 | 2125 |
2128 document().addMutationObserverTypes(registration->mutationTypes()); | 2126 document().addMutationObserverTypes(registration->mutationTypes()); |
2129 } | 2127 } |
2130 | 2128 |
2131 void Node::unregisterMutationObserver(MutationObserverRegistration* registration
) | 2129 void Node::unregisterMutationObserver(MutationObserverRegistration* registration
) |
2132 { | 2130 { |
2133 WillBeHeapVector<OwnPtrWillBeMember<MutationObserverRegistration> >* registr
y = mutationObserverRegistry(); | 2131 WillBeHeapVector<OwnPtrWillBeMember<MutationObserverRegistration> >* registr
y = mutationObserverRegistry(); |
2134 ASSERT(registry); | 2132 ASSERT(registry); |
2135 if (!registry) | 2133 if (!registry) |
2136 return; | 2134 return; |
2137 | 2135 |
2138 size_t index = registry->find(registration); | 2136 std::size_t index = registry->find(registration); |
2139 ASSERT(index != kNotFound); | 2137 ASSERT(index != kNotFound); |
2140 if (index == kNotFound) | 2138 if (index == kNotFound) |
2141 return; | 2139 return; |
2142 | 2140 |
2143 // Deleting the registration may cause this node to be derefed, so we must m
ake sure the Vector operation completes | 2141 // Deleting the registration may cause this node to be derefed, so we must m
ake sure the Vector operation completes |
2144 // before that, in case |this| is destroyed (see MutationObserverRegistratio
n::m_registrationNodeKeepAlive). | 2142 // before that, in case |this| is destroyed (see MutationObserverRegistratio
n::m_registrationNodeKeepAlive). |
2145 // FIXME: Simplify the registration/transient registration logic to make thi
s understandable by humans. | 2143 // FIXME: Simplify the registration/transient registration logic to make thi
s understandable by humans. |
2146 RefPtrWillBeRawPtr<Node> protect(this); | 2144 RefPtrWillBeRawPtr<Node> protect(this); |
2147 #if ENABLE(OILPAN) | 2145 #if ENABLE(OILPAN) |
2148 // The explicit dispose() is needed to have the registration | 2146 // The explicit dispose() is needed to have the registration |
(...skipping 19 matching lines...) Expand all Loading... |
2168 transientRegistry->remove(registration); | 2166 transientRegistry->remove(registration); |
2169 } | 2167 } |
2170 | 2168 |
2171 void Node::notifyMutationObserversNodeWillDetach() | 2169 void Node::notifyMutationObserversNodeWillDetach() |
2172 { | 2170 { |
2173 if (!document().hasMutationObservers()) | 2171 if (!document().hasMutationObservers()) |
2174 return; | 2172 return; |
2175 | 2173 |
2176 for (Node* node = parentNode(); node; node = node->parentNode()) { | 2174 for (Node* node = parentNode(); node; node = node->parentNode()) { |
2177 if (WillBeHeapVector<OwnPtrWillBeMember<MutationObserverRegistration> >*
registry = node->mutationObserverRegistry()) { | 2175 if (WillBeHeapVector<OwnPtrWillBeMember<MutationObserverRegistration> >*
registry = node->mutationObserverRegistry()) { |
2178 const size_t size = registry->size(); | 2176 const std::size_t size = registry->size(); |
2179 for (size_t i = 0; i < size; ++i) | 2177 for (std::size_t i = 0; i < size; ++i) |
2180 registry->at(i)->observedSubtreeNodeWillDetach(*this); | 2178 registry->at(i)->observedSubtreeNodeWillDetach(*this); |
2181 } | 2179 } |
2182 | 2180 |
2183 if (WillBeHeapHashSet<RawPtrWillBeMember<MutationObserverRegistration> >
* transientRegistry = node->transientMutationObserverRegistry()) { | 2181 if (WillBeHeapHashSet<RawPtrWillBeMember<MutationObserverRegistration> >
* transientRegistry = node->transientMutationObserverRegistry()) { |
2184 for (WillBeHeapHashSet<RawPtrWillBeMember<MutationObserverRegistrati
on> >::iterator iter = transientRegistry->begin(); iter != transientRegistry->en
d(); ++iter) | 2182 for (WillBeHeapHashSet<RawPtrWillBeMember<MutationObserverRegistrati
on> >::iterator iter = transientRegistry->begin(); iter != transientRegistry->en
d(); ++iter) |
2185 (*iter)->observedSubtreeNodeWillDetach(*this); | 2183 (*iter)->observedSubtreeNodeWillDetach(*this); |
2186 } | 2184 } |
2187 } | 2185 } |
2188 } | 2186 } |
2189 | 2187 |
(...skipping 254 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2444 for (Node* node = parentOrShadowHostNode(); node; node = node->parentOrShado
wHostNode()) | 2442 for (Node* node = parentOrShadowHostNode(); node; node = node->parentOrShado
wHostNode()) |
2445 node->incrementConnectedSubframeCount(count); | 2443 node->incrementConnectedSubframeCount(count); |
2446 } | 2444 } |
2447 | 2445 |
2448 PassRefPtrWillBeRawPtr<NodeList> Node::getDestinationInsertionPoints() | 2446 PassRefPtrWillBeRawPtr<NodeList> Node::getDestinationInsertionPoints() |
2449 { | 2447 { |
2450 document().updateDistributionForNodeIfNeeded(this); | 2448 document().updateDistributionForNodeIfNeeded(this); |
2451 WillBeHeapVector<RawPtrWillBeMember<InsertionPoint>, 8> insertionPoints; | 2449 WillBeHeapVector<RawPtrWillBeMember<InsertionPoint>, 8> insertionPoints; |
2452 collectDestinationInsertionPoints(*this, insertionPoints); | 2450 collectDestinationInsertionPoints(*this, insertionPoints); |
2453 WillBeHeapVector<RefPtrWillBeMember<Node> > filteredInsertionPoints; | 2451 WillBeHeapVector<RefPtrWillBeMember<Node> > filteredInsertionPoints; |
2454 for (size_t i = 0; i < insertionPoints.size(); ++i) { | 2452 for (std::size_t i = 0; i < insertionPoints.size(); ++i) { |
2455 InsertionPoint* insertionPoint = insertionPoints[i]; | 2453 InsertionPoint* insertionPoint = insertionPoints[i]; |
2456 ASSERT(insertionPoint->containingShadowRoot()); | 2454 ASSERT(insertionPoint->containingShadowRoot()); |
2457 if (insertionPoint->containingShadowRoot()->type() != ShadowRoot::UserAg
entShadowRoot) | 2455 if (insertionPoint->containingShadowRoot()->type() != ShadowRoot::UserAg
entShadowRoot) |
2458 filteredInsertionPoints.append(insertionPoint); | 2456 filteredInsertionPoints.append(insertionPoint); |
2459 } | 2457 } |
2460 return StaticNodeList::adopt(filteredInsertionPoints); | 2458 return StaticNodeList::adopt(filteredInsertionPoints); |
2461 } | 2459 } |
2462 | 2460 |
2463 void Node::registerScopedHTMLStyleChild() | 2461 void Node::registerScopedHTMLStyleChild() |
2464 { | 2462 { |
2465 setHasScopedHTMLStyleChild(true); | 2463 setHasScopedHTMLStyleChild(true); |
2466 } | 2464 } |
2467 | 2465 |
2468 void Node::unregisterScopedHTMLStyleChild() | 2466 void Node::unregisterScopedHTMLStyleChild() |
2469 { | 2467 { |
2470 ASSERT(hasScopedHTMLStyleChild()); | 2468 ASSERT(hasScopedHTMLStyleChild()); |
2471 setHasScopedHTMLStyleChild(numberOfScopedHTMLStyleChildren()); | 2469 setHasScopedHTMLStyleChild(numberOfScopedHTMLStyleChildren()); |
2472 } | 2470 } |
2473 | 2471 |
2474 size_t Node::numberOfScopedHTMLStyleChildren() const | 2472 std::size_t Node::numberOfScopedHTMLStyleChildren() const |
2475 { | 2473 { |
2476 size_t count = 0; | 2474 std::size_t count = 0; |
2477 for (HTMLStyleElement* style = Traversal<HTMLStyleElement>::firstChild(*this
); style; style = Traversal<HTMLStyleElement>::nextSibling(*style)) { | 2475 for (HTMLStyleElement* style = Traversal<HTMLStyleElement>::firstChild(*this
); style; style = Traversal<HTMLStyleElement>::nextSibling(*style)) { |
2478 if (style->isRegisteredAsScoped()) | 2476 if (style->isRegisteredAsScoped()) |
2479 ++count; | 2477 ++count; |
2480 } | 2478 } |
2481 | 2479 |
2482 return count; | 2480 return count; |
2483 } | 2481 } |
2484 | 2482 |
2485 void Node::setFocus(bool flag) | 2483 void Node::setFocus(bool flag) |
2486 { | 2484 { |
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2596 node->showTreeForThis(); | 2594 node->showTreeForThis(); |
2597 } | 2595 } |
2598 | 2596 |
2599 void showNodePath(const WebCore::Node* node) | 2597 void showNodePath(const WebCore::Node* node) |
2600 { | 2598 { |
2601 if (node) | 2599 if (node) |
2602 node->showNodePathForThis(); | 2600 node->showNodePathForThis(); |
2603 } | 2601 } |
2604 | 2602 |
2605 #endif | 2603 #endif |
OLD | NEW |