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/FindPropertiesNeedingUpdate.h" | 13 #include "core/paint/FindPropertiesNeedingUpdate.h" |
| 14 #include "core/paint/ObjectPaintProperties.h" | 14 #include "core/paint/ObjectPaintProperties.h" |
| 15 #include "core/paint/PaintLayer.h" | 15 #include "core/paint/PaintLayer.h" |
| 16 #include "core/paint/SVGRootPainter.h" | 16 #include "core/paint/SVGRootPainter.h" |
| 17 #include "platform/transforms/TransformationMatrix.h" | 17 #include "platform/transforms/TransformationMatrix.h" |
| 18 #include "wtf/PtrUtil.h" | 18 #include "wtf/PtrUtil.h" |
| 19 #include <memory> | 19 #include <memory> |
| 20 | 20 |
| 21 namespace blink { | 21 namespace blink { |
| 22 | 22 |
| 23 PaintPropertyTreeBuilderContext | 23 PaintPropertyTreeBuilderContext |
| 24 PaintPropertyTreeBuilder::setupInitialContext() { | 24 PaintPropertyTreeBuilder::setupInitialContext() { |
| 25 PaintPropertyTreeBuilderContext context; | 25 PaintPropertyTreeBuilderContext context; |
| 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 return context; | 34 return context; |
| 34 } | 35 } |
| 35 | 36 |
| 36 void updateFrameViewPreTranslation( | 37 void updateFrameViewPreTranslation( |
| 37 FrameView& frameView, | 38 FrameView& frameView, |
| 38 PassRefPtr<const TransformPaintPropertyNode> parent, | 39 PassRefPtr<const TransformPaintPropertyNode> parent, |
| (...skipping 332 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 371 effectNodeNeeded = true; | 372 effectNodeNeeded = true; |
| 372 | 373 |
| 373 CompositorFilterOperations filter; | 374 CompositorFilterOperations filter; |
| 374 if (object.isSVG() && !object.isSVGRoot()) { | 375 if (object.isSVG() && !object.isSVGRoot()) { |
| 375 // TODO(trchen): SVG caches filters in SVGResources. Implement it. | 376 // TODO(trchen): SVG caches filters in SVGResources. Implement it. |
| 376 } else if (PaintLayer* layer = toLayoutBoxModelObject(object).layer()) { | 377 } else if (PaintLayer* layer = toLayoutBoxModelObject(object).layer()) { |
| 377 // TODO(trchen): Eliminate PaintLayer dependency. | 378 // TODO(trchen): Eliminate PaintLayer dependency. |
| 378 filter = layer->createCompositorFilterOperationsForFilter(style); | 379 filter = layer->createCompositorFilterOperationsForFilter(style); |
| 379 } | 380 } |
| 380 | 381 |
| 381 const ClipPaintPropertyNode* outputClip = ClipPaintPropertyNode::root(); | 382 const ClipPaintPropertyNode* outputClip = context.inputClipOfCurrentEffect; |
| 382 // The CSS filter spec didn't specify how filters interact with overflow | 383 // The CSS filter spec didn't specify how filters interact with overflow |
| 383 // clips. The implementation here mimics the old Blink/WebKit behavior for | 384 // clips. The implementation here mimics the old Blink/WebKit behavior for |
| 384 // backward compatibility. | 385 // backward compatibility. |
| 385 // Basically the output of the filter will be affected by clips that applies | 386 // Basically the output of the filter will be affected by clips that applies |
| 386 // to the current element. The descendants that paints into the input of the | 387 // to the current element. The descendants that paints into the input of the |
| 387 // filter ignores any clips collected so far. For example: | 388 // filter ignores any clips collected so far. For example: |
| 388 // <div style="overflow:scroll"> | 389 // <div style="overflow:scroll"> |
| 389 // <div style="filter:blur(1px);"> | 390 // <div style="filter:blur(1px);"> |
| 390 // <div>A</div> | 391 // <div>A</div> |
| 391 // <div style="position:absolute;">B</div> | 392 // <div style="position:absolute;">B</div> |
| (...skipping 20 matching lines...) Expand all Loading... | |
| 412 std::move(filter), opacity); | 413 std::move(filter), opacity); |
| 413 } else { | 414 } else { |
| 414 if (auto* properties = object.getMutableForPainting().paintProperties()) | 415 if (auto* properties = object.getMutableForPainting().paintProperties()) |
| 415 properties->clearEffect(); | 416 properties->clearEffect(); |
| 416 } | 417 } |
| 417 } | 418 } |
| 418 | 419 |
| 419 const auto* properties = object.paintProperties(); | 420 const auto* properties = object.paintProperties(); |
| 420 if (properties && properties->effect()) { | 421 if (properties && properties->effect()) { |
| 421 context.currentEffect = properties->effect(); | 422 context.currentEffect = properties->effect(); |
| 422 // TODO(pdr): Once the expansion clip node is created above, it should be | 423 if (!properties->effect()->filter().isEmpty()) { |
| 423 // used here to update all current clip nodes; | 424 // TODO(trchen): Change input clip to expansion hint created above. |
|
chrishtr
2016/11/23 17:40:51
This comment is now out of date - there is no expa
| |
| 424 const ClipPaintPropertyNode* expansionHint = context.current.clip; | 425 const ClipPaintPropertyNode* inputClip = |
| 425 context.current.clip = context.absolutePosition.clip = | 426 properties->effect()->outputClip(); |
| 426 context.fixedPosition.clip = expansionHint; | 427 context.inputClipOfCurrentEffect = context.current.clip = |
| 428 context.absolutePosition.clip = context.fixedPosition.clip = | |
| 429 inputClip; | |
| 430 } | |
| 427 } | 431 } |
| 428 } | 432 } |
| 429 | 433 |
| 430 void PaintPropertyTreeBuilder::updateCssClip( | 434 void PaintPropertyTreeBuilder::updateCssClip( |
| 431 const LayoutObject& object, | 435 const LayoutObject& object, |
| 432 PaintPropertyTreeBuilderContext& context) { | 436 PaintPropertyTreeBuilderContext& context) { |
| 433 if (object.needsPaintPropertyUpdate()) { | 437 if (object.needsPaintPropertyUpdate()) { |
| 434 if (object.hasClip()) { | 438 if (object.hasClip()) { |
| 435 // Create clip node for descendants that are not fixed position. | 439 // Create clip node for descendants that are not fixed position. |
| 436 // We don't have to setup context.absolutePosition.clip here because this | 440 // We don't have to setup context.absolutePosition.clip here because this |
| (...skipping 463 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 900 #endif | 904 #endif |
| 901 | 905 |
| 902 updateOverflowClip(object, context); | 906 updateOverflowClip(object, context); |
| 903 updatePerspective(object, context); | 907 updatePerspective(object, context); |
| 904 updateSvgLocalToBorderBoxTransform(object, context); | 908 updateSvgLocalToBorderBoxTransform(object, context); |
| 905 updateScrollAndScrollTranslation(object, context); | 909 updateScrollAndScrollTranslation(object, context); |
| 906 updateOutOfFlowContext(object, context); | 910 updateOutOfFlowContext(object, context); |
| 907 } | 911 } |
| 908 | 912 |
| 909 } // namespace blink | 913 } // namespace blink |
| OLD | NEW |