Commit 8ace0e3a authored by Rob Buis's avatar Rob Buis Committed by Commit Bot

Fix dom/ranges/Range-compareBoundaryPoints.html on ARM

The how parameter is defined as unsigned short in WebIDL. The
generated bindings end up calling ToSmallerUInt in V8BindingForCore.cpp.
The final cast in this method seems to hit an ARM specific issue [1].
To fix this static cast to int64_t before static casting to the unsigned type.

[1] http://www.embeddeduse.com/2013/08/25/casting-a-negative-float-to-an-unsigned-int/

Bug: 823812

Cq-Include-Trybots: master.tryserver.chromium.android:android_cronet_tester;master.tryserver.chromium.mac:ios-simulator-cronet
Change-Id: I90c733185b8325984e004224dd72176840d1794e
Reviewed-on: https://chromium-review.googlesource.com/970901Reviewed-by: default avatarJeremy Roman <jbroman@chromium.org>
Reviewed-by: default avatarRobert Ma <robertma@chromium.org>
Reviewed-by: default avatarKentaro Hara <haraken@chromium.org>
Commit-Queue: Rob Buis <rob.buis@samsung.com>
Cr-Commit-Position: refs/heads/master@{#545078}
parent 5c0b4d1a
......@@ -185,6 +185,7 @@ external/wpt/dom/nodes/Document-contentType/contentType/createHTMLDocument.html
external/wpt/dom/nodes/Node-lookupPrefix.xhtml
external/wpt/domparsing/innerhtml-03.xhtml
external/wpt/domparsing/innerhtml-04.html
external/wpt/dom/ranges/Range-compareBoundaryPoints.html
external/wpt/dom/ranges/Range-constructor.html
external/wpt/dom/traversal/NodeFilter-constants.html
external/wpt/dom/traversal/TreeWalker-walking-outside-a-tree.html
......
......@@ -43,6 +43,7 @@
#include "bindings/core/v8/WindowProxy.h"
#include "bindings/core/v8/WorkerOrWorkletScriptController.h"
#include "bindings/core/v8/custom/V8CustomXPathNSResolver.h"
#include "build/build_config.h"
#include "core/dom/Document.h"
#include "core/dom/Element.h"
#include "core/dom/QualifiedName.h"
......@@ -256,9 +257,14 @@ static inline T ToSmallerUInt(v8::Isolate* isolate,
if (std::isinf(number_value))
return 0;
number_value =
number_value < 0 ? -floor(fabs(number_value)) : floor(fabs(number_value));
return static_cast<T>(fmod(number_value, LimitsTrait::kNumberOfValues));
// Confine number to (-kNumberOfValues, kNumberOfValues).
double number = fmod(trunc(number_value), LimitsTrait::kNumberOfValues);
// Adjust range to [0, kNumberOfValues).
if (number < 0)
number += LimitsTrait::kNumberOfValues;
return static_cast<T>(number);
}
int8_t ToInt8(v8::Isolate* isolate,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment