 Chromium Code Reviews
 Chromium Code Reviews Issue 2616623002:
  Do not send redundant selectionchange-events (decouple focus)  (Closed)
    
  
    Issue 2616623002:
  Do not send redundant selectionchange-events (decouple focus)  (Closed) 
  | Index: third_party/WebKit/Source/core/editing/EditingUtilities.cpp | 
| diff --git a/third_party/WebKit/Source/core/editing/EditingUtilities.cpp b/third_party/WebKit/Source/core/editing/EditingUtilities.cpp | 
| index 736d889bf286020e88b7afa6ef2f399bf276d8fd..a443f6a49abd8cd8f4e67c0fca612c473b8621e1 100644 | 
| --- a/third_party/WebKit/Source/core/editing/EditingUtilities.cpp | 
| +++ b/third_party/WebKit/Source/core/editing/EditingUtilities.cpp | 
| @@ -374,6 +374,23 @@ Element* rootEditableElement(const Node& node) { | 
| return toElement(const_cast<Node*>(result)); | 
| } | 
| +bool selectionHasFocus(const LocalFrame& frame, | 
| 
yosin_UTC9
2017/03/22 05:07:59
Let's take Document from selection instead of extr
 
hugoh_UTC2
2017/03/22 07:50:33
SelectionTemplate currently keeps Document private
 
yosin_UTC9
2017/03/22 07:53:19
You can get Document by Position, e.g. selection.b
 
hugoh_UTC2
2017/03/22 08:32:38
Done. See PS25.
 | 
| + const SelectionInFlatTree& selection) { | 
| + const Element* focus = frame.document()->focusedElement(); | 
| + if (!focus) { | 
| + // No focused element means document root has focus. | 
| + focus = frame.document()->documentElement(); | 
| + } | 
| + | 
| + const Node* const nodeWhereSelectionStarts = | 
| + selection.base().computeContainerNode(); | 
| + const Node* const nodeWhereSelectionEnds = | 
| + selection.extent().computeContainerNode(); | 
| + | 
| + return focus->containsIncludingHostElements(*nodeWhereSelectionStarts) || | 
| + focus->containsIncludingHostElements(*nodeWhereSelectionEnds); | 
| +} | 
| + | 
| ContainerNode* highestEditableRoot( | 
| const Position& position, | 
| Element* (*rootEditableElementOf)(const Position&), |