| OLD | NEW |
| 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 |
| OLD | NEW |