Changeset 122286 in webkit


Ignore:
Timestamp:
Jul 10, 2012 6:47:58 PM (12 years ago)
Author:
commit-queue@webkit.org
Message:

Input elements with type=range do not have default touch handlers.
https://bugs.webkit.org/show_bug.cgi?id=88807

Patch by Kevin Ellis <kevers@chromium.org> on 2012-07-10
Reviewed by Antonio Gomes.

Source/WebCore:

This patch adds support for touch event handling on input elements
and dragging a slider with touch start and move events. Previously,
manipulating a slider on a touch screen required generation of
synthetic mouse events.

Tests: fast/events/touch/touch-slider-no-js-touch-listener.html

fast/events/touch/touch-slider.html

  • dom/Event.cpp:

(WebCore::Event::isTouchEvent):
(WebCore):

  • dom/Event.h:

(Event):

  • dom/Touch.cpp:

(WebCore::Touch::Touch):

  • dom/Touch.h:

(WebCore::Touch::absoluteLocation):
(Touch):

  • dom/TouchEvent.cpp:

(WebCore::TouchEvent::isTouchEvent):
(WebCore):

  • dom/TouchEvent.h:

(TouchEvent):

  • html/HTMLInputElement.cpp:

(WebCore::HTMLInputElement::HTMLInputElement):
(WebCore::HTMLInputElement::~HTMLInputElement):
(WebCore::HTMLInputElement::updateType):
(WebCore::HTMLInputElement::defaultEventHandler):

  • html/HTMLInputElement.h:

(HTMLInputElement):

  • html/InputType.cpp:

(WebCore):
(WebCore::InputType::handleTouchEvent):
(WebCore::InputType::hasTouchEventHandler):

  • html/InputType.h:

(WebCore):
(ClickHandlingState):
(InputType):

  • html/RangeInputType.cpp:

(WebCore):
(WebCore::RangeInputType::handleTouchEvent):
(WebCore::RangeInputType::hasTouchEventHandler):

  • html/RangeInputType.h:

(RangeInputType):

  • html/shadow/SliderThumbElement.h:

(SliderThumbElement):

Source/WebKit/chromium:

Adds flag to enable native handling of touch events for input elements
with type=range.

  • features.gypi:

LayoutTests:

Add automated test for manipulating an input slider via touch
events.

  • fast/events/touch/script-tests/touch-slider-no-js-touch-listener.js: Added.

(checkPosition):

  • fast/events/touch/script-tests/touch-slider.js: Added.

(onTouchStart):
(onTouchEnd):
(onKeyDown):
(checkPosition):

  • fast/events/touch/touch-slider-expected.txt: Added.
  • fast/events/touch/touch-slider-no-js-touch-listener-expected.txt: Added.
  • fast/events/touch/touch-slider-no-js-touch-listener.html: Added.
  • fast/events/touch/touch-slider.html: Added.
  • platform/chromium/fast/events/touch/touch-slider-expected.txt: Added.
  • platform/chromium/fast/events/touch/touch-slider-no-js-touch-listener-expected.txt: Added.
