| 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 * Copyright (C) 2015 Google Inc. All rights reserved. | 5 * Copyright (C) 2015 Google Inc. All rights reserved. |
| 6 * | 6 * |
| 7 * Redistribution and use in source and binary forms, with or without | 7 * Redistribution and use in source and binary forms, with or without |
| 8 * modification, are permitted provided that the following conditions | 8 * modification, are permitted provided that the following conditions |
| 9 * are met: | 9 * are met: |
| 10 * 1. Redistributions of source code must retain the above copyright | 10 * 1. Redistributions of source code must retain the above copyright |
| (...skipping 260 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 271 // Don't restart the selection when the mouse is pressed on an | 271 // Don't restart the selection when the mouse is pressed on an |
| 272 // existing selection so we can allow for text dragging. | 272 // existing selection so we can allow for text dragging. |
| 273 if (FrameView* view = m_frame->view()) { | 273 if (FrameView* view = m_frame->view()) { |
| 274 LayoutPoint vPoint = view->rootFrameToContents(event.event().position())
; | 274 LayoutPoint vPoint = view->rootFrameToContents(event.event().position())
; |
| 275 if (!extendSelection && m_frame->selection().contains(vPoint)) { | 275 if (!extendSelection && m_frame->selection().contains(vPoint)) { |
| 276 m_mouseDownWasSingleClickInSelection = true; | 276 m_mouseDownWasSingleClickInSelection = true; |
| 277 return false; | 277 return false; |
| 278 } | 278 } |
| 279 } | 279 } |
| 280 | 280 |
| 281 VisiblePosition visiblePos(innerNode->layoutObject()->positionForPoint(event
.localPoint())); | 281 PositionWithAffinity eventPos = innerNode->layoutObject()->positionForPoint(
event.localPoint()); |
| 282 VisiblePosition visiblePos(Strategy::toPositionType(eventPos.position()), ev
entPos.affinity()); |
| 282 if (visiblePos.isNull()) | 283 if (visiblePos.isNull()) |
| 283 visiblePos = VisiblePosition(firstPositionInOrBeforeNode(innerNode), DOW
NSTREAM); | 284 visiblePos = VisiblePosition(firstPositionInOrBeforeNode(innerNode), DOW
NSTREAM); |
| 284 PositionType pos = Strategy::toPositionType(visiblePos.deepEquivalent()); | 285 PositionType pos = Strategy::toPositionType(visiblePos.deepEquivalent()); |
| 285 | 286 |
| 286 VisibleSelection newSelection = m_frame->selection().selection(); | 287 VisibleSelection newSelection = m_frame->selection().selection(); |
| 287 TextGranularity granularity = CharacterGranularity; | 288 TextGranularity granularity = CharacterGranularity; |
| 288 | 289 |
| 289 if (extendSelection && newSelection.isCaretOrRange()) { | 290 if (extendSelection && newSelection.isCaretOrRange()) { |
| 290 VisibleSelection selectionInUserSelectAll(expandSelectionToRespectUserSe
lectAll(innerNode, VisibleSelection(VisiblePosition(pos)))); | 291 VisibleSelection selectionInUserSelectAll(expandSelectionToRespectUserSe
lectAll(innerNode, VisibleSelection(VisiblePosition(pos)))); |
| 291 if (selectionInUserSelectAll.isRange()) { | 292 if (selectionInUserSelectAll.isRange()) { |
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 381 { | 382 { |
| 382 using PositionType = typename Strategy::PositionType; | 383 using PositionType = typename Strategy::PositionType; |
| 383 | 384 |
| 384 if (!m_mouseDownMayStartSelect) | 385 if (!m_mouseDownMayStartSelect) |
| 385 return; | 386 return; |
| 386 | 387 |
| 387 Node* target = hitTestResult.innerNode(); | 388 Node* target = hitTestResult.innerNode(); |
| 388 if (!target) | 389 if (!target) |
| 389 return; | 390 return; |
| 390 | 391 |
| 391 VisiblePosition targetPosition = m_frame->selection().selection().visiblePos
itionRespectingEditingBoundary(hitTestResult.localPoint(), target); | 392 PositionWithAffinity rawTargetPosition = m_frame->selection().selection().po
sitionRespectingEditingBoundary(hitTestResult.localPoint(), target); |
| 393 VisiblePosition targetPosition = VisiblePosition(Strategy::toPositionType(ra
wTargetPosition.position()), rawTargetPosition.affinity()); |
| 392 // Don't modify the selection if we're not on a node. | 394 // Don't modify the selection if we're not on a node. |
| 393 if (targetPosition.isNull()) | 395 if (targetPosition.isNull()) |
| 394 return; | 396 return; |
| 395 | 397 |
| 396 // Restart the selection if this is the first mouse move. This work is usual
ly | 398 // Restart the selection if this is the first mouse move. This work is usual
ly |
| 397 // done in handleMousePressEvent, but not if the mouse press was on an exist
ing selection. | 399 // done in handleMousePressEvent, but not if the mouse press was on an exist
ing selection. |
| 398 VisibleSelection newSelection = m_frame->selection().selection(); | 400 VisibleSelection newSelection = m_frame->selection().selection(); |
| 399 | 401 |
| 400 // Special case to limit selection to the containing block for SVG text. | 402 // Special case to limit selection to the containing block for SVG text. |
| 401 // FIXME: Isn't there a better non-SVG-specific way to do this? | 403 // FIXME: Isn't there a better non-SVG-specific way to do this? |
| (...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 589 { | 591 { |
| 590 return m_mouseDownMayStartSelect; | 592 return m_mouseDownMayStartSelect; |
| 591 } | 593 } |
| 592 | 594 |
| 593 bool SelectionController::mouseDownWasSingleClickInSelection() const | 595 bool SelectionController::mouseDownWasSingleClickInSelection() const |
| 594 { | 596 { |
| 595 return m_mouseDownWasSingleClickInSelection; | 597 return m_mouseDownWasSingleClickInSelection; |
| 596 } | 598 } |
| 597 | 599 |
| 598 } // namespace blink | 600 } // namespace blink |
| OLD | NEW |