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

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

Issue 28553005: Avoid parsing css text if there are identical inline style blocks. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Patch for landing Created 6 years, 11 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
« no previous file with comments | « Source/core/css/StyleSheetContents.cpp ('k') | Source/core/dom/StyleEngine.h » ('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) 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 117 matching lines...) Expand 10 before | Expand all | Expand 10 after
128 128
129 // If type is empty or CSS, this is a CSS style sheet. 129 // If type is empty or CSS, this is a CSS style sheet.
130 const AtomicString& type = this->type(); 130 const AtomicString& type = this->type();
131 bool passesContentSecurityPolicyChecks = document.contentSecurityPolicy()->a llowStyleNonce(e->fastGetAttribute(HTMLNames::nonceAttr)) || document.contentSec urityPolicy()->allowInlineStyle(e->document().url(), m_startPosition.m_line); 131 bool passesContentSecurityPolicyChecks = document.contentSecurityPolicy()->a llowStyleNonce(e->fastGetAttribute(HTMLNames::nonceAttr)) || document.contentSec urityPolicy()->allowInlineStyle(e->document().url(), m_startPosition.m_line);
132 if (isCSS(e, type) && passesContentSecurityPolicyChecks) { 132 if (isCSS(e, type) && passesContentSecurityPolicyChecks) {
133 RefPtr<MediaQuerySet> mediaQueries = MediaQuerySet::create(media()); 133 RefPtr<MediaQuerySet> mediaQueries = MediaQuerySet::create(media());
134 134
135 MediaQueryEvaluator screenEval("screen", true); 135 MediaQueryEvaluator screenEval("screen", true);
136 MediaQueryEvaluator printEval("print", true); 136 MediaQueryEvaluator printEval("print", true);
137 if (screenEval.eval(mediaQueries.get()) || printEval.eval(mediaQueries.g et())) { 137 if (screenEval.eval(mediaQueries.get()) || printEval.eval(mediaQueries.g et())) {
138 document.styleEngine()->addPendingSheet();
139 m_loading = true; 138 m_loading = true;
140
141 TextPosition startPosition = m_startPosition == TextPosition::belowR angePosition() ? TextPosition::minimumPosition() : m_startPosition; 139 TextPosition startPosition = m_startPosition == TextPosition::belowR angePosition() ? TextPosition::minimumPosition() : m_startPosition;
142 m_sheet = CSSStyleSheet::createInline(e, KURL(), startPosition, docu ment.inputEncoding()); 140 m_sheet = StyleEngine::createSheet(e, text, startPosition, m_created ByParser);
143 m_sheet->setMediaQueries(mediaQueries.release()); 141 m_sheet->setMediaQueries(mediaQueries.release());
144 m_sheet->setTitle(e->title());
145 m_sheet->contents()->parseStringAtPosition(text, startPosition, m_cr eatedByParser);
146
147 m_loading = false; 142 m_loading = false;
148 } 143 }
149 } 144 }
150 145
151 if (m_sheet) 146 if (m_sheet)
152 m_sheet->contents()->checkLoaded(); 147 m_sheet->contents()->checkLoaded();
153 } 148 }
154 149
155 bool StyleElement::isLoading() const 150 bool StyleElement::isLoading() const
156 { 151 {
(...skipping 10 matching lines...) Expand all
167 document.styleEngine()->removePendingSheet(m_sheet->ownerNode()); 162 document.styleEngine()->removePendingSheet(m_sheet->ownerNode());
168 return true; 163 return true;
169 } 164 }
170 165
171 void StyleElement::startLoadingDynamicSheet(Document& document) 166 void StyleElement::startLoadingDynamicSheet(Document& document)
172 { 167 {
173 document.styleEngine()->addPendingSheet(); 168 document.styleEngine()->addPendingSheet();
174 } 169 }
175 170
176 } 171 }
OLDNEW
« no previous file with comments | « Source/core/css/StyleSheetContents.cpp ('k') | Source/core/dom/StyleEngine.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698