tree: 57b3c9498e0a6cd91e7bcd9ae44e8f68e3779109 [path history] [tgz]
  1. AccessibleNode.cpp
  2. AccessibleNode.h
  3. AccessibleNode.idl
  4. AccessibleNodeList.cpp
  5. AccessibleNodeList.h
  6. AccessibleNodeList.idl
  7. AncestorList.h
  8. AnimationWorkletProxyClient.cpp
  9. AnimationWorkletProxyClient.h
  10. Attr.cpp
  11. Attr.h
  12. Attr.idl
  13. Attribute.h
  14. AttributeCollection.h
  15. AttrTest.cpp
  16. AXObjectCache.cpp
  17. AXObjectCache.h
  18. AXObjectCacheBase.cpp
  19. AXObjectCacheBase.h
  20. BUILD.gn
  21. CDATASection.cpp
  22. CDATASection.h
  23. CDATASection.idl
  24. CharacterData.cpp
  25. CharacterData.h
  26. CharacterData.idl
  27. ChildFrameDisconnector.cpp
  28. ChildFrameDisconnector.h
  29. ChildListMutationScope.cpp
  30. ChildListMutationScope.h
  31. ChildNode.h
  32. ChildNode.idl
  33. ChildNodeList.cpp
  34. ChildNodeList.h
  35. ClassCollection.cpp
  36. ClassCollection.h
  37. ClassicPendingScript.cpp
  38. ClassicPendingScript.h
  39. ClassicScript.cpp
  40. ClassicScript.h
  41. CollectionIndexCache.h
  42. Comment.cpp
  43. Comment.h
  44. Comment.idl
  45. CommonDefinitions.idl
  46. CompositorWorkerProxyClient.cpp
  47. CompositorWorkerProxyClient.h
  48. ContainerNode.cpp
  49. ContainerNode.h
  50. ContextFeatures.cpp
  51. ContextFeatures.h
  52. ContextFeaturesClientImpl.cpp
  53. ContextFeaturesClientImpl.h
  54. ContextLifecycleNotifier.cpp
  55. ContextLifecycleNotifier.h
  56. ContextLifecycleObserver.cpp
  57. ContextLifecycleObserver.h
  58. CSSSelectorWatch.cpp
  59. CSSSelectorWatch.h
  60. CSSSelectorWatchTest.cpp
  61. DatasetDOMStringMap.cpp
  62. DatasetDOMStringMap.h
  63. DecodedDataDocumentParser.cpp
  64. DecodedDataDocumentParser.h
  65. DistributedNodes.cpp
  66. DistributedNodes.h
  67. Document.cpp
  68. Document.h
  69. Document.idl
  70. DocumentEncodingData.cpp
  71. DocumentEncodingData.h
  72. DocumentFragment.cpp
  73. DocumentFragment.h
  74. DocumentFragment.idl
  75. DocumentInit.cpp
  76. DocumentInit.h
  77. DocumentLifecycle.cpp
  78. DocumentLifecycle.h
  79. DocumentOrShadowRoot.h
  80. DocumentOrShadowRoot.idl
  81. DocumentParser.cpp
  82. DocumentParser.h
  83. DocumentParserClient.h
  84. DocumentParserTiming.cpp
  85. DocumentParserTiming.h
  86. DocumentShutdownNotifier.cpp
  87. DocumentShutdownNotifier.h
  88. DocumentShutdownObserver.cpp
  89. DocumentShutdownObserver.h
  90. DocumentStatisticsCollector.cpp
  91. DocumentStatisticsCollector.h
  92. DocumentStatisticsCollectorTest.cpp
  93. DocumentStyleSheetCollection.cpp
  94. DocumentStyleSheetCollection.h
  95. DocumentStyleSheetCollector.cpp
  96. DocumentStyleSheetCollector.h
  97. DocumentTest.cpp
  98. DocumentTiming.cpp
  99. DocumentTiming.h
  100. DocumentType.cpp
  101. DocumentType.h
  102. DocumentType.idl
  103. DocumentWriteIntervention.cpp
  104. DocumentWriteIntervention.h
  105. DOMException.cpp
  106. DOMException.h
  107. DOMException.idl
  108. DOMHighResTimeStamp.h
  109. DOMImplementation.cpp
  110. DOMImplementation.h
  111. DOMImplementation.idl
  112. DOMImplementationTest.cpp
  113. DOMNodeIds.cpp
  114. DOMNodeIds.h
  115. DOMStringList.cpp
  116. DOMStringList.h
  117. DOMStringList.idl
  118. DOMStringMap.cpp
  119. DOMStringMap.h
  120. DOMStringMap.idl
  121. DOMTimeStamp.h
  122. DOMTokenList.cpp
  123. DOMTokenList.h
  124. DOMTokenList.idl
  125. Element.cpp
  126. Element.h
  127. Element.idl
  128. ElementCreationOptions.idl
  129. ElementData.cpp
  130. ElementData.h
  131. ElementDataCache.cpp
  132. ElementDataCache.h
  133. ElementDefinitionOptions.idl
  134. ElementRareData.cpp
  135. ElementRareData.h
  136. ElementRegistrationOptions.idl
  137. ElementShadow.cpp
  138. ElementShadow.h
  139. ElementShadowV0.cpp
  140. ElementShadowV0.h
  141. ElementTest.cpp
  142. ElementTraversal.h
  143. ElementVisibilityObserver.cpp
  144. ElementVisibilityObserver.h
  145. ElementVisibilityObserverTest.cpp
  146. EmptyNodeList.cpp
  147. EmptyNodeList.h
  148. ExceptionCode.h
  149. ExecutionContext.cpp
  150. ExecutionContext.h
  151. FirstLetterPseudoElement.cpp
  152. FirstLetterPseudoElement.h
  153. FlatTreeTraversal.cpp
  154. FlatTreeTraversal.h
  155. FlatTreeTraversalTest.cpp
  156. FrameRequestCallback.h
  157. FrameRequestCallback.idl
  158. FrameRequestCallbackCollection.cpp
  159. FrameRequestCallbackCollection.h
  160. FunctionStringCallback.idl
  161. GetRootNodeOptions.idl
  162. GlobalEventHandlers.h
  163. GlobalEventHandlers.idl
  164. IconURL.cpp
  165. IconURL.h
  166. IdleDeadline.cpp
  167. IdleDeadline.h
  168. IdleDeadline.idl
  169. IdleDeadlineTest.cpp
  170. IdleRequestCallback.h
  171. IdleRequestCallback.idl
  172. IdleRequestOptions.idl
  173. IdTargetObserver.cpp
  174. IdTargetObserver.h
  175. IdTargetObserverRegistry.cpp
  176. IdTargetObserverRegistry.h
  177. IgnoreDestructiveWriteCountIncrementer.h
  178. IncrementLoadEventDelayCount.cpp
  179. IncrementLoadEventDelayCount.h
  180. Iterator.h
  181. Iterator.idl
  182. LayoutTreeBuilder.cpp
  183. LayoutTreeBuilder.h
  184. LayoutTreeBuilderTraversal.cpp
  185. LayoutTreeBuilderTraversal.h
  186. LayoutTreeBuilderTraversalTest.cpp
  187. LiveNodeList.cpp
  188. LiveNodeList.h
  189. LiveNodeListBase.cpp
  190. LiveNodeListBase.h
  191. MessageChannel.cpp
  192. MessageChannel.h
  193. MessageChannel.idl
  194. MessagePort.cpp
  195. MessagePort.h
  196. MessagePort.idl
  197. MockScriptElementBase.h
  198. Modulator.cpp
  199. Modulator.h
  200. ModulatorImpl.cpp
  201. ModulatorImpl.h
  202. ModulatorTest.cpp
  203. ModuleMap.cpp
  204. ModuleMap.h
  205. ModuleMapTest.cpp
  206. ModulePendingScript.cpp
  207. ModulePendingScript.h
  208. ModuleScript.cpp
  209. ModuleScript.h
  210. MutationObserver.cpp
  211. MutationObserver.h
  212. MutationObserver.idl
  213. MutationObserverInit.idl
  214. MutationObserverInterestGroup.cpp
  215. MutationObserverInterestGroup.h
  216. MutationObserverRegistration.cpp
  217. MutationObserverRegistration.h
  218. MutationObserverTest.cpp
  219. MutationRecord.cpp
  220. MutationRecord.h
  221. MutationRecord.idl
  222. NamedNodeMap.cpp
  223. NamedNodeMap.h
  224. NamedNodeMap.idl
  225. NameNodeList.cpp
  226. NameNodeList.h
  227. Node.cpp
  228. Node.h
  229. Node.idl
  230. NodeChildRemovalTracker.cpp
  231. NodeChildRemovalTracker.h
  232. NodeComputedStyle.h
  233. NodeFilter.h
  234. NodeFilter.idl
  235. NodeIterator.cpp
  236. NodeIterator.h
  237. NodeIterator.idl
  238. NodeIteratorBase.cpp
  239. NodeIteratorBase.h
  240. NodeList.h
  241. NodeList.idl
  242. NodeListsNodeData.cpp
  243. NodeListsNodeData.h
  244. NodeRareData.cpp
  245. NodeRareData.h
  246. NodeTest.cpp
  247. NodeTraversal.cpp
  248. NodeTraversal.h
  249. NodeTraversalStrategy.h
  250. NodeWithIndex.h
  251. NoncedElement.idl
  252. NonDocumentTypeChildNode.h
  253. NonDocumentTypeChildNode.idl
  254. NonElementParentNode.h
  255. NonElementParentNode.idl
  256. NthIndexCache.cpp
  257. NthIndexCache.h
  258. NthIndexCacheTest.cpp
  259. OWNERS
  260. ParentNode.h
  261. ParentNode.idl
  262. ParserContentPolicy.h
  263. PendingScript.cpp
  264. PendingScript.h
  265. PresentationAttributeStyle.cpp
  266. PresentationAttributeStyle.h
  267. ProcessingInstruction.cpp
  268. ProcessingInstruction.h
  269. ProcessingInstruction.idl
  270. PseudoElement.cpp
  271. PseudoElement.h
  272. PseudoElementData.h
  273. QualifiedName.cpp
  274. QualifiedName.h
  275. Range.cpp
  276. Range.h
  277. Range.idl
  278. RangeBoundaryPoint.h
  279. RangeTest.cpp
  280. RawDataDocumentParser.h
  281. README.md
  282. RemoteSecurityContext.cpp
  283. RemoteSecurityContext.h
  284. SandboxFlags.cpp
  285. SandboxFlags.h
  286. ScopedWindowFocusAllowedIndicator.h
  287. Script.h
  288. ScriptableDocumentParser.cpp
  289. ScriptableDocumentParser.h
  290. ScriptedAnimationController.cpp
  291. ScriptedAnimationController.h
  292. ScriptedAnimationControllerTest.cpp
  293. ScriptedIdleTaskController.cpp
  294. ScriptedIdleTaskController.h
  295. ScriptedIdleTaskControllerTest.cpp
  296. ScriptElementBase.cpp
  297. ScriptElementBase.h
  298. ScriptLoader.cpp
  299. ScriptLoader.h
  300. ScriptModuleResolver.h
  301. ScriptModuleResolverImpl.cpp
  302. ScriptModuleResolverImpl.h
  303. ScriptModuleResolverImplTest.cpp
  304. ScriptRunner.cpp
  305. ScriptRunner.h
  306. ScriptRunnerTest.cpp
  307. SecurityContext.cpp
  308. SecurityContext.h
  309. SelectorQuery.cpp
  310. SelectorQuery.h
  311. SelectorQueryTest.cpp
  312. SelectRuleFeatureSet.cpp
  313. SelectRuleFeatureSet.h
  314. ShadowDOMV0Test.cpp
  315. ShadowRoot.cpp
  316. ShadowRoot.h
  317. ShadowRoot.idl
  318. ShadowRootInit.idl
  319. ShadowRootRareDataV0.h
  320. ShadowTreeStyleSheetCollection.cpp
  321. ShadowTreeStyleSheetCollection.h
  322. SimulatedClickOptions.h
  323. SinkDocument.cpp
  324. SinkDocument.h
  325. SlotAssignment.cpp
  326. SlotAssignment.h
  327. SpaceSplitString.cpp
  328. SpaceSplitString.h
  329. SpaceSplitStringTest.cpp
  330. StaticNodeList.h
  331. StaticRange.cpp
  332. StaticRange.h
  333. StaticRange.idl
  334. StaticRangeTest.cpp
  335. StyleChangeReason.cpp
  336. StyleChangeReason.h
  337. StyleElement.cpp
  338. StyleElement.h
  339. StyleElementTest.cpp
  340. StyleEngine.cpp
  341. StyleEngine.h
  342. StyleEngineContext.cpp
  343. StyleEngineContext.h
  344. StyleEngineTest.cpp
  345. stylerecalc.md
  346. StyleSheetCandidate.cpp
  347. StyleSheetCandidate.h
  348. StyleSheetCollection.cpp
  349. StyleSheetCollection.h
  350. SuspendableObject.cpp
  351. SuspendableObject.h
  352. SuspendableObjectTest.cpp
  353. SynchronousMutationNotifier.cpp
  354. SynchronousMutationNotifier.h
  355. SynchronousMutationObserver.cpp
  356. SynchronousMutationObserver.h
  357. SyncReattachContext.cpp
  358. SyncReattachContext.h
  359. TagCollection.cpp
  360. TagCollection.h
  361. TaskRunnerHelper.cpp
  362. TaskRunnerHelper.h
  363. TemplateContentDocumentFragment.h
  364. Text.cpp
  365. Text.h
  366. Text.idl
  367. TextLinkColors.cpp
  368. TextLinkColors.h
  369. TextTest.cpp
  370. ThrowOnDynamicMarkupInsertionCountIncrementer.h
  371. Touch.cpp
  372. Touch.h
  373. Touch.idl
  374. TouchInit.idl
  375. TouchList.cpp
  376. TouchList.h
  377. TouchList.idl
  378. TransformSource.h
  379. TransformSourceLibxslt.cpp
  380. TreeOrderedList.cpp
  381. TreeOrderedList.h
  382. TreeOrderedMap.cpp
  383. TreeOrderedMap.h
  384. TreeScope.cpp
  385. TreeScope.h
  386. TreeScopeAdopter.cpp
  387. TreeScopeAdopter.h
  388. TreeScopeStyleSheetCollection.cpp
  389. TreeScopeStyleSheetCollection.h
  390. TreeScopeTest.cpp
  391. TreeWalker.cpp
  392. TreeWalker.h
  393. TreeWalker.idl
  394. UserActionElementSet.cpp
  395. UserActionElementSet.h
  396. UserGestureIndicator.cpp
  397. UserGestureIndicator.h
  398. UserGestureIndicatorTest.cpp
  399. V0InsertionPoint.cpp
  400. V0InsertionPoint.h
  401. ViewportDescription.cpp
  402. ViewportDescription.h
  403. VisitedLinkState.cpp
  404. VisitedLinkState.h
  405. WeakIdentifierMap.h
  406. WhitespaceAttacher.cpp
  407. WhitespaceAttacher.h
  408. WhitespaceAttacherTest.cpp
  409. WhitespaceLayoutObjects.md
  410. XMLDocument.cpp
  411. XMLDocument.h
  412. XMLDocument.idl
