import FIREFOX_52_6_0esr_RELEASE from mozilla-esr52 hg repo

This commit is contained in:
Roy Tam 2018-01-19 03:59:58 +08:00
commit dcd9973243
150858 changed files with 23884658 additions and 0 deletions

View file

@ -0,0 +1,33 @@
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim: set sw=4 ts=8 et 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/. */
#ifndef mozilla_layers_CompositorController_h
#define mozilla_layers_CompositorController_h
#include "mozilla/RefCountType.h" // for MozExternalRefCountType
#include "nscore.h" // for NS_IMETHOD_
namespace mozilla {
namespace layers {
class CompositorController
{
public:
NS_IMETHOD_(MozExternalRefCountType) AddRef() = 0;
NS_IMETHOD_(MozExternalRefCountType) Release() = 0;
virtual void ScheduleRenderOnCompositorThread() = 0;
virtual void ScheduleHideAllPluginWindows() = 0;
virtual void ScheduleShowAllPluginWindows() = 0;
protected:
virtual ~CompositorController() {}
};
} // namespace layers
} // namespace mozilla
#endif // mozilla_layers_CompositorController_h

View file

@ -0,0 +1,179 @@
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim: set sw=4 ts=8 et 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/. */
#ifndef mozilla_layers_GeckoContentController_h
#define mozilla_layers_GeckoContentController_h
#include "FrameMetrics.h" // for FrameMetrics, etc
#include "InputData.h" // for PinchGestureInput
#include "Units.h" // for CSSPoint, CSSRect, etc
#include "mozilla/Assertions.h" // for MOZ_ASSERT_HELPER2
#include "mozilla/EventForwards.h" // for Modifiers
#include "nsISupportsImpl.h"
namespace mozilla {
class Runnable;
namespace layers {
class GeckoContentController
{
public:
NS_INLINE_DECL_THREADSAFE_REFCOUNTING(GeckoContentController)
/**
* Requests a paint of the given FrameMetrics |aFrameMetrics| from Gecko.
* Implementations per-platform are responsible for actually handling this.
*
* This method must always be called on the repaint thread, which depends
* on the GeckoContentController. For ChromeProcessController it is the
* Gecko main thread, while for RemoteContentController it is the compositor
* thread where it can send IPDL messages.
*/
virtual void RequestContentRepaint(const FrameMetrics& aFrameMetrics) = 0;
/**
* Different types of tap-related events that can be sent in
* the HandleTap function. The names should be relatively self-explanatory.
* Note that the eLongTapUp will always be preceded by an eLongTap, but not
* all eLongTap notifications will be followed by an eLongTapUp (for instance,
* if the user moves their finger after triggering the long-tap but before
* lifting it).
* The difference between eDoubleTap and eSecondTap is subtle - the eDoubleTap
* is for an actual double-tap "gesture" while eSecondTap is for the same user
* input but where a double-tap gesture is not allowed. This is used to fire
* a click event with detail=2 to web content (similar to what a mouse double-
* click would do).
*/
enum class TapType {
eSingleTap,
eDoubleTap,
eSecondTap,
eLongTap,
eLongTapUp,
eSentinel,
};
/**
* Requests handling of a tap event. |aPoint| is in LD pixels, relative to the
* current scroll offset.
*/
virtual void HandleTap(TapType aType,
const LayoutDevicePoint& aPoint,
Modifiers aModifiers,
const ScrollableLayerGuid& aGuid,
uint64_t aInputBlockId) = 0;
/**
* When the apz.allow_zooming pref is set to false, the APZ will not
* translate pinch gestures to actual zooming. Instead, it will call this
* method to notify gecko of the pinch gesture, and allow it to deal with it
* however it wishes. Note that this function is not called if the pinch is
* prevented by content calling preventDefault() on the touch events, or via
* use of the touch-action property.
* @param aType One of PINCHGESTURE_START, PINCHGESTURE_SCALE, or
* PINCHGESTURE_END, indicating the phase of the pinch.
* @param aGuid The guid of the APZ that is detecting the pinch. This is
* generally the root APZC for the layers id.
* @param aSpanChange For the START or END event, this is always 0.
* For a SCALE event, this is the difference in span between the
* previous state and the new state.
* @param aModifiers The keyboard modifiers depressed during the pinch.
*/
virtual void NotifyPinchGesture(PinchGestureInput::PinchGestureType aType,
const ScrollableLayerGuid& aGuid,
LayoutDeviceCoord aSpanChange,
Modifiers aModifiers) = 0;
/**
* Schedules a runnable to run on the controller/UI thread at some time
* in the future.
* This method must always be called on the controller thread.
*/
virtual void PostDelayedTask(already_AddRefed<Runnable> aRunnable, int aDelayMs) = 0;
/**
* Returns true if we are currently on the thread that can send repaint requests.
*/
virtual bool IsRepaintThread() = 0;
/**
* Runs the given task on the "repaint" thread.
*/
virtual void DispatchToRepaintThread(already_AddRefed<Runnable> aTask) = 0;
enum class APZStateChange {
/**
* APZ started modifying the view (including panning, zooming, and fling).
*/
eTransformBegin,
/**
* APZ finished modifying the view.
*/
eTransformEnd,
/**
* APZ started a touch.
* |aArg| is 1 if touch can be a pan, 0 otherwise.
*/
eStartTouch,
/**
* APZ started a pan.
*/
eStartPanning,
/**
* APZ finished processing a touch.
* |aArg| is 1 if touch was a click, 0 otherwise.
*/
eEndTouch,
// Sentinel value for IPC, this must be the last item in the enum and
// should not be used as an actual message value.
eSentinel
};
/**
* General notices of APZ state changes for consumers.
* |aGuid| identifies the APZC originating the state change.
* |aChange| identifies the type of state change
* |aArg| is used by some state changes to pass extra information (see
* the documentation for each state change above)
*/
virtual void NotifyAPZStateChange(const ScrollableLayerGuid& aGuid,
APZStateChange aChange,
int aArg = 0) {}
/**
* Notify content of a MozMouseScrollFailed event.
*/
virtual void NotifyMozMouseScrollEvent(const FrameMetrics::ViewID& aScrollId, const nsString& aEvent)
{}
/**
* Notify content that the repaint requests have been flushed.
*/
virtual void NotifyFlushComplete() = 0;
virtual void UpdateOverscrollVelocity(float aX, float aY, bool aIsRootContent) {}
virtual void UpdateOverscrollOffset(float aX, float aY, bool aIsRootContent) {}
virtual void SetScrollingRootContent(bool isRootContent) {}
GeckoContentController() {}
/**
* Needs to be called on the main thread.
*/
virtual void Destroy() {}
protected:
// Protected destructor, to discourage deletion outside of Release():
virtual ~GeckoContentController() {}
};
} // namespace layers
} // namespace mozilla
#endif // mozilla_layers_GeckoContentController_h

