Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 Loading... | |
| 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())); |
|
sashab
2017/03/09 23:48:22
Does this have a perf cost?
shend
2017/03/14 06:05:21
Shouldn't affect perf since initialStyle() returns
| |
| 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(); |
| 151 m_rareNonInheritedData.access()->m_flexibleBox.init(); | 133 m_rareNonInheritedData.access()->m_flexibleBox.init(); |
| 152 m_rareNonInheritedData.access()->m_multiCol.init(); | 134 m_rareNonInheritedData.access()->m_multiCol.init(); |
| 153 m_rareNonInheritedData.access()->m_transform.init(); | 135 m_rareNonInheritedData.access()->m_transform.init(); |
| 154 m_rareNonInheritedData.access()->m_willChange.init(); | 136 m_rareNonInheritedData.access()->m_willChange.init(); |
| 155 m_rareNonInheritedData.access()->m_filter.init(); | 137 m_rareNonInheritedData.access()->m_filter.init(); |
| 156 m_rareNonInheritedData.access()->m_backdropFilter.init(); | 138 m_rareNonInheritedData.access()->m_backdropFilter.init(); |
| 157 m_rareNonInheritedData.access()->m_grid.init(); | 139 m_rareNonInheritedData.access()->m_grid.init(); |
| 158 m_rareNonInheritedData.access()->m_gridItem.init(); | 140 m_rareNonInheritedData.access()->m_gridItem.init(); |
| 159 m_rareNonInheritedData.access()->m_scrollSnap.init(); | 141 m_rareNonInheritedData.access()->m_scrollSnap.init(); |
| 160 m_rareInheritedData.init(); | 142 m_rareInheritedData.init(); |
| 161 m_styleInheritedData.init(); | 143 m_styleInheritedData.init(); |
| 162 m_svgStyle.init(); | 144 m_svgStyle.init(); |
| 145 | |
| 146 static_assert((sizeof(InheritedData) <= 8), "InheritedData should not grow"); | |
| 147 static_assert((sizeof(NonInheritedData) <= 12), | |
| 148 "NonInheritedData should not grow"); | |
|
meade_UTC10
2017/03/09 05:43:13
Is there a problem with moving these static_assert
shend
2017/03/09 14:59:54
Yeah I don't know why they're in the constructor.
sashab
2017/03/09 23:48:22
Hmm, you can check git blame, but this looks like
shend
2017/03/14 06:05:21
Done.
| |
| 163 } | 149 } |
| 164 | 150 |
| 165 ALWAYS_INLINE ComputedStyle::ComputedStyle(const ComputedStyle& o) | 151 ALWAYS_INLINE ComputedStyle::ComputedStyle(const ComputedStyle& o) |
| 166 : ComputedStyleBase(o), | 152 : ComputedStyleBase(o), |
| 167 RefCounted<ComputedStyle>(), | 153 RefCounted<ComputedStyle>(), |
| 168 m_box(o.m_box), | 154 m_box(o.m_box), |
| 169 m_visual(o.m_visual), | 155 m_visual(o.m_visual), |
| 170 m_background(o.m_background), | 156 m_background(o.m_background), |
| 171 m_surround(o.m_surround), | 157 m_surround(o.m_surround), |
| 172 m_rareNonInheritedData(o.m_rareNonInheritedData), | 158 m_rareNonInheritedData(o.m_rareNonInheritedData), |
| (...skipping 2325 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2498 if (value < 0) | 2484 if (value < 0) |
| 2499 fvalue -= 0.5f; | 2485 fvalue -= 0.5f; |
| 2500 else | 2486 else |
| 2501 fvalue += 0.5f; | 2487 fvalue += 0.5f; |
| 2502 } | 2488 } |
| 2503 | 2489 |
| 2504 return roundForImpreciseConversion<int>(fvalue / zoomFactor); | 2490 return roundForImpreciseConversion<int>(fvalue / zoomFactor); |
| 2505 } | 2491 } |
| 2506 | 2492 |
| 2507 } // namespace blink | 2493 } // namespace blink |
| OLD | NEW |