Chromium Code Reviews| 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" |
| 11 #include "core/layout/LayoutView.h" | 11 #include "core/layout/LayoutView.h" |
| 12 #include "core/layout/svg/LayoutSVGRoot.h" | 12 #include "core/layout/svg/LayoutSVGRoot.h" |
| 13 #include "core/paint/ObjectPaintProperties.h" | 13 #include "core/paint/ObjectPaintProperties.h" |
| 14 #include "core/paint/PaintLayer.h" | 14 #include "core/paint/PaintLayer.h" |
| 15 #include "core/paint/SVGRootPainter.h" | 15 #include "core/paint/SVGRootPainter.h" |
| 16 #include "platform/transforms/TransformationMatrix.h" | 16 #include "platform/transforms/TransformationMatrix.h" |
| 17 #include "wtf/PtrUtil.h" | 17 #include "wtf/PtrUtil.h" |
| 18 #include <memory> | 18 #include <memory> |
| 19 | 19 |
| 20 namespace blink { | 20 namespace blink { |
| 21 | 21 |
| 22 PaintPropertyTreeBuilderContext | 22 PaintPropertyTreeBuilderContext |
| 23 PaintPropertyTreeBuilder::setupInitialContext() { | 23 PaintPropertyTreeBuilder::setupInitialContext() { |
| 24 PaintPropertyTreeBuilderContext context; | 24 PaintPropertyTreeBuilderContext context; |
| 25 | 25 |
| 26 context.current.clip = context.absolutePosition.clip = | 26 context.current.clip = context.absolutePosition.clip = |
| 27 context.fixedPosition.clip = ClipPaintPropertyNode::root(); | 27 context.fixedPosition.clip = ClipPaintPropertyNode::root(); |
| 28 context.currentEffect = EffectPaintPropertyNode::root(); | 28 context.currentEffect = EffectPaintPropertyNode::root(); |
| 29 context.inputClipOfCurrentEffect = ClipPaintPropertyNode::root(); | |
| 29 context.current.transform = context.absolutePosition.transform = | 30 context.current.transform = context.absolutePosition.transform = |
| 30 context.fixedPosition.transform = TransformPaintPropertyNode::root(); | 31 context.fixedPosition.transform = TransformPaintPropertyNode::root(); |
| 31 context.current.scroll = context.absolutePosition.scroll = | 32 context.current.scroll = context.absolutePosition.scroll = |
| 32 context.fixedPosition.scroll = ScrollPaintPropertyNode::root(); | 33 context.fixedPosition.scroll = ScrollPaintPropertyNode::root(); |
| 33 | 34 |
| 34 // Ensure scroll tree properties are reset. They will be rebuilt during the | 35 // Ensure scroll tree properties are reset. They will be rebuilt during the |
| 35 // tree walk. | 36 // tree walk. |
| 36 ScrollPaintPropertyNode::root()->clearMainThreadScrollingReasons(); | 37 ScrollPaintPropertyNode::root()->clearMainThreadScrollingReasons(); |
| 37 | 38 |
| 38 return context; | 39 return context; |
| (...skipping 310 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 349 effectNodeNeeded = true; | 350 effectNodeNeeded = true; |
| 350 | 351 |
| 351 CompositorFilterOperations filter; | 352 CompositorFilterOperations filter; |
| 352 if (object.isSVG() && !object.isSVGRoot()) { | 353 if (object.isSVG() && !object.isSVGRoot()) { |
| 353 // TODO(trchen): SVG caches filters in SVGResources. Implement it. | 354 // TODO(trchen): SVG caches filters in SVGResources. Implement it. |
| 354 } else if (PaintLayer* layer = toLayoutBoxModelObject(object).layer()) { | 355 } else if (PaintLayer* layer = toLayoutBoxModelObject(object).layer()) { |
| 355 // TODO(trchen): Eliminate PaintLayer dependency. | 356 // TODO(trchen): Eliminate PaintLayer dependency. |
| 356 filter = layer->createCompositorFilterOperationsForFilter(style); | 357 filter = layer->createCompositorFilterOperationsForFilter(style); |
| 357 } | 358 } |
| 358 | 359 |
| 359 const ClipPaintPropertyNode* outputClip = ClipPaintPropertyNode::root(); | 360 const ClipPaintPropertyNode* outputClip = context.inputClipOfCurrentEffect; |
| 361 const ClipPaintPropertyNode* expansionHint = nullptr; | |
| 360 // The CSS filter spec didn't specify how filters interact with overflow | 362 // The CSS filter spec didn't specify how filters interact with overflow |
| 361 // clips. The implementation here mimics the old Blink/WebKit behavior for | 363 // clips. The implementation here mimics the old Blink/WebKit behavior for |
| 362 // backward compatibility. | 364 // backward compatibility. |
| 363 // Basically the output of the filter will be affected by clips that applies | 365 // Basically the output of the filter will be affected by clips that applies |
| 364 // to the current element. The descendants that paints into the input of the | 366 // to the current element. The descendants that paints into the input of the |
| 365 // filter ignores any clips collected so far. For example: | 367 // filter ignores any clips collected so far. For example: |
| 366 // <div style="overflow:scroll"> | 368 // <div style="overflow:scroll"> |
| 367 // <div style="filter:blur(1px);"> | 369 // <div style="filter:blur(1px);"> |
| 368 // <div>A</div> | 370 // <div>A</div> |
| 369 // <div style="position:absolute;">B</div> | 371 // <div style="position:absolute;">B</div> |
| 370 // </div> | 372 // </div> |
| 371 // </div> | 373 // </div> |
| 372 // In this example "A" should be clipped if the filter was not present. | 374 // In this example "A" should be clipped if the filter was not present. |
| 373 // With the filter, "A" will be rastered without clipping, but instead | 375 // With the filter, "A" will be rastered without clipping, but instead |
| 374 // the blurred result will be clipped. | 376 // the blurred result will be clipped. |
| 375 // On the other hand, "B" should not be clipped because the overflow clip is | 377 // On the other hand, "B" should not be clipped because the overflow clip is |
| 376 // not in its containing block chain, but as the filter output will be | 378 // not in its containing block chain, but as the filter output will be |
| 377 // clipped, so a blurred "B" may still be invisible. | 379 // clipped, so a blurred "B" may still be invisible. |
| 378 if (!filter.isEmpty()) { | 380 if (!filter.isEmpty()) { |
| 379 effectNodeNeeded = true; | 381 effectNodeNeeded = true; |
| 380 outputClip = context.current.clip; | 382 outputClip = context.current.clip; |
| 381 | 383 |
| 382 // TODO(trchen): A filter may contain spatial operations such that an | 384 // TODO(trchen): A filter may contain spatial operations such that an |
| 383 // output pixel may depend on an input pixel outside of the output clip. | 385 // output pixel may depend on an input pixel outside of the output clip. |
| 384 // We should generate a special clip node to represent this expansion. | 386 // We should generate a special clip node to represent this expansion. |
| 387 expansionHint = outputClip; | |
|
chrishtr
2016/11/14 19:45:10
Why is it called expansionHint? It's not a hint is
trchen
2016/11/23 04:47:18
We haven't implemented one yet. The output clip is
| |
| 385 } | 388 } |
| 386 | 389 |
| 387 if (effectNodeNeeded) { | 390 if (effectNodeNeeded) { |
| 388 object.getMutableForPainting().ensurePaintProperties().updateEffect( | 391 object.getMutableForPainting().ensurePaintProperties().updateEffect( |
| 389 context.currentEffect, context.current.transform, outputClip, | 392 context.currentEffect, context.current.transform, outputClip, |
| 390 std::move(filter), opacity); | 393 std::move(filter), opacity); |
| 391 } else { | 394 } else { |
| 392 if (auto* properties = object.getMutableForPainting().paintProperties()) | 395 if (auto* properties = object.getMutableForPainting().paintProperties()) |
| 393 properties->clearEffect(); | 396 properties->clearEffect(); |
| 394 } | 397 } |
| 395 | 398 |
| 396 const auto* properties = object.paintProperties(); | 399 const auto* properties = object.paintProperties(); |
| 397 if (properties && properties->effect()) { | 400 if (properties && properties->effect()) { |
| 398 context.currentEffect = properties->effect(); | 401 context.currentEffect = properties->effect(); |
| 399 // TODO(pdr): Once the expansion clip node is created above, it should be | 402 if (expansionHint) { |
| 400 // used here to update all current clip nodes; | 403 context.inputClipOfCurrentEffect = context.current.clip = |
| 401 const ClipPaintPropertyNode* expansionHint = context.current.clip; | 404 context.absolutePosition.clip = context.fixedPosition.clip = |
| 402 context.current.clip = context.absolutePosition.clip = | 405 expansionHint; |
| 403 context.fixedPosition.clip = expansionHint; | 406 } |
| 404 } | 407 } |
| 405 } | 408 } |
| 406 | 409 |
| 407 void PaintPropertyTreeBuilder::updateCssClip( | 410 void PaintPropertyTreeBuilder::updateCssClip( |
| 408 const LayoutObject& object, | 411 const LayoutObject& object, |
| 409 PaintPropertyTreeBuilderContext& context) { | 412 PaintPropertyTreeBuilderContext& context) { |
| 410 if (object.hasClip()) { | 413 if (object.hasClip()) { |
| 411 // Create clip node for descendants that are not fixed position. | 414 // Create clip node for descendants that are not fixed position. |
| 412 // We don't have to setup context.absolutePosition.clip here because this | 415 // We don't have to setup context.absolutePosition.clip here because this |
| 413 // object must be a container for absolute position descendants, and will | 416 // object must be a container for absolute position descendants, and will |
| (...skipping 445 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 859 return; | 862 return; |
| 860 | 863 |
| 861 updateOverflowClip(object, context); | 864 updateOverflowClip(object, context); |
| 862 updatePerspective(object, context); | 865 updatePerspective(object, context); |
| 863 updateSvgLocalToBorderBoxTransform(object, context); | 866 updateSvgLocalToBorderBoxTransform(object, context); |
| 864 updateScrollAndScrollTranslation(object, context); | 867 updateScrollAndScrollTranslation(object, context); |
| 865 updateOutOfFlowContext(object, context); | 868 updateOutOfFlowContext(object, context); |
| 866 } | 869 } |
| 867 | 870 |
| 868 } // namespace blink | 871 } // namespace blink |
| OLD | NEW |