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

Side by Side Diff: third_party/WebKit/Source/core/css/CSSToLengthConversionData.cpp

Issue 2793193004: Remove mutable from ComputedStyle by const_cast. (Closed)
Patch Set: Created 3 years, 8 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 | « no previous file | third_party/WebKit/Source/core/style/ComputedStyle.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 * Copyright (C) 2013 Google Inc. All rights reserved. 2 * Copyright (C) 2013 Google Inc. All rights reserved.
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 are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
91 const ComputedStyle* style, 91 const ComputedStyle* style,
92 const ComputedStyle* rootStyle, 92 const ComputedStyle* rootStyle,
93 const LayoutViewItem& layoutViewItem, 93 const LayoutViewItem& layoutViewItem,
94 float zoom) 94 float zoom)
95 : CSSToLengthConversionData(style, 95 : CSSToLengthConversionData(style,
96 FontSizes(style, rootStyle), 96 FontSizes(style, rootStyle),
97 ViewportSize(layoutViewItem), 97 ViewportSize(layoutViewItem),
98 zoom) {} 98 zoom) {}
99 99
100 double CSSToLengthConversionData::viewportWidthPercent() const { 100 double CSSToLengthConversionData::viewportWidthPercent() const {
101 m_style->setHasViewportUnits(); 101 const_cast<ComputedStyle*>(m_style)->setHasViewportUnits();
alancutter (OOO until 2018) 2017/04/05 05:22:23 Let's add a TODO to plumb these bits through as ou
shend 2017/04/05 06:19:11 Done.
102 return m_viewportSize.width() / 100; 102 return m_viewportSize.width() / 100;
103 } 103 }
104 double CSSToLengthConversionData::viewportHeightPercent() const { 104 double CSSToLengthConversionData::viewportHeightPercent() const {
105 m_style->setHasViewportUnits(); 105 const_cast<ComputedStyle*>(m_style)->setHasViewportUnits();
106 return m_viewportSize.height() / 100; 106 return m_viewportSize.height() / 100;
107 } 107 }
108 double CSSToLengthConversionData::viewportMinPercent() const { 108 double CSSToLengthConversionData::viewportMinPercent() const {
109 m_style->setHasViewportUnits(); 109 const_cast<ComputedStyle*>(m_style)->setHasViewportUnits();
110 return std::min(m_viewportSize.width(), m_viewportSize.height()) / 100; 110 return std::min(m_viewportSize.width(), m_viewportSize.height()) / 100;
111 } 111 }
112 double CSSToLengthConversionData::viewportMaxPercent() const { 112 double CSSToLengthConversionData::viewportMaxPercent() const {
113 m_style->setHasViewportUnits(); 113 const_cast<ComputedStyle*>(m_style)->setHasViewportUnits();
114 return std::max(m_viewportSize.width(), m_viewportSize.height()) / 100; 114 return std::max(m_viewportSize.width(), m_viewportSize.height()) / 100;
115 } 115 }
116 116
117 float CSSToLengthConversionData::remFontSize() const { 117 float CSSToLengthConversionData::remFontSize() const {
118 m_style->setHasRemUnits(); 118 const_cast<ComputedStyle*>(m_style)->setHasRemUnits();
119 return m_fontSizes.rem(); 119 return m_fontSizes.rem();
120 } 120 }
121 121
122 double CSSToLengthConversionData::zoomedComputedPixels( 122 double CSSToLengthConversionData::zoomedComputedPixels(
123 double value, 123 double value,
124 CSSPrimitiveValue::UnitType type) const { 124 CSSPrimitiveValue::UnitType type) const {
125 // The logic in this function is duplicated in MediaValues::computeLength() 125 // The logic in this function is duplicated in MediaValues::computeLength()
126 // because MediaValues::computeLength() needs nearly identical logic, but we 126 // because MediaValues::computeLength() needs nearly identical logic, but we
127 // haven't found a way to make zoomedComputedPixels() more generic (to solve 127 // haven't found a way to make zoomedComputedPixels() more generic (to solve
128 // both cases) without hurting performance. 128 // both cases) without hurting performance.
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
175 case CSSPrimitiveValue::UnitType::Chs: 175 case CSSPrimitiveValue::UnitType::Chs:
176 return value * chFontSize(); 176 return value * chFontSize();
177 177
178 default: 178 default:
179 ASSERT_NOT_REACHED(); 179 ASSERT_NOT_REACHED();
180 return 0; 180 return 0;
181 } 181 }
182 } 182 }
183 183
184 } // namespace blink 184 } // namespace blink
OLDNEW
« no previous file with comments | « no previous file | third_party/WebKit/Source/core/style/ComputedStyle.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698