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

Side by Side Diff: third_party/WebKit/Source/core/css/StyleRule.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 * (C) 2002-2003 Dirk Mueller (mueller@kde.org) 3 * (C) 2002-2003 Dirk Mueller (mueller@kde.org)
4 * Copyright (C) 2002, 2005, 2006, 2008, 2012 Apple Inc. All rights reserved. 4 * Copyright (C) 2002, 2005, 2006, 2008, 2012 Apple Inc. All rights reserved.
5 * 5 *
6 * This library is free software; you can redistribute it and/or 6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Library General Public 7 * modify it under the terms of the GNU Library General Public
8 * License as published by the Free Software Foundation; either 8 * License as published by the Free Software Foundation; either
9 * version 2 of the License, or (at your option) any later version. 9 * version 2 of the License, or (at your option) any later version.
10 * 10 *
(...skipping 24 matching lines...) Expand all
35 #include "core/css/StyleRuleNamespace.h" 35 #include "core/css/StyleRuleNamespace.h"
36 36
37 namespace blink { 37 namespace blink {
38 38
39 struct SameSizeAsStyleRuleBase : public GarbageCollectedFinalized<SameSizeAsStyl eRuleBase> { 39 struct SameSizeAsStyleRuleBase : public GarbageCollectedFinalized<SameSizeAsStyl eRuleBase> {
40 unsigned bitfields; 40 unsigned bitfields;
41 }; 41 };
42 42
43 static_assert(sizeof(StyleRuleBase) <= sizeof(SameSizeAsStyleRuleBase), "StyleRu leBase should stay small"); 43 static_assert(sizeof(StyleRuleBase) <= sizeof(SameSizeAsStyleRuleBase), "StyleRu leBase should stay small");
44 44
45 RawPtr<CSSRule> StyleRuleBase::createCSSOMWrapper(CSSStyleSheet* parentSheet) co nst 45 CSSRule* StyleRuleBase::createCSSOMWrapper(CSSStyleSheet* parentSheet) const
46 { 46 {
47 return createCSSOMWrapper(parentSheet, 0); 47 return createCSSOMWrapper(parentSheet, 0);
48 } 48 }
49 49
50 RawPtr<CSSRule> StyleRuleBase::createCSSOMWrapper(CSSRule* parentRule) const 50 CSSRule* StyleRuleBase::createCSSOMWrapper(CSSRule* parentRule) const
51 { 51 {
52 return createCSSOMWrapper(0, parentRule); 52 return createCSSOMWrapper(0, parentRule);
53 } 53 }
54 54
55 DEFINE_TRACE(StyleRuleBase) 55 DEFINE_TRACE(StyleRuleBase)
56 { 56 {
57 switch (type()) { 57 switch (type()) {
58 case Charset: 58 case Charset:
59 toStyleRuleCharset(this)->traceAfterDispatch(visitor); 59 toStyleRuleCharset(this)->traceAfterDispatch(visitor);
60 return; 60 return;
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
165 case Namespace: 165 case Namespace:
166 delete toStyleRuleNamespace(this); 166 delete toStyleRuleNamespace(this);
167 return; 167 return;
168 case Viewport: 168 case Viewport:
169 delete toStyleRuleViewport(this); 169 delete toStyleRuleViewport(this);
170 return; 170 return;
171 } 171 }
172 ASSERT_NOT_REACHED(); 172 ASSERT_NOT_REACHED();
173 } 173 }
174 174
175 RawPtr<StyleRuleBase> StyleRuleBase::copy() const 175 StyleRuleBase* StyleRuleBase::copy() const
176 { 176 {
177 switch (type()) { 177 switch (type()) {
178 case Style: 178 case Style:
179 return toStyleRule(this)->copy(); 179 return toStyleRule(this)->copy();
180 case Page: 180 case Page:
181 return toStyleRulePage(this)->copy(); 181 return toStyleRulePage(this)->copy();
182 case FontFace: 182 case FontFace:
183 return toStyleRuleFontFace(this)->copy(); 183 return toStyleRuleFontFace(this)->copy();
184 case Media: 184 case Media:
185 return toStyleRuleMedia(this)->copy(); 185 return toStyleRuleMedia(this)->copy();
(...skipping 10 matching lines...) Expand all
196 case Charset: 196 case Charset:
197 case Keyframe: 197 case Keyframe:
198 case Namespace: 198 case Namespace:
199 ASSERT_NOT_REACHED(); 199 ASSERT_NOT_REACHED();
200 return nullptr; 200 return nullptr;
201 } 201 }
202 ASSERT_NOT_REACHED(); 202 ASSERT_NOT_REACHED();
203 return nullptr; 203 return nullptr;
204 } 204 }
205 205
206 RawPtr<CSSRule> StyleRuleBase::createCSSOMWrapper(CSSStyleSheet* parentSheet, CS SRule* parentRule) const 206 CSSRule* StyleRuleBase::createCSSOMWrapper(CSSStyleSheet* parentSheet, CSSRule* parentRule) const
207 { 207 {
208 RawPtr<CSSRule> rule = nullptr; 208 CSSRule* rule = nullptr;
209 StyleRuleBase* self = const_cast<StyleRuleBase*>(this); 209 StyleRuleBase* self = const_cast<StyleRuleBase*>(this);
210 switch (type()) { 210 switch (type()) {
211 case Style: 211 case Style:
212 rule = CSSStyleRule::create(toStyleRule(self), parentSheet); 212 rule = CSSStyleRule::create(toStyleRule(self), parentSheet);
213 break; 213 break;
214 case Page: 214 case Page:
215 rule = CSSPageRule::create(toStyleRulePage(self), parentSheet); 215 rule = CSSPageRule::create(toStyleRulePage(self), parentSheet);
216 break; 216 break;
217 case FontFace: 217 case FontFace:
218 rule = CSSFontFaceRule::create(toStyleRuleFontFace(self), parentSheet); 218 rule = CSSFontFaceRule::create(toStyleRuleFontFace(self), parentSheet);
(...skipping 16 matching lines...) Expand all
235 case Viewport: 235 case Viewport:
236 rule = CSSViewportRule::create(toStyleRuleViewport(self), parentSheet); 236 rule = CSSViewportRule::create(toStyleRuleViewport(self), parentSheet);
237 break; 237 break;
238 case Keyframe: 238 case Keyframe:
239 case Charset: 239 case Charset:
240 ASSERT_NOT_REACHED(); 240 ASSERT_NOT_REACHED();
241 return nullptr; 241 return nullptr;
242 } 242 }
243 if (parentRule) 243 if (parentRule)
244 rule->setParentRule(parentRule); 244 rule->setParentRule(parentRule);
245 return rule.release(); 245 return rule;
246 } 246 }
247 247
248 unsigned StyleRule::averageSizeInBytes() 248 unsigned StyleRule::averageSizeInBytes()
249 { 249 {
250 return sizeof(StyleRule) + sizeof(CSSSelector) + StylePropertySet::averageSi zeInBytes(); 250 return sizeof(StyleRule) + sizeof(CSSSelector) + StylePropertySet::averageSi zeInBytes();
251 } 251 }
252 252
253 StyleRule::StyleRule(CSSSelectorList selectorList, RawPtr<StylePropertySet> prop erties) 253 StyleRule::StyleRule(CSSSelectorList selectorList, StylePropertySet* properties)
254 : StyleRuleBase(Style) 254 : StyleRuleBase(Style)
255 , m_properties(properties) 255 , m_properties(properties)
256 { 256 {
257 m_selectorList = std::move(selectorList); 257 m_selectorList = std::move(selectorList);
258 } 258 }
259 259
260 StyleRule::StyleRule(const StyleRule& o) 260 StyleRule::StyleRule(const StyleRule& o)
261 : StyleRuleBase(o) 261 : StyleRuleBase(o)
262 , m_properties(o.m_properties->mutableCopy()) 262 , m_properties(o.m_properties->mutableCopy())
263 , m_selectorList(o.m_selectorList.copy()) 263 , m_selectorList(o.m_selectorList.copy())
(...skipping 10 matching lines...) Expand all
274 m_properties = m_properties->mutableCopy(); 274 m_properties = m_properties->mutableCopy();
275 return *toMutableStylePropertySet(m_properties.get()); 275 return *toMutableStylePropertySet(m_properties.get());
276 } 276 }
277 277
278 DEFINE_TRACE_AFTER_DISPATCH(StyleRule) 278 DEFINE_TRACE_AFTER_DISPATCH(StyleRule)
279 { 279 {
280 visitor->trace(m_properties); 280 visitor->trace(m_properties);
281 StyleRuleBase::traceAfterDispatch(visitor); 281 StyleRuleBase::traceAfterDispatch(visitor);
282 } 282 }
283 283
284 StyleRulePage::StyleRulePage(CSSSelectorList selectorList, RawPtr<StylePropertyS et> properties) 284 StyleRulePage::StyleRulePage(CSSSelectorList selectorList, StylePropertySet* pro perties)
285 : StyleRuleBase(Page) 285 : StyleRuleBase(Page)
286 , m_properties(properties) 286 , m_properties(properties)
287 , m_selectorList(std::move(selectorList)) 287 , m_selectorList(std::move(selectorList))
288 { 288 {
289 } 289 }
290 290
291 StyleRulePage::StyleRulePage(const StyleRulePage& o) 291 StyleRulePage::StyleRulePage(const StyleRulePage& o)
292 : StyleRuleBase(o) 292 : StyleRuleBase(o)
293 , m_properties(o.m_properties->mutableCopy()) 293 , m_properties(o.m_properties->mutableCopy())
294 , m_selectorList(o.m_selectorList.copy()) 294 , m_selectorList(o.m_selectorList.copy())
(...skipping 10 matching lines...) Expand all
305 m_properties = m_properties->mutableCopy(); 305 m_properties = m_properties->mutableCopy();
306 return *toMutableStylePropertySet(m_properties.get()); 306 return *toMutableStylePropertySet(m_properties.get());
307 } 307 }
308 308
309 DEFINE_TRACE_AFTER_DISPATCH(StyleRulePage) 309 DEFINE_TRACE_AFTER_DISPATCH(StyleRulePage)
310 { 310 {
311 visitor->trace(m_properties); 311 visitor->trace(m_properties);
312 StyleRuleBase::traceAfterDispatch(visitor); 312 StyleRuleBase::traceAfterDispatch(visitor);
313 } 313 }
314 314
315 StyleRuleFontFace::StyleRuleFontFace(RawPtr<StylePropertySet> properties) 315 StyleRuleFontFace::StyleRuleFontFace(StylePropertySet* properties)
316 : StyleRuleBase(FontFace) 316 : StyleRuleBase(FontFace)
317 , m_properties(properties) 317 , m_properties(properties)
318 { 318 {
319 } 319 }
320 320
321 StyleRuleFontFace::StyleRuleFontFace(const StyleRuleFontFace& o) 321 StyleRuleFontFace::StyleRuleFontFace(const StyleRuleFontFace& o)
322 : StyleRuleBase(o) 322 : StyleRuleBase(o)
323 , m_properties(o.m_properties->mutableCopy()) 323 , m_properties(o.m_properties->mutableCopy())
324 { 324 {
325 } 325 }
(...skipping 22 matching lines...) Expand all
348 } 348 }
349 349
350 StyleRuleGroup::StyleRuleGroup(const StyleRuleGroup& o) 350 StyleRuleGroup::StyleRuleGroup(const StyleRuleGroup& o)
351 : StyleRuleBase(o) 351 : StyleRuleBase(o)
352 , m_childRules(o.m_childRules.size()) 352 , m_childRules(o.m_childRules.size())
353 { 353 {
354 for (unsigned i = 0; i < m_childRules.size(); ++i) 354 for (unsigned i = 0; i < m_childRules.size(); ++i)
355 m_childRules[i] = o.m_childRules[i]->copy(); 355 m_childRules[i] = o.m_childRules[i]->copy();
356 } 356 }
357 357
358 void StyleRuleGroup::wrapperInsertRule(unsigned index, RawPtr<StyleRuleBase> rul e) 358 void StyleRuleGroup::wrapperInsertRule(unsigned index, StyleRuleBase* rule)
359 { 359 {
360 m_childRules.insert(index, rule); 360 m_childRules.insert(index, rule);
361 } 361 }
362 362
363 void StyleRuleGroup::wrapperRemoveRule(unsigned index) 363 void StyleRuleGroup::wrapperRemoveRule(unsigned index)
364 { 364 {
365 m_childRules.remove(index); 365 m_childRules.remove(index);
366 } 366 }
367 367
368 DEFINE_TRACE_AFTER_DISPATCH(StyleRuleGroup) 368 DEFINE_TRACE_AFTER_DISPATCH(StyleRuleGroup)
369 { 369 {
370 visitor->trace(m_childRules); 370 visitor->trace(m_childRules);
371 StyleRuleBase::traceAfterDispatch(visitor); 371 StyleRuleBase::traceAfterDispatch(visitor);
372 } 372 }
373 373
374 StyleRuleMedia::StyleRuleMedia(RawPtr<MediaQuerySet> media, HeapVector<Member<St yleRuleBase>>& adoptRules) 374 StyleRuleMedia::StyleRuleMedia(MediaQuerySet* media, HeapVector<Member<StyleRule Base>>& adoptRules)
375 : StyleRuleGroup(Media, adoptRules) 375 : StyleRuleGroup(Media, adoptRules)
376 , m_mediaQueries(media) 376 , m_mediaQueries(media)
377 { 377 {
378 } 378 }
379 379
380 StyleRuleMedia::StyleRuleMedia(const StyleRuleMedia& o) 380 StyleRuleMedia::StyleRuleMedia(const StyleRuleMedia& o)
381 : StyleRuleGroup(o) 381 : StyleRuleGroup(o)
382 { 382 {
383 if (o.m_mediaQueries) 383 if (o.m_mediaQueries)
384 m_mediaQueries = o.m_mediaQueries->copy(); 384 m_mediaQueries = o.m_mediaQueries->copy();
(...skipping 12 matching lines...) Expand all
397 { 397 {
398 } 398 }
399 399
400 StyleRuleSupports::StyleRuleSupports(const StyleRuleSupports& o) 400 StyleRuleSupports::StyleRuleSupports(const StyleRuleSupports& o)
401 : StyleRuleGroup(o) 401 : StyleRuleGroup(o)
402 , m_conditionText(o.m_conditionText) 402 , m_conditionText(o.m_conditionText)
403 , m_conditionIsSupported(o.m_conditionIsSupported) 403 , m_conditionIsSupported(o.m_conditionIsSupported)
404 { 404 {
405 } 405 }
406 406
407 StyleRuleViewport::StyleRuleViewport(RawPtr<StylePropertySet> properties) 407 StyleRuleViewport::StyleRuleViewport(StylePropertySet* properties)
408 : StyleRuleBase(Viewport) 408 : StyleRuleBase(Viewport)
409 , m_properties(properties) 409 , m_properties(properties)
410 { 410 {
411 } 411 }
412 412
413 StyleRuleViewport::StyleRuleViewport(const StyleRuleViewport& o) 413 StyleRuleViewport::StyleRuleViewport(const StyleRuleViewport& o)
414 : StyleRuleBase(o) 414 : StyleRuleBase(o)
415 , m_properties(o.m_properties->mutableCopy()) 415 , m_properties(o.m_properties->mutableCopy())
416 { 416 {
417 } 417 }
418 418
419 StyleRuleViewport::~StyleRuleViewport() 419 StyleRuleViewport::~StyleRuleViewport()
420 { 420 {
421 } 421 }
422 422
423 MutableStylePropertySet& StyleRuleViewport::mutableProperties() 423 MutableStylePropertySet& StyleRuleViewport::mutableProperties()
424 { 424 {
425 if (!m_properties->isMutable()) 425 if (!m_properties->isMutable())
426 m_properties = m_properties->mutableCopy(); 426 m_properties = m_properties->mutableCopy();
427 return *toMutableStylePropertySet(m_properties); 427 return *toMutableStylePropertySet(m_properties);
428 } 428 }
429 429
430 DEFINE_TRACE_AFTER_DISPATCH(StyleRuleViewport) 430 DEFINE_TRACE_AFTER_DISPATCH(StyleRuleViewport)
431 { 431 {
432 visitor->trace(m_properties); 432 visitor->trace(m_properties);
433 StyleRuleBase::traceAfterDispatch(visitor); 433 StyleRuleBase::traceAfterDispatch(visitor);
434 } 434 }
435 435
436 } // namespace blink 436 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/css/StyleRule.h ('k') | third_party/WebKit/Source/core/css/StyleRuleImport.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698