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/frame/LocalFrame.h" | 8 #include "core/frame/LocalFrame.h" |
9 #include "core/frame/Settings.h" | 9 #include "core/frame/Settings.h" |
10 #include "core/layout/LayoutInline.h" | 10 #include "core/layout/LayoutInline.h" |
(...skipping 20 matching lines...) Expand all Loading... | |
31 ClipPaintPropertyNode* rootClipNode() { | 31 ClipPaintPropertyNode* rootClipNode() { |
32 DEFINE_STATIC_REF(ClipPaintPropertyNode, rootClip, | 32 DEFINE_STATIC_REF(ClipPaintPropertyNode, rootClip, |
33 (ClipPaintPropertyNode::create( | 33 (ClipPaintPropertyNode::create( |
34 nullptr, rootTransformNode(), | 34 nullptr, rootTransformNode(), |
35 FloatRoundedRect(LayoutRect::infiniteIntRect())))); | 35 FloatRoundedRect(LayoutRect::infiniteIntRect())))); |
36 return rootClip; | 36 return rootClip; |
37 } | 37 } |
38 | 38 |
39 EffectPaintPropertyNode* rootEffectNode() { | 39 EffectPaintPropertyNode* rootEffectNode() { |
40 DEFINE_STATIC_REF(EffectPaintPropertyNode, rootEffect, | 40 DEFINE_STATIC_REF(EffectPaintPropertyNode, rootEffect, |
41 (EffectPaintPropertyNode::create(nullptr, 1.0))); | 41 (EffectPaintPropertyNode::create(nullptr, rootTransformNode( ), rootClipNode(), 1.0, CompositorFilterOperations()))); |
42 return rootEffect; | 42 return rootEffect; |
43 } | 43 } |
44 | 44 |
45 ScrollPaintPropertyNode* rootScrollNode() { | 45 ScrollPaintPropertyNode* rootScrollNode() { |
46 DEFINE_STATIC_REF( | 46 DEFINE_STATIC_REF( |
47 ScrollPaintPropertyNode, rootScroll, | 47 ScrollPaintPropertyNode, rootScroll, |
48 (ScrollPaintPropertyNode::create(nullptr, rootTransformNode(), IntSize(), | 48 (ScrollPaintPropertyNode::create(nullptr, rootTransformNode(), IntSize(), |
49 IntSize(), false, false))); | 49 IntSize(), false, false))); |
50 return rootScroll; | 50 return rootScroll; |
51 } | 51 } |
(...skipping 288 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
340 } | 340 } |
341 | 341 |
342 if (ObjectPaintProperties* properties = | 342 if (ObjectPaintProperties* properties = |
343 object.getMutableForPainting().objectPaintProperties()) | 343 object.getMutableForPainting().objectPaintProperties()) |
344 properties->clearTransform(); | 344 properties->clearTransform(); |
345 } | 345 } |
346 | 346 |
347 void PaintPropertyTreeBuilder::updateEffect( | 347 void PaintPropertyTreeBuilder::updateEffect( |
348 const LayoutObject& object, | 348 const LayoutObject& object, |
349 PaintPropertyTreeBuilderContext& context) { | 349 PaintPropertyTreeBuilderContext& context) { |
350 if (!object.styleRef().hasOpacity()) { | 350 const ComputedStyle& style = object.styleRef(); |
351 | |
352 if (!style.isStackingContext()) { | |
351 if (ObjectPaintProperties* properties = | 353 if (ObjectPaintProperties* properties = |
352 object.getMutableForPainting().objectPaintProperties()) | 354 object.getMutableForPainting().objectPaintProperties()) |
353 properties->clearEffect(); | 355 properties->clearEffect(); |
356 return; | |
357 } | |
358 | |
359 // TODO(trchen): Can't omit effect node if we have 3D children. | |
360 // TODO(trchen): Can't omit effect node if we have blending children. | |
361 bool effectNodeNeeded = false; | |
362 | |
363 float opacity = style.opacity(); | |
364 if (opacity != 1.0f) | |
365 effectNodeNeeded = true; | |
366 | |
367 // TODO(trchen): Eliminate PaintLayer dependency. | |
368 PaintLayer* layer = toLayoutBoxModelObject(object).layer(); | |
369 DCHECK(layer); | |
370 CompositorFilterOperations filter = layer->createCompositorFilterOperationsFor Filter(style); | |
371 if (!filter.isEmpty()) | |
372 effectNodeNeeded = true; | |
373 | |
374 const ClipPaintPropertyNode* outputClip = rootClipNode(); | |
375 // The CSS filter spec didn't specify how filters interact with overflow | |
376 // clips. The implementation here mimics the old Blink/WebKit behavior for | |
377 // backward compatibility. | |
378 // Basically the output of the filter will be affected by clips that applies | |
379 // to the current element. The descendants that paints into the input of the | |
380 // filter ignores any clips collected so far. For example: | |
381 // <div style="overflow:scroll"> | |
382 // <div style="filter:blur(1px);"> | |
383 // <div>A</div> | |
384 // <div style="position:absolute;">B</div> | |
385 // </div> | |
386 // </div> | |
387 // In this example "A" should be clipped if the filter did not present. | |
pdr.
2016/10/19 17:44:43
Nit: did not -> is not
trchen
2016/10/21 23:26:39
Done.
| |
388 // With the filter, "A" will be rastered without clipping, but instead | |
389 // the blurred result will be clipped. | |
390 // On the other hand, "B" should not be clipped because the overflow clip is | |
391 // not in its containing block chain, but as the filter output will be | |
392 // clipped, so a blurred "B" may still be invisible. | |
pdr.
2016/10/19 17:44:43
This description is good and helped me understand
| |
393 if (!filter.isEmpty()) { | |
394 outputClip = context.current.clip; | |
395 context.current.clip = context.absolutePosition.clip = | |
396 context.fixedPosition.clip = rootClipNode(); | |
397 } | |
398 | |
399 if (!effectNodeNeeded) { | |
400 if (ObjectPaintProperties* properties = | |
401 object.getMutableForPainting().objectPaintProperties()) | |
402 properties->clearEffect(); | |
354 return; | 403 return; |
355 } | 404 } |
356 | 405 |
357 context.currentEffect = | 406 context.currentEffect = |
358 object.getMutableForPainting() | 407 object.getMutableForPainting() |
359 .ensureObjectPaintProperties() | 408 .ensureObjectPaintProperties() |
360 .createOrUpdateEffect(context.currentEffect, | 409 .createOrUpdateEffect(context.currentEffect, |
361 object.styleRef().opacity()); | 410 context.current.transform, |
411 outputClip, | |
412 object.styleRef().opacity(), | |
413 std::move(filter)); | |
362 } | 414 } |
363 | 415 |
364 void PaintPropertyTreeBuilder::updateCssClip( | 416 void PaintPropertyTreeBuilder::updateCssClip( |
365 const LayoutObject& object, | 417 const LayoutObject& object, |
366 PaintPropertyTreeBuilderContext& context) { | 418 PaintPropertyTreeBuilderContext& context) { |
367 if (object.hasClip()) { | 419 if (object.hasClip()) { |
368 // Create clip node for descendants that are not fixed position. | 420 // Create clip node for descendants that are not fixed position. |
369 // We don't have to setup context.absolutePosition.clip here because this | 421 // We don't have to setup context.absolutePosition.clip here because this |
370 // object must be a container for absolute position descendants, and will | 422 // object must be a container for absolute position descendants, and will |
371 // copy from in-flow context later at updateOutOfFlowContext() step. | 423 // copy from in-flow context later at updateOutOfFlowContext() step. |
(...skipping 440 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
812 return; | 864 return; |
813 | 865 |
814 updateOverflowClip(object, context); | 866 updateOverflowClip(object, context); |
815 updatePerspective(object, context); | 867 updatePerspective(object, context); |
816 updateSvgLocalToBorderBoxTransform(object, context); | 868 updateSvgLocalToBorderBoxTransform(object, context); |
817 updateScrollAndScrollTranslation(object, context); | 869 updateScrollAndScrollTranslation(object, context); |
818 updateOutOfFlowContext(object, context); | 870 updateOutOfFlowContext(object, context); |
819 } | 871 } |
820 | 872 |
821 } // namespace blink | 873 } // namespace blink |
OLD | NEW |