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

Side by Side Diff: third_party/WebKit/Source/core/style/ComputedStyle.cpp

Issue 2735283002: Combine ComputedStyle default ctor with initial style ctor. (Closed)
Patch Set: Rebase Created 3 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 | « third_party/WebKit/Source/core/style/ComputedStyle.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 3 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010 Apple Inc. All rights
4 * reserved. 4 * reserved.
5 * Copyright (C) 2011 Adobe Systems Incorporated. All rights reserved. 5 * Copyright (C) 2011 Adobe Systems Incorporated. All rights reserved.
6 * 6 *
7 * This library is free software; you can redistribute it and/or 7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Library General Public 8 * modify it under the terms of the GNU Library General Public
9 * License as published by the Free Software Foundation; either 9 * License as published by the Free Software Foundation; either
10 * version 2 of the License, or (at your option) any later version. 10 * version 2 of the License, or (at your option) any later version.
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
88 } m_nonInheritedData; 88 } m_nonInheritedData;
89 }; 89 };
90 90
91 // If this assert fails, it means that size of ComputedStyle has changed. Please 91 // If this assert fails, it means that size of ComputedStyle has changed. Please
92 // check that you really *do* what to increase the size of ComputedStyle, then 92 // check that you really *do* what to increase the size of ComputedStyle, then
93 // update the SameSizeAsComputedStyle struct to match the updated storage of 93 // update the SameSizeAsComputedStyle struct to match the updated storage of
94 // ComputedStyle. 94 // ComputedStyle.
95 ASSERT_SIZE(ComputedStyle, SameSizeAsComputedStyle); 95 ASSERT_SIZE(ComputedStyle, SameSizeAsComputedStyle);
96 96
97 PassRefPtr<ComputedStyle> ComputedStyle::create() { 97 PassRefPtr<ComputedStyle> ComputedStyle::create() {
98 return adoptRef(new ComputedStyle()); 98 return adoptRef(new ComputedStyle(initialStyle()));
99 } 99 }
100 100
101 PassRefPtr<ComputedStyle> ComputedStyle::createInitialStyle() { 101 PassRefPtr<ComputedStyle> ComputedStyle::createInitialStyle() {
102 return adoptRef(new ComputedStyle(InitialStyle)); 102 return adoptRef(new ComputedStyle(InitialStyle));
103 } 103 }
104 104
105 void ComputedStyle::invalidateInitialStyle() { 105 void ComputedStyle::invalidateInitialStyle() {
106 mutableInitialStyle().setTapHighlightColor(initialTapHighlightColor()); 106 mutableInitialStyle().setTapHighlightColor(initialTapHighlightColor());
107 } 107 }
108 108
109 PassRefPtr<ComputedStyle> ComputedStyle::createAnonymousStyleWithDisplay( 109 PassRefPtr<ComputedStyle> ComputedStyle::createAnonymousStyleWithDisplay(
110 const ComputedStyle& parentStyle, 110 const ComputedStyle& parentStyle,
111 EDisplay display) { 111 EDisplay display) {
112 RefPtr<ComputedStyle> newStyle = ComputedStyle::create(); 112 RefPtr<ComputedStyle> newStyle = ComputedStyle::create();
113 newStyle->inheritFrom(parentStyle); 113 newStyle->inheritFrom(parentStyle);
114 newStyle->setUnicodeBidi(parentStyle.getUnicodeBidi()); 114 newStyle->setUnicodeBidi(parentStyle.getUnicodeBidi());
115 newStyle->setDisplay(display); 115 newStyle->setDisplay(display);
116 return newStyle; 116 return newStyle;
117 } 117 }
118 118
119 PassRefPtr<ComputedStyle> ComputedStyle::clone(const ComputedStyle& other) { 119 PassRefPtr<ComputedStyle> ComputedStyle::clone(const ComputedStyle& other) {
120 return adoptRef(new ComputedStyle(other)); 120 return adoptRef(new ComputedStyle(other));
121 } 121 }
122 122
123 ALWAYS_INLINE ComputedStyle::ComputedStyle()
124 : ComputedStyleBase(),
125 RefCounted<ComputedStyle>(),
126 m_box(initialStyle().m_box),
127 m_visual(initialStyle().m_visual),
128 m_background(initialStyle().m_background),
129 m_surround(initialStyle().m_surround),
130 m_rareNonInheritedData(initialStyle().m_rareNonInheritedData),
131 m_rareInheritedData(initialStyle().m_rareInheritedData),
132 m_styleInheritedData(initialStyle().m_styleInheritedData),
133 m_svgStyle(initialStyle().m_svgStyle) {
134 initializeBitDefaults(); // Would it be faster to copy this from the default
135 // style?
136 static_assert((sizeof(InheritedData) <= 8), "InheritedData should not grow");
137 static_assert((sizeof(NonInheritedData) <= 12),
138 "NonInheritedData should not grow");
139 }
140
141 ALWAYS_INLINE ComputedStyle::ComputedStyle(InitialStyleTag) 123 ALWAYS_INLINE ComputedStyle::ComputedStyle(InitialStyleTag)
142 : ComputedStyleBase(), RefCounted<ComputedStyle>() { 124 : ComputedStyleBase(), RefCounted<ComputedStyle>() {
143 initializeBitDefaults(); 125 initializeBitDefaults();
144 126
145 m_box.init(); 127 m_box.init();
146 m_visual.init(); 128 m_visual.init();
147 m_background.init(); 129 m_background.init();
148 m_surround.init(); 130 m_surround.init();
149 m_rareNonInheritedData.init(); 131 m_rareNonInheritedData.init();
150 m_rareNonInheritedData.access()->m_deprecatedFlexibleBox.init(); 132 m_rareNonInheritedData.access()->m_deprecatedFlexibleBox.init();
(...skipping 2348 matching lines...) Expand 10 before | Expand all | Expand 10 after
2499 if (value < 0) 2481 if (value < 0)
2500 fvalue -= 0.5f; 2482 fvalue -= 0.5f;
2501 else 2483 else
2502 fvalue += 0.5f; 2484 fvalue += 0.5f;
2503 } 2485 }
2504 2486
2505 return roundForImpreciseConversion<int>(fvalue / zoomFactor); 2487 return roundForImpreciseConversion<int>(fvalue / zoomFactor);
2506 } 2488 }
2507 2489
2508 } // namespace blink 2490 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/style/ComputedStyle.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698