View file

@ -0,0 +1,164 @@
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/* vim: set ts=8 sts=2 et sw=2 tw=99: */
/* 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 "mozilla/layers/IAPZCTreeManager.h"
#include "gfxPrefs.h" // for gfxPrefs
#include "InputData.h" // for InputData, etc
#include "mozilla/EventStateManager.h" // for WheelPrefs
#include "mozilla/layers/APZThreadUtils.h" // for AssertOnCompositorThread, etc
#include "mozilla/MouseEvents.h" // for WidgetMouseEvent
#include "mozilla/TouchEvents.h" // for WidgetTouchEvent
namespace mozilla {
namespace layers {
static bool
WillHandleMouseEvent(const WidgetMouseEventBase& aEvent)
{
return aEvent.mMessage == eMouseMove ||
aEvent.mMessage == eMouseDown ||
aEvent.mMessage == eMouseUp ||
aEvent.mMessage == eDragEnd;
}
// Returns whether or not a wheel event action will be (or was) performed by
// APZ. If this returns true, the event must not perform a synchronous
// scroll.
//
// Even if this returns false, all wheel events in APZ-aware widgets must
// be sent through APZ so they are transformed correctly for TabParent.
static bool
WillHandleWheelEvent(WidgetWheelEvent* aEvent)
{
return EventStateManager::WheelEventIsScrollAction(aEvent) &&
(aEvent->mDeltaMode == nsIDOMWheelEvent::DOM_DELTA_LINE ||
aEvent->mDeltaMode == nsIDOMWheelEvent::DOM_DELTA_PIXEL ||
aEvent->mDeltaMode == nsIDOMWheelEvent::DOM_DELTA_PAGE);
}
nsEventStatus
IAPZCTreeManager::ReceiveInputEvent(
WidgetInputEvent& aEvent,
ScrollableLayerGuid* aOutTargetGuid,
uint64_t* aOutInputBlockId)
{
APZThreadUtils::AssertOnControllerThread();
// Initialize aOutInputBlockId to a sane value, and then later we overwrite
// it if the input event goes into a block.
if (aOutInputBlockId) {
*aOutInputBlockId = 0;
}
switch (aEvent.mClass) {
case eMouseEventClass:
case eDragEventClass: {
WidgetMouseEvent& mouseEvent = *aEvent.AsMouseEvent();
// Note, we call this before having transformed the reference point.
if (mouseEvent.IsReal()) {
UpdateWheelTransaction(mouseEvent.mRefPoint, mouseEvent.mMessage);
}
if (WillHandleMouseEvent(mouseEvent)) {
MouseInput input(mouseEvent);
input.mOrigin = ScreenPoint(mouseEvent.mRefPoint.x, mouseEvent.mRefPoint.y);
nsEventStatus status = ReceiveInputEvent(input, aOutTargetGuid, aOutInputBlockId);
mouseEvent.mRefPoint.x = input.mOrigin.x;
mouseEvent.mRefPoint.y = input.mOrigin.y;
mouseEvent.mFlags.mHandledByAPZ = input.mHandledByAPZ;
return status;
}
TransformEventRefPoint(&mouseEvent.mRefPoint, aOutTargetGuid);
return nsEventStatus_eIgnore;
}
case eTouchEventClass: {
WidgetTouchEvent& touchEvent = *aEvent.AsTouchEvent();
MultiTouchInput touchInput(touchEvent);
nsEventStatus result = ReceiveInputEvent(touchInput, aOutTargetGuid, aOutInputBlockId);
// touchInput was modified in-place to possibly remove some
// touch points (if we are overscrolled), and the coordinates were
// modified using the APZ untransform. We need to copy these changes
// back into the WidgetInputEvent.
touchEvent.mTouches.Clear();
touchEvent.mTouches.SetCapacity(touchInput.mTouches.Length());
for (size_t i = 0; i < touchInput.mTouches.Length(); i++) {
*touchEvent.mTouches.AppendElement() =
touchInput.mTouches[i].ToNewDOMTouch();
}
touchEvent.mFlags.mHandledByAPZ = touchInput.mHandledByAPZ;
return result;
}
case eWheelEventClass: {
WidgetWheelEvent& wheelEvent = *aEvent.AsWheelEvent();
if (WillHandleWheelEvent(&wheelEvent)) {
ScrollWheelInput::ScrollMode scrollMode = ScrollWheelInput::SCROLLMODE_INSTANT;
if (gfxPrefs::SmoothScrollEnabled() &&
((wheelEvent.mDeltaMode == nsIDOMWheelEvent::DOM_DELTA_LINE &&
gfxPrefs::WheelSmoothScrollEnabled()) ||
(wheelEvent.mDeltaMode == nsIDOMWheelEvent::DOM_DELTA_PAGE &&
gfxPrefs::PageSmoothScrollEnabled())))
{
scrollMode = ScrollWheelInput::SCROLLMODE_SMOOTH;
}
ScreenPoint origin(wheelEvent.mRefPoint.x, wheelEvent.mRefPoint.y);
ScrollWheelInput input(wheelEvent.mTime, wheelEvent.mTimeStamp, 0,
scrollMode,
ScrollWheelInput::DeltaTypeForDeltaMode(
wheelEvent.mDeltaMode),
origin,
wheelEvent.mDeltaX, wheelEvent.mDeltaY,
wheelEvent.mAllowToOverrideSystemScrollSpeed);
// We add the user multiplier as a separate field, rather than premultiplying
// it, because if the input is converted back to a WidgetWheelEvent, then
// EventStateManager would apply the delta a second time. We could in theory
// work around this by asking ESM to customize the event much sooner, and
// then save the "mCustomizedByUserPrefs" bit on ScrollWheelInput - but for
// now, this seems easier.
EventStateManager::GetUserPrefsForWheelEvent(&wheelEvent,
&input.mUserDeltaMultiplierX,
&input.mUserDeltaMultiplierY);
nsEventStatus status = ReceiveInputEvent(input, aOutTargetGuid, aOutInputBlockId);
wheelEvent.mRefPoint.x = input.mOrigin.x;
wheelEvent.mRefPoint.y = input.mOrigin.y;
wheelEvent.mFlags.mHandledByAPZ = input.mHandledByAPZ;
return status;
}
UpdateWheelTransaction(aEvent.mRefPoint, aEvent.mMessage);
TransformEventRefPoint(&aEvent.mRefPoint, aOutTargetGuid);
return nsEventStatus_eIgnore;
}
default: {
UpdateWheelTransaction(aEvent.mRefPoint, aEvent.mMessage);
TransformEventRefPoint(&aEvent.mRefPoint, aOutTargetGuid);
return nsEventStatus_eIgnore;
}
}
MOZ_ASSERT_UNREACHABLE("Invalid WidgetInputEvent type.");
return nsEventStatus_eConsumeNoDefault;
}
} // namespace layers
} // namespace mozilla

View file

@ -0,0 +1,223 @@
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/* vim: set ts=8 sts=2 et sw=2 tw=99: */
/* 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/. */
#ifndef mozilla_layers_IAPZCTreeManager_h
#define mozilla_layers_IAPZCTreeManager_h
#include <stdint.h> // for uint64_t, uint32_t
#include "FrameMetrics.h" // for FrameMetrics, etc
#include "mozilla/EventForwards.h" // for WidgetInputEvent, nsEventStatus
#include "mozilla/layers/APZUtils.h" // for HitTestResult
#include "nsTArrayForwardDeclare.h" // for nsTArray, nsTArray_Impl, etc
#include "nsISupportsImpl.h" // for MOZ_COUNT_CTOR, etc
#include "Units.h" // for CSSPoint, CSSRect, etc
namespace mozilla {
class InputData;
namespace layers {
enum AllowedTouchBehavior {
NONE = 0,
VERTICAL_PAN = 1 << 0,
HORIZONTAL_PAN = 1 << 1,
PINCH_ZOOM = 1 << 2,
DOUBLE_TAP_ZOOM = 1 << 3,
UNKNOWN = 1 << 4
};
enum ZoomToRectBehavior : uint32_t {
DEFAULT_BEHAVIOR = 0,
DISABLE_ZOOM_OUT = 1 << 0,
PAN_INTO_VIEW_ONLY = 1 << 1,
ONLY_ZOOM_TO_DEFAULT_SCALE = 1 << 2
};
class AsyncDragMetrics;
class IAPZCTreeManager {
NS_INLINE_DECL_THREADSAFE_VIRTUAL_REFCOUNTING(IAPZCTreeManager)
public:
/**
* General handler for incoming input events. Manipulates the frame metrics
* based on what type of input it is. For example, a PinchGestureEvent will
* cause scaling. This should only be called externally to this class, and
* must be called on the controller thread.
*
* This function transforms |aEvent| to have its coordinates in DOM space.
* This is so that the event can be passed through the DOM and content can
* handle them. The event may need to be converted to a WidgetInputEvent
* by the caller if it wants to do this.
*
* The following values may be returned by this function:
* nsEventStatus_eConsumeNoDefault is returned to indicate the
* APZ is consuming this event and the caller should discard the event with
* extreme prejudice. The exact scenarios under which this is returned is
* implementation-dependent and may vary.
* nsEventStatus_eIgnore is returned to indicate that the APZ code didn't
* use this event. This might be because it was directed at a point on
* the screen where there was no APZ, or because the thing the user was
* trying to do was not allowed. (For example, attempting to pan a
* non-pannable document).
* nsEventStatus_eConsumeDoDefault is returned to indicate that the APZ
* code may have used this event to do some user-visible thing. Note that
* in some cases CONSUMED is returned even if the event was NOT used. This
* is because we cannot always know at the time of event delivery whether
* the event will be used or not. So we err on the side of sending
* CONSUMED when we are uncertain.
*
* @param aEvent input event object; is modified in-place
* @param aOutTargetGuid returns the guid of the apzc this event was
* delivered to. May be null.
* @param aOutInputBlockId returns the id of the input block that this event
* was added to, if that was the case. May be null.
*/
virtual nsEventStatus ReceiveInputEvent(
InputData& aEvent,
ScrollableLayerGuid* aOutTargetGuid,
uint64_t* aOutInputBlockId) = 0;
/**
* WidgetInputEvent handler. Transforms |aEvent| (which is assumed to be an
* already-existing instance of an WidgetInputEvent which may be an
* WidgetTouchEvent) to have its coordinates in DOM space. This is so that the
* event can be passed through the DOM and content can handle them.
*
* NOTE: Be careful of invoking the WidgetInputEvent variant. This can only be
* called on the main thread. See widget/InputData.h for more information on
* why we have InputData and WidgetInputEvent separated. If this function is
* used, the controller thread must be the main thread, or undefined behaviour
* may occur.
* NOTE: On unix, mouse events are treated as touch and are forwarded
* to the appropriate apz as such.
*
* See documentation for other ReceiveInputEvent above.
*/
nsEventStatus ReceiveInputEvent(
WidgetInputEvent& aEvent,
ScrollableLayerGuid* aOutTargetGuid,
uint64_t* aOutInputBlockId);
/**
* Kicks an animation to zoom to a rect. This may be either a zoom out or zoom
* in. The actual animation is done on the compositor thread after being set
* up. |aRect| must be given in CSS pixels, relative to the document.
* |aFlags| is a combination of the ZoomToRectBehavior enum values.
*/
virtual void ZoomToRect(
const ScrollableLayerGuid& aGuid,
const CSSRect& aRect,
const uint32_t aFlags = DEFAULT_BEHAVIOR) = 0;
/**
* If we have touch listeners, this should always be called when we know
* definitively whether or not content has preventDefaulted any touch events
* that have come in. If |aPreventDefault| is true, any touch events in the
* queue will be discarded. This function must be called on the controller
* thread.
*/
virtual void ContentReceivedInputBlock(
uint64_t aInputBlockId,
bool aPreventDefault) = 0;
/**
* When the event regions code is enabled, this function should be invoked to
* to confirm the target of the input block. This is only needed in cases
* where the initial input event of the block hit a dispatch-to-content region
* but is safe to call for all input blocks. This function should always be
* invoked on the controller thread.
* The different elements in the array of targets correspond to the targets
* for the different touch points. In the case where the touch point has no
* target, or the target is not a scrollable frame, the target's |mScrollId|
* should be set to FrameMetrics::NULL_SCROLL_ID.
*/
virtual void SetTargetAPZC(
uint64_t aInputBlockId,
const nsTArray<ScrollableLayerGuid>& aTargets) = 0;
/**
* Updates any zoom constraints contained in the <meta name="viewport"> tag.
* If the |aConstraints| is Nothing() then previously-provided constraints for
* the given |aGuid| are cleared.
*/
virtual void UpdateZoomConstraints(
const ScrollableLayerGuid& aGuid,
const Maybe<ZoomConstraints>& aConstraints) = 0;
/**
* Cancels any currently running animation. Note that all this does is set the
* state of the AsyncPanZoomController back to NOTHING, but it is the
* animation's responsibility to check this before advancing.
*/
virtual void CancelAnimation(const ScrollableLayerGuid &aGuid) = 0;
/**
* Adjusts the root APZC to compensate for a shift in the surface. See the
* documentation on AsyncPanZoomController::AdjustScrollForSurfaceShift for
* some more details. This is only currently needed due to surface shifts
* caused by the dynamic toolbar on Android.
*/
virtual void AdjustScrollForSurfaceShift(const ScreenPoint& aShift) = 0;
virtual void SetDPI(float aDpiValue) = 0;
/**
* Sets allowed touch behavior values for current touch-session for specific
* input block (determined by aInputBlock).
* Should be invoked by the widget. Each value of the aValues arrays
* corresponds to the different touch point that is currently active.
* Must be called after receiving the TOUCH_START event that starts the
* touch-session.
* This must be called on the controller thread.
*/
virtual void SetAllowedTouchBehavior(
uint64_t aInputBlockId,
const nsTArray<TouchBehaviorFlags>& aValues) = 0;
virtual void StartScrollbarDrag(
const ScrollableLayerGuid& aGuid,
const AsyncDragMetrics& aDragMetrics) = 0;
/**
* Function used to disable LongTap gestures.
*
* On slow running tests, drags and touch events can be misinterpreted
* as a long tap. This allows tests to disable long tap gesture detection.
*/
virtual void SetLongTapEnabled(bool aTapGestureEnabled) = 0;
/**
* Process touch velocity.
* Sometimes the touch move event will have a velocity even though no scrolling
* is occurring such as when the toolbar is being hidden/shown in Fennec.
* This function can be called to have the y axis' velocity queue updated.
*/
virtual void ProcessTouchVelocity(uint32_t aTimestampMs, float aSpeedY) = 0;
protected:
// Methods to help process WidgetInputEvents (or manage conversion to/from InputData)
virtual void TransformEventRefPoint(
LayoutDeviceIntPoint* aRefPoint,
ScrollableLayerGuid* aOutTargetGuid) = 0;
virtual void UpdateWheelTransaction(
LayoutDeviceIntPoint aRefPoint,
EventMessage aEventMessage) = 0;
// Discourage destruction outside of decref
virtual ~IAPZCTreeManager() { }
};
} // namespace layers
} // namespace mozilla
#endif // mozilla_layers_IAPZCTreeManager_h

