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

Side by Side Diff: Source/core/css/CSSStyleSheet.h

Issue 49093005: Fix memory error during selector matching due to getMatchedCSSRules. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: stop calling willMutateRules Created 7 years, 1 month 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 | Annotate | Revision Log
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, 2008, 2009, 2010, 2012 Apple Inc. All rights reserved. 3 * Copyright (C) 2004, 2006, 2007, 2008, 2009, 2010, 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 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
96 96
97 private: 97 private:
98 CSSStyleSheet* m_styleSheet; 98 CSSStyleSheet* m_styleSheet;
99 }; 99 };
100 100
101 void willMutateRules(); 101 void willMutateRules();
102 void didMutateRules(); 102 void didMutateRules();
103 void didMutate(StyleSheetUpdateType = PartialRuleUpdate); 103 void didMutate(StyleSheetUpdateType = PartialRuleUpdate);
104 104
105 void clearChildRuleCSSOMWrappers(); 105 void clearChildRuleCSSOMWrappers();
106 void reattachChildRuleCSSOMWrappers(); 106
107 void registerExtraChildRuleCSSOMWrapper(PassRefPtr<CSSRule>);
107 108
108 StyleSheetContents* contents() const { return m_contents.get(); } 109 StyleSheetContents* contents() const { return m_contents.get(); }
109 110
110 bool isInline() const { return m_isInlineStylesheet; } 111 bool isInline() const { return m_isInlineStylesheet; }
111 TextPosition startPositionInSource() const { return m_startPosition; } 112 TextPosition startPositionInSource() const { return m_startPosition; }
112 113
113 private: 114 private:
114 CSSStyleSheet(PassRefPtr<StyleSheetContents>, CSSImportRule* ownerRule); 115 CSSStyleSheet(PassRefPtr<StyleSheetContents>, CSSImportRule* ownerRule);
115 CSSStyleSheet(PassRefPtr<StyleSheetContents>, Node* ownerNode, bool isInline Stylesheet, const TextPosition& startPosition); 116 CSSStyleSheet(PassRefPtr<StyleSheetContents>, Node* ownerNode, bool isInline Stylesheet, const TextPosition& startPosition);
116 117
117 virtual bool isCSSStyleSheet() const { return true; } 118 virtual bool isCSSStyleSheet() const { return true; }
118 virtual String type() const { return "text/css"; } 119 virtual String type() const { return "text/css"; }
119 120
121 void extraCSSOMWrapperIndices(Vector<unsigned>& indices);
122 void reattachChildRuleCSSOMWrappers(const Vector<unsigned>& extraCSSOMWrappe rIndices);
123
120 bool canAccessRules() const; 124 bool canAccessRules() const;
121 125
122 RefPtr<StyleSheetContents> m_contents; 126 RefPtr<StyleSheetContents> m_contents;
123 bool m_isInlineStylesheet; 127 bool m_isInlineStylesheet;
124 bool m_isDisabled; 128 bool m_isDisabled;
125 String m_title; 129 String m_title;
126 RefPtr<MediaQuerySet> m_mediaQueries; 130 RefPtr<MediaQuerySet> m_mediaQueries;
127 131
128 Node* m_ownerNode; 132 Node* m_ownerNode;
129 CSSRule* m_ownerRule; 133 CSSRule* m_ownerRule;
130 134
131 TextPosition m_startPosition; 135 TextPosition m_startPosition;
132 136
133 mutable RefPtr<MediaList> m_mediaCSSOMWrapper; 137 mutable RefPtr<MediaList> m_mediaCSSOMWrapper;
134 mutable Vector<RefPtr<CSSRule> > m_childRuleCSSOMWrappers; 138 mutable Vector<RefPtr<CSSRule> > m_childRuleCSSOMWrappers;
139 // These are CSSOMWrappers that come from getMatchedCSSRules and thus don't map 1-1 to
140 // the StyleRules in the StyleSheetContents.
141 mutable Vector<RefPtr<CSSRule> > m_extraChildRuleCSSOMWrappers;
135 mutable OwnPtr<CSSRuleList> m_ruleListCSSOMWrapper; 142 mutable OwnPtr<CSSRuleList> m_ruleListCSSOMWrapper;
136 }; 143 };
137 144
138 inline CSSStyleSheet::RuleMutationScope::RuleMutationScope(CSSStyleSheet* sheet) 145 inline CSSStyleSheet::RuleMutationScope::RuleMutationScope(CSSStyleSheet* sheet)
139 : m_styleSheet(sheet) 146 : m_styleSheet(sheet)
140 { 147 {
141 if (m_styleSheet) 148 if (m_styleSheet)
142 m_styleSheet->willMutateRules(); 149 m_styleSheet->willMutateRules();
143 } 150 }
144 151
145 inline CSSStyleSheet::RuleMutationScope::RuleMutationScope(CSSRule* rule) 152 inline CSSStyleSheet::RuleMutationScope::RuleMutationScope(CSSRule* rule)
146 : m_styleSheet(rule ? rule->parentStyleSheet() : 0) 153 : m_styleSheet(rule ? rule->parentStyleSheet() : 0)
147 { 154 {
148 if (m_styleSheet) 155 if (m_styleSheet)
149 m_styleSheet->willMutateRules(); 156 m_styleSheet->willMutateRules();
150 } 157 }
151 158
152 inline CSSStyleSheet::RuleMutationScope::~RuleMutationScope() 159 inline CSSStyleSheet::RuleMutationScope::~RuleMutationScope()
153 { 160 {
154 if (m_styleSheet) 161 if (m_styleSheet)
155 m_styleSheet->didMutateRules(); 162 m_styleSheet->didMutateRules();
156 } 163 }
157 164
158 } // namespace 165 } // namespace
159 166
160 #endif 167 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698