Changeset 150801 in webkit


Ignore:
Timestamp:
May 28, 2013 7:01:20 AM (11 years ago)
Author:
akling@apple.com
Message:

Move dispatching of focus-related events from Node to Element.
<http://webkit.org/b/116864>

Reviewed by Antti Koivisto.

...and pass around pointers to Element instead of Node.

  • dom/Node.cpp:
  • dom/Node.h:
  • dom/Element.h:
  • dom/Element.cpp:

(WebCore::Element::dispatchFocusInEvent):
(WebCore::Element::dispatchFocusOutEvent):
(WebCore::Element::dispatchFocusEvent):
(WebCore::Element::dispatchBlurEvent):

Moved here from Node.

  • html/HTMLFormControlElement.h:
  • html/HTMLFormControlElement.cpp:

(WebCore::HTMLFormControlElement::dispatchBlurEvent):

  • html/HTMLSelectElement.h:
  • html/HTMLSelectElement.cpp:

(WebCore::HTMLSelectElement::dispatchFocusEvent):
(WebCore::HTMLSelectElement::dispatchBlurEvent):

  • html/HTMLTextFormControlElement.h:
  • html/HTMLTextFormControlElement.cpp:

(WebCore::HTMLTextFormControlElement::dispatchFocusEvent):
(WebCore::HTMLTextFormControlElement::dispatchBlurEvent):

Update subclass overrides and sprinkle OVERRIDE/FINAL.

