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 233 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
316 ASSERT(!isXSLStyleSheet(*node)); | 315 ASSERT(!isXSLStyleSheet(*node)); |
317 | 316 |
318 TreeScopeStyleSheetCollection* collection = styleSheetCollectionFor(treeScop
e); | 317 TreeScopeStyleSheetCollection* collection = styleSheetCollectionFor(treeScop
e); |
319 ASSERT(collection); | 318 ASSERT(collection); |
320 collection->removeStyleSheetCandidateNode(node); | 319 collection->removeStyleSheetCandidateNode(node); |
321 | 320 |
322 markTreeScopeDirty(treeScope); | 321 markTreeScopeDirty(treeScope); |
323 m_activeTreeScopes.remove(&treeScope); | 322 m_activeTreeScopes.remove(&treeScope); |
324 } | 323 } |
325 | 324 |
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) | 325 void StyleEngine::modifiedStyleSheetCandidateNode(Node* node) |
358 { | 326 { |
359 if (!node->inDocument()) | 327 if (!node->inDocument()) |
360 return; | 328 return; |
361 | 329 |
362 TreeScope& treeScope = isStyleElement(*node) ? node->treeScope() : *m_docume
nt; | 330 TreeScope& treeScope = isStyleElement(*node) ? node->treeScope() : *m_docume
nt; |
363 ASSERT(isStyleElement(*node) || treeScope == m_document); | 331 ASSERT(isStyleElement(*node) || treeScope == m_document); |
364 markTreeScopeDirty(treeScope); | 332 markTreeScopeDirty(treeScope); |
365 } | 333 } |
366 | 334 |
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
528 void StyleEngine::didDetach() | 496 void StyleEngine::didDetach() |
529 { | 497 { |
530 clearResolver(); | 498 clearResolver(); |
531 } | 499 } |
532 | 500 |
533 bool StyleEngine::shouldClearResolver() const | 501 bool StyleEngine::shouldClearResolver() const |
534 { | 502 { |
535 return !m_didCalculateResolver && !haveStylesheetsLoaded(); | 503 return !m_didCalculateResolver && !haveStylesheetsLoaded(); |
536 } | 504 } |
537 | 505 |
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) | 506 void StyleEngine::resolverChanged(StyleResolverUpdateMode mode) |
546 { | 507 { |
547 if (!isMaster()) { | 508 if (!isMaster()) { |
548 if (Document* master = this->master()) | 509 if (Document* master = this->master()) |
549 master->styleResolverChanged(mode); | 510 master->styleResolverChanged(mode); |
550 return; | 511 return; |
551 } | 512 } |
552 | 513 |
553 // Don't bother updating, since we haven't loaded all our style info yet | 514 // 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. | 515 // and haven't calculated the style selector for the first time. |
555 if (!document().isActive() || shouldClearResolver()) { | 516 if (!document().isActive() || shouldClearResolver()) { |
556 clearResolver(); | 517 clearResolver(); |
557 return; | 518 return; |
558 } | 519 } |
559 | 520 |
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; | 521 m_didCalculateResolver = true; |
570 updateActiveStyleSheets(mode); | 522 updateActiveStyleSheets(mode); |
571 } | 523 } |
572 | 524 |
573 void StyleEngine::clearFontCache() | 525 void StyleEngine::clearFontCache() |
574 { | 526 { |
575 if (m_fontSelector) | 527 if (m_fontSelector) |
576 m_fontSelector->fontFaceCache()->clearCSSConnected(); | 528 m_fontSelector->fontFaceCache()->clearCSSConnected(); |
577 if (m_resolver) | 529 if (m_resolver) |
578 m_resolver->invalidateMatchedPropertiesCache(); | 530 m_resolver->invalidateMatchedPropertiesCache(); |
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
710 visitor->trace(m_document); | 662 visitor->trace(m_document); |
711 visitor->trace(m_injectedAuthorStyleSheets); | 663 visitor->trace(m_injectedAuthorStyleSheets); |
712 visitor->trace(m_authorStyleSheets); | 664 visitor->trace(m_authorStyleSheets); |
713 visitor->trace(m_documentStyleSheetCollection); | 665 visitor->trace(m_documentStyleSheetCollection); |
714 visitor->trace(m_styleSheetCollectionMap); | 666 visitor->trace(m_styleSheetCollectionMap); |
715 visitor->trace(m_scopedStyleResolvers); | 667 visitor->trace(m_scopedStyleResolvers); |
716 visitor->trace(m_resolver); | 668 visitor->trace(m_resolver); |
717 visitor->trace(m_fontSelector); | 669 visitor->trace(m_fontSelector); |
718 visitor->trace(m_textToSheetCache); | 670 visitor->trace(m_textToSheetCache); |
719 visitor->trace(m_sheetToTextCache); | 671 visitor->trace(m_sheetToTextCache); |
720 visitor->trace(m_xslStyleSheet); | |
721 #endif | 672 #endif |
722 CSSFontSelectorClient::trace(visitor); | 673 CSSFontSelectorClient::trace(visitor); |
723 } | 674 } |
724 | 675 |
725 } | 676 } |
OLD | NEW |