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

Unified Diff: third_party/WebKit/Source/core/editing/FrameSelection.cpp

Issue 2979513002: Use Layoutselection::SelectionBounds() in RevealSelection() (Closed)
Patch Set: update Created 3 years, 5 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « third_party/WebKit/Source/core/editing/FrameSelection.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/Source/core/editing/FrameSelection.cpp
diff --git a/third_party/WebKit/Source/core/editing/FrameSelection.cpp b/third_party/WebKit/Source/core/editing/FrameSelection.cpp
index a80dfd1c4dff89925c17e6a0ca4af78cee076f26..be6bbd776c49a5daaa4d8c4672e45908f6efc81c 100644
--- a/third_party/WebKit/Source/core/editing/FrameSelection.cpp
+++ b/third_party/WebKit/Source/core/editing/FrameSelection.cpp
@@ -947,10 +947,23 @@ LayoutRect FrameSelection::UnclippedBounds() const {
return LayoutRect(layout_selection_->SelectionBounds());
}
-static IntRect AbsoluteSelectionBoundsOf(
- const VisibleSelectionInFlatTree& selection) {
- return ComputeTextRect(
- EphemeralRangeInFlatTree(selection.Start(), selection.End()));
+IntRect FrameSelection::ComputeRectToScroll(
+ RevealExtentOption reveal_extent_option) {
+ const VisibleSelection& selection = ComputeVisibleSelectionInDOMTree();
+ LayoutRect rect;
+ switch (selection.GetSelectionType()) {
+ case kCaretSelection:
+ return AbsoluteCaretBounds();
+ case kRangeSelection: {
+ if (reveal_extent_option == kRevealExtent)
+ return AbsoluteCaretBoundsOf(CreateVisiblePosition(selection.Extent()));
+ layout_selection_->SetHasPendingSelection();
+ return layout_selection_->SelectionBounds();
+ }
+ default:
+ NOTREACHED();
+ return {};
+ }
}
// TODO(editing-dev): This should be done in FlatTree world.
@@ -967,23 +980,6 @@ void FrameSelection::RevealSelection(const ScrollAlignment& alignment,
if (selection.GetSelectionType() == kNoSelection)
return;
- LayoutRect rect;
- switch (selection.GetSelectionType()) {
- case kCaretSelection:
- rect = LayoutRect(AbsoluteCaretBounds());
- break;
- case kRangeSelection: {
- rect = LayoutRect(
- reveal_extent_option == kRevealExtent
- ? AbsoluteCaretBoundsOf(CreateVisiblePosition(selection.Extent()))
- : AbsoluteSelectionBoundsOf(ComputeVisibleSelectionInFlatTree()));
- break;
- }
- default:
- NOTREACHED();
- break;
- }
-
// FIXME: This code only handles scrolling the startContainer's layer, but
// the selection rect could intersect more than just that.
if (DocumentLoader* document_loader = frame_->Loader().GetDocumentLoader())
@@ -992,7 +988,8 @@ void FrameSelection::RevealSelection(const ScrollAlignment& alignment,
DCHECK(start.AnchorNode());
DCHECK(start.AnchorNode()->GetLayoutObject());
if (!start.AnchorNode()->GetLayoutObject()->ScrollRectToVisible(
- rect, alignment, alignment))
+ LayoutRect(ComputeRectToScroll(reveal_extent_option)), alignment,
+ alignment))
return;
UpdateAppearance();
« no previous file with comments | « third_party/WebKit/Source/core/editing/FrameSelection.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698