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

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

Issue 2809333002: WIP Logging for Contextual Search: Node->Element. (Closed)
Patch Set: 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
Index: third_party/WebKit/Source/core/input/MouseEventManager.cpp
diff --git a/third_party/WebKit/Source/core/input/MouseEventManager.cpp b/third_party/WebKit/Source/core/input/MouseEventManager.cpp
index ea204d0016d5ff04befd546cf3e5d6fee1e68c65..0fdac204dbb17312cbf30aff7ae8f92c776ef820 100644
--- a/third_party/WebKit/Source/core/input/MouseEventManager.cpp
+++ b/third_party/WebKit/Source/core/input/MouseEventManager.cpp
@@ -94,7 +94,7 @@ void MouseEventManager::Clear() {
last_known_mouse_global_position_ = IntPoint();
mouse_pressed_ = false;
click_count_ = 0;
- click_node_ = nullptr;
+ click_element_ = nullptr;
mouse_down_pos_ = IntPoint();
mouse_down_timestamp_ = TimeTicks();
mouse_down_ = WebMouseEvent();
@@ -111,7 +111,7 @@ DEFINE_TRACE(MouseEventManager) {
visitor->Trace(scroll_manager_);
visitor->Trace(node_under_mouse_);
visitor->Trace(mouse_press_node_);
- visitor->Trace(click_node_);
+ visitor->Trace(click_element_);
SynchronousMutationObserver::Trace(visitor);
}
@@ -232,7 +232,8 @@ WebInputEventResult MouseEventManager::SetMousePositionAndDispatchMouseEvent(
}
WebInputEventResult MouseEventManager::DispatchMouseClickIfNeeded(
- const MouseEventWithHitTestResults& mev) {
+ const MouseEventWithHitTestResults& mev,
+ Element& mouse_release_target) {
// We only prevent click event when the click may cause contextmenu to popup.
// However, we always send auxclick.
bool context_menu_event =
@@ -247,40 +248,39 @@ WebInputEventResult MouseEventManager::DispatchMouseClickIfNeeded(
context_menu_event = true;
#endif
- WebInputEventResult click_event_result = WebInputEventResult::kNotHandled;
const bool should_dispatch_click_event =
- click_count_ > 0 && !context_menu_event && mev.InnerNode() &&
- click_node_ && mev.InnerNode()->CanParticipateInFlatTree() &&
- click_node_->CanParticipateInFlatTree() &&
+ click_count_ > 0 && !context_menu_event && click_element_ &&
+ mouse_release_target.CanParticipateInFlatTree() &&
+ click_element_->CanParticipateInFlatTree() &&
!(frame_->GetEventHandler()
.GetSelectionController()
.HasExtendedSelection() &&
IsLinkSelection(mev));
- if (should_dispatch_click_event) {
- Node* click_target_node = nullptr;
+ if (!should_dispatch_click_event)
+ return WebInputEventResult::kNotHandled;
+
+ Node* click_target_node = nullptr;
+ if (click_element_ == mouse_release_target) {
+ click_target_node = click_element_;
+ } else if (click_element_->GetDocument() ==
+ mouse_release_target.GetDocument()) {
// Updates distribution because a 'mouseup' event listener can make the
// tree dirty at dispatchMouseEvent() invocation above.
// Unless distribution is updated, commonAncestor would hit ASSERT.
- if (click_node_ == mev.InnerNode()) {
- click_target_node = click_node_;
- click_target_node->UpdateDistribution();
- } else if (click_node_->GetDocument() == mev.InnerNode()->GetDocument()) {
- click_node_->UpdateDistribution();
- mev.InnerNode()->UpdateDistribution();
- click_target_node = mev.InnerNode()->CommonAncestor(
- *click_node_, EventHandlingUtil::ParentForClickEvent);
- }
- if (click_target_node) {
- click_event_result = DispatchMouseEvent(
- click_target_node,
- !RuntimeEnabledFeatures::auxclickEnabled() ||
- (mev.Event().button == WebPointerProperties::Button::kLeft)
- ? EventTypeNames::click
- : EventTypeNames::auxclick,
- mev.Event(), mev.CanvasRegionId(), nullptr);
- }
+ click_element_->UpdateDistribution();
+ mouse_release_target.UpdateDistribution();
+ click_target_node = mouse_release_target.CommonAncestor(
+ *click_element_, EventHandlingUtil::ParentForClickEvent);
}
- return click_event_result;
+ if (!click_target_node)
+ return WebInputEventResult::kNotHandled;
+ return DispatchMouseEvent(
+ click_target_node,
+ !RuntimeEnabledFeatures::auxclickEnabled() ||
+ (mev.Event().button == WebPointerProperties::Button::kLeft)
+ ? EventTypeNames::click
+ : EventTypeNames::auxclick,
+ mev.Event(), mev.CanvasRegionId(), nullptr);
}
void MouseEventManager::FakeMouseMoveEventTimerFired(TimerBase* timer) {
@@ -381,19 +381,19 @@ void MouseEventManager::SetNodeUnderMouse(
}
void MouseEventManager::NodeChildrenWillBeRemoved(ContainerNode& container) {
- if (container == click_node_)
+ if (container == click_element_)
return;
- if (!container.IsShadowIncludingInclusiveAncestorOf(click_node_.Get()))
+ if (!container.IsShadowIncludingInclusiveAncestorOf(click_element_.Get()))
return;
- click_node_ = nullptr;
+ click_element_ = nullptr;
}
void MouseEventManager::NodeWillBeRemoved(Node& node_to_be_removed) {
if (node_to_be_removed.IsShadowIncludingInclusiveAncestorOf(
- click_node_.Get())) {
+ click_element_.Get())) {
// We don't dispatch click events if the mousedown node is removed
// before a mouseup event. It is compatible with IE and Firefox.
- click_node_ = nullptr;
+ click_element_ = nullptr;
}
}
@@ -1005,7 +1005,7 @@ bool MouseEventManager::HandleSvgPanIfNeeded(bool is_release_event) {
void MouseEventManager::InvalidateClick() {
click_count_ = 0;
- click_node_ = nullptr;
+ click_element_ = nullptr;
}
bool MouseEventManager::MousePressed() {
@@ -1032,9 +1032,11 @@ void MouseEventManager::SetMousePressNode(Node* node) {
mouse_press_node_ = node;
}
-void MouseEventManager::SetClickNode(Node* node) {
- SetContext(node ? node->ownerDocument() : nullptr);
- click_node_ = node;
+void MouseEventManager::SetClickElement(Element* element) {
+ // // TODO: Call NonTextParentElement internally
+ // DCHECK(!node || !node->IsTextNode());
+ SetContext(element ? element->ownerDocument() : nullptr);
+ click_element_ = element;
}
void MouseEventManager::SetClickCount(int click_count) {

Powered by Google App Engine
This is Rietveld 408576698