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

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

Issue 1903803002: Do not block painting for in-body CSS (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixed merge conflict Created 4 years, 7 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 128 matching lines...) Expand 10 before | Expand all | Expand 10 after
139 if (!element || !element->inShadowIncludingDocument()) 139 if (!element || !element->inShadowIncludingDocument())
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); 149 ownerElement->document().styleEngine().removePendingSheet(ownerElement, m_styleEngineContext);
150 150
151 m_sheet.release()->clearOwnerNode(); 151 m_sheet.release()->clearOwnerNode();
152 } 152 }
153 153
154 static bool shouldBypassMainWorldCSP(Element* element) 154 static bool shouldBypassMainWorldCSP(Element* element)
155 { 155 {
156 // Main world CSP is bypassed within an isolated world. 156 // Main world CSP is bypassed within an isolated world.
157 LocalFrame* frame = element->document().frame(); 157 LocalFrame* frame = element->document().frame();
158 if (frame && frame->script().shouldBypassMainWorldCSP()) 158 if (frame && frame->script().shouldBypassMainWorldCSP())
159 return true; 159 return true;
(...skipping 24 matching lines...) Expand all
184 // If type is empty or CSS, this is a CSS style sheet. 184 // If type is empty or CSS, this is a CSS style sheet.
185 const AtomicString& type = this->type(); 185 const AtomicString& type = this->type();
186 if (isCSS(e, type) && passesContentSecurityPolicyChecks) { 186 if (isCSS(e, type) && passesContentSecurityPolicyChecks) {
187 MediaQuerySet* mediaQueries = MediaQuerySet::create(media()); 187 MediaQuerySet* mediaQueries = MediaQuerySet::create(media());
188 188
189 MediaQueryEvaluator screenEval("screen", true); 189 MediaQueryEvaluator screenEval("screen", true);
190 MediaQueryEvaluator printEval("print", true); 190 MediaQueryEvaluator printEval("print", true);
191 if (screenEval.eval(mediaQueries) || printEval.eval(mediaQueries)) { 191 if (screenEval.eval(mediaQueries) || printEval.eval(mediaQueries)) {
192 m_loading = true; 192 m_loading = true;
193 TextPosition startPosition = m_startPosition == TextPosition::belowR angePosition() ? TextPosition::minimumPosition() : m_startPosition; 193 TextPosition startPosition = m_startPosition == TextPosition::belowR angePosition() ? TextPosition::minimumPosition() : m_startPosition;
194 newSheet = document.styleEngine().createSheet(e, text, startPosition ); 194 newSheet = document.styleEngine().createSheet(e, text, startPosition , m_styleEngineContext);
195 newSheet->setMediaQueries(mediaQueries); 195 newSheet->setMediaQueries(mediaQueries);
196 m_loading = false; 196 m_loading = false;
197 } 197 }
198 } 198 }
199 199
200 if (m_sheet) 200 if (m_sheet)
201 clearSheet(e); 201 clearSheet(e);
202 202
203 m_sheet = newSheet; 203 m_sheet = newSheet;
204 if (m_sheet) 204 if (m_sheet)
205 m_sheet->contents()->checkLoaded(); 205 m_sheet->contents()->checkLoaded();
206 206
207 return passesContentSecurityPolicyChecks ? ProcessingSuccessful : Processing FatalError; 207 return passesContentSecurityPolicyChecks ? ProcessingSuccessful : Processing FatalError;
208 } 208 }
209 209
210 bool StyleElement::isLoading() const 210 bool StyleElement::isLoading() const
211 { 211 {
212 if (m_loading) 212 if (m_loading)
213 return true; 213 return true;
214 return m_sheet ? m_sheet->isLoading() : false; 214 return m_sheet ? m_sheet->isLoading() : false;
215 } 215 }
216 216
217 bool StyleElement::sheetLoaded(Document& document) 217 bool StyleElement::sheetLoaded(Document& document)
218 { 218 {
219 if (isLoading()) 219 if (isLoading())
220 return false; 220 return false;
221 221
222 document.styleEngine().removePendingSheet(m_sheet->ownerNode()); 222 document.styleEngine().removePendingSheet(m_sheet->ownerNode(), m_styleEngin eContext);
223 return true; 223 return true;
224 } 224 }
225 225
226 void StyleElement::startLoadingDynamicSheet(Document& document) 226 void StyleElement::startLoadingDynamicSheet(Document& document)
227 { 227 {
228 document.styleEngine().addPendingSheet(); 228 document.styleEngine().addPendingSheet(m_styleEngineContext);
229 } 229 }
230 230
231 DEFINE_TRACE(StyleElement) 231 DEFINE_TRACE(StyleElement)
232 { 232 {
233 visitor->trace(m_sheet); 233 visitor->trace(m_sheet);
234 } 234 }
235 235
236 } // namespace blink 236 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/dom/StyleElement.h ('k') | third_party/WebKit/Source/core/dom/StyleEngine.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698