| 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 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 344 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 355 ASSERT(isHTMLStyleElement(node) || treeScope == m_document); | 355 ASSERT(isHTMLStyleElement(node) || treeScope == m_document); |
| 356 markTreeScopeDirty(treeScope); | 356 markTreeScopeDirty(treeScope); |
| 357 } | 357 } |
| 358 | 358 |
| 359 void StyleEngine::enableExitTransitionStylesheets() | 359 void StyleEngine::enableExitTransitionStylesheets() |
| 360 { | 360 { |
| 361 TreeScopeStyleSheetCollection* collection = ensureStyleSheetCollectionFor(*m
_document); | 361 TreeScopeStyleSheetCollection* collection = ensureStyleSheetCollectionFor(*m
_document); |
| 362 collection->enableExitTransitionStylesheets(); | 362 collection->enableExitTransitionStylesheets(); |
| 363 } | 363 } |
| 364 | 364 |
| 365 bool StyleEngine::shouldUpdateShadowTreeStyleSheetCollection(StyleResolverUpdate
Mode updateMode) | 365 bool StyleEngine::shouldUpdateDocumentStyleSheetCollection(StyleResolverUpdateMo
de updateMode) const |
| 366 { |
| 367 return m_documentScopeDirty || updateMode == FullStyleUpdate; |
| 368 } |
| 369 |
| 370 bool StyleEngine::shouldUpdateShadowTreeStyleSheetCollection(StyleResolverUpdate
Mode updateMode) const |
| 366 { | 371 { |
| 367 return !m_dirtyTreeScopes.isEmpty() || updateMode == FullStyleUpdate; | 372 return !m_dirtyTreeScopes.isEmpty() || updateMode == FullStyleUpdate; |
| 368 } | 373 } |
| 369 | 374 |
| 370 void StyleEngine::clearMediaQueryRuleSetOnTreeScopeStyleSheets(TreeScopeSet tree
Scopes) | 375 void StyleEngine::clearMediaQueryRuleSetOnTreeScopeStyleSheets(TreeScopeSet tree
Scopes) |
| 371 { | 376 { |
| 372 for (TreeScopeSet::iterator it = treeScopes.begin(); it != treeScopes.end();
++it) { | 377 for (TreeScopeSet::iterator it = treeScopes.begin(); it != treeScopes.end();
++it) { |
| 373 TreeScope& treeScope = **it; | 378 TreeScope& treeScope = **it; |
| 374 ASSERT(treeScope != m_document); | 379 ASSERT(treeScope != m_document); |
| 375 ShadowTreeStyleSheetCollection* collection = static_cast<ShadowTreeStyle
SheetCollection*>(styleSheetCollectionFor(treeScope)); | 380 ShadowTreeStyleSheetCollection* collection = static_cast<ShadowTreeStyle
SheetCollection*>(styleSheetCollectionFor(treeScope)); |
| (...skipping 11 matching lines...) Expand all Loading... |
| 387 | 392 |
| 388 void StyleEngine::updateStyleSheetsInImport(DocumentStyleSheetCollector& parentC
ollector) | 393 void StyleEngine::updateStyleSheetsInImport(DocumentStyleSheetCollector& parentC
ollector) |
| 389 { | 394 { |
| 390 ASSERT(!isMaster()); | 395 ASSERT(!isMaster()); |
| 391 WillBeHeapVector<RefPtrWillBeMember<StyleSheet> > sheetsForList; | 396 WillBeHeapVector<RefPtrWillBeMember<StyleSheet> > sheetsForList; |
| 392 ImportedDocumentStyleSheetCollector subcollector(parentCollector, sheetsForL
ist); | 397 ImportedDocumentStyleSheetCollector subcollector(parentCollector, sheetsForL
ist); |
| 393 documentStyleSheetCollection()->collectStyleSheets(this, subcollector); | 398 documentStyleSheetCollection()->collectStyleSheets(this, subcollector); |
| 394 documentStyleSheetCollection()->swapSheetsForSheetList(sheetsForList); | 399 documentStyleSheetCollection()->swapSheetsForSheetList(sheetsForList); |
| 395 } | 400 } |
| 396 | 401 |
| 397 bool StyleEngine::updateActiveStyleSheets(StyleResolverUpdateMode updateMode) | 402 void StyleEngine::updateActiveStyleSheets(StyleResolverUpdateMode updateMode) |
| 398 { | 403 { |
| 399 ASSERT(isMaster()); | 404 ASSERT(isMaster()); |
| 400 ASSERT(!document().inStyleRecalc()); | 405 ASSERT(!document().inStyleRecalc()); |
| 401 | 406 |
| 402 if (!document().isActive()) | 407 if (!document().isActive()) |
| 403 return false; | 408 return; |
| 404 | 409 |
| 405 bool requiresFullStyleRecalc = false; | 410 if (shouldUpdateDocumentStyleSheetCollection(updateMode)) |
| 406 if (m_documentScopeDirty || updateMode == FullStyleUpdate) | 411 documentStyleSheetCollection()->updateActiveStyleSheets(this, updateMode
); |
| 407 requiresFullStyleRecalc = documentStyleSheetCollection()->updateActiveSt
yleSheets(this, updateMode); | |
| 408 | 412 |
| 409 if (shouldUpdateShadowTreeStyleSheetCollection(updateMode)) { | 413 if (shouldUpdateShadowTreeStyleSheetCollection(updateMode)) { |
| 410 TreeScopeSet treeScopes = updateMode == FullStyleUpdate ? m_activeTreeSc
opes : m_dirtyTreeScopes; | 414 TreeScopeSet treeScopes = updateMode == FullStyleUpdate ? m_activeTreeSc
opes : m_dirtyTreeScopes; |
| 411 HashSet<TreeScope*> treeScopesRemoved; | 415 HashSet<TreeScope*> treeScopesRemoved; |
| 412 | 416 |
| 413 for (TreeScopeSet::iterator it = treeScopes.begin(); it != treeScopes.en
d(); ++it) { | 417 for (TreeScopeSet::iterator it = treeScopes.begin(); it != treeScopes.en
d(); ++it) { |
| 414 TreeScope* treeScope = *it; | 418 TreeScope* treeScope = *it; |
| 415 ASSERT(treeScope != m_document); | 419 ASSERT(treeScope != m_document); |
| 416 ShadowTreeStyleSheetCollection* collection = static_cast<ShadowTreeS
tyleSheetCollection*>(styleSheetCollectionFor(*treeScope)); | 420 ShadowTreeStyleSheetCollection* collection = static_cast<ShadowTreeS
tyleSheetCollection*>(styleSheetCollectionFor(*treeScope)); |
| 417 ASSERT(collection); | 421 ASSERT(collection); |
| 418 collection->updateActiveStyleSheets(this, updateMode); | 422 collection->updateActiveStyleSheets(this, updateMode); |
| 419 if (!collection->hasStyleSheetCandidateNodes()) | 423 if (!collection->hasStyleSheetCandidateNodes()) |
| 420 treeScopesRemoved.add(treeScope); | 424 treeScopesRemoved.add(treeScope); |
| 421 } | 425 } |
| 422 m_activeTreeScopes.removeAll(treeScopesRemoved); | 426 m_activeTreeScopes.removeAll(treeScopesRemoved); |
| 423 } | 427 } |
| 424 | 428 |
| 425 InspectorInstrumentation::activeStyleSheetsUpdated(m_document); | 429 InspectorInstrumentation::activeStyleSheetsUpdated(m_document); |
| 426 m_usesRemUnits = documentStyleSheetCollection()->usesRemUnits(); | 430 m_usesRemUnits = documentStyleSheetCollection()->usesRemUnits(); |
| 427 | 431 |
| 428 m_dirtyTreeScopes.clear(); | 432 m_dirtyTreeScopes.clear(); |
| 429 m_documentScopeDirty = false; | 433 m_documentScopeDirty = false; |
| 430 | |
| 431 return requiresFullStyleRecalc; | |
| 432 } | 434 } |
| 433 | 435 |
| 434 const WillBeHeapVector<RefPtrWillBeMember<CSSStyleSheet> > StyleEngine::activeSt
yleSheetsForInspector() const | 436 const WillBeHeapVector<RefPtrWillBeMember<CSSStyleSheet> > StyleEngine::activeSt
yleSheetsForInspector() const |
| 435 { | 437 { |
| 436 if (m_activeTreeScopes.isEmpty()) | 438 if (m_activeTreeScopes.isEmpty()) |
| 437 return documentStyleSheetCollection()->activeAuthorStyleSheets(); | 439 return documentStyleSheetCollection()->activeAuthorStyleSheets(); |
| 438 | 440 |
| 439 WillBeHeapVector<RefPtrWillBeMember<CSSStyleSheet> > activeStyleSheets; | 441 WillBeHeapVector<RefPtrWillBeMember<CSSStyleSheet> > activeStyleSheets; |
| 440 | 442 |
| 441 activeStyleSheets.appendVector(documentStyleSheetCollection()->activeAuthorS
tyleSheets()); | 443 activeStyleSheets.appendVector(documentStyleSheetCollection()->activeAuthorS
tyleSheets()); |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 520 return !m_didCalculateResolver && !haveStylesheetsLoaded(); | 522 return !m_didCalculateResolver && !haveStylesheetsLoaded(); |
| 521 } | 523 } |
| 522 | 524 |
| 523 bool StyleEngine::shouldApplyXSLTransform() const | 525 bool StyleEngine::shouldApplyXSLTransform() const |
| 524 { | 526 { |
| 525 if (!RuntimeEnabledFeatures::xsltEnabled()) | 527 if (!RuntimeEnabledFeatures::xsltEnabled()) |
| 526 return false; | 528 return false; |
| 527 return m_xslStyleSheet && !m_document->transformSourceDocument(); | 529 return m_xslStyleSheet && !m_document->transformSourceDocument(); |
| 528 } | 530 } |
| 529 | 531 |
| 530 StyleResolverChange StyleEngine::resolverChanged(StyleResolverUpdateMode mode) | 532 void StyleEngine::resolverChanged(StyleResolverUpdateMode mode) |
| 531 { | 533 { |
| 532 StyleResolverChange change; | |
| 533 | |
| 534 if (!isMaster()) { | 534 if (!isMaster()) { |
| 535 if (Document* master = this->master()) | 535 if (Document* master = this->master()) |
| 536 master->styleResolverChanged(mode); | 536 master->styleResolverChanged(mode); |
| 537 return change; | 537 return; |
| 538 } | 538 } |
| 539 | 539 |
| 540 // Don't bother updating, since we haven't loaded all our style info yet | 540 // Don't bother updating, since we haven't loaded all our style info yet |
| 541 // and haven't calculated the style selector for the first time. | 541 // and haven't calculated the style selector for the first time. |
| 542 if (!document().isActive() || shouldClearResolver()) { | 542 if (!document().isActive() || shouldClearResolver()) { |
| 543 clearResolver(); | 543 clearResolver(); |
| 544 return change; | 544 return; |
| 545 } | 545 } |
| 546 | 546 |
| 547 if (shouldApplyXSLTransform()) { | 547 if (shouldApplyXSLTransform()) { |
| 548 // Processing instruction (XML documents only). | 548 // Processing instruction (XML documents only). |
| 549 // We don't support linking to embedded CSS stylesheets, see <https://bu
gs.webkit.org/show_bug.cgi?id=49281> for discussion. | 549 // We don't support linking to embedded CSS stylesheets, see <https://bu
gs.webkit.org/show_bug.cgi?id=49281> for discussion. |
| 550 // Don't apply XSL transforms to already transformed documents -- <rdar:
//problem/4132806> | 550 // Don't apply XSL transforms to already transformed documents -- <rdar:
//problem/4132806> |
| 551 if (!m_document->parsing() && !m_xslStyleSheet->isLoading()) | 551 if (!m_document->parsing() && !m_xslStyleSheet->isLoading()) |
| 552 m_document->applyXSLTransform(m_xslStyleSheet.get()); | 552 m_document->applyXSLTransform(m_xslStyleSheet.get()); |
| 553 return change; | 553 return; |
| 554 } | 554 } |
| 555 | 555 |
| 556 m_didCalculateResolver = true; | 556 m_didCalculateResolver = true; |
| 557 if (document().didLayoutWithPendingStylesheets() && !hasPendingSheets()) | 557 updateActiveStyleSheets(mode); |
| 558 change.setNeedsRepaint(); | |
| 559 | |
| 560 if (updateActiveStyleSheets(mode)) | |
| 561 change.setNeedsStyleRecalc(); | |
| 562 | |
| 563 return change; | |
| 564 } | 558 } |
| 565 | 559 |
| 566 void StyleEngine::clearFontCache() | 560 void StyleEngine::clearFontCache() |
| 567 { | 561 { |
| 568 // We should not recreate FontSelector. Instead, clear fontFaceCache. | 562 // We should not recreate FontSelector. Instead, clear fontFaceCache. |
| 569 if (m_fontSelector) | 563 if (m_fontSelector) |
| 570 m_fontSelector->fontFaceCache()->clear(); | 564 m_fontSelector->fontFaceCache()->clear(); |
| 571 if (m_resolver) | 565 if (m_resolver) |
| 572 m_resolver->invalidateMatchedPropertiesCache(); | 566 m_resolver->invalidateMatchedPropertiesCache(); |
| 573 } | 567 } |
| (...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 699 visitor->trace(m_documentStyleSheetCollection); | 693 visitor->trace(m_documentStyleSheetCollection); |
| 700 visitor->trace(m_styleSheetCollectionMap); | 694 visitor->trace(m_styleSheetCollectionMap); |
| 701 visitor->trace(m_resolver); | 695 visitor->trace(m_resolver); |
| 702 visitor->trace(m_fontSelector); | 696 visitor->trace(m_fontSelector); |
| 703 visitor->trace(m_textToSheetCache); | 697 visitor->trace(m_textToSheetCache); |
| 704 visitor->trace(m_sheetToTextCache); | 698 visitor->trace(m_sheetToTextCache); |
| 705 CSSFontSelectorClient::trace(visitor); | 699 CSSFontSelectorClient::trace(visitor); |
| 706 } | 700 } |
| 707 | 701 |
| 708 } | 702 } |
| OLD | NEW |