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

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

Issue 16161005: Reduce CSSProperty's StylePropertyMetadata memory footprint by half when used inside a ImmutableSty… (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 7 years, 6 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/CSSProperty.h ('k') | Source/core/css/StylePropertySet.h » ('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 * (C) 1999-2003 Lars Knoll (knoll@kde.org) 2 * (C) 1999-2003 Lars Knoll (knoll@kde.org)
3 * Copyright (C) 2004, 2005, 2006 Apple Computer, Inc. 3 * Copyright (C) 2004, 2005, 2006 Apple Computer, Inc.
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 19 matching lines...) Expand all
30 30
31 namespace WebCore { 31 namespace WebCore {
32 32
33 struct SameSizeAsCSSProperty { 33 struct SameSizeAsCSSProperty {
34 uint32_t bitfields; 34 uint32_t bitfields;
35 void* value; 35 void* value;
36 }; 36 };
37 37
38 COMPILE_ASSERT(sizeof(CSSProperty) == sizeof(SameSizeAsCSSProperty), CSSProperty _should_stay_small); 38 COMPILE_ASSERT(sizeof(CSSProperty) == sizeof(SameSizeAsCSSProperty), CSSProperty _should_stay_small);
39 39
40 CSSPropertyID StylePropertyMetadata::shorthandID() const
41 {
42 if (!m_isSetFromShorthand)
43 return CSSPropertyInvalid;
44
45 const Vector<StylePropertyShorthand> shorthands = matchingShorthandsForLongh and(static_cast<CSSPropertyID>(m_propertyID));
46 ASSERT(shorthands.size() && m_indexInShorthandsVector >= 0 && m_indexInShort handsVector < shorthands.size());
47 return shorthands.at(m_indexInShorthandsVector).id();
48 }
49
40 void CSSProperty::wrapValueInCommaSeparatedList() 50 void CSSProperty::wrapValueInCommaSeparatedList()
41 { 51 {
42 RefPtr<CSSValue> value = m_value.release(); 52 RefPtr<CSSValue> value = m_value.release();
43 m_value = CSSValueList::createCommaSeparated(); 53 m_value = CSSValueList::createCommaSeparated();
44 toCSSValueList(m_value.get())->append(value.release()); 54 toCSSValueList(m_value.get())->append(value.release());
45 } 55 }
46 56
47 enum LogicalBoxSide { BeforeSide, EndSide, AfterSide, StartSide }; 57 enum LogicalBoxSide { BeforeSide, EndSide, AfterSide, StartSide };
48 enum PhysicalBoxSide { TopSide, RightSide, BottomSide, LeftSide }; 58 enum PhysicalBoxSide { TopSide, RightSide, BottomSide, LeftSide };
49 59
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after
157 static CSSPropertyID resolveToPhysicalProperty(WritingMode writingMode, LogicalE xtent logicalSide, const CSSPropertyID* properties) 167 static CSSPropertyID resolveToPhysicalProperty(WritingMode writingMode, LogicalE xtent logicalSide, const CSSPropertyID* properties)
158 { 168 {
159 if (writingMode == TopToBottomWritingMode || writingMode == BottomToTopWriti ngMode) 169 if (writingMode == TopToBottomWritingMode || writingMode == BottomToTopWriti ngMode)
160 return properties[logicalSide]; 170 return properties[logicalSide];
161 return logicalSide == LogicalWidth ? properties[1] : properties[0]; 171 return logicalSide == LogicalWidth ? properties[1] : properties[0];
162 } 172 }
163 173
164 static const StylePropertyShorthand& borderDirections() 174 static const StylePropertyShorthand& borderDirections()
165 { 175 {
166 static const CSSPropertyID properties[4] = { CSSPropertyBorderTop, CSSProper tyBorderRight, CSSPropertyBorderBottom, CSSPropertyBorderLeft }; 176 static const CSSPropertyID properties[4] = { CSSPropertyBorderTop, CSSProper tyBorderRight, CSSPropertyBorderBottom, CSSPropertyBorderLeft };
167 DEFINE_STATIC_LOCAL(StylePropertyShorthand, borderDirections, (properties, W TF_ARRAY_LENGTH(properties))); 177 DEFINE_STATIC_LOCAL(StylePropertyShorthand, borderDirections, (CSSPropertyBo rder, properties, WTF_ARRAY_LENGTH(properties)));
168 return borderDirections; 178 return borderDirections;
169 } 179 }
170 180
171 CSSPropertyID CSSProperty::resolveDirectionAwareProperty(CSSPropertyID propertyI D, TextDirection direction, WritingMode writingMode) 181 CSSPropertyID CSSProperty::resolveDirectionAwareProperty(CSSPropertyID propertyI D, TextDirection direction, WritingMode writingMode)
172 { 182 {
173 switch (propertyID) { 183 switch (propertyID) {
174 case CSSPropertyWebkitMarginEnd: 184 case CSSPropertyWebkitMarginEnd:
175 return resolveToPhysicalProperty(direction, writingMode, EndSide, margin Shorthand()); 185 return resolveToPhysicalProperty(direction, writingMode, EndSide, margin Shorthand());
176 case CSSPropertyWebkitMarginStart: 186 case CSSPropertyWebkitMarginStart:
177 return resolveToPhysicalProperty(direction, writingMode, StartSide, marg inShorthand()); 187 return resolveToPhysicalProperty(direction, writingMode, StartSide, marg inShorthand());
(...skipping 491 matching lines...) Expand 10 before | Expand all | Expand 10 after
669 } 679 }
670 680
671 void CSSProperty::reportMemoryUsage(MemoryObjectInfo* memoryObjectInfo) const 681 void CSSProperty::reportMemoryUsage(MemoryObjectInfo* memoryObjectInfo) const
672 { 682 {
673 MemoryClassInfo info(memoryObjectInfo, this, WebCoreMemoryTypes::CSS); 683 MemoryClassInfo info(memoryObjectInfo, this, WebCoreMemoryTypes::CSS);
674 info.addMember(m_value, "value"); 684 info.addMember(m_value, "value");
675 info.ignoreMember(m_metadata); 685 info.ignoreMember(m_metadata);
676 } 686 }
677 687
678 } // namespace WebCore 688 } // namespace WebCore
OLDNEW
« no previous file with comments | « Source/core/css/CSSProperty.h ('k') | Source/core/css/StylePropertySet.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698