Location:
trunk/Source/WebCore
Files:
11 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r150799 r150801  
     12013-05-28  Andreas Kling  <akling@apple.com>
     2
     3        Move dispatching of focus-related events from Node to Element.
     4        <http://webkit.org/b/116864>
     5
     6        Reviewed by Antti Koivisto.
     7
     8        ...and pass around pointers to Element instead of Node.
     9
     10        * dom/Node.cpp:
     11        * dom/Node.h:
     12        * dom/Element.h:
     13        * dom/Element.cpp:
     14        (WebCore::Element::dispatchFocusInEvent):
     15        (WebCore::Element::dispatchFocusOutEvent):
     16        (WebCore::Element::dispatchFocusEvent):
     17        (WebCore::Element::dispatchBlurEvent):
     18
     19            Moved here from Node.
     20
     21        * html/HTMLFormControlElement.h:
     22        * html/HTMLFormControlElement.cpp:
     23        (WebCore::HTMLFormControlElement::dispatchBlurEvent):
     24        * html/HTMLSelectElement.h:
     25        * html/HTMLSelectElement.cpp:
     26        (WebCore::HTMLSelectElement::dispatchFocusEvent):
     27        (WebCore::HTMLSelectElement::dispatchBlurEvent):
     28        * html/HTMLTextFormControlElement.h:
     29        * html/HTMLTextFormControlElement.cpp:
     30        (WebCore::HTMLTextFormControlElement::dispatchFocusEvent):
     31        (WebCore::HTMLTextFormControlElement::dispatchBlurEvent):
     32
     33            Update subclass overrides and sprinkle OVERRIDE/FINAL.
     34
    1352013-05-28  Zan Dobersek  <zdobersek@igalia.com>
    236
  • trunk/Source/WebCore/dom/Element.cpp

    r150796 r150801  
    4747#include "FlowThreadController.h"
    4848#include "FocusController.h"
     49#include "FocusEvent.h"
    4950#include "Frame.h"
    5051#include "FrameSelection.h"
     
    21592160}
    21602161
     2162void Element::dispatchFocusInEvent(const AtomicString& eventType, PassRefPtr<Element> oldFocusedElement)
     2163{
     2164    ASSERT(!NoEventDispatchAssertion::isEventDispatchForbidden());
     2165    ASSERT(eventType == eventNames().focusinEvent || eventType == eventNames().DOMFocusInEvent);
     2166    dispatchScopedEventDispatchMediator(FocusInEventDispatchMediator::create(FocusEvent::create(eventType, true, false, document()->defaultView(), 0, oldFocusedElement)));
     2167}
     2168
     2169void Element::dispatchFocusOutEvent(const AtomicString& eventType, PassRefPtr<Element> newFocusedElement)
     2170{
     2171    ASSERT(!NoEventDispatchAssertion::isEventDispatchForbidden());
     2172    ASSERT(eventType == eventNames().focusoutEvent || eventType == eventNames().DOMFocusOutEvent);
     2173    dispatchScopedEventDispatchMediator(FocusOutEventDispatchMediator::create(FocusEvent::create(eventType, true, false, document()->defaultView(), 0, newFocusedElement)));
     2174}
     2175
     2176void Element::dispatchFocusEvent(PassRefPtr<Element> oldFocusedElement, FocusDirection)
     2177{
     2178    if (document()->page())
     2179        document()->page()->chrome().client()->elementDidFocus(this);
     2180
     2181    RefPtr<FocusEvent> event = FocusEvent::create(eventNames().focusEvent, false, false, document()->defaultView(), 0, oldFocusedElement);
     2182    EventDispatcher::dispatchEvent(this, FocusEventDispatchMediator::create(event.release()));
     2183}
     2184
     2185void Element::dispatchBlurEvent(PassRefPtr<Element> newFocusedElement)
     2186{
     2187    if (document()->page())
     2188        document()->page()->chrome().client()->elementDidBlur(this);
     2189
     2190    RefPtr<FocusEvent> event = FocusEvent::create(eventNames().blurEvent, false, false, document()->defaultView(), 0, newFocusedElement);
     2191    EventDispatcher::dispatchEvent(this, BlurEventDispatchMediator::create(event.release()));
     2192}
     2193
     2194
    21612195String Element::innerText()
    21622196{
  • trunk/Source/WebCore/dom/Element.h

    r150744 r150801  
    637637
    638638    void dispatchSimulatedClick(Event* underlyingEvent, SimulatedClickMouseEventOptions = SendNoEvents, SimulatedClickVisualOptions = ShowPressedLook);
     639    void dispatchFocusInEvent(const AtomicString& eventType, PassRefPtr<Element> oldFocusedElement);
     640    void dispatchFocusOutEvent(const AtomicString& eventType, PassRefPtr<Element> newFocusedElement);
     641    virtual void dispatchFocusEvent(PassRefPtr<Element> oldFocusedElement, FocusDirection);
     642    virtual void dispatchBlurEvent(PassRefPtr<Element> newFocusedElement);
    639643
    640644protected:
  • trunk/Source/WebCore/dom/Node.cpp

    r150796 r150801  
    6161#include "ExceptionCode.h"
    6262#include "ExceptionCodePlaceholder.h"
    63 #include "FocusEvent.h"
    6463#include "Frame.h"
    6564#include "FrameView.h"
     
    22992298}
    23002299
    2301 void Node::dispatchFocusInEvent(const AtomicString& eventType, PassRefPtr<Node> oldFocusedNode)
    2302 {
    2303     ASSERT(!NoEventDispatchAssertion::isEventDispatchForbidden());
    2304     ASSERT(eventType == eventNames().focusinEvent || eventType == eventNames().DOMFocusInEvent);
    2305     dispatchScopedEventDispatchMediator(FocusInEventDispatchMediator::create(FocusEvent::create(eventType, true, false, document()->defaultView(), 0, oldFocusedNode)));
    2306 }
    2307 
    2308 void Node::dispatchFocusOutEvent(const AtomicString& eventType, PassRefPtr<Node> newFocusedNode)
    2309 {
    2310     ASSERT(!NoEventDispatchAssertion::isEventDispatchForbidden());
    2311     ASSERT(eventType == eventNames().focusoutEvent || eventType == eventNames().DOMFocusOutEvent);
    2312     dispatchScopedEventDispatchMediator(FocusOutEventDispatchMediator::create(FocusEvent::create(eventType, true, false, document()->defaultView(), 0, newFocusedNode)));
    2313 }
    2314 
    23152300bool Node::dispatchDOMActivateEvent(int detail, PassRefPtr<Event> underlyingEvent)
    23162301{
     
    23642349{
    23652350    return EventDispatcher::dispatchEvent(this, WheelEventDispatchMediator::create(event, document()->defaultView()));
    2366 }
    2367 
    2368 void Node::dispatchFocusEvent(PassRefPtr<Node> oldFocusedNode, FocusDirection)
    2369 {
    2370     if (document()->page())
    2371         document()->page()->chrome().client()->elementDidFocus(this);
    2372 
    2373     RefPtr<FocusEvent> event = FocusEvent::create(eventNames().focusEvent, false, false, document()->defaultView(), 0, oldFocusedNode);
    2374     EventDispatcher::dispatchEvent(this, FocusEventDispatchMediator::create(event.release()));
    2375 }
    2376 
    2377 void Node::dispatchBlurEvent(PassRefPtr<Node> newFocusedNode)
    2378 {
    2379     if (document()->page())
    2380         document()->page()->chrome().client()->elementDidBlur(this);
    2381 
    2382     RefPtr<FocusEvent> event = FocusEvent::create(eventNames().blurEvent, false, false, document()->defaultView(), 0, newFocusedNode);
    2383     EventDispatcher::dispatchEvent(this, BlurEventDispatchMediator::create(event.release()));
    23842351}
    23852352
  • trunk/Source/WebCore/dom/Node.h

    r150783 r150801  
    2828#include "EditingBoundary.h"
    2929#include "EventTarget.h"
    30 #include "FocusDirection.h"
    3130#include "KURLHash.h"
    3231#include "LayoutRect.h"
     
    604603    void dispatchSubtreeModifiedEvent();
    605604    bool dispatchDOMActivateEvent(int detail, PassRefPtr<Event> underlyingEvent);
    606     void dispatchFocusInEvent(const AtomicString& eventType, PassRefPtr<Node> oldFocusedNode);
    607     void dispatchFocusOutEvent(const AtomicString& eventType, PassRefPtr<Node> newFocusedNode);
    608605
    609606    bool dispatchKeyEvent(const PlatformKeyboardEvent&);
     
    619616    bool dispatchBeforeLoadEvent(const String& sourceURL);
    620617
    621     virtual void dispatchFocusEvent(PassRefPtr<Node> oldFocusedNode, FocusDirection);
    622     virtual void dispatchBlurEvent(PassRefPtr<Node> newFocusedNode);
    623618    virtual void dispatchChangeEvent();
    624619    virtual void dispatchInputEvent();
  • trunk/Source/WebCore/html/HTMLFormControlElement.cpp

    r150711 r150801  
    457457}
    458458
    459 void HTMLFormControlElement::dispatchBlurEvent(PassRefPtr<Node> newFocusedNode)
    460 {
    461     HTMLElement::dispatchBlurEvent(newFocusedNode);
     459void HTMLFormControlElement::dispatchBlurEvent(PassRefPtr<Element> newFocusedElement)
     460{
     461    HTMLElement::dispatchBlurEvent(newFocusedElement);
    462462    hideVisibleValidationMessage();
    463463}
  • trunk/Source/WebCore/html/HTMLFormControlElement.h

    r150711 r150801  
    122122    virtual void didRecalcStyle(StyleChange) OVERRIDE;
    123123
    124     virtual void dispatchBlurEvent(PassRefPtr<Node> newFocusedNode);
     124    virtual void dispatchBlurEvent(PassRefPtr<Element> newFocusedElement) OVERRIDE;
    125125
    126126    // This must be called any time the result of willValidate() has changed.
  • trunk/Source/WebCore/html/HTMLSelectElement.cpp

    r150102 r150801  
    906906}
    907907
    908 void HTMLSelectElement::dispatchFocusEvent(PassRefPtr<Node> oldFocusedNode, FocusDirection direction)
     908void HTMLSelectElement::dispatchFocusEvent(PassRefPtr<Element> oldFocusedElement, FocusDirection direction)
    909909{
    910910    // Save the selection so it can be compared to the new selection when
     
    912912    if (usesMenuList())
    913913        saveLastSelection();
    914     HTMLFormControlElementWithState::dispatchFocusEvent(oldFocusedNode, direction);
    915 }
    916 
    917 void HTMLSelectElement::dispatchBlurEvent(PassRefPtr<Node> newFocusedNode)
     914    HTMLFormControlElementWithState::dispatchFocusEvent(oldFocusedElement, direction);
     915}
     916
     917void HTMLSelectElement::dispatchBlurEvent(PassRefPtr<Element> newFocusedElement)
    918918{
    919919    // We only need to fire change events here for menu lists, because we fire
     
    922922    if (usesMenuList())
    923923        dispatchChangeEventForMenuList();
    924     HTMLFormControlElementWithState::dispatchBlurEvent(newFocusedNode);
     924    HTMLFormControlElementWithState::dispatchBlurEvent(newFocusedElement);
    925925}
    926926
  • trunk/Source/WebCore/html/HTMLSelectElement.h

    r150692 r150801  
    115115    virtual bool isMouseFocusable() const OVERRIDE;
    116116
    117     virtual void dispatchFocusEvent(PassRefPtr<Node> oldFocusedNode, FocusDirection) OVERRIDE;
    118     virtual void dispatchBlurEvent(PassRefPtr<Node> newFocusedNode);
     117    virtual void dispatchFocusEvent(PassRefPtr<Element> oldFocusedElement, FocusDirection) OVERRIDE FINAL;
     118    virtual void dispatchBlurEvent(PassRefPtr<Element> newFocusedElement) OVERRIDE FINAL;
    119119   
    120120    virtual bool canStartSelection() const { return false; }
  • trunk/Source/WebCore/html/HTMLTextFormControlElement.cpp

    r150796 r150801  
    8686}
    8787
    88 void HTMLTextFormControlElement::dispatchFocusEvent(PassRefPtr<Node> oldFocusedNode, FocusDirection direction)
     88void HTMLTextFormControlElement::dispatchFocusEvent(PassRefPtr<Element> oldFocusedElement, FocusDirection direction)
    8989{
    9090    if (supportsPlaceholder())
    9191        updatePlaceholderVisibility(false);
    92     handleFocusEvent(oldFocusedNode.get(), direction);
    93     HTMLFormControlElementWithState::dispatchFocusEvent(oldFocusedNode, direction);
    94 }
    95 
    96 void HTMLTextFormControlElement::dispatchBlurEvent(PassRefPtr<Node> newFocusedNode)
     92    handleFocusEvent(oldFocusedElement.get(), direction);
     93    HTMLFormControlElementWithState::dispatchFocusEvent(oldFocusedElement, direction);
     94}
     95
     96void HTMLTextFormControlElement::dispatchBlurEvent(PassRefPtr<Element> newFocusedElement)
    9797{
    9898    if (supportsPlaceholder())
    9999        updatePlaceholderVisibility(false);
    100100    handleBlurEvent();
    101     HTMLFormControlElementWithState::dispatchBlurEvent(newFocusedNode);
     101    HTMLFormControlElementWithState::dispatchBlurEvent(newFocusedElement);
    102102}
    103103
  • trunk/Source/WebCore/html/HTMLTextFormControlElement.h

    r150711 r150801  
    117117    TextFieldSelectionDirection computeSelectionDirection() const;
    118118
    119     virtual void dispatchFocusEvent(PassRefPtr<Node> oldFocusedNode, FocusDirection) OVERRIDE;
    120     virtual void dispatchBlurEvent(PassRefPtr<Node> newFocusedNode);
     119    virtual void dispatchFocusEvent(PassRefPtr<Element> oldFocusedElement, FocusDirection) OVERRIDE FINAL;
     120    virtual void dispatchBlurEvent(PassRefPtr<Element> newFocusedElement) OVERRIDE FINAL;
    121121    virtual bool childShouldCreateRenderer(const NodeRenderingContext&) const OVERRIDE;
    122122
Note: See TracChangeset for help on using the changeset viewer.