| 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 244 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 255 | 255 |
| 256 // Force inline display (except for floating first-letters). | 256 // Force inline display (except for floating first-letters). |
| 257 style.setDisplay(style.isFloating() ? BLOCK : INLINE); | 257 style.setDisplay(style.isFloating() ? BLOCK : INLINE); |
| 258 | 258 |
| 259 // CSS2 says first-letter can't be positioned. | 259 // CSS2 says first-letter can't be positioned. |
| 260 style.setPosition(StaticPosition); | 260 style.setPosition(StaticPosition); |
| 261 } | 261 } |
| 262 | 262 |
| 263 void StyleAdjuster::adjustStyleForAlignment(ComputedStyle& style, const Computed
Style& parentStyle) | 263 void StyleAdjuster::adjustStyleForAlignment(ComputedStyle& style, const Computed
Style& parentStyle) |
| 264 { | 264 { |
| 265 bool isFlexOrGrid = style.isDisplayFlexibleOrGridBox(); | 265 // If the inherited value of justify-items includes the 'legacy' keyword, 'a
uto' |
| 266 bool absolutePositioned = style.position() == AbsolutePosition; | |
| 267 | |
| 268 // If the inherited value of justify-items includes the legacy keyword, 'aut
o' | |
| 269 // computes to the the inherited value. | 266 // computes to the the inherited value. |
| 270 // Otherwise, auto computes to: | 267 // Otherwise, 'auto' computes to 'normal'. |
| 271 // - 'stretch' for flex containers and grid containers. | |
| 272 // - 'start' for everything else. | |
| 273 if (style.justifyItemsPosition() == ItemPositionAuto) { | 268 if (style.justifyItemsPosition() == ItemPositionAuto) { |
| 274 if (parentStyle.justifyItemsPositionType() == LegacyPosition) | 269 if (parentStyle.justifyItemsPositionType() == LegacyPosition) |
| 275 style.setJustifyItems(parentStyle.justifyItems()); | 270 style.setJustifyItems(parentStyle.justifyItems()); |
| 276 else if (isFlexOrGrid) | 271 else |
| 277 style.setJustifyItemsPosition(ItemPositionStretch); | 272 style.setJustifyItemsPosition(ItemPositionNormal); |
| 278 } | 273 } |
| 279 | 274 |
| 280 // The 'auto' keyword computes to 'stretch' on absolutely-positioned element
s, | 275 // The 'auto' keyword computes the computed value of justify-items on the pa
rent (minus |
| 281 // and to the computed value of justify-items on the parent (minus | 276 // any legacy keywords), or 'normal' if the box has no parent. |
| 282 // any legacy keywords) on all other boxes. | 277 if (style.justifySelfPosition() == ItemPositionAuto) |
| 283 if (style.justifySelfPosition() == ItemPositionAuto) { | 278 style.setJustifySelf(parentStyle.justifyItems()); |
| 284 if (absolutePositioned) | |
| 285 style.setJustifySelfPosition(ItemPositionStretch); | |
| 286 else | |
| 287 style.setJustifySelf(parentStyle.justifyItems()); | |
| 288 } | |
| 289 | |
| 290 // The 'auto' keyword computes to: | |
| 291 // - 'stretch' for flex containers and grid containers, | |
| 292 // - 'start' for everything else. | |
| 293 if (style.alignItemsPosition() == ItemPositionAuto) { | |
| 294 if (isFlexOrGrid) | |
| 295 style.setAlignItemsPosition(ItemPositionStretch); | |
| 296 } | |
| 297 } | 279 } |
| 298 | 280 |
| 299 void StyleAdjuster::adjustStyleForHTMLElement(ComputedStyle& style, const Comput
edStyle& parentStyle, HTMLElement& element) | 281 void StyleAdjuster::adjustStyleForHTMLElement(ComputedStyle& style, const Comput
edStyle& parentStyle, HTMLElement& element) |
| 300 { | 282 { |
| 301 // <div> and <span> are the most common elements on the web, we skip all the
work for them. | 283 // <div> and <span> are the most common elements on the web, we skip all the
work for them. |
| 302 if (isHTMLDivElement(element) || isHTMLSpanElement(element)) | 284 if (isHTMLDivElement(element) || isHTMLSpanElement(element)) |
| 303 return; | 285 return; |
| 304 | 286 |
| 305 if (isHTMLTableCellElement(element)) { | 287 if (isHTMLTableCellElement(element)) { |
| 306 // FIXME: We shouldn't be overriding start/-webkit-auto like this. Do it
in html.css instead. | 288 // FIXME: We shouldn't be overriding start/-webkit-auto like this. Do it
in html.css instead. |
| (...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 436 // We want to count vertical percentage paddings/margins on flex items b
ecause our current | 418 // We want to count vertical percentage paddings/margins on flex items b
ecause our current |
| 437 // behavior is different from the spec and we want to gather compatibili
ty data. | 419 // behavior is different from the spec and we want to gather compatibili
ty data. |
| 438 if (style.paddingBefore().hasPercent() || style.paddingAfter().hasPercen
t()) | 420 if (style.paddingBefore().hasPercent() || style.paddingAfter().hasPercen
t()) |
| 439 UseCounter::count(document, UseCounter::FlexboxPercentagePaddingVert
ical); | 421 UseCounter::count(document, UseCounter::FlexboxPercentagePaddingVert
ical); |
| 440 if (style.marginBefore().hasPercent() || style.marginAfter().hasPercent(
)) | 422 if (style.marginBefore().hasPercent() || style.marginAfter().hasPercent(
)) |
| 441 UseCounter::count(document, UseCounter::FlexboxPercentageMarginVerti
cal); | 423 UseCounter::count(document, UseCounter::FlexboxPercentageMarginVerti
cal); |
| 442 } | 424 } |
| 443 } | 425 } |
| 444 | 426 |
| 445 } // namespace blink | 427 } // namespace blink |
| OLD | NEW |