third_party/WebKit/Source/core/dom/README.md

DOM

Rendered

The Source/core/dom directory contains the implementation of DOM.

Basically, this directory should contain only a file which is related to DOM Standard. However, for historical reasons, Source/core/dom directory has been used as if it were misc directory. As a result, unfortunately, this directory contains a lot of files which are not directly related to DOM.

Please don‘t add unrelated files to this directory any more. We are trying to organize the files so that developers wouldn’t get confused at seeing this directory.

  • See the spreadsheet, as a rough plan to organize Source/core/dom files.

    The classification in the spreadsheet might be wrong. Please update the spreadsheet, and move files if you can, if you know more appropriate places for each file.

  • See crbug.com/738794 for tracking our efforts.

Node and DOM Tree

In this README, we draw a tree in left-to-right direction. A is the root of the tree.

A
├───B
├───C
   ├───D
   └───E
└───F

Node is a base class of all kinds of nodes in DOM tree. Each Node has following 3 pointers (but not limited to):

  • parent_or_shadow_host_node_: Points to the parent (or the shadow host if it is a shadow root; explained later)
  • previous_: Points to the previous sibling
  • next_: Points to the next sibling

ContainerNode, from which Element extends, has additional pointers for its child:

  • first_child_: The meaning is obvious.
  • last_child_: Nit.

