| 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 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 150 return; | 150 return; |
| 151 if (nodeToBeRemoved.isInShadowTree()) { | 151 if (nodeToBeRemoved.isInShadowTree()) { |
| 152 m_clickNode = nodeToBeRemoved.parentOrShadowHostNode(); | 152 m_clickNode = nodeToBeRemoved.parentOrShadowHostNode(); |
| 153 } else { | 153 } else { |
| 154 // We don't dispatch click events if the mousedown node is removed | 154 // We don't dispatch click events if the mousedown node is removed |
| 155 // before a mouseup event. It is compatible with IE and Firefox. | 155 // before a mouseup event. It is compatible with IE and Firefox. |
| 156 m_clickNode = nullptr; | 156 m_clickNode = nullptr; |
| 157 } | 157 } |
| 158 } | 158 } |
| 159 | 159 |
| 160 void EventHandler::selectClosestWordFromHitTestResult(const HitTestResult& resul
t, AppendTrailingWhitespace appendTrailingWhitespace) | |
| 161 { | |
| 162 Node* innerNode = result.targetNode(); | |
| 163 VisibleSelection newSelection; | |
| 164 | |
| 165 if (innerNode && innerNode->renderer()) { | |
| 166 VisiblePosition pos(innerNode->renderer()->positionForPoint(result.local
Point())); | |
| 167 if (pos.isNotNull()) { | |
| 168 newSelection = VisibleSelection(pos); | |
| 169 newSelection.expandUsingGranularity(WordGranularity); | |
| 170 } | |
| 171 | |
| 172 if (appendTrailingWhitespace == ShouldAppendTrailingWhitespace && newSel
ection.isRange()) | |
| 173 newSelection.appendTrailingWhitespace(); | |
| 174 } | |
| 175 } | |
| 176 | |
| 177 void EventHandler::selectClosestMisspellingFromHitTestResult(const HitTestResult
& result, AppendTrailingWhitespace appendTrailingWhitespace) | |
| 178 { | |
| 179 Node* innerNode = result.targetNode(); | |
| 180 VisibleSelection newSelection; | |
| 181 | |
| 182 if (innerNode && innerNode->renderer()) { | |
| 183 VisiblePosition pos(innerNode->renderer()->positionForPoint(result.local
Point())); | |
| 184 Position start = pos.deepEquivalent(); | |
| 185 Position end = pos.deepEquivalent(); | |
| 186 if (pos.isNotNull()) { | |
| 187 DocumentMarkerVector markers = innerNode->document().markers().marke
rsInRange(makeRange(pos, pos).get(), DocumentMarker::MisspellingMarkers()); | |
| 188 if (markers.size() == 1) { | |
| 189 start.moveToOffset(markers[0]->startOffset()); | |
| 190 end.moveToOffset(markers[0]->endOffset()); | |
| 191 newSelection = VisibleSelection(start, end); | |
| 192 } | |
| 193 } | |
| 194 | |
| 195 if (appendTrailingWhitespace == ShouldAppendTrailingWhitespace && newSel
ection.isRange()) | |
| 196 newSelection.appendTrailingWhitespace(); | |
| 197 } | |
| 198 } | |
| 199 | |
| 200 HitTestResult EventHandler::hitTestResultAtPoint(const LayoutPoint& point, HitTe
stRequest::HitTestRequestType hitType, const LayoutSize& padding) | 160 HitTestResult EventHandler::hitTestResultAtPoint(const LayoutPoint& point, HitTe
stRequest::HitTestRequestType hitType, const LayoutSize& padding) |
| 201 { | 161 { |
| 202 TRACE_EVENT0("blink", "EventHandler::hitTestResultAtPoint"); | 162 TRACE_EVENT0("blink", "EventHandler::hitTestResultAtPoint"); |
| 203 | 163 |
| 204 HitTestResult result(point, padding.height(), padding.width(), padding.heigh
t(), padding.width()); | 164 HitTestResult result(point, padding.height(), padding.width(), padding.heigh
t(), padding.width()); |
| 205 | 165 |
| 206 // RenderView::hitTest causes a layout, and we don't want to hit that until
the first | 166 // RenderView::hitTest causes a layout, and we don't want to hit that until
the first |
| 207 // layout because until then, there is nothing shown on the screen - the use
r can't | 167 // layout because until then, there is nothing shown on the screen - the use
r can't |
| 208 // have intentionally clicked on something belonging to this page. Furthermo
re, | 168 // have intentionally clicked on something belonging to this page. Furthermo
re, |
| 209 // mousemove events before the first layout should not lead to a premature l
ayout() | 169 // mousemove events before the first layout should not lead to a premature l
ayout() |
| (...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 429 bool EventHandler::dragHysteresisExceeded(const FloatPoint& floatDragViewportLoc
ation) const | 389 bool EventHandler::dragHysteresisExceeded(const FloatPoint& floatDragViewportLoc
ation) const |
| 430 { | 390 { |
| 431 return dragHysteresisExceeded(flooredIntPoint(floatDragViewportLocation)); | 391 return dragHysteresisExceeded(flooredIntPoint(floatDragViewportLocation)); |
| 432 } | 392 } |
| 433 | 393 |
| 434 bool EventHandler::dragHysteresisExceeded(const IntPoint& dragViewportLocation)
const | 394 bool EventHandler::dragHysteresisExceeded(const IntPoint& dragViewportLocation)
const |
| 435 { | 395 { |
| 436 return false; | 396 return false; |
| 437 } | 397 } |
| 438 | 398 |
| 399 // TODO(abarth): This should just be targetForKeyboardEvent |
| 400 static Node* eventTargetNodeForDocument(Document* document) |
| 401 { |
| 402 if (Node* node = document->focusedElement()) |
| 403 return node; |
| 404 return document; |
| 405 } |
| 406 |
| 439 bool EventHandler::handleTextInputEvent(const String& text, Event* underlyingEve
nt, TextEventInputType inputType) | 407 bool EventHandler::handleTextInputEvent(const String& text, Event* underlyingEve
nt, TextEventInputType inputType) |
| 440 { | 408 { |
| 441 // Platforms should differentiate real commands like selectAll from text inp
ut in disguise (like insertNewline), | 409 // Platforms should differentiate real commands like selectAll from text inp
ut in disguise (like insertNewline), |
| 442 // and avoid dispatching text input events from keydown default handlers. | 410 // and avoid dispatching text input events from keydown default handlers. |
| 443 ASSERT(!underlyingEvent || !underlyingEvent->isKeyboardEvent() || toKeyboard
Event(underlyingEvent)->type() == EventTypeNames::keypress); | 411 ASSERT(!underlyingEvent || !underlyingEvent->isKeyboardEvent() || toKeyboard
Event(underlyingEvent)->type() == EventTypeNames::keypress); |
| 444 | 412 |
| 445 if (!m_frame) | 413 if (!m_frame) |
| 446 return false; | 414 return false; |
| 447 | 415 |
| 448 EventTarget* target; | 416 EventTarget* target; |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 523 | 491 |
| 524 void EventHandler::focusDocumentView() | 492 void EventHandler::focusDocumentView() |
| 525 { | 493 { |
| 526 Page* page = m_frame->page(); | 494 Page* page = m_frame->page(); |
| 527 if (!page) | 495 if (!page) |
| 528 return; | 496 return; |
| 529 page->focusController().focusDocumentView(m_frame); | 497 page->focusController().focusDocumentView(m_frame); |
| 530 } | 498 } |
| 531 | 499 |
| 532 } // namespace blink | 500 } // namespace blink |
| OLD | NEW |