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

Side by Side Diff: third_party/WebKit/Source/core/input/EventHandler.cpp

Issue 2849883002: Cleanup determining ibeam for node. (Closed)
Patch Set: Fix nits 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All rights 2 * Copyright (C) 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All rights
3 * reserved. 3 * reserved.
4 * Copyright (C) 2006 Alexey Proskuryakov (ap@webkit.org) 4 * Copyright (C) 2006 Alexey Proskuryakov (ap@webkit.org)
5 * Copyright (C) 2012 Digia Plc. and/or its subsidiary(-ies) 5 * Copyright (C) 2012 Digia Plc. and/or its subsidiary(-ies)
6 * 6 *
7 * Redistribution and use in source and binary forms, with or without 7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions 8 * modification, are permitted provided that the following conditions
9 * are met: 9 * are met:
10 * 1. Redistributions of source code must retain the above copyright 10 * 1. Redistributions of source code must retain the above copyright
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
111 // EventHandler::handleMousePressEvent to pass the event to the FrameViewBase 111 // EventHandler::handleMousePressEvent to pass the event to the FrameViewBase
112 // and thus the event target node can't still be the shadow node. 112 // and thus the event target node can't still be the shadow node.
113 bool ShouldRefetchEventTarget(const MouseEventWithHitTestResults& mev) { 113 bool ShouldRefetchEventTarget(const MouseEventWithHitTestResults& mev) {
114 Node* target_node = mev.InnerNode(); 114 Node* target_node = mev.InnerNode();
115 if (!target_node || !target_node->parentNode()) 115 if (!target_node || !target_node->parentNode())
116 return true; 116 return true;
117 return target_node->IsShadowRoot() && 117 return target_node->IsShadowRoot() &&
118 isHTMLInputElement(ToShadowRoot(target_node)->host()); 118 isHTMLInputElement(ToShadowRoot(target_node)->host());
119 } 119 }
120 120
121 bool ShouldShowIBeamForNode(const Node* node, const HitTestResult& result) {
122 if (!node)
123 return false;
124
125 bool layout_object_selectable = false;
126 if (LayoutObject* layout_object = node->GetLayoutObject()) {
127 PaintLayer* layer = layout_object->EnclosingLayer();
128 if (layer->GetScrollableArea() &&
129 layer->GetScrollableArea()->IsPointInResizeControl(
130 result.RoundedPointInMainFrame(), kResizerForPointer)) {
131 return false;
132 }
133
134 layout_object_selectable =
135 layout_object->IsText() && node->CanStartSelection();
136 }
137
138 return HasEditableStyle(*node) || layout_object_selectable;
139 }
140
121 } // namespace 141 } // namespace
122 142
123 using namespace HTMLNames; 143 using namespace HTMLNames;
124 144
125 // The amount of time to wait for a cursor update on style and layout changes 145 // The amount of time to wait for a cursor update on style and layout changes
126 // Set to 50Hz, no need to be faster than common screen refresh rate 146 // Set to 50Hz, no need to be faster than common screen refresh rate
127 static const double kCursorUpdateInterval = 0.02; 147 static const double kCursorUpdateInterval = 0.02;
128 148
129 static const int kMaximumCursorSize = 128; 149 static const int kMaximumCursorSize = 128;
130 150
(...skipping 399 matching lines...) Expand 10 before | Expand all | Expand 10 after
530 return PointerCursor(); 550 return PointerCursor();
531 } 551 }
532 552
533 OptionalCursor EventHandler::SelectAutoCursor(const HitTestResult& result, 553 OptionalCursor EventHandler::SelectAutoCursor(const HitTestResult& result,
534 Node* node, 554 Node* node,
535 const Cursor& i_beam) { 555 const Cursor& i_beam) {
536 if (result.GetScrollbar()) { 556 if (result.GetScrollbar()) {
537 return PointerCursor(); 557 return PointerCursor();
538 } 558 }
539 559
540 bool editable = (node && HasEditableStyle(*node));
541
542 const bool is_over_link = 560 const bool is_over_link =
543 !GetSelectionController().MouseDownMayStartSelect() && 561 !GetSelectionController().MouseDownMayStartSelect() &&
544 result.IsOverLink(); 562 result.IsOverLink();
545 if (UseHandCursor(node, is_over_link)) 563 if (UseHandCursor(node, is_over_link))
546 return HandCursor(); 564 return HandCursor();
547 565
548 bool in_resizer = false;
549 LayoutObject* layout_object = node ? node->GetLayoutObject() : nullptr;
550 if (layout_object && frame_->View()) {
551 PaintLayer* layer = layout_object->EnclosingLayer();
552 in_resizer = layer->GetScrollableArea() &&
553 layer->GetScrollableArea()->IsPointInResizeControl(
554 result.RoundedPointInMainFrame(), kResizerForPointer);
555 }
556
557 // During selection, use an I-beam no matter what we're over. 566 // During selection, use an I-beam no matter what we're over.
558 // If a drag may be starting or we're capturing mouse events for a particular 567 // If a drag may be starting or we're capturing mouse events for a particular
559 // node, don't treat this as a selection. 568 // node, don't treat this as a selection. Note calling
569 // ComputeVisibleSelectionInDOMTreeDeprecated may update layout.
560 if (mouse_event_manager_->MousePressed() && 570 if (mouse_event_manager_->MousePressed() &&
561 GetSelectionController().MouseDownMayStartSelect() && 571 GetSelectionController().MouseDownMayStartSelect() &&
562 !mouse_event_manager_->MouseDownMayStartDrag() && 572 !mouse_event_manager_->MouseDownMayStartDrag() &&
563 !frame_->Selection() 573 !frame_->Selection()
564 .ComputeVisibleSelectionInDOMTreeDeprecated() 574 .ComputeVisibleSelectionInDOMTreeDeprecated()
565 .IsNone() && 575 .IsNone() &&
566 !capturing_mouse_events_node_) { 576 !capturing_mouse_events_node_) {
567 return i_beam; 577 return i_beam;
568 } 578 }
569 579
570 if ((editable || (layout_object && layout_object->IsText() && 580 if (ShouldShowIBeamForNode(node, result))
571 node->CanStartSelection())) &&
572 !in_resizer && !result.GetScrollbar())
573 return i_beam; 581 return i_beam;
574 return PointerCursor(); 582 return PointerCursor();
575 } 583 }
576 584
577 WebInputEventResult EventHandler::HandleMousePressEvent( 585 WebInputEventResult EventHandler::HandleMousePressEvent(
578 const WebMouseEvent& mouse_event) { 586 const WebMouseEvent& mouse_event) {
579 TRACE_EVENT0("blink", "EventHandler::handleMousePressEvent"); 587 TRACE_EVENT0("blink", "EventHandler::handleMousePressEvent");
580 588
581 // For 4th/5th button in the mouse since Chrome does not yet send 589 // For 4th/5th button in the mouse since Chrome does not yet send
582 // button value to Blink but in some cases it does send the event. 590 // button value to Blink but in some cases it does send the event.
(...skipping 1526 matching lines...) Expand 10 before | Expand all | Expand 10 after
2109 MouseEventWithHitTestResults& mev, 2117 MouseEventWithHitTestResults& mev,
2110 LocalFrame* subframe) { 2118 LocalFrame* subframe) {
2111 WebInputEventResult result = 2119 WebInputEventResult result =
2112 subframe->GetEventHandler().HandleMouseReleaseEvent(mev.Event()); 2120 subframe->GetEventHandler().HandleMouseReleaseEvent(mev.Event());
2113 if (result != WebInputEventResult::kNotHandled) 2121 if (result != WebInputEventResult::kNotHandled)
2114 return result; 2122 return result;
2115 return WebInputEventResult::kHandledSystem; 2123 return WebInputEventResult::kHandledSystem;
2116 } 2124 }
2117 2125
2118 } // namespace blink 2126 } // namespace blink
OLDNEW
« 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