That means:

  • Siblings are stored as a linked list. It takes O(N) to access a parent's n-th child.
  • Parent can't tell how many children it has in O(1).

Further info:

  • Node, ContainerNode

C++11 range-based for loops for traversing a tree

You can traverse a tree manually:

// Traverse a children.
for (Node* child = parent.firstChild(); child; child = child->nextSibling()) {
  ...
}
// Traverse nodes in tree order, depth-first traversal.
void foo(const Node& node) {
  ...
  for (Node* child = node.firstChild(); child; child = child->nextSibling()) {
    foo(*child);  // Recursively
  }
}

However, traversing a tree in this way might be error-prone. Instead, you can use NodeTraversal and ElementTraversal. They provides a C++11's range-based for loops, such as:

for (Node& child : NodeTraversal::childrenOf(parent) {
  ...
}

e.g. Given a parent A, this traverses B, C, and F in this order.

for (Node& node : NodeTraversal::startsAt(root)) {
  ...
}

e.g. Given the root A, this traverses A, B, C, D, E, and F in this order.

There are several other useful range-based for loops for each purpose. The cost of using range-based for loops is zero because everything can be inlined.

Further info:

  • NodeTraversal and ElementTraversal (more type-safe version)
  • The CL, which introduced these range-based for loops.

Shadow Tree

TODO(hayato): Explain.

TreeScope

TODO(hayato): Explain.

Composed Tree (a tree of DOM trees)

TODO(hayato): Explain.

Layout Tree

TODO(hayato): Explain.

Flat tree and FlatTreeTraversal

TODO(hayato): Explain.

Distribution and slots

TODO(hayato): Explain.

DOM mutations

TODO(hayato): Explain.

Related flags

TODO(hayato): Explain.

Event path and Event Retargeting

TODO(hayato): Explain.