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

Side by Side Diff: sky/engine/core/css/StyleSheetContents.cpp

Issue 807703003: Remove @media rules. (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 6 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
« no previous file with comments | « sky/engine/core/css/StyleSheetContents.h ('k') | sky/engine/core/css/parser/BisonCSSParser.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 18 matching lines...) Expand all
29 #include "sky/engine/core/dom/Document.h" 29 #include "sky/engine/core/dom/Document.h"
30 #include "sky/engine/core/dom/Node.h" 30 #include "sky/engine/core/dom/Node.h"
31 #include "sky/engine/core/dom/StyleEngine.h" 31 #include "sky/engine/core/dom/StyleEngine.h"
32 #include "sky/engine/core/frame/UseCounter.h" 32 #include "sky/engine/core/frame/UseCounter.h"
33 #include "sky/engine/platform/TraceEvent.h" 33 #include "sky/engine/platform/TraceEvent.h"
34 #include "sky/engine/wtf/Deque.h" 34 #include "sky/engine/wtf/Deque.h"
35 35
36 namespace blink { 36 namespace blink {
37 37
38 StyleSheetContents::StyleSheetContents(const CSSParserContext& context) 38 StyleSheetContents::StyleSheetContents(const CSSParserContext& context)
39 : m_hasMediaQueries(false) 39 : m_parserContext(context)
40 , m_parserContext(context)
41 { 40 {
42 } 41 }
43 42
44 StyleSheetContents::~StyleSheetContents() 43 StyleSheetContents::~StyleSheetContents()
45 { 44 {
46 // TODO(esprehn): Why is this here? The rules will be cleared immediately 45 // TODO(esprehn): Why is this here? The rules will be cleared immediately
47 // after this destructor runs anyway. 46 // after this destructor runs anyway.
48 m_childRules.clear(); 47 m_childRules.clear();
49 } 48 }
50 49
51 void StyleSheetContents::parserAppendRule(PassRefPtr<StyleRuleBase> rule) 50 void StyleSheetContents::parserAppendRule(PassRefPtr<StyleRuleBase> rule)
52 { 51 {
53 if (rule->isMediaRule())
54 setHasMediaQueries();
55 m_childRules.append(rule); 52 m_childRules.append(rule);
56 } 53 }
57 54
58 void StyleSheetContents::setHasMediaQueries()
59 {
60 m_hasMediaQueries = true;
61 }
62
63 bool StyleSheetContents::parseString(const String& sheetText) 55 bool StyleSheetContents::parseString(const String& sheetText)
64 { 56 {
65 CSSParserContext context(parserContext(), UseCounter::getFrom(this)); 57 CSSParserContext context(parserContext(), UseCounter::getFrom(this));
66 BisonCSSParser p(context); 58 BisonCSSParser p(context);
67 p.parseSheet(this, sheetText); 59 p.parseSheet(this, sheetText);
68 return true; 60 return true;
69 } 61 }
70 62
71 void StyleSheetContents::registerClient(CSSStyleSheet* sheet) 63 void StyleSheetContents::registerClient(CSSStyleSheet* sheet)
72 { 64 {
(...skipping 12 matching lines...) Expand all
85 if (!sheet->ownerDocument() || !m_clients.isEmpty()) 77 if (!sheet->ownerDocument() || !m_clients.isEmpty())
86 return; 78 return;
87 sheet->ownerDocument()->styleEngine()->removeSheet(this); 79 sheet->ownerDocument()->styleEngine()->removeSheet(this);
88 } 80 }
89 81
90 void StyleSheetContents::shrinkToFit() 82 void StyleSheetContents::shrinkToFit()
91 { 83 {
92 m_childRules.shrinkToFit(); 84 m_childRules.shrinkToFit();
93 } 85 }
94 86
95 RuleSet& StyleSheetContents::ensureRuleSet(const MediaQueryEvaluator& medium, Ad dRuleFlags addRuleFlags) 87 RuleSet& StyleSheetContents::ensureRuleSet(AddRuleFlags addRuleFlags)
96 { 88 {
97 if (!m_ruleSet) { 89 if (!m_ruleSet) {
98 m_ruleSet = RuleSet::create(); 90 m_ruleSet = RuleSet::create();
99 m_ruleSet->addRulesFromSheet(this, medium, addRuleFlags); 91 m_ruleSet->addRulesFromSheet(this, addRuleFlags);
100 } 92 }
101 return *m_ruleSet.get(); 93 return *m_ruleSet.get();
102 } 94 }
103 95
104 void StyleSheetContents::clearRuleSet() 96 void StyleSheetContents::clearRuleSet()
105 { 97 {
106 // Don't want to clear the StyleResolver if the RuleSet hasn't been created 98 // Don't want to clear the StyleResolver if the RuleSet hasn't been created
107 // since we only clear the StyleResolver so that it's members are properly 99 // since we only clear the StyleResolver so that it's members are properly
108 // updated in ScopedStyleResolver::addRulesFromSheet. 100 // updated in ScopedStyleResolver::addRulesFromSheet.
109 if (!m_ruleSet) 101 if (!m_ruleSet)
110 return; 102 return;
111 103
112 // Clearing the ruleSet means we need to recreate the styleResolver data str uctures. 104 // Clearing the ruleSet means we need to recreate the styleResolver data str uctures.
113 // See the StyleResolver calls in ScopedStyleResolver::addRulesFromSheet. 105 // See the StyleResolver calls in ScopedStyleResolver::addRulesFromSheet.
114 for (RawPtr<CSSStyleSheet> client : m_clients) { 106 for (RawPtr<CSSStyleSheet> client : m_clients) {
115 if (Document* document = client->ownerDocument()) 107 if (Document* document = client->ownerDocument())
116 document->styleEngine()->clearResolver(); 108 document->styleEngine()->clearResolver();
117 } 109 }
118 m_ruleSet.clear(); 110 m_ruleSet.clear();
119 } 111 }
120 112
121 } 113 }
OLDNEW
« no previous file with comments | « sky/engine/core/css/StyleSheetContents.h ('k') | sky/engine/core/css/parser/BisonCSSParser.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698