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

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

Issue 2455093002: [css-align] Don't resolve 'auto' values for computed style. (Closed)
Patch Set: 'auto' is not valid for justify-items. Created 3 years, 7 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
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 183 matching lines...) Expand 10 before | Expand all | Expand 10 after
194 bool independent_equal = old_style->IndependentInheritedEqual(*new_style); 194 bool independent_equal = old_style->IndependentInheritedEqual(*new_style);
195 bool non_independent_equal = 195 bool non_independent_equal =
196 old_style->NonIndependentInheritedEqual(*new_style); 196 old_style->NonIndependentInheritedEqual(*new_style);
197 if (!independent_equal || !non_independent_equal) { 197 if (!independent_equal || !non_independent_equal) {
198 if (non_independent_equal && !old_style->HasExplicitlyInheritedProperties()) 198 if (non_independent_equal && !old_style->HasExplicitlyInheritedProperties())
199 return kIndependentInherit; 199 return kIndependentInherit;
200 return kInherit; 200 return kInherit;
201 } 201 }
202 202
203 if (!old_style->LoadingCustomFontsEqual(*new_style) || 203 if (!old_style->LoadingCustomFontsEqual(*new_style) ||
204 old_style->AlignItems() != new_style->AlignItems() ||
205 old_style->JustifyItems() != new_style->JustifyItems()) 204 old_style->JustifyItems() != new_style->JustifyItems())
206 return kInherit; 205 return kInherit;
207 206
208 if (*old_style == *new_style) 207 if (*old_style == *new_style)
209 return DiffPseudoStyles(*old_style, *new_style); 208 return DiffPseudoStyles(*old_style, *new_style);
210 209
211 if (old_style->HasExplicitlyInheritedProperties()) 210 if (old_style->HasExplicitlyInheritedProperties())
212 return kInherit; 211 return kInherit;
213 212
214 return kNoInherit; 213 return kNoInherit;
215 } 214 }
216 215
217 void ComputedStyle::PropagateIndependentInheritedProperties( 216 void ComputedStyle::PropagateIndependentInheritedProperties(
218 const ComputedStyle& parent_style) { 217 const ComputedStyle& parent_style) {
219 ComputedStyleBase::PropagateIndependentInheritedProperties(parent_style); 218 ComputedStyleBase::PropagateIndependentInheritedProperties(parent_style);
220 } 219 }
221 220
222 StyleSelfAlignmentData ResolvedSelfAlignment( 221 StyleSelfAlignmentData ResolvedSelfAlignment(
223 const StyleSelfAlignmentData& value, 222 const StyleSelfAlignmentData& value,
224 ItemPosition normal_value_behavior) { 223 ItemPosition normal_value_behavior) {
225 // To avoid needing to copy the RareNonInheritedData, we repurpose the 'auto'
226 // flag to not just mean 'auto' prior to running the StyleAdjuster but also
227 // mean 'normal' after running it.
228 if (value.GetPosition() == kItemPositionNormal || 224 if (value.GetPosition() == kItemPositionNormal ||
229 value.GetPosition() == kItemPositionAuto) 225 value.GetPosition() == kItemPositionAuto)
230 return {normal_value_behavior, kOverflowAlignmentDefault}; 226 return {normal_value_behavior, kOverflowAlignmentDefault};
231 return value; 227 return value;
232 } 228 }
233 229
234 StyleSelfAlignmentData ComputedStyle::ResolvedAlignItems( 230 StyleSelfAlignmentData ComputedStyle::ResolvedAlignItems(
235 ItemPosition normal_value_behaviour) const { 231 ItemPosition normal_value_behaviour) const {
236 // We will return the behaviour of 'normal' value if needed, which is specific 232 // We will return the behaviour of 'normal' value if needed, which is specific
237 // of each layout model. 233 // of each layout model.
238 return ResolvedSelfAlignment(AlignItems(), normal_value_behaviour); 234 return ResolvedSelfAlignment(AlignItems(), normal_value_behaviour);
239 } 235 }
240 236
241 StyleSelfAlignmentData ComputedStyle::ResolvedAlignSelf( 237 StyleSelfAlignmentData ComputedStyle::ResolvedAlignSelf(
242 ItemPosition normal_value_behaviour, 238 ItemPosition normal_value_behaviour,
243 const ComputedStyle* parent_style) const { 239 const ComputedStyle* parent_style) const {
244 // We will return the behaviour of 'normal' value if needed, which is specific 240 // We will return the behaviour of 'normal' value if needed, which is specific
245 // of each layout model. 241 // of each layout model.
246 if (!parent_style || AlignSelfPosition() != kItemPositionAuto) 242 if (!parent_style || AlignSelfPosition() != kItemPositionAuto)
247 return ResolvedSelfAlignment(AlignSelf(), normal_value_behaviour); 243 return ResolvedSelfAlignment(AlignSelf(), normal_value_behaviour);
248 244
249 // We shouldn't need to resolve any 'auto' value in post-adjusment
250 // ComputedStyle, but some layout models can generate anonymous boxes that may
251 // need 'auto' value resolution during layout.
252 // The 'auto' keyword computes to the parent's align-items computed value. 245 // The 'auto' keyword computes to the parent's align-items computed value.
253 return parent_style->ResolvedAlignItems(normal_value_behaviour); 246 return parent_style->ResolvedAlignItems(normal_value_behaviour);
254 } 247 }
255 248
256 StyleSelfAlignmentData ComputedStyle::ResolvedJustifyItems( 249 StyleSelfAlignmentData ComputedStyle::ResolvedJustifyItems(
257 ItemPosition normal_value_behaviour) const { 250 ItemPosition normal_value_behaviour) const {
258 // We will return the behaviour of 'normal' value if needed, which is specific 251 // We will return the behaviour of 'normal' value if needed, which is specific
259 // of each layout model. 252 // of each layout model.
260 return ResolvedSelfAlignment(JustifyItems(), normal_value_behaviour); 253 return ResolvedSelfAlignment(JustifyItems(), normal_value_behaviour);
261 } 254 }
262 255
263 StyleSelfAlignmentData ComputedStyle::ResolvedJustifySelf( 256 StyleSelfAlignmentData ComputedStyle::ResolvedJustifySelf(
264 ItemPosition normal_value_behaviour, 257 ItemPosition normal_value_behaviour,
265 const ComputedStyle* parent_style) const { 258 const ComputedStyle* parent_style) const {
266 // We will return the behaviour of 'normal' value if needed, which is specific 259 // We will return the behaviour of 'normal' value if needed, which is specific
267 // of each layout model. 260 // of each layout model.
268 if (!parent_style || JustifySelfPosition() != kItemPositionAuto) 261 if (!parent_style || JustifySelfPosition() != kItemPositionAuto)
269 return ResolvedSelfAlignment(JustifySelf(), normal_value_behaviour); 262 return ResolvedSelfAlignment(JustifySelf(), normal_value_behaviour);
270 263
271 // We shouldn't need to resolve any 'auto' value in post-adjusment
272 // ComputedStyle, but some layout models can generate anonymous boxes that may
273 // need 'auto' value resolution during layout.
274 // The auto keyword computes to the parent's justify-items computed value. 264 // The auto keyword computes to the parent's justify-items computed value.
275 return parent_style->ResolvedJustifyItems(normal_value_behaviour); 265 return parent_style->ResolvedJustifyItems(normal_value_behaviour);
276 } 266 }
277 267
278 static inline ContentPosition ResolvedContentAlignmentPosition( 268 static inline ContentPosition ResolvedContentAlignmentPosition(
279 const StyleContentAlignmentData& value, 269 const StyleContentAlignmentData& value,
280 const StyleContentAlignmentData& normal_value_behavior) { 270 const StyleContentAlignmentData& normal_value_behavior) {
281 return (value.GetPosition() == kContentPositionNormal && 271 return (value.GetPosition() == kContentPositionNormal &&
282 value.Distribution() == kContentDistributionDefault) 272 value.Distribution() == kContentDistributionDefault)
283 ? normal_value_behavior.GetPosition() 273 ? normal_value_behavior.GetPosition()
(...skipping 2196 matching lines...) Expand 10 before | Expand all | Expand 10 after
2480 if (value < 0) 2470 if (value < 0)
2481 fvalue -= 0.5f; 2471 fvalue -= 0.5f;
2482 else 2472 else
2483 fvalue += 0.5f; 2473 fvalue += 0.5f;
2484 } 2474 }
2485 2475
2486 return RoundForImpreciseConversion<int>(fvalue / zoom_factor); 2476 return RoundForImpreciseConversion<int>(fvalue / zoom_factor);
2487 } 2477 }
2488 2478
2489 } // namespace blink 2479 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698