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

Unified Diff: third_party/WebKit/Source/core/input/EventHandler.cpp

Issue 2849883002: Cleanup determining ibeam for node. (Closed)
Patch Set: Fix nits Created 3 years, 8 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 | 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/input/EventHandler.cpp
diff --git a/third_party/WebKit/Source/core/input/EventHandler.cpp b/third_party/WebKit/Source/core/input/EventHandler.cpp
index da142b18a6aa44c1b289c2f83f829018207d25e2..4d9a51e3d187a58cd9a29d0efda877d69db56af0 100644
--- a/third_party/WebKit/Source/core/input/EventHandler.cpp
+++ b/third_party/WebKit/Source/core/input/EventHandler.cpp
@@ -118,6 +118,26 @@ bool ShouldRefetchEventTarget(const MouseEventWithHitTestResults& mev) {
isHTMLInputElement(ToShadowRoot(target_node)->host());
}
+bool ShouldShowIBeamForNode(const Node* node, const HitTestResult& result) {
+ if (!node)
+ return false;
+
+ bool layout_object_selectable = false;
+ if (LayoutObject* layout_object = node->GetLayoutObject()) {
+ PaintLayer* layer = layout_object->EnclosingLayer();
+ if (layer->GetScrollableArea() &&
+ layer->GetScrollableArea()->IsPointInResizeControl(
+ result.RoundedPointInMainFrame(), kResizerForPointer)) {
+ return false;
+ }
+
+ layout_object_selectable =
+ layout_object->IsText() && node->CanStartSelection();
+ }
+
+ return HasEditableStyle(*node) || layout_object_selectable;
+}
+
} // namespace
using namespace HTMLNames;
@@ -537,26 +557,16 @@ OptionalCursor EventHandler::SelectAutoCursor(const HitTestResult& result,
return PointerCursor();
}
- bool editable = (node && HasEditableStyle(*node));
-
const bool is_over_link =
!GetSelectionController().MouseDownMayStartSelect() &&
result.IsOverLink();
if (UseHandCursor(node, is_over_link))
return HandCursor();
- bool in_resizer = false;
- LayoutObject* layout_object = node ? node->GetLayoutObject() : nullptr;
- if (layout_object && frame_->View()) {
- PaintLayer* layer = layout_object->EnclosingLayer();
- in_resizer = layer->GetScrollableArea() &&
- layer->GetScrollableArea()->IsPointInResizeControl(
- result.RoundedPointInMainFrame(), kResizerForPointer);
- }
-
// During selection, use an I-beam no matter what we're over.
// If a drag may be starting or we're capturing mouse events for a particular
- // node, don't treat this as a selection.
+ // node, don't treat this as a selection. Note calling
+ // ComputeVisibleSelectionInDOMTreeDeprecated may update layout.
if (mouse_event_manager_->MousePressed() &&
GetSelectionController().MouseDownMayStartSelect() &&
!mouse_event_manager_->MouseDownMayStartDrag() &&
@@ -567,9 +577,7 @@ OptionalCursor EventHandler::SelectAutoCursor(const HitTestResult& result,
return i_beam;
}
- if ((editable || (layout_object && layout_object->IsText() &&
- node->CanStartSelection())) &&
- !in_resizer && !result.GetScrollbar())
+ if (ShouldShowIBeamForNode(node, result))
return i_beam;
return PointerCursor();
}
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698