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

Side by Side Diff: sky/engine/core/dom/TreeScope.cpp

Issue 759663003: Only allow one shadowRoot. (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: ojan review. Created 6 years 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 | « sky/engine/core/dom/TreeScope.h ('k') | sky/engine/core/dom/TreeScopeAdopter.cpp » ('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 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
85 if (m_selection) { 85 if (m_selection) {
86 m_selection->clearTreeScope(); 86 m_selection->clearTreeScope();
87 m_selection = nullptr; 87 m_selection = nullptr;
88 } 88 }
89 89
90 if (m_parentTreeScope) 90 if (m_parentTreeScope)
91 m_parentTreeScope->guardDeref(); 91 m_parentTreeScope->guardDeref();
92 #endif 92 #endif
93 } 93 }
94 94
95 TreeScope* TreeScope::olderShadowRootOrParentTreeScope() const
96 {
97 if (rootNode().isShadowRoot()) {
98 if (ShadowRoot* olderShadowRoot = toShadowRoot(rootNode()).olderShadowRo ot())
99 return olderShadowRoot;
100 }
101 return parentTreeScope();
102 }
103
104 bool TreeScope::isInclusiveOlderSiblingShadowRootOrAncestorTreeScopeOf(const Tre eScope& scope) const 95 bool TreeScope::isInclusiveOlderSiblingShadowRootOrAncestorTreeScopeOf(const Tre eScope& scope) const
105 { 96 {
106 for (const TreeScope* current = &scope; current; current = current->olderSha dowRootOrParentTreeScope()) { 97 for (const TreeScope* current = &scope; current; current = current->parentTr eeScope()) {
107 if (current == this) 98 if (current == this)
108 return true; 99 return true;
109 } 100 }
110 return false; 101 return false;
111 } 102 }
112 103
113 bool TreeScope::rootNodeHasTreeSharedParent() const 104 bool TreeScope::rootNodeHasTreeSharedParent() const
114 { 105 {
115 return rootNode().hasTreeSharedParent(); 106 return rootNode().hasTreeSharedParent();
116 } 107 }
(...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after
296 287
297 for (unsigned i = std::min(index1, index2); i; --i) { 288 for (unsigned i = std::min(index1, index2); i; --i) {
298 const TreeScope* child1 = chain1[--index1]; 289 const TreeScope* child1 = chain1[--index1];
299 const TreeScope* child2 = chain2[--index2]; 290 const TreeScope* child2 = chain2[--index2];
300 if (child1 != child2) { 291 if (child1 != child2) {
301 Node* shadowHost1 = child1->rootNode().parentOrShadowHostNode(); 292 Node* shadowHost1 = child1->rootNode().parentOrShadowHostNode();
302 Node* shadowHost2 = child2->rootNode().parentOrShadowHostNode(); 293 Node* shadowHost2 = child2->rootNode().parentOrShadowHostNode();
303 if (shadowHost1 != shadowHost2) 294 if (shadowHost1 != shadowHost2)
304 return shadowHost1->compareDocumentPosition(shadowHost2, Node::T reatShadowTreesAsDisconnected); 295 return shadowHost1->compareDocumentPosition(shadowHost2, Node::T reatShadowTreesAsDisconnected);
305 296
306 for (const ShadowRoot* child = toShadowRoot(child2->rootNode()).olde rShadowRoot(); child; child = child->olderShadowRoot())
307 if (child == child1)
308 return Node::DOCUMENT_POSITION_FOLLOWING;
309
310 return Node::DOCUMENT_POSITION_PRECEDING; 297 return Node::DOCUMENT_POSITION_PRECEDING;
311 } 298 }
312 } 299 }
313 300
314 // There was no difference between the two parent chains, i.e., one was a su bset of the other. The shorter 301 // There was no difference between the two parent chains, i.e., one was a su bset of the other. The shorter
315 // chain is the ancestor. 302 // chain is the ancestor.
316 return index1 < index2 ? 303 return index1 < index2 ?
317 Node::DOCUMENT_POSITION_FOLLOWING | Node::DOCUMENT_POSITION_CONTAINED_BY : 304 Node::DOCUMENT_POSITION_FOLLOWING | Node::DOCUMENT_POSITION_CONTAINED_BY :
318 Node::DOCUMENT_POSITION_PRECEDING | Node::DOCUMENT_POSITION_CONTAINS; 305 Node::DOCUMENT_POSITION_PRECEDING | Node::DOCUMENT_POSITION_CONTAINS;
319 } 306 }
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
407 394
408 Element* TreeScope::getElementByAccessKey(const String& key) const 395 Element* TreeScope::getElementByAccessKey(const String& key) const
409 { 396 {
410 if (key.isEmpty()) 397 if (key.isEmpty())
411 return 0; 398 return 0;
412 Element* result = 0; 399 Element* result = 0;
413 Node& root = rootNode(); 400 Node& root = rootNode();
414 for (Element* element = ElementTraversal::firstWithin(root); element; elemen t = ElementTraversal::next(*element, &root)) { 401 for (Element* element = ElementTraversal::firstWithin(root); element; elemen t = ElementTraversal::next(*element, &root)) {
415 if (equalIgnoringCase(element->getAttribute(HTMLNames::accesskeyAttr), k ey)) 402 if (equalIgnoringCase(element->getAttribute(HTMLNames::accesskeyAttr), k ey))
416 result = element; 403 result = element;
417 for (ShadowRoot* shadowRoot = element->youngestShadowRoot(); shadowRoot; shadowRoot = shadowRoot->olderShadowRoot()) { 404 if (ShadowRoot* shadowRoot = element->shadowRoot()) {
418 if (Element* shadowResult = shadowRoot->getElementByAccessKey(key)) 405 if (Element* shadowResult = shadowRoot->getElementByAccessKey(key))
419 result = shadowResult; 406 result = shadowResult;
420 } 407 }
421 } 408 }
422 return result; 409 return result;
423 } 410 }
424 411
425 void TreeScope::setNeedsStyleRecalcForViewportUnits() 412 void TreeScope::setNeedsStyleRecalcForViewportUnits()
426 { 413 {
427 for (Element* element = ElementTraversal::firstWithin(rootNode()); element; element = ElementTraversal::next(*element)) { 414 for (Element* element = ElementTraversal::firstWithin(rootNode()); element; element = ElementTraversal::next(*element)) {
428 for (ShadowRoot* root = element->youngestShadowRoot(); root; root = root ->olderShadowRoot()) 415 if (ShadowRoot* root = element->shadowRoot())
429 root->setNeedsStyleRecalcForViewportUnits(); 416 root->setNeedsStyleRecalcForViewportUnits();
430 RenderStyle* style = element->renderStyle(); 417 RenderStyle* style = element->renderStyle();
431 if (style && style->hasViewportUnits()) 418 if (style && style->hasViewportUnits())
432 element->setNeedsStyleRecalc(LocalStyleChange); 419 element->setNeedsStyleRecalc(LocalStyleChange);
433 } 420 }
434 } 421 }
435 422
436 } // namespace blink 423 } // namespace blink
OLDNEW
« no previous file with comments | « sky/engine/core/dom/TreeScope.h ('k') | sky/engine/core/dom/TreeScopeAdopter.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698