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

Side by Side Diff: Source/core/css/CSSValue.cpp

Issue 1310603004: WIP: Reduce sizeof(CSSValue) by 8 byte Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 5 years, 3 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 | Annotate | Revision Log
« no previous file with comments | « Source/core/css/CSSValue.h ('k') | Source/core/css/CSSValueList.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2011 Andreas Kling (kling@webkit.org) 2 * Copyright (C) 2011 Andreas Kling (kling@webkit.org)
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions 5 * modification, are permitted provided that the following conditions
6 * are met: 6 * are met:
7 * 1. Redistributions of source code must retain the above copyright 7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer. 8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright 9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the 10 * notice, this list of conditions and the following disclaimer in the
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
57 namespace blink { 57 namespace blink {
58 58
59 struct SameSizeAsCSSValue : public RefCountedWillBeGarbageCollectedFinalized<Sam eSizeAsCSSValue> { 59 struct SameSizeAsCSSValue : public RefCountedWillBeGarbageCollectedFinalized<Sam eSizeAsCSSValue> {
60 uint32_t bitfields; 60 uint32_t bitfields;
61 }; 61 };
62 62
63 static_assert(sizeof(CSSValue) <= sizeof(SameSizeAsCSSValue), "CSSValue should s tay small"); 63 static_assert(sizeof(CSSValue) <= sizeof(SameSizeAsCSSValue), "CSSValue should s tay small");
64 64
65 bool CSSValue::isImplicitInitialValue() const 65 bool CSSValue::isImplicitInitialValue() const
66 { 66 {
67 return m_classType == InitialClass && toCSSInitialValue(this)->isImplicit(); 67 return classType() == InitialClass && toCSSInitialValue(this)->isImplicit();
68 } 68 }
69 69
70 bool CSSValue::hasFailedOrCanceledSubresources() const 70 bool CSSValue::hasFailedOrCanceledSubresources() const
71 { 71 {
72 if (isValueList()) 72 if (isValueList())
73 return toCSSValueList(this)->hasFailedOrCanceledSubresources(); 73 return toCSSValueList(this)->hasFailedOrCanceledSubresources();
74 if (classType() == FontFaceSrcClass) 74 if (classType() == FontFaceSrcClass)
75 return toCSSFontFaceSrcValue(this)->hasFailedOrCanceledSubresources(); 75 return toCSSFontFaceSrcValue(this)->hasFailedOrCanceledSubresources();
76 if (classType() == ImageClass) 76 if (classType() == ImageClass)
77 return toCSSImageValue(this)->hasFailedOrCanceledSubresources(); 77 return toCSSImageValue(this)->hasFailedOrCanceledSubresources();
78 if (classType() == CrossfadeClass) 78 if (classType() == CrossfadeClass)
79 return toCSSCrossfadeValue(this)->hasFailedOrCanceledSubresources(); 79 return toCSSCrossfadeValue(this)->hasFailedOrCanceledSubresources();
80 if (classType() == ImageSetClass) 80 if (classType() == ImageSetClass)
81 return toCSSImageSetValue(this)->hasFailedOrCanceledSubresources(); 81 return toCSSImageSetValue(this)->hasFailedOrCanceledSubresources();
82 82
83 return false; 83 return false;
84 } 84 }
85 85
86 template<class ChildClassType> 86 template<class ChildClassType>
87 inline static bool compareCSSValues(const CSSValue& first, const CSSValue& secon d) 87 inline static bool compareCSSValues(const CSSValue& first, const CSSValue& secon d)
88 { 88 {
89 return static_cast<const ChildClassType&>(first).equals(static_cast<const Ch ildClassType&>(second)); 89 return static_cast<const ChildClassType&>(first).equals(static_cast<const Ch ildClassType&>(second));
90 } 90 }
91 91
92 bool CSSValue::equals(const CSSValue& other) const 92 bool CSSValue::equals(const CSSValue& other) const
93 { 93 {
94 if (m_classType == other.m_classType) { 94 if (classType() == other.classType()) {
95 switch (classType()) { 95 switch (classType()) {
96 case BorderImageSliceClass: 96 case BorderImageSliceClass:
97 return compareCSSValues<CSSBorderImageSliceValue>(*this, other); 97 return compareCSSValues<CSSBorderImageSliceValue>(*this, other);
98 case CanvasClass: 98 case CanvasClass:
99 return compareCSSValues<CSSCanvasValue>(*this, other); 99 return compareCSSValues<CSSCanvasValue>(*this, other);
100 case CounterClass: 100 case CounterClass:
101 return compareCSSValues<CSSCounterValue>(*this, other); 101 return compareCSSValues<CSSCounterValue>(*this, other);
102 case CursorImageClass: 102 case CursorImageClass:
103 return compareCSSValues<CSSCursorImageValue>(*this, other); 103 return compareCSSValues<CSSCursorImageValue>(*this, other);
104 case FontFaceSrcClass: 104 case FontFaceSrcClass:
(...skipping 382 matching lines...) Expand 10 before | Expand all | Expand 10 after
487 toCSSSVGDocumentValue(this)->traceAfterDispatch(visitor); 487 toCSSSVGDocumentValue(this)->traceAfterDispatch(visitor);
488 return; 488 return;
489 case CSSContentDistributionClass: 489 case CSSContentDistributionClass:
490 toCSSContentDistributionValue(this)->traceAfterDispatch(visitor); 490 toCSSContentDistributionValue(this)->traceAfterDispatch(visitor);
491 return; 491 return;
492 } 492 }
493 ASSERT_NOT_REACHED(); 493 ASSERT_NOT_REACHED();
494 } 494 }
495 495
496 } 496 }
OLDNEW
« no previous file with comments | « Source/core/css/CSSValue.h ('k') | Source/core/css/CSSValueList.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698