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

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

Issue 175263002: Implement will-change-based creation of layers, stacking contexts, and containing blocks (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 10 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: Source/core/css/resolver/StyleAdjuster.cpp
diff --git a/Source/core/css/resolver/StyleAdjuster.cpp b/Source/core/css/resolver/StyleAdjuster.cpp
index 7e8b3ee4309acba66f1e09e6ec046b116d58e71b..e36ddb44a284537bb00f255ff2d83997dd6af387 100644
--- a/Source/core/css/resolver/StyleAdjuster.cpp
+++ b/Source/core/css/resolver/StyleAdjuster.cpp
@@ -44,6 +44,7 @@
#include "core/rendering/style/RenderStyle.h"
#include "core/rendering/style/RenderStyleConstants.h"
#include "platform/Length.h"
+#include "platform/transforms/TransformOperations.h"
#include "wtf/Assertions.h"
namespace WebCore {
@@ -158,6 +159,38 @@ static bool parentStyleForcesZIndexToCreateStackingContext(const RenderStyle* pa
return isDisplayFlexibleBox(parentStyle->display()) || isDisplayGridBox(parentStyle->display());
}
+static bool hasWillChangeThatCreatesStackingContext(const RenderStyle* style, Element* e)
+{
+ for (size_t i = 0; i < style->willChangeProperties().size(); ++i) {
+ switch (style->willChangeProperties()[i]) {
+ case CSSPropertyOpacity:
+ case CSSPropertyWebkitTransform:
+ case CSSPropertyWebkitTransformStyle:
+ case CSSPropertyWebkitPerspective:
+ case CSSPropertyWebkitMask:
+ case CSSPropertyWebkitMaskBoxImage:
+ case CSSPropertyWebkitClipPath:
+ case CSSPropertyWebkitBoxReflect:
+ case CSSPropertyWebkitFilter:
+ case CSSPropertyZIndex:
Ian Vollick 2014/02/26 16:21:12 z-index only creates a sc if the element is also p
ajuma 2014/02/26 17:00:30 I took a look at what Mozilla's implementation doe
+ return true;
+ case CSSPropertyMixBlendMode:
+ case CSSPropertyIsolation:
+ if (RuntimeEnabledFeatures::cssCompositingEnabled())
+ return true;
+ break;
+ case CSSPropertyPosition:
+ if (RuntimeEnabledFeatures::cssStickyPositionEnabled()
+ || (e && e->document().settings() && e->document().settings()->fixedPositionCreatesStackingContext()))
+ return true;
+ break;
+ default:
+ break;
+ }
+ }
+ return false;
+}
+
void StyleAdjuster::adjustRenderStyle(RenderStyle* style, RenderStyle* parentStyle, Element *e)
{
ASSERT(parentStyle);
@@ -275,9 +308,15 @@ void StyleAdjuster::adjustRenderStyle(RenderStyle* style, RenderStyle* parentSty
|| style->position() == StickyPosition
|| (style->position() == FixedPosition && e && e->document().settings() && e->document().settings()->fixedPositionCreatesStackingContext())
|| isInTopLayer(e, style)
+ || hasWillChangeThatCreatesStackingContext(style, e)
))
style->setZIndex(0);
+ // will-change:transform should result in the same rendering behavior as having a transform,
+ // including the creation of a containing block for fixed position descendants.
+ if (!style->hasTransform() && style->willChangeProperties().contains(CSSPropertyWebkitTransform))
+ style->setTransform(TransformOperations(true));
+
// Textarea considers overflow visible as auto.
if (e && e->hasTagName(textareaTag)) {
style->setOverflowX(style->overflowX() == OVISIBLE ? OAUTO : style->overflowX());
« no previous file with comments | « LayoutTests/compositing/will-change/stacking-context-creation-expected.html ('k') | Source/core/rendering/RenderBox.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698