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

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

Issue 2405143003: Separate @viewport from other RuleSet construction. (Closed)
Patch Set: Missing resolve() Created 4 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
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 6 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2011, 2012 Apple Inc. All
7 * rights reserved. 7 * rights reserved.
8 * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved. 8 * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved.
9 * (http://www.torchmobile.com/) 9 * (http://www.torchmobile.com/)
10 * Copyright (C) 2008, 2009, 2011, 2012 Google Inc. All rights reserved. 10 * Copyright (C) 2008, 2009, 2011, 2012 Google Inc. All rights reserved.
(...skipping 19 matching lines...) Expand all
30 #include "core/dom/StyleEngine.h" 30 #include "core/dom/StyleEngine.h"
31 31
32 #include "core/HTMLNames.h" 32 #include "core/HTMLNames.h"
33 #include "core/css/CSSDefaultStyleSheets.h" 33 #include "core/css/CSSDefaultStyleSheets.h"
34 #include "core/css/CSSFontSelector.h" 34 #include "core/css/CSSFontSelector.h"
35 #include "core/css/CSSStyleSheet.h" 35 #include "core/css/CSSStyleSheet.h"
36 #include "core/css/FontFaceCache.h" 36 #include "core/css/FontFaceCache.h"
37 #include "core/css/StyleSheetContents.h" 37 #include "core/css/StyleSheetContents.h"
38 #include "core/css/invalidation/InvalidationSet.h" 38 #include "core/css/invalidation/InvalidationSet.h"
39 #include "core/css/resolver/ScopedStyleResolver.h" 39 #include "core/css/resolver/ScopedStyleResolver.h"
40 #include "core/css/resolver/ViewportStyleResolver.h"
40 #include "core/dom/DocumentStyleSheetCollector.h" 41 #include "core/dom/DocumentStyleSheetCollector.h"
41 #include "core/dom/Element.h" 42 #include "core/dom/Element.h"
42 #include "core/dom/ElementTraversal.h" 43 #include "core/dom/ElementTraversal.h"
43 #include "core/dom/ProcessingInstruction.h" 44 #include "core/dom/ProcessingInstruction.h"
44 #include "core/dom/ShadowTreeStyleSheetCollection.h" 45 #include "core/dom/ShadowTreeStyleSheetCollection.h"
45 #include "core/dom/StyleChangeReason.h" 46 #include "core/dom/StyleChangeReason.h"
46 #include "core/dom/shadow/ShadowRoot.h" 47 #include "core/dom/shadow/ShadowRoot.h"
47 #include "core/frame/Settings.h" 48 #include "core/frame/Settings.h"
48 #include "core/html/HTMLIFrameElement.h" 49 #include "core/html/HTMLIFrameElement.h"
49 #include "core/html/HTMLLinkElement.h" 50 #include "core/html/HTMLLinkElement.h"
(...skipping 336 matching lines...) Expand 10 before | Expand all | Expand 10 after
386 collection->activeAuthorStyleSheets()); 387 collection->activeAuthorStyleSheets());
387 } 388 }
388 m_styleSheetCollectionMap.remove(shadowRoot); 389 m_styleSheetCollectionMap.remove(shadowRoot);
389 m_activeTreeScopes.remove(shadowRoot); 390 m_activeTreeScopes.remove(shadowRoot);
390 m_dirtyTreeScopes.remove(shadowRoot); 391 m_dirtyTreeScopes.remove(shadowRoot);
391 } 392 }
392 393
393 void StyleEngine::appendActiveAuthorStyleSheets() { 394 void StyleEngine::appendActiveAuthorStyleSheets() {
394 DCHECK(isMaster()); 395 DCHECK(isMaster());
395 396
397 documentStyleSheetCollection().updateViewport();
398
396 m_resolver->appendAuthorStyleSheets( 399 m_resolver->appendAuthorStyleSheets(
397 documentStyleSheetCollection().activeAuthorStyleSheets()); 400 documentStyleSheetCollection().activeAuthorStyleSheets());
398 for (TreeScope* treeScope : m_activeTreeScopes) { 401 for (TreeScope* treeScope : m_activeTreeScopes) {
399 if (TreeScopeStyleSheetCollection* collection = 402 if (TreeScopeStyleSheetCollection* collection =
400 m_styleSheetCollectionMap.get(treeScope)) 403 m_styleSheetCollectionMap.get(treeScope))
401 m_resolver->appendAuthorStyleSheets( 404 m_resolver->appendAuthorStyleSheets(
402 collection->activeAuthorStyleSheets()); 405 collection->activeAuthorStyleSheets());
403 } 406 }
404 m_resolver->finishAppendAuthorStyleSheets(); 407 m_resolver->finishAppendAuthorStyleSheets();
405 } 408 }
(...skipping 29 matching lines...) Expand all
435 } 438 }
436 } 439 }
437 440
438 void StyleEngine::clearMasterResolver() { 441 void StyleEngine::clearMasterResolver() {
439 if (Document* master = this->master()) 442 if (Document* master = this->master())
440 master->styleEngine().clearResolver(); 443 master->styleEngine().clearResolver();
441 } 444 }
442 445
443 void StyleEngine::didDetach() { 446 void StyleEngine::didDetach() {
444 clearResolver(); 447 clearResolver();
448 m_viewportResolver.clear();
445 } 449 }
446 450
447 bool StyleEngine::shouldClearResolver() const { 451 bool StyleEngine::shouldClearResolver() const {
448 return !m_didCalculateResolver && !haveScriptBlockingStylesheetsLoaded(); 452 return !m_didCalculateResolver && !haveScriptBlockingStylesheetsLoaded();
449 } 453 }
450 454
451 void StyleEngine::resolverChanged(StyleResolverUpdateMode mode) { 455 void StyleEngine::resolverChanged(StyleResolverUpdateMode mode) {
452 if (!isMaster()) { 456 if (!isMaster()) {
453 if (Document* master = this->master()) 457 if (Document* master = this->master())
454 master->styleEngine().resolverChanged(mode); 458 master->styleEngine().resolverChanged(mode);
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
492 if (!m_fontSelector) 496 if (!m_fontSelector)
493 return; 497 return;
494 498
495 FontFaceCache* cache = m_fontSelector->fontFaceCache(); 499 FontFaceCache* cache = m_fontSelector->fontFaceCache();
496 for (unsigned i = 0; i < fontFaceRules.size(); ++i) 500 for (unsigned i = 0; i < fontFaceRules.size(); ++i)
497 cache->remove(fontFaceRules[i]); 501 cache->remove(fontFaceRules[i]);
498 if (m_resolver) 502 if (m_resolver)
499 m_resolver->invalidateMatchedPropertiesCache(); 503 m_resolver->invalidateMatchedPropertiesCache();
500 } 504 }
501 505
506 ViewportStyleResolver& StyleEngine::ensureViewportStyleResolver() {
507 if (!m_viewportResolver)
508 m_viewportResolver = ViewportStyleResolver::create(m_document);
509 return *m_viewportResolver.get();
510 }
511
502 void StyleEngine::markTreeScopeDirty(TreeScope& scope) { 512 void StyleEngine::markTreeScopeDirty(TreeScope& scope) {
503 if (scope == m_document) { 513 if (scope == m_document) {
504 markDocumentDirty(); 514 markDocumentDirty();
505 return; 515 return;
506 } 516 }
507 517
508 DCHECK(m_styleSheetCollectionMap.contains(&scope)); 518 DCHECK(m_styleSheetCollectionMap.contains(&scope));
509 m_dirtyTreeScopes.add(&scope); 519 m_dirtyTreeScopes.add(&scope);
510 } 520 }
511 521
(...skipping 428 matching lines...) Expand 10 before | Expand all | Expand 10 after
940 } 950 }
941 951
942 void StyleEngine::ensureFullscreenUAStyle() { 952 void StyleEngine::ensureFullscreenUAStyle() {
943 CSSDefaultStyleSheets::instance().ensureDefaultStyleSheetForFullscreen(); 953 CSSDefaultStyleSheets::instance().ensureDefaultStyleSheetForFullscreen();
944 if (!m_resolver) 954 if (!m_resolver)
945 return; 955 return;
946 if (!m_resolver->hasFullscreenUAStyle()) 956 if (!m_resolver->hasFullscreenUAStyle())
947 m_resolver->resetRuleFeatures(); 957 m_resolver->resetRuleFeatures();
948 } 958 }
949 959
960 void StyleEngine::initialViewportChanged() {
961 if (m_viewportResolver &&
962 m_viewportResolver->isAffectedByInitialViewportChange())
963 updateViewport();
964 }
965
950 DEFINE_TRACE(StyleEngine) { 966 DEFINE_TRACE(StyleEngine) {
951 visitor->trace(m_document); 967 visitor->trace(m_document);
952 visitor->trace(m_injectedAuthorStyleSheets); 968 visitor->trace(m_injectedAuthorStyleSheets);
953 visitor->trace(m_inspectorStyleSheet); 969 visitor->trace(m_inspectorStyleSheet);
954 visitor->trace(m_documentStyleSheetCollection); 970 visitor->trace(m_documentStyleSheetCollection);
955 visitor->trace(m_styleSheetCollectionMap); 971 visitor->trace(m_styleSheetCollectionMap);
956 visitor->trace(m_resolver); 972 visitor->trace(m_resolver);
973 visitor->trace(m_viewportResolver);
957 visitor->trace(m_styleInvalidator); 974 visitor->trace(m_styleInvalidator);
958 visitor->trace(m_dirtyTreeScopes); 975 visitor->trace(m_dirtyTreeScopes);
959 visitor->trace(m_activeTreeScopes); 976 visitor->trace(m_activeTreeScopes);
960 visitor->trace(m_fontSelector); 977 visitor->trace(m_fontSelector);
961 visitor->trace(m_textToSheetCache); 978 visitor->trace(m_textToSheetCache);
962 visitor->trace(m_sheetToTextCache); 979 visitor->trace(m_sheetToTextCache);
963 CSSFontSelectorClient::trace(visitor); 980 CSSFontSelectorClient::trace(visitor);
964 } 981 }
965 982
966 DEFINE_TRACE_WRAPPERS(StyleEngine) { 983 DEFINE_TRACE_WRAPPERS(StyleEngine) {
967 for (auto sheet : m_injectedAuthorStyleSheets) { 984 for (auto sheet : m_injectedAuthorStyleSheets) {
968 visitor->traceWrappers(sheet); 985 visitor->traceWrappers(sheet);
969 } 986 }
970 visitor->traceWrappers(m_documentStyleSheetCollection); 987 visitor->traceWrappers(m_documentStyleSheetCollection);
971 } 988 }
972 989
973 } // namespace blink 990 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/dom/StyleEngine.h ('k') | third_party/WebKit/Source/core/dom/StyleEngineTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698