Chromium Code Reviews| Index: third_party/WebKit/Source/platform/graphics/paint/TransformPaintPropertyNode.h |
| diff --git a/third_party/WebKit/Source/platform/graphics/paint/TransformPaintPropertyNode.h b/third_party/WebKit/Source/platform/graphics/paint/TransformPaintPropertyNode.h |
| index 03980087c1c8c198b83549a2574fbd84142fa8b2..0828cc9ead064039b4f401a1b98f67100e101338 100644 |
| --- a/third_party/WebKit/Source/platform/graphics/paint/TransformPaintPropertyNode.h |
| +++ b/third_party/WebKit/Source/platform/graphics/paint/TransformPaintPropertyNode.h |
| @@ -21,9 +21,47 @@ namespace blink { |
| // for the root. |
| class PLATFORM_EXPORT TransformPaintPropertyNode : public RefCounted<TransformPaintPropertyNode> { |
| public: |
| - static PassRefPtr<TransformPaintPropertyNode> create(const TransformationMatrix& matrix, const FloatPoint3D& origin, PassRefPtr<TransformPaintPropertyNode> parent = nullptr) |
| + enum TransformStyle { FlattenTransform, Preserve3D }; |
| + enum RenderingContextBehavior { |
|
trchen
2016/07/13 04:39:44
I don't think this belong here. This is a CSS conc
jbroman
2016/07/13 21:47:13
Because the |this| pointer doesn't exist yet there
trchen
2016/07/13 22:31:42
Why do we need to TransformPaintPropertyNode* as s
jbroman
2016/07/14 20:34:58
It doesn't need to be; it just was (it's convenien
|
| + // The node should participate in the context provided, if any, but not |
| + // establish a new one. |
| + DontEstablishNewRenderingContext, |
| + |
| + // The node should establish a new 3D rendering context. |
| + // No existing rendering context root should be provided. |
| + EstablishNewRenderingContext |
| + }; |
| + |
| + // Creates a transform node, allowing full specification of the rendering |
| + // context and transform style. If renderingContextBehavior is |
| + // EstablishNewRenderingContext, then the renderingContextRoot provided must |
| + // be null. |
| + static PassRefPtr<TransformPaintPropertyNode> create( |
| + const TransformationMatrix& matrix, |
| + const FloatPoint3D& origin, |
| + PassRefPtr<TransformPaintPropertyNode> parent, |
| + RenderingContextBehavior renderingContextBehavior, |
| + const TransformPaintPropertyNode* renderingContextRoot, |
| + TransformStyle transformStyle) |
| + { |
| + return adoptRef(new TransformPaintPropertyNode(matrix, origin, parent, renderingContextBehavior, renderingContextRoot, transformStyle)); |
| + } |
| + |
| + // As above, but inherits the rendering context and transform style from the |
| + // parent transform node. Never establishes a new rendering context. |
| + static PassRefPtr<TransformPaintPropertyNode> create( |
| + const TransformationMatrix& matrix, |
| + const FloatPoint3D& origin, |
| + PassRefPtr<TransformPaintPropertyNode> parent = nullptr) |
| { |
| - return adoptRef(new TransformPaintPropertyNode(matrix, origin, parent)); |
| + if (!parent) |
| + return create(matrix, origin, nullptr, DontEstablishNewRenderingContext, nullptr, FlattenTransform); |
| + |
| + // Have to copy the data out of parent before we pass the reference |
| + // (and null out the local pointer). |
| + const TransformPaintPropertyNode* renderingContextRoot = parent->renderingContextRoot(); |
| + TransformStyle transformStyle = parent->transformStyle(); |
| + return create(matrix, origin, parent, DontEstablishNewRenderingContext, renderingContextRoot, transformStyle); |
| } |
| const TransformationMatrix& matrix() const { return m_matrix; } |
| @@ -33,14 +71,53 @@ public: |
| // is the root transform. |
| TransformPaintPropertyNode* parent() const { return m_parent.get(); } |
| + // Content whose transform nodes have a common rendering context root is 3D |
| + // sorted. If this is nullptr, content will not be 3D sorted. |
| + const TransformPaintPropertyNode* renderingContextRoot() const { return m_renderingContextRoot; } |
| + bool hasRenderingContext() const { return renderingContextRoot(); } |
| + |
| + // If a transform node flattens transform, then content within it is |
| + // flattened into the plane of the transform space (including this node's |
| + // matrix). If it preserves 3D, then no such flattening occurs. |
| + // |
| + // This corresponds fairly closely to CSS transform-style semantics, and in |
| + // CSS is fairly tightly connected with the rendering context root. |
| + TransformStyle transformStyle() const { return m_transformStyle; } |
| + bool flattensTransform() const { return transformStyle() == FlattenTransform; } |
| + bool preserves3D() const { return transformStyle() == Preserve3D; } |
|
trchen
2016/07/13 04:39:44
Ditto. It is a leak of CSS concept. I think flatte
chrishtr
2016/07/13 20:30:50
I don't understand this comment, could you rephras
jbroman
2016/07/13 21:47:13
This isn't the CSS concept, because it is not inte
trchen
2016/07/13 22:31:42
In that case, why not name it "flattensLocalToScre
trchen
2016/07/13 22:31:42
For example:
<div style="transform-style:preserve
jbroman
2016/07/14 20:34:58
We can, and now this CL does. It does require some
|
| + |
| private: |
| + TransformPaintPropertyNode( |
| + const TransformationMatrix& matrix, |
| + const FloatPoint3D& origin, |
| + PassRefPtr<TransformPaintPropertyNode> parent, |
| + RenderingContextBehavior renderingContextBehavior, |
| + const TransformPaintPropertyNode* renderingContextRoot, |
| + TransformStyle transformStyle) |
| + : m_matrix(matrix) |
| + , m_origin(origin) |
| + , m_parent(parent) |
| + , m_transformStyle(transformStyle) |
| + { |
| + switch (renderingContextBehavior) { |
| + case DontEstablishNewRenderingContext: |
| + m_renderingContextRoot = renderingContextRoot; |
| + break; |
| + case EstablishNewRenderingContext: |
| + DCHECK(!renderingContextRoot); |
| + m_renderingContextRoot = this; |
| + break; |
| + } |
| - TransformPaintPropertyNode(const TransformationMatrix& matrix, const FloatPoint3D& origin, PassRefPtr<TransformPaintPropertyNode> parent) |
| - : m_matrix(matrix), m_origin(origin), m_parent(parent) { } |
| + // Every rendering context root must preserve 3D. |
| + DCHECK(!m_renderingContextRoot || m_renderingContextRoot->preserves3D()); |
| + } |
| const TransformationMatrix m_matrix; |
| const FloatPoint3D m_origin; |
| RefPtr<TransformPaintPropertyNode> m_parent; |
| + const TransformPaintPropertyNode* m_renderingContextRoot; |
| + const TransformStyle m_transformStyle; |
| }; |
| // Redeclared here to avoid ODR issues. |