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 29 matching lines...) Expand all Loading... |
101 | 145 |
102 void StyleAdjuster::adjustRenderStyle(RenderStyle* style, RenderStyle* parentSty
le, Element& element) | 146 void StyleAdjuster::adjustRenderStyle(RenderStyle* style, RenderStyle* parentSty
le, Element& element) |
103 { | 147 { |
104 ASSERT(parentStyle); | 148 ASSERT(parentStyle); |
105 | 149 |
106 if (style->display() != NONE) { | 150 if (style->display() != NONE) { |
107 // Absolute/fixed positioned elements, floating elements and the documen
t element need block-like outside display. | 151 // Absolute/fixed positioned elements, floating elements and the documen
t element need block-like outside display. |
108 if (style->hasOutOfFlowPosition() || element.document().documentElement(
) == element) | 152 if (style->hasOutOfFlowPosition() || element.document().documentElement(
) == element) |
109 style->setDisplay(equivalentBlockDisplay(style->display())); | 153 style->setDisplay(equivalentBlockDisplay(style->display())); |
110 | 154 |
111 adjustStyleForDisplay(style, parentStyle); | 155 if (requiresOnlyBlockChildren(parentStyle)) |
| 156 style->setDisplay(equivalentBlockDisplay(style->display())); |
| 157 else |
| 158 style->setDisplay(equivalentInlineDisplay(style->display())); |
112 } | 159 } |
113 | 160 |
114 // Make sure our z-index value is only applied if the object is positioned. | 161 // Make sure our z-index value is only applied if the object is positioned. |
115 if (style->position() == StaticPosition && !parentStyleForcesZIndexToCreateS
tackingContext(parentStyle)) | 162 if (style->position() == StaticPosition && !parentStyleForcesZIndexToCreateS
tackingContext(parentStyle)) |
116 style->setHasAutoZIndex(); | 163 style->setHasAutoZIndex(); |
117 | 164 |
118 // Auto z-index becomes 0 for the root element and transparent objects. This
prevents | 165 // Auto z-index becomes 0 for the root element and transparent objects. This
prevents |
119 // cases where objects that should be blended as a single unit end up with a
non-transparent | 166 // cases where objects that should be blended as a single unit end up with a
non-transparent |
120 // object wedged in between them. Auto z-index also becomes 0 for objects th
at specify transforms/masks/reflections. | 167 // object wedged in between them. Auto z-index also becomes 0 for objects th
at specify transforms/masks/reflections. |
121 if (style->hasAutoZIndex() && ((element.document().documentElement() == elem
ent) | 168 if (style->hasAutoZIndex() && ((element.document().documentElement() == elem
ent) |
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
219 if (style->overflowX() == OVISIBLE && style->overflowY() != OVISIBLE) { | 266 if (style->overflowX() == OVISIBLE && style->overflowY() != OVISIBLE) { |
220 // FIXME: Once we implement pagination controls, overflow-x should defau
lt to hidden | 267 // FIXME: Once we implement pagination controls, overflow-x should defau
lt to hidden |
221 // if overflow-y is set to -webkit-paged-x or -webkit-page-y. For now, w
e'll let it | 268 // if overflow-y is set to -webkit-paged-x or -webkit-page-y. For now, w
e'll let it |
222 // default to auto so we can at least scroll through the pages. | 269 // default to auto so we can at least scroll through the pages. |
223 style->setOverflowX(OAUTO); | 270 style->setOverflowX(OAUTO); |
224 } else if (style->overflowY() == OVISIBLE && style->overflowX() != OVISIBLE)
{ | 271 } else if (style->overflowY() == OVISIBLE && style->overflowX() != OVISIBLE)
{ |
225 style->setOverflowY(OAUTO); | 272 style->setOverflowY(OAUTO); |
226 } | 273 } |
227 } | 274 } |
228 | 275 |
229 void StyleAdjuster::adjustStyleForDisplay(RenderStyle* style, RenderStyle* paren
tStyle) | |
230 { | |
231 if (parentStyle->isDisplayFlexibleBox()) { | |
232 style->setDisplay(equivalentBlockDisplay(style->display())); | |
233 } | |
234 } | |
235 | |
236 } | 276 } |
OLD | NEW |