Changeset 82882 in webkit
- Timestamp:
- Apr 4, 2011 3:25:18 PM (13 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 2 added
- 15 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/Android.mk
r82880 r82882 189 189 dom/TouchList.cpp \ 190 190 dom/Traversal.cpp \ 191 dom/TreeScope.cpp \ 191 192 dom/TreeWalker.cpp \ 192 193 dom/UIEvent.cpp \ -
trunk/Source/WebCore/CMakeLists.txt
r82880 r82882 615 615 dom/TransformSourceLibxslt.cpp 616 616 dom/Traversal.cpp 617 dom/TreeScope.cpp 617 618 dom/TreeWalker.cpp 618 619 dom/UIEvent.cpp -
trunk/Source/WebCore/ChangeLog
r82880 r82882 1 2011-04-04 Roland Steiner <rolandsteiner@chromium.org> 2 3 Reviewed by Dimitri Glazkov. 4 5 Bug 57689 - Extract scoping functionality from Document 6 https://bugs.webkit.org/show_bug.cgi?id=57689 7 8 Moved selfOnlyRef (renamed to guardRef), element ID, image map 9 and accesss key functionalities from Document to a new base 10 class TreeScope. 11 12 TreeShared: made removedLastRef protected 13 14 No new tests. (refactoring) 15 16 * Android.mk: 17 * CMakeLists.txt: 18 * GNUmakefile.am: 19 * WebCore.gypi: 20 * WebCore.pro: 21 * WebCore.vcproj/WebCore.vcproj: 22 * WebCore.xcodeproj/project.pbxproj: 23 * dom/Document.cpp: 24 (WebCore::Document::Document): 25 (WebCore::Document::destroyScope): 26 (WebCore::Document::getElementById): 27 (WebCore::Document::childrenChanged): 28 (WebCore::Document::scheduleStyleRecalc): 29 (WebCore::Document::attach): 30 (WebCore::Document::detach): 31 * dom/Document.h: 32 (WebCore::Node::Node): 33 * dom/DocumentOrderedMap.cpp: 34 (WebCore::DocumentOrderedMap::get): 35 (WebCore::DocumentOrderedMap::getElementById): 36 (WebCore::DocumentOrderedMap::getElementByMapName): 37 (WebCore::DocumentOrderedMap::getElementByLowercasedMapName): 38 * dom/DocumentOrderedMap.h: 39 * dom/DOMAllInOne.cpp: 40 * dom/Node.cpp: 41 (WebCore::Node::~Node): 42 (WebCore::Node::setDocument): 43 * dom/Node.h: 44 * dom/TreeScope.cpp: Added. 45 * dom/TreeScope.h: Added. 46 * platform/TreeShared.h: 47 (WebCore::TreeShared::removedLastRef): made protected 48 1 49 2011-04-04 MORITA Hajime <morrita@google.com> 2 50 -
trunk/Source/WebCore/GNUmakefile.am
r82880 r82882 1353 1353 Source/WebCore/dom/Traversal.h \ 1354 1354 Source/WebCore/dom/TreeDepthLimit.h \ 1355 Source/WebCore/dom/TreeScope.cpp \ 1356 Source/WebCore/dom/TreeScope.h \ 1355 1357 Source/WebCore/dom/TreeWalker.cpp \ 1356 1358 Source/WebCore/dom/TreeWalker.h \ -
trunk/Source/WebCore/WebCore.gypi
r82880 r82882 2546 2546 'dom/Traversal.h', 2547 2547 'dom/TreeDepthLimit.h', 2548 'dom/TreeScope.cpp', 2549 'dom/TreeScope.h', 2548 2550 'dom/TreeWalker.cpp', 2549 2551 'dom/TreeWalker.h', -
trunk/Source/WebCore/WebCore.pro
r82880 r82882 545 545 dom/TouchList.cpp \ 546 546 dom/Traversal.cpp \ 547 dom/TreeScope.cpp \ 547 548 dom/TreeWalker.cpp \ 548 549 dom/UIEvent.cpp \ … … 1508 1509 dom/Traversal.h \ 1509 1510 dom/TreeDepthLimit.h \ 1511 dom/TreeScope.h \ 1510 1512 dom/TreeWalker.h \ 1511 1513 dom/UIEvent.h \ -
trunk/Source/WebCore/WebCore.vcproj/WebCore.vcproj
r82880 r82882 47079 47079 </File> 47080 47080 <File 47081 RelativePath="..\dom\TreeScope.cpp" 47082 > 47083 <FileConfiguration 47084 Name="Debug|Win32" 47085 ExcludedFromBuild="true" 47086 > 47087 <Tool 47088 Name="VCCLCompilerTool" 47089 /> 47090 </FileConfiguration> 47091 <FileConfiguration 47092 Name="Release|Win32" 47093 ExcludedFromBuild="true" 47094 > 47095 <Tool 47096 Name="VCCLCompilerTool" 47097 /> 47098 </FileConfiguration> 47099 <FileConfiguration 47100 Name="Debug_Cairo_CFLite|Win32" 47101 ExcludedFromBuild="true" 47102 > 47103 <Tool 47104 Name="VCCLCompilerTool" 47105 /> 47106 </FileConfiguration> 47107 <FileConfiguration 47108 Name="Release_Cairo_CFLite|Win32" 47109 ExcludedFromBuild="true" 47110 > 47111 <Tool 47112 Name="VCCLCompilerTool" 47113 /> 47114 </FileConfiguration> 47115 <FileConfiguration 47116 Name="Debug_All|Win32" 47117 ExcludedFromBuild="true" 47118 > 47119 <Tool 47120 Name="VCCLCompilerTool" 47121 /> 47122 </FileConfiguration> 47123 <FileConfiguration 47124 Name="Production|Win32" 47125 ExcludedFromBuild="true" 47126 > 47127 <Tool 47128 Name="VCCLCompilerTool" 47129 /> 47130 </FileConfiguration> 47131 </File> 47132 <File 47133 RelativePath="..\dom\TreeScope.h" 47134 > 47135 </File> 47136 <File 47081 47137 RelativePath="..\dom\TreeWalker.h" 47082 47138 > -
trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj
r82880 r82882 317 317 14CF7B3309F6ECD700EB3665 /* JSCSSRule.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 14CF7B3109F6ECD700EB3665 /* JSCSSRule.cpp */; }; 318 318 14CF7B3409F6ECD700EB3665 /* JSCSSRule.h in Headers */ = {isa = PBXBuildFile; fileRef = 14CF7B3209F6ECD700EB3665 /* JSCSSRule.h */; }; 319 14D64B5C134A5B6B00E58FDA /* TreeScope.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 14D64B5A134A5B6B00E58FDA /* TreeScope.cpp */; }; 320 14D64B5D134A5B6B00E58FDA /* TreeScope.h in Headers */ = {isa = PBXBuildFile; fileRef = 14D64B5B134A5B6B00E58FDA /* TreeScope.h */; settings = {ATTRIBUTES = (Private, ); }; }; 319 321 14D823520AF92A790004F057 /* Chrome.h in Headers */ = {isa = PBXBuildFile; fileRef = 14D823500AF92A790004F057 /* Chrome.h */; settings = {ATTRIBUTES = (Private, ); }; }; 320 322 14D8238B0AF92DF60004F057 /* Chrome.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 14D8238A0AF92DF60004F057 /* Chrome.cpp */; }; … … 6696 6698 14CF7B3209F6ECD700EB3665 /* JSCSSRule.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = JSCSSRule.h; sourceTree = "<group>"; }; 6697 6699 14CF7C2009F7110600EB3665 /* KeyboardEvent.idl */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = text; path = KeyboardEvent.idl; sourceTree = "<group>"; }; 6700 14D64B5A134A5B6B00E58FDA /* TreeScope.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = TreeScope.cpp; sourceTree = "<group>"; }; 6701 14D64B5B134A5B6B00E58FDA /* TreeScope.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TreeScope.h; sourceTree = "<group>"; }; 6698 6702 14D823500AF92A790004F057 /* Chrome.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Chrome.h; sourceTree = "<group>"; }; 6699 6703 14D8238A0AF92DF60004F057 /* Chrome.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = Chrome.cpp; sourceTree = "<group>"; }; … … 19438 19442 854FE72D0A2297BE0058D7AD /* Traversal.h */, 19439 19443 37FD4297118368460093C029 /* TreeDepthLimit.h */, 19444 14D64B5A134A5B6B00E58FDA /* TreeScope.cpp */, 19445 14D64B5B134A5B6B00E58FDA /* TreeScope.h */, 19440 19446 854FE72E0A2297BE0058D7AD /* TreeWalker.cpp */, 19441 19447 854FE72F0A2297BE0058D7AD /* TreeWalker.h */, … … 21209 21215 4F707A9A11EF679400ACDA69 /* InspectorBackendDispatcher.h in Headers */, 21210 21216 F3D4C47912E07663003DA150 /* InspectorBrowserDebuggerAgent.h in Headers */, 21211 227777601345DEA9008EA455 /* InspectorFrontendChannel.h in Headers */,21212 21217 1C81B95C0E97330800266E07 /* InspectorClient.h in Headers */, 21213 21218 F3335BF912E07DC300D33011 /* InspectorConsoleAgent.h in Headers */, … … 21222 21227 7A74ECBB101839A600BF939E /* InspectorDOMStorageAgent.h in Headers */, 21223 21228 41F061740F5F00AC00A07EAC /* InspectorDOMStorageResource.h in Headers */, 21229 227777601345DEA9008EA455 /* InspectorFrontendChannel.h in Headers */, 21224 21230 F344C7141125B82C00F26EEE /* InspectorFrontendClient.h in Headers */, 21225 21231 F344C75311294D9D00F26EEE /* InspectorFrontendClientLocal.h in Headers */, … … 22597 22603 854FE7370A2297BE0058D7AD /* Traversal.h in Headers */, 22598 22604 37FD4298118368460093C029 /* TreeDepthLimit.h in Headers */, 22605 14D64B5D134A5B6B00E58FDA /* TreeScope.h in Headers */, 22599 22606 1419D2C50CEA6F6100FF507A /* TreeShared.h in Headers */, 22600 22607 854FE7390A2297BE0058D7AD /* TreeWalker.h in Headers */, … … 25305 25312 49E911D10EF86D47009D0CAF /* TranslateTransformOperation.cpp in Sources */, 25306 25313 854FE7360A2297BE0058D7AD /* Traversal.cpp in Sources */, 25314 14D64B5C134A5B6B00E58FDA /* TreeScope.cpp in Sources */, 25307 25315 854FE7380A2297BE0058D7AD /* TreeWalker.cpp in Sources */, 25308 25316 93309E19099E64920056E581 /* TypingCommand.cpp in Sources */, -
trunk/Source/WebCore/dom/DOMAllInOne.cpp
r82127 r82882 122 122 #include "TransformSourceLibxslt.cpp" 123 123 #include "Traversal.cpp" 124 #include "TreeScope.cpp" 124 125 #include "TreeWalker.cpp" 125 126 #include "UIEvent.cpp" -
trunk/Source/WebCore/dom/Document.cpp
r82580 r82882 378 378 379 379 Document::Document(Frame* frame, const KURL& url, bool isXHTML, bool isHTML) 380 : ContainerNode(0)380 : TreeScope(0) 381 381 , m_compatibilityMode(NoQuirksMode) 382 382 , m_compatibilityModeLocked(false) … … 400 400 , m_savedRenderer(0) 401 401 , m_designMode(inherit) 402 , m_selfOnlyRefCount(0)403 402 #if ENABLE(SVG) 404 403 , m_svgExtensions(0) … … 408 407 , m_dashboardRegionsDirty(false) 409 408 #endif 410 , m_accessKeyMapValid(false)411 409 , m_createRenderers(true) 412 410 , m_inPageCache(false) … … 416 414 , m_usesViewSourceStyles(false) 417 415 , m_sawElementsInKnownNamespaces(false) 418 , m_numNodeListCaches(0)419 416 #if USE(JSC) 420 417 , m_normalWorldWrapperCache(0) … … 512 509 } 513 510 514 void Document:: removedLastRef()511 void Document::destroyScope() 515 512 { 516 513 ASSERT(!m_deletionHasBegun); 517 if (m_selfOnlyRefCount) { 518 // If removing a child removes the last self-only ref, we don't 519 // want the document to be destructed until after 520 // removeAllChildren returns, so we guard ourselves with an 521 // extra self-only ref. 522 selfOnlyRef(); 523 524 // We must make sure not to be retaining any of our children through 525 // these extra pointers or we will create a reference cycle. 526 m_docType = 0; 527 m_focusedNode = 0; 528 m_hoverNode = 0; 529 m_activeNode = 0; 530 m_titleElement = 0; 531 m_documentElement = 0; 514 515 // We must make sure not to be retaining any of our children through 516 // these extra pointers or we will create a reference cycle. 517 m_docType = 0; 518 m_focusedNode = 0; 519 m_hoverNode = 0; 520 m_activeNode = 0; 521 m_titleElement = 0; 522 m_documentElement = 0; 532 523 #if ENABLE(FULLSCREEN_API) 533 m_fullScreenElement = 0; 534 #endif 535 536 // removeAllChildren() doesn't always unregister IDs, do it upfront to avoid having stale references in the map. 537 m_elementsById.clear(); 538 539 removeAllChildren(); 540 541 m_markers->detach(); 542 543 detachParser(); 544 545 m_cssCanvasElements.clear(); 524 m_fullScreenElement = 0; 525 #endif 526 527 TreeScope::destroyScope(); 528 529 m_markers->detach(); 530 531 detachParser(); 532 533 m_cssCanvasElements.clear(); 546 534 547 535 #if ENABLE(REQUEST_ANIMATION_FRAME) 548 549 536 // FIXME: consider using ActiveDOMObject. 537 m_scriptedAnimationController = 0; 550 538 #endif 551 539 552 540 #ifndef NDEBUG 553 m_inRemovedLastRefFunction = false; 554 #endif 555 556 selfOnlyDeref(); 557 } else { 558 #ifndef NDEBUG 559 m_deletionHasBegun = true; 560 #endif 561 delete this; 562 } 541 m_inRemovedLastRefFunction = false; 542 #endif 563 543 } 564 544 … … 622 602 } 623 603 604 Element* Document::getElementById(const AtomicString& id) const 605 { 606 return TreeScope::getElementById(id); 607 } 608 624 609 MediaQueryMatcher* Document::mediaQueryMatcher() 625 610 { … … 710 695 void Document::childrenChanged(bool changedByParser, Node* beforeChange, Node* afterChange, int childCountDelta) 711 696 { 712 ContainerNode::childrenChanged(changedByParser, beforeChange, afterChange, childCountDelta);697 TreeScope::childrenChanged(changedByParser, beforeChange, afterChange, childCountDelta); 713 698 714 699 // Invalidate the document element we have cached in case it was replaced. … … 1003 988 } 1004 989 1005 Element* Document::getElementById(const AtomicString& elementId) const1006 {1007 if (elementId.isEmpty())1008 return 0;1009 return m_elementsById.getElementById(elementId.impl(), this);1010 }1011 1012 990 String Document::readyState() const 1013 991 { … … 1236 1214 } 1237 1215 1238 void Document::addElementById(const AtomicString& elementId, Element* element)1239 {1240 m_elementsById.add(elementId.impl(), element);1241 }1242 1243 void Document::removeElementById(const AtomicString& elementId, Element* element)1244 {1245 m_elementsById.remove(elementId.impl(), element);1246 }1247 1248 Element* Document::getElementByAccessKey(const String& key) const1249 {1250 if (key.isEmpty())1251 return 0;1252 if (!m_accessKeyMapValid) {1253 for (Node* n = firstChild(); n; n = n->traverseNextNode()) {1254 if (!n->isElementNode())1255 continue;1256 Element* element = static_cast<Element*>(n);1257 const AtomicString& accessKey = element->getAttribute(accesskeyAttr);1258 if (!accessKey.isEmpty())1259 m_elementsByAccessKey.set(accessKey.impl(), element);1260 }1261 m_accessKeyMapValid = true;1262 }1263 return m_elementsByAccessKey.get(key.impl());1264 }1265 1266 1216 /* 1267 1217 * Performs three operations: … … 1461 1411 1462 1412 // FIXME: Why on earth is this here? This is clearly misplaced. 1463 if (m_accessKeyMapValid) { 1464 m_accessKeyMapValid = false; 1465 m_elementsByAccessKey.clear(); 1466 } 1413 invalidateAccessKeyMap(); 1467 1414 1468 1415 m_styleRecalcTimer.startOneShot(0); … … 1756 1703 setRenderer(0); 1757 1704 1758 ContainerNode::attach();1705 TreeScope::attach(); 1759 1706 1760 1707 setRenderer(render); … … 1813 1760 m_activeNode = 0; 1814 1761 1815 ContainerNode::detach();1762 TreeScope::detach(); 1816 1763 1817 1764 unscheduleStyleRecalc(); … … 3896 3843 } 3897 3844 3898 void Document::addImageMap(HTMLMapElement* imageMap)3899 {3900 AtomicStringImpl* name = imageMap->getName().impl();3901 if (!name)3902 return;3903 m_imageMapsByName.add(name, imageMap);3904 }3905 3906 void Document::removeImageMap(HTMLMapElement* imageMap)3907 {3908 AtomicStringImpl* name = imageMap->getName().impl();3909 if (!name)3910 return;3911 m_imageMapsByName.remove(name, imageMap);3912 }3913 3914 HTMLMapElement* Document::getImageMap(const String& url) const3915 {3916 if (url.isNull())3917 return 0;3918 size_t hashPos = url.find('#');3919 String name = (hashPos == notFound ? url : url.substring(hashPos + 1)).impl();3920 if (isHTMLDocument())3921 return static_cast<HTMLMapElement*>(m_imageMapsByName.getElementByLowercasedMapName(AtomicString(name.lower()).impl(), this));3922 return static_cast<HTMLMapElement*>(m_imageMapsByName.getElementByMapName(AtomicString(name).impl(), this));3923 }3924 3925 3845 void Document::setDecoder(PassRefPtr<TextResourceDecoder> decoder) 3926 3846 { … … 4771 4691 } 4772 4692 4773 Element* Document::findAnchor(const String& name)4774 {4775 if (name.isEmpty())4776 return 0;4777 if (Element* element = getElementById(name))4778 return element;4779 for (Node* node = this; node; node = node->traverseNextNode()) {4780 if (node->hasTagName(aTag)) {4781 HTMLAnchorElement* anchor = static_cast<HTMLAnchorElement*>(node);4782 if (inQuirksMode()) {4783 // Quirks mode, case insensitive comparison of names.4784 if (equalIgnoringCase(anchor->name(), name))4785 return anchor;4786 } else {4787 // Strict mode, names need to match exactly.4788 if (anchor->name() == name)4789 return anchor;4790 }4791 }4792 }4793 return 0;4794 }4795 4796 4693 String Document::displayStringModifiedByEncoding(const String& str) const 4797 4694 { -
trunk/Source/WebCore/dom/Document.h
r82580 r82882 32 32 #include "CollectionType.h" 33 33 #include "Color.h" 34 #include "ContainerNode.h"35 34 #include "DOMTimeStamp.h" 36 #include "DocumentOrderedMap.h"37 35 #include "DocumentTiming.h" 38 36 #include "QualifiedName.h" … … 40 38 #include "StringWithDirection.h" 41 39 #include "Timer.h" 40 #include "TreeScope.h" 42 41 #include "ViewportArguments.h" 43 42 #include <wtf/FixedArray.h> … … 207 206 enum StyleSelectorUpdateFlag { RecalcStyleImmediately, DeferRecalcStyle }; 208 207 209 class Document : public ContainerNode, public ScriptExecutionContext {208 class Document : public TreeScope, public ScriptExecutionContext { 210 209 public: 211 210 static PassRefPtr<Document> create(Frame* frame, const KURL& url) … … 221 220 MediaQueryMatcher* mediaQueryMatcher(); 222 221 223 using ContainerNode::ref; 224 using ContainerNode::deref; 225 226 // Nodes belonging to this document hold "self-only" references - 227 // these are enough to keep the document from being destroyed, but 228 // not enough to keep it from removing its children. This allows a 229 // node that outlives its document to still have a valid document 230 // pointer without introducing reference cycles 231 232 void selfOnlyRef() 233 { 234 ASSERT(!m_deletionHasBegun); 235 ++m_selfOnlyRefCount; 236 } 237 void selfOnlyDeref() 238 { 239 ASSERT(!m_deletionHasBegun); 240 --m_selfOnlyRefCount; 241 if (!m_selfOnlyRefCount && !refCount()) { 242 #ifndef NDEBUG 243 m_deletionHasBegun = true; 244 #endif 245 delete this; 246 } 247 } 222 using TreeScope::ref; 223 using TreeScope::deref; 224 225 Element* getElementById(const AtomicString& id) const; 248 226 249 227 // DOM methods & attributes for Document … … 330 308 virtual PassRefPtr<Element> createElementNS(const String& namespaceURI, const String& qualifiedName, ExceptionCode&); 331 309 PassRefPtr<Element> createElement(const QualifiedName&, bool createdByParser); 332 Element* getElementById(const AtomicString&) const;333 bool hasElementWithId(AtomicStringImpl* id) const;334 bool containsMultipleElementsWithId(const AtomicString& id) const;335 310 336 311 /** … … 396 371 PassRefPtr<HTMLAllCollection> all(); 397 372 398 // Find first anchor with the given name.399 // First searches for an element with the given ID, but if that fails, then looks400 // for an anchor with the given name. ID matching is always case sensitive, but401 // Anchor name matching is case sensitive in strict mode and not case sensitive in402 // quirks mode for historical compatibility reasons.403 Element* findAnchor(const String& name);404 405 373 CollectionCache* collectionInfo(CollectionType type) 406 374 { … … 453 421 } 454 422 455 Element* getElementByAccessKey(const String& key) const;456 457 423 /** 458 424 * Updates the pending sheet count and then calls updateStyleSelector. … … 868 834 static bool hasPrefixNamespaceMismatch(const QualifiedName&); 869 835 870 void addElementById(const AtomicString& elementId, Element *element);871 void removeElementById(const AtomicString& elementId, Element *element);872 873 void addImageMap(HTMLMapElement*);874 void removeImageMap(HTMLMapElement*);875 HTMLMapElement* getImageMap(const String& url) const;876 877 836 HTMLElement* body() const; 878 837 void setBody(PassRefPtr<HTMLElement>, ExceptionCode&); … … 947 906 bool useSecureKeyboardEntryWhenActive() const; 948 907 949 void addNodeListCache() { ++m_numNodeListCaches; }950 void removeNodeListCache() { ASSERT(m_numNodeListCaches > 0); --m_numNodeListCaches; }951 bool hasNodeListCaches() const { return m_numNodeListCaches; }952 953 908 void updateFocusAppearanceSoon(bool restorePreviousSelection); 954 909 void cancelFocusAppearanceUpdate(); … … 1131 1086 Document(Frame*, const KURL&, bool isXHTML, bool isHTML); 1132 1087 1088 virtual void destroyScope(); 1089 1133 1090 void clearXMLVersion() { m_xmlVersion = String(); } 1134 1091 … … 1142 1099 1143 1100 virtual bool isDocument() const { return true; } 1144 virtual void removedLastRef();1145 1101 1146 1102 virtual void childrenChanged(bool changedByParser = false, Node* beforeChange = 0, Node* afterChange = 0, int childCountDelta = 0); … … 1329 1285 #endif 1330 1286 1331 DocumentOrderedMap m_imageMapsByName;1332 1333 1287 int m_docID; // A unique document identifier used for things like document-specific mapped attributes. 1334 1288 … … 1347 1301 RefPtr<TextResourceDecoder> m_decoder; 1348 1302 1349 DocumentOrderedMap m_elementsById;1350 1351 mutable HashMap<StringImpl*, Element*, CaseFoldingHash> m_elementsByAccessKey;1352 1353 1303 InheritedBool m_designMode; 1354 1304 1355 int m_selfOnlyRefCount;1356 1357 1305 CheckedRadioButtons m_checkedRadioButtons; 1358 1306 … … 1377 1325 HashMap<String, RefPtr<HTMLCanvasElement> > m_cssCanvasElements; 1378 1326 1379 mutable bool m_accessKeyMapValid;1380 1327 bool m_createRenderers; 1381 1328 bool m_inPageCache; … … 1393 1340 bool m_usesViewSourceStyles; 1394 1341 bool m_sawElementsInKnownNamespaces; 1395 1396 unsigned m_numNodeListCaches;1397 1342 1398 1343 #if USE(JSC) … … 1443 1388 }; 1444 1389 1445 inline bool Document::hasElementWithId(AtomicStringImpl* id) const1446 {1447 ASSERT(id);1448 return m_elementsById.contains(id);1449 }1450 1451 inline bool Document::containsMultipleElementsWithId(const AtomicString& id) const1452 {1453 return m_elementsById.containsMultiple(id.impl());1454 }1455 1456 1390 inline bool Node::isDocumentNode() const 1457 1391 { … … 1468 1402 { 1469 1403 if (m_document) 1470 m_document-> selfOnlyRef();1404 m_document->guardRef(); 1471 1405 #if !defined(NDEBUG) || (defined(DUMP_NODE_STATISTICS) && DUMP_NODE_STATISTICS) 1472 1406 trackForDebugging(); -
trunk/Source/WebCore/dom/DocumentOrderedMap.cpp
r77239 r82882 35 35 #include "HTMLMapElement.h" 36 36 #include "HTMLNames.h" 37 #include "TreeScope.h" 37 38 38 39 namespace WebCore { … … 105 106 106 107 template<bool keyMatches(AtomicStringImpl*, Element*)> 107 inline Element* DocumentOrderedMap::get(AtomicStringImpl* key, const Document* document) const108 inline Element* DocumentOrderedMap::get(AtomicStringImpl* key, const TreeScope* scope) const 108 109 { 109 110 ASSERT(key); … … 117 118 if (m_duplicateCounts.contains(key)) { 118 119 // We know there's at least one node that matches; iterate to find the first one. 119 for (Node* node = document->firstChild(); node; node = node->traverseNextNode()) {120 for (Node* node = scope->firstChild(); node; node = node->traverseNextNode()) { 120 121 if (!node->isElementNode()) 121 122 continue; … … 133 134 } 134 135 135 Element* DocumentOrderedMap::getElementById(AtomicStringImpl* key, const Document* document) const136 Element* DocumentOrderedMap::getElementById(AtomicStringImpl* key, const TreeScope* scope) const 136 137 { 137 return get<keyMatchesId>(key, document);138 return get<keyMatchesId>(key, scope); 138 139 } 139 140 140 Element* DocumentOrderedMap::getElementByMapName(AtomicStringImpl* key, const Document* document) const141 Element* DocumentOrderedMap::getElementByMapName(AtomicStringImpl* key, const TreeScope* scope) const 141 142 { 142 return get<keyMatchesMapName>(key, document);143 return get<keyMatchesMapName>(key, scope); 143 144 } 144 145 145 Element* DocumentOrderedMap::getElementByLowercasedMapName(AtomicStringImpl* key, const Document* document) const146 Element* DocumentOrderedMap::getElementByLowercasedMapName(AtomicStringImpl* key, const TreeScope* scope) const 146 147 { 147 return get<keyMatchesLowercasedMapName>(key, document);148 return get<keyMatchesLowercasedMapName>(key, scope); 148 149 } 149 150 -
trunk/Source/WebCore/dom/DocumentOrderedMap.h
r77239 r82882 38 38 namespace WebCore { 39 39 40 class Document;41 40 class Element; 41 class TreeScope; 42 42 43 43 class DocumentOrderedMap { … … 50 50 bool containsMultiple(AtomicStringImpl*) const; 51 51 // concrete instantiations of the get<>() method template 52 Element* getElementById(AtomicStringImpl*, const Document*) const;53 Element* getElementByMapName(AtomicStringImpl*, const Document*) const;54 Element* getElementByLowercasedMapName(AtomicStringImpl*, const Document*) const;52 Element* getElementById(AtomicStringImpl*, const TreeScope*) const; 53 Element* getElementByMapName(AtomicStringImpl*, const TreeScope*) const; 54 Element* getElementByLowercasedMapName(AtomicStringImpl*, const TreeScope*) const; 55 55 56 56 void checkConsistency() const; 57 57 58 58 private: 59 template<bool keyMatches(AtomicStringImpl*, Element*)> Element* get(AtomicStringImpl*, const Document*) const;59 template<bool keyMatches(AtomicStringImpl*, Element*)> Element* get(AtomicStringImpl*, const TreeScope*) const; 60 60 61 61 typedef HashMap<AtomicStringImpl*, Element*> Map; -
trunk/Source/WebCore/dom/Node.cpp
r82264 r82882 407 407 408 408 if (m_document) 409 m_document-> selfOnlyDeref();409 m_document->guardDeref(); 410 410 } 411 411 … … 443 443 return; 444 444 445 document-> selfOnlyRef();445 document->guardRef(); 446 446 447 447 setWillMoveToNewOwnerDocumentWasCalled(false); … … 461 461 if (m_document) { 462 462 m_document->moveNodeIteratorsToNewDocument(this, document); 463 m_document-> selfOnlyDeref();463 m_document->guardDeref(); 464 464 } 465 465 … … 795 795 } 796 796 797 void Node::setDocumentRecursively(Document* document)798 { 799 if ( this->document() == document)797 void Node::setDocumentRecursively(Document* newDocument) 798 { 799 if (document() == newDocument) 800 800 return; 801 801 … … 804 804 // of the document it was moved to. By increasing the DOMTreeVersion of the donating document here 805 805 // we ensure that the collection cache will be invalidated as needed when the element is moved back. 806 if ( this->document())807 this->document()->incDOMTreeVersion();806 if (document()) 807 document()->incDOMTreeVersion(); 808 808 809 809 for (Node* node = this; node; node = node->traverseNextNode(this)) { 810 node->setDocument( document);810 node->setDocument(newDocument); 811 811 if (!node->isElementNode()) 812 812 continue; 813 813 if (Node* shadow = toElement(node)->shadowRoot()) 814 shadow->setDocumentRecursively( document);814 shadow->setDocumentRecursively(newDocument); 815 815 } 816 816 } -
trunk/Source/WebCore/platform/TreeShared.h
r76248 r82882 110 110 #endif 111 111 112 private: 113 #ifndef NDEBUG 114 friend void adopted<>(TreeShared<T>*); 115 #endif 116 112 protected: 117 113 virtual void removedLastRef() 118 114 { … … 122 118 delete this; 123 119 } 120 121 private: 122 #ifndef NDEBUG 123 friend void adopted<>(TreeShared<T>*); 124 #endif 124 125 125 126 int m_refCount;
Note: See TracChangeset
for help on using the changeset viewer.