View file

@ -0,0 +1,40 @@
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim: set sw=4 ts=8 et 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/. */
#ifndef mozilla_layers_MetricsSharingController_h
#define mozilla_layers_MetricsSharingController_h
#include "FrameMetrics.h" // for FrameMetrics
#include "mozilla/ipc/CrossProcessMutex.h" // for CrossProcessMutexHandle
#include "mozilla/ipc/SharedMemoryBasic.h" // for SharedMemoryBasic
#include "mozilla/RefCountType.h" // for MozExternalRefCountType
#include "nscore.h" // for NS_IMETHOD_
namespace mozilla {
namespace layers {
class MetricsSharingController
{
public:
NS_IMETHOD_(MozExternalRefCountType) AddRef() = 0;
NS_IMETHOD_(MozExternalRefCountType) Release() = 0;
virtual base::ProcessId RemotePid() = 0;
virtual bool StartSharingMetrics(mozilla::ipc::SharedMemoryBasic::Handle aHandle,
CrossProcessMutexHandle aMutexHandle,
uint64_t aLayersId,
uint32_t aApzcId) = 0;
virtual bool StopSharingMetrics(FrameMetrics::ViewID aScrollId,
uint32_t aApzcId) = 0;
protected:
virtual ~MetricsSharingController() {}
};
} // namespace layers
} // namespace mozilla
#endif // mozilla_layers_MetricsSharingController_h