/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* vim: set ts=8 sts=2 et sw=2 tw=80: */ /* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ #include "PositionedEventTargeting.h" #include "mozilla/EventListenerManager.h" #include "mozilla/EventStates.h" #include "mozilla/MouseEvents.h" #include "mozilla/Preferences.h" #include "mozilla/PresShell.h" #include "mozilla/StaticPrefs_dom.h" #include "mozilla/StaticPrefs_ui.h" #include "mozilla/ToString.h" #include "mozilla/dom/MouseEventBinding.h" #include "nsFrameList.h" // for DEBUG_FRAME_DUMP #include "nsHTMLParts.h" #include "nsLayoutUtils.h" #include "nsGkAtoms.h" #include "nsFontMetrics.h" #include "nsPrintfCString.h" #include "mozilla/dom/Element.h" #include "nsRegion.h" #include "nsDeviceContext.h" #include "nsIContentInlines.h" #include "nsIFrame.h" #include using namespace mozilla; using namespace mozilla::dom; // If debugging this code you may wish to enable this logging, via // the env var MOZ_LOG="event.retarget:4". For extra logging (getting // frame dumps, use MOZ_LOG="event.retarget:5". static mozilla::LazyLogModule sEvtTgtLog("event.retarget"); #define PET_LOG(...) MOZ_LOG(sEvtTgtLog, LogLevel::Debug, (__VA_ARGS__)) namespace mozilla { /* * The basic goal of FindFrameTargetedByInputEvent() is to find a good * target element that can respond to mouse events. Both mouse events and touch * events are targeted at this element. Note that even for touch events, we * check responsiveness to mouse events. We assume Web authors * designing for touch events will take their own steps to account for * inaccurate touch events. * * GetClickableAncestor() encapsulates the heuristic that determines whether an * element is expected to respond to mouse events. An element is deemed * "clickable" if it has registered listeners for "click", "mousedown" or * "mouseup", or is on a whitelist of element tags (,