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 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
107 return true; | 107 return true; |
108 | 108 |
109 if (!node->canStartSelection()) | 109 if (!node->canStartSelection()) |
110 return false; | 110 return false; |
111 | 111 |
112 return true; | 112 return true; |
113 } | 113 } |
114 | 114 |
115 VisiblePositionInFlatTree visiblePositionOfHitTestResult(const HitTestResult& hi
tTestResult) | 115 VisiblePositionInFlatTree visiblePositionOfHitTestResult(const HitTestResult& hi
tTestResult) |
116 { | 116 { |
117 return createVisiblePosition( | 117 return createVisiblePositionDeprecated( |
118 fromPositionInDOMTree<EditingInFlatTreeStrategy>(hitTestResult.innerNode
()->layoutObject()->positionForPoint(hitTestResult.localPoint()))); | 118 fromPositionInDOMTree<EditingInFlatTreeStrategy>(hitTestResult.innerNode
()->layoutObject()->positionForPoint(hitTestResult.localPoint()))); |
119 } | 119 } |
120 | 120 |
121 } // namespace | 121 } // namespace |
122 | 122 |
123 bool SelectionController::handleMousePressEventSingleClick(const MouseEventWithH
itTestResults& event) | 123 bool SelectionController::handleMousePressEventSingleClick(const MouseEventWithH
itTestResults& event) |
124 { | 124 { |
125 TRACE_EVENT0("blink", "SelectionController::handleMousePressEventSingleClick
"); | 125 TRACE_EVENT0("blink", "SelectionController::handleMousePressEventSingleClick
"); |
126 | 126 |
127 DCHECK(!m_frame->document()->needsLayoutTreeUpdate()); | 127 DCHECK(!m_frame->document()->needsLayoutTreeUpdate()); |
128 Node* innerNode = event.innerNode(); | 128 Node* innerNode = event.innerNode(); |
129 if (!(innerNode && innerNode->layoutObject() && m_mouseDownMayStartSelect)) | 129 if (!(innerNode && innerNode->layoutObject() && m_mouseDownMayStartSelect)) |
130 return false; | 130 return false; |
131 | 131 |
132 // Extend the selection if the Shift key is down, unless the click is in a l
ink or image. | 132 // Extend the selection if the Shift key is down, unless the click is in a l
ink or image. |
133 bool extendSelection = isExtendingSelection(event); | 133 bool extendSelection = isExtendingSelection(event); |
134 | 134 |
135 // Don't restart the selection when the mouse is pressed on an | 135 // Don't restart the selection when the mouse is pressed on an |
136 // existing selection so we can allow for text dragging. | 136 // existing selection so we can allow for text dragging. |
137 if (FrameView* view = m_frame->view()) { | 137 if (FrameView* view = m_frame->view()) { |
138 LayoutPoint vPoint = view->rootFrameToContents(event.event().position())
; | 138 LayoutPoint vPoint = view->rootFrameToContents(event.event().position())
; |
139 if (!extendSelection && selection().contains(vPoint)) { | 139 if (!extendSelection && selection().contains(vPoint)) { |
140 m_mouseDownWasSingleClickInSelection = true; | 140 m_mouseDownWasSingleClickInSelection = true; |
141 return false; | 141 return false; |
142 } | 142 } |
143 } | 143 } |
144 | 144 |
145 VisiblePositionInFlatTree visiblePos = visiblePositionOfHitTestResult(event.
hitTestResult()); | 145 VisiblePositionInFlatTree visiblePos = visiblePositionOfHitTestResult(event.
hitTestResult()); |
146 if (visiblePos.isNull()) | 146 if (visiblePos.isNull()) |
147 visiblePos = createVisiblePosition(PositionInFlatTree::firstPositionInOr
BeforeNode(innerNode)); | 147 visiblePos = createVisiblePositionDeprecated(PositionInFlatTree::firstPo
sitionInOrBeforeNode(innerNode)); |
148 PositionInFlatTree pos = visiblePos.deepEquivalent(); | 148 PositionInFlatTree pos = visiblePos.deepEquivalent(); |
149 | 149 |
150 VisibleSelectionInFlatTree newSelection = selection().visibleSelection<Editi
ngInFlatTreeStrategy>(); | 150 VisibleSelectionInFlatTree newSelection = selection().visibleSelection<Editi
ngInFlatTreeStrategy>(); |
151 TextGranularity granularity = CharacterGranularity; | 151 TextGranularity granularity = CharacterGranularity; |
152 | 152 |
153 if (extendSelection && !newSelection.isNone()) { | 153 if (extendSelection && !newSelection.isNone()) { |
154 const VisibleSelectionInFlatTree selectionInUserSelectAll(expandSelectio
nToRespectUserSelectAll(innerNode, VisibleSelectionInFlatTree(createVisiblePosit
ion(pos)))); | 154 const VisibleSelectionInFlatTree selectionInUserSelectAll(expandSelectio
nToRespectUserSelectAll(innerNode, VisibleSelectionInFlatTree(createVisiblePosit
ionDeprecated(pos)))); |
155 if (selectionInUserSelectAll.isRange()) { | 155 if (selectionInUserSelectAll.isRange()) { |
156 if (selectionInUserSelectAll.start().compareTo(newSelection.start())
< 0) | 156 if (selectionInUserSelectAll.start().compareTo(newSelection.start())
< 0) |
157 pos = selectionInUserSelectAll.start(); | 157 pos = selectionInUserSelectAll.start(); |
158 else if (newSelection.end().compareTo(selectionInUserSelectAll.end()
) < 0) | 158 else if (newSelection.end().compareTo(selectionInUserSelectAll.end()
) < 0) |
159 pos = selectionInUserSelectAll.end(); | 159 pos = selectionInUserSelectAll.end(); |
160 } | 160 } |
161 | 161 |
162 if (!m_frame->editor().behavior().shouldConsiderSelectionAsDirectional()
) { | 162 if (!m_frame->editor().behavior().shouldConsiderSelectionAsDirectional()
) { |
163 if (pos.isNotNull()) { | 163 if (pos.isNotNull()) { |
164 // See <rdar://problem/3668157> REGRESSION (Mail): shift-click | 164 // See <rdar://problem/3668157> REGRESSION (Mail): shift-click |
(...skipping 27 matching lines...) Expand all Loading... |
192 void SelectionController::updateSelectionForMouseDrag(const HitTestResult& hitTe
stResult, Node* mousePressNode, const LayoutPoint& dragStartPos, const IntPoint&
lastKnownMousePosition) | 192 void SelectionController::updateSelectionForMouseDrag(const HitTestResult& hitTe
stResult, Node* mousePressNode, const LayoutPoint& dragStartPos, const IntPoint&
lastKnownMousePosition) |
193 { | 193 { |
194 if (!m_mouseDownMayStartSelect) | 194 if (!m_mouseDownMayStartSelect) |
195 return; | 195 return; |
196 | 196 |
197 Node* target = hitTestResult.innerNode(); | 197 Node* target = hitTestResult.innerNode(); |
198 if (!target) | 198 if (!target) |
199 return; | 199 return; |
200 | 200 |
201 const PositionWithAffinity& rawTargetPosition = positionRespectingEditingBou
ndary(selection().selection().start(), hitTestResult.localPoint(), target); | 201 const PositionWithAffinity& rawTargetPosition = positionRespectingEditingBou
ndary(selection().selection().start(), hitTestResult.localPoint(), target); |
202 VisiblePositionInFlatTree targetPosition = createVisiblePosition(fromPositio
nInDOMTree<EditingInFlatTreeStrategy>(rawTargetPosition)); | 202 VisiblePositionInFlatTree targetPosition = createVisiblePositionDeprecated(f
romPositionInDOMTree<EditingInFlatTreeStrategy>(rawTargetPosition)); |
203 // Don't modify the selection if we're not on a node. | 203 // Don't modify the selection if we're not on a node. |
204 if (targetPosition.isNull()) | 204 if (targetPosition.isNull()) |
205 return; | 205 return; |
206 | 206 |
207 // Restart the selection if this is the first mouse move. This work is usual
ly | 207 // Restart the selection if this is the first mouse move. This work is usual
ly |
208 // done in handleMousePressEvent, but not if the mouse press was on an exist
ing selection. | 208 // done in handleMousePressEvent, but not if the mouse press was on an exist
ing selection. |
209 VisibleSelectionInFlatTree newSelection = selection().visibleSelection<Editi
ngInFlatTreeStrategy>(); | 209 VisibleSelectionInFlatTree newSelection = selection().visibleSelection<Editi
ngInFlatTreeStrategy>(); |
210 | 210 |
211 // Special case to limit selection to the containing block for SVG text. | 211 // Special case to limit selection to the containing block for SVG text. |
212 // FIXME: Isn't there a better non-SVG-specific way to do this? | 212 // FIXME: Isn't there a better non-SVG-specific way to do this? |
(...skipping 461 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
674 return event.event().altKey() && event.isOverLink(); | 674 return event.event().altKey() && event.isOverLink(); |
675 } | 675 } |
676 | 676 |
677 bool isExtendingSelection(const MouseEventWithHitTestResults& event) | 677 bool isExtendingSelection(const MouseEventWithHitTestResults& event) |
678 { | 678 { |
679 bool isMouseDownOnLinkOrImage = event.isOverLink() || event.hitTestResult().
image(); | 679 bool isMouseDownOnLinkOrImage = event.isOverLink() || event.hitTestResult().
image(); |
680 return event.event().shiftKey() && !isMouseDownOnLinkOrImage; | 680 return event.event().shiftKey() && !isMouseDownOnLinkOrImage; |
681 } | 681 } |
682 | 682 |
683 } // namespace blink | 683 } // namespace blink |
OLD | NEW |