Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 Loading... | |
| 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 ShowIBeamForNode(const Node* node, const HitTestResult& result) { | |
|
jbroman
2017/04/28 15:35:48
nit: not clear if this function shows it or is sim
dtapuska
2017/04/28 15:47:35
Done.
| |
| 122 if (!node || result.GetScrollbar()) | |
|
jbroman
2017/04/28 15:35:48
nit: the caller already checks for GetScrollbar, I
dtapuska
2017/04/28 15:47:35
Done.
| |
| 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 Loading... | |
| 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. |
| 560 if (mouse_event_manager_->MousePressed() && | 569 if (mouse_event_manager_->MousePressed() && |
|
jbroman
2017/04/28 15:35:49
nit: consider comment that this causes layout to a
dtapuska
2017/04/28 15:47:35
Done.
| |
| 561 GetSelectionController().MouseDownMayStartSelect() && | 570 GetSelectionController().MouseDownMayStartSelect() && |
| 562 !mouse_event_manager_->MouseDownMayStartDrag() && | 571 !mouse_event_manager_->MouseDownMayStartDrag() && |
| 563 !frame_->Selection() | 572 !frame_->Selection() |
| 564 .ComputeVisibleSelectionInDOMTreeDeprecated() | 573 .ComputeVisibleSelectionInDOMTreeDeprecated() |
| 565 .IsNone() && | 574 .IsNone() && |
| 566 !capturing_mouse_events_node_) { | 575 !capturing_mouse_events_node_) { |
| 567 return i_beam; | 576 return i_beam; |
| 568 } | 577 } |
| 569 | 578 |
| 570 if ((editable || (layout_object && layout_object->IsText() && | 579 if (ShowIBeamForNode(node, result)) |
| 571 node->CanStartSelection())) && | |
| 572 !in_resizer && !result.GetScrollbar()) | |
| 573 return i_beam; | 580 return i_beam; |
| 574 return PointerCursor(); | 581 return PointerCursor(); |
| 575 } | 582 } |
| 576 | 583 |
| 577 WebInputEventResult EventHandler::HandleMousePressEvent( | 584 WebInputEventResult EventHandler::HandleMousePressEvent( |
| 578 const WebMouseEvent& mouse_event) { | 585 const WebMouseEvent& mouse_event) { |
| 579 TRACE_EVENT0("blink", "EventHandler::handleMousePressEvent"); | 586 TRACE_EVENT0("blink", "EventHandler::handleMousePressEvent"); |
| 580 | 587 |
| 581 // For 4th/5th button in the mouse since Chrome does not yet send | 588 // 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. | 589 // 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 Loading... | |
| 2109 MouseEventWithHitTestResults& mev, | 2116 MouseEventWithHitTestResults& mev, |
| 2110 LocalFrame* subframe) { | 2117 LocalFrame* subframe) { |
| 2111 WebInputEventResult result = | 2118 WebInputEventResult result = |
| 2112 subframe->GetEventHandler().HandleMouseReleaseEvent(mev.Event()); | 2119 subframe->GetEventHandler().HandleMouseReleaseEvent(mev.Event()); |
| 2113 if (result != WebInputEventResult::kNotHandled) | 2120 if (result != WebInputEventResult::kNotHandled) |
| 2114 return result; | 2121 return result; |
| 2115 return WebInputEventResult::kHandledSystem; | 2122 return WebInputEventResult::kHandledSystem; |
| 2116 } | 2123 } |
| 2117 | 2124 |
| 2118 } // namespace blink | 2125 } // namespace blink |
| OLD | NEW |