Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(368)

Side by Side Diff: third_party/WebKit/Source/core/css/StyleSheetContents.cpp

Issue 2557533005: Collect active stylesheets and and apply asynchronously. (Closed)
Patch Set: Rebased. Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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 clearResolvers(HeapHashSet<WeakMember<CSSStyleSheet>>& clients) { 620 static void setNeedsActiveStyleUpdateForClients(
621 HeapHashSet<WeakMember<CSSStyleSheet>>& clients) {
621 for (const auto& sheet : clients) { 622 for (const auto& sheet : clients) {
622 if (Document* document = sheet->ownerDocument()) 623 Document* document = sheet->ownerDocument();
623 document->styleEngine().clearResolver(); 624 Node* node = sheet->ownerNode();
625 if (!document || !node || !node->isConnected())
626 continue;
627 document->styleEngine().setNeedsActiveStyleUpdate(node->treeScope());
624 } 628 }
625 } 629 }
626 630
627 void StyleSheetContents::clearRuleSet() { 631 void StyleSheetContents::clearRuleSet() {
628 if (StyleSheetContents* parentSheet = parentStyleSheet()) 632 if (StyleSheetContents* parentSheet = parentStyleSheet())
629 parentSheet->clearRuleSet(); 633 parentSheet->clearRuleSet();
630 634
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.
634 if (!m_ruleSet) 635 if (!m_ruleSet)
635 return; 636 return;
636 637
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);
642 m_ruleSet.clear(); 638 m_ruleSet.clear();
639 setNeedsActiveStyleUpdateForClients(m_loadingClients);
640 setNeedsActiveStyleUpdateForClients(m_completedClients);
643 } 641 }
644 642
645 static void removeFontFaceRules(HeapHashSet<WeakMember<CSSStyleSheet>>& clients, 643 static void removeFontFaceRules(HeapHashSet<WeakMember<CSSStyleSheet>>& clients,
646 const StyleRuleFontFace* fontFaceRule) { 644 const StyleRuleFontFace* fontFaceRule) {
647 for (const auto& sheet : clients) { 645 for (const auto& sheet : clients) {
648 if (Node* ownerNode = sheet->ownerNode()) 646 if (Node* ownerNode = sheet->ownerNode())
649 ownerNode->document().styleEngine().removeFontFaceRules( 647 ownerNode->document().styleEngine().removeFontFaceRules(
650 HeapVector<Member<const StyleRuleFontFace>>(1, fontFaceRule)); 648 HeapVector<Member<const StyleRuleFontFace>>(1, fontFaceRule));
651 } 649 }
652 } 650 }
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
691 visitor->trace(m_importRules); 689 visitor->trace(m_importRules);
692 visitor->trace(m_namespaceRules); 690 visitor->trace(m_namespaceRules);
693 visitor->trace(m_childRules); 691 visitor->trace(m_childRules);
694 visitor->trace(m_loadingClients); 692 visitor->trace(m_loadingClients);
695 visitor->trace(m_completedClients); 693 visitor->trace(m_completedClients);
696 visitor->trace(m_ruleSet); 694 visitor->trace(m_ruleSet);
697 visitor->trace(m_referencedFromResource); 695 visitor->trace(m_referencedFromResource);
698 } 696 }
699 697
700 } // namespace blink 698 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/css/FontFaceSet.cpp ('k') | third_party/WebKit/Source/core/css/resolver/StyleResolver.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698