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

Side by Side Diff: third_party/WebKit/Source/core/dom/DOMRectReadOnly.h

Issue 2612263002: Adding fromRect to DOMRect and DOMRectReadOnly interfaces following spec. (Closed)
Patch Set: Adding fromRect to DOMRect and DOMRectReadOnly interfaces following spec. Created 3 years, 11 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 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 #ifndef DOMRectReadOnly_h 5 #ifndef DOMRectReadOnly_h
6 #define DOMRectReadOnly_h 6 #define DOMRectReadOnly_h
7 7
8 #include "bindings/core/v8/ScriptWrappable.h" 8 #include "bindings/core/v8/ScriptWrappable.h"
9 #include "core/CoreExport.h" 9 #include "core/CoreExport.h"
10 #include "platform/heap/Handle.h" 10 #include "platform/heap/Handle.h"
11 11
12 namespace blink { 12 namespace blink {
13 13
14 class DOMRectInit;
14 class ScriptValue; 15 class ScriptValue;
15 class ScriptState; 16 class ScriptState;
16 17
17 class CORE_EXPORT DOMRectReadOnly : public GarbageCollected<DOMRectReadOnly>, 18 class CORE_EXPORT DOMRectReadOnly : public GarbageCollected<DOMRectReadOnly>,
18 public ScriptWrappable { 19 public ScriptWrappable {
19 DEFINE_WRAPPERTYPEINFO(); 20 DEFINE_WRAPPERTYPEINFO();
20 21
21 public: 22 public:
22 static DOMRectReadOnly* create(double x, 23 static DOMRectReadOnly* create(double x,
23 double y, 24 double y,
24 double width, 25 double width,
25 double height); 26 double height);
27 static DOMRectReadOnly* fromRect(const DOMRectInit&);
26 28
27 double x() const { return m_x; } 29 double x() const { return m_x; }
28 double y() const { return m_y; } 30 double y() const { return m_y; }
29 double width() const { return m_width; } 31 double width() const { return m_width; }
30 double height() const { return m_height; } 32 double height() const { return m_height; }
31 33
32 double top() const { return std::min(m_y, m_y + m_height); } 34 double top() const { return std::min(m_y, m_y + m_height); }
33 double right() const { return std::max(m_x, m_x + m_width); } 35 double right() const { return std::max(m_x, m_x + m_width); }
34 double bottom() const { return std::max(m_y, m_y + m_height); } 36 double bottom() const { return std::max(m_y, m_y + m_height); }
35 double left() const { return std::min(m_x, m_x + m_width); } 37 double left() const { return std::min(m_x, m_x + m_width); }
36 38
37 DEFINE_INLINE_TRACE() {} 39 DEFINE_INLINE_TRACE() {}
38 40
39 ScriptValue toJSONForBinding(ScriptState*) const; 41 ScriptValue toJSONForBinding(ScriptState*) const;
40 42
41 protected: 43 protected:
42 DOMRectReadOnly(double x, double y, double width, double height); 44 DOMRectReadOnly(double x, double y, double width, double height);
43 45
44 double m_x; 46 double m_x;
45 double m_y; 47 double m_y;
46 double m_width; 48 double m_width;
47 double m_height; 49 double m_height;
48 }; 50 };
49 51
50 } // namespace blink 52 } // namespace blink
51 53
52 #endif 54 #endif
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/dom/DOMRectInit.idl ('k') | third_party/WebKit/Source/core/dom/DOMRectReadOnly.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698