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 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
66 | 66 |
67 namespace { | 67 namespace { |
68 | 68 |
69 void setSelectionIfNeeded(FrameSelection& selection, const VisibleSelectionInFla
tTree& newSelection) | 69 void setSelectionIfNeeded(FrameSelection& selection, const VisibleSelectionInFla
tTree& newSelection) |
70 { | 70 { |
71 if (selection.visibleSelection<EditingInFlatTreeStrategy>() == newSelection) | 71 if (selection.visibleSelection<EditingInFlatTreeStrategy>() == newSelection) |
72 return; | 72 return; |
73 selection.setSelection(newSelection); | 73 selection.setSelection(newSelection); |
74 } | 74 } |
75 | 75 |
76 bool dispatchSelectStart(Node* node) | 76 DispatchEventResult dispatchSelectStart(Node* node) |
77 { | 77 { |
78 if (!node || !node->layoutObject()) | 78 if (!node || !node->layoutObject()) |
79 return true; | 79 return DispatchEventResult::NotCanceled; |
80 | 80 |
81 return node->dispatchEvent(Event::createCancelableBubble(EventTypeNames::sel
ectstart)); | 81 return node->dispatchEvent(Event::createCancelableBubble(EventTypeNames::sel
ectstart)); |
82 } | 82 } |
83 | 83 |
84 VisibleSelectionInFlatTree expandSelectionToRespectUserSelectAll(Node* targetNod
e, const VisibleSelectionInFlatTree& selection) | 84 VisibleSelectionInFlatTree expandSelectionToRespectUserSelectAll(Node* targetNod
e, const VisibleSelectionInFlatTree& selection) |
85 { | 85 { |
86 Node* rootUserSelectAll = EditingInFlatTreeStrategy::rootUserSelectAllForNod
e(targetNode); | 86 Node* rootUserSelectAll = EditingInFlatTreeStrategy::rootUserSelectAllForNod
e(targetNode); |
87 if (!rootUserSelectAll) | 87 if (!rootUserSelectAll) |
88 return selection; | 88 return selection; |
89 | 89 |
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
210 // FIXME: Isn't there a better non-SVG-specific way to do this? | 210 // FIXME: Isn't there a better non-SVG-specific way to do this? |
211 if (Node* selectionBaseNode = newSelection.base().anchorNode()) { | 211 if (Node* selectionBaseNode = newSelection.base().anchorNode()) { |
212 if (LayoutObject* selectionBaseLayoutObject = selectionBaseNode->layoutO
bject()) { | 212 if (LayoutObject* selectionBaseLayoutObject = selectionBaseNode->layoutO
bject()) { |
213 if (selectionBaseLayoutObject->isSVGText()) { | 213 if (selectionBaseLayoutObject->isSVGText()) { |
214 if (target->layoutObject()->containingBlock() != selectionBaseLa
youtObject->containingBlock()) | 214 if (target->layoutObject()->containingBlock() != selectionBaseLa
youtObject->containingBlock()) |
215 return; | 215 return; |
216 } | 216 } |
217 } | 217 } |
218 } | 218 } |
219 | 219 |
220 if (m_selectionState == SelectionState::HaveNotStartedSelection && !dispatch
SelectStart(target)) | 220 if (m_selectionState == SelectionState::HaveNotStartedSelection && dispatchS
electStart(target) != DispatchEventResult::NotCanceled) |
221 return; | 221 return; |
222 | 222 |
223 // TODO(yosin) We should check |mousePressNode|, |targetPosition|, and | 223 // TODO(yosin) We should check |mousePressNode|, |targetPosition|, and |
224 // |newSelection| are valid for |m_frame->document()|. | 224 // |newSelection| are valid for |m_frame->document()|. |
225 // |dispatchSelectStart()| can change them by "selectstart" event handler. | 225 // |dispatchSelectStart()| can change them by "selectstart" event handler. |
226 | 226 |
227 if (m_selectionState != SelectionState::ExtendedSelection) { | 227 if (m_selectionState != SelectionState::ExtendedSelection) { |
228 // Always extend selection here because it's caused by a mouse drag | 228 // Always extend selection here because it's caused by a mouse drag |
229 m_selectionState = SelectionState::ExtendedSelection; | 229 m_selectionState = SelectionState::ExtendedSelection; |
230 newSelection = VisibleSelectionInFlatTree(targetPosition); | 230 newSelection = VisibleSelectionInFlatTree(targetPosition); |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
262 | 262 |
263 selection().setNonDirectionalSelectionIfNeeded(newSelection, selection().gra
nularity(), | 263 selection().setNonDirectionalSelectionIfNeeded(newSelection, selection().gra
nularity(), |
264 FrameSelection::AdjustEndpointsAtBidiBoundary); | 264 FrameSelection::AdjustEndpointsAtBidiBoundary); |
265 } | 265 } |
266 | 266 |
267 bool SelectionController::updateSelectionForMouseDownDispatchingSelectStart(Node
* targetNode, const VisibleSelectionInFlatTree& selection, TextGranularity granu
larity) | 267 bool SelectionController::updateSelectionForMouseDownDispatchingSelectStart(Node
* targetNode, const VisibleSelectionInFlatTree& selection, TextGranularity granu
larity) |
268 { | 268 { |
269 if (targetNode && targetNode->layoutObject() && !targetNode->layoutObject()-
>isSelectable()) | 269 if (targetNode && targetNode->layoutObject() && !targetNode->layoutObject()-
>isSelectable()) |
270 return false; | 270 return false; |
271 | 271 |
272 if (!dispatchSelectStart(targetNode)) | 272 if (dispatchSelectStart(targetNode) != DispatchEventResult::NotCanceled) |
273 return false; | 273 return false; |
274 | 274 |
275 if (!selection.isValidFor(*m_frame->document())) | 275 if (!selection.isValidFor(*m_frame->document())) |
276 return false; | 276 return false; |
277 | 277 |
278 if (selection.isRange()) { | 278 if (selection.isRange()) { |
279 m_selectionState = SelectionState::ExtendedSelection; | 279 m_selectionState = SelectionState::ExtendedSelection; |
280 } else { | 280 } else { |
281 granularity = CharacterGranularity; | 281 granularity = CharacterGranularity; |
282 m_selectionState = SelectionState::PlacedCaret; | 282 m_selectionState = SelectionState::PlacedCaret; |
(...skipping 334 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
617 else | 617 else |
618 m_selectionState = SelectionState::HaveNotStartedSelection; | 618 m_selectionState = SelectionState::HaveNotStartedSelection; |
619 } | 619 } |
620 | 620 |
621 FrameSelection& SelectionController::selection() const | 621 FrameSelection& SelectionController::selection() const |
622 { | 622 { |
623 return m_frame->selection(); | 623 return m_frame->selection(); |
624 } | 624 } |
625 | 625 |
626 } // namespace blink | 626 } // namespace blink |
OLD | NEW |