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

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: 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 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 void reattachChildRuleCSSOMWrappers();
107 107
108 void registerExtraChildRuleCSSOMWrapper(PassRefPtr<CSSRule>);
109
108 StyleSheetContents* contents() const { return m_contents.get(); } 110 StyleSheetContents* contents() const { return m_contents.get(); }
109 111
110 bool isInline() const { return m_isInlineStylesheet; } 112 bool isInline() const { return m_isInlineStylesheet; }
111 TextPosition startPositionInSource() const { return m_startPosition; } 113 TextPosition startPositionInSource() const { return m_startPosition; }
112 114
113 private: 115 private:
114 CSSStyleSheet(PassRefPtr<StyleSheetContents>, CSSImportRule* ownerRule); 116 CSSStyleSheet(PassRefPtr<StyleSheetContents>, CSSImportRule* ownerRule);
115 CSSStyleSheet(PassRefPtr<StyleSheetContents>, Node* ownerNode, bool isInline Stylesheet, const TextPosition& startPosition); 117 CSSStyleSheet(PassRefPtr<StyleSheetContents>, Node* ownerNode, bool isInline Stylesheet, const TextPosition& startPosition);
116 118
117 virtual bool isCSSStyleSheet() const { return true; } 119 virtual bool isCSSStyleSheet() const { return true; }
118 virtual String type() const { return "text/css"; } 120 virtual String type() const { return "text/css"; }
119 121
120 bool canAccessRules() const; 122 bool canAccessRules() const;
121 123
122 RefPtr<StyleSheetContents> m_contents; 124 RefPtr<StyleSheetContents> m_contents;
123 bool m_isInlineStylesheet; 125 bool m_isInlineStylesheet;
124 bool m_isDisabled; 126 bool m_isDisabled;
125 String m_title; 127 String m_title;
126 RefPtr<MediaQuerySet> m_mediaQueries; 128 RefPtr<MediaQuerySet> m_mediaQueries;
127 129
128 Node* m_ownerNode; 130 Node* m_ownerNode;
129 CSSRule* m_ownerRule; 131 CSSRule* m_ownerRule;
130 132
131 TextPosition m_startPosition; 133 TextPosition m_startPosition;
132 134
133 mutable RefPtr<MediaList> m_mediaCSSOMWrapper; 135 mutable RefPtr<MediaList> m_mediaCSSOMWrapper;
134 mutable Vector<RefPtr<CSSRule> > m_childRuleCSSOMWrappers; 136 mutable Vector<RefPtr<CSSRule> > m_childRuleCSSOMWrappers;
137 // These are CSSOMWrappers that come from getMatchedCSSRules and thus don't map 1-1 to
138 // the StyleRules in the StyleSheetContents.
139 mutable Vector<RefPtr<CSSRule> > m_extraChildRuleCSSOMWrappers;
135 mutable OwnPtr<CSSRuleList> m_ruleListCSSOMWrapper; 140 mutable OwnPtr<CSSRuleList> m_ruleListCSSOMWrapper;
136 }; 141 };
137 142
138 inline CSSStyleSheet::RuleMutationScope::RuleMutationScope(CSSStyleSheet* sheet) 143 inline CSSStyleSheet::RuleMutationScope::RuleMutationScope(CSSStyleSheet* sheet)
139 : m_styleSheet(sheet) 144 : m_styleSheet(sheet)
140 { 145 {
141 if (m_styleSheet) 146 if (m_styleSheet)
142 m_styleSheet->willMutateRules(); 147 m_styleSheet->willMutateRules();
143 } 148 }
144 149
145 inline CSSStyleSheet::RuleMutationScope::RuleMutationScope(CSSRule* rule) 150 inline CSSStyleSheet::RuleMutationScope::RuleMutationScope(CSSRule* rule)
146 : m_styleSheet(rule ? rule->parentStyleSheet() : 0) 151 : m_styleSheet(rule ? rule->parentStyleSheet() : 0)
147 { 152 {
148 if (m_styleSheet) 153 if (m_styleSheet)
149 m_styleSheet->willMutateRules(); 154 m_styleSheet->willMutateRules();
150 } 155 }
151 156
152 inline CSSStyleSheet::RuleMutationScope::~RuleMutationScope() 157 inline CSSStyleSheet::RuleMutationScope::~RuleMutationScope()
153 { 158 {
154 if (m_styleSheet) 159 if (m_styleSheet)
155 m_styleSheet->didMutateRules(); 160 m_styleSheet->didMutateRules();
156 } 161 }
157 162
158 } // namespace 163 } // namespace
159 164
160 #endif 165 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698