OLD | NEW |
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 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
112 | 112 |
113 StyleSheetCollectionMap::iterator it = | 113 StyleSheetCollectionMap::iterator it = |
114 m_styleSheetCollectionMap.find(&treeScope); | 114 m_styleSheetCollectionMap.find(&treeScope); |
115 if (it == m_styleSheetCollectionMap.end()) | 115 if (it == m_styleSheetCollectionMap.end()) |
116 return nullptr; | 116 return nullptr; |
117 return it->value.get(); | 117 return it->value.get(); |
118 } | 118 } |
119 | 119 |
120 const HeapVector<TraceWrapperMember<StyleSheet>>& | 120 const HeapVector<TraceWrapperMember<StyleSheet>>& |
121 StyleEngine::styleSheetsForStyleSheetList(TreeScope& treeScope) { | 121 StyleEngine::styleSheetsForStyleSheetList(TreeScope& treeScope) { |
| 122 // TODO(rune@opera.com): we could split styleSheets and active stylesheet |
| 123 // update to have a lighter update while accessing the styleSheets list. |
| 124 DCHECK(master()); |
| 125 if (master()->isActive()) { |
| 126 if (isMaster()) |
| 127 updateActiveStyle(); |
| 128 else |
| 129 master()->styleEngine().updateActiveStyle(); |
| 130 } |
| 131 |
122 if (treeScope == m_document) | 132 if (treeScope == m_document) |
123 return documentStyleSheetCollection().styleSheetsForStyleSheetList(); | 133 return documentStyleSheetCollection().styleSheetsForStyleSheetList(); |
124 | 134 |
125 return ensureStyleSheetCollectionFor(treeScope) | 135 return ensureStyleSheetCollectionFor(treeScope) |
126 ->styleSheetsForStyleSheetList(); | 136 ->styleSheetsForStyleSheetList(); |
127 } | 137 } |
128 | 138 |
129 void StyleEngine::injectAuthorSheet(StyleSheetContents* authorSheet) { | 139 void StyleEngine::injectAuthorSheet(StyleSheetContents* authorSheet) { |
130 m_injectedAuthorStyleSheets.append(TraceWrapperMember<CSSStyleSheet>( | 140 m_injectedAuthorStyleSheets.append(TraceWrapperMember<CSSStyleSheet>( |
131 this, CSSStyleSheet::create(authorSheet, *m_document))); | 141 this, CSSStyleSheet::create(authorSheet, *m_document))); |
(...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
326 for (TreeScope* treeScope : treeScopesRemoved) | 336 for (TreeScope* treeScope : treeScopesRemoved) |
327 m_activeTreeScopes.remove(treeScope); | 337 m_activeTreeScopes.remove(treeScope); |
328 } | 338 } |
329 | 339 |
330 InspectorInstrumentation::activeStyleSheetsUpdated(m_document); | 340 InspectorInstrumentation::activeStyleSheetsUpdated(m_document); |
331 | 341 |
332 m_dirtyTreeScopes.clear(); | 342 m_dirtyTreeScopes.clear(); |
333 m_documentScopeDirty = false; | 343 m_documentScopeDirty = false; |
334 } | 344 } |
335 | 345 |
| 346 void StyleEngine::updateActiveStyleSheets() { |
| 347 // TODO(rune@opera.com): collect ActiveStyleSheets here. |
| 348 } |
| 349 |
| 350 void StyleEngine::updateViewport() { |
| 351 if (m_viewportResolver) |
| 352 m_viewportResolver->updateViewport(documentStyleSheetCollection()); |
| 353 } |
| 354 |
| 355 bool StyleEngine::needsActiveStyleUpdate() const { |
| 356 return m_viewportResolver && m_viewportResolver->needsUpdate(); |
| 357 } |
| 358 |
| 359 void StyleEngine::updateActiveStyle() { |
| 360 updateViewport(); |
| 361 updateActiveStyleSheets(); |
| 362 m_globalRuleSet.update(document()); |
| 363 } |
| 364 |
336 const HeapVector<Member<CSSStyleSheet>> | 365 const HeapVector<Member<CSSStyleSheet>> |
337 StyleEngine::activeStyleSheetsForInspector() const { | 366 StyleEngine::activeStyleSheetsForInspector() const { |
338 if (m_activeTreeScopes.isEmpty()) | 367 if (m_activeTreeScopes.isEmpty()) |
339 return documentStyleSheetCollection().activeAuthorStyleSheets(); | 368 return documentStyleSheetCollection().activeAuthorStyleSheets(); |
340 | 369 |
341 HeapVector<Member<CSSStyleSheet>> activeStyleSheets; | 370 HeapVector<Member<CSSStyleSheet>> activeStyleSheets; |
342 | 371 |
343 activeStyleSheets.appendVector( | 372 activeStyleSheets.appendVector( |
344 documentStyleSheetCollection().activeAuthorStyleSheets()); | 373 documentStyleSheetCollection().activeAuthorStyleSheets()); |
345 for (TreeScope* treeScope : m_activeTreeScopes) { | 374 for (TreeScope* treeScope : m_activeTreeScopes) { |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
392 m_globalRuleSet.update(document()); | 421 m_globalRuleSet.update(document()); |
393 | 422 |
394 if (!document().layoutViewItem().isNull() && | 423 if (!document().layoutViewItem().isNull() && |
395 document().layoutViewItem().style()) | 424 document().layoutViewItem().style()) |
396 document().layoutViewItem().style()->font().update(fontSelector()); | 425 document().layoutViewItem().style()->font().update(fontSelector()); |
397 } | 426 } |
398 | 427 |
399 void StyleEngine::appendActiveAuthorStyleSheets() { | 428 void StyleEngine::appendActiveAuthorStyleSheets() { |
400 DCHECK(isMaster()); | 429 DCHECK(isMaster()); |
401 | 430 |
402 viewportRulesChanged(); | |
403 | |
404 m_resolver->appendAuthorStyleSheets( | 431 m_resolver->appendAuthorStyleSheets( |
405 documentStyleSheetCollection().activeAuthorStyleSheets()); | 432 documentStyleSheetCollection().activeAuthorStyleSheets()); |
406 for (TreeScope* treeScope : m_activeTreeScopes) { | 433 for (TreeScope* treeScope : m_activeTreeScopes) { |
407 if (TreeScopeStyleSheetCollection* collection = | 434 if (TreeScopeStyleSheetCollection* collection = |
408 m_styleSheetCollectionMap.get(treeScope)) | 435 m_styleSheetCollectionMap.get(treeScope)) |
409 m_resolver->appendAuthorStyleSheets( | 436 m_resolver->appendAuthorStyleSheets( |
410 collection->activeAuthorStyleSheets()); | 437 collection->activeAuthorStyleSheets()); |
411 } | 438 } |
412 } | 439 } |
413 | 440 |
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
529 markDocumentDirty(); | 556 markDocumentDirty(); |
530 return; | 557 return; |
531 } | 558 } |
532 | 559 |
533 DCHECK(m_styleSheetCollectionMap.contains(&scope)); | 560 DCHECK(m_styleSheetCollectionMap.contains(&scope)); |
534 m_dirtyTreeScopes.add(&scope); | 561 m_dirtyTreeScopes.add(&scope); |
535 } | 562 } |
536 | 563 |
537 void StyleEngine::markDocumentDirty() { | 564 void StyleEngine::markDocumentDirty() { |
538 m_documentScopeDirty = true; | 565 m_documentScopeDirty = true; |
| 566 if (RuntimeEnabledFeatures::cssViewportEnabled()) |
| 567 viewportRulesChanged(); |
539 if (document().importLoader()) | 568 if (document().importLoader()) |
540 document().importsController()->master()->styleEngine().markDocumentDirty(); | 569 document().importsController()->master()->styleEngine().markDocumentDirty(); |
541 } | 570 } |
542 | 571 |
543 CSSStyleSheet* StyleEngine::createSheet(Element& element, | 572 CSSStyleSheet* StyleEngine::createSheet(Element& element, |
544 const String& text, | 573 const String& text, |
545 TextPosition startPosition, | 574 TextPosition startPosition, |
546 StyleEngineContext& context) { | 575 StyleEngineContext& context) { |
547 DCHECK(element.document() == document()); | 576 DCHECK(element.document() == document()); |
548 CSSStyleSheet* styleSheet = nullptr; | 577 CSSStyleSheet* styleSheet = nullptr; |
(...skipping 442 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
991 m_globalRuleSet.markDirty(); | 1020 m_globalRuleSet.markDirty(); |
992 m_globalRuleSet.update(document()); | 1021 m_globalRuleSet.update(document()); |
993 } | 1022 } |
994 } | 1023 } |
995 | 1024 |
996 bool StyleEngine::hasRulesForId(const AtomicString& id) const { | 1025 bool StyleEngine::hasRulesForId(const AtomicString& id) const { |
997 return m_globalRuleSet.ruleFeatureSet().hasSelectorForId(id); | 1026 return m_globalRuleSet.ruleFeatureSet().hasSelectorForId(id); |
998 } | 1027 } |
999 | 1028 |
1000 void StyleEngine::initialViewportChanged() { | 1029 void StyleEngine::initialViewportChanged() { |
1001 if (!m_viewportResolver) | 1030 if (m_viewportResolver) |
1002 return; | 1031 m_viewportResolver->initialViewportChanged(); |
1003 | |
1004 m_viewportResolver->initialViewportChanged(); | |
1005 | |
1006 // TODO(rune@opera.com): for async stylesheet update, updateViewport() should | |
1007 // be called as part of the lifecycle update for active style. Synchronous for | |
1008 // now. | |
1009 m_viewportResolver->updateViewport(documentStyleSheetCollection()); | |
1010 } | 1032 } |
1011 | 1033 |
1012 void StyleEngine::viewportRulesChanged() { | 1034 void StyleEngine::viewportRulesChanged() { |
1013 if (!m_viewportResolver) | 1035 if (m_viewportResolver) |
1014 return; | 1036 m_viewportResolver->setNeedsCollectRules(); |
1015 m_viewportResolver->setNeedsCollectRules(); | |
1016 | |
1017 // TODO(rune@opera.com): for async stylesheet update, updateViewport() should | |
1018 // be called as part of the lifecycle update for active style. Synchronous for | |
1019 // now. | |
1020 m_viewportResolver->updateViewport(documentStyleSheetCollection()); | |
1021 } | 1037 } |
1022 | 1038 |
1023 PassRefPtr<ComputedStyle> StyleEngine::findSharedStyle( | 1039 PassRefPtr<ComputedStyle> StyleEngine::findSharedStyle( |
1024 const ElementResolveContext& elementResolveContext) { | 1040 const ElementResolveContext& elementResolveContext) { |
1025 DCHECK(m_resolver); | 1041 DCHECK(m_resolver); |
1026 return SharedStyleFinder( | 1042 return SharedStyleFinder( |
1027 elementResolveContext, m_globalRuleSet.ruleFeatureSet(), | 1043 elementResolveContext, m_globalRuleSet.ruleFeatureSet(), |
1028 m_globalRuleSet.siblingRuleSet(), | 1044 m_globalRuleSet.siblingRuleSet(), |
1029 m_globalRuleSet.uncommonAttributeRuleSet(), *m_resolver) | 1045 m_globalRuleSet.uncommonAttributeRuleSet(), *m_resolver) |
1030 .findSharedStyle(); | 1046 .findSharedStyle(); |
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1141 } | 1157 } |
1142 | 1158 |
1143 DEFINE_TRACE_WRAPPERS(StyleEngine) { | 1159 DEFINE_TRACE_WRAPPERS(StyleEngine) { |
1144 for (auto sheet : m_injectedAuthorStyleSheets) { | 1160 for (auto sheet : m_injectedAuthorStyleSheets) { |
1145 visitor->traceWrappers(sheet); | 1161 visitor->traceWrappers(sheet); |
1146 } | 1162 } |
1147 visitor->traceWrappers(m_documentStyleSheetCollection); | 1163 visitor->traceWrappers(m_documentStyleSheetCollection); |
1148 } | 1164 } |
1149 | 1165 |
1150 } // namespace blink | 1166 } // namespace blink |
OLD | NEW |