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

Side by Side 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: Always create a stacking context for will-change:position 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 26 matching lines...) Expand all
37 #include "core/html/HTMLIFrameElement.h" 37 #include "core/html/HTMLIFrameElement.h"
38 #include "core/html/HTMLInputElement.h" 38 #include "core/html/HTMLInputElement.h"
39 #include "core/html/HTMLTextAreaElement.h" 39 #include "core/html/HTMLTextAreaElement.h"
40 #include "core/frame/FrameView.h" 40 #include "core/frame/FrameView.h"
41 #include "core/frame/Settings.h" 41 #include "core/frame/Settings.h"
42 #include "core/rendering/RenderTheme.h" 42 #include "core/rendering/RenderTheme.h"
43 #include "core/rendering/style/GridPosition.h" 43 #include "core/rendering/style/GridPosition.h"
44 #include "core/rendering/style/RenderStyle.h" 44 #include "core/rendering/style/RenderStyle.h"
45 #include "core/rendering/style/RenderStyleConstants.h" 45 #include "core/rendering/style/RenderStyleConstants.h"
46 #include "platform/Length.h" 46 #include "platform/Length.h"
47 #include "platform/transforms/TransformOperations.h"
47 #include "wtf/Assertions.h" 48 #include "wtf/Assertions.h"
48 49
49 namespace WebCore { 50 namespace WebCore {
50 51
51 using namespace HTMLNames; 52 using namespace HTMLNames;
52 53
53 // FIXME: This is duplicated with StyleResolver.cpp 54 // FIXME: This is duplicated with StyleResolver.cpp
54 // Perhaps this should move onto ElementResolveContext or even Element? 55 // Perhaps this should move onto ElementResolveContext or even Element?
55 static inline bool isAtShadowBoundary(const Element* element) 56 static inline bool isAtShadowBoundary(const Element* element)
56 { 57 {
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
151 static bool isDisplayGridBox(EDisplay display) 152 static bool isDisplayGridBox(EDisplay display)
152 { 153 {
153 return display == GRID || display == INLINE_GRID; 154 return display == GRID || display == INLINE_GRID;
154 } 155 }
155 156
156 static bool parentStyleForcesZIndexToCreateStackingContext(const RenderStyle* pa rentStyle) 157 static bool parentStyleForcesZIndexToCreateStackingContext(const RenderStyle* pa rentStyle)
157 { 158 {
158 return isDisplayFlexibleBox(parentStyle->display()) || isDisplayGridBox(pare ntStyle->display()); 159 return isDisplayFlexibleBox(parentStyle->display()) || isDisplayGridBox(pare ntStyle->display());
159 } 160 }
160 161
162 static bool hasWillChangeThatCreatesStackingContext(const RenderStyle* style, El ement* e)
163 {
164 for (size_t i = 0; i < style->willChangeProperties().size(); ++i) {
165 switch (style->willChangeProperties()[i]) {
166 case CSSPropertyOpacity:
167 case CSSPropertyWebkitTransform:
168 case CSSPropertyWebkitTransformStyle:
169 case CSSPropertyWebkitPerspective:
170 case CSSPropertyWebkitMask:
171 case CSSPropertyWebkitMaskBoxImage:
172 case CSSPropertyWebkitClipPath:
173 case CSSPropertyWebkitBoxReflect:
174 case CSSPropertyWebkitFilter:
175 case CSSPropertyZIndex:
176 case CSSPropertyPosition:
jamesr 2014/02/26 23:56:22 this is supposed to be a set of all CSS properties
ajuma 2014/02/27 00:05:47 Yes, this is supposed to be all CSS properties tha
esprehn 2014/02/27 20:58:31 This just begs for a unit test, but I suppose it'l
177 return true;
178 case CSSPropertyMixBlendMode:
179 case CSSPropertyIsolation:
180 if (RuntimeEnabledFeatures::cssCompositingEnabled())
181 return true;
182 break;
183 default:
184 break;
185 }
186 }
187 return false;
188 }
189
161 void StyleAdjuster::adjustRenderStyle(RenderStyle* style, RenderStyle* parentSty le, Element *e) 190 void StyleAdjuster::adjustRenderStyle(RenderStyle* style, RenderStyle* parentSty le, Element *e)
162 { 191 {
163 ASSERT(parentStyle); 192 ASSERT(parentStyle);
164 193
165 // Cache our original display. 194 // Cache our original display.
166 style->setOriginalDisplay(style->display()); 195 style->setOriginalDisplay(style->display());
167 196
168 if (style->display() != NONE) { 197 if (style->display() != NONE) {
169 // If we have a <td> that specifies a float property, in quirks mode we just drop the float 198 // If we have a <td> that specifies a float property, in quirks mode we just drop the float
170 // property. 199 // property.
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
268 || style->hasTransformRelatedProperty() 297 || style->hasTransformRelatedProperty()
269 || style->hasMask() 298 || style->hasMask()
270 || style->clipPath() 299 || style->clipPath()
271 || style->boxReflect() 300 || style->boxReflect()
272 || style->hasFilter() 301 || style->hasFilter()
273 || style->hasBlendMode() 302 || style->hasBlendMode()
274 || style->hasIsolation() 303 || style->hasIsolation()
275 || style->position() == StickyPosition 304 || style->position() == StickyPosition
276 || (style->position() == FixedPosition && e && e->document().settings() && e->document().settings()->fixedPositionCreatesStackingContext()) 305 || (style->position() == FixedPosition && e && e->document().settings() && e->document().settings()->fixedPositionCreatesStackingContext())
277 || isInTopLayer(e, style) 306 || isInTopLayer(e, style)
307 || hasWillChangeThatCreatesStackingContext(style, e)
278 )) 308 ))
279 style->setZIndex(0); 309 style->setZIndex(0);
280 310
311 // will-change:transform should result in the same rendering behavior as hav ing a transform,
312 // including the creation of a containing block for fixed position descendan ts.
esprehn 2014/02/27 22:05:27 This is observable from script. If you do getCompu
313 if (!style->hasTransform() && style->willChangeProperties().contains(CSSProp ertyWebkitTransform)) {
314 bool makeIdentity = true;
315 style->setTransform(TransformOperations(makeIdentity));
316 }
317
281 // Textarea considers overflow visible as auto. 318 // Textarea considers overflow visible as auto.
282 if (e && e->hasTagName(textareaTag)) { 319 if (e && e->hasTagName(textareaTag)) {
283 style->setOverflowX(style->overflowX() == OVISIBLE ? OAUTO : style->over flowX()); 320 style->setOverflowX(style->overflowX() == OVISIBLE ? OAUTO : style->over flowX());
284 style->setOverflowY(style->overflowY() == OVISIBLE ? OAUTO : style->over flowY()); 321 style->setOverflowY(style->overflowY() == OVISIBLE ? OAUTO : style->over flowY());
285 } 322 }
286 323
287 // For now, <marquee> requires an overflow clip to work properly. 324 // For now, <marquee> requires an overflow clip to work properly.
288 if (e && e->hasTagName(marqueeTag)) { 325 if (e && e->hasTagName(marqueeTag)) {
289 style->setOverflowX(OHIDDEN); 326 style->setOverflowX(OHIDDEN);
290 style->setOverflowY(OHIDDEN); 327 style->setOverflowY(OHIDDEN);
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after
402 if (prop.isNamedGridArea() && !map.contains(prop.namedGridLine())) \ 439 if (prop.isNamedGridArea() && !map.contains(prop.namedGridLine())) \
403 style->setGrid##Prop(GridPosition()); 440 style->setGrid##Prop(GridPosition());
404 441
405 CLEAR_UNKNOWN_NAMED_AREA(columnStartPosition, ColumnStart); 442 CLEAR_UNKNOWN_NAMED_AREA(columnStartPosition, ColumnStart);
406 CLEAR_UNKNOWN_NAMED_AREA(columnEndPosition, ColumnEnd); 443 CLEAR_UNKNOWN_NAMED_AREA(columnEndPosition, ColumnEnd);
407 CLEAR_UNKNOWN_NAMED_AREA(rowStartPosition, RowStart); 444 CLEAR_UNKNOWN_NAMED_AREA(rowStartPosition, RowStart);
408 CLEAR_UNKNOWN_NAMED_AREA(rowEndPosition, RowEnd); 445 CLEAR_UNKNOWN_NAMED_AREA(rowEndPosition, RowEnd);
409 } 446 }
410 447
411 } 448 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698