| 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 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 62 , m_usesSiblingRulesOverride(false) | 62 , m_usesSiblingRulesOverride(false) |
| 63 , m_usesFirstLineRules(false) | 63 , m_usesFirstLineRules(false) |
| 64 , m_usesFirstLetterRules(false) | 64 , m_usesFirstLetterRules(false) |
| 65 , m_usesRemUnits(false) | 65 , m_usesRemUnits(false) |
| 66 , m_maxDirectAdjacentSelectors(0) | 66 , m_maxDirectAdjacentSelectors(0) |
| 67 , m_ignorePendingStylesheets(false) | 67 , m_ignorePendingStylesheets(false) |
| 68 , m_didCalculateResolver(false) | 68 , m_didCalculateResolver(false) |
| 69 // We don't need to create CSSFontSelector for imported document or | 69 // We don't need to create CSSFontSelector for imported document or |
| 70 // HTMLTemplateElement's document, because those documents have no frame. | 70 // HTMLTemplateElement's document, because those documents have no frame. |
| 71 , m_fontSelector(document.frame() ? CSSFontSelector::create(&document) : nul
lptr) | 71 , m_fontSelector(document.frame() ? CSSFontSelector::create(&document) : nul
lptr) |
| 72 , m_xslStyleSheet(nullptr) | |
| 73 { | 72 { |
| 74 if (m_fontSelector) | 73 if (m_fontSelector) |
| 75 m_fontSelector->registerForInvalidationCallbacks(this); | 74 m_fontSelector->registerForInvalidationCallbacks(this); |
| 76 } | 75 } |
| 77 | 76 |
| 78 StyleEngine::~StyleEngine() | 77 StyleEngine::~StyleEngine() |
| 79 { | 78 { |
| 80 } | 79 } |
| 81 | 80 |
| 82 #if !ENABLE(OILPAN) | 81 #if !ENABLE(OILPAN) |
| (...skipping 222 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 305 ASSERT(!isXSLStyleSheet(*node)); | 304 ASSERT(!isXSLStyleSheet(*node)); |
| 306 | 305 |
| 307 TreeScopeStyleSheetCollection* collection = styleSheetCollectionFor(treeScop
e); | 306 TreeScopeStyleSheetCollection* collection = styleSheetCollectionFor(treeScop
e); |
| 308 ASSERT(collection); | 307 ASSERT(collection); |
| 309 collection->removeStyleSheetCandidateNode(node, scopingNode); | 308 collection->removeStyleSheetCandidateNode(node, scopingNode); |
| 310 | 309 |
| 311 markTreeScopeDirty(treeScope); | 310 markTreeScopeDirty(treeScope); |
| 312 m_activeTreeScopes.remove(&treeScope); | 311 m_activeTreeScopes.remove(&treeScope); |
| 313 } | 312 } |
| 314 | 313 |
| 315 void StyleEngine::addXSLStyleSheet(ProcessingInstruction* node, bool createdByPa
rser) | |
| 316 { | |
| 317 if (!node->inDocument()) | |
| 318 return; | |
| 319 | |
| 320 ASSERT(isXSLStyleSheet(*node)); | |
| 321 bool needToUpdate = false; | |
| 322 if (createdByParser || !m_xslStyleSheet) { | |
| 323 needToUpdate = !m_xslStyleSheet; | |
| 324 } else { | |
| 325 unsigned position = m_xslStyleSheet->compareDocumentPosition(node, Node:
:TreatShadowTreesAsDisconnected); | |
| 326 needToUpdate = position & Node::DOCUMENT_POSITION_FOLLOWING; | |
| 327 } | |
| 328 | |
| 329 if (!needToUpdate) | |
| 330 return; | |
| 331 | |
| 332 markTreeScopeDirty(*m_document); | |
| 333 m_xslStyleSheet = node; | |
| 334 } | |
| 335 | |
| 336 void StyleEngine::removeXSLStyleSheet(ProcessingInstruction* node) | |
| 337 { | |
| 338 ASSERT(isXSLStyleSheet(*node)); | |
| 339 if (m_xslStyleSheet != node) | |
| 340 return; | |
| 341 | |
| 342 markTreeScopeDirty(*m_document); | |
| 343 m_xslStyleSheet = nullptr; | |
| 344 } | |
| 345 | |
| 346 void StyleEngine::modifiedStyleSheetCandidateNode(Node* node) | 314 void StyleEngine::modifiedStyleSheetCandidateNode(Node* node) |
| 347 { | 315 { |
| 348 if (!node->inDocument()) | 316 if (!node->inDocument()) |
| 349 return; | 317 return; |
| 350 | 318 |
| 351 TreeScope& treeScope = isHTMLStyleElement(*node) ? node->treeScope() : *m_do
cument; | 319 TreeScope& treeScope = isHTMLStyleElement(*node) ? node->treeScope() : *m_do
cument; |
| 352 ASSERT(isHTMLStyleElement(node) || treeScope == m_document); | 320 ASSERT(isHTMLStyleElement(node) || treeScope == m_document); |
| 353 markTreeScopeDirty(treeScope); | 321 markTreeScopeDirty(treeScope); |
| 354 } | 322 } |
| 355 | 323 |
| (...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 517 void StyleEngine::didDetach() | 485 void StyleEngine::didDetach() |
| 518 { | 486 { |
| 519 clearResolver(); | 487 clearResolver(); |
| 520 } | 488 } |
| 521 | 489 |
| 522 bool StyleEngine::shouldClearResolver() const | 490 bool StyleEngine::shouldClearResolver() const |
| 523 { | 491 { |
| 524 return !m_didCalculateResolver && !haveStylesheetsLoaded(); | 492 return !m_didCalculateResolver && !haveStylesheetsLoaded(); |
| 525 } | 493 } |
| 526 | 494 |
| 527 bool StyleEngine::shouldApplyXSLTransform() const | |
| 528 { | |
| 529 if (!RuntimeEnabledFeatures::xsltEnabled()) | |
| 530 return false; | |
| 531 return m_xslStyleSheet && !m_document->transformSourceDocument(); | |
| 532 } | |
| 533 | |
| 534 void StyleEngine::resolverChanged(StyleResolverUpdateMode mode) | 495 void StyleEngine::resolverChanged(StyleResolverUpdateMode mode) |
| 535 { | 496 { |
| 536 if (!isMaster()) { | 497 if (!isMaster()) { |
| 537 if (Document* master = this->master()) | 498 if (Document* master = this->master()) |
| 538 master->styleResolverChanged(mode); | 499 master->styleResolverChanged(mode); |
| 539 return; | 500 return; |
| 540 } | 501 } |
| 541 | 502 |
| 542 // Don't bother updating, since we haven't loaded all our style info yet | 503 // Don't bother updating, since we haven't loaded all our style info yet |
| 543 // and haven't calculated the style selector for the first time. | 504 // and haven't calculated the style selector for the first time. |
| 544 if (!document().isActive() || shouldClearResolver()) { | 505 if (!document().isActive() || shouldClearResolver()) { |
| 545 clearResolver(); | 506 clearResolver(); |
| 546 return; | 507 return; |
| 547 } | 508 } |
| 548 | 509 |
| 549 if (shouldApplyXSLTransform()) { | |
| 550 // Processing instruction (XML documents only). | |
| 551 // We don't support linking to embedded CSS stylesheets, see <https://bu
gs.webkit.org/show_bug.cgi?id=49281> for discussion. | |
| 552 // Don't apply XSL transforms to already transformed documents -- <rdar:
//problem/4132806> | |
| 553 if (!m_document->parsing() && !m_xslStyleSheet->isLoading()) | |
| 554 m_document->applyXSLTransform(m_xslStyleSheet.get()); | |
| 555 return; | |
| 556 } | |
| 557 | |
| 558 m_didCalculateResolver = true; | 510 m_didCalculateResolver = true; |
| 559 updateActiveStyleSheets(mode); | 511 updateActiveStyleSheets(mode); |
| 560 } | 512 } |
| 561 | 513 |
| 562 void StyleEngine::clearFontCache() | 514 void StyleEngine::clearFontCache() |
| 563 { | 515 { |
| 564 if (m_fontSelector) | 516 if (m_fontSelector) |
| 565 m_fontSelector->fontFaceCache()->clearCSSConnected(); | 517 m_fontSelector->fontFaceCache()->clearCSSConnected(); |
| 566 if (m_resolver) | 518 if (m_resolver) |
| 567 m_resolver->invalidateMatchedPropertiesCache(); | 519 m_resolver->invalidateMatchedPropertiesCache(); |
| (...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 699 visitor->trace(m_document); | 651 visitor->trace(m_document); |
| 700 visitor->trace(m_injectedAuthorStyleSheets); | 652 visitor->trace(m_injectedAuthorStyleSheets); |
| 701 visitor->trace(m_authorStyleSheets); | 653 visitor->trace(m_authorStyleSheets); |
| 702 visitor->trace(m_documentStyleSheetCollection); | 654 visitor->trace(m_documentStyleSheetCollection); |
| 703 visitor->trace(m_styleSheetCollectionMap); | 655 visitor->trace(m_styleSheetCollectionMap); |
| 704 visitor->trace(m_scopedStyleResolvers); | 656 visitor->trace(m_scopedStyleResolvers); |
| 705 visitor->trace(m_resolver); | 657 visitor->trace(m_resolver); |
| 706 visitor->trace(m_fontSelector); | 658 visitor->trace(m_fontSelector); |
| 707 visitor->trace(m_textToSheetCache); | 659 visitor->trace(m_textToSheetCache); |
| 708 visitor->trace(m_sheetToTextCache); | 660 visitor->trace(m_sheetToTextCache); |
| 709 visitor->trace(m_xslStyleSheet); | |
| 710 #endif | 661 #endif |
| 711 CSSFontSelectorClient::trace(visitor); | 662 CSSFontSelectorClient::trace(visitor); |
| 712 } | 663 } |
| 713 | 664 |
| 714 } | 665 } |
| OLD | NEW |