Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(16)

Side by Side Diff: Source/core/platform/graphics/transforms/TranslateTransformOperation.h

Issue 22900008: Make vw/vh units to work in css transforms. Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 7 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2000 Lars Knoll (knoll@kde.org) 2 * Copyright (C) 2000 Lars Knoll (knoll@kde.org)
3 * (C) 2000 Antti Koivisto (koivisto@kde.org) 3 * (C) 2000 Antti Koivisto (koivisto@kde.org)
4 * (C) 2000 Dirk Mueller (mueller@kde.org) 4 * (C) 2000 Dirk Mueller (mueller@kde.org)
5 * Copyright (C) 2003, 2005, 2006, 2007, 2008 Apple Inc. All rights reserved. 5 * Copyright (C) 2003, 2005, 2006, 2007, 2008 Apple Inc. All rights reserved.
6 * Copyright (C) 2006 Graham Dennis (graham.dennis@gmail.com) 6 * Copyright (C) 2006 Graham Dennis (graham.dennis@gmail.com)
7 * 7 *
8 * This library is free software; you can redistribute it and/or 8 * This library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Library General Public 9 * modify it under the terms of the GNU Library General Public
10 * License as published by the Free Software Foundation; either 10 * License as published by the Free Software Foundation; either
(...skipping 25 matching lines...) Expand all
36 static PassRefPtr<TranslateTransformOperation> create(const Length& tx, cons t Length& ty, OperationType type) 36 static PassRefPtr<TranslateTransformOperation> create(const Length& tx, cons t Length& ty, OperationType type)
37 { 37 {
38 return adoptRef(new TranslateTransformOperation(tx, ty, Length(0, Fixed) , type)); 38 return adoptRef(new TranslateTransformOperation(tx, ty, Length(0, Fixed) , type));
39 } 39 }
40 40
41 static PassRefPtr<TranslateTransformOperation> create(const Length& tx, cons t Length& ty, const Length& tz, OperationType type) 41 static PassRefPtr<TranslateTransformOperation> create(const Length& tx, cons t Length& ty, const Length& tz, OperationType type)
42 { 42 {
43 return adoptRef(new TranslateTransformOperation(tx, ty, tz, type)); 43 return adoptRef(new TranslateTransformOperation(tx, ty, tz, type));
44 } 44 }
45 45
46 double x(const FloatSize& borderBoxSize) const { return floatValueForLength( m_x, borderBoxSize.width()); } 46 double x(const FloatSize& borderBoxSize, RenderView* renderView) const { ret urn floatValueForLength(m_x, borderBoxSize.width(), renderView); }
47 double y(const FloatSize& borderBoxSize) const { return floatValueForLength( m_y, borderBoxSize.height()); } 47 double y(const FloatSize& borderBoxSize, RenderView* renderView) const { ret urn floatValueForLength(m_y, borderBoxSize.height(), renderView); }
48 double z(const FloatSize&) const { return floatValueForLength(m_z, 1); } 48 double z(const FloatSize&, RenderView* renderView) const { return floatValue ForLength(m_z, 1, renderView); }
49 49
50 Length x() const { return m_x; } 50 Length x() const { return m_x; }
51 Length y() const { return m_y; } 51 Length y() const { return m_y; }
52 Length z() const { return m_z; } 52 Length z() const { return m_z; }
53 53
54 private: 54 private:
55 virtual bool isIdentity() const { return !floatValueForLength(m_x, 1) && !fl oatValueForLength(m_y, 1) && !floatValueForLength(m_z, 1); } 55 virtual bool isIdentity() const { return !floatValueForLength(m_x, 1) && !fl oatValueForLength(m_y, 1) && !floatValueForLength(m_z, 1); }
56 56
57 virtual OperationType getOperationType() const { return m_type; } 57 virtual OperationType getOperationType() const { return m_type; }
58 virtual bool isSameType(const TransformOperation& o) const { return o.getOpe rationType() == m_type; } 58 virtual bool isSameType(const TransformOperation& o) const { return o.getOpe rationType() == m_type; }
59 59
60 virtual bool operator==(const TransformOperation& o) const 60 virtual bool operator==(const TransformOperation& o) const
61 { 61 {
62 if (!isSameType(o)) 62 if (!isSameType(o))
63 return false; 63 return false;
64 const TranslateTransformOperation* t = static_cast<const TranslateTransf ormOperation*>(&o); 64 const TranslateTransformOperation* t = static_cast<const TranslateTransf ormOperation*>(&o);
65 return m_x == t->m_x && m_y == t->m_y && m_z == t->m_z; 65 return m_x == t->m_x && m_y == t->m_y && m_z == t->m_z;
66 } 66 }
67 67
68 virtual bool apply(TransformationMatrix& transform, const FloatSize& borderB oxSize) const 68 virtual bool apply(TransformationMatrix& transform, const FloatSize& borderB oxSize, RenderView* renderView) const
69 { 69 {
70 transform.translate3d(x(borderBoxSize), y(borderBoxSize), z(borderBoxSiz e)); 70 transform.translate3d(x(borderBoxSize, renderView), y(borderBoxSize, ren derView), z(borderBoxSize, renderView));
71 return m_x.type() == Percent || m_y.type() == Percent; 71 return m_x.type() == Percent || m_y.type() == Percent;
72 } 72 }
73 73
74 virtual PassRefPtr<TransformOperation> blend(const TransformOperation* from, double progress, bool blendToIdentity = false); 74 virtual PassRefPtr<TransformOperation> blend(const TransformOperation* from, double progress, bool blendToIdentity = false, RenderView* =0);
75 75
76 TranslateTransformOperation(const Length& tx, const Length& ty, const Length & tz, OperationType type) 76 TranslateTransformOperation(const Length& tx, const Length& ty, const Length & tz, OperationType type)
77 : m_x(tx) 77 : m_x(tx)
78 , m_y(ty) 78 , m_y(ty)
79 , m_z(tz) 79 , m_z(tz)
80 , m_type(type) 80 , m_type(type)
81 { 81 {
82 ASSERT(type == TranslateX || type == TranslateY || type == TranslateZ || type == Translate || type == Translate3D); 82 ASSERT(type == TranslateX || type == TranslateY || type == TranslateZ || type == Translate || type == Translate3D);
83 } 83 }
84 84
85 Length m_x; 85 Length m_x;
86 Length m_y; 86 Length m_y;
87 Length m_z; 87 Length m_z;
88 OperationType m_type; 88 OperationType m_type;
89 }; 89 };
90 90
91 } // namespace WebCore 91 } // namespace WebCore
92 92
93 #endif // TranslateTransformOperation_h 93 #endif // TranslateTransformOperation_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698