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

Side by Side Diff: third_party/WebKit/Source/core/dom/StyleElement.cpp

Issue 2149893003: Rename Node::inShadowIncludingDocument() to Node::isConnected() (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: addressed Created 4 years, 5 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
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2006, 2007 Rob Buis 2 * Copyright (C) 2006, 2007 Rob Buis
3 * Copyright (C) 2008 Apple, Inc. All rights reserved. 3 * Copyright (C) 2008 Apple, Inc. All rights reserved.
4 * 4 *
5 * This library is free software; you can redistribute it and/or 5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Library General Public 6 * modify it under the terms of the GNU Library General Public
7 * License as published by the Free Software Foundation; either 7 * License as published by the Free Software Foundation; either
8 * version 2 of the License, or (at your option) any later version. 8 * version 2 of the License, or (at your option) any later version.
9 * 9 *
10 * This library is distributed in the hope that it will be useful, 10 * This library is distributed in the hope that it will be useful,
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
54 } 54 }
55 55
56 StyleElement::~StyleElement() 56 StyleElement::~StyleElement()
57 { 57 {
58 } 58 }
59 59
60 StyleElement::ProcessingResult StyleElement::processStyleSheet(Document& documen t, Element* element) 60 StyleElement::ProcessingResult StyleElement::processStyleSheet(Document& documen t, Element* element)
61 { 61 {
62 TRACE_EVENT0("blink", "StyleElement::processStyleSheet"); 62 TRACE_EVENT0("blink", "StyleElement::processStyleSheet");
63 DCHECK(element); 63 DCHECK(element);
64 DCHECK(element->inShadowIncludingDocument()); 64 DCHECK(element->isConnected());
65 65
66 m_registeredAsCandidate = true; 66 m_registeredAsCandidate = true;
67 document.styleEngine().addStyleSheetCandidateNode(element); 67 document.styleEngine().addStyleSheetCandidateNode(element);
68 if (m_createdByParser) 68 if (m_createdByParser)
69 return ProcessingSuccessful; 69 return ProcessingSuccessful;
70 70
71 return process(element); 71 return process(element);
72 } 72 }
73 73
74 void StyleElement::insertedInto(Element* element, ContainerNode* insertionPoint) 74 void StyleElement::insertedInto(Element* element, ContainerNode* insertionPoint)
75 { 75 {
76 if (!insertionPoint->inShadowIncludingDocument() || !element->isInShadowTree ()) 76 if (!insertionPoint->isConnected() || !element->isInShadowTree())
77 return; 77 return;
78 if (ShadowRoot* scope = element->containingShadowRoot()) 78 if (ShadowRoot* scope = element->containingShadowRoot())
79 scope->registerScopedHTMLStyleChild(); 79 scope->registerScopedHTMLStyleChild();
80 } 80 }
81 81
82 void StyleElement::removedFrom(Element* element, ContainerNode* insertionPoint) 82 void StyleElement::removedFrom(Element* element, ContainerNode* insertionPoint)
83 { 83 {
84 if (!insertionPoint->inShadowIncludingDocument()) 84 if (!insertionPoint->isConnected())
85 return; 85 return;
86 86
87 ShadowRoot* shadowRoot = element->containingShadowRoot(); 87 ShadowRoot* shadowRoot = element->containingShadowRoot();
88 if (!shadowRoot) 88 if (!shadowRoot)
89 shadowRoot = insertionPoint->containingShadowRoot(); 89 shadowRoot = insertionPoint->containingShadowRoot();
90 90
91 if (shadowRoot) 91 if (shadowRoot)
92 shadowRoot->unregisterScopedHTMLStyleChild(); 92 shadowRoot->unregisterScopedHTMLStyleChild();
93 93
94 Document& document = element->document(); 94 Document& document = element->document();
95 if (m_registeredAsCandidate) { 95 if (m_registeredAsCandidate) {
96 document.styleEngine().removeStyleSheetCandidateNode(element, shadowRoot ? *toTreeScope(shadowRoot) : toTreeScope(document)); 96 document.styleEngine().removeStyleSheetCandidateNode(element, shadowRoot ? *toTreeScope(shadowRoot) : toTreeScope(document));
97 m_registeredAsCandidate = false; 97 m_registeredAsCandidate = false;
98 } 98 }
99 99
100 StyleSheet* removedSheet = m_sheet.get(); 100 StyleSheet* removedSheet = m_sheet.get();
101 101
102 if (m_sheet) 102 if (m_sheet)
103 clearSheet(element); 103 clearSheet(element);
104 if (removedSheet) 104 if (removedSheet)
105 document.styleEngine().setNeedsActiveStyleUpdate(removedSheet, AnalyzedS tyleUpdate); 105 document.styleEngine().setNeedsActiveStyleUpdate(removedSheet, AnalyzedS tyleUpdate);
106 } 106 }
107 107
108 void StyleElement::clearDocumentData(Document& document, Element* element) 108 void StyleElement::clearDocumentData(Document& document, Element* element)
109 { 109 {
110 if (m_sheet) 110 if (m_sheet)
111 m_sheet->clearOwnerNode(); 111 m_sheet->clearOwnerNode();
112 112
113 if (m_registeredAsCandidate) { 113 if (m_registeredAsCandidate) {
114 DCHECK(element->inShadowIncludingDocument()); 114 DCHECK(element->isConnected());
115 document.styleEngine().removeStyleSheetCandidateNode(element, element->t reeScope()); 115 document.styleEngine().removeStyleSheetCandidateNode(element, element->t reeScope());
116 m_registeredAsCandidate = false; 116 m_registeredAsCandidate = false;
117 } 117 }
118 } 118 }
119 119
120 StyleElement::ProcessingResult StyleElement::childrenChanged(Element* element) 120 StyleElement::ProcessingResult StyleElement::childrenChanged(Element* element)
121 { 121 {
122 DCHECK(element); 122 DCHECK(element);
123 if (m_createdByParser) 123 if (m_createdByParser)
124 return ProcessingSuccessful; 124 return ProcessingSuccessful;
125 125
126 return process(element); 126 return process(element);
127 } 127 }
128 128
129 StyleElement::ProcessingResult StyleElement::finishParsingChildren(Element* elem ent) 129 StyleElement::ProcessingResult StyleElement::finishParsingChildren(Element* elem ent)
130 { 130 {
131 DCHECK(element); 131 DCHECK(element);
132 ProcessingResult result = process(element); 132 ProcessingResult result = process(element);
133 m_createdByParser = false; 133 m_createdByParser = false;
134 return result; 134 return result;
135 } 135 }
136 136
137 StyleElement::ProcessingResult StyleElement::process(Element* element) 137 StyleElement::ProcessingResult StyleElement::process(Element* element)
138 { 138 {
139 if (!element || !element->inShadowIncludingDocument()) 139 if (!element || !element->isConnected())
140 return ProcessingSuccessful; 140 return ProcessingSuccessful;
141 return createSheet(element, element->textFromChildren()); 141 return createSheet(element, element->textFromChildren());
142 } 142 }
143 143
144 void StyleElement::clearSheet(Element* ownerElement) 144 void StyleElement::clearSheet(Element* ownerElement)
145 { 145 {
146 DCHECK(m_sheet); 146 DCHECK(m_sheet);
147 147
148 if (ownerElement && m_sheet->isLoading()) 148 if (ownerElement && m_sheet->isLoading())
149 ownerElement->document().styleEngine().removePendingSheet(ownerElement, m_styleEngineContext); 149 ownerElement->document().styleEngine().removePendingSheet(ownerElement, m_styleEngineContext);
(...skipping 12 matching lines...) Expand all
162 ShadowRoot* root = element->containingShadowRoot(); 162 ShadowRoot* root = element->containingShadowRoot();
163 if (root && root->type() == ShadowRootType::UserAgent) 163 if (root && root->type() == ShadowRootType::UserAgent)
164 return true; 164 return true;
165 165
166 return false; 166 return false;
167 } 167 }
168 168
169 StyleElement::ProcessingResult StyleElement::createSheet(Element* e, const Strin g& text) 169 StyleElement::ProcessingResult StyleElement::createSheet(Element* e, const Strin g& text)
170 { 170 {
171 DCHECK(e); 171 DCHECK(e);
172 DCHECK(e->inShadowIncludingDocument()); 172 DCHECK(e->isConnected());
173 Document& document = e->document(); 173 Document& document = e->document();
174 174
175 const ContentSecurityPolicy* csp = document.contentSecurityPolicy(); 175 const ContentSecurityPolicy* csp = document.contentSecurityPolicy();
176 bool passesContentSecurityPolicyChecks = shouldBypassMainWorldCSP(e) 176 bool passesContentSecurityPolicyChecks = shouldBypassMainWorldCSP(e)
177 || csp->allowStyleWithHash(text, ContentSecurityPolicy::InlineType::Bloc k) 177 || csp->allowStyleWithHash(text, ContentSecurityPolicy::InlineType::Bloc k)
178 || csp->allowInlineStyle(e->document().url(), e->fastGetAttribute(HTMLNa mes::nonceAttr), m_startPosition.m_line, text); 178 || csp->allowInlineStyle(e->document().url(), e->fastGetAttribute(HTMLNa mes::nonceAttr), m_startPosition.m_line, text);
179 179
180 // Clearing the current sheet may remove the cache entry so create the new s heet first 180 // Clearing the current sheet may remove the cache entry so create the new s heet first
181 CSSStyleSheet* newSheet = nullptr; 181 CSSStyleSheet* newSheet = nullptr;
182 182
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
226 { 226 {
227 document.styleEngine().addPendingSheet(m_styleEngineContext); 227 document.styleEngine().addPendingSheet(m_styleEngineContext);
228 } 228 }
229 229
230 DEFINE_TRACE(StyleElement) 230 DEFINE_TRACE(StyleElement)
231 { 231 {
232 visitor->trace(m_sheet); 232 visitor->trace(m_sheet);
233 } 233 }
234 234
235 } // namespace blink 235 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/dom/SelectorQuery.cpp ('k') | third_party/WebKit/Source/core/dom/StyleEngine.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698