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

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

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 #include "core/dom/DOMRectReadOnly.h" 5 #include "core/dom/DOMRectReadOnly.h"
6 6
7 #include "bindings/core/v8/ScriptValue.h" 7 #include "bindings/core/v8/ScriptValue.h"
8 #include "bindings/core/v8/V8ObjectBuilder.h" 8 #include "bindings/core/v8/V8ObjectBuilder.h"
9 #include "core/dom/DOMRectInit.h"
9 10
10 namespace blink { 11 namespace blink {
11 12
12 DOMRectReadOnly* DOMRectReadOnly::create(double x, 13 DOMRectReadOnly* DOMRectReadOnly::create(double x,
13 double y, 14 double y,
14 double width, 15 double width,
15 double height) { 16 double height) {
16 return new DOMRectReadOnly(x, y, width, height); 17 return new DOMRectReadOnly(x, y, width, height);
17 } 18 }
18 19
19 ScriptValue DOMRectReadOnly::toJSONForBinding(ScriptState* scriptState) const { 20 ScriptValue DOMRectReadOnly::toJSONForBinding(ScriptState* scriptState) const {
20 V8ObjectBuilder result(scriptState); 21 V8ObjectBuilder result(scriptState);
21 result.addNumber("x", x()); 22 result.addNumber("x", x());
22 result.addNumber("y", y()); 23 result.addNumber("y", y());
23 result.addNumber("width", width()); 24 result.addNumber("width", width());
24 result.addNumber("height", height()); 25 result.addNumber("height", height());
25 result.addNumber("top", top()); 26 result.addNumber("top", top());
26 result.addNumber("right", right()); 27 result.addNumber("right", right());
27 result.addNumber("bottom", bottom()); 28 result.addNumber("bottom", bottom());
28 result.addNumber("left", left()); 29 result.addNumber("left", left());
29 return result.scriptValue(); 30 return result.scriptValue();
30 } 31 }
31 32
33 DOMRectReadOnly* DOMRectReadOnly::fromRect(const DOMRectInit& other) {
34 return new DOMRectReadOnly(other.x(), other.y(), other.width(), other.he ight());
zino 2017/01/14 17:11:34 nit: Please remove unnecessary blanks.
Byoungkwon Ko 2017/01/15 02:49:08 Done.
35 }
36
32 DOMRectReadOnly::DOMRectReadOnly(double x, 37 DOMRectReadOnly::DOMRectReadOnly(double x,
33 double y, 38 double y,
34 double width, 39 double width,
35 double height) 40 double height)
36 : m_x(x), m_y(y), m_width(width), m_height(height) {} 41 : m_x(x), m_y(y), m_width(width), m_height(height) {}
37 42
38 } // namespace blink 43 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698