From 0d7266acef9d61f0f4466d5c558a526fac31c1e7 Mon Sep 17 00:00:00 2001 From: Jiyeon Kim Date: Thu, 18 Apr 2013 13:42:02 +0900 Subject: [PATCH] [CherryPick] thumb doesn't match click position for rtl input type=range [Title] [CherryPick] thumb doesn't match click position for rtl input type=range [Problem] N/A [Cause] N/A [Solution] N/A [Cherry-Picker] Jiyeon Kim https://bugs.webkit.org/show_bug.cgi?id=94890 Change-Id: Ifb02014b86b960e1f559fbbd925be0366456e5db --- .../range/range-hit-test-with-padding-expected.txt | 6 +++++- .../forms/range/range-hit-test-with-padding.html | 22 +++++++++++++++++----- Source/WebCore/html/shadow/SliderThumbElement.cpp | 5 ++++- 3 files changed, 26 insertions(+), 7 deletions(-) diff --git a/LayoutTests/fast/forms/range/range-hit-test-with-padding-expected.txt b/LayoutTests/fast/forms/range/range-hit-test-with-padding-expected.txt index 664c8ba..a787dc3 100644 --- a/LayoutTests/fast/forms/range/range-hit-test-with-padding-expected.txt +++ b/LayoutTests/fast/forms/range/range-hit-test-with-padding-expected.txt @@ -1,6 +1,10 @@ Clicking middle of input type=range with padding should set the value to middle. -PASS input.value is "500" +PASS input_ltr.value is "25" +PASS input_rtl.value is "25" +PASS input_vertical_ltr.value is "25" +PASS input_vertical_rtl.value is "25" + PASS successfullyParsed is true TEST COMPLETE diff --git a/LayoutTests/fast/forms/range/range-hit-test-with-padding.html b/LayoutTests/fast/forms/range/range-hit-test-with-padding.html index b987600..3701287 100644 --- a/LayoutTests/fast/forms/range/range-hit-test-with-padding.html +++ b/LayoutTests/fast/forms/range/range-hit-test-with-padding.html @@ -14,19 +14,31 @@ input::before {

Clicking middle of input type=range with padding should set the value to middle.

- + + + + diff --git a/Source/WebCore/html/shadow/SliderThumbElement.cpp b/Source/WebCore/html/shadow/SliderThumbElement.cpp index 967b48a..aa94a81 100644 --- a/Source/WebCore/html/shadow/SliderThumbElement.cpp +++ b/Source/WebCore/html/shadow/SliderThumbElement.cpp @@ -251,6 +251,7 @@ void SliderThumbElement::setPositionFromPoint(const LayoutPoint& point) input->setTextAsOfLastFormControlChangeEvent(input->value()); LayoutPoint offset = roundedLayoutPoint(input->renderer()->absoluteToLocal(point, false, true)); bool isVertical = hasVerticalAppearance(input); + bool isLeftToRightDirection = renderBox()->style()->isLeftToRightDirection(); LayoutUnit trackSize; LayoutUnit position; LayoutUnit currentPosition; @@ -269,6 +270,8 @@ void SliderThumbElement::setPositionFromPoint(const LayoutPoint& point) } else { trackSize = trackElement->renderBox()->contentWidth(); position = offset.x() - renderBox()->width() / 2 - trackBoundingBox.x() + inputBoundingBox.x(); + if (!isLeftToRightDirection) + position += renderBox()->width(); currentPosition = absoluteThumbOrigin.x() - absoluteSliderContentOrigin.x(); } position = max(0, min(position, trackSize)); @@ -276,7 +279,7 @@ void SliderThumbElement::setPositionFromPoint(const LayoutPoint& point) return; const Decimal ratio = Decimal::fromDouble(static_cast(position) / trackSize); - const Decimal fraction = isVertical || !renderBox()->style()->isLeftToRightDirection() ? Decimal(1) - ratio : ratio; + const Decimal fraction = isVertical || !isLeftToRightDirection ? Decimal(1) - ratio : ratio; StepRange stepRange(input->createStepRange(RejectAny)); const Decimal value = stepRange.clampValue(stepRange.valueFromProportion(fraction)); -- 2.7.4