Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(751)

Side by Side Diff: Source/core/dom/TreeScope.cpp

Issue 1134173002: Get rid of TreeBoundaryCrossingRules. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Missing important UA rules. Created 5 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « Source/core/dom/TreeScope.h ('k') | Source/core/dom/shadow/ShadowRoot.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2011 Google Inc. All Rights Reserved. 2 * Copyright (C) 2011 Google Inc. All Rights Reserved.
3 * Copyright (C) 2012 Apple Inc. All rights reserved. 3 * Copyright (C) 2012 Apple Inc. All rights reserved.
4 * 4 *
5 * Redistribution and use in source and binary forms, with or without 5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions 6 * modification, are permitted provided that the following conditions
7 * are met: 7 * are met:
8 * 1. Redistributions of source code must retain the above copyright 8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright 10 * 2. Redistributions in binary form must reproduce the above copyright
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
53 #include "wtf/Vector.h" 53 #include "wtf/Vector.h"
54 54
55 namespace blink { 55 namespace blink {
56 56
57 using namespace HTMLNames; 57 using namespace HTMLNames;
58 58
59 TreeScope::TreeScope(ContainerNode& rootNode, Document& document) 59 TreeScope::TreeScope(ContainerNode& rootNode, Document& document)
60 : m_rootNode(&rootNode) 60 : m_rootNode(&rootNode)
61 , m_document(&document) 61 , m_document(&document)
62 , m_parentTreeScope(&document) 62 , m_parentTreeScope(&document)
63 , m_composedParent(nullptr)
63 #if !ENABLE(OILPAN) 64 #if !ENABLE(OILPAN)
64 , m_guardRefCount(0) 65 , m_guardRefCount(0)
65 #endif 66 #endif
66 , m_idTargetObserverRegistry(IdTargetObserverRegistry::create()) 67 , m_idTargetObserverRegistry(IdTargetObserverRegistry::create())
67 { 68 {
68 ASSERT(rootNode != document); 69 ASSERT(rootNode != document);
69 #if !ENABLE(OILPAN) 70 #if !ENABLE(OILPAN)
70 m_parentTreeScope->guardRef(); 71 m_parentTreeScope->guardRef();
71 #endif 72 #endif
72 m_rootNode->setTreeScope(this); 73 m_rootNode->setTreeScope(this);
(...skipping 488 matching lines...) Expand 10 before | Expand all | Expand 10 after
561 { 562 {
562 for (Element* element = ElementTraversal::firstWithin(rootNode()); element; element = ElementTraversal::nextIncludingPseudo(*element)) { 563 for (Element* element = ElementTraversal::firstWithin(rootNode()); element; element = ElementTraversal::nextIncludingPseudo(*element)) {
563 for (ShadowRoot* root = element->youngestShadowRoot(); root; root = root ->olderShadowRoot()) 564 for (ShadowRoot* root = element->youngestShadowRoot(); root; root = root ->olderShadowRoot())
564 root->setNeedsStyleRecalcForViewportUnits(); 565 root->setNeedsStyleRecalcForViewportUnits();
565 const ComputedStyle* style = element->computedStyle(); 566 const ComputedStyle* style = element->computedStyle();
566 if (style && style->hasViewportUnits()) 567 if (style && style->hasViewportUnits())
567 element->setNeedsStyleRecalc(LocalStyleChange, StyleChangeReasonForT racing::create(StyleChangeReason::ViewportUnits)); 568 element->setNeedsStyleRecalc(LocalStyleChange, StyleChangeReasonForT racing::create(StyleChangeReason::ViewportUnits));
568 } 569 }
569 } 570 }
570 571
572 TreeScope* TreeScope::composedParent()
573 {
574 if (rootNode().isDocumentNode())
575 return nullptr;
576 if (!m_composedParent) {
577 ShadowRoot& root = toShadowRoot(rootNode());
578 if (root.olderShadowRoot())
579 m_composedParent = root.olderShadowRoot();
580 else if (ContainerNode* host = rootNode().parentOrShadowHostNode())
581 m_composedParent = treeScopeInComposedTree(*host);
582 }
583 return m_composedParent;
584 }
585
586 TreeScope* TreeScope::treeScopeInComposedTree(const Node& node)
587 {
588 for (Node* composedParent = ComposedTreeTraversal::parent(node); composedPar ent; composedParent = ComposedTreeTraversal::parent(*composedParent)) {
589 if (composedParent && isShadowHost(composedParent))
590 return toElement(composedParent)->shadow()->youngestShadowRoot();
591 }
592 return &node.document();
593 }
594
571 DEFINE_TRACE(TreeScope) 595 DEFINE_TRACE(TreeScope)
572 { 596 {
573 visitor->trace(m_rootNode); 597 visitor->trace(m_rootNode);
574 visitor->trace(m_document); 598 visitor->trace(m_document);
575 visitor->trace(m_parentTreeScope); 599 visitor->trace(m_parentTreeScope);
600 visitor->trace(m_composedParent);
576 visitor->trace(m_idTargetObserverRegistry); 601 visitor->trace(m_idTargetObserverRegistry);
577 visitor->trace(m_selection); 602 visitor->trace(m_selection);
578 visitor->trace(m_elementsById); 603 visitor->trace(m_elementsById);
579 visitor->trace(m_imageMapsByName); 604 visitor->trace(m_imageMapsByName);
580 visitor->trace(m_labelsByForAttribute); 605 visitor->trace(m_labelsByForAttribute);
581 visitor->trace(m_scopedStyleResolver); 606 visitor->trace(m_scopedStyleResolver);
582 } 607 }
583 608
584 } // namespace blink 609 } // namespace blink
OLDNEW
« no previous file with comments | « Source/core/dom/TreeScope.h ('k') | Source/core/dom/shadow/ShadowRoot.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698