| 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 static bool isStyleElement(Node& node) | 81 static bool isStyleElement(Node& node) |
| (...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 288 markTreeScopeDirty(treeScope); | 287 markTreeScopeDirty(treeScope); |
| 289 } | 288 } |
| 290 | 289 |
| 291 void StyleEngine::addStyleSheetCandidateNode(Node* node, bool createdByParser) | 290 void StyleEngine::addStyleSheetCandidateNode(Node* node, bool createdByParser) |
| 292 { | 291 { |
| 293 if (!node->inDocument()) | 292 if (!node->inDocument()) |
| 294 return; | 293 return; |
| 295 | 294 |
| 296 TreeScope& treeScope = isStyleElement(*node) ? node->treeScope() : *m_docume
nt; | 295 TreeScope& treeScope = isStyleElement(*node) ? node->treeScope() : *m_docume
nt; |
| 297 ASSERT(isStyleElement(*node) || treeScope == m_document); | 296 ASSERT(isStyleElement(*node) || treeScope == m_document); |
| 298 ASSERT(!isXSLStyleSheet(*node)); | |
| 299 TreeScopeStyleSheetCollection* collection = ensureStyleSheetCollectionFor(tr
eeScope); | 297 TreeScopeStyleSheetCollection* collection = ensureStyleSheetCollectionFor(tr
eeScope); |
| 300 ASSERT(collection); | 298 ASSERT(collection); |
| 301 collection->addStyleSheetCandidateNode(node, createdByParser); | 299 collection->addStyleSheetCandidateNode(node, createdByParser); |
| 302 | 300 |
| 303 markTreeScopeDirty(treeScope); | 301 markTreeScopeDirty(treeScope); |
| 304 if (treeScope != m_document) | 302 if (treeScope != m_document) |
| 305 insertTreeScopeInDocumentOrder(m_activeTreeScopes, &treeScope); | 303 insertTreeScopeInDocumentOrder(m_activeTreeScopes, &treeScope); |
| 306 } | 304 } |
| 307 | 305 |
| 308 void StyleEngine::removeStyleSheetCandidateNode(Node* node) | 306 void StyleEngine::removeStyleSheetCandidateNode(Node* node) |
| 309 { | 307 { |
| 310 removeStyleSheetCandidateNode(node, *m_document); | 308 removeStyleSheetCandidateNode(node, *m_document); |
| 311 } | 309 } |
| 312 | 310 |
| 313 void StyleEngine::removeStyleSheetCandidateNode(Node* node, TreeScope& treeScope
) | 311 void StyleEngine::removeStyleSheetCandidateNode(Node* node, TreeScope& treeScope
) |
| 314 { | 312 { |
| 315 ASSERT(isStyleElement(*node) || treeScope == m_document); | 313 ASSERT(isStyleElement(*node) || treeScope == m_document); |
| 316 ASSERT(!isXSLStyleSheet(*node)); | |
| 317 | 314 |
| 318 TreeScopeStyleSheetCollection* collection = styleSheetCollectionFor(treeScop
e); | 315 TreeScopeStyleSheetCollection* collection = styleSheetCollectionFor(treeScop
e); |
| 319 ASSERT(collection); | 316 ASSERT(collection); |
| 320 collection->removeStyleSheetCandidateNode(node); | 317 collection->removeStyleSheetCandidateNode(node); |
| 321 | 318 |
| 322 markTreeScopeDirty(treeScope); | 319 markTreeScopeDirty(treeScope); |
| 323 m_activeTreeScopes.remove(&treeScope); | 320 m_activeTreeScopes.remove(&treeScope); |
| 324 } | 321 } |
| 325 | 322 |
| 326 void StyleEngine::addXSLStyleSheet(ProcessingInstruction* node, bool createdByPa
rser) | |
| 327 { | |
| 328 if (!node->inDocument()) | |
| 329 return; | |
| 330 | |
| 331 ASSERT(isXSLStyleSheet(*node)); | |
| 332 bool needToUpdate = false; | |
| 333 if (createdByParser || !m_xslStyleSheet) { | |
| 334 needToUpdate = !m_xslStyleSheet; | |
| 335 } else { | |
| 336 unsigned position = m_xslStyleSheet->compareDocumentPosition(node, Node:
:TreatShadowTreesAsDisconnected); | |
| 337 needToUpdate = position & Node::DOCUMENT_POSITION_FOLLOWING; | |
| 338 } | |
| 339 | |
| 340 if (!needToUpdate) | |
| 341 return; | |
| 342 | |
| 343 markTreeScopeDirty(*m_document); | |
| 344 m_xslStyleSheet = node; | |
| 345 } | |
| 346 | |
| 347 void StyleEngine::removeXSLStyleSheet(ProcessingInstruction* node) | |
| 348 { | |
| 349 ASSERT(isXSLStyleSheet(*node)); | |
| 350 if (m_xslStyleSheet != node) | |
| 351 return; | |
| 352 | |
| 353 markTreeScopeDirty(*m_document); | |
| 354 m_xslStyleSheet = nullptr; | |
| 355 } | |
| 356 | |
| 357 void StyleEngine::modifiedStyleSheetCandidateNode(Node* node) | 323 void StyleEngine::modifiedStyleSheetCandidateNode(Node* node) |
| 358 { | 324 { |
| 359 if (!node->inDocument()) | 325 if (!node->inDocument()) |
| 360 return; | 326 return; |
| 361 | 327 |
| 362 TreeScope& treeScope = isStyleElement(*node) ? node->treeScope() : *m_docume
nt; | 328 TreeScope& treeScope = isStyleElement(*node) ? node->treeScope() : *m_docume
nt; |
| 363 ASSERT(isStyleElement(*node) || treeScope == m_document); | 329 ASSERT(isStyleElement(*node) || treeScope == m_document); |
| 364 markTreeScopeDirty(treeScope); | 330 markTreeScopeDirty(treeScope); |
| 365 } | 331 } |
| 366 | 332 |
| (...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 528 void StyleEngine::didDetach() | 494 void StyleEngine::didDetach() |
| 529 { | 495 { |
| 530 clearResolver(); | 496 clearResolver(); |
| 531 } | 497 } |
| 532 | 498 |
| 533 bool StyleEngine::shouldClearResolver() const | 499 bool StyleEngine::shouldClearResolver() const |
| 534 { | 500 { |
| 535 return !m_didCalculateResolver && !haveStylesheetsLoaded(); | 501 return !m_didCalculateResolver && !haveStylesheetsLoaded(); |
| 536 } | 502 } |
| 537 | 503 |
| 538 bool StyleEngine::shouldApplyXSLTransform() const | |
| 539 { | |
| 540 if (!RuntimeEnabledFeatures::xsltEnabled()) | |
| 541 return false; | |
| 542 return m_xslStyleSheet && !m_document->transformSourceDocument(); | |
| 543 } | |
| 544 | |
| 545 void StyleEngine::resolverChanged(StyleResolverUpdateMode mode) | 504 void StyleEngine::resolverChanged(StyleResolverUpdateMode mode) |
| 546 { | 505 { |
| 547 if (!isMaster()) { | 506 if (!isMaster()) { |
| 548 if (Document* master = this->master()) | 507 if (Document* master = this->master()) |
| 549 master->styleResolverChanged(mode); | 508 master->styleResolverChanged(mode); |
| 550 return; | 509 return; |
| 551 } | 510 } |
| 552 | 511 |
| 553 // Don't bother updating, since we haven't loaded all our style info yet | 512 // Don't bother updating, since we haven't loaded all our style info yet |
| 554 // and haven't calculated the style selector for the first time. | 513 // and haven't calculated the style selector for the first time. |
| 555 if (!document().isActive() || shouldClearResolver()) { | 514 if (!document().isActive() || shouldClearResolver()) { |
| 556 clearResolver(); | 515 clearResolver(); |
| 557 return; | 516 return; |
| 558 } | 517 } |
| 559 | 518 |
| 560 if (shouldApplyXSLTransform()) { | |
| 561 // Processing instruction (XML documents only). | |
| 562 // We don't support linking to embedded CSS stylesheets, see <https://bu
gs.webkit.org/show_bug.cgi?id=49281> for discussion. | |
| 563 // Don't apply XSL transforms to already transformed documents -- <rdar:
//problem/4132806> | |
| 564 if (!m_document->parsing() && !m_xslStyleSheet->isLoading()) | |
| 565 m_document->applyXSLTransform(m_xslStyleSheet.get()); | |
| 566 return; | |
| 567 } | |
| 568 | |
| 569 m_didCalculateResolver = true; | 519 m_didCalculateResolver = true; |
| 570 updateActiveStyleSheets(mode); | 520 updateActiveStyleSheets(mode); |
| 571 } | 521 } |
| 572 | 522 |
| 573 void StyleEngine::clearFontCache() | 523 void StyleEngine::clearFontCache() |
| 574 { | 524 { |
| 575 if (m_fontSelector) | 525 if (m_fontSelector) |
| 576 m_fontSelector->fontFaceCache()->clearCSSConnected(); | 526 m_fontSelector->fontFaceCache()->clearCSSConnected(); |
| 577 if (m_resolver) | 527 if (m_resolver) |
| 578 m_resolver->invalidateMatchedPropertiesCache(); | 528 m_resolver->invalidateMatchedPropertiesCache(); |
| (...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 710 visitor->trace(m_document); | 660 visitor->trace(m_document); |
| 711 visitor->trace(m_injectedAuthorStyleSheets); | 661 visitor->trace(m_injectedAuthorStyleSheets); |
| 712 visitor->trace(m_authorStyleSheets); | 662 visitor->trace(m_authorStyleSheets); |
| 713 visitor->trace(m_documentStyleSheetCollection); | 663 visitor->trace(m_documentStyleSheetCollection); |
| 714 visitor->trace(m_styleSheetCollectionMap); | 664 visitor->trace(m_styleSheetCollectionMap); |
| 715 visitor->trace(m_scopedStyleResolvers); | 665 visitor->trace(m_scopedStyleResolvers); |
| 716 visitor->trace(m_resolver); | 666 visitor->trace(m_resolver); |
| 717 visitor->trace(m_fontSelector); | 667 visitor->trace(m_fontSelector); |
| 718 visitor->trace(m_textToSheetCache); | 668 visitor->trace(m_textToSheetCache); |
| 719 visitor->trace(m_sheetToTextCache); | 669 visitor->trace(m_sheetToTextCache); |
| 720 visitor->trace(m_xslStyleSheet); | |
| 721 #endif | 670 #endif |
| 722 CSSFontSelectorClient::trace(visitor); | 671 CSSFontSelectorClient::trace(visitor); |
| 723 } | 672 } |
| 724 | 673 |
| 725 } | 674 } |
| OLD | NEW |