Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(269)

Unified Diff: third_party/WebKit/Source/core/css/resolver/StyleAdjuster.cpp

Issue 2047283002: Avoid touching z-index in StyleAdjuster by using an isStackingContext flag instead (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Update comments Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/core/css/resolver/StyleAdjuster.cpp
diff --git a/third_party/WebKit/Source/core/css/resolver/StyleAdjuster.cpp b/third_party/WebKit/Source/core/css/resolver/StyleAdjuster.cpp
index 77241c51c9e5fc232cf10ad24631050f49920c20..90e4221c16c3c86f203ecf958624440bb553e9a0 100644
--- a/third_party/WebKit/Source/core/css/resolver/StyleAdjuster.cpp
+++ b/third_party/WebKit/Source/core/css/resolver/StyleAdjuster.cpp
@@ -119,36 +119,6 @@ static bool parentStyleForcesZIndexToCreateStackingContext(const ComputedStyle&
return parentStyle.isDisplayFlexibleOrGridBox();
}
-static bool hasWillChangeThatCreatesStackingContext(const ComputedStyle& style)
-{
- for (size_t i = 0; i < style.willChangeProperties().size(); ++i) {
- switch (style.willChangeProperties()[i]) {
- case CSSPropertyOpacity:
- case CSSPropertyTransform:
- case CSSPropertyAliasWebkitTransform:
- case CSSPropertyTransformStyle:
- case CSSPropertyAliasWebkitTransformStyle:
- case CSSPropertyPerspective:
- case CSSPropertyAliasWebkitPerspective:
- case CSSPropertyWebkitMask:
- case CSSPropertyWebkitMaskBoxImage:
- case CSSPropertyWebkitClipPath:
- case CSSPropertyWebkitBoxReflect:
- case CSSPropertyFilter:
- case CSSPropertyAliasWebkitFilter:
- case CSSPropertyBackdropFilter:
- case CSSPropertyZIndex:
- case CSSPropertyPosition:
- case CSSPropertyMixBlendMode:
- case CSSPropertyIsolation:
- return true;
- default:
- break;
- }
- }
- return false;
-}
-
void StyleAdjuster::adjustStyleForEditing(ComputedStyle& style)
{
if (style.userModify() != READ_WRITE_PLAINTEXT_ONLY)
@@ -398,30 +368,18 @@ void StyleAdjuster::adjustComputedStyle(ComputedStyle& style, const ComputedStyl
style.setHasCompositorProxy(true);
// Make sure our z-index value is only applied if the object is positioned.
- if (style.position() == StaticPosition && !parentStyleForcesZIndexToCreateStackingContext(parentStyle))
- style.setHasAutoZIndex();
+ if (style.position() == StaticPosition && !parentStyleForcesZIndexToCreateStackingContext(parentStyle)) {
+ style.setIsStackingContext(false);
+ // TODO(alancutter): Avoid altering z-index here.
+ if (!style.hasAutoZIndex())
+ style.setZIndex(0);
+ } else if (!style.hasAutoZIndex()) {
+ style.setIsStackingContext(true);
+ }
if (style.overflowX() != OverflowVisible || style.overflowY() != OverflowVisible)
adjustOverflow(style);
- // Auto z-index becomes 0 for the root element and transparent objects. This prevents
- // cases where objects that should be blended as a single unit end up with a non-transparent
- // object wedged in between them. Auto z-index also becomes 0 for objects that specify transforms/masks/reflections.
- if (style.hasAutoZIndex() && ((element && element->document().documentElement() == element)
- || style.hasOpacity()
- || style.hasTransformRelatedProperty()
- || style.hasMask()
- || style.clipPath()
- || style.boxReflect()
- || style.hasFilterInducingProperty()
- || style.hasBlendMode()
- || style.hasIsolation()
- || style.hasViewportConstrainedPosition()
- || isInTopLayer(element, style)
- || hasWillChangeThatCreatesStackingContext(style)
- || style.containsPaint()))
- style.setZIndex(0);
-
if (doesNotInheritTextDecoration(style, element))
style.clearAppliedTextDecorations();

Powered by Google App Engine
This is Rietveld 408576698