Changeset 126132 in webkit


Ignore:
Timestamp:
Aug 20, 2012 9:27:27 PM (12 years ago)
Author:
keishi@webkit.org
Message:

Clicking input type=range with padding or border sets wrong value
https://bugs.webkit.org/show_bug.cgi?id=94473

Reviewed by Kent Tamura.

Source/WebCore:

We should take the padding and border width into account when calculating the value from the mouse location.

Test: fast/forms/range/range-hit-test-with-padding.html

  • html/shadow/SliderThumbElement.cpp:

(WebCore::sliderTrackElementOf):
(WebCore):
(WebCore::SliderThumbElement::setPositionFromPoint):

  • html/shadow/SliderThumbElement.h:

(WebCore):

LayoutTests:

  • fast/forms/range/range-hit-test-with-padding-expected.txt: Added.
  • fast/forms/range/range-hit-test-with-padding.html: Added.
Location:
trunk
Files:
2 added
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r126131 r126132  
     12012-08-20  Keishi Hattori  <keishi@webkit.org>
     2
     3        Clicking input type=range with padding or border sets wrong value
     4        https://bugs.webkit.org/show_bug.cgi?id=94473
     5
     6        Reviewed by Kent Tamura.
     7
     8        * fast/forms/range/range-hit-test-with-padding-expected.txt: Added.
     9        * fast/forms/range/range-hit-test-with-padding.html: Added.
     10
    1112012-08-20  MORITA Hajime  <morrita@google.com>
    212
  • trunk/Source/WebCore/ChangeLog

    r126131 r126132  
     12012-08-20  Keishi Hattori  <keishi@webkit.org>
     2
     3        Clicking input type=range with padding or border sets wrong value
     4        https://bugs.webkit.org/show_bug.cgi?id=94473
     5
     6        Reviewed by Kent Tamura.
     7
     8        We should take the padding and border width into account when calculating the value from the mouse location.
     9
     10        Test: fast/forms/range/range-hit-test-with-padding.html
     11
     12        * html/shadow/SliderThumbElement.cpp:
     13        (WebCore::sliderTrackElementOf):
     14        (WebCore):
     15        (WebCore::SliderThumbElement::setPositionFromPoint):
     16        * html/shadow/SliderThumbElement.h:
     17        (WebCore):
     18
    1192012-08-20  MORITA Hajime  <morrita@google.com>
    220
  • trunk/Source/WebCore/html/shadow/SliderThumbElement.cpp

    r125048 r126132  
    8282    ASSERT(thumb);
    8383    return toSliderThumbElement(thumb);
     84}
     85
     86HTMLElement* sliderTrackElementOf(Node* node)
     87{
     88    ASSERT(node);
     89    ShadowRoot* shadow = node->toInputElement()->userAgentShadowRoot();
     90    ASSERT(shadow);
     91    Node* track = shadow->firstChild()->firstChild();
     92    ASSERT(track);
     93    return toHTMLElement(track);
    8494}
    8595
     
    241251{
    242252    HTMLInputElement* input = hostInput();
    243 
    244     if (!input->renderer() || !renderer())
     253    HTMLElement* trackElement = sliderTrackElementOf(input);
     254
     255    if (!input->renderer() || !renderer() || !trackElement->renderer())
    245256        return;
    246257
     
    257268    LayoutPoint absoluteThumbOrigin = renderBox()->absoluteBoundingBoxRectIgnoringTransforms().location();
    258269    LayoutPoint absoluteSliderContentOrigin = roundedLayoutPoint(input->renderer()->localToAbsolute());
     270    IntRect trackBoundingBox = trackElement->renderer()->absoluteBoundingBoxRectIgnoringTransforms();
     271    IntRect inputBoundingBox = input->renderer()->absoluteBoundingBoxRectIgnoringTransforms();
    259272    if (isVertical) {
    260         trackSize = input->renderBox()->contentHeight() - renderBox()->height();
    261         position = offset.y() - renderBox()->height() / 2;
     273        trackSize = trackElement->renderBox()->contentHeight();
     274        position = offset.y() - renderBox()->height() / 2 - trackBoundingBox.y() + inputBoundingBox.y();
    262275        currentPosition = absoluteThumbOrigin.y() - absoluteSliderContentOrigin.y();
    263276    } else {
    264         trackSize = input->renderBox()->contentWidth() - renderBox()->width();
    265         position = offset.x() - renderBox()->width() / 2;
     277        trackSize = trackElement->renderBox()->contentWidth();
     278        position = offset.x() - renderBox()->width() / 2 - trackBoundingBox.x() + inputBoundingBox.x();
    266279        currentPosition = absoluteThumbOrigin.x() - absoluteSliderContentOrigin.x();
    267280    }
  • trunk/Source/WebCore/html/shadow/SliderThumbElement.h

    r124180 r126132  
    101101// An assertion fails if the specified node is not a range input.
    102102SliderThumbElement* sliderThumbElementOf(Node*);
     103HTMLElement* sliderTrackElementOf(Node*);
    103104
    104105// --------------------------------
Note: See TracChangeset for help on using the changeset viewer.