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

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

Issue 1913833002: Current work-in-progress crbug.com/567021 (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: More assert fixes Created 4 years, 6 months 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 256 matching lines...) Expand 10 before | Expand all | Expand 10 after
267 } 267 }
268 268
269 if (rule->isNamespaceRule()) 269 if (rule->isNamespaceRule())
270 return false; 270 return false;
271 271
272 index -= m_namespaceRules.size(); 272 index -= m_namespaceRules.size();
273 273
274 if (rule->isMediaRule()) 274 if (rule->isMediaRule())
275 setHasMediaQueries(); 275 setHasMediaQueries();
276 else if (rule->isFontFaceRule()) 276 else if (rule->isFontFaceRule())
277 setHasFontFaceRule(true); 277 setHasFontFaceRule();
278 else if (rule->isViewportRule())
279 setHasViewportRule();
278 280
279 m_childRules.insert(index, rule); 281 m_childRules.insert(index, rule);
280 return true; 282 return true;
281 } 283 }
282 284
283 bool StyleSheetContents::wrapperDeleteRule(unsigned index) 285 bool StyleSheetContents::wrapperDeleteRule(unsigned index)
284 { 286 {
285 ASSERT(m_isMutable); 287 ASSERT(m_isMutable);
286 ASSERT_WITH_SECURITY_IMPLICATION(index < ruleCount()); 288 ASSERT_WITH_SECURITY_IMPLICATION(index < ruleCount());
287 289
(...skipping 313 matching lines...) Expand 10 before | Expand all | Expand 10 after
601 603
602 RuleSet& StyleSheetContents::ensureRuleSet(const MediaQueryEvaluator& medium, Ad dRuleFlags addRuleFlags) 604 RuleSet& StyleSheetContents::ensureRuleSet(const MediaQueryEvaluator& medium, Ad dRuleFlags addRuleFlags)
603 { 605 {
604 if (!m_ruleSet) { 606 if (!m_ruleSet) {
605 m_ruleSet = RuleSet::create(); 607 m_ruleSet = RuleSet::create();
606 m_ruleSet->addRulesFromSheet(this, medium, addRuleFlags); 608 m_ruleSet->addRulesFromSheet(this, medium, addRuleFlags);
607 } 609 }
608 return *m_ruleSet.get(); 610 return *m_ruleSet.get();
609 } 611 }
610 612
611 static void clearResolvers(HeapHashSet<WeakMember<CSSStyleSheet>>& clients) 613 RuleSet& StyleSheetContents::ensureEmptyRuleSet()
614 {
615 DCHECK(m_ruleSet);
616 m_ruleSet = RuleSet::create();
617 return *m_ruleSet.get();
618 }
619
620 static void setNeedsActiveStyleUpdateForClients(HeapHashSet<WeakMember<CSSStyleS heet>>& clients)
612 { 621 {
613 for (const auto& sheet : clients) { 622 for (const auto& sheet : clients) {
614 if (Document* document = sheet->ownerDocument()) 623 Document* document = sheet->ownerDocument();
615 document->styleEngine().clearResolver(); 624 Node* node = sheet->ownerNode();
625 if (!document || !node || !node->inShadowIncludingDocument())
626 continue;
627 document->styleEngine().setNeedsActiveStyleUpdate(node->treeScope());
616 } 628 }
617 } 629 }
618 630
619 void StyleSheetContents::clearRuleSet() 631 void StyleSheetContents::clearRuleSet()
620 { 632 {
621 if (StyleSheetContents* parentSheet = parentStyleSheet()) 633 if (StyleSheetContents* parentSheet = parentStyleSheet())
622 parentSheet->clearRuleSet(); 634 parentSheet->clearRuleSet();
623 635
624 // Don't want to clear the StyleResolver if the RuleSet hasn't been created
625 // since we only clear the StyleResolver so that it's members are properly
626 // updated in ScopedStyleResolver::addRulesFromSheet.
627 if (!m_ruleSet) 636 if (!m_ruleSet)
628 return; 637 return;
629 638
630 // Clearing the ruleSet means we need to recreate the styleResolver data str uctures.
631 // See the StyleResolver calls in ScopedStyleResolver::addRulesFromSheet.
632 clearResolvers(m_loadingClients);
633 clearResolvers(m_completedClients);
634 m_ruleSet.clear(); 639 m_ruleSet.clear();
640
641 setNeedsActiveStyleUpdateForClients(m_loadingClients);
642 setNeedsActiveStyleUpdateForClients(m_completedClients);
635 } 643 }
636 644
637 static void removeFontFaceRules(HeapHashSet<WeakMember<CSSStyleSheet>>& clients, const StyleRuleFontFace* fontFaceRule) 645 static void removeFontFaceRules(HeapHashSet<WeakMember<CSSStyleSheet>>& clients, const StyleRuleFontFace* fontFaceRule)
638 { 646 {
639 for (const auto& sheet : clients) { 647 for (const auto& sheet : clients) {
640 if (Node* ownerNode = sheet->ownerNode()) 648 if (Node* ownerNode = sheet->ownerNode())
641 ownerNode->document().styleEngine().removeFontFaceRules(HeapVector<M ember<const StyleRuleFontFace>>(1, fontFaceRule)); 649 ownerNode->document().styleEngine().removeFontFaceRules(HeapVector<M ember<const StyleRuleFontFace>>(1, fontFaceRule));
642 } 650 }
643 } 651 }
644 652
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
682 visitor->trace(m_importRules); 690 visitor->trace(m_importRules);
683 visitor->trace(m_namespaceRules); 691 visitor->trace(m_namespaceRules);
684 visitor->trace(m_childRules); 692 visitor->trace(m_childRules);
685 visitor->trace(m_loadingClients); 693 visitor->trace(m_loadingClients);
686 visitor->trace(m_completedClients); 694 visitor->trace(m_completedClients);
687 visitor->trace(m_ruleSet); 695 visitor->trace(m_ruleSet);
688 visitor->trace(m_referencedFromResource); 696 visitor->trace(m_referencedFromResource);
689 } 697 }
690 698
691 } // namespace blink 699 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698