OLD | NEW |
---|---|
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "core/paint/PaintPropertyTreeBuilder.h" | 5 #include "core/paint/PaintPropertyTreeBuilder.h" |
6 | 6 |
7 #include "core/frame/FrameView.h" | 7 #include "core/frame/FrameView.h" |
8 #include "core/layout/LayoutPart.h" | 8 #include "core/layout/LayoutPart.h" |
9 #include "core/layout/LayoutView.h" | 9 #include "core/layout/LayoutView.h" |
10 #include "core/paint/ObjectPaintProperties.h" | 10 #include "core/paint/ObjectPaintProperties.h" |
(...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
207 static PassRefPtr<EffectPaintPropertyNode> createEffectIfNeeded(const LayoutObje ct& object, PaintPropertyTreeBuilderContext& context) | 207 static PassRefPtr<EffectPaintPropertyNode> createEffectIfNeeded(const LayoutObje ct& object, PaintPropertyTreeBuilderContext& context) |
208 { | 208 { |
209 const ComputedStyle& style = object.styleRef(); | 209 const ComputedStyle& style = object.styleRef(); |
210 if (!style.hasOpacity()) | 210 if (!style.hasOpacity()) |
211 return nullptr; | 211 return nullptr; |
212 RefPtr<EffectPaintPropertyNode> newEffectNode = EffectPaintPropertyNode::cre ate(style.opacity(), context.currentEffect); | 212 RefPtr<EffectPaintPropertyNode> newEffectNode = EffectPaintPropertyNode::cre ate(style.opacity(), context.currentEffect); |
213 context.currentEffect = newEffectNode.get(); | 213 context.currentEffect = newEffectNode.get(); |
214 return newEffectNode.release(); | 214 return newEffectNode.release(); |
215 } | 215 } |
216 | 216 |
217 void createCSSClipIfNeeded(RefPtr<ClipPaintPropertyNode>& newClipNodeForCSSClip, RefPtr<ClipPaintPropertyNode>& newClipNodeForCSSClipFixedPosition, const Layout Object& object, PaintPropertyTreeBuilderContext& context) | |
218 { | |
219 if (!object.hasClip()) | |
220 return; | |
221 ASSERT(object.canContainAbsolutePositionObjects()); | |
222 | |
223 // Create clip node for descendants that are not fixed position. | |
224 // We don't have to setup context.clipForAbsolutePosition here because this object must be | |
225 // a container for absolute position descendants, and will copy from in-flow context later | |
226 // at updateOutOfFlowContext() step. | |
227 LayoutRect clipRect = toLayoutBox(object).clipRect(context.paintOffset); | |
228 newClipNodeForCSSClip = ClipPaintPropertyNode::create( | |
229 context.currentTransform, | |
230 FloatRoundedRect(FloatRect(clipRect)), | |
231 context.currentClip); | |
232 context.currentClip = newClipNodeForCSSClip.get(); | |
233 | |
234 // Again, we don't have to setup context.clipForFixedPosition here if this o bject is | |
235 // a container for fixed position descendants. It will copy from in-flow con text at | |
236 // updateOutOfFlowContext() step later. | |
237 // TODO(pdr): Remove the !object.isLayoutView() condition when removing Fram eView | |
pdr.
2016/03/23 00:53:31
TODO(trchen)! :)
trchen
2016/03/23 01:45:42
It is copied from updateOutOfFlowContext(). The co
| |
238 // paint properties for rootLayerScrolls. | |
239 if (!object.isLayoutView() && object.canContainFixedPositionObjects()) | |
240 return; | |
241 | |
242 // Now, before creating clip node for fixed position, check whether in-flow context and | |
243 // fixed-position context has exactly the same clip. Reuse if possible. | |
244 if (context.currentClip->parent() == context.clipForFixedPosition) { | |
245 context.clipForFixedPosition = context.currentClip; | |
246 return; | |
247 } | |
248 | |
249 newClipNodeForCSSClipFixedPosition = ClipPaintPropertyNode::create( | |
250 context.currentTransform, | |
251 FloatRoundedRect(FloatRect(clipRect)), | |
252 context.clipForFixedPosition); | |
253 context.clipForFixedPosition = newClipNodeForCSSClipFixedPosition.get(); | |
254 } | |
255 | |
217 // TODO(trchen): Remove this once we bake the paint offset into frameRect. | 256 // TODO(trchen): Remove this once we bake the paint offset into frameRect. |
218 static PassRefPtr<TransformPaintPropertyNode> createScrollbarPaintOffsetIfNeeded (const LayoutObject& object, PaintPropertyTreeBuilderContext& context) | 257 static PassRefPtr<TransformPaintPropertyNode> createScrollbarPaintOffsetIfNeeded (const LayoutObject& object, PaintPropertyTreeBuilderContext& context) |
219 { | 258 { |
220 IntPoint roundedPaintOffset = roundedIntPoint(context.paintOffset); | 259 IntPoint roundedPaintOffset = roundedIntPoint(context.paintOffset); |
221 if (roundedPaintOffset == IntPoint()) | 260 if (roundedPaintOffset == IntPoint()) |
222 return nullptr; | 261 return nullptr; |
223 | 262 |
224 if (!object.isBoxModelObject()) | 263 if (!object.isBoxModelObject()) |
225 return nullptr; | 264 return nullptr; |
226 PaintLayerScrollableArea* scrollableArea = toLayoutBoxModelObject(object).ge tScrollableArea(); | 265 PaintLayerScrollableArea* scrollableArea = toLayoutBoxModelObject(object).ge tScrollableArea(); |
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
347 } | 386 } |
348 | 387 |
349 void PaintPropertyTreeBuilder::walk(LayoutObject& object, const PaintPropertyTre eBuilderContext& context) | 388 void PaintPropertyTreeBuilder::walk(LayoutObject& object, const PaintPropertyTre eBuilderContext& context) |
350 { | 389 { |
351 PaintPropertyTreeBuilderContext localContext(context); | 390 PaintPropertyTreeBuilderContext localContext(context); |
352 | 391 |
353 deriveBorderBoxFromContainerContext(object, localContext); | 392 deriveBorderBoxFromContainerContext(object, localContext); |
354 RefPtr<TransformPaintPropertyNode> newTransformNodeForPaintOffsetTranslation = createPaintOffsetTranslationIfNeeded(object, localContext); | 393 RefPtr<TransformPaintPropertyNode> newTransformNodeForPaintOffsetTranslation = createPaintOffsetTranslationIfNeeded(object, localContext); |
355 RefPtr<TransformPaintPropertyNode> newTransformNodeForTransform = createTran sformIfNeeded(object, localContext); | 394 RefPtr<TransformPaintPropertyNode> newTransformNodeForTransform = createTran sformIfNeeded(object, localContext); |
356 RefPtr<EffectPaintPropertyNode> newEffectNode = createEffectIfNeeded(object, localContext); | 395 RefPtr<EffectPaintPropertyNode> newEffectNode = createEffectIfNeeded(object, localContext); |
396 RefPtr<ClipPaintPropertyNode> newClipNodeForCSSClip; | |
397 RefPtr<ClipPaintPropertyNode> newClipNodeForCSSClipFixedPosition; | |
398 createCSSClipIfNeeded(newClipNodeForCSSClip, newClipNodeForCSSClipFixedPosit ion, object, localContext); | |
357 OwnPtr<ObjectPaintProperties::LocalBorderBoxProperties> newRecordedContext = recordTreeContextIfNeeded(object, localContext); | 399 OwnPtr<ObjectPaintProperties::LocalBorderBoxProperties> newRecordedContext = recordTreeContextIfNeeded(object, localContext); |
358 RefPtr<TransformPaintPropertyNode> newTransformNodeForScrollbarPaintOffset = createScrollbarPaintOffsetIfNeeded(object, localContext); | 400 RefPtr<TransformPaintPropertyNode> newTransformNodeForScrollbarPaintOffset = createScrollbarPaintOffsetIfNeeded(object, localContext); |
359 RefPtr<ClipPaintPropertyNode> newClipNodeForOverflowClip = createOverflowCli pIfNeeded(object, localContext); | 401 RefPtr<ClipPaintPropertyNode> newClipNodeForOverflowClip = createOverflowCli pIfNeeded(object, localContext); |
360 // TODO(trchen): Insert flattening transform here, as specified by | 402 // TODO(trchen): Insert flattening transform here, as specified by |
361 // http://www.w3.org/TR/css3-transforms/#transform-style-property | 403 // http://www.w3.org/TR/css3-transforms/#transform-style-property |
362 RefPtr<TransformPaintPropertyNode> newTransformNodeForPerspective = createPe rspectiveIfNeeded(object, localContext); | 404 RefPtr<TransformPaintPropertyNode> newTransformNodeForPerspective = createPe rspectiveIfNeeded(object, localContext); |
363 RefPtr<TransformPaintPropertyNode> newTransformNodeForScrollTranslation = cr eateScrollTranslationIfNeeded(object, localContext); | 405 RefPtr<TransformPaintPropertyNode> newTransformNodeForScrollTranslation = cr eateScrollTranslationIfNeeded(object, localContext); |
364 updateOutOfFlowContext(object, localContext); | 406 updateOutOfFlowContext(object, localContext); |
365 | 407 |
366 if (newTransformNodeForPaintOffsetTranslation || newTransformNodeForTransfor m || newEffectNode || newClipNodeForOverflowClip || newTransformNodeForPerspecti ve || newTransformNodeForScrollTranslation || newTransformNodeForScrollbarPaintO ffset || newRecordedContext) { | 408 if (newTransformNodeForPaintOffsetTranslation || newTransformNodeForTransfor m || newEffectNode || newClipNodeForCSSClip || newClipNodeForCSSClipFixedPositio n || newClipNodeForOverflowClip || newTransformNodeForPerspective || newTransfor mNodeForScrollTranslation || newTransformNodeForScrollbarPaintOffset || newRecor dedContext) { |
367 OwnPtr<ObjectPaintProperties> updatedPaintProperties = ObjectPaintProper ties::create( | 409 OwnPtr<ObjectPaintProperties> updatedPaintProperties = ObjectPaintProper ties::create( |
368 newTransformNodeForPaintOffsetTranslation.release(), | 410 newTransformNodeForPaintOffsetTranslation.release(), |
369 newTransformNodeForTransform.release(), | 411 newTransformNodeForTransform.release(), |
370 newEffectNode.release(), | 412 newEffectNode.release(), |
413 newClipNodeForCSSClip.release(), | |
414 newClipNodeForCSSClipFixedPosition.release(), | |
371 newClipNodeForOverflowClip.release(), | 415 newClipNodeForOverflowClip.release(), |
372 newTransformNodeForPerspective.release(), | 416 newTransformNodeForPerspective.release(), |
373 newTransformNodeForScrollTranslation.release(), | 417 newTransformNodeForScrollTranslation.release(), |
374 newTransformNodeForScrollbarPaintOffset.release(), | 418 newTransformNodeForScrollbarPaintOffset.release(), |
375 newRecordedContext.release()); | 419 newRecordedContext.release()); |
376 object.setObjectPaintProperties(updatedPaintProperties.release()); | 420 object.setObjectPaintProperties(updatedPaintProperties.release()); |
377 } else { | 421 } else { |
378 object.clearObjectPaintProperties(); | 422 object.clearObjectPaintProperties(); |
379 } | 423 } |
380 | 424 |
381 for (LayoutObject* child = object.slowFirstChild(); child; child = child->ne xtSibling()) { | 425 for (LayoutObject* child = object.slowFirstChild(); child; child = child->ne xtSibling()) { |
382 if (child->isBoxModelObject() || child->isSVG()) | 426 if (child->isBoxModelObject() || child->isSVG()) |
383 walk(*child, localContext); | 427 walk(*child, localContext); |
384 } | 428 } |
385 | 429 |
386 if (object.isLayoutPart()) { | 430 if (object.isLayoutPart()) { |
387 Widget* widget = toLayoutPart(object).widget(); | 431 Widget* widget = toLayoutPart(object).widget(); |
388 if (widget && widget->isFrameView()) | 432 if (widget && widget->isFrameView()) |
389 walk(*toFrameView(widget), localContext); | 433 walk(*toFrameView(widget), localContext); |
390 // TODO(pdr): Investigate RemoteFrameView (crbug.com/579281). | 434 // TODO(pdr): Investigate RemoteFrameView (crbug.com/579281). |
391 } | 435 } |
392 } | 436 } |
393 | 437 |
394 } // namespace blink | 438 } // namespace blink |
OLD | NEW |