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

Side by Side Diff: Source/core/rendering/style/StyleRareInheritedData.cpp

Issue 196103013: Pack StyleColor members in StyleRareInheritedData tighter to save memory (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Fix initial isCurrentColor valuse Created 6 years, 9 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
« no previous file with comments | « Source/core/rendering/style/StyleRareInheritedData.h ('k') | no next file » | 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) 1999 Antti Koivisto (koivisto@kde.org) 2 * Copyright (C) 1999 Antti Koivisto (koivisto@kde.org)
3 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010 Apple Inc. All rights reserved. 3 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010 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 15 matching lines...) Expand all
26 #include "core/rendering/style/QuotesData.h" 26 #include "core/rendering/style/QuotesData.h"
27 #include "core/rendering/style/RenderStyle.h" 27 #include "core/rendering/style/RenderStyle.h"
28 #include "core/rendering/style/RenderStyleConstants.h" 28 #include "core/rendering/style/RenderStyleConstants.h"
29 #include "core/rendering/style/ShadowList.h" 29 #include "core/rendering/style/ShadowList.h"
30 #include "core/rendering/style/StyleImage.h" 30 #include "core/rendering/style/StyleImage.h"
31 31
32 namespace WebCore { 32 namespace WebCore {
33 33
34 struct SameSizeAsStyleRareInheritedData : public RefCounted<SameSizeAsStyleRareI nheritedData> { 34 struct SameSizeAsStyleRareInheritedData : public RefCounted<SameSizeAsStyleRareI nheritedData> {
35 void* styleImage; 35 void* styleImage;
36 StyleColor firstColor; 36 Color firstColor;
37 float firstFloat; 37 float firstFloat;
38 StyleColor colors[5]; 38 Color colors[5];
39 void* ownPtrs[1]; 39 void* ownPtrs[1];
40 AtomicString atomicStrings[4]; 40 AtomicString atomicStrings[4];
41 void* refPtrs[2]; 41 void* refPtrs[2];
42 Length lengths[1]; 42 Length lengths[1];
43 float secondFloat; 43 float secondFloat;
44 unsigned m_bitfields[2]; 44 unsigned m_bitfields[2];
45 short pagedMediaShorts[2]; 45 short pagedMediaShorts[2];
46 unsigned unsigneds[1]; 46 unsigned unsigneds[1];
47 short hyphenationShorts[3]; 47 short hyphenationShorts[3];
48 48
49 Color touchColors; 49 Color touchColors;
50 }; 50 };
51 51
52 COMPILE_ASSERT(sizeof(StyleRareInheritedData) == sizeof(SameSizeAsStyleRareInher itedData), StyleRareInheritedData_should_bit_pack); 52 COMPILE_ASSERT(sizeof(StyleRareInheritedData) == sizeof(SameSizeAsStyleRareInher itedData), StyleRareInheritedData_should_bit_pack);
53 53
54 StyleRareInheritedData::StyleRareInheritedData() 54 StyleRareInheritedData::StyleRareInheritedData()
55 : listStyleImage(RenderStyle::initialListStyleImage()) 55 : listStyleImage(RenderStyle::initialListStyleImage())
56 , textStrokeColor(StyleColor::currentColor())
57 , textStrokeWidth(RenderStyle::initialTextStrokeWidth()) 56 , textStrokeWidth(RenderStyle::initialTextStrokeWidth())
58 , textFillColor(StyleColor::currentColor())
59 , textEmphasisColor(StyleColor::currentColor())
60 , visitedLinkTextStrokeColor(StyleColor::currentColor())
61 , visitedLinkTextFillColor(StyleColor::currentColor())
62 , visitedLinkTextEmphasisColor(StyleColor::currentColor())
63 , indent(RenderStyle::initialTextIndent()) 57 , indent(RenderStyle::initialTextIndent())
64 , m_effectiveZoom(RenderStyle::initialZoom()) 58 , m_effectiveZoom(RenderStyle::initialZoom())
65 , widows(RenderStyle::initialWidows()) 59 , widows(RenderStyle::initialWidows())
66 , orphans(RenderStyle::initialOrphans()) 60 , orphans(RenderStyle::initialOrphans())
67 , m_hasAutoWidows(true) 61 , m_hasAutoWidows(true)
68 , m_hasAutoOrphans(true) 62 , m_hasAutoOrphans(true)
63 , m_textStrokeColorIsCurrentColor(true)
64 , m_textFillColorIsCurrentColor(true)
65 , m_textEmphasisColorIsCurrentColor(true)
66 , m_visitedLinkTextStrokeColorIsCurrentColor(true)
67 , m_visitedLinkTextFillColorIsCurrentColor(true)
68 , m_visitedLinkTextEmphasisColorIsCurrentColor(true)
69 , textSecurity(RenderStyle::initialTextSecurity()) 69 , textSecurity(RenderStyle::initialTextSecurity())
70 , userModify(READ_ONLY) 70 , userModify(READ_ONLY)
71 , wordBreak(RenderStyle::initialWordBreak()) 71 , wordBreak(RenderStyle::initialWordBreak())
72 , overflowWrap(RenderStyle::initialOverflowWrap()) 72 , overflowWrap(RenderStyle::initialOverflowWrap())
73 , lineBreak(LineBreakAuto) 73 , lineBreak(LineBreakAuto)
74 , resize(RenderStyle::initialResize()) 74 , resize(RenderStyle::initialResize())
75 , userSelect(RenderStyle::initialUserSelect()) 75 , userSelect(RenderStyle::initialUserSelect())
76 , speak(SpeakNormal) 76 , speak(SpeakNormal)
77 , hyphens(HyphensManual) 77 , hyphens(HyphensManual)
78 , textEmphasisFill(TextEmphasisFillFilled) 78 , textEmphasisFill(TextEmphasisFillFilled)
(...skipping 12 matching lines...) Expand all
91 , hyphenationLimitAfter(-1) 91 , hyphenationLimitAfter(-1)
92 , hyphenationLimitLines(-1) 92 , hyphenationLimitLines(-1)
93 , m_tabSize(RenderStyle::initialTabSize()) 93 , m_tabSize(RenderStyle::initialTabSize())
94 , tapHighlightColor(RenderStyle::initialTapHighlightColor()) 94 , tapHighlightColor(RenderStyle::initialTapHighlightColor())
95 { 95 {
96 } 96 }
97 97
98 StyleRareInheritedData::StyleRareInheritedData(const StyleRareInheritedData& o) 98 StyleRareInheritedData::StyleRareInheritedData(const StyleRareInheritedData& o)
99 : RefCounted<StyleRareInheritedData>() 99 : RefCounted<StyleRareInheritedData>()
100 , listStyleImage(o.listStyleImage) 100 , listStyleImage(o.listStyleImage)
101 , textStrokeColor(o.textStrokeColor) 101 , m_textStrokeColor(o.m_textStrokeColor)
102 , textStrokeWidth(o.textStrokeWidth) 102 , textStrokeWidth(o.textStrokeWidth)
103 , textFillColor(o.textFillColor) 103 , m_textFillColor(o.m_textFillColor)
104 , textEmphasisColor(o.textEmphasisColor) 104 , m_textEmphasisColor(o.m_textEmphasisColor)
105 , visitedLinkTextStrokeColor(o.visitedLinkTextStrokeColor) 105 , m_visitedLinkTextStrokeColor(o.m_visitedLinkTextStrokeColor)
106 , visitedLinkTextFillColor(o.visitedLinkTextFillColor) 106 , m_visitedLinkTextFillColor(o.m_visitedLinkTextFillColor)
107 , visitedLinkTextEmphasisColor(o.visitedLinkTextEmphasisColor) 107 , m_visitedLinkTextEmphasisColor(o.m_visitedLinkTextEmphasisColor)
108 , textShadow(o.textShadow) 108 , textShadow(o.textShadow)
109 , highlight(o.highlight) 109 , highlight(o.highlight)
110 , cursorData(o.cursorData) 110 , cursorData(o.cursorData)
111 , indent(o.indent) 111 , indent(o.indent)
112 , m_effectiveZoom(o.m_effectiveZoom) 112 , m_effectiveZoom(o.m_effectiveZoom)
113 , widows(o.widows) 113 , widows(o.widows)
114 , orphans(o.orphans) 114 , orphans(o.orphans)
115 , m_hasAutoWidows(o.m_hasAutoWidows) 115 , m_hasAutoWidows(o.m_hasAutoWidows)
116 , m_hasAutoOrphans(o.m_hasAutoOrphans) 116 , m_hasAutoOrphans(o.m_hasAutoOrphans)
117 , m_textStrokeColorIsCurrentColor(o.m_textStrokeColorIsCurrentColor)
118 , m_textFillColorIsCurrentColor(o.m_textFillColorIsCurrentColor)
119 , m_textEmphasisColorIsCurrentColor(o.m_textEmphasisColorIsCurrentColor)
120 , m_visitedLinkTextStrokeColorIsCurrentColor(o.m_visitedLinkTextStrokeColorI sCurrentColor)
121 , m_visitedLinkTextFillColorIsCurrentColor(o.m_visitedLinkTextFillColorIsCur rentColor)
122 , m_visitedLinkTextEmphasisColorIsCurrentColor(o.m_visitedLinkTextEmphasisCo lorIsCurrentColor)
117 , textSecurity(o.textSecurity) 123 , textSecurity(o.textSecurity)
118 , userModify(o.userModify) 124 , userModify(o.userModify)
119 , wordBreak(o.wordBreak) 125 , wordBreak(o.wordBreak)
120 , overflowWrap(o.overflowWrap) 126 , overflowWrap(o.overflowWrap)
121 , lineBreak(o.lineBreak) 127 , lineBreak(o.lineBreak)
122 , resize(o.resize) 128 , resize(o.resize)
123 , userSelect(o.userSelect) 129 , userSelect(o.userSelect)
124 , speak(o.speak) 130 , speak(o.speak)
125 , hyphens(o.hyphens) 131 , hyphens(o.hyphens)
126 , textEmphasisFill(o.textEmphasisFill) 132 , textEmphasisFill(o.textEmphasisFill)
(...skipping 27 matching lines...) Expand all
154 { 160 {
155 if (c1 == c2) 161 if (c1 == c2)
156 return true; 162 return true;
157 if ((!c1 && c2) || (c1 && !c2)) 163 if ((!c1 && c2) || (c1 && !c2))
158 return false; 164 return false;
159 return (*c1 == *c2); 165 return (*c1 == *c2);
160 } 166 }
161 167
162 bool StyleRareInheritedData::operator==(const StyleRareInheritedData& o) const 168 bool StyleRareInheritedData::operator==(const StyleRareInheritedData& o) const
163 { 169 {
164 return textStrokeColor == o.textStrokeColor 170 return m_textStrokeColor == o.m_textStrokeColor
165 && textStrokeWidth == o.textStrokeWidth 171 && textStrokeWidth == o.textStrokeWidth
166 && textFillColor == o.textFillColor 172 && m_textFillColor == o.m_textFillColor
167 && textEmphasisColor == o.textEmphasisColor 173 && m_textEmphasisColor == o.m_textEmphasisColor
168 && visitedLinkTextStrokeColor == o.visitedLinkTextStrokeColor 174 && m_visitedLinkTextStrokeColor == o.m_visitedLinkTextStrokeColor
169 && visitedLinkTextFillColor == o.visitedLinkTextFillColor 175 && m_visitedLinkTextFillColor == o.m_visitedLinkTextFillColor
170 && visitedLinkTextEmphasisColor == o.visitedLinkTextEmphasisColor 176 && m_visitedLinkTextEmphasisColor == o.m_visitedLinkTextEmphasisColor
171 && tapHighlightColor == o.tapHighlightColor 177 && tapHighlightColor == o.tapHighlightColor
172 && shadowDataEquivalent(o) 178 && shadowDataEquivalent(o)
173 && highlight == o.highlight 179 && highlight == o.highlight
174 && cursorDataEquivalent(cursorData.get(), o.cursorData.get()) 180 && cursorDataEquivalent(cursorData.get(), o.cursorData.get())
175 && indent == o.indent 181 && indent == o.indent
176 && m_effectiveZoom == o.m_effectiveZoom 182 && m_effectiveZoom == o.m_effectiveZoom
177 && widows == o.widows 183 && widows == o.widows
178 && orphans == o.orphans 184 && orphans == o.orphans
179 && m_hasAutoWidows == o.m_hasAutoWidows 185 && m_hasAutoWidows == o.m_hasAutoWidows
180 && m_hasAutoOrphans == o.m_hasAutoOrphans 186 && m_hasAutoOrphans == o.m_hasAutoOrphans
187 && m_textStrokeColorIsCurrentColor == o.m_textStrokeColorIsCurrentColor
188 && m_textFillColorIsCurrentColor == o.m_textFillColorIsCurrentColor
189 && m_textEmphasisColorIsCurrentColor == o.m_textEmphasisColorIsCurrentCo lor
190 && m_visitedLinkTextStrokeColorIsCurrentColor == o.m_visitedLinkTextStro keColorIsCurrentColor
191 && m_visitedLinkTextFillColorIsCurrentColor == o.m_visitedLinkTextFillCo lorIsCurrentColor
192 && m_visitedLinkTextEmphasisColorIsCurrentColor == o.m_visitedLinkTextEm phasisColorIsCurrentColor
181 && textSecurity == o.textSecurity 193 && textSecurity == o.textSecurity
182 && userModify == o.userModify 194 && userModify == o.userModify
183 && wordBreak == o.wordBreak 195 && wordBreak == o.wordBreak
184 && overflowWrap == o.overflowWrap 196 && overflowWrap == o.overflowWrap
185 && lineBreak == o.lineBreak 197 && lineBreak == o.lineBreak
186 && resize == o.resize 198 && resize == o.resize
187 && userSelect == o.userSelect 199 && userSelect == o.userSelect
188 && speak == o.speak 200 && speak == o.speak
189 && hyphens == o.hyphens 201 && hyphens == o.hyphens
190 && hyphenationLimitBefore == o.hyphenationLimitBefore 202 && hyphenationLimitBefore == o.hyphenationLimitBefore
(...skipping 22 matching lines...) Expand all
213 bool StyleRareInheritedData::shadowDataEquivalent(const StyleRareInheritedData& o) const 225 bool StyleRareInheritedData::shadowDataEquivalent(const StyleRareInheritedData& o) const
214 { 226 {
215 if ((!textShadow && o.textShadow) || (textShadow && !o.textShadow)) 227 if ((!textShadow && o.textShadow) || (textShadow && !o.textShadow))
216 return false; 228 return false;
217 if (textShadow && o.textShadow && (*textShadow != *o.textShadow)) 229 if (textShadow && o.textShadow && (*textShadow != *o.textShadow))
218 return false; 230 return false;
219 return true; 231 return true;
220 } 232 }
221 233
222 } // namespace WebCore 234 } // namespace WebCore
OLDNEW
« no previous file with comments | « Source/core/rendering/style/StyleRareInheritedData.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698