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

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

Issue 2491763004: Revert of Utilize FrameSelection::setSelection() taking SelectionInDOMTree/SelectionInFlatTree (Closed)
Patch Set: 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 SelectionInFlatTree::Builder builder; 770 VisibleSelectionInFlatTree newSelection;
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;
776 builder.collapse(pos.toPositionWithAffinity()); 777 builder.collapse(pos.toPositionWithAffinity());
778 newSelection = createVisibleSelection(builder.build());
779 }
777 } 780 }
778 781
779 if (selection().visibleSelection<EditingInFlatTreeStrategy>() != 782 if (selection().visibleSelection<EditingInFlatTreeStrategy>() !=
780 createVisibleSelection(builder.build())) { 783 newSelection) {
781 selection().setSelection(builder.build()); 784 selection().setSelection(newSelection);
782 } 785 }
783 786
784 handled = true; 787 handled = true;
785 } 788 }
786 789
787 selection().notifyLayoutObjectOfSelectionChange(UserTriggered); 790 selection().notifyLayoutObjectOfSelectionChange(UserTriggered);
788 791
789 selection().selectFrameElementInParentIfFullySelected(); 792 selection().selectFrameElementInParentIfFullySelected();
790 793
791 if (event.event().pointerProperties().button == 794 if (event.event().pointerProperties().button ==
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after
915 if (!selection().contains(p)) 918 if (!selection().contains(p))
916 return; 919 return;
917 920
918 // TODO(xiaochengh): The use of updateStyleAndLayoutIgnorePendingStylesheets 921 // TODO(xiaochengh): The use of updateStyleAndLayoutIgnorePendingStylesheets
919 // needs to be audited. See http://crbug.com/590369 for more details. 922 // needs to be audited. See http://crbug.com/590369 for more details.
920 m_frame->document()->updateStyleAndLayoutIgnorePendingStylesheets(); 923 m_frame->document()->updateStyleAndLayoutIgnorePendingStylesheets();
921 924
922 const VisiblePositionInFlatTree& visiblePos = 925 const VisiblePositionInFlatTree& visiblePos =
923 visiblePositionOfHitTestResult(mev.hitTestResult()); 926 visiblePositionOfHitTestResult(mev.hitTestResult());
924 if (visiblePos.isNull()) { 927 if (visiblePos.isNull()) {
925 selection().setSelection(SelectionInFlatTree()); 928 selection().setSelection(VisibleSelectionInFlatTree());
926 return; 929 return;
927 } 930 }
928 selection().setSelection(SelectionInFlatTree::Builder() 931 SelectionInFlatTree::Builder builder;
929 .collapse(visiblePos.toPositionWithAffinity()) 932 builder.collapse(visiblePos.toPositionWithAffinity());
930 .build()); 933 selection().setSelection(createVisibleSelection(builder.build()));
931 } 934 }
932 935
933 void SelectionController::initializeSelectionState() { 936 void SelectionController::initializeSelectionState() {
934 m_selectionState = SelectionState::HaveNotStartedSelection; 937 m_selectionState = SelectionState::HaveNotStartedSelection;
935 } 938 }
936 939
937 void SelectionController::setMouseDownMayStartSelect(bool mayStartSelect) { 940 void SelectionController::setMouseDownMayStartSelect(bool mayStartSelect) {
938 m_mouseDownMayStartSelect = mayStartSelect; 941 m_mouseDownMayStartSelect = mayStartSelect;
939 } 942 }
940 943
(...skipping 22 matching lines...) Expand all
963 return event.event().altKey() && event.isOverLink(); 966 return event.event().altKey() && event.isOverLink();
964 } 967 }
965 968
966 bool isExtendingSelection(const MouseEventWithHitTestResults& event) { 969 bool isExtendingSelection(const MouseEventWithHitTestResults& event) {
967 bool isMouseDownOnLinkOrImage = 970 bool isMouseDownOnLinkOrImage =
968 event.isOverLink() || event.hitTestResult().image(); 971 event.isOverLink() || event.hitTestResult().image();
969 return event.event().shiftKey() && !isMouseDownOnLinkOrImage; 972 return event.event().shiftKey() && !isMouseDownOnLinkOrImage;
970 } 973 }
971 974
972 } // namespace blink 975 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698