| 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 } | 80 } |
| 80 | 81 |
| 81 StyleEngine::~StyleEngine() | 82 StyleEngine::~StyleEngine() |
| 82 { | 83 { |
| 83 } | 84 } |
| 84 | 85 |
| 85 #if !ENABLE(OILPAN) | 86 #if !ENABLE(OILPAN) |
| 86 void StyleEngine::detachFromDocument() | 87 void StyleEngine::detachFromDocument() |
| 87 { | 88 { |
| (...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 278 markTreeScopeDirty(treeScope); | 279 markTreeScopeDirty(treeScope); |
| 279 } | 280 } |
| 280 | 281 |
| 281 void StyleEngine::addStyleSheetCandidateNode(Node* node, bool createdByParser) | 282 void StyleEngine::addStyleSheetCandidateNode(Node* node, bool createdByParser) |
| 282 { | 283 { |
| 283 if (!node->inDocument()) | 284 if (!node->inDocument()) |
| 284 return; | 285 return; |
| 285 | 286 |
| 286 TreeScope& treeScope = isHTMLStyleElement(*node) ? node->treeScope() : *m_do
cument; | 287 TreeScope& treeScope = isHTMLStyleElement(*node) ? node->treeScope() : *m_do
cument; |
| 287 ASSERT(isHTMLStyleElement(node) || treeScope == m_document); | 288 ASSERT(isHTMLStyleElement(node) || treeScope == m_document); |
| 288 | 289 ASSERT(!isXSLStyleSheet(node)); |
| 289 TreeScopeStyleSheetCollection* collection = ensureStyleSheetCollectionFor(tr
eeScope); | 290 TreeScopeStyleSheetCollection* collection = ensureStyleSheetCollectionFor(tr
eeScope); |
| 290 ASSERT(collection); | 291 ASSERT(collection); |
| 291 collection->addStyleSheetCandidateNode(node, createdByParser); | 292 collection->addStyleSheetCandidateNode(node, createdByParser); |
| 292 | 293 |
| 293 markTreeScopeDirty(treeScope); | 294 markTreeScopeDirty(treeScope); |
| 294 if (treeScope != m_document) | 295 if (treeScope != m_document) |
| 295 insertTreeScopeInDocumentOrder(m_activeTreeScopes, &treeScope); | 296 insertTreeScopeInDocumentOrder(m_activeTreeScopes, &treeScope); |
| 296 } | 297 } |
| 297 | 298 |
| 298 void StyleEngine::removeStyleSheetCandidateNode(Node* node) | 299 void StyleEngine::removeStyleSheetCandidateNode(Node* node) |
| 299 { | 300 { |
| 300 removeStyleSheetCandidateNode(node, 0, *m_document); | 301 removeStyleSheetCandidateNode(node, 0, *m_document); |
| 301 } | 302 } |
| 302 | 303 |
| 303 void StyleEngine::removeStyleSheetCandidateNode(Node* node, ContainerNode* scopi
ngNode, TreeScope& treeScope) | 304 void StyleEngine::removeStyleSheetCandidateNode(Node* node, ContainerNode* scopi
ngNode, TreeScope& treeScope) |
| 304 { | 305 { |
| 305 ASSERT(isHTMLStyleElement(node) || treeScope == m_document); | 306 ASSERT(isHTMLStyleElement(node) || treeScope == m_document); |
| 307 ASSERT(!isXSLStyleSheet(node)); |
| 306 | 308 |
| 307 TreeScopeStyleSheetCollection* collection = styleSheetCollectionFor(treeScop
e); | 309 TreeScopeStyleSheetCollection* collection = styleSheetCollectionFor(treeScop
e); |
| 308 ASSERT(collection); | 310 ASSERT(collection); |
| 309 collection->removeStyleSheetCandidateNode(node, scopingNode); | 311 collection->removeStyleSheetCandidateNode(node, scopingNode); |
| 310 | 312 |
| 311 markTreeScopeDirty(treeScope); | 313 markTreeScopeDirty(treeScope); |
| 312 m_activeTreeScopes.remove(&treeScope); | 314 m_activeTreeScopes.remove(&treeScope); |
| 313 } | 315 } |
| 314 | 316 |
| 317 void StyleEngine::addXSLStyleSheet(ProcessingInstruction* node, bool createdByPa
rser) |
| 318 { |
| 319 if (!node->inDocument()) |
| 320 return; |
| 321 |
| 322 ASSERT(isXSLStyleSheet(node)); |
| 323 bool needToUpdate = false; |
| 324 if (createdByParser || !m_xslStyleSheet) { |
| 325 needToUpdate = !m_xslStyleSheet; |
| 326 } else { |
| 327 unsigned position = m_xslStyleSheet->compareDocumentPositionInternal(nod
e, Node::TreatShadowTreesAsDisconnected); |
| 328 needToUpdate = position & Node::DOCUMENT_POSITION_FOLLOWING; |
| 329 } |
| 330 |
| 331 if (!needToUpdate) |
| 332 return; |
| 333 |
| 334 markTreeScopeDirty(*m_document); |
| 335 m_xslStyleSheet = node; |
| 336 } |
| 337 |
| 338 void StyleEngine::removeXSLStyleSheet(ProcessingInstruction* node) |
| 339 { |
| 340 ASSERT(isXSLStyleSheet(node)); |
| 341 if (m_xslStyleSheet != node) |
| 342 return; |
| 343 |
| 344 markTreeScopeDirty(*m_document); |
| 345 m_xslStyleSheet = nullptr; |
| 346 } |
| 347 |
| 315 void StyleEngine::modifiedStyleSheetCandidateNode(Node* node) | 348 void StyleEngine::modifiedStyleSheetCandidateNode(Node* node) |
| 316 { | 349 { |
| 317 if (!node->inDocument()) | 350 if (!node->inDocument()) |
| 318 return; | 351 return; |
| 319 | 352 |
| 320 TreeScope& treeScope = isHTMLStyleElement(*node) ? node->treeScope() : *m_do
cument; | 353 TreeScope& treeScope = isHTMLStyleElement(*node) ? node->treeScope() : *m_do
cument; |
| 321 ASSERT(isHTMLStyleElement(node) || treeScope == m_document); | 354 ASSERT(isHTMLStyleElement(node) || treeScope == m_document); |
| 322 markTreeScopeDirty(treeScope); | 355 markTreeScopeDirty(treeScope); |
| 323 } | 356 } |
| 324 | 357 |
| (...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 486 void StyleEngine::didDetach() | 519 void StyleEngine::didDetach() |
| 487 { | 520 { |
| 488 clearResolver(); | 521 clearResolver(); |
| 489 } | 522 } |
| 490 | 523 |
| 491 bool StyleEngine::shouldClearResolver() const | 524 bool StyleEngine::shouldClearResolver() const |
| 492 { | 525 { |
| 493 return !m_didCalculateResolver && !haveStylesheetsLoaded(); | 526 return !m_didCalculateResolver && !haveStylesheetsLoaded(); |
| 494 } | 527 } |
| 495 | 528 |
| 529 bool StyleEngine::shouldApplyXSLTransform() const |
| 530 { |
| 531 if (!RuntimeEnabledFeatures::xsltEnabled()) |
| 532 return false; |
| 533 return m_xslStyleSheet && !m_document->transformSourceDocument(); |
| 534 } |
| 535 |
| 496 StyleResolverChange StyleEngine::resolverChanged(StyleResolverUpdateMode mode) | 536 StyleResolverChange StyleEngine::resolverChanged(StyleResolverUpdateMode mode) |
| 497 { | 537 { |
| 498 StyleResolverChange change; | 538 StyleResolverChange change; |
| 499 | 539 |
| 500 if (!isMaster()) { | 540 if (!isMaster()) { |
| 501 if (Document* master = this->master()) | 541 if (Document* master = this->master()) |
| 502 master->styleResolverChanged(mode); | 542 master->styleResolverChanged(mode); |
| 503 return change; | 543 return change; |
| 504 } | 544 } |
| 505 | 545 |
| 506 // Don't bother updating, since we haven't loaded all our style info yet | 546 // Don't bother updating, since we haven't loaded all our style info yet |
| 507 // and haven't calculated the style selector for the first time. | 547 // and haven't calculated the style selector for the first time. |
| 508 if (!document().isActive() || shouldClearResolver()) { | 548 if (!document().isActive() || shouldClearResolver()) { |
| 509 clearResolver(); | 549 clearResolver(); |
| 510 return change; | 550 return change; |
| 511 } | 551 } |
| 512 | 552 |
| 553 if (shouldApplyXSLTransform()) { |
| 554 // Processing instruction (XML documents only). |
| 555 // We don't support linking to embedded CSS stylesheets, see <https://bu
gs.webkit.org/show_bug.cgi?id=49281> for discussion. |
| 556 // Don't apply XSL transforms to already transformed documents -- <rdar:
//problem/4132806> |
| 557 if (!m_document->parsing() && !m_xslStyleSheet->isLoading()) |
| 558 m_document->applyXSLTransform(m_xslStyleSheet.get()); |
| 559 return change; |
| 560 } |
| 561 |
| 513 m_didCalculateResolver = true; | 562 m_didCalculateResolver = true; |
| 514 if (document().didLayoutWithPendingStylesheets() && !hasPendingSheets()) | 563 if (document().didLayoutWithPendingStylesheets() && !hasPendingSheets()) |
| 515 change.setNeedsRepaint(); | 564 change.setNeedsRepaint(); |
| 516 | 565 |
| 517 if (updateActiveStyleSheets(mode)) | 566 if (updateActiveStyleSheets(mode)) |
| 518 change.setNeedsStyleRecalc(); | 567 change.setNeedsStyleRecalc(); |
| 519 | 568 |
| 520 return change; | 569 return change; |
| 521 } | 570 } |
| 522 | 571 |
| (...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 641 visitor->trace(m_authorStyleSheets); | 690 visitor->trace(m_authorStyleSheets); |
| 642 visitor->trace(m_documentStyleSheetCollection); | 691 visitor->trace(m_documentStyleSheetCollection); |
| 643 visitor->trace(m_styleSheetCollectionMap); | 692 visitor->trace(m_styleSheetCollectionMap); |
| 644 visitor->trace(m_resolver); | 693 visitor->trace(m_resolver); |
| 645 visitor->trace(m_fontSelector); | 694 visitor->trace(m_fontSelector); |
| 646 visitor->trace(m_textToSheetCache); | 695 visitor->trace(m_textToSheetCache); |
| 647 visitor->trace(m_sheetToTextCache); | 696 visitor->trace(m_sheetToTextCache); |
| 648 } | 697 } |
| 649 | 698 |
| 650 } | 699 } |
| OLD | NEW |