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