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

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

Issue 1858753003: Remove RawPtr from core/css (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 8 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 28 matching lines...) Expand all
39 #include "core/html/HTMLStyleElement.h" 39 #include "core/html/HTMLStyleElement.h"
40 #include "core/inspector/InspectorInstrumentation.h" 40 #include "core/inspector/InspectorInstrumentation.h"
41 #include "core/svg/SVGStyleElement.h" 41 #include "core/svg/SVGStyleElement.h"
42 #include "platform/weborigin/SecurityOrigin.h" 42 #include "platform/weborigin/SecurityOrigin.h"
43 #include "wtf/text/StringBuilder.h" 43 #include "wtf/text/StringBuilder.h"
44 44
45 namespace blink { 45 namespace blink {
46 46
47 class StyleSheetCSSRuleList final : public CSSRuleList { 47 class StyleSheetCSSRuleList final : public CSSRuleList {
48 public: 48 public:
49 static RawPtr<StyleSheetCSSRuleList> create(CSSStyleSheet* sheet) 49 static StyleSheetCSSRuleList* create(CSSStyleSheet* sheet)
50 { 50 {
51 return new StyleSheetCSSRuleList(sheet); 51 return new StyleSheetCSSRuleList(sheet);
52 } 52 }
53 53
54 DEFINE_INLINE_VIRTUAL_TRACE() 54 DEFINE_INLINE_VIRTUAL_TRACE()
55 { 55 {
56 visitor->trace(m_styleSheet); 56 visitor->trace(m_styleSheet);
57 CSSRuleList::trace(visitor); 57 CSSRuleList::trace(visitor);
58 } 58 }
59 59
(...skipping 23 matching lines...) Expand all
83 // clearOwnerNode() in the owner's destructor in oilpan. 83 // clearOwnerNode() in the owner's destructor in oilpan.
84 return !parentNode 84 return !parentNode
85 || parentNode->isDocumentNode() 85 || parentNode->isDocumentNode()
86 || isHTMLLinkElement(*parentNode) 86 || isHTMLLinkElement(*parentNode)
87 || isHTMLStyleElement(*parentNode) 87 || isHTMLStyleElement(*parentNode)
88 || isSVGStyleElement(*parentNode) 88 || isSVGStyleElement(*parentNode)
89 || parentNode->getNodeType() == Node::PROCESSING_INSTRUCTION_NODE; 89 || parentNode->getNodeType() == Node::PROCESSING_INSTRUCTION_NODE;
90 } 90 }
91 #endif 91 #endif
92 92
93 RawPtr<CSSStyleSheet> CSSStyleSheet::create(RawPtr<StyleSheetContents> sheet, CS SImportRule* ownerRule) 93 CSSStyleSheet* CSSStyleSheet::create(StyleSheetContents* sheet, CSSImportRule* o wnerRule)
94 { 94 {
95 return new CSSStyleSheet(sheet, ownerRule); 95 return new CSSStyleSheet(sheet, ownerRule);
96 } 96 }
97 97
98 RawPtr<CSSStyleSheet> CSSStyleSheet::create(RawPtr<StyleSheetContents> sheet, No de* ownerNode) 98 CSSStyleSheet* CSSStyleSheet::create(StyleSheetContents* sheet, Node* ownerNode)
99 { 99 {
100 return new CSSStyleSheet(sheet, ownerNode, false, TextPosition::minimumPosit ion()); 100 return new CSSStyleSheet(sheet, ownerNode, false, TextPosition::minimumPosit ion());
101 } 101 }
102 102
103 RawPtr<CSSStyleSheet> CSSStyleSheet::createInline(RawPtr<StyleSheetContents> she et, Node* ownerNode, const TextPosition& startPosition) 103 CSSStyleSheet* CSSStyleSheet::createInline(StyleSheetContents* sheet, Node* owne rNode, const TextPosition& startPosition)
104 { 104 {
105 ASSERT(sheet); 105 ASSERT(sheet);
106 return new CSSStyleSheet(sheet, ownerNode, true, startPosition); 106 return new CSSStyleSheet(sheet, ownerNode, true, startPosition);
107 } 107 }
108 108
109 RawPtr<CSSStyleSheet> CSSStyleSheet::createInline(Node* ownerNode, const KURL& b aseURL, const TextPosition& startPosition, const String& encoding) 109 CSSStyleSheet* CSSStyleSheet::createInline(Node* ownerNode, const KURL& baseURL, const TextPosition& startPosition, const String& encoding)
110 { 110 {
111 CSSParserContext parserContext(ownerNode->document(), 0, baseURL, encoding); 111 CSSParserContext parserContext(ownerNode->document(), 0, baseURL, encoding);
112 RawPtr<StyleSheetContents> sheet = StyleSheetContents::create(baseURL.getStr ing(), parserContext); 112 StyleSheetContents* sheet = StyleSheetContents::create(baseURL.getString(), parserContext);
113 return new CSSStyleSheet(sheet.release(), ownerNode, true, startPosition); 113 return new CSSStyleSheet(sheet, ownerNode, true, startPosition);
114 } 114 }
115 115
116 CSSStyleSheet::CSSStyleSheet(RawPtr<StyleSheetContents> contents, CSSImportRule* ownerRule) 116 CSSStyleSheet::CSSStyleSheet(StyleSheetContents* contents, CSSImportRule* ownerR ule)
117 : m_contents(contents) 117 : m_contents(contents)
118 , m_isInlineStylesheet(false) 118 , m_isInlineStylesheet(false)
119 , m_isDisabled(false) 119 , m_isDisabled(false)
120 , m_ownerNode(nullptr) 120 , m_ownerNode(nullptr)
121 , m_ownerRule(ownerRule) 121 , m_ownerRule(ownerRule)
122 , m_startPosition(TextPosition::minimumPosition()) 122 , m_startPosition(TextPosition::minimumPosition())
123 , m_loadCompleted(false) 123 , m_loadCompleted(false)
124 { 124 {
125 m_contents->registerClient(this); 125 m_contents->registerClient(this);
126 } 126 }
127 127
128 CSSStyleSheet::CSSStyleSheet(RawPtr<StyleSheetContents> contents, Node* ownerNod e, bool isInlineStylesheet, const TextPosition& startPosition) 128 CSSStyleSheet::CSSStyleSheet(StyleSheetContents* contents, Node* ownerNode, bool isInlineStylesheet, const TextPosition& startPosition)
129 : m_contents(contents) 129 : m_contents(contents)
130 , m_isInlineStylesheet(isInlineStylesheet) 130 , m_isInlineStylesheet(isInlineStylesheet)
131 , m_isDisabled(false) 131 , m_isDisabled(false)
132 , m_ownerNode(ownerNode) 132 , m_ownerNode(ownerNode)
133 , m_ownerRule(nullptr) 133 , m_ownerRule(nullptr)
134 , m_startPosition(startPosition) 134 , m_startPosition(startPosition)
135 , m_loadCompleted(false) 135 , m_loadCompleted(false)
136 { 136 {
137 ASSERT(isAcceptableCSSStyleSheetParent(ownerNode)); 137 ASSERT(isAcceptableCSSStyleSheetParent(ownerNode));
138 m_contents->registerClient(this); 138 m_contents->registerClient(this);
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
215 215
216 void CSSStyleSheet::setDisabled(bool disabled) 216 void CSSStyleSheet::setDisabled(bool disabled)
217 { 217 {
218 if (disabled == m_isDisabled) 218 if (disabled == m_isDisabled)
219 return; 219 return;
220 m_isDisabled = disabled; 220 m_isDisabled = disabled;
221 221
222 didMutate(); 222 didMutate();
223 } 223 }
224 224
225 void CSSStyleSheet::setMediaQueries(RawPtr<MediaQuerySet> mediaQueries) 225 void CSSStyleSheet::setMediaQueries(MediaQuerySet* mediaQueries)
226 { 226 {
227 m_mediaQueries = mediaQueries; 227 m_mediaQueries = mediaQueries;
228 if (m_mediaCSSOMWrapper && m_mediaQueries) 228 if (m_mediaCSSOMWrapper && m_mediaQueries)
229 m_mediaCSSOMWrapper->reattach(m_mediaQueries.get()); 229 m_mediaCSSOMWrapper->reattach(m_mediaQueries.get());
230 230
231 } 231 }
232 232
233 unsigned CSSStyleSheet::length() const 233 unsigned CSSStyleSheet::length() const
234 { 234 {
235 return m_contents->ruleCount(); 235 return m_contents->ruleCount();
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
269 Document* document = ownerDocument(); 269 Document* document = ownerDocument();
270 if (!document) 270 if (!document)
271 return true; 271 return true;
272 if (document->getSecurityOrigin()->canRequestNoSuborigin(baseURL)) 272 if (document->getSecurityOrigin()->canRequestNoSuborigin(baseURL))
273 return true; 273 return true;
274 if (m_allowRuleAccessFromOrigin && document->getSecurityOrigin()->canAccessC heckSuborigins(m_allowRuleAccessFromOrigin.get())) 274 if (m_allowRuleAccessFromOrigin && document->getSecurityOrigin()->canAccessC heckSuborigins(m_allowRuleAccessFromOrigin.get()))
275 return true; 275 return true;
276 return false; 276 return false;
277 } 277 }
278 278
279 RawPtr<CSSRuleList> CSSStyleSheet::rules() 279 CSSRuleList* CSSStyleSheet::rules()
280 { 280 {
281 return cssRules(); 281 return cssRules();
282 } 282 }
283 283
284 unsigned CSSStyleSheet::insertRule(const String& ruleString, unsigned index, Exc eptionState& exceptionState) 284 unsigned CSSStyleSheet::insertRule(const String& ruleString, unsigned index, Exc eptionState& exceptionState)
285 { 285 {
286 ASSERT(m_childRuleCSSOMWrappers.isEmpty() || m_childRuleCSSOMWrappers.size() == m_contents->ruleCount()); 286 ASSERT(m_childRuleCSSOMWrappers.isEmpty() || m_childRuleCSSOMWrappers.size() == m_contents->ruleCount());
287 287
288 if (index > length()) { 288 if (index > length()) {
289 exceptionState.throwDOMException(IndexSizeError, "The index provided (" + String::number(index) + ") is larger than the maximum index (" + String::numbe r(length()) + ")."); 289 exceptionState.throwDOMException(IndexSizeError, "The index provided (" + String::number(index) + ") is larger than the maximum index (" + String::numbe r(length()) + ").");
290 return 0; 290 return 0;
291 } 291 }
292 CSSParserContext context(m_contents->parserContext(), UseCounter::getFrom(th is)); 292 CSSParserContext context(m_contents->parserContext(), UseCounter::getFrom(th is));
293 RawPtr<StyleRuleBase> rule = CSSParser::parseRule(context, m_contents.get(), ruleString); 293 StyleRuleBase* rule = CSSParser::parseRule(context, m_contents.get(), ruleSt ring);
294 294
295 if (!rule) { 295 if (!rule) {
296 exceptionState.throwDOMException(SyntaxError, "Failed to parse the rule '" + ruleString + "'."); 296 exceptionState.throwDOMException(SyntaxError, "Failed to parse the rule '" + ruleString + "'.");
297 return 0; 297 return 0;
298 } 298 }
299 RuleMutationScope mutationScope(this); 299 RuleMutationScope mutationScope(this);
300 300
301 bool success = m_contents->wrapperInsertRule(rule, index); 301 bool success = m_contents->wrapperInsertRule(rule, index);
302 if (!success) { 302 if (!success) {
303 if (rule->isNamespaceRule()) 303 if (rule->isNamespaceRule())
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
355 // As per Microsoft documentation, always return -1. 355 // As per Microsoft documentation, always return -1.
356 return -1; 356 return -1;
357 } 357 }
358 358
359 int CSSStyleSheet::addRule(const String& selector, const String& style, Exceptio nState& exceptionState) 359 int CSSStyleSheet::addRule(const String& selector, const String& style, Exceptio nState& exceptionState)
360 { 360 {
361 return addRule(selector, style, length(), exceptionState); 361 return addRule(selector, style, length(), exceptionState);
362 } 362 }
363 363
364 364
365 RawPtr<CSSRuleList> CSSStyleSheet::cssRules() 365 CSSRuleList* CSSStyleSheet::cssRules()
366 { 366 {
367 if (!canAccessRules()) 367 if (!canAccessRules())
368 return nullptr; 368 return nullptr;
369 if (!m_ruleListCSSOMWrapper) 369 if (!m_ruleListCSSOMWrapper)
370 m_ruleListCSSOMWrapper = StyleSheetCSSRuleList::create(this); 370 m_ruleListCSSOMWrapper = StyleSheetCSSRuleList::create(this);
371 return m_ruleListCSSOMWrapper.get(); 371 return m_ruleListCSSOMWrapper.get();
372 } 372 }
373 373
374 String CSSStyleSheet::href() const 374 String CSSStyleSheet::href() const
375 { 375 {
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
455 visitor->trace(m_mediaQueries); 455 visitor->trace(m_mediaQueries);
456 visitor->trace(m_ownerNode); 456 visitor->trace(m_ownerNode);
457 visitor->trace(m_ownerRule); 457 visitor->trace(m_ownerRule);
458 visitor->trace(m_mediaCSSOMWrapper); 458 visitor->trace(m_mediaCSSOMWrapper);
459 visitor->trace(m_childRuleCSSOMWrappers); 459 visitor->trace(m_childRuleCSSOMWrappers);
460 visitor->trace(m_ruleListCSSOMWrapper); 460 visitor->trace(m_ruleListCSSOMWrapper);
461 StyleSheet::trace(visitor); 461 StyleSheet::trace(visitor);
462 } 462 }
463 463
464 } // namespace blink 464 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/css/CSSStyleSheet.h ('k') | third_party/WebKit/Source/core/css/CSSStyleSheetResourceTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698