| 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 15 matching lines...) Expand all Loading... |
| 26 * Boston, MA 02110-1301, USA. | 26 * Boston, MA 02110-1301, USA. |
| 27 */ | 27 */ |
| 28 | 28 |
| 29 #include "config.h" | 29 #include "config.h" |
| 30 #include "core/css/resolver/StyleAdjuster.h" | 30 #include "core/css/resolver/StyleAdjuster.h" |
| 31 | 31 |
| 32 #include "core/dom/ContainerNode.h" | 32 #include "core/dom/ContainerNode.h" |
| 33 #include "core/dom/Document.h" | 33 #include "core/dom/Document.h" |
| 34 #include "core/dom/Element.h" | 34 #include "core/dom/Element.h" |
| 35 #include "core/dom/NodeRenderStyle.h" | 35 #include "core/dom/NodeRenderStyle.h" |
| 36 #include "core/rendering/style/GridPosition.h" | |
| 37 #include "core/rendering/style/RenderStyle.h" | 36 #include "core/rendering/style/RenderStyle.h" |
| 38 #include "core/rendering/style/RenderStyleConstants.h" | 37 #include "core/rendering/style/RenderStyleConstants.h" |
| 39 #include "platform/Length.h" | 38 #include "platform/Length.h" |
| 40 #include "platform/transforms/TransformOperations.h" | 39 #include "platform/transforms/TransformOperations.h" |
| 41 #include "wtf/Assertions.h" | 40 #include "wtf/Assertions.h" |
| 42 | 41 |
| 43 namespace blink { | 42 namespace blink { |
| 44 | 43 |
| 45 static EDisplay equivalentBlockDisplay(EDisplay display) | 44 static EDisplay equivalentBlockDisplay(EDisplay display) |
| 46 { | 45 { |
| 47 switch (display) { | 46 switch (display) { |
| 48 case BLOCK: | 47 case BLOCK: |
| 49 case FLEX: | 48 case FLEX: |
| 50 case GRID: | |
| 51 return display; | 49 return display; |
| 52 case INLINE_FLEX: | 50 case INLINE_FLEX: |
| 53 return FLEX; | 51 return FLEX; |
| 54 case INLINE_GRID: | |
| 55 return GRID; | |
| 56 | 52 |
| 57 case INLINE: | 53 case INLINE: |
| 58 case INLINE_BLOCK: | 54 case INLINE_BLOCK: |
| 59 return BLOCK; | 55 return BLOCK; |
| 60 case NONE: | 56 case NONE: |
| 61 ASSERT_NOT_REACHED(); | 57 ASSERT_NOT_REACHED(); |
| 62 return NONE; | 58 return NONE; |
| 63 } | 59 } |
| 64 ASSERT_NOT_REACHED(); | 60 ASSERT_NOT_REACHED(); |
| 65 return BLOCK; | 61 return BLOCK; |
| 66 } | 62 } |
| 67 | 63 |
| 68 // CSS requires text-decoration to be reset at each DOM element for tables, | 64 // CSS requires text-decoration to be reset at each DOM element for tables, |
| 69 // inline blocks, inline tables, shadow DOM crossings, floating elements, | 65 // inline blocks, inline tables, shadow DOM crossings, floating elements, |
| 70 // and absolute or relatively positioned elements. | 66 // and absolute or relatively positioned elements. |
| 71 static bool doesNotInheritTextDecoration(const RenderStyle* style, const Element
& e) | 67 static bool doesNotInheritTextDecoration(const RenderStyle* style, const Element
& e) |
| 72 { | 68 { |
| 73 return style->display() == INLINE_BLOCK || isAtShadowBoundary(&e) || style->
hasOutOfFlowPosition(); | 69 return style->display() == INLINE_BLOCK || isAtShadowBoundary(&e) || style->
hasOutOfFlowPosition(); |
| 74 } | 70 } |
| 75 | 71 |
| 76 static bool parentStyleForcesZIndexToCreateStackingContext(const RenderStyle* pa
rentStyle) | 72 static bool parentStyleForcesZIndexToCreateStackingContext(const RenderStyle* pa
rentStyle) |
| 77 { | 73 { |
| 78 return parentStyle->isDisplayFlexibleOrGridBox(); | 74 return parentStyle->isDisplayFlexibleBox(); |
| 79 } | 75 } |
| 80 | 76 |
| 81 static bool hasWillChangeThatCreatesStackingContext(const RenderStyle* style) | 77 static bool hasWillChangeThatCreatesStackingContext(const RenderStyle* style) |
| 82 { | 78 { |
| 83 for (size_t i = 0; i < style->willChangeProperties().size(); ++i) { | 79 for (size_t i = 0; i < style->willChangeProperties().size(); ++i) { |
| 84 switch (style->willChangeProperties()[i]) { | 80 switch (style->willChangeProperties()[i]) { |
| 85 case CSSPropertyOpacity: | 81 case CSSPropertyOpacity: |
| 86 case CSSPropertyTransform: | 82 case CSSPropertyTransform: |
| 87 case CSSPropertyWebkitTransform: | 83 case CSSPropertyWebkitTransform: |
| 88 case CSSPropertyTransformStyle: | 84 case CSSPropertyTransformStyle: |
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 168 if (style->preserves3D() && (style->overflowX() != OVISIBLE | 164 if (style->preserves3D() && (style->overflowX() != OVISIBLE |
| 169 || style->overflowY() != OVISIBLE | 165 || style->overflowY() != OVISIBLE |
| 170 || style->hasFilter())) | 166 || style->hasFilter())) |
| 171 style->setTransformStyle3D(TransformStyle3DFlat); | 167 style->setTransformStyle3D(TransformStyle3DFlat); |
| 172 | 168 |
| 173 adjustStyleForAlignment(*style, *parentStyle); | 169 adjustStyleForAlignment(*style, *parentStyle); |
| 174 } | 170 } |
| 175 | 171 |
| 176 void StyleAdjuster::adjustStyleForAlignment(RenderStyle& style, const RenderStyl
e& parentStyle) | 172 void StyleAdjuster::adjustStyleForAlignment(RenderStyle& style, const RenderStyl
e& parentStyle) |
| 177 { | 173 { |
| 178 bool isFlexOrGrid = style.isDisplayFlexibleOrGridBox(); | 174 bool isFlex = style.isDisplayFlexibleBox(); |
| 179 bool absolutePositioned = style.position() == AbsolutePosition; | 175 bool absolutePositioned = style.position() == AbsolutePosition; |
| 180 | 176 |
| 181 // If the inherited value of justify-items includes the legacy keyword, 'aut
o' | 177 // If the inherited value of justify-items includes the legacy keyword, 'aut
o' |
| 182 // computes to the the inherited value. | 178 // computes to the the inherited value. |
| 183 // Otherwise, auto computes to: | 179 // Otherwise, auto computes to: |
| 184 // - 'stretch' for flex containers and grid containers. | 180 // - 'stretch' for flex containers. |
| 185 // - 'start' for everything else. | 181 // - 'start' for everything else. |
| 186 if (style.justifyItems() == ItemPositionAuto) { | 182 if (style.justifyItems() == ItemPositionAuto) { |
| 187 if (parentStyle.justifyItemsPositionType() == LegacyPosition) { | 183 if (parentStyle.justifyItemsPositionType() == LegacyPosition) { |
| 188 style.setJustifyItems(parentStyle.justifyItems()); | 184 style.setJustifyItems(parentStyle.justifyItems()); |
| 189 style.setJustifyItemsPositionType(parentStyle.justifyItemsPositionTy
pe()); | 185 style.setJustifyItemsPositionType(parentStyle.justifyItemsPositionTy
pe()); |
| 190 } else if (isFlexOrGrid) { | 186 } else if (isFlex) { |
| 191 style.setJustifyItems(ItemPositionStretch); | 187 style.setJustifyItems(ItemPositionStretch); |
| 192 } | 188 } |
| 193 } | 189 } |
| 194 | 190 |
| 195 // The 'auto' keyword computes to 'stretch' on absolutely-positioned element
s, | 191 // The 'auto' keyword computes to 'stretch' on absolutely-positioned element
s, |
| 196 // and to the computed value of justify-items on the parent (minus | 192 // and to the computed value of justify-items on the parent (minus |
| 197 // any legacy keywords) on all other boxes. | 193 // any legacy keywords) on all other boxes. |
| 198 if (style.justifySelf() == ItemPositionAuto) { | 194 if (style.justifySelf() == ItemPositionAuto) { |
| 199 if (absolutePositioned) { | 195 if (absolutePositioned) { |
| 200 style.setJustifySelf(ItemPositionStretch); | 196 style.setJustifySelf(ItemPositionStretch); |
| 201 } else { | 197 } else { |
| 202 style.setJustifySelf(parentStyle.justifyItems()); | 198 style.setJustifySelf(parentStyle.justifyItems()); |
| 203 style.setJustifySelfOverflowAlignment(parentStyle.justifyItemsOverfl
owAlignment()); | 199 style.setJustifySelfOverflowAlignment(parentStyle.justifyItemsOverfl
owAlignment()); |
| 204 } | 200 } |
| 205 } | 201 } |
| 206 | 202 |
| 207 // The 'auto' keyword computes to: | 203 // The 'auto' keyword computes to: |
| 208 // - 'stretch' for flex containers and grid containers, | 204 // - 'stretch' for flex containers, |
| 209 // - 'start' for everything else. | 205 // - 'start' for everything else. |
| 210 if (style.alignItems() == ItemPositionAuto) { | 206 if (style.alignItems() == ItemPositionAuto) { |
| 211 if (isFlexOrGrid) | 207 if (isFlex) |
| 212 style.setAlignItems(ItemPositionStretch); | 208 style.setAlignItems(ItemPositionStretch); |
| 213 } | 209 } |
| 214 | 210 |
| 215 // The 'auto' keyword computes to 'stretch' on absolutely-positioned element
s, | 211 // The 'auto' keyword computes to 'stretch' on absolutely-positioned element
s, |
| 216 // and to the computed value of align-items on the parent (minus | 212 // and to the computed value of align-items on the parent (minus |
| 217 // any 'legacy' keywords) on all other boxes. | 213 // any 'legacy' keywords) on all other boxes. |
| 218 if (style.alignSelf() == ItemPositionAuto) { | 214 if (style.alignSelf() == ItemPositionAuto) { |
| 219 if (absolutePositioned) { | 215 if (absolutePositioned) { |
| 220 style.setAlignSelf(ItemPositionStretch); | 216 style.setAlignSelf(ItemPositionStretch); |
| 221 } else { | 217 } else { |
| (...skipping 13 matching lines...) Expand all Loading... |
| 235 // if overflow-y is set to -webkit-paged-x or -webkit-page-y. For now, w
e'll let it | 231 // if overflow-y is set to -webkit-paged-x or -webkit-page-y. For now, w
e'll let it |
| 236 // default to auto so we can at least scroll through the pages. | 232 // default to auto so we can at least scroll through the pages. |
| 237 style->setOverflowX(OAUTO); | 233 style->setOverflowX(OAUTO); |
| 238 } else if (style->overflowY() == OVISIBLE && style->overflowX() != OVISIBLE)
{ | 234 } else if (style->overflowY() == OVISIBLE && style->overflowX() != OVISIBLE)
{ |
| 239 style->setOverflowY(OAUTO); | 235 style->setOverflowY(OAUTO); |
| 240 } | 236 } |
| 241 } | 237 } |
| 242 | 238 |
| 243 void StyleAdjuster::adjustStyleForDisplay(RenderStyle* style, RenderStyle* paren
tStyle) | 239 void StyleAdjuster::adjustStyleForDisplay(RenderStyle* style, RenderStyle* paren
tStyle) |
| 244 { | 240 { |
| 245 if (style->display() == BLOCK) | 241 if (parentStyle->isDisplayFlexibleBox()) { |
| 246 return; | |
| 247 | |
| 248 if (parentStyle->isDisplayFlexibleOrGridBox()) { | |
| 249 style->setDisplay(equivalentBlockDisplay(style->display())); | 242 style->setDisplay(equivalentBlockDisplay(style->display())); |
| 250 } | 243 } |
| 251 } | 244 } |
| 252 | 245 |
| 253 } | 246 } |
| OLD | NEW |