Location:
trunk
Files:
8 added
17 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r122281 r122286  
     12012-07-10  Kevin Ellis  <kevers@chromium.org>
     2
     3        Input elements with type=range do not have default touch handlers.
     4        https://bugs.webkit.org/show_bug.cgi?id=88807
     5
     6        Reviewed by Antonio Gomes.
     7
     8        Add automated test for manipulating an input slider via touch
     9        events.
     10
     11        * fast/events/touch/script-tests/touch-slider-no-js-touch-listener.js: Added.
     12        (checkPosition):
     13        * fast/events/touch/script-tests/touch-slider.js: Added.
     14        (onTouchStart):
     15        (onTouchEnd):
     16        (onKeyDown):
     17        (checkPosition):
     18        * fast/events/touch/touch-slider-expected.txt: Added.
     19        * fast/events/touch/touch-slider-no-js-touch-listener-expected.txt: Added.
     20        * fast/events/touch/touch-slider-no-js-touch-listener.html: Added.
     21        * fast/events/touch/touch-slider.html: Added.
     22        * platform/chromium/fast/events/touch/touch-slider-expected.txt: Added.
     23        * platform/chromium/fast/events/touch/touch-slider-no-js-touch-listener-expected.txt: Added.
     24
    1252012-07-10  Kenneth Russell  <kbr@google.com>
    226
  • trunk/Source/WebCore/ChangeLog

    r122282 r122286  
     12012-07-10  Kevin Ellis  <kevers@chromium.org>
     2
     3        Input elements with type=range do not have default touch handlers.
     4        https://bugs.webkit.org/show_bug.cgi?id=88807
     5
     6        Reviewed by Antonio Gomes.
     7
     8        This patch adds support for touch event handling on input elements
     9        and dragging a slider with touch start and move events.  Previously,
     10        manipulating a slider on a touch screen required generation of
     11        synthetic mouse events.
     12
     13        Tests: fast/events/touch/touch-slider-no-js-touch-listener.html
     14               fast/events/touch/touch-slider.html
     15
     16        * dom/Event.cpp:
     17        (WebCore::Event::isTouchEvent):
     18        (WebCore):
     19        * dom/Event.h:
     20        (Event):
     21        * dom/Touch.cpp:
     22        (WebCore::Touch::Touch):
     23        * dom/Touch.h:
     24        (WebCore::Touch::absoluteLocation):
     25        (Touch):
     26        * dom/TouchEvent.cpp:
     27        (WebCore::TouchEvent::isTouchEvent):
     28        (WebCore):
     29        * dom/TouchEvent.h:
     30        (TouchEvent):
     31        * html/HTMLInputElement.cpp:
     32        (WebCore::HTMLInputElement::HTMLInputElement):
     33        (WebCore::HTMLInputElement::~HTMLInputElement):
     34        (WebCore::HTMLInputElement::updateType):
     35        (WebCore::HTMLInputElement::defaultEventHandler):
     36        * html/HTMLInputElement.h:
     37        (HTMLInputElement):
     38        * html/InputType.cpp:
     39        (WebCore):
     40        (WebCore::InputType::handleTouchEvent):
     41        (WebCore::InputType::hasTouchEventHandler):
     42        * html/InputType.h:
     43        (WebCore):
     44        (ClickHandlingState):
     45        (InputType):
     46        * html/RangeInputType.cpp:
     47        (WebCore):
     48        (WebCore::RangeInputType::handleTouchEvent):
     49        (WebCore::RangeInputType::hasTouchEventHandler):
     50        * html/RangeInputType.h:
     51        (RangeInputType):
     52        * html/shadow/SliderThumbElement.h:
     53        (SliderThumbElement):
     54
    1552012-07-10  Pravin D  <pravind.2k4@gmail.com>
    256
  • trunk/Source/WebCore/dom/Event.cpp

    r114867 r122286  
    127127}
    128128
     129bool Event::isTouchEvent() const
     130{
     131    return false;
     132}
     133
    129134bool Event::isDragEvent() const
    130135{
  • trunk/Source/WebCore/dom/Event.h

    r116039 r122286  
    121121        virtual bool isMouseEvent() const;
    122122        virtual bool isKeyboardEvent() const;
     123        virtual bool isTouchEvent() const;
    123124
    124125        // Drag events are a subset of mouse events.
  • trunk/Source/WebCore/dom/Touch.cpp

    r95901 r122286  
    3030#include "Touch.h"
    3131
     32#include "DOMWindow.h"
    3233#include "Frame.h"
    3334#include "FrameView.h"
     
    6970    , m_force(force)
    7071{
     72    float scaleFactor = frame->pageZoomFactor() * frame->frameScaleFactor();
     73    float x = pageX * scaleFactor;
     74    float y = pageY * scaleFactor;
     75    m_absoluteLocation = roundedLayoutPoint(FloatPoint(x, y));
    7176}
    7277
  • trunk/Source/WebCore/dom/Touch.h

    r95901 r122286  
    3030
    3131#include "EventTarget.h"
     32#include "LayoutTypes.h"
    3233#include <wtf/PassRefPtr.h>
    3334#include <wtf/RefCounted.h>
     
    6061    float webkitRotationAngle() const { return m_rotationAngle; }
    6162    float webkitForce() const { return m_force; }
     63    const LayoutPoint& absoluteLocation() const { return m_absoluteLocation; }
    6264
    6365private:
     
    7880    float m_rotationAngle;
    7981    float m_force;
     82    LayoutPoint m_absoluteLocation;
    8083};
    8184
  • trunk/Source/WebCore/dom/TouchEvent.cpp

    r113575 r122286  
    9595}
    9696
     97bool TouchEvent::isTouchEvent() const
     98{
     99    return true;
     100}
     101
    97102} // namespace WebCore
    98103
  • trunk/Source/WebCore/dom/TouchEvent.h

    r113575 r122286  
    7070    bool isTouchHold() const { return m_touchHold; }
    7171#endif
     72    virtual bool isTouchEvent() const OVERRIDE;
    7273
    7374    virtual const AtomicString& interfaceName() const;
  • trunk/Source/WebCore/html/HTMLInputElement.cpp

    r121519 r122286  
    6868#endif
    6969
     70#if ENABLE(TOUCH_EVENTS)
     71#include "TouchEvent.h"
     72#endif
     73
    7074using namespace std;
    7175
     
    99103    , m_wasModifiedByUser(false)
    100104    , m_canReceiveDroppedFiles(false)
     105    , m_hasTouchEventHandler(false)
    101106    , m_inputType(InputType::createText(this))
    102107{
     
    131136    if (isRadioButton())
    132137        document()->formController()->checkedRadioButtons().removeButton(this);
     138#if ENABLE(TOUCH_EVENTS)
     139    if (m_hasTouchEventHandler)
     140        document()->didRemoveTouchEventHandler();
     141#endif
    133142}
    134143
     
    401410    m_inputType = newType.release();
    402411    m_inputType->createShadowSubtree();
     412
     413#if ENABLE(TOUCH_EVENTS)
     414    bool hasTouchEventHandler = m_inputType->hasTouchEventHandler();
     415    if (hasTouchEventHandler != m_hasTouchEventHandler) {
     416      if (hasTouchEventHandler) {
     417        document()->didAddTouchEventHandler();
     418        document()->addListenerType(Document::TOUCH_LISTENER);
     419      } else
     420        document()->didRemoveTouchEventHandler();
     421      m_hasTouchEventHandler = hasTouchEventHandler;
     422    }
     423#endif
    403424
    404425    setNeedsWillValidateCheck();
     
    10391060    }
    10401061
     1062#if ENABLE(TOUCH_EVENTS)
     1063    if (evt->isTouchEvent()) {
     1064        m_inputType->handleTouchEvent(static_cast<TouchEvent*>(evt));
     1065        if (evt->defaultHandled())
     1066            return;
     1067    }
     1068#endif
     1069
    10411070    if (evt->isKeyboardEvent() && evt->type() == eventNames().keydownEvent) {
    10421071        m_inputType->handleKeydownEvent(static_cast<KeyboardEvent*>(evt));
  • trunk/Source/WebCore/html/HTMLInputElement.h

    r121519 r122286  
    391391    bool m_wasModifiedByUser : 1;
    392392    bool m_canReceiveDroppedFiles : 1;
     393    bool m_hasTouchEventHandler: 1;
    393394    OwnPtr<InputType> m_inputType;
    394395};
  • trunk/Source/WebCore/html/InputType.cpp

    r121019 r122286  
    418418}
    419419
     420#if ENABLE(TOUCH_EVENTS)
     421void InputType::handleTouchEvent(TouchEvent*)
     422{
     423}
     424#endif
     425
    420426void InputType::forwardEvent(Event*)
    421427{
     
    873879{
    874880}
     881
     882#if ENABLE(TOUCH_EVENTS)
     883bool InputType::hasTouchEventHandler() const
     884{
     885    return false;
     886}
     887#endif
    875888
    876889String InputType::defaultToolTip() const
  • trunk/Source/WebCore/html/InputType.h

    r120695 r122286  
    6262class RenderObject;
    6363class RenderStyle;
     64class TouchEvent;
    6465class WheelEvent;
    6566
     
    6869struct ClickHandlingState {
    6970    WTF_MAKE_FAST_ALLOCATED;
     71 
    7072public:
    7173    bool checked;
     
    191193    virtual void handleBeforeTextInsertedEvent(BeforeTextInsertedEvent*);
    192194    virtual void handleWheelEvent(WheelEvent*);
     195#if ENABLE(TOUCH_EVENTS)
     196    virtual void handleTouchEvent(TouchEvent*);
     197#endif
    193198    virtual void forwardEvent(Event*);
    194199    // Helpers for event handlers.
     
    203208    virtual bool canBeSuccessfulSubmitButton();
    204209    virtual void subtreeHasChanged();
     210#if ENABLE(TOUCH_EVENTS)
     211    virtual bool hasTouchEventHandler() const;
     212#endif
    205213
    206214    // Shadow tree handling
  • trunk/Source/WebCore/html/RangeInputType.cpp

    r120313 r122286  
    5050#include <wtf/PassOwnPtr.h>
    5151
     52#if ENABLE(TOUCH_EVENTS)
     53#include "Touch.h"
     54#include "TouchEvent.h"
     55#include "TouchList.h"
     56#endif
     57
    5258namespace WebCore {
    5359
     
    134140    thumb->dragFrom(event->absoluteLocation());
    135141}
     142
     143#if ENABLE(TOUCH_EVENTS)
     144#if ENABLE(TOUCH_SLIDER)
     145void RangeInputType::handleTouchEvent(TouchEvent* event)
     146{
     147    if (element()->disabled() || element()->readOnly())
     148        return;
     149
     150    if (event->type() == eventNames().touchendEvent) {
     151        event->setDefaultHandled();
     152        return;
     153    }
     154
     155    TouchList* touches = event->targetTouches();
     156    if (touches->length() == 1) {
     157        Touch* touch = touches->item(0);
     158        SliderThumbElement* thumb = sliderThumbElementOf(element());
     159        thumb->setPositionFromPoint(touch->absoluteLocation());
     160        event->setDefaultHandled();
     161    }
     162}
     163
     164bool RangeInputType::hasTouchEventHandler() const
     165{
     166    return true;
     167}
     168#endif
     169#endif
    136170
    137171void RangeInputType::handleKeydownEvent(KeyboardEvent* event)
  • trunk/Source/WebCore/html/RangeInputType.h

    r120313 r122286  
    5252    virtual bool isSteppable() const OVERRIDE;
    5353    virtual void handleMouseDownEvent(MouseEvent*) OVERRIDE;
     54#if ENABLE(TOUCH_EVENTS)
     55#if ENABLE(TOUCH_SLIDER)
     56    virtual void handleTouchEvent(TouchEvent*) OVERRIDE;
     57    virtual bool hasTouchEventHandler() const OVERRIDE;
     58#endif
     59#endif
    5460    virtual void handleKeydownEvent(KeyboardEvent*) OVERRIDE;
    5561    virtual RenderObject* createRenderer(RenderArena*, RenderStyle*) const OVERRIDE;
  • trunk/Source/WebCore/html/shadow/SliderThumbElement.h

    r95901 r122286  
    5858    virtual const AtomicString& shadowPseudoId() const;
    5959    HTMLInputElement* hostInput() const;
     60    void setPositionFromPoint(const LayoutPoint&);
    6061
    6162private:
     
    6869    void startDragging();
    6970    void stopDragging();
    70     void setPositionFromPoint(const LayoutPoint&);
    7171
    7272    bool m_inDragMode;
  • trunk/Source/WebKit/chromium/ChangeLog

    r122284 r122286  
     12012-07-10  Kevin Ellis  <kevers@chromium.org>
     2
     3        Input elements with type=range do not have default touch handlers.
     4        https://bugs.webkit.org/show_bug.cgi?id=88807
     5
     6        Reviewed by Antonio Gomes.
     7
     8        Adds flag to enable native handling of touch events for input elements
     9        with type=range.
     10
     11        * features.gypi:
     12
    1132012-07-10  Adam Klein  <adamk@chromium.org>
    214
  • trunk/Source/WebKit/chromium/features.gypi

    r122195 r122286  
    9898      'ENABLE_TOUCH_EVENTS=<(enable_touch_events)',
    9999      'ENABLE_TOUCH_ICON_LOADING=<(enable_touch_icon_loading)',
     100      'ENABLE_TOUCH_SLIDER=1',
    100101      'ENABLE_V8_SCRIPT_DEBUG_SERVER=1',
    101102      'ENABLE_VIDEO=1',
Note: See TracChangeset for help on using the changeset viewer.