| 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 23 matching lines...) Expand all Loading... |
| 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/RenderStyle.h" | 36 #include "core/rendering/style/RenderStyle.h" |
| 37 #include "core/rendering/style/RenderStyleConstants.h" | 37 #include "core/rendering/style/RenderStyleConstants.h" |
| 38 #include "platform/Length.h" | 38 #include "platform/Length.h" |
| 39 #include "platform/transforms/TransformOperations.h" | 39 #include "platform/transforms/TransformOperations.h" |
| 40 #include "wtf/Assertions.h" | 40 #include "wtf/Assertions.h" |
| 41 | 41 |
| 42 namespace blink { | 42 namespace blink { |
| 43 | 43 |
| 44 static bool requiresOnlyBlockChildren(RenderStyle* parentStyle) |
| 45 { |
| 46 switch (parentStyle->display()) { |
| 47 case PARAGRAPH: |
| 48 case INLINE: |
| 49 return false; |
| 50 |
| 51 case BLOCK: |
| 52 case FLEX: |
| 53 case INLINE_FLEX: |
| 54 case INLINE_BLOCK: |
| 55 return true; |
| 56 |
| 57 case NONE: |
| 58 ASSERT_NOT_REACHED(); |
| 59 return false; |
| 60 } |
| 61 } |
| 62 |
| 63 static EDisplay equivalentInlineDisplay(EDisplay display) |
| 64 { |
| 65 switch (display) { |
| 66 // TODO(ojan): Do we need an INLINE_PARAGRAPH display? |
| 67 case PARAGRAPH: |
| 68 return INLINE; |
| 69 |
| 70 case BLOCK: |
| 71 return INLINE_BLOCK; |
| 72 |
| 73 case FLEX: |
| 74 return INLINE_FLEX; |
| 75 |
| 76 case INLINE: |
| 77 case INLINE_FLEX: |
| 78 case INLINE_BLOCK: |
| 79 return display; |
| 80 |
| 81 case NONE: |
| 82 ASSERT_NOT_REACHED(); |
| 83 return NONE; |
| 84 } |
| 85 } |
| 86 |
| 44 static EDisplay equivalentBlockDisplay(EDisplay display) | 87 static EDisplay equivalentBlockDisplay(EDisplay display) |
| 45 { | 88 { |
| 46 switch (display) { | 89 switch (display) { |
| 90 case PARAGRAPH: |
| 47 case BLOCK: | 91 case BLOCK: |
| 48 case FLEX: | 92 case FLEX: |
| 49 return display; | 93 return display; |
| 94 |
| 50 case INLINE_FLEX: | 95 case INLINE_FLEX: |
| 51 return FLEX; | 96 return FLEX; |
| 52 | 97 |
| 53 case INLINE: | 98 case INLINE: |
| 54 case INLINE_BLOCK: | 99 case INLINE_BLOCK: |
| 55 return BLOCK; | 100 return BLOCK; |
| 101 |
| 56 case NONE: | 102 case NONE: |
| 57 ASSERT_NOT_REACHED(); | 103 ASSERT_NOT_REACHED(); |
| 58 return NONE; | 104 return NONE; |
| 59 } | 105 } |
| 60 ASSERT_NOT_REACHED(); | |
| 61 return BLOCK; | |
| 62 } | 106 } |
| 63 | 107 |
| 64 // CSS requires text-decoration to be reset at each DOM element for tables, | 108 // CSS requires text-decoration to be reset at each DOM element for tables, |
| 65 // inline blocks, inline tables, shadow DOM crossings, floating elements, | 109 // inline blocks, inline tables, shadow DOM crossings, floating elements, |
| 66 // and absolute or relatively positioned elements. | 110 // and absolute or relatively positioned elements. |
| 67 static bool doesNotInheritTextDecoration(const RenderStyle* style, const Element
& e) | 111 static bool doesNotInheritTextDecoration(const RenderStyle* style, const Element
& e) |
| 68 { | 112 { |
| 69 return style->display() == INLINE_BLOCK || isAtShadowBoundary(&e) || style->
hasOutOfFlowPosition(); | 113 return style->display() == INLINE_BLOCK || isAtShadowBoundary(&e) || style->
hasOutOfFlowPosition(); |
| 70 } | 114 } |
| 71 | 115 |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 106 | 150 |
| 107 void StyleAdjuster::adjustRenderStyle(RenderStyle* style, RenderStyle* parentSty
le, Element& element) | 151 void StyleAdjuster::adjustRenderStyle(RenderStyle* style, RenderStyle* parentSty
le, Element& element) |
| 108 { | 152 { |
| 109 ASSERT(parentStyle); | 153 ASSERT(parentStyle); |
| 110 | 154 |
| 111 if (style->display() != NONE) { | 155 if (style->display() != NONE) { |
| 112 // Absolute/fixed positioned elements, floating elements and the documen
t element need block-like outside display. | 156 // Absolute/fixed positioned elements, floating elements and the documen
t element need block-like outside display. |
| 113 if (style->hasOutOfFlowPosition() || element.document().documentElement(
) == element) | 157 if (style->hasOutOfFlowPosition() || element.document().documentElement(
) == element) |
| 114 style->setDisplay(equivalentBlockDisplay(style->display())); | 158 style->setDisplay(equivalentBlockDisplay(style->display())); |
| 115 | 159 |
| 116 adjustStyleForDisplay(style, parentStyle); | 160 if (requiresOnlyBlockChildren(parentStyle)) |
| 161 style->setDisplay(equivalentBlockDisplay(style->display())); |
| 162 else |
| 163 style->setDisplay(equivalentInlineDisplay(style->display())); |
| 117 } | 164 } |
| 118 | 165 |
| 119 // Make sure our z-index value is only applied if the object is positioned. | 166 // Make sure our z-index value is only applied if the object is positioned. |
| 120 if (style->position() == StaticPosition && !parentStyleForcesZIndexToCreateS
tackingContext(parentStyle)) | 167 if (style->position() == StaticPosition && !parentStyleForcesZIndexToCreateS
tackingContext(parentStyle)) |
| 121 style->setHasAutoZIndex(); | 168 style->setHasAutoZIndex(); |
| 122 | 169 |
| 123 // Auto z-index becomes 0 for the root element and transparent objects. This
prevents | 170 // Auto z-index becomes 0 for the root element and transparent objects. This
prevents |
| 124 // cases where objects that should be blended as a single unit end up with a
non-transparent | 171 // cases where objects that should be blended as a single unit end up with a
non-transparent |
| 125 // object wedged in between them. Auto z-index also becomes 0 for objects th
at specify transforms/masks/reflections. | 172 // object wedged in between them. Auto z-index also becomes 0 for objects th
at specify transforms/masks/reflections. |
| 126 if (style->hasAutoZIndex() && ((element.document().documentElement() == elem
ent) | 173 if (style->hasAutoZIndex() && ((element.document().documentElement() == elem
ent) |
| (...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 226 if (style->overflowX() == OVISIBLE && style->overflowY() != OVISIBLE) { | 273 if (style->overflowX() == OVISIBLE && style->overflowY() != OVISIBLE) { |
| 227 // FIXME: Once we implement pagination controls, overflow-x should defau
lt to hidden | 274 // FIXME: Once we implement pagination controls, overflow-x should defau
lt to hidden |
| 228 // if overflow-y is set to -webkit-paged-x or -webkit-page-y. For now, w
e'll let it | 275 // if overflow-y is set to -webkit-paged-x or -webkit-page-y. For now, w
e'll let it |
| 229 // default to auto so we can at least scroll through the pages. | 276 // default to auto so we can at least scroll through the pages. |
| 230 style->setOverflowX(OAUTO); | 277 style->setOverflowX(OAUTO); |
| 231 } else if (style->overflowY() == OVISIBLE && style->overflowX() != OVISIBLE)
{ | 278 } else if (style->overflowY() == OVISIBLE && style->overflowX() != OVISIBLE)
{ |
| 232 style->setOverflowY(OAUTO); | 279 style->setOverflowY(OAUTO); |
| 233 } | 280 } |
| 234 } | 281 } |
| 235 | 282 |
| 236 void StyleAdjuster::adjustStyleForDisplay(RenderStyle* style, RenderStyle* paren
tStyle) | |
| 237 { | |
| 238 if (parentStyle->isDisplayFlexibleBox()) { | |
| 239 style->setDisplay(equivalentBlockDisplay(style->display())); | |
| 240 } | |
| 241 } | |
| 242 | |
| 243 } | 283 } |
| OLD | NEW |