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 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
68 namespace { | 68 namespace { |
69 | 69 |
70 template <typename Strategy> | 70 template <typename Strategy> |
71 void setSelectionIfNeeded(FrameSelection& selection, const VisibleSelectionTempl
ate<Strategy>& newSelection) | 71 void setSelectionIfNeeded(FrameSelection& selection, const VisibleSelectionTempl
ate<Strategy>& newSelection) |
72 { | 72 { |
73 if (selection.visibleSelection<Strategy>() == newSelection) | 73 if (selection.visibleSelection<Strategy>() == newSelection) |
74 return; | 74 return; |
75 selection.setSelection(newSelection); | 75 selection.setSelection(newSelection); |
76 } | 76 } |
77 | 77 |
78 bool dispatchSelectStart(Node* node) | 78 WebInputEventResult dispatchSelectStart(Node* node) |
79 { | 79 { |
80 if (!node || !node->layoutObject()) | 80 if (!node || !node->layoutObject()) |
81 return true; | 81 return WebInputEventResult::NotHandled; |
82 | 82 |
83 return node->dispatchEvent(Event::createCancelableBubble(EventTypeNames::sel
ectstart)); | 83 return node->dispatchEvent(Event::createCancelableBubble(EventTypeNames::sel
ectstart)); |
84 } | 84 } |
85 | 85 |
86 template <typename Strategy> | 86 template <typename Strategy> |
87 VisibleSelectionTemplate<Strategy> expandSelectionToRespectUserSelectAll(Node* t
argetNode, const VisibleSelectionTemplate<Strategy>& selection) | 87 VisibleSelectionTemplate<Strategy> expandSelectionToRespectUserSelectAll(Node* t
argetNode, const VisibleSelectionTemplate<Strategy>& selection) |
88 { | 88 { |
89 Node* rootUserSelectAll = Strategy::rootUserSelectAllForNode(targetNode); | 89 Node* rootUserSelectAll = Strategy::rootUserSelectAllForNode(targetNode); |
90 if (!rootUserSelectAll) | 90 if (!rootUserSelectAll) |
91 return selection; | 91 return selection; |
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
211 // FIXME: Isn't there a better non-SVG-specific way to do this? | 211 // FIXME: Isn't there a better non-SVG-specific way to do this? |
212 if (Node* selectionBaseNode = newSelection.base().anchorNode()) { | 212 if (Node* selectionBaseNode = newSelection.base().anchorNode()) { |
213 if (LayoutObject* selectionBaseLayoutObject = selectionBaseNode->layoutO
bject()) { | 213 if (LayoutObject* selectionBaseLayoutObject = selectionBaseNode->layoutO
bject()) { |
214 if (selectionBaseLayoutObject->isSVGText()) { | 214 if (selectionBaseLayoutObject->isSVGText()) { |
215 if (target->layoutObject()->containingBlock() != selectionBaseLa
youtObject->containingBlock()) | 215 if (target->layoutObject()->containingBlock() != selectionBaseLa
youtObject->containingBlock()) |
216 return; | 216 return; |
217 } | 217 } |
218 } | 218 } |
219 } | 219 } |
220 | 220 |
221 if (m_selectionState == SelectionState::HaveNotStartedSelection && !dispatch
SelectStart(target)) | 221 if (m_selectionState == SelectionState::HaveNotStartedSelection && dispatchS
electStart(target) != WebInputEventResult::NotHandled) |
222 return; | 222 return; |
223 | 223 |
224 // TODO(yosin) We should check |mousePressNode|, |targetPosition|, and | 224 // TODO(yosin) We should check |mousePressNode|, |targetPosition|, and |
225 // |newSelection| are valid for |m_frame->document()|. | 225 // |newSelection| are valid for |m_frame->document()|. |
226 // |dispatchSelectStart()| can change them by "selectstart" event handler. | 226 // |dispatchSelectStart()| can change them by "selectstart" event handler. |
227 | 227 |
228 if (m_selectionState != SelectionState::ExtendedSelection) { | 228 if (m_selectionState != SelectionState::ExtendedSelection) { |
229 // Always extend selection here because it's caused by a mouse drag | 229 // Always extend selection here because it's caused by a mouse drag |
230 m_selectionState = SelectionState::ExtendedSelection; | 230 m_selectionState = SelectionState::ExtendedSelection; |
231 newSelection = VisibleSelectionTemplate<Strategy>(targetPosition); | 231 newSelection = VisibleSelectionTemplate<Strategy>(targetPosition); |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
264 selection().setNonDirectionalSelectionIfNeeded(newSelection, selection().gra
nularity(), | 264 selection().setNonDirectionalSelectionIfNeeded(newSelection, selection().gra
nularity(), |
265 FrameSelection::AdjustEndpointsAtBidiBoundary); | 265 FrameSelection::AdjustEndpointsAtBidiBoundary); |
266 } | 266 } |
267 | 267 |
268 template <typename Strategy> | 268 template <typename Strategy> |
269 bool SelectionController::updateSelectionForMouseDownDispatchingSelectStart(Node
* targetNode, const VisibleSelectionTemplate<Strategy>& selection, TextGranulari
ty granularity) | 269 bool SelectionController::updateSelectionForMouseDownDispatchingSelectStart(Node
* targetNode, const VisibleSelectionTemplate<Strategy>& selection, TextGranulari
ty granularity) |
270 { | 270 { |
271 if (targetNode && targetNode->layoutObject() && !targetNode->layoutObject()-
>isSelectable()) | 271 if (targetNode && targetNode->layoutObject() && !targetNode->layoutObject()-
>isSelectable()) |
272 return false; | 272 return false; |
273 | 273 |
274 if (!dispatchSelectStart(targetNode)) | 274 if (dispatchSelectStart(targetNode) != WebInputEventResult::NotHandled) |
275 return false; | 275 return false; |
276 | 276 |
277 if (!selection.isValidFor(*m_frame->document())) | 277 if (!selection.isValidFor(*m_frame->document())) |
278 return false; | 278 return false; |
279 | 279 |
280 if (selection.isRange()) { | 280 if (selection.isRange()) { |
281 m_selectionState = SelectionState::ExtendedSelection; | 281 m_selectionState = SelectionState::ExtendedSelection; |
282 } else { | 282 } else { |
283 granularity = CharacterGranularity; | 283 granularity = CharacterGranularity; |
284 m_selectionState = SelectionState::PlacedCaret; | 284 m_selectionState = SelectionState::PlacedCaret; |
(...skipping 394 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
679 else | 679 else |
680 m_selectionState = SelectionState::HaveNotStartedSelection; | 680 m_selectionState = SelectionState::HaveNotStartedSelection; |
681 } | 681 } |
682 | 682 |
683 FrameSelection& SelectionController::selection() const | 683 FrameSelection& SelectionController::selection() const |
684 { | 684 { |
685 return m_frame->selection(); | 685 return m_frame->selection(); |
686 } | 686 } |
687 | 687 |
688 } // namespace blink | 688 } // namespace blink |
OLD | NEW |