Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 /* | 1 /* |
| 2 * Copyright (C) 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All rights | 2 * Copyright (C) 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All rights |
| 3 * reserved. | 3 * reserved. |
| 4 * Copyright (C) 2006 Alexey Proskuryakov (ap@webkit.org) | 4 * Copyright (C) 2006 Alexey Proskuryakov (ap@webkit.org) |
| 5 * Copyright (C) 2012 Digia Plc. and/or its subsidiary(-ies) | 5 * Copyright (C) 2012 Digia Plc. and/or its subsidiary(-ies) |
| 6 * Copyright (C) 2015 Google Inc. All rights reserved. | 6 * Copyright (C) 2015 Google Inc. All rights reserved. |
| 7 * | 7 * |
| 8 * Redistribution and use in source and binary forms, with or without | 8 * Redistribution and use in source and binary forms, with or without |
| 9 * modification, are permitted provided that the following conditions | 9 * modification, are permitted provided that the following conditions |
| 10 * are met: | 10 * are met: |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 74 if (!node || !node->GetLayoutObject()) | 74 if (!node || !node->GetLayoutObject()) |
| 75 return DispatchEventResult::kNotCanceled; | 75 return DispatchEventResult::kNotCanceled; |
| 76 | 76 |
| 77 return node->DispatchEvent( | 77 return node->DispatchEvent( |
| 78 Event::CreateCancelableBubble(EventTypeNames::selectstart)); | 78 Event::CreateCancelableBubble(EventTypeNames::selectstart)); |
| 79 } | 79 } |
| 80 | 80 |
| 81 VisibleSelectionInFlatTree ExpandSelectionToRespectUserSelectAll( | 81 VisibleSelectionInFlatTree ExpandSelectionToRespectUserSelectAll( |
| 82 Node* target_node, | 82 Node* target_node, |
| 83 const VisibleSelectionInFlatTree& selection) { | 83 const VisibleSelectionInFlatTree& selection) { |
| 84 if (selection.IsNone()) | |
| 85 return selection; | |
| 84 Node* const root_user_select_all = | 86 Node* const root_user_select_all = |
| 85 EditingInFlatTreeStrategy::RootUserSelectAllForNode(target_node); | 87 EditingInFlatTreeStrategy::RootUserSelectAllForNode(target_node); |
| 86 if (!root_user_select_all) | 88 if (!root_user_select_all) { |
| 87 return selection; | 89 SelectionInFlatTree::Builder builder; |
| 90 if (selection.IsBaseFirst()) | |
|
Xiaocheng
2017/06/23 17:31:11
Can we use |builder.SetBaseAndExtent(selection.Bas
yosin_UTC9
2017/06/26 04:14:50
No. When granularity is word/pargraph, base == ext
| |
| 91 builder.SetBaseAndExtent(selection.Start(), selection.End()); | |
| 92 else | |
| 93 builder.SetBaseAndExtent(selection.End(), selection.Start()); | |
| 94 builder.SetAffinity(selection.Affinity()); | |
| 95 return CreateVisibleSelection(builder.Build()); | |
| 96 } | |
| 88 | 97 |
| 89 return CreateVisibleSelection( | 98 return CreateVisibleSelection( |
| 90 SelectionInFlatTree::Builder(selection.AsSelection()) | 99 SelectionInFlatTree::Builder(selection.AsSelection()) |
| 91 .Collapse(MostBackwardCaretPosition( | 100 .Collapse(MostBackwardCaretPosition( |
| 92 PositionInFlatTree::BeforeNode(*root_user_select_all), | 101 PositionInFlatTree::BeforeNode(*root_user_select_all), |
| 93 kCanCrossEditingBoundary)) | 102 kCanCrossEditingBoundary)) |
| 94 .Extend(MostForwardCaretPosition( | 103 .Extend(MostForwardCaretPosition( |
| 95 PositionInFlatTree::AfterNode(*root_user_select_all), | 104 PositionInFlatTree::AfterNode(*root_user_select_all), |
| 96 kCanCrossEditingBoundary)) | 105 kCanCrossEditingBoundary)) |
| 97 .Build()); | 106 .Build()); |
| (...skipping 1099 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1197 | 1206 |
| 1198 bool IsExtendingSelection(const MouseEventWithHitTestResults& event) { | 1207 bool IsExtendingSelection(const MouseEventWithHitTestResults& event) { |
| 1199 bool is_mouse_down_on_link_or_image = | 1208 bool is_mouse_down_on_link_or_image = |
| 1200 event.IsOverLink() || event.GetHitTestResult().GetImage(); | 1209 event.IsOverLink() || event.GetHitTestResult().GetImage(); |
| 1201 return (event.Event().GetModifiers() & WebInputEvent::Modifiers::kShiftKey) != | 1210 return (event.Event().GetModifiers() & WebInputEvent::Modifiers::kShiftKey) != |
| 1202 0 && | 1211 0 && |
| 1203 !is_mouse_down_on_link_or_image; | 1212 !is_mouse_down_on_link_or_image; |
| 1204 } | 1213 } |
| 1205 | 1214 |
| 1206 } // namespace blink | 1215 } // namespace blink |
| OLD | NEW |