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 593 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
604 | 604 |
605 RuleSet& StyleSheetContents::ensureRuleSet(const MediaQueryEvaluator& medium, | 605 RuleSet& StyleSheetContents::ensureRuleSet(const MediaQueryEvaluator& medium, |
606 AddRuleFlags addRuleFlags) { | 606 AddRuleFlags addRuleFlags) { |
607 if (!m_ruleSet) { | 607 if (!m_ruleSet) { |
608 m_ruleSet = RuleSet::create(); | 608 m_ruleSet = RuleSet::create(); |
609 m_ruleSet->addRulesFromSheet(this, medium, addRuleFlags); | 609 m_ruleSet->addRulesFromSheet(this, medium, addRuleFlags); |
610 } | 610 } |
611 return *m_ruleSet.get(); | 611 return *m_ruleSet.get(); |
612 } | 612 } |
613 | 613 |
614 static void clearResolvers(HeapHashSet<WeakMember<CSSStyleSheet>>& clients) { | 614 static void setNeedsActiveStyleUpdateForClients( |
| 615 HeapHashSet<WeakMember<CSSStyleSheet>>& clients) { |
615 for (const auto& sheet : clients) { | 616 for (const auto& sheet : clients) { |
616 if (Document* document = sheet->ownerDocument()) | 617 Document* document = sheet->ownerDocument(); |
617 document->styleEngine().clearResolver(); | 618 Node* node = sheet->ownerNode(); |
| 619 if (!document || !node || !node->isConnected()) |
| 620 continue; |
| 621 document->styleEngine().setNeedsActiveStyleUpdate(node->treeScope()); |
618 } | 622 } |
619 } | 623 } |
620 | 624 |
621 void StyleSheetContents::clearRuleSet() { | 625 void StyleSheetContents::clearRuleSet() { |
622 if (StyleSheetContents* parentSheet = parentStyleSheet()) | 626 if (StyleSheetContents* parentSheet = parentStyleSheet()) |
623 parentSheet->clearRuleSet(); | 627 parentSheet->clearRuleSet(); |
624 | 628 |
625 // Don't want to clear the StyleResolver if the RuleSet hasn't been created | |
626 // since we only clear the StyleResolver so that it's members are properly | |
627 // updated in ScopedStyleResolver::addRulesFromSheet. | |
628 if (!m_ruleSet) | 629 if (!m_ruleSet) |
629 return; | 630 return; |
630 | 631 |
631 // Clearing the ruleSet means we need to recreate the styleResolver data | |
632 // structures. See the StyleResolver calls in | |
633 // ScopedStyleResolver::addRulesFromSheet. | |
634 clearResolvers(m_loadingClients); | |
635 clearResolvers(m_completedClients); | |
636 m_ruleSet.clear(); | 632 m_ruleSet.clear(); |
| 633 setNeedsActiveStyleUpdateForClients(m_loadingClients); |
| 634 setNeedsActiveStyleUpdateForClients(m_completedClients); |
637 } | 635 } |
638 | 636 |
639 static void removeFontFaceRules(HeapHashSet<WeakMember<CSSStyleSheet>>& clients, | 637 static void removeFontFaceRules(HeapHashSet<WeakMember<CSSStyleSheet>>& clients, |
640 const StyleRuleFontFace* fontFaceRule) { | 638 const StyleRuleFontFace* fontFaceRule) { |
641 for (const auto& sheet : clients) { | 639 for (const auto& sheet : clients) { |
642 if (Node* ownerNode = sheet->ownerNode()) | 640 if (Node* ownerNode = sheet->ownerNode()) |
643 ownerNode->document().styleEngine().removeFontFaceRules( | 641 ownerNode->document().styleEngine().removeFontFaceRules( |
644 HeapVector<Member<const StyleRuleFontFace>>(1, fontFaceRule)); | 642 HeapVector<Member<const StyleRuleFontFace>>(1, fontFaceRule)); |
645 } | 643 } |
646 } | 644 } |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
685 visitor->trace(m_importRules); | 683 visitor->trace(m_importRules); |
686 visitor->trace(m_namespaceRules); | 684 visitor->trace(m_namespaceRules); |
687 visitor->trace(m_childRules); | 685 visitor->trace(m_childRules); |
688 visitor->trace(m_loadingClients); | 686 visitor->trace(m_loadingClients); |
689 visitor->trace(m_completedClients); | 687 visitor->trace(m_completedClients); |
690 visitor->trace(m_ruleSet); | 688 visitor->trace(m_ruleSet); |
691 visitor->trace(m_referencedFromResource); | 689 visitor->trace(m_referencedFromResource); |
692 } | 690 } |
693 | 691 |
694 } // namespace blink | 692 } // namespace blink |
OLD | NEW |