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 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
112 static bool isInTopLayer(const Element* element, const ComputedStyle& style) | 112 static bool isInTopLayer(const Element* element, const ComputedStyle& style) |
113 { | 113 { |
114 return (element && element->isInTopLayer()) || style.styleType() == PseudoId Backdrop; | 114 return (element && element->isInTopLayer()) || style.styleType() == PseudoId Backdrop; |
115 } | 115 } |
116 | 116 |
117 static bool parentStyleForcesZIndexToCreateStackingContext(const ComputedStyle& parentStyle) | 117 static bool parentStyleForcesZIndexToCreateStackingContext(const ComputedStyle& parentStyle) |
118 { | 118 { |
119 return parentStyle.isDisplayFlexibleOrGridBox(); | 119 return parentStyle.isDisplayFlexibleOrGridBox(); |
120 } | 120 } |
121 | 121 |
122 static bool hasWillChangeThatCreatesStackingContext(const ComputedStyle& style) | |
123 { | |
124 for (size_t i = 0; i < style.willChangeProperties().size(); ++i) { | |
125 switch (style.willChangeProperties()[i]) { | |
126 case CSSPropertyOpacity: | |
127 case CSSPropertyTransform: | |
128 case CSSPropertyAliasWebkitTransform: | |
129 case CSSPropertyTransformStyle: | |
130 case CSSPropertyAliasWebkitTransformStyle: | |
131 case CSSPropertyPerspective: | |
132 case CSSPropertyAliasWebkitPerspective: | |
133 case CSSPropertyWebkitMask: | |
134 case CSSPropertyWebkitMaskBoxImage: | |
135 case CSSPropertyWebkitClipPath: | |
136 case CSSPropertyWebkitBoxReflect: | |
137 case CSSPropertyWebkitFilter: | |
138 case CSSPropertyBackdropFilter: | |
139 case CSSPropertyZIndex: | |
140 case CSSPropertyPosition: | |
141 case CSSPropertyMixBlendMode: | |
142 case CSSPropertyIsolation: | |
143 return true; | |
144 default: | |
145 break; | |
146 } | |
147 } | |
148 return false; | |
149 } | |
150 | |
151 void StyleAdjuster::adjustComputedStyle(ComputedStyle& style, const ComputedStyl e& parentStyle, Element* element) | 122 void StyleAdjuster::adjustComputedStyle(ComputedStyle& style, const ComputedStyl e& parentStyle, Element* element) |
152 { | 123 { |
153 if (style.display() != NONE) { | 124 if (style.display() != NONE) { |
154 if (element && element->isHTMLElement()) | 125 if (element && element->isHTMLElement()) |
155 adjustStyleForHTMLElement(style, parentStyle, toHTMLElement(*element )); | 126 adjustStyleForHTMLElement(style, parentStyle, toHTMLElement(*element )); |
156 | 127 |
157 // Per the spec, position 'static' and 'relative' in the top layer compu te to 'absolute'. | 128 // Per the spec, position 'static' and 'relative' in the top layer compu te to 'absolute'. |
158 if (isInTopLayer(element, style) && (style.position() == StaticPosition || style.position() == RelativePosition)) | 129 if (isInTopLayer(element, style) && (style.position() == StaticPosition || style.position() == RelativePosition)) |
159 style.setPosition(AbsolutePosition); | 130 style.setPosition(AbsolutePosition); |
160 | 131 |
(...skipping 13 matching lines...) Expand all Loading... | |
174 style.setDisplay(BLOCK); | 145 style.setDisplay(BLOCK); |
175 } else { | 146 } else { |
176 adjustStyleForFirstLetter(style); | 147 adjustStyleForFirstLetter(style); |
177 } | 148 } |
178 | 149 |
179 if (element && element->hasCompositorProxy()) | 150 if (element && element->hasCompositorProxy()) |
180 style.setHasCompositorProxy(true); | 151 style.setHasCompositorProxy(true); |
181 | 152 |
182 // Make sure our z-index value is only applied if the object is positioned. | 153 // Make sure our z-index value is only applied if the object is positioned. |
183 if (style.position() == StaticPosition && !parentStyleForcesZIndexToCreateSt ackingContext(parentStyle)) | 154 if (style.position() == StaticPosition && !parentStyleForcesZIndexToCreateSt ackingContext(parentStyle)) |
184 style.setHasAutoZIndex(); | 155 style.setHasAutoZIndex(); |
rune
2016/06/09 09:13:43
This also incorrectly affects computed style.
alancutter (OOO until 2018)
2016/06/10 05:36:47
Thanks for the catch. Updated test and added setIs
alancutter (OOO until 2018)
2016/06/10 08:26:00
I spoke too soon, looks like layering depends on t
| |
185 | 156 |
186 // Auto z-index becomes 0 for the root element and transparent objects. This prevents | |
187 // cases where objects that should be blended as a single unit end up with a non-transparent | |
188 // object wedged in between them. Auto z-index also becomes 0 for objects th at specify transforms/masks/reflections. | |
189 if (style.hasAutoZIndex() && ((element && element->document().documentElemen t() == element) | |
190 || style.hasOpacity() | |
191 || style.hasTransformRelatedProperty() | |
192 || style.hasMask() | |
193 || style.clipPath() | |
194 || style.boxReflect() | |
195 || style.hasFilterInducingProperty() | |
196 || style.hasBlendMode() | |
197 || style.hasIsolation() | |
198 || style.hasViewportConstrainedPosition() | |
199 || isInTopLayer(element, style) | |
200 || hasWillChangeThatCreatesStackingContext(style) | |
201 || style.containsPaint())) | |
202 style.setZIndex(0); | |
203 | |
204 if (doesNotInheritTextDecoration(style, element)) | 157 if (doesNotInheritTextDecoration(style, element)) |
205 style.clearAppliedTextDecorations(); | 158 style.clearAppliedTextDecorations(); |
206 | 159 |
207 style.applyTextDecorations(); | 160 style.applyTextDecorations(); |
208 | 161 |
209 if (style.overflowX() != OverflowVisible || style.overflowY() != OverflowVis ible) | 162 if (style.overflowX() != OverflowVisible || style.overflowY() != OverflowVis ible) |
210 adjustOverflow(style); | 163 adjustOverflow(style); |
211 | 164 |
212 // Cull out any useless layers and also repeat patterns into additional laye rs. | 165 // Cull out any useless layers and also repeat patterns into additional laye rs. |
213 style.adjustBackgroundLayers(); | 166 style.adjustBackgroundLayers(); |
(...skipping 243 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
457 // We want to count vertical percentage paddings/margins on flex items b ecause our current | 410 // We want to count vertical percentage paddings/margins on flex items b ecause our current |
458 // behavior is different from the spec and we want to gather compatibili ty data. | 411 // behavior is different from the spec and we want to gather compatibili ty data. |
459 if (style.paddingBefore().hasPercent() || style.paddingAfter().hasPercen t()) | 412 if (style.paddingBefore().hasPercent() || style.paddingAfter().hasPercen t()) |
460 UseCounter::count(document, UseCounter::FlexboxPercentagePaddingVert ical); | 413 UseCounter::count(document, UseCounter::FlexboxPercentagePaddingVert ical); |
461 if (style.marginBefore().hasPercent() || style.marginAfter().hasPercent( )) | 414 if (style.marginBefore().hasPercent() || style.marginAfter().hasPercent( )) |
462 UseCounter::count(document, UseCounter::FlexboxPercentageMarginVerti cal); | 415 UseCounter::count(document, UseCounter::FlexboxPercentageMarginVerti cal); |
463 } | 416 } |
464 } | 417 } |
465 | 418 |
466 } // namespace blink | 419 } // namespace blink |
OLD | NEW |