OLD | NEW |
---|---|
1 /* | 1 /* |
2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) | 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) |
3 * (C) 2004-2005 Allan Sandfeld Jensen (kde@carewolf.com) | 3 * (C) 2004-2005 Allan Sandfeld Jensen (kde@carewolf.com) |
4 * Copyright (C) 2006, 2007 Nicholas Shanks (webkit@nickshanks.com) | 4 * Copyright (C) 2006, 2007 Nicholas Shanks (webkit@nickshanks.com) |
5 * Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013 Apple Inc. All rights reserved. | 5 * Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013 Apple Inc. All rights reserved. |
6 * Copyright (C) 2007 Alexey Proskuryakov <ap@webkit.org> | 6 * Copyright (C) 2007 Alexey Proskuryakov <ap@webkit.org> |
7 * Copyright (C) 2007, 2008 Eric Seidel <eric@webkit.org> | 7 * Copyright (C) 2007, 2008 Eric Seidel <eric@webkit.org> |
8 * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved. (http://www.t orchmobile.com/) | 8 * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved. (http://www.t orchmobile.com/) |
9 * Copyright (c) 2011, Code Aurora Forum. All rights reserved. | 9 * Copyright (c) 2011, Code Aurora Forum. All rights reserved. |
10 * Copyright (C) Research In Motion Limited 2011. All rights reserved. | 10 * Copyright (C) Research In Motion Limited 2011. All rights reserved. |
(...skipping 255 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
266 | 266 |
267 // Force inline display (except for floating first-letters). | 267 // Force inline display (except for floating first-letters). |
268 style.setDisplay(style.isFloating() ? BLOCK : INLINE); | 268 style.setDisplay(style.isFloating() ? BLOCK : INLINE); |
269 | 269 |
270 // CSS2 says first-letter can't be positioned. | 270 // CSS2 says first-letter can't be positioned. |
271 style.setPosition(StaticPosition); | 271 style.setPosition(StaticPosition); |
272 } | 272 } |
273 | 273 |
274 void StyleAdjuster::adjustStyleForAlignment(ComputedStyle& style, const Computed Style& parentStyle) | 274 void StyleAdjuster::adjustStyleForAlignment(ComputedStyle& style, const Computed Style& parentStyle) |
275 { | 275 { |
276 bool isFlexOrGrid = style.isDisplayFlexibleOrGridBox(); | 276 // To avoid needing to copy the RareNonInheritedData, we repurpose the 'auto ' flag |
277 bool absolutePositioned = style.position() == AbsolutePosition; | 277 // to not just mean 'auto' prior to running the StyleAdjuster but also mean 'normal' |
278 // after running it. | |
278 | 279 |
279 // If the inherited value of justify-items includes the legacy keyword, 'aut o' | 280 // If the inherited value of justify-items includes the 'legacy' keyword, 'a uto' |
280 // computes to the the inherited value. | 281 // computes to the the inherited value. |
281 // Otherwise, auto computes to: | 282 // Otherwise, 'auto' computes to 'normal'. |
282 // - 'stretch' for flex containers and grid containers. | |
283 // - 'start' for everything else. | |
284 if (style.justifyItemsPosition() == ItemPositionAuto) { | 283 if (style.justifyItemsPosition() == ItemPositionAuto) { |
285 if (parentStyle.justifyItemsPositionType() == LegacyPosition) | 284 if (parentStyle.justifyItemsPositionType() == LegacyPosition) |
286 style.setJustifyItems(parentStyle.justifyItems()); | 285 style.setJustifyItems(parentStyle.justifyItems()); |
287 else if (isFlexOrGrid) | |
288 style.setJustifyItemsPosition(ItemPositionStretch); | |
289 } | 286 } |
290 | 287 |
291 // The 'auto' keyword computes to 'stretch' on absolutely-positioned element s, | 288 // The 'auto' keyword computes the computed value of justify-items on the pa rent (minus |
292 // and to the computed value of justify-items on the parent (minus | 289 // any legacy keywords), or 'normal' if the box has no parent. |
rune
2016/05/30 07:55:10
I haven't looked at the details here, but I notice
| |
293 // any legacy keywords) on all other boxes. | |
294 if (style.justifySelfPosition() == ItemPositionAuto) { | 290 if (style.justifySelfPosition() == ItemPositionAuto) { |
295 if (absolutePositioned) | 291 if (parentStyle.justifyItemsPositionType() == LegacyPosition) |
296 style.setJustifySelfPosition(ItemPositionStretch); | 292 style.setJustifySelfPosition(parentStyle.justifyItemsPosition()); |
297 else | 293 else if (parentStyle.justifyItemsPosition() != ItemPositionAuto) |
298 style.setJustifySelf(parentStyle.justifyItems()); | 294 style.setJustifySelf(parentStyle.justifyItems()); |
299 } | 295 } |
300 | 296 |
301 // The 'auto' keyword computes to: | 297 // The 'auto' keyword computes the computed value of align-items on the pare nt |
302 // - 'stretch' for flex containers and grid containers, | 298 // or 'normal' if the box has no parent. |
303 // - 'start' for everything else. | 299 if (style.alignSelfPosition() == ItemPositionAuto && parentStyle.alignItemsP osition() != ItemPositionNormal) |
304 if (style.alignItemsPosition() == ItemPositionAuto) { | 300 style.setAlignSelf(parentStyle.alignItems()); |
305 if (isFlexOrGrid) | |
306 style.setAlignItemsPosition(ItemPositionStretch); | |
307 } | |
308 } | 301 } |
309 | 302 |
310 void StyleAdjuster::adjustStyleForHTMLElement(ComputedStyle& style, const Comput edStyle& parentStyle, HTMLElement& element) | 303 void StyleAdjuster::adjustStyleForHTMLElement(ComputedStyle& style, const Comput edStyle& parentStyle, HTMLElement& element) |
311 { | 304 { |
312 // <div> and <span> are the most common elements on the web, we skip all the work for them. | 305 // <div> and <span> are the most common elements on the web, we skip all the work for them. |
313 if (isHTMLDivElement(element) || isHTMLSpanElement(element)) | 306 if (isHTMLDivElement(element) || isHTMLSpanElement(element)) |
314 return; | 307 return; |
315 | 308 |
316 if (isHTMLTableCellElement(element)) { | 309 if (isHTMLTableCellElement(element)) { |
317 if (style.whiteSpace() == KHTML_NOWRAP) { | 310 if (style.whiteSpace() == KHTML_NOWRAP) { |
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
457 // We want to count vertical percentage paddings/margins on flex items b ecause our current | 450 // We want to count vertical percentage paddings/margins on flex items b ecause our current |
458 // behavior is different from the spec and we want to gather compatibili ty data. | 451 // behavior is different from the spec and we want to gather compatibili ty data. |
459 if (style.paddingBefore().hasPercent() || style.paddingAfter().hasPercen t()) | 452 if (style.paddingBefore().hasPercent() || style.paddingAfter().hasPercen t()) |
460 UseCounter::count(document, UseCounter::FlexboxPercentagePaddingVert ical); | 453 UseCounter::count(document, UseCounter::FlexboxPercentagePaddingVert ical); |
461 if (style.marginBefore().hasPercent() || style.marginAfter().hasPercent( )) | 454 if (style.marginBefore().hasPercent() || style.marginAfter().hasPercent( )) |
462 UseCounter::count(document, UseCounter::FlexboxPercentageMarginVerti cal); | 455 UseCounter::count(document, UseCounter::FlexboxPercentageMarginVerti cal); |
463 } | 456 } |
464 } | 457 } |
465 | 458 |
466 } // namespace blink | 459 } // namespace blink |
OLD | NEW |