Changeset 145514 in webkit
- Timestamp:
- Mar 12, 2013 4:13:02 AM (11 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r145511 r145514 1 2013-03-12 Matt Falkenhagen <falken@chromium.org> 2 3 Refactoring: Pull Node::disabled() and Node::isInert() down to Element. 4 https://bugs.webkit.org/show_bug.cgi?id=112085 5 6 Reviewed by Hajime Morrita. 7 8 Node is too low a level for these methods. 9 10 No new tests, just refactoring. 11 12 * dom/Element.cpp: 13 (WebCore::Element::disabled): 14 (WebCore): 15 (WebCore::Element::isInert): 16 * dom/Element.h: 17 (Element): 18 * dom/EventDispatcher.cpp: 19 (WebCore::EventDispatcher::dispatchSimulatedClick): 20 * dom/GestureEvent.cpp: 21 (WebCore::GestureEventDispatchMediator::dispatchEvent): 22 * dom/MouseEvent.cpp: 23 (WebCore::MouseEventDispatchMediator::dispatchEvent): 24 * dom/Node.cpp: 25 (WebCore::Node::handleLocalEvents): 26 (WebCore::Node::willRespondToMouseMoveEvents): 27 (WebCore::Node::willRespondToMouseClickEvents): 28 (WebCore::Node::willRespondToTouchEvents): 29 * dom/Node.h: 30 (Node): 31 1 32 2013-03-12 Marja Hölttä <marja@chromium.org> 2 33 -
trunk/Source/WebCore/dom/Element.cpp
r145377 r145514 1153 1153 } 1154 1154 1155 bool Element::disabled() const 1156 { 1157 #if ENABLE(DIALOG_ELEMENT) 1158 // FIXME: disabled and inert are separate concepts in the spec, but now we treat them as the same. 1159 // For example, an inert, non-disabled form control should not be grayed out. 1160 if (isInert()) 1161 return true; 1162 #endif 1163 return false; 1164 } 1165 1166 #if ENABLE(DIALOG_ELEMENT) 1167 bool Element::isInert() const 1168 { 1169 Element* dialog = document()->activeModalDialog(); 1170 return dialog && !containsIncludingShadowDOM(dialog) && !dialog->containsIncludingShadowDOM(this); 1171 } 1172 #endif 1173 1155 1174 Node::InsertionNotificationRequest Element::insertedInto(ContainerNode* insertionPoint) 1156 1175 { -
trunk/Source/WebCore/dom/Element.h
r145036 r145514 547 547 virtual void dispatchFormControlChangeEvent() { } 548 548 549 // Used for disabled form elements; if true, prevents mouse events from being dispatched 550 // to event listeners, and prevents DOMActivate events from being sent at all. 551 virtual bool disabled() const; 552 553 #if ENABLE(DIALOG_ELEMENT) 554 bool isInert() const; 555 #endif 556 549 557 #if ENABLE(SVG) 550 558 virtual bool childShouldCreateRenderer(const NodeRenderingContext&) const; -
trunk/Source/WebCore/dom/EventDispatcher.cpp
r143426 r145514 80 80 void EventDispatcher::dispatchSimulatedClick(Node* node, Event* underlyingEvent, SimulatedClickMouseEventOptions mouseEventOptions, SimulatedClickVisualOptions visualOptions) 81 81 { 82 if (node-> disabled())82 if (node->isElementNode() && toElement(node)->disabled()) 83 83 return; 84 84 -
trunk/Source/WebCore/dom/GestureEvent.cpp
r143303 r145514 30 30 #include "GestureEvent.h" 31 31 32 #include "Element.h" 32 33 #include <wtf/text/AtomicString.h> 33 34 … … 120 121 bool GestureEventDispatchMediator::dispatchEvent(EventDispatcher* dispatcher) const 121 122 { 122 if (dispatcher->node()-> disabled())123 if (dispatcher->node()->isElementNode() && toElement(dispatcher->node())->disabled()) 123 124 return true; 124 125 -
trunk/Source/WebCore/dom/MouseEvent.cpp
r144553 r145514 301 301 } 302 302 303 if (dispatcher->node()-> disabled()) // Don't even send DOM events for disabled controls..303 if (dispatcher->node()->isElementNode() && toElement(dispatcher->node())->disabled()) // Don't even send DOM events for disabled controls.. 304 304 return false; 305 305 -
trunk/Source/WebCore/dom/Node.cpp
r145340 r145514 903 903 } 904 904 905 #if ENABLE(DIALOG_ELEMENT)906 bool Node::isInert() const907 {908 Element* dialog = document()->activeModalDialog();909 return dialog && !containsIncludingShadowDOM(dialog) && !dialog->containsIncludingShadowDOM(this);910 }911 #endif912 913 905 unsigned Node::nodeIndex() const 914 906 { … … 2313 2305 return; 2314 2306 2315 if ( disabled() && event->isMouseEvent())2307 if (isElementNode() && toElement(this)->disabled() && event->isMouseEvent()) 2316 2308 return; 2317 2309 … … 2451 2443 { 2452 2444 dispatchScopedEvent(Event::create(eventNames().inputEvent, true, false)); 2453 }2454 2455 bool Node::disabled() const2456 {2457 #if ENABLE(DIALOG_ELEMENT)2458 if (isInert())2459 return true;2460 #endif2461 return false;2462 2445 } 2463 2446 … … 2521 2504 bool Node::willRespondToMouseMoveEvents() 2522 2505 { 2523 if ( disabled())2506 if (isElementNode() && toElement(this)->disabled()) 2524 2507 return false; 2525 2508 return hasEventListeners(eventNames().mousemoveEvent) || hasEventListeners(eventNames().mouseoverEvent) || hasEventListeners(eventNames().mouseoutEvent); … … 2528 2511 bool Node::willRespondToMouseClickEvents() 2529 2512 { 2530 if ( disabled())2513 if (isElementNode() && toElement(this)->disabled()) 2531 2514 return false; 2532 2515 return isContentEditable(UserSelectAllIsAlwaysNonEditable) || hasEventListeners(eventNames().mouseupEvent) || hasEventListeners(eventNames().mousedownEvent) || hasEventListeners(eventNames().clickEvent) || hasEventListeners(eventNames().DOMActivateEvent); … … 2536 2519 { 2537 2520 #if ENABLE(TOUCH_EVENTS) 2538 if ( disabled())2521 if (isElementNode() && toElement(this)->disabled()) 2539 2522 return false; 2540 2523 return hasEventListeners(eventNames().touchstartEvent) || hasEventListeners(eventNames().touchmoveEvent) || hasEventListeners(eventNames().touchcancelEvent) || hasEventListeners(eventNames().touchendEvent); -
trunk/Source/WebCore/dom/Node.h
r145340 r145514 415 415 virtual Node* focusDelegate(); 416 416 417 #if ENABLE(DIALOG_ELEMENT)418 bool isInert() const;419 #endif420 421 417 enum UserSelectAllTreatment { 422 418 UserSelectAllDoesNotAffectEditability, … … 664 660 virtual void defaultEventHandler(Event*); 665 661 666 // Used for disabled form elements; if true, prevents mouse events from being dispatched667 // to event listeners, and prevents DOMActivate events from being sent at all.668 virtual bool disabled() const;669 670 662 using TreeShared<Node>::ref; 671 663 using TreeShared<Node>::deref;
Note: See TracChangeset
for help on using the changeset viewer.