Chromium Code Reviews| 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 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 64 , m_usesSiblingRulesOverride(false) | 64 , m_usesSiblingRulesOverride(false) |
| 65 , m_usesFirstLineRules(false) | 65 , m_usesFirstLineRules(false) |
| 66 , m_usesFirstLetterRules(false) | 66 , m_usesFirstLetterRules(false) |
| 67 , m_usesRemUnits(false) | 67 , m_usesRemUnits(false) |
| 68 , m_maxDirectAdjacentSelectors(0) | 68 , m_maxDirectAdjacentSelectors(0) |
| 69 , m_ignorePendingStylesheets(false) | 69 , m_ignorePendingStylesheets(false) |
| 70 , m_didCalculateResolver(false) | 70 , m_didCalculateResolver(false) |
| 71 // We don't need to create CSSFontSelector for imported document or | 71 // We don't need to create CSSFontSelector for imported document or |
| 72 // HTMLTemplateElement's document, because those documents have no frame. | 72 // HTMLTemplateElement's document, because those documents have no frame. |
| 73 , m_fontSelector(document.frame() ? CSSFontSelector::create(&document) : nul lptr) | 73 , m_fontSelector(document.frame() ? CSSFontSelector::create(&document) : nul lptr) |
| 74 , m_xslStyleSheet(0) | |
| 74 { | 75 { |
| 75 } | 76 } |
| 76 | 77 |
| 77 StyleEngine::~StyleEngine() | 78 StyleEngine::~StyleEngine() |
| 78 { | 79 { |
| 79 } | 80 } |
| 80 | 81 |
| 81 void StyleEngine::detachFromDocument() | 82 void StyleEngine::detachFromDocument() |
| 82 { | 83 { |
| 83 // Cleanup is performed eagerly when the StyleEngine is removed from the | 84 // Cleanup is performed eagerly when the StyleEngine is removed from the |
| (...skipping 195 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_doc ument; | 288 TreeScope& treeScope = isHTMLStyleElement(*node) ? node->treeScope() : m_doc ument; |
| 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(Node* node, bool createdByParser) | |
|
esprehn
2014/05/22 18:32:20
This should just take a ProcessingInstruction*
tasak
2014/05/27 06:17:30
Done.
| |
| 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 = toProcessingInstruction(node); | |
| 337 } | |
| 338 | |
| 339 void StyleEngine::removeXSLStyleSheet(Node* node) | |
|
esprehn
2014/05/22 18:32:20
ditto
tasak
2014/05/27 06:17:30
Done.
| |
| 340 { | |
| 341 ASSERT(isXSLStyleSheet(node)); | |
| 342 if (m_xslStyleSheet != node) | |
| 343 return; | |
| 344 | |
| 345 markTreeScopeDirty(m_document); | |
| 346 m_xslStyleSheet = 0; | |
| 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_doc ument; | 354 TreeScope& treeScope = isHTMLStyleElement(*node) ? node->treeScope() : m_doc ument; |
| 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 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 481 void StyleEngine::didDetach() | 514 void StyleEngine::didDetach() |
| 482 { | 515 { |
| 483 clearResolver(); | 516 clearResolver(); |
| 484 } | 517 } |
| 485 | 518 |
| 486 bool StyleEngine::shouldClearResolver() const | 519 bool StyleEngine::shouldClearResolver() const |
| 487 { | 520 { |
| 488 return !m_didCalculateResolver && !haveStylesheetsLoaded(); | 521 return !m_didCalculateResolver && !haveStylesheetsLoaded(); |
| 489 } | 522 } |
| 490 | 523 |
| 524 bool StyleEngine::shouldApplyXSLTransform() const | |
| 525 { | |
| 526 return m_xslStyleSheet && RuntimeEnabledFeatures::xsltEnabled() && !m_docume nt.transformSourceDocument(); | |
|
esprehn
2014/05/22 18:32:20
Early return on the runtime enabled feature.
if (
tasak
2014/05/27 06:17:30
Done.
| |
| 527 } | |
| 528 | |
| 491 StyleResolverChange StyleEngine::resolverChanged(RecalcStyleTime time, StyleReso lverUpdateMode mode) | 529 StyleResolverChange StyleEngine::resolverChanged(RecalcStyleTime time, StyleReso lverUpdateMode mode) |
| 492 { | 530 { |
| 493 StyleResolverChange change; | 531 StyleResolverChange change; |
| 494 | 532 |
| 495 if (!isMaster()) { | 533 if (!isMaster()) { |
| 496 if (Document* master = this->master()) | 534 if (Document* master = this->master()) |
| 497 master->styleResolverChanged(time, mode); | 535 master->styleResolverChanged(time, mode); |
| 498 return change; | 536 return change; |
| 499 } | 537 } |
| 500 | 538 |
| 501 // Don't bother updating, since we haven't loaded all our style info yet | 539 // Don't bother updating, since we haven't loaded all our style info yet |
| 502 // and haven't calculated the style selector for the first time. | 540 // and haven't calculated the style selector for the first time. |
| 503 if (!m_document.isActive() || shouldClearResolver()) { | 541 if (!m_document.isActive() || shouldClearResolver()) { |
| 504 clearResolver(); | 542 clearResolver(); |
| 505 return change; | 543 return change; |
| 506 } | 544 } |
| 507 | 545 |
| 546 if (shouldApplyXSLTransform()) { | |
| 547 // Processing instruction (XML documents only). | |
| 548 // We don't support linking to embedded CSS stylesheets, see <https://bu gs.webkit.org/show_bug.cgi?id=49281> for discussion. | |
| 549 // Don't apply XSL transforms to already transformed documents -- <rdar: //problem/4132806> | |
| 550 if (!m_document.parsing() && !m_xslStyleSheet->isLoading()) | |
| 551 m_document.applyXSLTransform(m_xslStyleSheet); | |
| 552 return change; | |
| 553 } | |
| 554 | |
| 508 m_didCalculateResolver = true; | 555 m_didCalculateResolver = true; |
| 509 if (m_document.didLayoutWithPendingStylesheets() && !hasPendingSheets()) | 556 if (m_document.didLayoutWithPendingStylesheets() && !hasPendingSheets()) |
| 510 change.setNeedsRepaint(); | 557 change.setNeedsRepaint(); |
| 511 | 558 |
| 512 if (updateActiveStyleSheets(mode)) | 559 if (updateActiveStyleSheets(mode)) |
| 513 change.setNeedsStyleRecalc(); | 560 change.setNeedsStyleRecalc(); |
| 514 | 561 |
| 515 return change; | 562 return change; |
| 516 } | 563 } |
| 517 | 564 |
| (...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 635 visitor->trace(m_authorStyleSheets); | 682 visitor->trace(m_authorStyleSheets); |
| 636 visitor->trace(m_documentStyleSheetCollection); | 683 visitor->trace(m_documentStyleSheetCollection); |
| 637 visitor->trace(m_styleSheetCollectionMap); | 684 visitor->trace(m_styleSheetCollectionMap); |
| 638 visitor->trace(m_resolver); | 685 visitor->trace(m_resolver); |
| 639 visitor->trace(m_fontSelector); | 686 visitor->trace(m_fontSelector); |
| 640 visitor->trace(m_textToSheetCache); | 687 visitor->trace(m_textToSheetCache); |
| 641 visitor->trace(m_sheetToTextCache); | 688 visitor->trace(m_sheetToTextCache); |
| 642 } | 689 } |
| 643 | 690 |
| 644 } | 691 } |
| OLD | NEW |