summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorhajimehoshi@chromium.org <hajimehoshi@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-04-16 11:30:01 +0000
committerhajimehoshi@chromium.org <hajimehoshi@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-04-16 11:30:01 +0000
commitf53eba128d2e455b0c827b08eeeb91b45c295515 (patch)
tree91d6548be70bb064115a6de2e1ea15207df3f24a
parent32a5a3bd590584e6ff5d8730ab79ff387f05e5e3 (diff)
downloadchromium_src-f53eba128d2e455b0c827b08eeeb91b45c295515.zip
chromium_src-f53eba128d2e455b0c827b08eeeb91b45c295515.tar.gz
chromium_src-f53eba128d2e455b0c827b08eeeb91b45c295515.tar.bz2
gin: Stop converting float values into integers implicitly
This CL is basically revert of https://codereview.chromium.org/195893017/. TEST=layout tests, gin_unittests Review URL: https://codereview.chromium.org/236883002 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@264170 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--content/shell/renderer/test_runner/event_sender.cc34
-rw-r--r--gin/converter.cc4
-rw-r--r--gin/converter_unittest.cc2
3 files changed, 21 insertions, 19 deletions
diff --git a/content/shell/renderer/test_runner/event_sender.cc b/content/shell/renderer/test_runner/event_sender.cc
index 53e2f11..d4cdd5d 100644
--- a/content/shell/renderer/test_runner/event_sender.cc
+++ b/content/shell/renderer/test_runner/event_sender.cc
@@ -340,7 +340,7 @@ class EventSenderBindings : public gin::Wrappable<EventSenderBindings> {
void SetPageScaleFactor(gin::Arguments* args);
void ClearTouchPoints();
void ReleaseTouchPoint(unsigned index);
- void UpdateTouchPoint(unsigned index, int x, int y);
+ void UpdateTouchPoint(unsigned index, double x, double y);
void CancelTouchPoint(unsigned index);
void SetTouchModifier(const std::string& key_name, bool set_mask);
void DumpFilenameBeingDragged();
@@ -587,8 +587,8 @@ void EventSenderBindings::SetPageScaleFactor(gin::Arguments* args) {
if (!sender_)
return;
float scale_factor;
- int x;
- int y;
+ double x;
+ double y;
if (args->PeekNext().IsEmpty())
return;
args->GetNext(&scale_factor);
@@ -598,7 +598,8 @@ void EventSenderBindings::SetPageScaleFactor(gin::Arguments* args) {
if (args->PeekNext().IsEmpty())
return;
args->GetNext(&y);
- sender_->SetPageScaleFactor(scale_factor, x, y);
+ sender_->SetPageScaleFactor(scale_factor,
+ static_cast<int>(x), static_cast<int>(y));
}
void EventSenderBindings::ClearTouchPoints() {
@@ -611,9 +612,9 @@ void EventSenderBindings::ReleaseTouchPoint(unsigned index) {
sender_->ReleaseTouchPoint(index);
}
-void EventSenderBindings::UpdateTouchPoint(unsigned index, int x, int y) {
+void EventSenderBindings::UpdateTouchPoint(unsigned index, double x, double y) {
if (sender_)
- sender_->UpdateTouchPoint(index, x, y);
+ sender_->UpdateTouchPoint(index, static_cast<int>(x), static_cast<int>(y));
}
void EventSenderBindings::CancelTouchPoint(unsigned index) {
@@ -1537,24 +1538,25 @@ void EventSender::BeginDragWithFiles(const std::vector<std::string>& files) {
}
void EventSender::AddTouchPoint(gin::Arguments* args) {
- int x;
- int y;
+ double x;
+ double y;
args->GetNext(&x);
args->GetNext(&y);
WebTouchPoint touch_point;
touch_point.state = WebTouchPoint::StatePressed;
- touch_point.position = WebFloatPoint(x, y);
+ touch_point.position = WebFloatPoint(static_cast<int>(x),
+ static_cast<int>(y));
touch_point.screenPosition = touch_point.position;
if (!args->PeekNext().IsEmpty()) {
- int radius_x;
+ double radius_x;
if (!args->GetNext(&radius_x)) {
args->ThrowError();
return;
}
- int radius_y = radius_x;
+ double radius_y = radius_x;
if (!args->PeekNext().IsEmpty()) {
if (!args->GetNext(&radius_y)) {
args->ThrowError();
@@ -1562,8 +1564,8 @@ void EventSender::AddTouchPoint(gin::Arguments* args) {
}
}
- touch_point.radiusX = radius_x;
- touch_point.radiusY = radius_y;
+ touch_point.radiusX = static_cast<int>(radius_x);
+ touch_point.radiusY = static_cast<int>(radius_y);
}
int lowest_id = 0;
@@ -1687,11 +1689,11 @@ void EventSender::MouseMoveTo(gin::Arguments* args) {
if (force_layout_on_events_)
view_->layout();
- int x;
- int y;
+ double x;
+ double y;
args->GetNext(&x);
args->GetNext(&y);
- WebPoint mouse_pos(x, y);
+ WebPoint mouse_pos(static_cast<int>(x), static_cast<int>(y));
int modifiers = 0;
if (!args->PeekNext().IsEmpty())
diff --git a/gin/converter.cc b/gin/converter.cc
index 29da322..07437b7 100644
--- a/gin/converter.cc
+++ b/gin/converter.cc
@@ -35,7 +35,7 @@ Handle<Value> Converter<int32_t>::ToV8(Isolate* isolate, int32_t val) {
bool Converter<int32_t>::FromV8(Isolate* isolate, Handle<Value> val,
int32_t* out) {
- if (!val->IsNumber())
+ if (!val->IsInt32())
return false;
*out = val->Int32Value();
return true;
@@ -47,7 +47,7 @@ Handle<Value> Converter<uint32_t>::ToV8(Isolate* isolate, uint32_t val) {
bool Converter<uint32_t>::FromV8(Isolate* isolate, Handle<Value> val,
uint32_t* out) {
- if (!val->IsNumber())
+ if (!val->IsUint32())
return false;
*out = val->Uint32Value();
return true;
diff --git a/gin/converter_unittest.cc b/gin/converter_unittest.cc
index cf1affc..791d7e6 100644
--- a/gin/converter_unittest.cc
+++ b/gin/converter_unittest.cc
@@ -89,7 +89,7 @@ TEST_F(ConverterTest, Int32) {
{ Integer::New(instance_->isolate(), 0).As<Value>(), true, 0 },
{ Integer::New(instance_->isolate(), 1).As<Value>(), true, 1 },
{ Number::New(instance_->isolate(), -1).As<Value>(), true, -1 },
- { Number::New(instance_->isolate(), 1.1).As<Value>(), true, 1 },
+ { Number::New(instance_->isolate(), 1.1).As<Value>(), false, 0 },
{ String::NewFromUtf8(instance_->isolate(), "42").As<Value>(), false, 0 },
{ String::NewFromUtf8(instance_->isolate(), "foo").As<Value>(), false, 0 },
{ Object::New(instance_->isolate()).As<Value>(), false, 0 },