Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(191)

Side by Side Diff: third_party/WebKit/Source/core/editing/SelectionController.cpp

Issue 2457613004: Utilize FrameSelection::setSelection() taking SelectionInDOMTree/SelectionInFlatTree (Closed)
Patch Set: 2016-10-28T15:45:56 Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 749 matching lines...) Expand 10 before | Expand all | Expand 10 after
760 // editing, place the caret. 760 // editing, place the caret.
761 if (m_mouseDownWasSingleClickInSelection && 761 if (m_mouseDownWasSingleClickInSelection &&
762 m_selectionState != SelectionState::ExtendedSelection && 762 m_selectionState != SelectionState::ExtendedSelection &&
763 dragStartPos == event.event().position() && selection().isRange() && 763 dragStartPos == event.event().position() && selection().isRange() &&
764 event.event().pointerProperties().button != 764 event.event().pointerProperties().button !=
765 WebPointerProperties::Button::Right) { 765 WebPointerProperties::Button::Right) {
766 // TODO(xiaochengh): The use of updateStyleAndLayoutIgnorePendingStylesheets 766 // TODO(xiaochengh): The use of updateStyleAndLayoutIgnorePendingStylesheets
767 // needs to be audited. See http://crbug.com/590369 for more details. 767 // needs to be audited. See http://crbug.com/590369 for more details.
768 m_frame->document()->updateStyleAndLayoutIgnorePendingStylesheets(); 768 m_frame->document()->updateStyleAndLayoutIgnorePendingStylesheets();
769 769
770 VisibleSelectionInFlatTree newSelection; 770 SelectionInFlatTree::Builder builder;
771 Node* node = event.innerNode(); 771 Node* node = event.innerNode();
772 if (node && node->layoutObject() && hasEditableStyle(*node)) { 772 if (node && node->layoutObject() && hasEditableStyle(*node)) {
773 const VisiblePositionInFlatTree pos = 773 const VisiblePositionInFlatTree pos =
774 visiblePositionOfHitTestResult(event.hitTestResult()); 774 visiblePositionOfHitTestResult(event.hitTestResult());
775 if (pos.isNotNull()) { 775 if (pos.isNotNull())
776 SelectionInFlatTree::Builder builder;
777 builder.collapse(pos.toPositionWithAffinity()); 776 builder.collapse(pos.toPositionWithAffinity());
778 newSelection = createVisibleSelection(builder.build());
779 }
780 } 777 }
781 778
782 if (selection().visibleSelection<EditingInFlatTreeStrategy>() != 779 if (selection().visibleSelection<EditingInFlatTreeStrategy>() !=
783 newSelection) { 780 createVisibleSelection(builder.build())) {
784 selection().setSelection(newSelection); 781 selection().setSelection(builder.build());
785 } 782 }
786 783
787 handled = true; 784 handled = true;
788 } 785 }
789 786
790 selection().notifyLayoutObjectOfSelectionChange(UserTriggered); 787 selection().notifyLayoutObjectOfSelectionChange(UserTriggered);
791 788
792 selection().selectFrameElementInParentIfFullySelected(); 789 selection().selectFrameElementInParentIfFullySelected();
793 790
794 if (event.event().pointerProperties().button == 791 if (event.event().pointerProperties().button ==
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after
917 if (!selection().contains(p)) 914 if (!selection().contains(p))
918 return; 915 return;
919 916
920 // TODO(xiaochengh): The use of updateStyleAndLayoutIgnorePendingStylesheets 917 // TODO(xiaochengh): The use of updateStyleAndLayoutIgnorePendingStylesheets
921 // needs to be audited. See http://crbug.com/590369 for more details. 918 // needs to be audited. See http://crbug.com/590369 for more details.
922 m_frame->document()->updateStyleAndLayoutIgnorePendingStylesheets(); 919 m_frame->document()->updateStyleAndLayoutIgnorePendingStylesheets();
923 920
924 const VisiblePositionInFlatTree& visiblePos = 921 const VisiblePositionInFlatTree& visiblePos =
925 visiblePositionOfHitTestResult(mev.hitTestResult()); 922 visiblePositionOfHitTestResult(mev.hitTestResult());
926 if (visiblePos.isNull()) { 923 if (visiblePos.isNull()) {
927 selection().setSelection(VisibleSelectionInFlatTree()); 924 selection().setSelection(SelectionInFlatTree());
928 return; 925 return;
929 } 926 }
930 SelectionInFlatTree::Builder builder; 927 selection().setSelection(SelectionInFlatTree::Builder()
931 builder.collapse(visiblePos.toPositionWithAffinity()); 928 .collapse(visiblePos.toPositionWithAffinity())
932 selection().setSelection(createVisibleSelection(builder.build())); 929 .build());
933 } 930 }
934 931
935 void SelectionController::initializeSelectionState() { 932 void SelectionController::initializeSelectionState() {
936 m_selectionState = SelectionState::HaveNotStartedSelection; 933 m_selectionState = SelectionState::HaveNotStartedSelection;
937 } 934 }
938 935
939 void SelectionController::setMouseDownMayStartSelect(bool mayStartSelect) { 936 void SelectionController::setMouseDownMayStartSelect(bool mayStartSelect) {
940 m_mouseDownMayStartSelect = mayStartSelect; 937 m_mouseDownMayStartSelect = mayStartSelect;
941 } 938 }
942 939
(...skipping 22 matching lines...) Expand all
965 return event.event().altKey() && event.isOverLink(); 962 return event.event().altKey() && event.isOverLink();
966 } 963 }
967 964
968 bool isExtendingSelection(const MouseEventWithHitTestResults& event) { 965 bool isExtendingSelection(const MouseEventWithHitTestResults& event) {
969 bool isMouseDownOnLinkOrImage = 966 bool isMouseDownOnLinkOrImage =
970 event.isOverLink() || event.hitTestResult().image(); 967 event.isOverLink() || event.hitTestResult().image();
971 return event.event().shiftKey() && !isMouseDownOnLinkOrImage; 968 return event.event().shiftKey() && !isMouseDownOnLinkOrImage;
972 } 969 }
973 970
974 } // namespace blink 971 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698