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 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
68 , m_usesSiblingRulesOverride(false) | 68 , m_usesSiblingRulesOverride(false) |
69 , m_usesFirstLineRules(false) | 69 , m_usesFirstLineRules(false) |
70 , m_usesFirstLetterRules(false) | 70 , m_usesFirstLetterRules(false) |
71 , m_usesRemUnits(false) | 71 , m_usesRemUnits(false) |
72 , m_maxDirectAdjacentSelectors(0) | 72 , m_maxDirectAdjacentSelectors(0) |
73 , m_ignorePendingStylesheets(false) | 73 , m_ignorePendingStylesheets(false) |
74 , m_didCalculateResolver(false) | 74 , m_didCalculateResolver(false) |
75 // We don't need to create CSSFontSelector for imported document or | 75 // We don't need to create CSSFontSelector for imported document or |
76 // HTMLTemplateElement's document, because those documents have no frame. | 76 // HTMLTemplateElement's document, because those documents have no frame. |
77 , m_fontSelector(document.frame() ? CSSFontSelector::create(&document) : nul
lptr) | 77 , m_fontSelector(document.frame() ? CSSFontSelector::create(&document) : nul
lptr) |
| 78 , m_xslStyleSheet(nullptr) |
78 { | 79 { |
79 if (m_fontSelector) | 80 if (m_fontSelector) |
80 m_fontSelector->registerForInvalidationCallbacks(this); | 81 m_fontSelector->registerForInvalidationCallbacks(this); |
81 } | 82 } |
82 | 83 |
83 StyleEngine::~StyleEngine() | 84 StyleEngine::~StyleEngine() |
84 { | 85 { |
85 } | 86 } |
86 | 87 |
87 #if !ENABLE(OILPAN) | 88 #if !ENABLE(OILPAN) |
(...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
279 markTreeScopeDirty(treeScope); | 280 markTreeScopeDirty(treeScope); |
280 } | 281 } |
281 | 282 |
282 void StyleEngine::addStyleSheetCandidateNode(Node* node, bool createdByParser) | 283 void StyleEngine::addStyleSheetCandidateNode(Node* node, bool createdByParser) |
283 { | 284 { |
284 if (!node->inDocument()) | 285 if (!node->inDocument()) |
285 return; | 286 return; |
286 | 287 |
287 TreeScope& treeScope = isHTMLStyleElement(*node) ? node->treeScope() : *m_do
cument; | 288 TreeScope& treeScope = isHTMLStyleElement(*node) ? node->treeScope() : *m_do
cument; |
288 ASSERT(isHTMLStyleElement(node) || treeScope == m_document); | 289 ASSERT(isHTMLStyleElement(node) || treeScope == m_document); |
289 | 290 ASSERT(!isXSLStyleSheet(*node)); |
290 TreeScopeStyleSheetCollection* collection = ensureStyleSheetCollectionFor(tr
eeScope); | 291 TreeScopeStyleSheetCollection* collection = ensureStyleSheetCollectionFor(tr
eeScope); |
291 ASSERT(collection); | 292 ASSERT(collection); |
292 collection->addStyleSheetCandidateNode(node, createdByParser); | 293 collection->addStyleSheetCandidateNode(node, createdByParser); |
293 | 294 |
294 markTreeScopeDirty(treeScope); | 295 markTreeScopeDirty(treeScope); |
295 if (treeScope != m_document) | 296 if (treeScope != m_document) |
296 insertTreeScopeInDocumentOrder(m_activeTreeScopes, &treeScope); | 297 insertTreeScopeInDocumentOrder(m_activeTreeScopes, &treeScope); |
297 } | 298 } |
298 | 299 |
299 void StyleEngine::removeStyleSheetCandidateNode(Node* node) | 300 void StyleEngine::removeStyleSheetCandidateNode(Node* node) |
300 { | 301 { |
301 removeStyleSheetCandidateNode(node, 0, *m_document); | 302 removeStyleSheetCandidateNode(node, 0, *m_document); |
302 } | 303 } |
303 | 304 |
304 void StyleEngine::removeStyleSheetCandidateNode(Node* node, ContainerNode* scopi
ngNode, TreeScope& treeScope) | 305 void StyleEngine::removeStyleSheetCandidateNode(Node* node, ContainerNode* scopi
ngNode, TreeScope& treeScope) |
305 { | 306 { |
306 ASSERT(isHTMLStyleElement(node) || treeScope == m_document); | 307 ASSERT(isHTMLStyleElement(node) || treeScope == m_document); |
| 308 ASSERT(!isXSLStyleSheet(*node)); |
307 | 309 |
308 TreeScopeStyleSheetCollection* collection = styleSheetCollectionFor(treeScop
e); | 310 TreeScopeStyleSheetCollection* collection = styleSheetCollectionFor(treeScop
e); |
309 ASSERT(collection); | 311 ASSERT(collection); |
310 collection->removeStyleSheetCandidateNode(node, scopingNode); | 312 collection->removeStyleSheetCandidateNode(node, scopingNode); |
311 | 313 |
312 markTreeScopeDirty(treeScope); | 314 markTreeScopeDirty(treeScope); |
313 m_activeTreeScopes.remove(&treeScope); | 315 m_activeTreeScopes.remove(&treeScope); |
314 } | 316 } |
315 | 317 |
| 318 void StyleEngine::addXSLStyleSheet(ProcessingInstruction* node, bool createdByPa
rser) |
| 319 { |
| 320 if (!node->inDocument()) |
| 321 return; |
| 322 |
| 323 ASSERT(isXSLStyleSheet(*node)); |
| 324 bool needToUpdate = false; |
| 325 if (createdByParser || !m_xslStyleSheet) { |
| 326 needToUpdate = !m_xslStyleSheet; |
| 327 } else { |
| 328 unsigned position = m_xslStyleSheet->compareDocumentPositionInternal(nod
e, Node::TreatShadowTreesAsDisconnected); |
| 329 needToUpdate = position & Node::DOCUMENT_POSITION_FOLLOWING; |
| 330 } |
| 331 |
| 332 if (!needToUpdate) |
| 333 return; |
| 334 |
| 335 markTreeScopeDirty(*m_document); |
| 336 m_xslStyleSheet = node; |
| 337 } |
| 338 |
| 339 void StyleEngine::removeXSLStyleSheet(ProcessingInstruction* node) |
| 340 { |
| 341 ASSERT(isXSLStyleSheet(*node)); |
| 342 if (m_xslStyleSheet != node) |
| 343 return; |
| 344 |
| 345 markTreeScopeDirty(*m_document); |
| 346 m_xslStyleSheet = nullptr; |
| 347 } |
| 348 |
316 void StyleEngine::modifiedStyleSheetCandidateNode(Node* node) | 349 void StyleEngine::modifiedStyleSheetCandidateNode(Node* node) |
317 { | 350 { |
318 if (!node->inDocument()) | 351 if (!node->inDocument()) |
319 return; | 352 return; |
320 | 353 |
321 TreeScope& treeScope = isHTMLStyleElement(*node) ? node->treeScope() : *m_do
cument; | 354 TreeScope& treeScope = isHTMLStyleElement(*node) ? node->treeScope() : *m_do
cument; |
322 ASSERT(isHTMLStyleElement(node) || treeScope == m_document); | 355 ASSERT(isHTMLStyleElement(node) || treeScope == m_document); |
323 markTreeScopeDirty(treeScope); | 356 markTreeScopeDirty(treeScope); |
324 } | 357 } |
325 | 358 |
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
480 void StyleEngine::didDetach() | 513 void StyleEngine::didDetach() |
481 { | 514 { |
482 clearResolver(); | 515 clearResolver(); |
483 } | 516 } |
484 | 517 |
485 bool StyleEngine::shouldClearResolver() const | 518 bool StyleEngine::shouldClearResolver() const |
486 { | 519 { |
487 return !m_didCalculateResolver && !haveStylesheetsLoaded(); | 520 return !m_didCalculateResolver && !haveStylesheetsLoaded(); |
488 } | 521 } |
489 | 522 |
| 523 bool StyleEngine::shouldApplyXSLTransform() const |
| 524 { |
| 525 if (!RuntimeEnabledFeatures::xsltEnabled()) |
| 526 return false; |
| 527 return m_xslStyleSheet && !m_document->transformSourceDocument(); |
| 528 } |
| 529 |
490 StyleResolverChange StyleEngine::resolverChanged(StyleResolverUpdateMode mode) | 530 StyleResolverChange StyleEngine::resolverChanged(StyleResolverUpdateMode mode) |
491 { | 531 { |
492 StyleResolverChange change; | 532 StyleResolverChange change; |
493 | 533 |
494 if (!isMaster()) { | 534 if (!isMaster()) { |
495 if (Document* master = this->master()) | 535 if (Document* master = this->master()) |
496 master->styleResolverChanged(mode); | 536 master->styleResolverChanged(mode); |
497 return change; | 537 return change; |
498 } | 538 } |
499 | 539 |
500 // 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 |
501 // and haven't calculated the style selector for the first time. | 541 // and haven't calculated the style selector for the first time. |
502 if (!document().isActive() || shouldClearResolver()) { | 542 if (!document().isActive() || shouldClearResolver()) { |
503 clearResolver(); | 543 clearResolver(); |
504 return change; | 544 return change; |
505 } | 545 } |
506 | 546 |
| 547 if (shouldApplyXSLTransform()) { |
| 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. |
| 550 // Don't apply XSL transforms to already transformed documents -- <rdar:
//problem/4132806> |
| 551 if (!m_document->parsing() && !m_xslStyleSheet->isLoading()) |
| 552 m_document->applyXSLTransform(m_xslStyleSheet.get()); |
| 553 return change; |
| 554 } |
| 555 |
507 m_didCalculateResolver = true; | 556 m_didCalculateResolver = true; |
508 if (document().didLayoutWithPendingStylesheets() && !hasPendingSheets()) | 557 if (document().didLayoutWithPendingStylesheets() && !hasPendingSheets()) |
509 change.setNeedsRepaint(); | 558 change.setNeedsRepaint(); |
510 | 559 |
511 if (updateActiveStyleSheets(mode)) | 560 if (updateActiveStyleSheets(mode)) |
512 change.setNeedsStyleRecalc(); | 561 change.setNeedsStyleRecalc(); |
513 | 562 |
514 return change; | 563 return change; |
515 } | 564 } |
516 | 565 |
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
646 visitor->trace(m_documentStyleSheetCollection); | 695 visitor->trace(m_documentStyleSheetCollection); |
647 visitor->trace(m_styleSheetCollectionMap); | 696 visitor->trace(m_styleSheetCollectionMap); |
648 visitor->trace(m_resolver); | 697 visitor->trace(m_resolver); |
649 visitor->trace(m_fontSelector); | 698 visitor->trace(m_fontSelector); |
650 visitor->trace(m_textToSheetCache); | 699 visitor->trace(m_textToSheetCache); |
651 visitor->trace(m_sheetToTextCache); | 700 visitor->trace(m_sheetToTextCache); |
652 CSSFontSelectorClient::trace(visitor); | 701 CSSFontSelectorClient::trace(visitor); |
653 } | 702 } |
654 | 703 |
655 } | 704 } |
OLD | NEW |