| 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 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 148 // existing selection so we can allow for text dragging. | 148 // existing selection so we can allow for text dragging. |
| 149 if (FrameView* view = m_frame->view()) { | 149 if (FrameView* view = m_frame->view()) { |
| 150 LayoutPoint vPoint = view->rootFrameToContents(event.event().position())
; | 150 LayoutPoint vPoint = view->rootFrameToContents(event.event().position())
; |
| 151 if (!extendSelection && selection().contains(vPoint)) { | 151 if (!extendSelection && selection().contains(vPoint)) { |
| 152 m_mouseDownWasSingleClickInSelection = true; | 152 m_mouseDownWasSingleClickInSelection = true; |
| 153 return false; | 153 return false; |
| 154 } | 154 } |
| 155 } | 155 } |
| 156 | 156 |
| 157 PositionWithAffinity eventPos = innerNode->layoutObject()->positionForPoint(
event.localPoint()); | 157 PositionWithAffinity eventPos = innerNode->layoutObject()->positionForPoint(
event.localPoint()); |
| 158 VisiblePosition visiblePos(Strategy::toPositionType(eventPos.position()), ev
entPos.affinity()); | 158 VisiblePosition visiblePos = visiblePositionOf(Strategy::toPositionType(even
tPos.position()), eventPos.affinity()); |
| 159 if (visiblePos.isNull()) | 159 if (visiblePos.isNull()) |
| 160 visiblePos = VisiblePosition(firstPositionInOrBeforeNode(innerNode)); | 160 visiblePos = VisiblePosition(firstPositionInOrBeforeNode(innerNode)); |
| 161 PositionType pos = Strategy::toPositionType(visiblePos.deepEquivalent()); | 161 PositionType pos = Strategy::toPositionType(visiblePos.deepEquivalent()); |
| 162 | 162 |
| 163 VisibleSelection newSelection = selection().selection(); | 163 VisibleSelection newSelection = selection().selection(); |
| 164 TextGranularity granularity = CharacterGranularity; | 164 TextGranularity granularity = CharacterGranularity; |
| 165 | 165 |
| 166 if (extendSelection && newSelection.isCaretOrRange()) { | 166 if (extendSelection && newSelection.isCaretOrRange()) { |
| 167 VisibleSelection selectionInUserSelectAll(expandSelectionToRespectUserSe
lectAll(innerNode, VisibleSelection(VisiblePosition(pos)))); | 167 VisibleSelection selectionInUserSelectAll(expandSelectionToRespectUserSe
lectAll(innerNode, VisibleSelection(visiblePositionOf(pos)))); |
| 168 if (selectionInUserSelectAll.isRange()) { | 168 if (selectionInUserSelectAll.isRange()) { |
| 169 if (Strategy::selectionStart(selectionInUserSelectAll).compareTo(Str
ategy::selectionStart(newSelection)) < 0) | 169 if (Strategy::selectionStart(selectionInUserSelectAll).compareTo(Str
ategy::selectionStart(newSelection)) < 0) |
| 170 pos = Strategy::selectionStart(selectionInUserSelectAll); | 170 pos = Strategy::selectionStart(selectionInUserSelectAll); |
| 171 else if (Strategy::selectionEnd(newSelection).compareTo(Strategy::se
lectionEnd(selectionInUserSelectAll)) < 0) | 171 else if (Strategy::selectionEnd(newSelection).compareTo(Strategy::se
lectionEnd(selectionInUserSelectAll)) < 0) |
| 172 pos = Strategy::selectionEnd(selectionInUserSelectAll); | 172 pos = Strategy::selectionEnd(selectionInUserSelectAll); |
| 173 } | 173 } |
| 174 | 174 |
| 175 if (!m_frame->editor().behavior().shouldConsiderSelectionAsDirectional()
) { | 175 if (!m_frame->editor().behavior().shouldConsiderSelectionAsDirectional()
) { |
| 176 if (pos.isNotNull()) { | 176 if (pos.isNotNull()) { |
| 177 // See <rdar://problem/3668157> REGRESSION (Mail): shift-click d
eselects when selection | 177 // See <rdar://problem/3668157> REGRESSION (Mail): shift-click d
eselects when selection |
| (...skipping 30 matching lines...) Expand all Loading... |
| 208 using PositionType = typename Strategy::PositionType; | 208 using PositionType = typename Strategy::PositionType; |
| 209 | 209 |
| 210 if (!m_mouseDownMayStartSelect) | 210 if (!m_mouseDownMayStartSelect) |
| 211 return; | 211 return; |
| 212 | 212 |
| 213 Node* target = hitTestResult.innerNode(); | 213 Node* target = hitTestResult.innerNode(); |
| 214 if (!target) | 214 if (!target) |
| 215 return; | 215 return; |
| 216 | 216 |
| 217 PositionWithAffinity rawTargetPosition = selection().selection().positionRes
pectingEditingBoundary(hitTestResult.localPoint(), target); | 217 PositionWithAffinity rawTargetPosition = selection().selection().positionRes
pectingEditingBoundary(hitTestResult.localPoint(), target); |
| 218 VisiblePosition targetPosition = VisiblePosition(Strategy::toPositionType(ra
wTargetPosition.position()), rawTargetPosition.affinity()); | 218 VisiblePosition targetPosition = visiblePositionOf(Strategy::toPositionType(
rawTargetPosition.position()), rawTargetPosition.affinity()); |
| 219 // Don't modify the selection if we're not on a node. | 219 // Don't modify the selection if we're not on a node. |
| 220 if (targetPosition.isNull()) | 220 if (targetPosition.isNull()) |
| 221 return; | 221 return; |
| 222 | 222 |
| 223 // Restart the selection if this is the first mouse move. This work is usual
ly | 223 // Restart the selection if this is the first mouse move. This work is usual
ly |
| 224 // done in handleMousePressEvent, but not if the mouse press was on an exist
ing selection. | 224 // done in handleMousePressEvent, but not if the mouse press was on an exist
ing selection. |
| 225 VisibleSelection newSelection = selection().selection(); | 225 VisibleSelection newSelection = selection().selection(); |
| 226 | 226 |
| 227 // Special case to limit selection to the containing block for SVG text. | 227 // Special case to limit selection to the containing block for SVG text. |
| 228 // FIXME: Isn't there a better non-SVG-specific way to do this? | 228 // FIXME: Isn't there a better non-SVG-specific way to do this? |
| (...skipping 421 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 650 else | 650 else |
| 651 m_selectionState = SelectionState::HaveNotStartedSelection; | 651 m_selectionState = SelectionState::HaveNotStartedSelection; |
| 652 } | 652 } |
| 653 | 653 |
| 654 FrameSelection& SelectionController::selection() const | 654 FrameSelection& SelectionController::selection() const |
| 655 { | 655 { |
| 656 return m_frame->selection(); | 656 return m_frame->selection(); |
| 657 } | 657 } |
| 658 | 658 |
| 659 } // namespace blink | 659 } // namespace blink |
| OLD | NEW |