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

Side by Side Diff: Source/core/dom/shadow/ElementShadow.cpp

Issue 24430002: Rename attach and detach to createRenderTree/destroyRenderTree (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 7 years, 2 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 | Annotate | Revision Log
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2012 Google Inc. All rights reserved. 2 * Copyright (C) 2012 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * 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 * * Neither the name of Google Inc. nor the names of its 10 * * Neither the name of Google Inc. nor the names of its
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
57 57
58 ShadowRoot* ElementShadow::addShadowRoot(Element* shadowHost, ShadowRoot::Shadow RootType type) 58 ShadowRoot* ElementShadow::addShadowRoot(Element* shadowHost, ShadowRoot::Shadow RootType type)
59 { 59 {
60 RefPtr<ShadowRoot> shadowRoot = ShadowRoot::create(&shadowHost->document(), type); 60 RefPtr<ShadowRoot> shadowRoot = ShadowRoot::create(&shadowHost->document(), type);
61 61
62 shadowRoot->setParentOrShadowHostNode(shadowHost); 62 shadowRoot->setParentOrShadowHostNode(shadowHost);
63 shadowRoot->setParentTreeScope(&shadowHost->treeScope()); 63 shadowRoot->setParentTreeScope(&shadowHost->treeScope());
64 m_shadowRoots.push(shadowRoot.get()); 64 m_shadowRoots.push(shadowRoot.get());
65 ChildNodeInsertionNotifier(shadowHost).notify(shadowRoot.get()); 65 ChildNodeInsertionNotifier(shadowHost).notify(shadowRoot.get());
66 setNeedsDistributionRecalc(); 66 setNeedsDistributionRecalc();
67 shadowHost->lazyReattachIfAttached(); 67 shadowHost->scheduleRenderTreeRecreationIfAttached();
68 68
69 // addShadowRoot() affects apply-author-styles. However, we know that the yo ungest shadow root has not had any children yet. 69 // addShadowRoot() affects apply-author-styles. However, we know that the yo ungest shadow root has not had any children yet.
70 // The youngest shadow root's apply-author-styles is default (false). So we can just set m_applyAuthorStyles false. 70 // The youngest shadow root's apply-author-styles is default (false). So we can just set m_applyAuthorStyles false.
71 m_applyAuthorStyles = false; 71 m_applyAuthorStyles = false;
72 72
73 shadowHost->didAddShadowRoot(*shadowRoot); 73 shadowHost->didAddShadowRoot(*shadowRoot);
74 InspectorInstrumentation::didPushShadowRoot(shadowHost, shadowRoot.get()); 74 InspectorInstrumentation::didPushShadowRoot(shadowHost, shadowRoot.get());
75 75
76 return shadowRoot.get(); 76 return shadowRoot.get();
77 } 77 }
78 78
79 void ElementShadow::removeAllShadowRoots() 79 void ElementShadow::removeAllShadowRoots()
80 { 80 {
81 // Dont protect this ref count. 81 // Dont protect this ref count.
82 Element* shadowHost = host(); 82 Element* shadowHost = host();
83 83
84 while (RefPtr<ShadowRoot> oldRoot = m_shadowRoots.head()) { 84 while (RefPtr<ShadowRoot> oldRoot = m_shadowRoots.head()) {
85 InspectorInstrumentation::willPopShadowRoot(shadowHost, oldRoot.get()); 85 InspectorInstrumentation::willPopShadowRoot(shadowHost, oldRoot.get());
86 shadowHost->document().removeFocusedElementOfSubtree(oldRoot.get()); 86 shadowHost->document().removeFocusedElementOfSubtree(oldRoot.get());
87 87
88 if (oldRoot->attached()) 88 if (oldRoot->attached())
89 oldRoot->detach(); 89 oldRoot->destroyRenderTree();
90 90
91 m_shadowRoots.removeHead(); 91 m_shadowRoots.removeHead();
92 oldRoot->setParentOrShadowHostNode(0); 92 oldRoot->setParentOrShadowHostNode(0);
93 oldRoot->setParentTreeScope(&shadowHost->document()); 93 oldRoot->setParentTreeScope(&shadowHost->document());
94 oldRoot->setPrev(0); 94 oldRoot->setPrev(0);
95 oldRoot->setNext(0); 95 oldRoot->setNext(0);
96 ChildNodeRemovalNotifier(shadowHost).notify(oldRoot.get()); 96 ChildNodeRemovalNotifier(shadowHost).notify(oldRoot.get());
97 } 97 }
98 } 98 }
99 99
100 void ElementShadow::attach(const Node::AttachContext& context) 100 void ElementShadow::createRenderTree(const Node::AttachContext& context)
101 { 101 {
102 Node::AttachContext childrenContext(context); 102 Node::AttachContext childrenContext(context);
103 childrenContext.resolvedStyle = 0; 103 childrenContext.resolvedStyle = 0;
104 104
105 for (ShadowRoot* root = youngestShadowRoot(); root; root = root->olderShadow Root()) { 105 for (ShadowRoot* root = youngestShadowRoot(); root; root = root->olderShadow Root()) {
106 if (!root->attached()) 106 if (!root->attached())
107 root->attach(childrenContext); 107 root->createRenderTree(childrenContext);
108 } 108 }
109 } 109 }
110 110
111 void ElementShadow::detach(const Node::AttachContext& context) 111 void ElementShadow::destroyRenderTree(const Node::AttachContext& context)
112 { 112 {
113 Node::AttachContext childrenContext(context); 113 Node::AttachContext childrenContext(context);
114 childrenContext.resolvedStyle = 0; 114 childrenContext.resolvedStyle = 0;
115 115
116 for (ShadowRoot* root = youngestShadowRoot(); root; root = root->olderShadow Root()) { 116 for (ShadowRoot* root = youngestShadowRoot(); root; root = root->olderShadow Root()) {
117 if (root->attached()) 117 if (root->attached())
118 root->detach(childrenContext); 118 root->destroyRenderTree(childrenContext);
119 } 119 }
120 } 120 }
121 121
122 void ElementShadow::removeAllEventListeners() 122 void ElementShadow::removeAllEventListeners()
123 { 123 {
124 for (ShadowRoot* root = youngestShadowRoot(); root; root = root->olderShadow Root()) { 124 for (ShadowRoot* root = youngestShadowRoot(); root; root = root->olderShadow Root()) {
125 for (Node* node = root; node; node = NodeTraversal::next(node)) 125 for (Node* node = root; node; node = NodeTraversal::next(node))
126 node->removeAllEventListeners(); 126 node->removeAllEventListeners();
127 } 127 }
128 } 128 }
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
244 } 244 }
245 if (ElementShadow* shadow = shadowOfParentForDistribution(shadowElement) ) 245 if (ElementShadow* shadow = shadowOfParentForDistribution(shadowElement) )
246 shadow->setNeedsDistributionRecalc(); 246 shadow->setNeedsDistributionRecalc();
247 } 247 }
248 248
249 // Detach all nodes that were not distributed and have a renderer. 249 // Detach all nodes that were not distributed and have a renderer.
250 for (size_t i = 0; i < pool.size(); ++i) { 250 for (size_t i = 0; i < pool.size(); ++i) {
251 if (distributed[i]) 251 if (distributed[i])
252 continue; 252 continue;
253 if (pool[i]->renderer()) 253 if (pool[i]->renderer())
254 pool[i]->lazyReattachIfAttached(); 254 pool[i]->scheduleRenderTreeRecreationIfAttached();
255 } 255 }
256 } 256 }
257 257
258 void ElementShadow::distributeSelectionsTo(InsertionPoint* insertionPoint, const Vector<Node*>& pool, Vector<bool>& distributed) 258 void ElementShadow::distributeSelectionsTo(InsertionPoint* insertionPoint, const Vector<Node*>& pool, Vector<bool>& distributed)
259 { 259 {
260 ContentDistribution distribution; 260 ContentDistribution distribution;
261 261
262 for (size_t i = 0; i < pool.size(); ++i) { 262 for (size_t i = 0; i < pool.size(); ++i) {
263 if (distributed[i]) 263 if (distributed[i])
264 continue; 264 continue;
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
350 350
351 void ElementShadow::clearDistribution() 351 void ElementShadow::clearDistribution()
352 { 352 {
353 m_nodeToInsertionPoint.clear(); 353 m_nodeToInsertionPoint.clear();
354 354
355 for (ShadowRoot* root = youngestShadowRoot(); root; root = root->olderShadow Root()) 355 for (ShadowRoot* root = youngestShadowRoot(); root; root = root->olderShadow Root())
356 root->setInsertionPoint(0); 356 root->setInsertionPoint(0);
357 } 357 }
358 358
359 } // namespace 359 } // namespace
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698