OLD | NEW |
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 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
50 { | 50 { |
51 } | 51 } |
52 | 52 |
53 ElementShadow::~ElementShadow() | 53 ElementShadow::~ElementShadow() |
54 { | 54 { |
55 removeAllShadowRoots(); | 55 removeAllShadowRoots(); |
56 } | 56 } |
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(), t
ype); | 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->lazyReattachIfAttached(); |
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 InspectorInstrumentation::didPushShadowRoot(shadowHost, shadowRoot.get()); | 73 InspectorInstrumentation::didPushShadowRoot(shadowHost, shadowRoot.get()); |
74 | 74 |
75 return shadowRoot.get(); | 75 return shadowRoot.get(); |
76 } | 76 } |
77 | 77 |
78 void ElementShadow::removeAllShadowRoots() | 78 void ElementShadow::removeAllShadowRoots() |
79 { | 79 { |
80 // Dont protect this ref count. | 80 // Dont protect this ref count. |
81 Element* shadowHost = host(); | 81 Element* shadowHost = host(); |
82 | 82 |
83 while (RefPtr<ShadowRoot> oldRoot = m_shadowRoots.head()) { | 83 while (RefPtr<ShadowRoot> oldRoot = m_shadowRoots.head()) { |
84 InspectorInstrumentation::willPopShadowRoot(shadowHost, oldRoot.get()); | 84 InspectorInstrumentation::willPopShadowRoot(shadowHost, oldRoot.get()); |
85 shadowHost->document()->removeFocusedElementOfSubtree(oldRoot.get()); | 85 shadowHost->document().removeFocusedElementOfSubtree(oldRoot.get()); |
86 | 86 |
87 if (oldRoot->attached()) | 87 if (oldRoot->attached()) |
88 oldRoot->detach(); | 88 oldRoot->detach(); |
89 | 89 |
90 m_shadowRoots.removeHead(); | 90 m_shadowRoots.removeHead(); |
91 oldRoot->setParentOrShadowHostNode(0); | 91 oldRoot->setParentOrShadowHostNode(0); |
92 oldRoot->setParentTreeScope(shadowHost->document()); | 92 oldRoot->setParentTreeScope(&shadowHost->document()); |
93 oldRoot->setPrev(0); | 93 oldRoot->setPrev(0); |
94 oldRoot->setNext(0); | 94 oldRoot->setNext(0); |
95 ChildNodeRemovalNotifier(shadowHost).notify(oldRoot.get()); | 95 ChildNodeRemovalNotifier(shadowHost).notify(oldRoot.get()); |
96 } | 96 } |
97 } | 97 } |
98 | 98 |
99 void ElementShadow::attach(const Node::AttachContext& context) | 99 void ElementShadow::attach(const Node::AttachContext& context) |
100 { | 100 { |
101 Node::AttachContext childrenContext(context); | 101 Node::AttachContext childrenContext(context); |
102 childrenContext.resolvedStyle = 0; | 102 childrenContext.resolvedStyle = 0; |
(...skipping 244 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
347 | 347 |
348 void ElementShadow::clearDistribution() | 348 void ElementShadow::clearDistribution() |
349 { | 349 { |
350 m_nodeToInsertionPoint.clear(); | 350 m_nodeToInsertionPoint.clear(); |
351 | 351 |
352 for (ShadowRoot* root = youngestShadowRoot(); root; root = root->olderShadow
Root()) | 352 for (ShadowRoot* root = youngestShadowRoot(); root; root = root->olderShadow
Root()) |
353 root->setInsertionPoint(0); | 353 root->setInsertionPoint(0); |
354 } | 354 } |
355 | 355 |
356 } // namespace | 356 } // namespace |
OLD | NEW |