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

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

Issue 2900553005: Treat selection as focused if it contains focused element (Closed)
Patch Set: Mon May 22 18:52:27 PDT 2017 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | third_party/WebKit/Source/core/editing/FrameSelectionTest.cpp » ('j') | 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 91eca913ae3b82fd15416100e242ca674fee44bd..decdf8298f69484fdba6bd5410c017621d4af8b5 100644
--- a/third_party/WebKit/Source/core/editing/FrameSelection.cpp
+++ b/third_party/WebKit/Source/core/editing/FrameSelection.cpp
@@ -434,15 +434,22 @@ bool FrameSelection::SelectionHasFocus() const {
return false;
// No focused element means document root has focus.
- const Element* const focused_element = GetDocument().FocusedElement()
- ? GetDocument().FocusedElement()
- : GetDocument().documentElement();
+ Element* const focused_element = GetDocument().FocusedElement()
+ ? GetDocument().FocusedElement()
+ : GetDocument().documentElement();
if (!focused_element)
return false;
if (focused_element->IsTextControl())
return focused_element->ContainsIncludingHostElements(*current);
+ // Selection has focus if it contains the focused element.
+ const PositionInFlatTree& focused_position =
+ PositionInFlatTree::FirstPositionInNode(focused_element);
+ if (ComputeVisibleSelectionInFlatTree().Start() <= focused_position &&
+ ComputeVisibleSelectionInFlatTree().end() >= focused_position)
+ return true;
+
bool has_editable_style = HasEditableStyle(*current);
do {
// If the selection is within an editable sub tree and that sub tree
« no previous file with comments | « no previous file | third_party/WebKit/Source/core/editing/FrameSelectionTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698