Chromium Code Reviews| 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 166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 177 if (style->preserves3D() && (style->overflowX() != OVISIBLE | 177 if (style->preserves3D() && (style->overflowX() != OVISIBLE |
| 178 || style->overflowY() != OVISIBLE | 178 || style->overflowY() != OVISIBLE |
| 179 || style->hasFilter())) | 179 || style->hasFilter())) |
| 180 style->setTransformStyle3D(TransformStyle3DFlat); | 180 style->setTransformStyle3D(TransformStyle3DFlat); |
| 181 | 181 |
| 182 adjustStyleForAlignment(*style, *parentStyle); | 182 adjustStyleForAlignment(*style, *parentStyle); |
| 183 } | 183 } |
| 184 | 184 |
| 185 void StyleAdjuster::adjustStyleForAlignment(RenderStyle& style, const RenderStyl e& parentStyle) | 185 void StyleAdjuster::adjustStyleForAlignment(RenderStyle& style, const RenderStyl e& parentStyle) |
| 186 { | 186 { |
| 187 bool isFlex = style.isDisplayFlexibleBox(); | |
| 188 bool absolutePositioned = style.position() == AbsolutePosition; | |
| 189 | |
| 190 // If the inherited value of justify-items includes the legacy keyword, 'aut o' | |
| 191 // computes to the the inherited value. | |
| 192 // Otherwise, auto computes to: | |
| 193 // - 'stretch' for flex containers. | |
| 194 // - 'start' for everything else. | |
| 195 if (style.justifyItems() == ItemPositionAuto) { | 187 if (style.justifyItems() == ItemPositionAuto) { |
| 196 if (parentStyle.justifyItemsPositionType() == LegacyPosition) { | 188 style.setJustifyItems(parentStyle.justifyItems()); |
| 197 style.setJustifyItems(parentStyle.justifyItems()); | 189 style.setJustifyItemsPositionType(parentStyle.justifyItemsPositionType() ); |
| 198 style.setJustifyItemsPositionType(parentStyle.justifyItemsPositionTy pe()); | |
| 199 } else if (isFlex) { | |
| 200 style.setJustifyItems(ItemPositionStretch); | |
| 201 } | |
| 202 } | 190 } |
| 203 | 191 |
| 204 // The 'auto' keyword computes to 'stretch' on absolutely-positioned element s, | |
| 205 // and to the computed value of justify-items on the parent (minus | |
| 206 // any legacy keywords) on all other boxes. | |
| 207 if (style.justifySelf() == ItemPositionAuto) { | 192 if (style.justifySelf() == ItemPositionAuto) { |
| 208 if (absolutePositioned) { | 193 style.setJustifySelf(parentStyle.justifyItems()); |
|
eseidel
2015/04/06 23:29:19
Should this be squashed into a single if now? Thes
ojan
2015/04/06 23:41:49
They're reading/writing different values. justifyI
| |
| 209 style.setJustifySelf(ItemPositionStretch); | 194 style.setJustifySelfOverflowAlignment(parentStyle.justifyItemsOverflowAl ignment()); |
| 210 } else { | |
| 211 style.setJustifySelf(parentStyle.justifyItems()); | |
| 212 style.setJustifySelfOverflowAlignment(parentStyle.justifyItemsOverfl owAlignment()); | |
| 213 } | |
| 214 } | 195 } |
| 215 | 196 |
| 216 // The 'auto' keyword computes to: | |
| 217 // - 'stretch' for flex containers, | |
| 218 // - 'start' for everything else. | |
| 219 if (style.alignItems() == ItemPositionAuto) { | |
| 220 if (isFlex) | |
| 221 style.setAlignItems(ItemPositionStretch); | |
| 222 } | |
| 223 | |
| 224 // The 'auto' keyword computes to 'stretch' on absolutely-positioned element s, | |
| 225 // and to the computed value of align-items on the parent (minus | |
| 226 // any 'legacy' keywords) on all other boxes. | |
| 227 if (style.alignSelf() == ItemPositionAuto) { | 197 if (style.alignSelf() == ItemPositionAuto) { |
| 228 if (absolutePositioned) { | 198 style.setAlignSelf(parentStyle.alignItems()); |
| 229 style.setAlignSelf(ItemPositionStretch); | 199 style.setAlignSelfOverflowAlignment(parentStyle.alignItemsOverflowAlignm ent()); |
|
eseidel
2015/04/06 23:29:19
This one too? are these ifs even needed?
| |
| 230 } else { | |
| 231 style.setAlignSelf(parentStyle.alignItems()); | |
| 232 style.setAlignSelfOverflowAlignment(parentStyle.alignItemsOverflowAl ignment()); | |
| 233 } | |
| 234 } | 200 } |
| 235 } | 201 } |
| 236 | 202 |
| 237 void StyleAdjuster::adjustOverflow(RenderStyle* style) | 203 void StyleAdjuster::adjustOverflow(RenderStyle* style) |
| 238 { | 204 { |
| 239 ASSERT(style->overflowX() != OVISIBLE || style->overflowY() != OVISIBLE); | 205 ASSERT(style->overflowX() != OVISIBLE || style->overflowY() != OVISIBLE); |
| 240 | 206 |
| 241 // If either overflow value is not visible, change to auto. | 207 // If either overflow value is not visible, change to auto. |
| 242 if (style->overflowX() == OVISIBLE && style->overflowY() != OVISIBLE) { | 208 if (style->overflowX() == OVISIBLE && style->overflowY() != OVISIBLE) { |
| 243 // FIXME: Once we implement pagination controls, overflow-x should defau lt to hidden | 209 // FIXME: Once we implement pagination controls, overflow-x should defau lt to hidden |
| 244 // if overflow-y is set to -webkit-paged-x or -webkit-page-y. For now, w e'll let it | 210 // if overflow-y is set to -webkit-paged-x or -webkit-page-y. For now, w e'll let it |
| 245 // default to auto so we can at least scroll through the pages. | 211 // default to auto so we can at least scroll through the pages. |
| 246 style->setOverflowX(OAUTO); | 212 style->setOverflowX(OAUTO); |
| 247 } else if (style->overflowY() == OVISIBLE && style->overflowX() != OVISIBLE) { | 213 } else if (style->overflowY() == OVISIBLE && style->overflowX() != OVISIBLE) { |
| 248 style->setOverflowY(OAUTO); | 214 style->setOverflowY(OAUTO); |
| 249 } | 215 } |
| 250 } | 216 } |
| 251 | 217 |
| 252 } | 218 } |
| OLD | NEW |