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 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 12 matching lines...) Expand all Loading... | |
| 173 if (style.containsPaint() && style.display() == INLINE) | 144 if (style.containsPaint() && style.display() == INLINE) |
| 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.setIsStackingContext(false); |
| 185 | 156 // TODO(alancutter): Avoid altering z-index here. |
|
rune
2016/06/10 12:25:52
Could you add the crbug issue here as well? I've a
| |
| 186 // Auto z-index becomes 0 for the root element and transparent objects. This prevents | 157 if (!style.hasAutoZIndex()) |
| 187 // cases where objects that should be blended as a single unit end up with a non-transparent | 158 style.setZIndex(0); |
| 188 // object wedged in between them. Auto z-index also becomes 0 for objects th at specify transforms/masks/reflections. | 159 } else if (!style.hasAutoZIndex()) { |
| 189 if (style.hasAutoZIndex() && ((element && element->document().documentElemen t() == element) | 160 style.setIsStackingContext(true); |
| 190 || style.hasOpacity() | 161 } |
| 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 | 162 |
| 204 if (doesNotInheritTextDecoration(style, element)) | 163 if (doesNotInheritTextDecoration(style, element)) |
| 205 style.clearAppliedTextDecorations(); | 164 style.clearAppliedTextDecorations(); |
| 206 | 165 |
| 207 style.applyTextDecorations(); | 166 style.applyTextDecorations(); |
| 208 | 167 |
| 209 if (style.overflowX() != OverflowVisible || style.overflowY() != OverflowVis ible) | 168 if (style.overflowX() != OverflowVisible || style.overflowY() != OverflowVis ible) |
| 210 adjustOverflow(style); | 169 adjustOverflow(style); |
| 211 | 170 |
| 212 // Cull out any useless layers and also repeat patterns into additional laye rs. | 171 // Cull out any useless layers and also repeat patterns into additional laye rs. |
| (...skipping 244 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 | 416 // 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. | 417 // behavior is different from the spec and we want to gather compatibili ty data. |
| 459 if (style.paddingBefore().hasPercent() || style.paddingAfter().hasPercen t()) | 418 if (style.paddingBefore().hasPercent() || style.paddingAfter().hasPercen t()) |
| 460 UseCounter::count(document, UseCounter::FlexboxPercentagePaddingVert ical); | 419 UseCounter::count(document, UseCounter::FlexboxPercentagePaddingVert ical); |
| 461 if (style.marginBefore().hasPercent() || style.marginAfter().hasPercent( )) | 420 if (style.marginBefore().hasPercent() || style.marginAfter().hasPercent( )) |
| 462 UseCounter::count(document, UseCounter::FlexboxPercentageMarginVerti cal); | 421 UseCounter::count(document, UseCounter::FlexboxPercentageMarginVerti cal); |
| 463 } | 422 } |
| 464 } | 423 } |
| 465 | 424 |
| 466 } // namespace blink | 425 } // namespace blink |
| OLD | NEW |