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

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

Issue 2616093003: Make CSSParserContext be garbage collected. (Closed)
Patch Set: comments 1 Created 3 years, 11 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 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
95 Node& ownerNode, 95 Node& ownerNode,
96 const TextPosition& startPosition) { 96 const TextPosition& startPosition) {
97 DCHECK(sheet); 97 DCHECK(sheet);
98 return new CSSStyleSheet(sheet, ownerNode, true, startPosition); 98 return new CSSStyleSheet(sheet, ownerNode, true, startPosition);
99 } 99 }
100 100
101 CSSStyleSheet* CSSStyleSheet::createInline(Node& ownerNode, 101 CSSStyleSheet* CSSStyleSheet::createInline(Node& ownerNode,
102 const KURL& baseURL, 102 const KURL& baseURL,
103 const TextPosition& startPosition, 103 const TextPosition& startPosition,
104 const String& encoding) { 104 const String& encoding) {
105 CSSParserContext parserContext(ownerNode.document(), nullptr, baseURL, 105 CSSParserContext* parserContext =
106 encoding); 106 new CSSParserContext(ownerNode.document(), baseURL, encoding);
107 StyleSheetContents* sheet = 107 StyleSheetContents* sheet =
108 StyleSheetContents::create(baseURL.getString(), parserContext); 108 StyleSheetContents::create(baseURL.getString(), parserContext);
109 return new CSSStyleSheet(sheet, ownerNode, true, startPosition); 109 return new CSSStyleSheet(sheet, ownerNode, true, startPosition);
110 } 110 }
111 111
112 CSSStyleSheet::CSSStyleSheet(StyleSheetContents* contents, 112 CSSStyleSheet::CSSStyleSheet(StyleSheetContents* contents,
113 CSSImportRule* ownerRule) 113 CSSImportRule* ownerRule)
114 : m_contents(contents), 114 : m_contents(contents),
115 m_ownerRule(ownerRule), 115 m_ownerRule(ownerRule),
116 m_startPosition(TextPosition::minimumPosition()) { 116 m_startPosition(TextPosition::minimumPosition()) {
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after
257 DCHECK(m_childRuleCSSOMWrappers.isEmpty() || 257 DCHECK(m_childRuleCSSOMWrappers.isEmpty() ||
258 m_childRuleCSSOMWrappers.size() == m_contents->ruleCount()); 258 m_childRuleCSSOMWrappers.size() == m_contents->ruleCount());
259 259
260 if (index > length()) { 260 if (index > length()) {
261 exceptionState.throwDOMException( 261 exceptionState.throwDOMException(
262 IndexSizeError, "The index provided (" + String::number(index) + 262 IndexSizeError, "The index provided (" + String::number(index) +
263 ") is larger than the maximum index (" + 263 ") is larger than the maximum index (" +
264 String::number(length()) + ")."); 264 String::number(length()) + ").");
265 return 0; 265 return 0;
266 } 266 }
267 CSSParserContext context(m_contents->parserContext(), 267 const CSSParserContext* context =
268 UseCounter::getFrom(this)); 268 CSSParserContext::create(m_contents->parserContext(), this);
269 StyleRuleBase* rule = 269 StyleRuleBase* rule =
270 CSSParser::parseRule(context, m_contents.get(), ruleString); 270 CSSParser::parseRule(context, m_contents.get(), ruleString);
271 271
272 if (!rule) { 272 if (!rule) {
273 exceptionState.throwDOMException( 273 exceptionState.throwDOMException(
274 SyntaxError, "Failed to parse the rule '" + ruleString + "'."); 274 SyntaxError, "Failed to parse the rule '" + ruleString + "'.");
275 return 0; 275 return 0;
276 } 276 }
277 RuleMutationScope mutationScope(this); 277 RuleMutationScope mutationScope(this);
278 278
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after
434 visitor->trace(m_deviceDependentMediaQueryResults); 434 visitor->trace(m_deviceDependentMediaQueryResults);
435 visitor->trace(m_ownerNode); 435 visitor->trace(m_ownerNode);
436 visitor->trace(m_ownerRule); 436 visitor->trace(m_ownerRule);
437 visitor->trace(m_mediaCSSOMWrapper); 437 visitor->trace(m_mediaCSSOMWrapper);
438 visitor->trace(m_childRuleCSSOMWrappers); 438 visitor->trace(m_childRuleCSSOMWrappers);
439 visitor->trace(m_ruleListCSSOMWrapper); 439 visitor->trace(m_ruleListCSSOMWrapper);
440 StyleSheet::trace(visitor); 440 StyleSheet::trace(visitor);
441 } 441 }
442 442
443 } // namespace blink 443 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698