Changeset 93276 in webkit
- Timestamp:
- Aug 17, 2011 7:41:10 PM (13 years ago)
- Location:
- trunk
- Files:
-
- 16 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r93275 r93276 1 2011-08-17 Hayato Ito <hayato@chromium.org> 2 3 Implement proper handling of focus/blur events in regard to shadow DOM boundaries. 4 https://bugs.webkit.org/show_bug.cgi?id=61421 5 6 Reviewed by Dimitri Glazkov. 7 8 Introduces FocusEventDispatchMediator/BlurEventDispatchMediator so 9 that focus/blue events are stopped at the lowest common shadow boundary. 10 11 * fast/dom/shadow/shadow-boundary-events.html: 12 1 13 2011-08-17 Ben Wells <benwells@chromium.org> 2 14 -
trunk/LayoutTests/fast/dom/shadow/shadow-boundary-events-expected.txt
r93038 r93276 69 69 PASS dispatchedEvent("focusin") is ["divL(@divL)", "shadowK(@shadowK)", "shadowK(@divJ)"] 70 70 PASS dispatchedEvent("focusout") is ["divH(@divH)", "shadowG(@shadowG)", "shadowF(@shadowF)", "shadowF(@divE)"] 71 72 Move focus from a node to its sibling node. All nodes are outside of shadow boundary. 73 Moving focus from divB to divC 74 PASS dispatchedEvent("focus") is ["divC(@divA)(capturing phase)", "divC(@divC)"] 75 PASS dispatchedEvent("blur") is ["divB(@divA)(capturing phase)", "divB(@divB)"] 76 77 Old focused node and new focused node exist in separated subtrees, crossing shadow boundaries. Making sure that an event is not dispatched beyond the lowest common boundary. 78 Moving focus from shadowD/shadowF/shadowG/divH to shadowD/shadowK/divL 79 PASS dispatchedEvent("focus") is ["shadowK(@divJ)(capturing phase)", "shadowK(@shadowK)(capturing phase)", "divL(@divL)"] 80 PASS dispatchedEvent("blur") is ["shadowF(@divE)(capturing phase)", "shadowF(@shadowF)(capturing phase)", "shadowG(@shadowG)(capturing phase)", "divH(@divH)"] 71 81 PASS successfullyParsed is true 72 82 -
trunk/LayoutTests/fast/dom/shadow/shadow-boundary-events.html
r93038 r93276 58 58 if (event.currentTarget) 59 59 eventString += '(@' + event.currentTarget.id + ')'; 60 if (event.eventPhase == 1) 61 eventString += '(capturing phase)'; 60 62 eventRecords[eventType].push(eventString); 61 63 } … … 98 100 element.addEventListener('focusin', recordEvent, false); 99 101 element.addEventListener('focusout', recordEvent, false); 102 element.addEventListener('focus', recordEvent, true); // capturing phase 103 element.addEventListener('blur', recordEvent, true); // capturing phase 100 104 } 101 105 } … … 192 196 // Omitted test cases where either a oldFocusedNode or newFocusedNode is an ancestor of the other. 193 197 // Due to a focus transfer mechanism on shadow hosts, a focused node should be a leaf node in general. 198 199 // Test for focus/blur events. Event listners should be registerd on captureing phase. 200 moveFocus('divB', 'divC', 201 'Move focus from a node to its sibling node. All nodes are outside of shadow boundary.'); 202 shouldBe('dispatchedEvent("focus")', '["divC(@divA)(capturing phase)", "divC(@divC)"]'); 203 shouldBe('dispatchedEvent("blur")', '["divB(@divA)(capturing phase)", "divB(@divB)"]'); 204 205 moveFocus('shadowD/shadowF/shadowG/divH', 'shadowD/shadowK/divL', 206 'Old focused node and new focused node exist in separated subtrees, crossing shadow boundaries. Making sure that an event is not dispatched beyond the lowest common boundary.'); 207 shouldBe('dispatchedEvent("focus")', '["shadowK(@divJ)(capturing phase)", "shadowK(@shadowK)(capturing phase)", "divL(@divL)"]'); 208 shouldBe('dispatchedEvent("blur")', '["shadowF(@divE)(capturing phase)", "shadowF(@shadowF)(capturing phase)", "shadowG(@shadowG)(capturing phase)", "divH(@divH)"]'); 194 209 } 195 210 -
trunk/Source/WebCore/ChangeLog
r93275 r93276 1 2011-08-17 Hayato Ito <hayato@chromium.org> 2 3 Implement proper handling of focus/blur events in regard to shadow DOM boundaries. 4 https://bugs.webkit.org/show_bug.cgi?id=61421 5 6 Reviewed by Dimitri Glazkov. 7 8 Introduces FocusEventDispatchMediator/BlurEventDispatchMediator so 9 that focus/blue events are stopped at the lowest common shadow boundary. 10 11 * dom/Document.cpp: 12 (WebCore::Document::setFocusedNode): 13 * dom/Event.cpp: 14 (WebCore::FocusEventDispatchMediator::create): 15 (WebCore::FocusEventDispatchMediator::FocusEventDispatchMediator): 16 (WebCore::FocusEventDispatchMediator::dispatchEvent): 17 (WebCore::BlurEventDispatchMediator::create): 18 (WebCore::BlurEventDispatchMediator::BlurEventDispatchMediator): 19 (WebCore::BlurEventDispatchMediator::dispatchEvent): 20 * dom/Event.h: 21 * dom/Node.cpp: 22 (WebCore::Node::dispatchFocusEvent): 23 (WebCore::Node::dispatchBlurEvent): 24 * dom/Node.h: 25 * html/HTMLFormControlElement.cpp: 26 (WebCore::HTMLFormControlElement::dispatchBlurEvent): 27 * html/HTMLFormControlElement.h: 28 * html/HTMLSelectElement.cpp: 29 (WebCore::HTMLSelectElement::dispatchFocusEvent): 30 (WebCore::HTMLSelectElement::dispatchBlurEvent): 31 * html/HTMLSelectElement.h: 32 * html/HTMLTextFormControlElement.cpp: 33 (WebCore::HTMLTextFormControlElement::dispatchFocusEvent): 34 (WebCore::HTMLTextFormControlElement::dispatchBlurEvent): 35 * html/HTMLTextFormControlElement.h: 36 * page/FocusController.cpp: 37 (WebCore::dispatchEventsOnWindowAndFocusedNode): 38 1 39 2011-08-17 Ben Wells <benwells@chromium.org> 2 40 -
trunk/Source/WebCore/dom/Document.cpp
r93269 r93276 3126 3126 3127 3127 // Dispatch the blur event and let the node do any other blur related activities (important for text fields) 3128 oldFocusedNode->dispatchBlurEvent( );3128 oldFocusedNode->dispatchBlurEvent(newFocusedNode); 3129 3129 3130 3130 if (m_focusedNode) { … … 3170 3170 3171 3171 // Dispatch the focus event and let the node do any other focus related activities (important for text fields) 3172 m_focusedNode->dispatchFocusEvent( );3172 m_focusedNode->dispatchFocusEvent(oldFocusedNode); 3173 3173 3174 3174 if (m_focusedNode != newFocusedNode) { -
trunk/Source/WebCore/dom/Event.cpp
r92365 r93276 309 309 } 310 310 311 PassRefPtr<FocusEventDispatchMediator> FocusEventDispatchMediator::create(PassRefPtr<Node> oldFocusedNode) 312 { 313 return adoptRef(new FocusEventDispatchMediator(oldFocusedNode)); 314 } 315 316 FocusEventDispatchMediator::FocusEventDispatchMediator(PassRefPtr<Node> oldFocusedNode) 317 : EventDispatchMediator(Event::create(eventNames().focusEvent, false, false)) 318 , m_oldFocusedNode(oldFocusedNode) 319 { 320 } 321 322 bool FocusEventDispatchMediator::dispatchEvent(EventDispatcher* dispatcher) const 323 { 324 dispatcher->adjustRelatedTarget(event(), m_oldFocusedNode); 325 return EventDispatchMediator::dispatchEvent(dispatcher); 326 } 327 328 PassRefPtr<BlurEventDispatchMediator> BlurEventDispatchMediator::create(PassRefPtr<Node> newFocusedNode) 329 { 330 return adoptRef(new BlurEventDispatchMediator(newFocusedNode)); 331 } 332 333 BlurEventDispatchMediator::BlurEventDispatchMediator(PassRefPtr<Node> newFocusedNode) 334 : EventDispatchMediator(Event::create(eventNames().blurEvent, false, false)) 335 , m_newFocusedNode(newFocusedNode) 336 { 337 } 338 339 bool BlurEventDispatchMediator::dispatchEvent(EventDispatcher* dispatcher) const 340 { 341 dispatcher->adjustRelatedTarget(event(), m_newFocusedNode); 342 return EventDispatchMediator::dispatchEvent(dispatcher); 343 } 344 345 311 346 } // namespace WebCore -
trunk/Source/WebCore/dom/Event.h
r92450 r93276 231 231 } 232 232 233 class FocusEventDispatchMediator : public EventDispatchMediator { 234 public: 235 static PassRefPtr<FocusEventDispatchMediator> create(PassRefPtr<Node> oldFocusedNode); 236 private: 237 explicit FocusEventDispatchMediator(PassRefPtr<Node> oldFocusedNode); 238 virtual bool dispatchEvent(EventDispatcher*) const; 239 RefPtr<Node> m_oldFocusedNode; 240 }; 241 242 class BlurEventDispatchMediator : public EventDispatchMediator { 243 public: 244 static PassRefPtr<BlurEventDispatchMediator> create(PassRefPtr<Node> newFocusedNode); 245 private: 246 explicit BlurEventDispatchMediator(PassRefPtr<Node> newFocusedNode); 247 virtual bool dispatchEvent(EventDispatcher*) const; 248 RefPtr<Node> m_newFocusedNode; 249 }; 250 233 251 } // namespace WebCore 234 252 -
trunk/Source/WebCore/dom/Node.cpp
r93071 r93276 2778 2778 } 2779 2779 2780 void Node::dispatchFocusEvent( )2780 void Node::dispatchFocusEvent(PassRefPtr<Node> oldFocusedNode) 2781 2781 { 2782 2782 if (document()->page()) 2783 2783 document()->page()->chrome()->client()->elementDidFocus(this); 2784 2784 2785 dispatchEvent(Event::create(eventNames().focusEvent, false, false));2785 EventDispatcher::dispatchEvent(this, FocusEventDispatchMediator::create(oldFocusedNode)); 2786 2786 } 2787 2787 … … 2790 2790 } 2791 2791 2792 void Node::dispatchBlurEvent( )2792 void Node::dispatchBlurEvent(PassRefPtr<Node> newFocusedNode) 2793 2793 { 2794 2794 if (document()->page()) 2795 2795 document()->page()->chrome()->client()->elementDidBlur(this); 2796 2797 dispatchEvent(Event::create(eventNames().blurEvent, false, false));2796 2797 EventDispatcher::dispatchEvent(this, BlurEventDispatchMediator::create(newFocusedNode)); 2798 2798 } 2799 2799 -
trunk/Source/WebCore/dom/Node.h
r93071 r93276 563 563 void dispatchSimulatedClick(PassRefPtr<Event> underlyingEvent, bool sendMouseEvents = false, bool showPressedLook = true); 564 564 565 virtual void dispatchFocusEvent( );565 virtual void dispatchFocusEvent(PassRefPtr<Node> oldFocusedNode); 566 566 virtual void willBlur(); 567 virtual void dispatchBlurEvent( );567 virtual void dispatchBlurEvent(PassRefPtr<Node> newFocusedNode); 568 568 virtual void dispatchChangeEvent(); 569 569 virtual void dispatchInputEvent(); -
trunk/Source/WebCore/html/HTMLFormControlElement.cpp
r90849 r93276 431 431 } 432 432 433 void HTMLFormControlElement::dispatchBlurEvent( )434 { 435 HTMLElement::dispatchBlurEvent( );433 void HTMLFormControlElement::dispatchBlurEvent(PassRefPtr<Node> newFocusedNode) 434 { 435 HTMLElement::dispatchBlurEvent(newFocusedNode); 436 436 hideVisibleValidationMessage(); 437 437 } -
trunk/Source/WebCore/html/HTMLFormControlElement.h
r90849 r93276 122 122 virtual void recalcStyle(StyleChange); 123 123 124 virtual void dispatchBlurEvent( );124 virtual void dispatchBlurEvent(PassRefPtr<Node> newFocusedNode); 125 125 virtual void detach(); 126 126 -
trunk/Source/WebCore/html/HTMLSelectElement.cpp
r89332 r93276 368 368 } 369 369 370 void HTMLSelectElement::dispatchFocusEvent( )370 void HTMLSelectElement::dispatchFocusEvent(PassRefPtr<Node> oldFocusedNode) 371 371 { 372 372 SelectElement::dispatchFocusEvent(m_data, this); 373 HTMLFormControlElementWithState::dispatchFocusEvent( );374 } 375 376 void HTMLSelectElement::dispatchBlurEvent( )373 HTMLFormControlElementWithState::dispatchFocusEvent(oldFocusedNode); 374 } 375 376 void HTMLSelectElement::dispatchBlurEvent(PassRefPtr<Node> newFocusedNode) 377 377 { 378 378 SelectElement::dispatchBlurEvent(m_data, this); 379 HTMLFormControlElementWithState::dispatchBlurEvent( );379 HTMLFormControlElementWithState::dispatchBlurEvent(newFocusedNode); 380 380 } 381 381 -
trunk/Source/WebCore/html/HTMLSelectElement.h
r86135 r93276 104 104 virtual void recalcStyle(StyleChange); 105 105 106 virtual void dispatchFocusEvent( );107 virtual void dispatchBlurEvent( );106 virtual void dispatchFocusEvent(PassRefPtr<Node> oldFocusedNode); 107 virtual void dispatchBlurEvent(PassRefPtr<Node> newFocusedNode); 108 108 109 109 virtual bool canStartSelection() const { return false; } -
trunk/Source/WebCore/html/HTMLTextFormControlElement.cpp
r92088 r93276 65 65 } 66 66 67 void HTMLTextFormControlElement::dispatchFocusEvent( )67 void HTMLTextFormControlElement::dispatchFocusEvent(PassRefPtr<Node> oldFocusedNode) 68 68 { 69 69 if (supportsPlaceholder()) 70 70 updatePlaceholderVisibility(false); 71 71 handleFocusEvent(); 72 HTMLFormControlElementWithState::dispatchFocusEvent( );73 } 74 75 void HTMLTextFormControlElement::dispatchBlurEvent( )72 HTMLFormControlElementWithState::dispatchFocusEvent(oldFocusedNode); 73 } 74 75 void HTMLTextFormControlElement::dispatchBlurEvent(PassRefPtr<Node> newFocusedNode) 76 76 { 77 77 if (supportsPlaceholder()) 78 78 updatePlaceholderVisibility(false); 79 79 handleBlurEvent(); 80 HTMLFormControlElementWithState::dispatchBlurEvent( );80 HTMLFormControlElementWithState::dispatchBlurEvent(newFocusedNode); 81 81 } 82 82 -
trunk/Source/WebCore/html/HTMLTextFormControlElement.h
r92088 r93276 102 102 TextFieldSelectionDirection computeSelectionDirection() const; 103 103 104 virtual void dispatchFocusEvent( );105 virtual void dispatchBlurEvent( );104 virtual void dispatchFocusEvent(PassRefPtr<Node> oldFocusedNode); 105 virtual void dispatchBlurEvent(PassRefPtr<Node> newFocusedNode); 106 106 107 107 bool isPlaceholderEmpty() const; -
trunk/Source/WebCore/page/FocusController.cpp
r93270 r93276 78 78 79 79 if (!focused && document->focusedNode()) 80 document->focusedNode()->dispatchBlurEvent( );80 document->focusedNode()->dispatchBlurEvent(0); 81 81 document->dispatchWindowEvent(Event::create(focused ? eventNames().focusEvent : eventNames().blurEvent, false, false)); 82 82 if (focused && document->focusedNode()) 83 document->focusedNode()->dispatchFocusEvent( );83 document->focusedNode()->dispatchFocusEvent(0); 84 84 } 85 85
Note: See TracChangeset
for help on using the changeset viewer.