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

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

Issue 2894803002: Use current selection when tab navigation. (Closed)
Patch Set: Fix selection direction Created 3 years, 7 months 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) 2004, 2008, 2009, 2010 Apple Inc. All rights reserved. 2 * Copyright (C) 2004, 2008, 2009, 2010 Apple Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions 5 * modification, are permitted provided that the following conditions
6 * are met: 6 * are met:
7 * 1. Redistributions of source code must retain the above copyright 7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer. 8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright 9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the 10 * notice, this list of conditions and the following disclaimer in the
(...skipping 931 matching lines...) Expand 10 before | Expand all | Expand 10 after
942 FrameView* view = frame_->View(); 942 FrameView* view = frame_->View();
943 LayoutViewItem layout_view = frame_->ContentLayoutItem(); 943 LayoutViewItem layout_view = frame_->ContentLayoutItem();
944 944
945 if (!view || layout_view.IsNull()) 945 if (!view || layout_view.IsNull())
946 return LayoutRect(); 946 return LayoutRect();
947 947
948 view->UpdateLifecycleToLayoutClean(); 948 view->UpdateLifecycleToLayoutClean();
949 return LayoutRect(layout_selection_->SelectionBounds()); 949 return LayoutRect(layout_selection_->SelectionBounds());
950 } 950 }
951 951
952 static IntRect AbsoluteSelectionBoundsOf(
953 const VisibleSelectionInFlatTree& selection) {
954 return ComputeTextRect(
955 EphemeralRangeInFlatTree(selection.Start(), selection.end()));
956 }
957
958 // TODO(editing-dev): This should be done in FlatTree world.
952 void FrameSelection::RevealSelection(const ScrollAlignment& alignment, 959 void FrameSelection::RevealSelection(const ScrollAlignment& alignment,
953 RevealExtentOption reveal_extent_option) { 960 RevealExtentOption reveal_extent_option) {
954 DCHECK(IsAvailable()); 961 DCHECK(IsAvailable());
955 962
956 // TODO(editing-dev): The use of updateStyleAndLayoutIgnorePendingStylesheets 963 // TODO(editing-dev): The use of updateStyleAndLayoutIgnorePendingStylesheets
957 // needs to be audited. See http://crbug.com/590369 for more details. 964 // needs to be audited. See http://crbug.com/590369 for more details.
958 // Calculation of absolute caret bounds requires clean layout. 965 // Calculation of absolute caret bounds requires clean layout.
959 GetDocument().UpdateStyleAndLayoutIgnorePendingStylesheets(); 966 GetDocument().UpdateStyleAndLayoutIgnorePendingStylesheets();
960 967
961 LayoutRect rect; 968 LayoutRect rect;
962 969
963 switch (ComputeVisibleSelectionInDOMTree().GetSelectionType()) { 970 switch (ComputeVisibleSelectionInDOMTree().GetSelectionType()) {
964 case kNoSelection: 971 case kNoSelection:
965 return; 972 return;
966 case kCaretSelection: 973 case kCaretSelection:
967 rect = LayoutRect(AbsoluteCaretBounds()); 974 rect = LayoutRect(AbsoluteCaretBounds());
968 break; 975 break;
969 case kRangeSelection: 976 case kRangeSelection:
970 rect = LayoutRect(reveal_extent_option == kRevealExtent 977 rect = LayoutRect(
971 ? AbsoluteCaretBoundsOf(CreateVisiblePosition( 978 reveal_extent_option == kRevealExtent
972 ComputeVisibleSelectionInDOMTree().Extent())) 979 ? AbsoluteCaretBoundsOf(CreateVisiblePosition(
973 : EnclosingIntRect(UnclippedBounds())); 980 ComputeVisibleSelectionInDOMTree().Extent()))
981 : AbsoluteSelectionBoundsOf(ComputeVisibleSelectionInFlatTree()));
974 break; 982 break;
975 } 983 }
976 984
977 Position start = ComputeVisibleSelectionInDOMTree().Start(); 985 Position start = ComputeVisibleSelectionInDOMTree().Start();
978 DCHECK(start.AnchorNode()); 986 DCHECK(start.AnchorNode());
979 if (start.AnchorNode() && start.AnchorNode()->GetLayoutObject()) { 987 if (start.AnchorNode() && start.AnchorNode()->GetLayoutObject()) {
980 // FIXME: This code only handles scrolling the startContainer's layer, but 988 // FIXME: This code only handles scrolling the startContainer's layer, but
981 // the selection rect could intersect more than just that. 989 // the selection rect could intersect more than just that.
982 if (DocumentLoader* document_loader = frame_->Loader().GetDocumentLoader()) 990 if (DocumentLoader* document_loader = frame_->Loader().GetDocumentLoader())
983 document_loader->GetInitialScrollState().was_scrolled_by_user = true; 991 document_loader->GetInitialScrollState().was_scrolled_by_user = true;
(...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after
1175 } 1183 }
1176 1184
1177 void showTree(const blink::FrameSelection* sel) { 1185 void showTree(const blink::FrameSelection* sel) {
1178 if (sel) 1186 if (sel)
1179 sel->ShowTreeForThis(); 1187 sel->ShowTreeForThis();
1180 else 1188 else
1181 LOG(INFO) << "Cannot showTree for <null> FrameSelection."; 1189 LOG(INFO) << "Cannot showTree for <null> FrameSelection.";
1182 } 1190 }
1183 1191
1184 #endif 1192 #endif
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/editing/FrameSelection.h ('k') | third_party/WebKit/Source/core/editing/VisibleUnits.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698