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 12 matching lines...) Expand all Loading... | |
23 * along with this library; see the file COPYING.LIB. If not, write to | 23 * along with this library; see the file COPYING.LIB. If not, write to |
24 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, | 24 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
25 * Boston, MA 02110-1301, USA. | 25 * Boston, MA 02110-1301, USA. |
26 */ | 26 */ |
27 | 27 |
28 #include "config.h" | 28 #include "config.h" |
29 #include "core/dom/StyleEngine.h" | 29 #include "core/dom/StyleEngine.h" |
30 | 30 |
31 #include "HTMLNames.h" | 31 #include "HTMLNames.h" |
32 #include "SVGNames.h" | 32 #include "SVGNames.h" |
33 #include "core/css/CSSFontSelector.h" | |
33 #include "core/css/CSSStyleSheet.h" | 34 #include "core/css/CSSStyleSheet.h" |
34 #include "core/css/StyleInvalidationAnalysis.h" | 35 #include "core/css/StyleInvalidationAnalysis.h" |
35 #include "core/css/StyleSheetContents.h" | 36 #include "core/css/StyleSheetContents.h" |
36 #include "core/dom/Element.h" | 37 #include "core/dom/Element.h" |
37 #include "core/dom/ProcessingInstruction.h" | 38 #include "core/dom/ProcessingInstruction.h" |
38 #include "core/dom/ShadowTreeStyleSheetCollection.h" | 39 #include "core/dom/ShadowTreeStyleSheetCollection.h" |
39 #include "core/dom/shadow/ShadowRoot.h" | 40 #include "core/dom/shadow/ShadowRoot.h" |
40 #include "core/html/HTMLIFrameElement.h" | 41 #include "core/html/HTMLIFrameElement.h" |
41 #include "core/html/HTMLImport.h" | 42 #include "core/html/HTMLImport.h" |
42 #include "core/html/HTMLLinkElement.h" | 43 #include "core/html/HTMLLinkElement.h" |
(...skipping 20 matching lines...) Expand all Loading... | |
63 , m_usesSiblingRules(false) | 64 , m_usesSiblingRules(false) |
64 , m_usesSiblingRulesOverride(false) | 65 , m_usesSiblingRulesOverride(false) |
65 , m_usesFirstLineRules(false) | 66 , m_usesFirstLineRules(false) |
66 , m_usesFirstLetterRules(false) | 67 , m_usesFirstLetterRules(false) |
67 , m_usesRemUnits(false) | 68 , m_usesRemUnits(false) |
68 , m_maxDirectAdjacentSelectors(0) | 69 , m_maxDirectAdjacentSelectors(0) |
69 , m_ignorePendingStylesheets(false) | 70 , m_ignorePendingStylesheets(false) |
70 , m_didCalculateResolver(false) | 71 , m_didCalculateResolver(false) |
71 , m_lastResolverAccessCount(0) | 72 , m_lastResolverAccessCount(0) |
72 , m_resolverThrowawayTimer(this, &StyleEngine::resolverThrowawayTimerFired) | 73 , m_resolverThrowawayTimer(this, &StyleEngine::resolverThrowawayTimerFired) |
74 , m_fontSelector(document.frame() ? CSSFontSelector::create(&document) : 0) | |
ojan
2013/12/05 18:57:15
Is this null checking document.frame() for import
tasak
2013/12/06 07:13:47
Yes, and also for HTMLTemplateElement.
I found, if
| |
73 { | 75 { |
74 } | 76 } |
75 | 77 |
76 StyleEngine::~StyleEngine() | 78 StyleEngine::~StyleEngine() |
77 { | 79 { |
80 if (m_fontSelector) { | |
ojan
2013/12/05 18:57:15
Why do we need to do this?
tasak
2013/12/06 07:13:47
I see. Looking at ~CSSFontSelector, we don't need
| |
81 if (m_resolver) | |
82 m_fontSelector->unregisterForInvalidationCallbacks(m_resolver.get()) ; | |
83 m_fontSelector->clearDocument(); | |
84 } | |
85 | |
78 for (unsigned i = 0; i < m_injectedAuthorStyleSheets.size(); ++i) | 86 for (unsigned i = 0; i < m_injectedAuthorStyleSheets.size(); ++i) |
79 m_injectedAuthorStyleSheets[i]->clearOwnerNode(); | 87 m_injectedAuthorStyleSheets[i]->clearOwnerNode(); |
80 for (unsigned i = 0; i < m_authorStyleSheets.size(); ++i) | 88 for (unsigned i = 0; i < m_authorStyleSheets.size(); ++i) |
81 m_authorStyleSheets[i]->clearOwnerNode(); | 89 m_authorStyleSheets[i]->clearOwnerNode(); |
82 } | 90 } |
83 | 91 |
84 inline Document* StyleEngine::master() | 92 inline Document* StyleEngine::master() |
85 { | 93 { |
86 if (isMaster()) | 94 if (isMaster()) |
87 return &m_document; | 95 return &m_document; |
(...skipping 365 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
453 for (TreeScopeSet::iterator it = begin; it != end; ++it) { | 461 for (TreeScopeSet::iterator it = begin; it != end; ++it) { |
454 if (StyleSheetCollection* collection = m_styleSheetCollectionMap.get(*it )) { | 462 if (StyleSheetCollection* collection = m_styleSheetCollectionMap.get(*it )) { |
455 m_resolver->setBuildScopedStyleTreeInDocumentOrder(!collection->scop ingNodesForStyleScoped()); | 463 m_resolver->setBuildScopedStyleTreeInDocumentOrder(!collection->scop ingNodesForStyleScoped()); |
456 m_resolver->appendAuthorStyleSheets(0, collection->activeAuthorStyle Sheets()); | 464 m_resolver->appendAuthorStyleSheets(0, collection->activeAuthorStyle Sheets()); |
457 } | 465 } |
458 } | 466 } |
459 m_resolver->finishAppendAuthorStyleSheets(); | 467 m_resolver->finishAppendAuthorStyleSheets(); |
460 m_resolver->setBuildScopedStyleTreeInDocumentOrder(false); | 468 m_resolver->setBuildScopedStyleTreeInDocumentOrder(false); |
461 } | 469 } |
462 | 470 |
463 void StyleEngine::createResolver() | 471 void StyleEngine::createResolver() |
ojan
2013/12/05 18:57:15
Should this ASSERT(m_fontSelector)?
tasak
2013/12/06 07:13:47
I see. Done.
| |
464 { | 472 { |
465 // It is a programming error to attempt to resolve style on a Document | 473 // It is a programming error to attempt to resolve style on a Document |
466 // which is not in a frame. Code which hits this should have checked | 474 // which is not in a frame. Code which hits this should have checked |
467 // Document::isActive() before calling into code which could get here. | 475 // Document::isActive() before calling into code which could get here. |
468 | 476 |
469 ASSERT(m_document.frame()); | 477 ASSERT(m_document.frame()); |
470 | 478 |
471 m_resolver = adoptPtr(new StyleResolver(m_document)); | 479 m_resolver = adoptPtr(new StyleResolver(m_document)); |
472 appendActiveAuthorStyleSheets(); | 480 appendActiveAuthorStyleSheets(); |
481 m_fontSelector->registerForInvalidationCallbacks(m_resolver.get()); | |
473 combineCSSFeatureFlags(m_resolver->ensureRuleFeatureSet()); | 482 combineCSSFeatureFlags(m_resolver->ensureRuleFeatureSet()); |
474 } | 483 } |
475 | 484 |
476 void StyleEngine::clearResolver() | 485 void StyleEngine::clearResolver() |
ojan
2013/12/05 18:57:15
Should this ASSERT(m_fontSelector)?
tasak
2013/12/06 07:13:47
I added ASSERT(m_fontSelector || !m_resolver).
| |
477 { | 486 { |
478 ASSERT(!m_document.inStyleRecalc()); | 487 ASSERT(!m_document.inStyleRecalc()); |
479 ASSERT(isMaster() || !m_resolver); | 488 ASSERT(isMaster() || !m_resolver); |
489 if (m_resolver) | |
490 m_fontSelector->unregisterForInvalidationCallbacks(m_resolver.get()); | |
480 m_resolver.clear(); | 491 m_resolver.clear(); |
481 } | 492 } |
482 | 493 |
483 void StyleEngine::clearMasterResolver() | 494 void StyleEngine::clearMasterResolver() |
484 { | 495 { |
485 if (Document* master = this->master()) | 496 if (Document* master = this->master()) |
486 master->styleEngine()->clearResolver(); | 497 master->styleEngine()->clearResolver(); |
487 } | 498 } |
488 | 499 |
489 unsigned StyleEngine::resolverAccessCount() const | 500 unsigned StyleEngine::resolverAccessCount() const |
490 { | 501 { |
491 return m_resolver ? m_resolver->accessCount() : 0; | 502 return m_resolver ? m_resolver->accessCount() : 0; |
492 } | 503 } |
493 | 504 |
494 void StyleEngine::resolverThrowawayTimerFired(Timer<StyleEngine>*) | 505 void StyleEngine::resolverThrowawayTimerFired(Timer<StyleEngine>*) |
495 { | 506 { |
496 if (resolverAccessCount() == m_lastResolverAccessCount) | 507 if (resolverAccessCount() == m_lastResolverAccessCount) |
497 clearResolver(); | 508 clearResolver(); |
498 m_lastResolverAccessCount = resolverAccessCount(); | 509 m_lastResolverAccessCount = resolverAccessCount(); |
499 } | 510 } |
500 | 511 |
501 CSSFontSelector* StyleEngine::fontSelector() | |
502 { | |
503 return m_resolver ? m_resolver->fontSelector() : 0; | |
504 } | |
505 | |
506 void StyleEngine::didAttach() | 512 void StyleEngine::didAttach() |
507 { | 513 { |
508 m_resolverThrowawayTimer.startRepeating(60); | 514 m_resolverThrowawayTimer.startRepeating(60); |
509 } | 515 } |
510 | 516 |
511 void StyleEngine::didDetach() | 517 void StyleEngine::didDetach() |
512 { | 518 { |
513 m_resolverThrowawayTimer.stop(); | 519 m_resolverThrowawayTimer.stop(); |
514 clearResolver(); | 520 clearResolver(); |
515 } | 521 } |
(...skipping 23 matching lines...) Expand all Loading... | |
539 m_didCalculateResolver = true; | 545 m_didCalculateResolver = true; |
540 if (m_document.didLayoutWithPendingStylesheets() && !hasPendingSheets()) | 546 if (m_document.didLayoutWithPendingStylesheets() && !hasPendingSheets()) |
541 change.setNeedsRepaint(); | 547 change.setNeedsRepaint(); |
542 | 548 |
543 if (updateActiveStyleSheets(mode)) | 549 if (updateActiveStyleSheets(mode)) |
544 change.setNeedsStyleRecalc(); | 550 change.setNeedsStyleRecalc(); |
545 | 551 |
546 return change; | 552 return change; |
547 } | 553 } |
548 | 554 |
555 void StyleEngine::resetFontSelector() | |
556 { | |
557 if (!m_document.frame()) | |
ojan
2013/12/05 18:57:15
Should this be if (!m_fontSelector)?
tasak
2013/12/06 07:13:47
I think, should be if (!m_fontSelector || !m_docum
| |
558 return; | |
559 | |
560 m_fontSelector->clearDocument(); | |
561 if (m_resolver) { | |
562 m_fontSelector->unregisterForInvalidationCallbacks(m_resolver.get()); | |
563 m_resolver->invalidateMatchedPropertiesCache(); | |
564 } | |
565 m_fontSelector = CSSFontSelector::create(&m_document); | |
566 if (m_resolver) | |
567 m_fontSelector->registerForInvalidationCallbacks(m_resolver.get()); | |
549 } | 568 } |
569 | |
570 } | |
OLD | NEW |