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

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

Issue 25505007: Remove bogus use of the term "user style" in Blink and Blink API (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Patch for landing 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
« no previous file with comments | « Source/core/dom/StyleEngine.h ('k') | Source/core/page/InjectedStyleSheet.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) 1999 Lars Knoll (knoll@kde.org) 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org)
3 * (C) 1999 Antti Koivisto (koivisto@kde.org) 3 * (C) 1999 Antti Koivisto (koivisto@kde.org)
4 * (C) 2001 Dirk Mueller (mueller@kde.org) 4 * (C) 2001 Dirk Mueller (mueller@kde.org)
5 * (C) 2006 Alexey Proskuryakov (ap@webkit.org) 5 * (C) 2006 Alexey Proskuryakov (ap@webkit.org)
6 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2011, 2012 Apple Inc. All r ights reserved. 6 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2011, 2012 Apple Inc. All r ights reserved.
7 * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved. (http://www.t orchmobile.com/) 7 * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved. (http://www.t orchmobile.com/)
8 * Copyright (C) 2008, 2009, 2011, 2012 Google Inc. All rights reserved. 8 * Copyright (C) 2008, 2009, 2011, 2012 Google Inc. All rights reserved.
9 * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies) 9 * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies)
10 * Copyright (C) Research In Motion Limited 2010-2011. All rights reserved. 10 * Copyright (C) Research In Motion Limited 2010-2011. All rights reserved.
(...skipping 27 matching lines...) Expand all
38 #include "core/dom/Element.h" 38 #include "core/dom/Element.h"
39 #include "core/dom/ProcessingInstruction.h" 39 #include "core/dom/ProcessingInstruction.h"
40 #include "core/dom/ShadowTreeStyleSheetCollection.h" 40 #include "core/dom/ShadowTreeStyleSheetCollection.h"
41 #include "core/dom/shadow/ShadowRoot.h" 41 #include "core/dom/shadow/ShadowRoot.h"
42 #include "core/html/HTMLIFrameElement.h" 42 #include "core/html/HTMLIFrameElement.h"
43 #include "core/html/HTMLLinkElement.h" 43 #include "core/html/HTMLLinkElement.h"
44 #include "core/html/HTMLStyleElement.h" 44 #include "core/html/HTMLStyleElement.h"
45 #include "core/page/Page.h" 45 #include "core/page/Page.h"
46 #include "core/page/PageGroup.h" 46 #include "core/page/PageGroup.h"
47 #include "core/page/Settings.h" 47 #include "core/page/Settings.h"
48 #include "core/page/UserContentURLPattern.h"
49 #include "core/svg/SVGStyleElement.h" 48 #include "core/svg/SVGStyleElement.h"
49 #include "platform/URLPatternMatcher.h"
50 50
51 namespace WebCore { 51 namespace WebCore {
52 52
53 using namespace HTMLNames; 53 using namespace HTMLNames;
54 54
55 StyleEngine::StyleEngine(Document& document) 55 StyleEngine::StyleEngine(Document& document)
56 : m_document(document) 56 : m_document(document)
57 , m_pendingStylesheets(0) 57 , m_pendingStylesheets(0)
58 , m_injectedStyleSheetCacheValid(false) 58 , m_injectedStyleSheetCacheValid(false)
59 , m_needsUpdateActiveStylesheetsOnStyleRecalc(false) 59 , m_needsUpdateActiveStylesheetsOnStyleRecalc(false)
60 , m_usesSiblingRules(false) 60 , m_usesSiblingRules(false)
61 , m_usesSiblingRulesOverride(false) 61 , m_usesSiblingRulesOverride(false)
62 , m_usesFirstLineRules(false) 62 , m_usesFirstLineRules(false)
63 , m_usesFirstLetterRules(false) 63 , m_usesFirstLetterRules(false)
64 , m_usesRemUnits(false) 64 , m_usesRemUnits(false)
65 , m_documentStyleSheetCollection(document) 65 , m_documentStyleSheetCollection(document)
66 , m_needsDocumentStyleSheetsUpdate(true) 66 , m_needsDocumentStyleSheetsUpdate(true)
67 { 67 {
68 } 68 }
69 69
70 StyleEngine::~StyleEngine() 70 StyleEngine::~StyleEngine()
71 { 71 {
72 if (m_pageUserSheet) 72 if (m_pageUserSheet)
73 m_pageUserSheet->clearOwnerNode(); 73 m_pageUserSheet->clearOwnerNode();
74 for (unsigned i = 0; i < m_injectedUserStyleSheets.size(); ++i)
75 m_injectedUserStyleSheets[i]->clearOwnerNode();
76 for (unsigned i = 0; i < m_injectedAuthorStyleSheets.size(); ++i) 74 for (unsigned i = 0; i < m_injectedAuthorStyleSheets.size(); ++i)
77 m_injectedAuthorStyleSheets[i]->clearOwnerNode(); 75 m_injectedAuthorStyleSheets[i]->clearOwnerNode();
78 for (unsigned i = 0; i < m_userStyleSheets.size(); ++i) 76 for (unsigned i = 0; i < m_userStyleSheets.size(); ++i)
79 m_userStyleSheets[i]->clearOwnerNode(); 77 m_userStyleSheets[i]->clearOwnerNode();
80 for (unsigned i = 0; i < m_authorStyleSheets.size(); ++i) 78 for (unsigned i = 0; i < m_authorStyleSheets.size(); ++i)
81 m_authorStyleSheets[i]->clearOwnerNode(); 79 m_authorStyleSheets[i]->clearOwnerNode();
82 } 80 }
83 81
84 void StyleEngine::insertTreeScopeInDocumentOrder(TreeScopeSet& treeScopes, TreeS cope* treeScope) 82 void StyleEngine::insertTreeScopeInDocumentOrder(TreeScopeSet& treeScopes, TreeS cope* treeScope)
85 { 83 {
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after
199 } 197 }
200 198
201 void StyleEngine::updatePageUserSheet() 199 void StyleEngine::updatePageUserSheet()
202 { 200 {
203 clearPageUserSheet(); 201 clearPageUserSheet();
204 // FIXME: Why is this immediately and not defer? 202 // FIXME: Why is this immediately and not defer?
205 if (StyleSheet* addedSheet = pageUserSheet()) 203 if (StyleSheet* addedSheet = pageUserSheet())
206 m_document.addedStyleSheet(addedSheet, RecalcStyleImmediately); 204 m_document.addedStyleSheet(addedSheet, RecalcStyleImmediately);
207 } 205 }
208 206
209 const Vector<RefPtr<CSSStyleSheet> >& StyleEngine::injectedUserStyleSheets() con st
210 {
211 updateInjectedStyleSheetCache();
212 return m_injectedUserStyleSheets;
213 }
214
215 const Vector<RefPtr<CSSStyleSheet> >& StyleEngine::injectedAuthorStyleSheets() c onst 207 const Vector<RefPtr<CSSStyleSheet> >& StyleEngine::injectedAuthorStyleSheets() c onst
216 { 208 {
217 updateInjectedStyleSheetCache(); 209 updateInjectedStyleSheetCache();
218 return m_injectedAuthorStyleSheets; 210 return m_injectedAuthorStyleSheets;
219 } 211 }
220 212
221 void StyleEngine::updateInjectedStyleSheetCache() const 213 void StyleEngine::updateInjectedStyleSheetCache() const
222 { 214 {
223 if (m_injectedStyleSheetCacheValid) 215 if (m_injectedStyleSheetCacheValid)
224 return; 216 return;
225 m_injectedStyleSheetCacheValid = true; 217 m_injectedStyleSheetCacheValid = true;
226 m_injectedUserStyleSheets.clear();
227 m_injectedAuthorStyleSheets.clear(); 218 m_injectedAuthorStyleSheets.clear();
228 219
229 Page* owningPage = m_document.page(); 220 Page* owningPage = m_document.page();
230 if (!owningPage) 221 if (!owningPage)
231 return; 222 return;
232 223
233 const PageGroup& pageGroup = owningPage->group(); 224 const PageGroup& pageGroup = owningPage->group();
234 const UserStyleSheetVector& sheets = pageGroup.userStyleSheets(); 225 const InjectedStyleSheetVector& sheets = pageGroup.injectedStyleSheets();
235 for (unsigned i = 0; i < sheets.size(); ++i) { 226 for (unsigned i = 0; i < sheets.size(); ++i) {
236 const UserStyleSheet* sheet = sheets[i].get(); 227 const InjectedStyleSheet* sheet = sheets[i].get();
237 if (sheet->injectedFrames() == InjectInTopFrameOnly && m_document.ownerE lement()) 228 if (sheet->injectedFrames() == InjectStyleInTopFrameOnly && m_document.o wnerElement())
238 continue; 229 continue;
239 if (!UserContentURLPattern::matchesPatterns(m_document.url(), sheet->whi telist(), sheet->blacklist())) 230 if (!URLPatternMatcher::matchesPatterns(m_document.url(), sheet->whiteli st()))
240 continue; 231 continue;
241 RefPtr<CSSStyleSheet> groupSheet = CSSStyleSheet::createInline(const_cas t<Document*>(&m_document), sheet->url()); 232 RefPtr<CSSStyleSheet> groupSheet = CSSStyleSheet::createInline(const_cas t<Document*>(&m_document), KURL());
242 bool isUserStyleSheet = sheet->level() == UserStyleUserLevel; 233 m_injectedAuthorStyleSheets.append(groupSheet);
243 if (isUserStyleSheet) 234 groupSheet->contents()->setIsUserStyleSheet(false);
244 m_injectedUserStyleSheets.append(groupSheet);
245 else
246 m_injectedAuthorStyleSheets.append(groupSheet);
247 groupSheet->contents()->setIsUserStyleSheet(isUserStyleSheet);
248 groupSheet->contents()->parseString(sheet->source()); 235 groupSheet->contents()->parseString(sheet->source());
249 } 236 }
250 } 237 }
251 238
252 void StyleEngine::invalidateInjectedStyleSheetCache() 239 void StyleEngine::invalidateInjectedStyleSheetCache()
253 { 240 {
254 m_injectedStyleSheetCacheValid = false; 241 m_injectedStyleSheetCacheValid = false;
255 m_needsDocumentStyleSheetsUpdate = true; 242 m_needsDocumentStyleSheetsUpdate = true;
256 // FIXME: updateInjectedStyleSheetCache is called inside StyleSheetCollectio n::updateActiveStyleSheets 243 // FIXME: updateInjectedStyleSheetCache is called inside StyleSheetCollectio n::updateActiveStyleSheets
257 // and batch updates lots of sheets so we can't call addedStyleSheet() or re movedStyleSheet(). 244 // and batch updates lots of sheets so we can't call addedStyleSheet() or re movedStyleSheet().
(...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after
452 if (StyleSheetCollection* collection = m_styleSheetCollectionMap.get(*it )) { 439 if (StyleSheetCollection* collection = m_styleSheetCollectionMap.get(*it )) {
453 styleResolver->setBuildScopedStyleTreeInDocumentOrder(!collection->s copingNodesForStyleScoped()); 440 styleResolver->setBuildScopedStyleTreeInDocumentOrder(!collection->s copingNodesForStyleScoped());
454 styleResolver->appendAuthorStyleSheets(0, collection->activeAuthorSt yleSheets()); 441 styleResolver->appendAuthorStyleSheets(0, collection->activeAuthorSt yleSheets());
455 } 442 }
456 } 443 }
457 styleResolver->finishAppendAuthorStyleSheets(); 444 styleResolver->finishAppendAuthorStyleSheets();
458 styleResolver->setBuildScopedStyleTreeInDocumentOrder(false); 445 styleResolver->setBuildScopedStyleTreeInDocumentOrder(false);
459 } 446 }
460 447
461 } 448 }
OLDNEW
« no previous file with comments | « Source/core/dom/StyleEngine.h ('k') | Source/core/page/InjectedStyleSheet.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698