OLD | NEW |
---|---|
1 /* | 1 /* |
2 * (C) 1999-2003 Lars Knoll (knoll@kde.org) | 2 * (C) 1999-2003 Lars Knoll (knoll@kde.org) |
3 * Copyright (C) 2004, 2006, 2007, 2012 Apple Inc. All rights reserved. | 3 * Copyright (C) 2004, 2006, 2007, 2012 Apple Inc. All rights reserved. |
4 * | 4 * |
5 * This library is free software; you can redistribute it and/or | 5 * This library is free software; you can redistribute it and/or |
6 * modify it under the terms of the GNU Library General Public | 6 * modify it under the terms of the GNU Library General Public |
7 * License as published by the Free Software Foundation; either | 7 * License as published by the Free Software Foundation; either |
8 * version 2 of the License, or (at your option) any later version. | 8 * version 2 of the License, or (at your option) any later version. |
9 * | 9 * |
10 * This library is distributed in the hope that it will be useful, | 10 * This library is distributed in the hope that it will be useful, |
(...skipping 600 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
611 | 611 |
612 RuleSet& StyleSheetContents::ensureRuleSet(const MediaQueryEvaluator& medium, | 612 RuleSet& StyleSheetContents::ensureRuleSet(const MediaQueryEvaluator& medium, |
613 AddRuleFlags addRuleFlags) { | 613 AddRuleFlags addRuleFlags) { |
614 if (!m_ruleSet) { | 614 if (!m_ruleSet) { |
615 m_ruleSet = RuleSet::create(); | 615 m_ruleSet = RuleSet::create(); |
616 m_ruleSet->addRulesFromSheet(this, medium, addRuleFlags); | 616 m_ruleSet->addRulesFromSheet(this, medium, addRuleFlags); |
617 } | 617 } |
618 return *m_ruleSet.get(); | 618 return *m_ruleSet.get(); |
619 } | 619 } |
620 | 620 |
621 static void clearResolvers(HeapHashSet<WeakMember<CSSStyleSheet>>& clients) { | 621 static void setNeedsActiveStyleUpdateForClients( |
622 HeapHashSet<WeakMember<CSSStyleSheet>>& clients) { | |
622 for (const auto& sheet : clients) { | 623 for (const auto& sheet : clients) { |
623 if (Document* document = sheet->ownerDocument()) | 624 Document* document = sheet->ownerDocument(); |
624 document->styleEngine().clearResolver(); | 625 Node* node = sheet->ownerNode(); |
626 if (!document || !node || !node->isConnected()) | |
627 continue; | |
628 document->styleEngine().setNeedsActiveStyleUpdate(node->treeScope()); | |
esprehn
2016/12/09 01:36:21
Should this be a method on TreeScope instead?
rune
2016/12/09 08:55:50
We will need to pass the tree-scope on to StyleEng
| |
625 } | 629 } |
626 } | 630 } |
627 | 631 |
628 void StyleSheetContents::clearRuleSet() { | 632 void StyleSheetContents::clearRuleSet() { |
629 if (StyleSheetContents* parentSheet = parentStyleSheet()) | 633 if (StyleSheetContents* parentSheet = parentStyleSheet()) |
630 parentSheet->clearRuleSet(); | 634 parentSheet->clearRuleSet(); |
631 | 635 |
632 // Don't want to clear the StyleResolver if the RuleSet hasn't been created | |
633 // since we only clear the StyleResolver so that it's members are properly | |
634 // updated in ScopedStyleResolver::addRulesFromSheet. | |
635 if (!m_ruleSet) | 636 if (!m_ruleSet) |
636 return; | 637 return; |
637 | 638 |
638 // Clearing the ruleSet means we need to recreate the styleResolver data | |
639 // structures. See the StyleResolver calls in | |
640 // ScopedStyleResolver::addRulesFromSheet. | |
641 clearResolvers(m_loadingClients); | |
642 clearResolvers(m_completedClients); | |
643 m_ruleSet.clear(); | 639 m_ruleSet.clear(); |
640 setNeedsActiveStyleUpdateForClients(m_loadingClients); | |
641 setNeedsActiveStyleUpdateForClients(m_completedClients); | |
644 } | 642 } |
645 | 643 |
646 static void removeFontFaceRules(HeapHashSet<WeakMember<CSSStyleSheet>>& clients, | 644 static void removeFontFaceRules(HeapHashSet<WeakMember<CSSStyleSheet>>& clients, |
647 const StyleRuleFontFace* fontFaceRule) { | 645 const StyleRuleFontFace* fontFaceRule) { |
648 for (const auto& sheet : clients) { | 646 for (const auto& sheet : clients) { |
649 if (Node* ownerNode = sheet->ownerNode()) | 647 if (Node* ownerNode = sheet->ownerNode()) |
650 ownerNode->document().styleEngine().removeFontFaceRules( | 648 ownerNode->document().styleEngine().removeFontFaceRules( |
651 HeapVector<Member<const StyleRuleFontFace>>(1, fontFaceRule)); | 649 HeapVector<Member<const StyleRuleFontFace>>(1, fontFaceRule)); |
652 } | 650 } |
653 } | 651 } |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
692 visitor->trace(m_importRules); | 690 visitor->trace(m_importRules); |
693 visitor->trace(m_namespaceRules); | 691 visitor->trace(m_namespaceRules); |
694 visitor->trace(m_childRules); | 692 visitor->trace(m_childRules); |
695 visitor->trace(m_loadingClients); | 693 visitor->trace(m_loadingClients); |
696 visitor->trace(m_completedClients); | 694 visitor->trace(m_completedClients); |
697 visitor->trace(m_ruleSet); | 695 visitor->trace(m_ruleSet); |
698 visitor->trace(m_referencedFromResource); | 696 visitor->trace(m_referencedFromResource); |
699 } | 697 } |
700 | 698 |
701 } // namespace blink | 699 } // namespace blink |
OLD | NEW |