| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All rights reserv
ed. | 2 * Copyright (C) 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All rights reserv
ed. |
| 3 * Copyright (C) 2006 Alexey Proskuryakov (ap@webkit.org) | 3 * Copyright (C) 2006 Alexey Proskuryakov (ap@webkit.org) |
| 4 * Copyright (C) 2012 Digia Plc. and/or its subsidiary(-ies) | 4 * Copyright (C) 2012 Digia Plc. and/or its subsidiary(-ies) |
| 5 * | 5 * |
| 6 * Redistribution and use in source and binary forms, with or without | 6 * Redistribution and use in source and binary forms, with or without |
| 7 * modification, are permitted provided that the following conditions | 7 * modification, are permitted provided that the following conditions |
| 8 * are met: | 8 * are met: |
| 9 * 1. Redistributions of source code must retain the above copyright | 9 * 1. Redistributions of source code must retain the above copyright |
| 10 * notice, this list of conditions and the following disclaimer. | 10 * notice, this list of conditions and the following disclaimer. |
| (...skipping 391 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 402 static int textDistance(const Position& start, const Position& end) | 402 static int textDistance(const Position& start, const Position& end) |
| 403 { | 403 { |
| 404 RefPtr<Range> range = Range::create(*start.document(), start, end); | 404 RefPtr<Range> range = Range::create(*start.document(), start, end); |
| 405 return TextIterator::rangeLength(range.get(), true); | 405 return TextIterator::rangeLength(range.get(), true); |
| 406 } | 406 } |
| 407 | 407 |
| 408 bool EventHandler::handleMousePressEventSingleClick(const MouseEventWithHitTestR
esults& event) | 408 bool EventHandler::handleMousePressEventSingleClick(const MouseEventWithHitTestR
esults& event) |
| 409 { | 409 { |
| 410 TRACE_EVENT0("blink", "EventHandler::handleMousePressEventSingleClick"); | 410 TRACE_EVENT0("blink", "EventHandler::handleMousePressEventSingleClick"); |
| 411 | 411 |
| 412 m_frame->document()->updateLayoutIgnorePendingStylesheets(); | 412 m_frame->document()->updateLayout(); |
| 413 Node* innerNode = event.targetNode(); | 413 Node* innerNode = event.targetNode(); |
| 414 if (!(innerNode && innerNode->renderer() && m_mouseDownMayStartSelect)) | 414 if (!(innerNode && innerNode->renderer() && m_mouseDownMayStartSelect)) |
| 415 return false; | 415 return false; |
| 416 | 416 |
| 417 // Extend the selection if the Shift key is down, unless the click is in a l
ink. | 417 // Extend the selection if the Shift key is down, unless the click is in a l
ink. |
| 418 bool extendSelection = event.event().shiftKey() && !event.isOverLink(); | 418 bool extendSelection = event.event().shiftKey() && !event.isOverLink(); |
| 419 | 419 |
| 420 // Don't restart the selection when the mouse is pressed on an | 420 // Don't restart the selection when the mouse is pressed on an |
| 421 // existing selection so we can allow for text dragging. | 421 // existing selection so we can allow for text dragging. |
| 422 LayoutPoint vPoint = event.event().position(); | 422 LayoutPoint vPoint = event.event().position(); |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 481 | 481 |
| 482 return true; | 482 return true; |
| 483 } | 483 } |
| 484 | 484 |
| 485 bool EventHandler::handleMousePressEvent(const MouseEventWithHitTestResults& eve
nt) | 485 bool EventHandler::handleMousePressEvent(const MouseEventWithHitTestResults& eve
nt) |
| 486 { | 486 { |
| 487 TRACE_EVENT0("blink", "EventHandler::handleMousePressEvent"); | 487 TRACE_EVENT0("blink", "EventHandler::handleMousePressEvent"); |
| 488 | 488 |
| 489 cancelFakeMouseMoveEvent(); | 489 cancelFakeMouseMoveEvent(); |
| 490 | 490 |
| 491 m_frame->document()->updateLayoutIgnorePendingStylesheets(); | 491 m_frame->document()->updateLayout(); |
| 492 | 492 |
| 493 bool singleClick = event.event().clickCount() <= 1; | 493 bool singleClick = event.event().clickCount() <= 1; |
| 494 | 494 |
| 495 // If we got the event back, that must mean it wasn't prevented, | 495 // If we got the event back, that must mean it wasn't prevented, |
| 496 // so it's allowed to start a drag or selection if it wasn't in a scrollbar. | 496 // so it's allowed to start a drag or selection if it wasn't in a scrollbar. |
| 497 m_mouseDownMayStartSelect = canMouseDownStartSelect(event.targetNode()) && !
event.scrollbar(); | 497 m_mouseDownMayStartSelect = canMouseDownStartSelect(event.targetNode()) && !
event.scrollbar(); |
| 498 | 498 |
| 499 m_mouseDownMayStartDrag = singleClick; | 499 m_mouseDownMayStartDrag = singleClick; |
| 500 | 500 |
| 501 m_mouseDownWasSingleClickInSelection = false; | 501 m_mouseDownWasSingleClickInSelection = false; |
| (...skipping 265 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 767 curBox = curBox->containingBlock(); | 767 curBox = curBox->containingBlock(); |
| 768 } | 768 } |
| 769 | 769 |
| 770 return false; | 770 return false; |
| 771 } | 771 } |
| 772 | 772 |
| 773 bool EventHandler::bubblingScroll(ScrollDirection direction, ScrollGranularity g
ranularity, Node* startingNode) | 773 bool EventHandler::bubblingScroll(ScrollDirection direction, ScrollGranularity g
ranularity, Node* startingNode) |
| 774 { | 774 { |
| 775 // The layout needs to be up to date to determine if we can scroll. We may b
e | 775 // The layout needs to be up to date to determine if we can scroll. We may b
e |
| 776 // here because of an onLoad event, in which case the final layout hasn't be
en performed yet. | 776 // here because of an onLoad event, in which case the final layout hasn't be
en performed yet. |
| 777 m_frame->document()->updateLayoutIgnorePendingStylesheets(); | 777 m_frame->document()->updateLayout(); |
| 778 if (scroll(direction, granularity, startingNode)) | 778 if (scroll(direction, granularity, startingNode)) |
| 779 return true; | 779 return true; |
| 780 return false; | 780 return false; |
| 781 } | 781 } |
| 782 | 782 |
| 783 IntPoint EventHandler::lastKnownMousePosition() const | 783 IntPoint EventHandler::lastKnownMousePosition() const |
| 784 { | 784 { |
| 785 return m_lastKnownMousePosition; | 785 return m_lastKnownMousePosition; |
| 786 } | 786 } |
| 787 | 787 |
| (...skipping 559 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1347 bool EventHandler::dispatchMouseEvent(const AtomicString& eventType, Node* targe
tNode, int clickCount, const PlatformMouseEvent& mouseEvent, bool setUnder) | 1347 bool EventHandler::dispatchMouseEvent(const AtomicString& eventType, Node* targe
tNode, int clickCount, const PlatformMouseEvent& mouseEvent, bool setUnder) |
| 1348 { | 1348 { |
| 1349 updateMouseEventTargetNode(targetNode, mouseEvent, setUnder); | 1349 updateMouseEventTargetNode(targetNode, mouseEvent, setUnder); |
| 1350 return !m_nodeUnderMouse || m_nodeUnderMouse->dispatchMouseEvent(mouseEvent,
eventType, clickCount); | 1350 return !m_nodeUnderMouse || m_nodeUnderMouse->dispatchMouseEvent(mouseEvent,
eventType, clickCount); |
| 1351 } | 1351 } |
| 1352 | 1352 |
| 1353 // The return value means 'swallow event' (was handled), as for other handle* fu
nctions. | 1353 // The return value means 'swallow event' (was handled), as for other handle* fu
nctions. |
| 1354 bool EventHandler::handleMouseFocus(const PlatformMouseEvent& mouseEvent) | 1354 bool EventHandler::handleMouseFocus(const PlatformMouseEvent& mouseEvent) |
| 1355 { | 1355 { |
| 1356 // The layout needs to be up to date to determine if an element is focusable
. | 1356 // The layout needs to be up to date to determine if an element is focusable
. |
| 1357 m_frame->document()->updateLayoutIgnorePendingStylesheets(); | 1357 m_frame->document()->updateLayout(); |
| 1358 | 1358 |
| 1359 Element* element = 0; | 1359 Element* element = 0; |
| 1360 if (m_nodeUnderMouse) | 1360 if (m_nodeUnderMouse) |
| 1361 element = m_nodeUnderMouse->isElementNode() ? toElement(m_nodeUnderMouse
) : m_nodeUnderMouse->parentOrShadowHostElement(); | 1361 element = m_nodeUnderMouse->isElementNode() ? toElement(m_nodeUnderMouse
) : m_nodeUnderMouse->parentOrShadowHostElement(); |
| 1362 for (; element; element = element->parentOrShadowHostElement()) { | 1362 for (; element; element = element->parentOrShadowHostElement()) { |
| 1363 if (element->isFocusable() && element->focused()) | 1363 if (element->isFocusable() && element->focused()) |
| 1364 return false; | 1364 return false; |
| 1365 if (element->isMouseFocusable()) | 1365 if (element->isMouseFocusable()) |
| 1366 break; | 1366 break; |
| 1367 } | 1367 } |
| (...skipping 1243 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2611 unsigned EventHandler::accessKeyModifiers() | 2611 unsigned EventHandler::accessKeyModifiers() |
| 2612 { | 2612 { |
| 2613 #if OS(MACOSX) | 2613 #if OS(MACOSX) |
| 2614 return PlatformEvent::CtrlKey | PlatformEvent::AltKey; | 2614 return PlatformEvent::CtrlKey | PlatformEvent::AltKey; |
| 2615 #else | 2615 #else |
| 2616 return PlatformEvent::AltKey; | 2616 return PlatformEvent::AltKey; |
| 2617 #endif | 2617 #endif |
| 2618 } | 2618 } |
| 2619 | 2619 |
| 2620 } // namespace blink | 2620 } // namespace blink |
| OLD | NEW |