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

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

Issue 2793193004: Remove mutable from ComputedStyle by const_cast. (Closed)
Patch Set: Address comments 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 // FIXME: Remove m_style from this class. Plumb viewport and rem unit
102 // information through as output parameters on functions involved in length
103 // resolution.
104 const_cast<ComputedStyle*>(m_style)->setHasViewportUnits();
102 return m_viewportSize.width() / 100; 105 return m_viewportSize.width() / 100;
103 } 106 }
104 double CSSToLengthConversionData::viewportHeightPercent() const { 107 double CSSToLengthConversionData::viewportHeightPercent() const {
105 m_style->setHasViewportUnits(); 108 const_cast<ComputedStyle*>(m_style)->setHasViewportUnits();
106 return m_viewportSize.height() / 100; 109 return m_viewportSize.height() / 100;
107 } 110 }
108 double CSSToLengthConversionData::viewportMinPercent() const { 111 double CSSToLengthConversionData::viewportMinPercent() const {
109 m_style->setHasViewportUnits(); 112 const_cast<ComputedStyle*>(m_style)->setHasViewportUnits();
110 return std::min(m_viewportSize.width(), m_viewportSize.height()) / 100; 113 return std::min(m_viewportSize.width(), m_viewportSize.height()) / 100;
111 } 114 }
112 double CSSToLengthConversionData::viewportMaxPercent() const { 115 double CSSToLengthConversionData::viewportMaxPercent() const {
113 m_style->setHasViewportUnits(); 116 const_cast<ComputedStyle*>(m_style)->setHasViewportUnits();
114 return std::max(m_viewportSize.width(), m_viewportSize.height()) / 100; 117 return std::max(m_viewportSize.width(), m_viewportSize.height()) / 100;
115 } 118 }
116 119
117 float CSSToLengthConversionData::remFontSize() const { 120 float CSSToLengthConversionData::remFontSize() const {
118 m_style->setHasRemUnits(); 121 const_cast<ComputedStyle*>(m_style)->setHasRemUnits();
119 return m_fontSizes.rem(); 122 return m_fontSizes.rem();
120 } 123 }
121 124
122 double CSSToLengthConversionData::zoomedComputedPixels( 125 double CSSToLengthConversionData::zoomedComputedPixels(
123 double value, 126 double value,
124 CSSPrimitiveValue::UnitType type) const { 127 CSSPrimitiveValue::UnitType type) const {
125 // The logic in this function is duplicated in MediaValues::computeLength() 128 // The logic in this function is duplicated in MediaValues::computeLength()
126 // because MediaValues::computeLength() needs nearly identical logic, but we 129 // because MediaValues::computeLength() needs nearly identical logic, but we
127 // haven't found a way to make zoomedComputedPixels() more generic (to solve 130 // haven't found a way to make zoomedComputedPixels() more generic (to solve
128 // both cases) without hurting performance. 131 // both cases) without hurting performance.
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
175 case CSSPrimitiveValue::UnitType::Chs: 178 case CSSPrimitiveValue::UnitType::Chs:
176 return value * chFontSize(); 179 return value * chFontSize();
177 180
178 default: 181 default:
179 NOTREACHED(); 182 NOTREACHED();
180 return 0; 183 return 0;
181 } 184 }
182 } 185 }
183 186
184 } // namespace blink 187 } // 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