Commit 71552a7a authored by bratell's avatar bratell Committed by Commit bot

Merge two IsInDocument implementations.

There were two helper functions IsInDocument implementations in
core/input and this moves them to EventHandlingUtil so they can
be shared.

R=dtapuska@chromium.org

Review-Url: https://codereview.chromium.org/2845973002
Cr-Commit-Position: refs/heads/master@{#467684}
parent 1c6df461
......@@ -6,18 +6,15 @@
#include "core/dom/Node.h"
#include "core/dom/shadow/FlatTreeTraversal.h"
#include "core/input/EventHandlingUtil.h"
namespace blink {
namespace {
bool IsInDocument(EventTarget* target) {
return target && target->ToNode() && target->ToNode()->isConnected();
}
void BuildAncestorChain(EventTarget* target,
HeapVector<Member<Node>, 20>* ancestors) {
if (!IsInDocument(target))
if (!EventHandlingUtil::IsInDocument(target))
return;
Node* target_node = target->ToNode();
DCHECK(target_node);
......@@ -65,7 +62,7 @@ void BoundaryEventDispatcher::SendBoundaryEvents(EventTarget* exited_target,
return;
// Dispatch out event
if (IsInDocument(exited_target))
if (EventHandlingUtil::IsInDocument(exited_target))
DispatchOut(exited_target, entered_target);
// Create lists of all exited/entered ancestors, locate the common ancestor
......@@ -115,7 +112,7 @@ void BoundaryEventDispatcher::SendBoundaryEvents(EventTarget* exited_target,
!exited_node_has_capturing_ancestor);
// Dispatch over event
if (IsInDocument(entered_target))
if (EventHandlingUtil::IsInDocument(entered_target))
DispatchOver(entered_target, exited_target);
// Defer locating capturing enter listener until /after/ dispatching the leave
......
......@@ -83,6 +83,10 @@ PaintLayer* LayerForNode(Node* node) {
return layer;
}
bool IsInDocument(EventTarget* n) {
return n && n->ToNode() && n->ToNode()->isConnected();
}
ScrollableArea* AssociatedScrollableArea(const PaintLayer* layer) {
if (PaintLayerScrollableArea* scrollable_area = layer->GetScrollableArea()) {
if (scrollable_area->ScrollsOverflow())
......
......@@ -31,6 +31,8 @@ WebInputEventResult ToWebInputEventResult(DispatchEventResult);
PaintLayer* LayerForNode(Node*);
ScrollableArea* AssociatedScrollableArea(const PaintLayer*);
bool IsInDocument(EventTarget*);
ContainerNode* ParentForClickEvent(const Node&);
LayoutPoint ContentPointFromRootFrame(LocalFrame*,
......
......@@ -29,10 +29,6 @@ size_t ToPointerTypeIndex(WebPointerProperties::PointerType t) {
return static_cast<size_t>(t);
}
bool IsInDocument(EventTarget* n) {
return n && n->ToNode() && n->ToNode()->isConnected();
}
Vector<std::pair<WebTouchPoint, TimeTicks>> GetCoalescedPoints(
const Vector<WebTouchEvent>& coalesced_events,
int id) {
......@@ -496,10 +492,11 @@ WebInputEventResult PointerEventManager::SendMousePointerEvent(
EventTarget* mouse_target = effective_target;
// Event path could be null if pointer event is not dispatched and
// that happens for example when pointer event feature is not enabled.
if (!IsInDocument(mouse_target) && pointer_event->HasEventPath()) {
if (!EventHandlingUtil::IsInDocument(mouse_target) &&
pointer_event->HasEventPath()) {
for (const auto& context :
pointer_event->GetEventPath().NodeEventContexts()) {
if (IsInDocument(context.GetNode())) {
if (EventHandlingUtil::IsInDocument(context.GetNode())) {
mouse_target = context.GetNode();
break;
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment