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" |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 99 static FloatPoint3D transformOrigin(const LayoutBox& box) | 99 static FloatPoint3D transformOrigin(const LayoutBox& box) |
| 100 { | 100 { |
| 101 const ComputedStyle& style = box.styleRef(); | 101 const ComputedStyle& style = box.styleRef(); |
| 102 FloatSize borderBoxSize(box.size()); | 102 FloatSize borderBoxSize(box.size()); |
| 103 return FloatPoint3D( | 103 return FloatPoint3D( |
| 104 floatValueForLength(style.transformOriginX(), borderBoxSize.width()), | 104 floatValueForLength(style.transformOriginX(), borderBoxSize.width()), |
| 105 floatValueForLength(style.transformOriginY(), borderBoxSize.height()), | 105 floatValueForLength(style.transformOriginY(), borderBoxSize.height()), |
| 106 style.transformOriginZ()); | 106 style.transformOriginZ()); |
| 107 } | 107 } |
| 108 | 108 |
| 109 void PaintPropertyTreeBuilder::clearTransformProperty(const LayoutObject& object , void (ObjectPaintProperties::*setter)(PassRefPtr<TransformPaintPropertyNode>)) | |
| 110 { | |
| 111 if (ObjectPaintProperties* existingProperties = object.objectPaintProperties ()) | |
| 112 (existingProperties->*setter)(nullptr); | |
| 113 } | |
| 114 | |
| 115 void PaintPropertyTreeBuilder::updateOrCreateTransformProperty(const LayoutObjec t& object, TransformPaintPropertyNode* (ObjectPaintProperties::*getter)() const, void (ObjectPaintProperties::*setter)(PassRefPtr<TransformPaintPropertyNode>), const TransformationMatrix& matrix, const FloatPoint3D& origin, PassRefPtr<Trans formPaintPropertyNode> parent) | |
| 116 { | |
| 117 ObjectPaintProperties* existingProperties = object.objectPaintProperties(); | |
| 118 TransformPaintPropertyNode* existingTransform = existingProperties ? (existi ngProperties->*getter)() : nullptr; | |
| 119 if (!existingTransform) { | |
|
pdr.
2016/07/21 23:14:01
Oops, you'll want to do a comparison of the values
| |
| 120 (object.getMutableForPainting().ensureObjectPaintProperties().*setter)(T ransformPaintPropertyNode::create(matrix, origin, parent)); | |
| 121 return; | |
| 122 } | |
| 123 existingTransform->setMatrix(matrix); | |
| 124 existingTransform->setOrigin(origin); | |
| 125 existingTransform->setParent(parent); | |
| 126 } | |
| 127 | |
| 109 void PaintPropertyTreeBuilder::updateTransform(const LayoutObject& object, Paint PropertyTreeBuilderContext& context) | 128 void PaintPropertyTreeBuilder::updateTransform(const LayoutObject& object, Paint PropertyTreeBuilderContext& context) |
| 110 { | 129 { |
| 111 if (object.isSVG() && !object.isSVGRoot()) { | 130 if (object.isSVG() && !object.isSVGRoot()) { |
| 112 // SVG does not use paint offset internally. | 131 // SVG does not use paint offset internally. |
| 113 DCHECK(context.current.paintOffset == LayoutPoint()); | 132 DCHECK(context.current.paintOffset == LayoutPoint()); |
| 114 | 133 |
| 115 // FIXME(pdr): Check for the presence of a transform instead of the valu e. Checking for an | 134 // FIXME(pdr): Check for the presence of a transform instead of the valu e. Checking for an |
| 116 // identity matrix will cause the property tree structure to change duri ng animations if | 135 // identity matrix will cause the property tree structure to change duri ng animations if |
| 117 // the animation passes through the identity matrix. | 136 // the animation passes through the identity matrix. |
| 118 // FIXME(pdr): Refactor this so all non-root SVG objects use the same tr ansform function. | 137 // FIXME(pdr): Refactor this so all non-root SVG objects use the same tr ansform function. |
| 119 const AffineTransform& transform = object.isSVGForeignObject() ? object. localSVGTransform() : object.localToSVGParentTransform(); | 138 const AffineTransform& transform = object.isSVGForeignObject() ? object. localSVGTransform() : object.localToSVGParentTransform(); |
| 120 if (transform.isIdentity()) | 139 if (transform.isIdentity()) { |
| 140 clearTransformProperty(object, &ObjectPaintProperties::setTransform) ; | |
| 121 return; | 141 return; |
| 142 } | |
| 122 | 143 |
| 123 // The origin is included in the local transform, so use an empty origin . | 144 // The origin is included in the local transform, so use an empty origin . |
| 124 RefPtr<TransformPaintPropertyNode> svgTransform = TransformPaintProperty Node::create( | 145 updateOrCreateTransformProperty(object, &ObjectPaintProperties::transfor m, &ObjectPaintProperties::setTransform, transform, FloatPoint3D(0, 0, 0), conte xt.current.transform); |
| 125 transform, FloatPoint3D(0, 0, 0), context.current.transform); | 146 context.current.transform = object.objectPaintProperties()->transform(); |
| 126 context.current.transform = svgTransform.get(); | |
| 127 object.getMutableForPainting().ensureObjectPaintProperties().setTransfor m(svgTransform.release()); | |
| 128 return; | 147 return; |
| 129 } | 148 } |
| 130 | 149 |
| 131 const ComputedStyle& style = object.styleRef(); | 150 const ComputedStyle& style = object.styleRef(); |
| 132 if (!object.isBox() || !style.hasTransform()) | 151 if (!object.isBox() || !style.hasTransform()) { |
| 152 clearTransformProperty(object, &ObjectPaintProperties::setTransform); | |
| 133 return; | 153 return; |
| 154 } | |
| 134 | 155 |
| 135 TransformationMatrix matrix; | 156 TransformationMatrix matrix; |
| 136 style.applyTransform(matrix, toLayoutBox(object).size(), ComputedStyle::Excl udeTransformOrigin, | 157 style.applyTransform(matrix, toLayoutBox(object).size(), ComputedStyle::Excl udeTransformOrigin, |
| 137 ComputedStyle::IncludeMotionPath, ComputedStyle::IncludeIndependentTrans formProperties); | 158 ComputedStyle::IncludeMotionPath, ComputedStyle::IncludeIndependentTrans formProperties); |
| 138 RefPtr<TransformPaintPropertyNode> transformNode = TransformPaintPropertyNod e::create( | 159 updateOrCreateTransformProperty(object, &ObjectPaintProperties::transform, & ObjectPaintProperties::setTransform, matrix, transformOrigin(toLayoutBox(object) ), context.current.transform); |
| 139 matrix, transformOrigin(toLayoutBox(object)), context.current.transform) ; | 160 context.current.transform = object.objectPaintProperties()->transform(); |
| 140 context.current.transform = transformNode.get(); | |
| 141 object.getMutableForPainting().ensureObjectPaintProperties().setTransform(tr ansformNode.release()); | |
| 142 } | 161 } |
| 143 | 162 |
| 144 void PaintPropertyTreeBuilder::updateEffect(const LayoutObject& object, PaintPro pertyTreeBuilderContext& context) | 163 void PaintPropertyTreeBuilder::updateEffect(const LayoutObject& object, PaintPro pertyTreeBuilderContext& context) |
| 145 { | 164 { |
| 146 if (!object.styleRef().hasOpacity()) | 165 if (!object.styleRef().hasOpacity()) |
| 147 return; | 166 return; |
| 148 RefPtr<EffectPaintPropertyNode> effectNode = EffectPaintPropertyNode::create (object.styleRef().opacity(), context.currentEffect); | 167 RefPtr<EffectPaintPropertyNode> effectNode = EffectPaintPropertyNode::create (object.styleRef().opacity(), context.currentEffect); |
| 149 context.currentEffect = effectNode.get(); | 168 context.currentEffect = effectNode.get(); |
| 150 object.getMutableForPainting().ensureObjectPaintProperties().setEffect(effec tNode.release()); | 169 object.getMutableForPainting().ensureObjectPaintProperties().setEffect(effec tNode.release()); |
| 151 } | 170 } |
| (...skipping 226 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 378 if (boxModelObject.isTableCell()) { | 397 if (boxModelObject.isTableCell()) { |
| 379 LayoutObject* parentRow = boxModelObject.parent(); | 398 LayoutObject* parentRow = boxModelObject.parent(); |
| 380 ASSERT(parentRow && parentRow->isTableRow()); | 399 ASSERT(parentRow && parentRow->isTableRow()); |
| 381 context.current.paintOffset.moveBy(-toLayoutBox(parentRow)->topLeftL ocation()); | 400 context.current.paintOffset.moveBy(-toLayoutBox(parentRow)->topLeftL ocation()); |
| 382 } | 401 } |
| 383 } | 402 } |
| 384 } | 403 } |
| 385 | 404 |
| 386 void PaintPropertyTreeBuilder::buildTreeNodes(const LayoutObject& object, PaintP ropertyTreeBuilderContext& context) | 405 void PaintPropertyTreeBuilder::buildTreeNodes(const LayoutObject& object, PaintP ropertyTreeBuilderContext& context) |
| 387 { | 406 { |
| 388 object.getMutableForPainting().clearObjectPaintProperties(); | |
| 389 | |
| 390 if (!object.isBoxModelObject() && !object.isSVG()) | 407 if (!object.isBoxModelObject() && !object.isSVG()) |
| 391 return; | 408 return; |
| 392 | 409 |
| 393 deriveBorderBoxFromContainerContext(object, context); | 410 deriveBorderBoxFromContainerContext(object, context); |
| 394 | 411 |
| 395 updatePaintOffsetTranslation(object, context); | 412 updatePaintOffsetTranslation(object, context); |
| 396 updateTransform(object, context); | 413 updateTransform(object, context); |
| 397 updateEffect(object, context); | 414 updateEffect(object, context); |
| 398 updateCssClip(object, context); | 415 updateCssClip(object, context); |
| 399 updateLocalBorderBoxContext(object, context); | 416 updateLocalBorderBoxContext(object, context); |
| 400 updateScrollbarPaintOffset(object, context); | 417 updateScrollbarPaintOffset(object, context); |
| 401 updateOverflowClip(object, context); | 418 updateOverflowClip(object, context); |
| 402 // TODO(trchen): Insert flattening transform here, as specified by | 419 // TODO(trchen): Insert flattening transform here, as specified by |
| 403 // http://www.w3.org/TR/css3-transforms/#transform-style-property | 420 // http://www.w3.org/TR/css3-transforms/#transform-style-property |
| 404 updatePerspective(object, context); | 421 updatePerspective(object, context); |
| 405 updateSvgLocalToBorderBoxTransform(object, context); | 422 updateSvgLocalToBorderBoxTransform(object, context); |
| 406 updateScrollTranslation(object, context); | 423 updateScrollTranslation(object, context); |
| 407 updateOutOfFlowContext(object, context); | 424 updateOutOfFlowContext(object, context); |
| 408 } | 425 } |
| 409 | 426 |
| 410 } // namespace blink | 427 } // namespace blink |
| OLD | NEW |