| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) | 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) |
| 3 * (C) 1999 Antti Koivisto (koivisto@kde.org) | 3 * (C) 1999 Antti Koivisto (koivisto@kde.org) |
| 4 * (C) 2001 Dirk Mueller (mueller@kde.org) | 4 * (C) 2001 Dirk Mueller (mueller@kde.org) |
| 5 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All r
ights reserved. | 5 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All r
ights reserved. |
| 6 * Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies) | 6 * Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies) |
| 7 * Copyright (C) 2009 Torch Mobile Inc. All rights reserved. (http://www.torchmo
bile.com/) | 7 * Copyright (C) 2009 Torch Mobile Inc. All rights reserved. (http://www.torchmo
bile.com/) |
| 8 * | 8 * |
| 9 * This library is free software; you can redistribute it and/or | 9 * This library is free software; you can redistribute it and/or |
| 10 * modify it under the terms of the GNU Library General Public | 10 * modify it under the terms of the GNU Library General Public |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 54 #include "sky/engine/core/dom/shadow/ElementShadow.h" | 54 #include "sky/engine/core/dom/shadow/ElementShadow.h" |
| 55 #include "sky/engine/core/dom/shadow/InsertionPoint.h" | 55 #include "sky/engine/core/dom/shadow/InsertionPoint.h" |
| 56 #include "sky/engine/core/dom/shadow/ShadowRoot.h" | 56 #include "sky/engine/core/dom/shadow/ShadowRoot.h" |
| 57 #include "sky/engine/core/editing/htmlediting.h" | 57 #include "sky/engine/core/editing/htmlediting.h" |
| 58 #include "sky/engine/core/events/Event.h" | 58 #include "sky/engine/core/events/Event.h" |
| 59 #include "sky/engine/core/events/EventDispatchMediator.h" | 59 #include "sky/engine/core/events/EventDispatchMediator.h" |
| 60 #include "sky/engine/core/events/EventDispatcher.h" | 60 #include "sky/engine/core/events/EventDispatcher.h" |
| 61 #include "sky/engine/core/events/EventListener.h" | 61 #include "sky/engine/core/events/EventListener.h" |
| 62 #include "sky/engine/core/events/GestureEvent.h" | 62 #include "sky/engine/core/events/GestureEvent.h" |
| 63 #include "sky/engine/core/events/KeyboardEvent.h" | 63 #include "sky/engine/core/events/KeyboardEvent.h" |
| 64 #include "sky/engine/core/events/MouseEvent.h" | |
| 65 #include "sky/engine/core/events/TextEvent.h" | 64 #include "sky/engine/core/events/TextEvent.h" |
| 66 #include "sky/engine/core/events/TouchEvent.h" | 65 #include "sky/engine/core/events/TouchEvent.h" |
| 67 #include "sky/engine/core/events/UIEvent.h" | 66 #include "sky/engine/core/events/UIEvent.h" |
| 68 #include "sky/engine/core/events/WheelEvent.h" | |
| 69 #include "sky/engine/core/frame/LocalFrame.h" | 67 #include "sky/engine/core/frame/LocalFrame.h" |
| 70 #include "sky/engine/core/frame/Settings.h" | 68 #include "sky/engine/core/frame/Settings.h" |
| 71 #include "sky/engine/core/html/HTMLAnchorElement.h" | 69 #include "sky/engine/core/html/HTMLAnchorElement.h" |
| 72 #include "sky/engine/core/html/HTMLStyleElement.h" | 70 #include "sky/engine/core/html/HTMLStyleElement.h" |
| 73 #include "sky/engine/core/page/EventHandler.h" | 71 #include "sky/engine/core/page/EventHandler.h" |
| 74 #include "sky/engine/core/page/Page.h" | 72 #include "sky/engine/core/page/Page.h" |
| 75 #include "sky/engine/core/rendering/RenderBox.h" | 73 #include "sky/engine/core/rendering/RenderBox.h" |
| 76 #include "sky/engine/platform/EventDispatchForbiddenScope.h" | 74 #include "sky/engine/platform/EventDispatchForbiddenScope.h" |
| 77 #include "sky/engine/platform/Partitions.h" | 75 #include "sky/engine/platform/Partitions.h" |
| 78 #include "sky/engine/platform/TraceEvent.h" | 76 #include "sky/engine/platform/TraceEvent.h" |
| (...skipping 1369 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1448 dispatchScopedEventDispatchMediator(EventDispatchMediator::create(event)); | 1446 dispatchScopedEventDispatchMediator(EventDispatchMediator::create(event)); |
| 1449 } | 1447 } |
| 1450 | 1448 |
| 1451 void Node::dispatchScopedEventDispatchMediator(PassRefPtr<EventDispatchMediator>
eventDispatchMediator) | 1449 void Node::dispatchScopedEventDispatchMediator(PassRefPtr<EventDispatchMediator>
eventDispatchMediator) |
| 1452 { | 1450 { |
| 1453 EventDispatcher::dispatchScopedEvent(this, eventDispatchMediator); | 1451 EventDispatcher::dispatchScopedEvent(this, eventDispatchMediator); |
| 1454 } | 1452 } |
| 1455 | 1453 |
| 1456 bool Node::dispatchEvent(PassRefPtr<Event> event) | 1454 bool Node::dispatchEvent(PassRefPtr<Event> event) |
| 1457 { | 1455 { |
| 1458 if (event->isMouseEvent()) | |
| 1459 return EventDispatcher::dispatchEvent(this, MouseEventDispatchMediator::
create(static_pointer_cast<MouseEvent>(event), MouseEventDispatchMediator::Synth
eticMouseEvent)); | |
| 1460 if (event->isTouchEvent()) | 1456 if (event->isTouchEvent()) |
| 1461 return dispatchTouchEvent(static_pointer_cast<TouchEvent>(event)); | 1457 return dispatchTouchEvent(static_pointer_cast<TouchEvent>(event)); |
| 1462 return EventDispatcher::dispatchEvent(this, EventDispatchMediator::create(ev
ent)); | 1458 return EventDispatcher::dispatchEvent(this, EventDispatchMediator::create(ev
ent)); |
| 1463 } | 1459 } |
| 1464 | 1460 |
| 1465 bool Node::dispatchDOMActivateEvent(int detail, PassRefPtr<Event> underlyingEven
t) | 1461 bool Node::dispatchDOMActivateEvent(int detail, PassRefPtr<Event> underlyingEven
t) |
| 1466 { | 1462 { |
| 1467 ASSERT(!EventDispatchForbiddenScope::isEventDispatchForbidden()); | 1463 ASSERT(!EventDispatchForbiddenScope::isEventDispatchForbidden()); |
| 1468 RefPtr<UIEvent> event = UIEvent::create(EventTypeNames::DOMActivate, true, t
rue, document().domWindow(), detail); | 1464 RefPtr<UIEvent> event = UIEvent::create(EventTypeNames::DOMActivate, true, t
rue, document().domWindow(), detail); |
| 1469 event->setUnderlyingEvent(underlyingEvent); | 1465 event->setUnderlyingEvent(underlyingEvent); |
| 1470 dispatchScopedEvent(event); | 1466 dispatchScopedEvent(event); |
| 1471 return event->defaultHandled(); | 1467 return event->defaultHandled(); |
| 1472 } | 1468 } |
| 1473 | 1469 |
| 1474 bool Node::dispatchKeyEvent(const PlatformKeyboardEvent& event) | 1470 bool Node::dispatchKeyEvent(const PlatformKeyboardEvent& event) |
| 1475 { | 1471 { |
| 1476 return EventDispatcher::dispatchEvent(this, KeyboardEventDispatchMediator::c
reate(KeyboardEvent::create(event, document().domWindow()))); | 1472 return EventDispatcher::dispatchEvent(this, KeyboardEventDispatchMediator::c
reate(KeyboardEvent::create(event, document().domWindow()))); |
| 1477 } | 1473 } |
| 1478 | 1474 |
| 1479 bool Node::dispatchMouseEvent(const PlatformMouseEvent& event, const AtomicStrin
g& eventType, | |
| 1480 int detail, Node* relatedTarget) | |
| 1481 { | |
| 1482 return EventDispatcher::dispatchEvent(this, MouseEventDispatchMediator::crea
te(MouseEvent::create(eventType, document().domWindow(), event, detail, relatedT
arget))); | |
| 1483 } | |
| 1484 | |
| 1485 bool Node::dispatchGestureEvent(const PlatformGestureEvent& event) | 1475 bool Node::dispatchGestureEvent(const PlatformGestureEvent& event) |
| 1486 { | 1476 { |
| 1487 RefPtr<GestureEvent> gestureEvent = GestureEvent::create(document().domWindo
w(), event); | 1477 RefPtr<GestureEvent> gestureEvent = GestureEvent::create(document().domWindo
w(), event); |
| 1488 if (!gestureEvent) | 1478 if (!gestureEvent) |
| 1489 return false; | 1479 return false; |
| 1490 return EventDispatcher::dispatchEvent(this, GestureEventDispatchMediator::cr
eate(gestureEvent)); | 1480 return EventDispatcher::dispatchEvent(this, GestureEventDispatchMediator::cr
eate(gestureEvent)); |
| 1491 } | 1481 } |
| 1492 | 1482 |
| 1493 bool Node::dispatchTouchEvent(PassRefPtr<TouchEvent> event) | 1483 bool Node::dispatchTouchEvent(PassRefPtr<TouchEvent> event) |
| 1494 { | 1484 { |
| 1495 return EventDispatcher::dispatchEvent(this, TouchEventDispatchMediator::crea
te(event)); | 1485 return EventDispatcher::dispatchEvent(this, TouchEventDispatchMediator::crea
te(event)); |
| 1496 } | 1486 } |
| 1497 | 1487 |
| 1498 void Node::dispatchSimulatedClick(Event* underlyingEvent, SimulatedClickMouseEve
ntOptions eventOptions) | |
| 1499 { | |
| 1500 EventDispatcher::dispatchSimulatedClick(this, underlyingEvent, eventOptions)
; | |
| 1501 } | |
| 1502 | |
| 1503 bool Node::dispatchWheelEvent(const PlatformWheelEvent& event) | |
| 1504 { | |
| 1505 return EventDispatcher::dispatchEvent(this, WheelEventDispatchMediator::crea
te(event, document().domWindow())); | |
| 1506 } | |
| 1507 | |
| 1508 void Node::dispatchInputEvent() | 1488 void Node::dispatchInputEvent() |
| 1509 { | 1489 { |
| 1510 dispatchScopedEvent(Event::createBubble(EventTypeNames::input)); | 1490 dispatchScopedEvent(Event::createBubble(EventTypeNames::input)); |
| 1511 } | 1491 } |
| 1512 | 1492 |
| 1513 void Node::defaultEventHandler(Event* event) | 1493 void Node::defaultEventHandler(Event* event) |
| 1514 { | 1494 { |
| 1515 if (event->target() != this) | 1495 if (event->target() != this) |
| 1516 return; | 1496 return; |
| 1517 const AtomicString& eventType = event->type(); | 1497 const AtomicString& eventType = event->type(); |
| 1518 if (eventType == EventTypeNames::keydown || eventType == EventTypeNames::key
press) { | 1498 if (eventType == EventTypeNames::keydown || eventType == EventTypeNames::key
press) { |
| 1519 if (event->isKeyboardEvent()) { | 1499 if (event->isKeyboardEvent()) { |
| 1520 if (LocalFrame* frame = document().frame()) | 1500 if (LocalFrame* frame = document().frame()) |
| 1521 frame->eventHandler().defaultKeyboardEventHandler(toKeyboardEven
t(event)); | 1501 frame->eventHandler().defaultKeyboardEventHandler(toKeyboardEven
t(event)); |
| 1522 } | 1502 } |
| 1523 } else if (eventType == EventTypeNames::click) { | 1503 } else if (eventType == EventTypeNames::click) { |
| 1524 int detail = event->isUIEvent() ? static_cast<UIEvent*>(event)->detail()
: 0; | 1504 int detail = event->isUIEvent() ? static_cast<UIEvent*>(event)->detail()
: 0; |
| 1525 if (dispatchDOMActivateEvent(detail, event)) | 1505 if (dispatchDOMActivateEvent(detail, event)) |
| 1526 event->setDefaultHandled(); | 1506 event->setDefaultHandled(); |
| 1527 } else if (eventType == EventTypeNames::textInput) { | 1507 } else if (eventType == EventTypeNames::textInput) { |
| 1528 if (event->hasInterface(EventNames::TextEvent)) { | 1508 if (event->hasInterface(EventNames::TextEvent)) { |
| 1529 if (LocalFrame* frame = document().frame()) | 1509 if (LocalFrame* frame = document().frame()) |
| 1530 frame->eventHandler().defaultTextInputEventHandler(toTextEvent(e
vent)); | 1510 frame->eventHandler().defaultTextInputEventHandler(toTextEvent(e
vent)); |
| 1531 } | 1511 } |
| 1532 } else if ((eventType == EventTypeNames::wheel || eventType == EventTypeName
s::mousewheel) && event->hasInterface(EventNames::WheelEvent)) { | |
| 1533 WheelEvent* wheelEvent = toWheelEvent(event); | |
| 1534 | |
| 1535 // If we don't have a renderer, send the wheel event to the first node w
e find with a renderer. | |
| 1536 // This is needed for <option> and <optgroup> elements so that <select>s
get a wheel scroll. | |
| 1537 Node* startNode = this; | |
| 1538 while (startNode && !startNode->renderer()) | |
| 1539 startNode = startNode->parentOrShadowHostNode(); | |
| 1540 | |
| 1541 if (startNode && startNode->renderer()) { | |
| 1542 if (LocalFrame* frame = document().frame()) | |
| 1543 frame->eventHandler().defaultWheelEventHandler(startNode, wheelE
vent); | |
| 1544 } | |
| 1545 } else if (event->type() == EventTypeNames::webkitEditableContentChanged) { | 1512 } else if (event->type() == EventTypeNames::webkitEditableContentChanged) { |
| 1546 dispatchInputEvent(); | 1513 dispatchInputEvent(); |
| 1547 } | 1514 } |
| 1548 } | 1515 } |
| 1549 | 1516 |
| 1550 bool Node::willRespondToMouseMoveEvents() | 1517 bool Node::willRespondToMouseMoveEvents() |
| 1551 { | 1518 { |
| 1552 return hasEventListeners(EventTypeNames::mousemove) || hasEventListeners(Eve
ntTypeNames::mouseover) || hasEventListeners(EventTypeNames::mouseout); | 1519 return hasEventListeners(EventTypeNames::mousemove) || hasEventListeners(Eve
ntTypeNames::mouseover) || hasEventListeners(EventTypeNames::mouseout); |
| 1553 } | 1520 } |
| 1554 | 1521 |
| (...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1726 node->showTreeForThis(); | 1693 node->showTreeForThis(); |
| 1727 } | 1694 } |
| 1728 | 1695 |
| 1729 void showNodePath(const blink::Node* node) | 1696 void showNodePath(const blink::Node* node) |
| 1730 { | 1697 { |
| 1731 if (node) | 1698 if (node) |
| 1732 node->showNodePathForThis(); | 1699 node->showNodePathForThis(); |
| 1733 } | 1700 } |
| 1734 | 1701 |
| 1735 #endif | 1702 #endif |
| OLD | NEW |