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 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
112 | 112 |
113 // FIXME(pdr): Check for the presence of a transform instead of the valu e. Checking for an | 113 // FIXME(pdr): Check for the presence of a transform instead of the valu e. Checking for an |
114 // identity matrix will cause the property tree structure to change duri ng animations if | 114 // identity matrix will cause the property tree structure to change duri ng animations if |
115 // the animation passes through the identity matrix. | 115 // the animation passes through the identity matrix. |
116 // FIXME(pdr): Refactor this so all non-root SVG objects use the same tr ansform function. | 116 // FIXME(pdr): Refactor this so all non-root SVG objects use the same tr ansform function. |
117 const AffineTransform& transform = object.isSVGForeignObject() ? object. localSVGTransform() : object.localToSVGParentTransform(); | 117 const AffineTransform& transform = object.isSVGForeignObject() ? object. localSVGTransform() : object.localToSVGParentTransform(); |
118 if (transform.isIdentity()) | 118 if (transform.isIdentity()) |
119 return; | 119 return; |
120 | 120 |
121 // The origin is included in the local transform, so use an empty origin . | 121 // The origin is included in the local transform, so use an empty origin . |
122 // TODO(jbroman, pdr): Handle flattening in SVG? | |
trchen
2016/07/13 04:39:44
SVG doesn't support 3D transforms.
jbroman
2016/07/13 21:47:13
Oh good; that simplifies things. I guess I should
| |
122 RefPtr<TransformPaintPropertyNode> svgTransform = TransformPaintProperty Node::create( | 123 RefPtr<TransformPaintPropertyNode> svgTransform = TransformPaintProperty Node::create( |
123 transform, FloatPoint3D(0, 0, 0), context.currentTransform); | 124 transform, FloatPoint3D(0, 0, 0), context.currentTransform); |
124 context.currentTransform = svgTransform.get(); | 125 context.currentTransform = svgTransform.get(); |
125 object.getMutableForPainting().ensureObjectPaintProperties().setTransfor m(svgTransform.release()); | 126 object.getMutableForPainting().ensureObjectPaintProperties().setTransfor m(svgTransform.release()); |
126 return; | 127 return; |
127 } | 128 } |
128 | 129 |
130 if (!object.isBox()) | |
131 return; | |
129 const ComputedStyle& style = object.styleRef(); | 132 const ComputedStyle& style = object.styleRef(); |
130 if (!object.isBox() || !style.hasTransform()) | 133 if (!style.hasTransform() && !style.preserves3D()) |
131 return; | 134 return; |
132 | 135 |
133 TransformationMatrix matrix; | 136 TransformationMatrix matrix; |
134 style.applyTransform(matrix, toLayoutBox(object).size(), ComputedStyle::Excl udeTransformOrigin, | 137 style.applyTransform(matrix, toLayoutBox(object).size(), ComputedStyle::Excl udeTransformOrigin, |
135 ComputedStyle::IncludeMotionPath, ComputedStyle::IncludeIndependentTrans formProperties); | 138 ComputedStyle::IncludeMotionPath, ComputedStyle::IncludeIndependentTrans formProperties); |
139 | |
140 DCHECK(context.currentTransform); | |
141 const TransformPaintPropertyNode* renderingContextRoot = | |
142 context.currentTransform->preserves3D() | |
143 ? context.currentTransform->renderingContextRoot() : nullptr; | |
144 | |
145 // These variables must be initialized to make MSVC happy. | |
146 TransformPaintPropertyNode::TransformStyle transformStyle = | |
147 TransformPaintPropertyNode::FlattenTransform; | |
148 TransformPaintPropertyNode::RenderingContextBehavior renderingContextBehavio r = | |
149 TransformPaintPropertyNode::DontEstablishNewRenderingContext; | |
150 switch (style.transformStyle3D()) { | |
151 case TransformStyle3DFlat: | |
chrishtr
2016/07/13 20:30:50
Given the requirement to initialize for MSVC, migh
| |
152 transformStyle = TransformPaintPropertyNode::FlattenTransform; | |
153 break; | |
154 case TransformStyle3DPreserve3D: | |
155 transformStyle = TransformPaintPropertyNode::Preserve3D; | |
156 // If a node with transform-style: preserve-3d does not exist in an | |
157 // existing rendering context, it establishes a new one. | |
158 if (!renderingContextRoot) | |
159 renderingContextBehavior = TransformPaintPropertyNode::EstablishNewR enderingContext; | |
160 break; | |
161 } | |
162 | |
136 RefPtr<TransformPaintPropertyNode> transformNode = TransformPaintPropertyNod e::create( | 163 RefPtr<TransformPaintPropertyNode> transformNode = TransformPaintPropertyNod e::create( |
137 matrix, transformOrigin(toLayoutBox(object)), context.currentTransform); | 164 matrix, transformOrigin(toLayoutBox(object)), context.currentTransform, |
165 renderingContextBehavior, renderingContextRoot, transformStyle); | |
138 context.currentTransform = transformNode.get(); | 166 context.currentTransform = transformNode.get(); |
139 object.getMutableForPainting().ensureObjectPaintProperties().setTransform(tr ansformNode.release()); | 167 object.getMutableForPainting().ensureObjectPaintProperties().setTransform(tr ansformNode.release()); |
140 } | 168 } |
141 | 169 |
142 void PaintPropertyTreeBuilder::updateEffect(const LayoutObject& object, PaintPro pertyTreeBuilderContext& context) | 170 void PaintPropertyTreeBuilder::updateEffect(const LayoutObject& object, PaintPro pertyTreeBuilderContext& context) |
143 { | 171 { |
144 if (!object.styleRef().hasOpacity()) | 172 if (!object.styleRef().hasOpacity()) |
145 return; | 173 return; |
146 RefPtr<EffectPaintPropertyNode> effectNode = EffectPaintPropertyNode::create (object.styleRef().opacity(), context.currentEffect); | 174 RefPtr<EffectPaintPropertyNode> effectNode = EffectPaintPropertyNode::create (object.styleRef().opacity(), context.currentEffect); |
147 context.currentEffect = effectNode.get(); | 175 context.currentEffect = effectNode.get(); |
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
242 floatValueForLength(style.perspectiveOriginX(), borderBoxSize.width()), | 270 floatValueForLength(style.perspectiveOriginX(), borderBoxSize.width()), |
243 floatValueForLength(style.perspectiveOriginY(), borderBoxSize.height())) ; | 271 floatValueForLength(style.perspectiveOriginY(), borderBoxSize.height())) ; |
244 } | 272 } |
245 | 273 |
246 void PaintPropertyTreeBuilder::updatePerspective(const LayoutObject& object, Pai ntPropertyTreeBuilderContext& context) | 274 void PaintPropertyTreeBuilder::updatePerspective(const LayoutObject& object, Pai ntPropertyTreeBuilderContext& context) |
247 { | 275 { |
248 const ComputedStyle& style = object.styleRef(); | 276 const ComputedStyle& style = object.styleRef(); |
249 if (!object.isBox() || !style.hasPerspective()) | 277 if (!object.isBox() || !style.hasPerspective()) |
250 return; | 278 return; |
251 | 279 |
280 // The perspective node must not flatten (else nothing will get | |
281 // perspective), but it should still extend the rendering context as most | |
282 // transform nodes do. | |
283 DCHECK(context.currentTransform); | |
252 RefPtr<TransformPaintPropertyNode> perspective = TransformPaintPropertyNode: :create( | 284 RefPtr<TransformPaintPropertyNode> perspective = TransformPaintPropertyNode: :create( |
253 TransformationMatrix().applyPerspective(style.perspective()), | 285 TransformationMatrix().applyPerspective(style.perspective()), |
254 perspectiveOrigin(toLayoutBox(object)) + toLayoutSize(context.paintOffse t), | 286 perspectiveOrigin(toLayoutBox(object)) + toLayoutSize(context.paintOffse t), |
255 context.currentTransform); | 287 context.currentTransform, |
288 TransformPaintPropertyNode::DontEstablishNewRenderingContext, | |
289 context.currentTransform->renderingContextRoot(), | |
290 TransformPaintPropertyNode::Preserve3D); | |
256 context.currentTransform = perspective.get(); | 291 context.currentTransform = perspective.get(); |
257 object.getMutableForPainting().ensureObjectPaintProperties().setPerspective( perspective.release()); | 292 object.getMutableForPainting().ensureObjectPaintProperties().setPerspective( perspective.release()); |
258 } | 293 } |
259 | 294 |
260 void PaintPropertyTreeBuilder::updateSvgLocalToBorderBoxTransform(const LayoutOb ject& object, PaintPropertyTreeBuilderContext& context) | 295 void PaintPropertyTreeBuilder::updateSvgLocalToBorderBoxTransform(const LayoutOb ject& object, PaintPropertyTreeBuilderContext& context) |
261 { | 296 { |
262 if (!object.isSVGRoot()) | 297 if (!object.isSVGRoot()) |
263 return; | 298 return; |
264 | 299 |
265 AffineTransform transformToBorderBox = SVGRootPainter(toLayoutSVGRoot(object )).transformToPixelSnappedBorderBox(context.paintOffset); | 300 AffineTransform transformToBorderBox = SVGRootPainter(toLayoutSVGRoot(object )).transformToPixelSnappedBorderBox(context.paintOffset); |
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
408 updateOverflowClip(object, context); | 443 updateOverflowClip(object, context); |
409 // TODO(trchen): Insert flattening transform here, as specified by | 444 // TODO(trchen): Insert flattening transform here, as specified by |
410 // http://www.w3.org/TR/css3-transforms/#transform-style-property | 445 // http://www.w3.org/TR/css3-transforms/#transform-style-property |
411 updatePerspective(object, context); | 446 updatePerspective(object, context); |
412 updateSvgLocalToBorderBoxTransform(object, context); | 447 updateSvgLocalToBorderBoxTransform(object, context); |
413 updateScrollTranslation(object, context); | 448 updateScrollTranslation(object, context); |
414 updateOutOfFlowContext(object, context); | 449 updateOutOfFlowContext(object, context); |
415 } | 450 } |
416 | 451 |
417 } // namespace blink | 452 } // namespace blink |
OLD | NEW |