mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-25 05:41:12 +00:00
merge autoland to mozilla-central. r=merge a=merge
MozReview-Commit-ID: 3D21HjGG3i4
This commit is contained in:
commit
55e6971a70
@ -10,6 +10,7 @@
|
||||
# instead of BrandFullName and typically should not be modified.
|
||||
!define BrandFullNameInternal "Firefox Developer Edition"
|
||||
!define BrandShortName "Firefox Developer Edition"
|
||||
!define BrandFullName "Firefox Developer Edition"
|
||||
!define CompanyName "mozilla.org"
|
||||
!define URLInfoAbout "https://www.mozilla.org"
|
||||
!define HelpLink "https://support.mozilla.org"
|
||||
|
@ -9,6 +9,7 @@
|
||||
# BrandFullNameInternal is used for some registry and file system values
|
||||
# instead of BrandFullName and typically should not be modified.
|
||||
!define BrandFullNameInternal "Nightly"
|
||||
!define BrandFullName "Firefox Nightly"
|
||||
!define CompanyName "mozilla.org"
|
||||
!define URLInfoAbout "https://www.mozilla.org"
|
||||
!define HelpLink "https://support.mozilla.org"
|
||||
|
@ -2,4 +2,4 @@
|
||||
# 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/.
|
||||
|
||||
MOZ_APP_DISPLAYNAME=Nightly
|
||||
MOZ_APP_DISPLAYNAME=FirefoxNightly
|
||||
|
@ -3,7 +3,7 @@
|
||||
- file, You can obtain one at http://mozilla.org/MPL/2.0/. -->
|
||||
|
||||
<!ENTITY brandShorterName "Nightly">
|
||||
<!ENTITY brandShortName "Nightly">
|
||||
<!ENTITY brandFullName "Nightly">
|
||||
<!ENTITY brandShortName "Firefox Nightly">
|
||||
<!ENTITY brandFullName "Firefox Nightly">
|
||||
<!ENTITY vendorShortName "Mozilla">
|
||||
<!ENTITY trademarkInfo.part1 " ">
|
||||
|
@ -3,8 +3,8 @@
|
||||
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
|
||||
brandShorterName=Nightly
|
||||
brandShortName=Nightly
|
||||
brandFullName=Nightly
|
||||
brandShortName=Firefox Nightly
|
||||
brandFullName=Firefox Nightly
|
||||
vendorShortName=Mozilla
|
||||
|
||||
syncBrandShortName=Sync
|
||||
|
@ -9,6 +9,7 @@
|
||||
# BrandFullNameInternal is used for some registry and file system values
|
||||
# instead of BrandFullName and typically should not be modified.
|
||||
!define BrandFullNameInternal "Mozilla Firefox"
|
||||
!define BrandFullName "Mozilla Firefox"
|
||||
!define CompanyName "Mozilla Corporation"
|
||||
!define URLInfoAbout "https://www.mozilla.org"
|
||||
!define URLUpdateInfo "https://www.mozilla.org/firefox/${AppVersion}/releasenotes"
|
||||
|
@ -9,6 +9,7 @@
|
||||
# BrandFullNameInternal is used for some registry and file system values
|
||||
# instead of BrandFullName and typically should not be modified.
|
||||
!define BrandFullNameInternal "Mozilla Developer Preview"
|
||||
!define BrandFullName "Mozilla Developer Preview"
|
||||
!define CompanyName "mozilla.org"
|
||||
!define URLInfoAbout "https://www.mozilla.org"
|
||||
!define HelpLink "https://support.mozilla.org"
|
||||
|
@ -36,7 +36,6 @@
|
||||
!ifndef DEV_EDITION
|
||||
!define BrandShortName "@MOZ_APP_DISPLAYNAME@"
|
||||
!endif
|
||||
!define BrandFullName "${BrandFullNameInternal}"
|
||||
|
||||
!define CERTIFICATE_NAME "Mozilla Corporation"
|
||||
!define CERTIFICATE_ISSUER "DigiCert SHA2 Assured ID Code Signing CA"
|
||||
|
@ -51,7 +51,9 @@ Var BrandFullName
|
||||
; We keep defines.nsi defined so that we get other things like
|
||||
; the version number, but we redefine BrandFullName
|
||||
!define MaintFullName "Mozilla Maintenance Service"
|
||||
!ifdef BrandFullName
|
||||
!undef BrandFullName
|
||||
!endif
|
||||
!define BrandFullName "${MaintFullName}"
|
||||
|
||||
!include common.nsh
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -21,7 +21,7 @@
|
||||
#include "nsPresContext.h"
|
||||
#include "prtime.h"
|
||||
#include "Units.h"
|
||||
#include "AsyncScrollBase.h"
|
||||
#include "ScrollAnimationPhysics.h"
|
||||
|
||||
namespace mozilla {
|
||||
|
||||
|
@ -729,9 +729,11 @@ child:
|
||||
int32_t aModifiers,
|
||||
bool aPreventDefault);
|
||||
|
||||
async CompositionEvent(WidgetCompositionEvent event);
|
||||
prio(input) async CompositionEvent(WidgetCompositionEvent event);
|
||||
async NormalPriorityCompositionEvent(WidgetCompositionEvent event);
|
||||
|
||||
async SelectionEvent(WidgetSelectionEvent event);
|
||||
prio(input) async SelectionEvent(WidgetSelectionEvent event);
|
||||
async NormalPrioritySelectionEvent(WidgetSelectionEvent event);
|
||||
|
||||
/**
|
||||
* Call PasteTransferable via a controller on the content process
|
||||
|
@ -2114,6 +2114,13 @@ TabChild::RecvCompositionEvent(const WidgetCompositionEvent& aEvent)
|
||||
return IPC_OK();
|
||||
}
|
||||
|
||||
mozilla::ipc::IPCResult
|
||||
TabChild::RecvNormalPriorityCompositionEvent(
|
||||
const WidgetCompositionEvent& aEvent)
|
||||
{
|
||||
return RecvCompositionEvent(aEvent);
|
||||
}
|
||||
|
||||
mozilla::ipc::IPCResult
|
||||
TabChild::RecvSelectionEvent(const WidgetSelectionEvent& aEvent)
|
||||
{
|
||||
@ -2124,6 +2131,12 @@ TabChild::RecvSelectionEvent(const WidgetSelectionEvent& aEvent)
|
||||
return IPC_OK();
|
||||
}
|
||||
|
||||
mozilla::ipc::IPCResult
|
||||
TabChild::RecvNormalPrioritySelectionEvent(const WidgetSelectionEvent& aEvent)
|
||||
{
|
||||
return RecvSelectionEvent(aEvent);
|
||||
}
|
||||
|
||||
mozilla::ipc::IPCResult
|
||||
TabChild::RecvPasteTransferable(const IPCDataTransfer& aDataTransfer,
|
||||
const bool& aIsPrivateData,
|
||||
|
@ -465,9 +465,17 @@ public:
|
||||
virtual mozilla::ipc::IPCResult
|
||||
RecvCompositionEvent(const mozilla::WidgetCompositionEvent& aEvent) override;
|
||||
|
||||
virtual mozilla::ipc::IPCResult
|
||||
RecvNormalPriorityCompositionEvent(
|
||||
const mozilla::WidgetCompositionEvent& aEvent) override;
|
||||
|
||||
virtual mozilla::ipc::IPCResult
|
||||
RecvSelectionEvent(const mozilla::WidgetSelectionEvent& aEvent) override;
|
||||
|
||||
virtual mozilla::ipc::IPCResult
|
||||
RecvNormalPrioritySelectionEvent(
|
||||
const mozilla::WidgetSelectionEvent& aEvent) override;
|
||||
|
||||
virtual mozilla::ipc::IPCResult
|
||||
RecvPasteTransferable(const IPCDataTransfer& aDataTransfer,
|
||||
const bool& aIsPrivateData,
|
||||
|
@ -2305,7 +2305,12 @@ TabParent::SendCompositionEvent(WidgetCompositionEvent& aEvent)
|
||||
if (!mContentCache.OnCompositionEvent(aEvent)) {
|
||||
return true;
|
||||
}
|
||||
if (NS_WARN_IF(!PBrowserParent::SendCompositionEvent(aEvent))) {
|
||||
|
||||
bool ret =
|
||||
Manager()->AsContentParent()->IsInputPriorityEventEnabled()
|
||||
? PBrowserParent::SendCompositionEvent(aEvent)
|
||||
: PBrowserParent::SendNormalPriorityCompositionEvent(aEvent);
|
||||
if (NS_WARN_IF(!ret)) {
|
||||
return false;
|
||||
}
|
||||
MOZ_ASSERT(aEvent.HasBeenPostedToRemoteProcess());
|
||||
@ -2323,7 +2328,11 @@ TabParent::SendSelectionEvent(WidgetSelectionEvent& aEvent)
|
||||
return true;
|
||||
}
|
||||
mContentCache.OnSelectionEvent(aEvent);
|
||||
if (NS_WARN_IF(!PBrowserParent::SendSelectionEvent(aEvent))) {
|
||||
bool ret =
|
||||
Manager()->AsContentParent()->IsInputPriorityEventEnabled()
|
||||
? PBrowserParent::SendSelectionEvent(aEvent)
|
||||
: PBrowserParent::SendNormalPrioritySelectionEvent(aEvent);
|
||||
if (NS_WARN_IF(!ret)) {
|
||||
return false;
|
||||
}
|
||||
MOZ_ASSERT(aEvent.HasBeenPostedToRemoteProcess());
|
||||
|
@ -47,13 +47,13 @@ AxisPhysicsModel::~AxisPhysicsModel()
|
||||
}
|
||||
|
||||
double
|
||||
AxisPhysicsModel::GetVelocity()
|
||||
AxisPhysicsModel::GetVelocity() const
|
||||
{
|
||||
return LinearInterpolate(mPrevState.v, mNextState.v, mProgress);
|
||||
}
|
||||
|
||||
double
|
||||
AxisPhysicsModel::GetPosition()
|
||||
AxisPhysicsModel::GetPosition() const
|
||||
{
|
||||
return LinearInterpolate(mPrevState.p, mNextState.p, mProgress);
|
||||
}
|
||||
|
@ -7,7 +7,6 @@
|
||||
#ifndef mozilla_layers_AxisPhysicsModel_h
|
||||
#define mozilla_layers_AxisPhysicsModel_h
|
||||
|
||||
#include "AxisPhysicsModel.h"
|
||||
#include <sys/types.h> // for int32_t
|
||||
#include "mozilla/TimeStamp.h" // for TimeDuration
|
||||
|
||||
@ -38,7 +37,7 @@ public:
|
||||
/**
|
||||
* Gets the raw velocity of this axis at this moment.
|
||||
*/
|
||||
double GetVelocity();
|
||||
double GetVelocity() const;
|
||||
|
||||
/**
|
||||
* Sets the raw velocity of this axis at this moment.
|
||||
@ -48,7 +47,7 @@ public:
|
||||
/**
|
||||
* Gets the raw position of this axis at this moment.
|
||||
*/
|
||||
double GetPosition();
|
||||
double GetPosition() const;
|
||||
|
||||
/**
|
||||
* Sets the raw position of this axis at this moment.
|
||||
|
@ -77,6 +77,7 @@
|
||||
#include "prsystem.h" // for PR_GetPhysicalMemorySize
|
||||
#include "SharedMemoryBasic.h" // for SharedMemoryBasic
|
||||
#include "ScrollSnap.h" // for ScrollSnapUtils
|
||||
#include "ScrollAnimationPhysics.h" // for ComputeAcceleratedWheelDelta
|
||||
#include "WheelScrollAnimation.h"
|
||||
#include "KeyboardScrollAnimation.h"
|
||||
#if defined(MOZ_WIDGET_ANDROID)
|
||||
@ -1824,11 +1825,12 @@ AsyncPanZoomController::OnKeyboard(const KeyboardInput& aEvent)
|
||||
StartAnimation(new KeyboardScrollAnimation(*this, initialPosition, aEvent.mAction.mType));
|
||||
}
|
||||
|
||||
// Cast velocity from ParentLayerPoints/ms to CSSPoints/ms then convert to
|
||||
// appunits/second. We perform a cast to ParentLayerPoints/ms without a
|
||||
// conversion so that the scroll duration isn't affected by zoom
|
||||
// Convert velocity from ParentLayerPoints/ms to ParentLayerPoints/s and then
|
||||
// to appunits/second.
|
||||
nsPoint velocity =
|
||||
CSSPoint::ToAppUnits(CSSPoint(mX.GetVelocity(), mY.GetVelocity())) * 1000.0f;
|
||||
CSSPoint::ToAppUnits(
|
||||
ParentLayerPoint(mX.GetVelocity() * 1000.0f, mY.GetVelocity() * 1000.0f) /
|
||||
mFrameMetrics.GetZoom());
|
||||
|
||||
KeyboardScrollAnimation* animation = mAnimation->AsKeyboardScrollAnimation();
|
||||
MOZ_ASSERT(animation);
|
||||
@ -2102,11 +2104,14 @@ nsEventStatus AsyncPanZoomController::OnScrollWheel(const ScrollWheelInput& aEve
|
||||
|
||||
nsPoint deltaInAppUnits =
|
||||
CSSPoint::ToAppUnits(delta / mFrameMetrics.GetZoom());
|
||||
// Cast velocity from ParentLayerPoints/ms to CSSPoints/ms then convert to
|
||||
// appunits/second. We perform a cast to ParentLayerPoints/ms without a
|
||||
// conversion so that the scroll duration isn't affected by zoom
|
||||
|
||||
// Convert velocity from ParentLayerPoints/ms to ParentLayerPoints/s and
|
||||
// then to appunits/second.
|
||||
nsPoint velocity =
|
||||
CSSPoint::ToAppUnits(CSSPoint(mX.GetVelocity(), mY.GetVelocity())) * 1000.0f;
|
||||
CSSPoint::ToAppUnits(
|
||||
ParentLayerPoint(mX.GetVelocity() * 1000.0f,
|
||||
mY.GetVelocity() * 1000.0f) /
|
||||
mFrameMetrics.GetZoom());
|
||||
|
||||
WheelScrollAnimation* animation = mAnimation->AsWheelScrollAnimation();
|
||||
animation->UpdateDelta(aEvent.mTimeStamp, deltaInAppUnits, nsSize(velocity.x, velocity.y));
|
||||
@ -2861,11 +2866,14 @@ void AsyncPanZoomController::SmoothScrollTo(const CSSPoint& aDestination) {
|
||||
CancelAnimation();
|
||||
SetState(SMOOTH_SCROLL);
|
||||
nsPoint initialPosition = CSSPoint::ToAppUnits(mFrameMetrics.GetScrollOffset());
|
||||
// Cast velocity from ParentLayerPoints/ms to CSSPoints/ms then convert to
|
||||
// appunits/second. We perform a cast to ParentLayerPoints/ms without a
|
||||
// conversion so that the scroll duration isn't affected by zoom
|
||||
nsPoint initialVelocity = CSSPoint::ToAppUnits(CSSPoint(mX.GetVelocity(),
|
||||
mY.GetVelocity())) * 1000.0f;
|
||||
// Convert velocity from ParentLayerPoints/ms to ParentLayerPoints/s and
|
||||
// then to appunits/second.
|
||||
nsPoint initialVelocity =
|
||||
CSSPoint::ToAppUnits(
|
||||
ParentLayerPoint(mX.GetVelocity() * 1000.0f,
|
||||
mY.GetVelocity() * 1000.0f) /
|
||||
mFrameMetrics.GetZoom());
|
||||
|
||||
nsPoint destination = CSSPoint::ToAppUnits(aDestination);
|
||||
|
||||
StartAnimation(new SmoothScrollAnimation(*this,
|
||||
|
@ -9,17 +9,25 @@
|
||||
#include "AsyncPanZoomController.h"
|
||||
#include "gfxPrefs.h"
|
||||
#include "nsPoint.h"
|
||||
#include "ScrollAnimationPhysics.h"
|
||||
#include "ScrollAnimationBezierPhysics.h"
|
||||
#include "ScrollAnimationMSDPhysics.h"
|
||||
|
||||
namespace mozilla {
|
||||
namespace layers {
|
||||
|
||||
GenericScrollAnimation::GenericScrollAnimation(AsyncPanZoomController& aApzc,
|
||||
const nsPoint& aInitialPosition)
|
||||
: AsyncScrollBase(aInitialPosition)
|
||||
, mApzc(aApzc)
|
||||
const nsPoint& aInitialPosition,
|
||||
const ScrollAnimationBezierPhysicsSettings& aSettings)
|
||||
: mApzc(aApzc)
|
||||
, mFinalDestination(aInitialPosition)
|
||||
, mForceVerticalOverscroll(false)
|
||||
{
|
||||
if (gfxPrefs::SmoothScrollMSDPhysicsEnabled()) {
|
||||
mAnimationPhysics = MakeUnique<ScrollAnimationMSDPhysics>(aInitialPosition);
|
||||
} else {
|
||||
mAnimationPhysics = MakeUnique<ScrollAnimationBezierPhysics>(aInitialPosition, aSettings);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
@ -41,17 +49,13 @@ GenericScrollAnimation::UpdateDestination(TimeStamp aTime, nsPoint aDestination,
|
||||
void
|
||||
GenericScrollAnimation::Update(TimeStamp aTime, const nsSize& aCurrentVelocity)
|
||||
{
|
||||
if (mIsFirstIteration) {
|
||||
InitializeHistory(aTime);
|
||||
}
|
||||
|
||||
// Clamp the final destination to the scrollable area.
|
||||
CSSPoint clamped = CSSPoint::FromAppUnits(mFinalDestination);
|
||||
clamped.x = mApzc.mX.ClampOriginToScrollableRect(clamped.x);
|
||||
clamped.y = mApzc.mY.ClampOriginToScrollableRect(clamped.y);
|
||||
mFinalDestination = CSSPoint::ToAppUnits(clamped);
|
||||
|
||||
AsyncScrollBase::Update(aTime, mFinalDestination, aCurrentVelocity);
|
||||
mAnimationPhysics->Update(aTime, mFinalDestination, aCurrentVelocity);
|
||||
}
|
||||
|
||||
bool
|
||||
@ -63,10 +67,8 @@ GenericScrollAnimation::DoSample(FrameMetrics& aFrameMetrics, const TimeDuration
|
||||
// If the animation is finished, make sure the final position is correct by
|
||||
// using one last displacement. Otherwise, compute the delta via the timing
|
||||
// function as normal.
|
||||
bool finished = IsFinished(now);
|
||||
nsPoint sampledDest = finished
|
||||
? mDestination
|
||||
: PositionAt(now);
|
||||
bool finished = mAnimationPhysics->IsFinished(now);
|
||||
nsPoint sampledDest = mAnimationPhysics->PositionAt(now);
|
||||
ParentLayerPoint displacement =
|
||||
(CSSPoint::FromAppUnits(sampledDest) - aFrameMetrics.GetScrollOffset()) * zoom;
|
||||
|
||||
@ -74,11 +76,12 @@ GenericScrollAnimation::DoSample(FrameMetrics& aFrameMetrics, const TimeDuration
|
||||
mApzc.mX.SetVelocity(0);
|
||||
mApzc.mY.SetVelocity(0);
|
||||
} else if (!IsZero(displacement)) {
|
||||
// Velocity is measured in ParentLayerCoords / Milliseconds
|
||||
float xVelocity = displacement.x / aDelta.ToMilliseconds();
|
||||
float yVelocity = displacement.y / aDelta.ToMilliseconds();
|
||||
mApzc.mX.SetVelocity(xVelocity);
|
||||
mApzc.mY.SetVelocity(yVelocity);
|
||||
// Convert velocity from AppUnits/Seconds to ParentLayerCoords/Milliseconds
|
||||
nsSize velocity = mAnimationPhysics->VelocityAt(now);
|
||||
ParentLayerPoint velocityPL =
|
||||
CSSPoint::FromAppUnits(nsPoint(velocity.width, velocity.height)) * zoom;
|
||||
mApzc.mX.SetVelocity(velocityPL.x / 1000.0);
|
||||
mApzc.mY.SetVelocity(velocityPL.y / 1000.0);
|
||||
}
|
||||
|
||||
// Note: we ignore overscroll for generic animations.
|
||||
|
@ -8,20 +8,23 @@
|
||||
#define mozilla_layers_GenericScrollAnimation_h_
|
||||
|
||||
#include "AsyncPanZoomAnimation.h"
|
||||
#include "AsyncScrollBase.h"
|
||||
|
||||
namespace mozilla {
|
||||
|
||||
struct ScrollAnimationBezierPhysicsSettings;
|
||||
class ScrollAnimationPhysics;
|
||||
|
||||
namespace layers {
|
||||
|
||||
class AsyncPanZoomController;
|
||||
|
||||
class GenericScrollAnimation
|
||||
: public AsyncPanZoomAnimation,
|
||||
public AsyncScrollBase
|
||||
: public AsyncPanZoomAnimation
|
||||
{
|
||||
public:
|
||||
GenericScrollAnimation(AsyncPanZoomController& aApzc,
|
||||
const nsPoint& aInitialPosition);
|
||||
const nsPoint& aInitialPosition,
|
||||
const ScrollAnimationBezierPhysicsSettings& aSettings);
|
||||
|
||||
bool DoSample(FrameMetrics& aFrameMetrics, const TimeDuration& aDelta) override;
|
||||
|
||||
@ -37,6 +40,7 @@ private:
|
||||
|
||||
protected:
|
||||
AsyncPanZoomController& mApzc;
|
||||
UniquePtr<ScrollAnimationPhysics> mAnimationPhysics;
|
||||
nsPoint mFinalDestination;
|
||||
bool mForceVerticalOverscroll;
|
||||
};
|
||||
|
@ -6,7 +6,7 @@
|
||||
|
||||
#include "InputBlockState.h"
|
||||
#include "AsyncPanZoomController.h" // for AsyncPanZoomController
|
||||
#include "AsyncScrollBase.h" // for kScrollSeriesTimeoutMs
|
||||
#include "ScrollAnimationPhysics.h" // for kScrollSeriesTimeoutMs
|
||||
#include "gfxPrefs.h" // for gfxPrefs
|
||||
#include "mozilla/MouseEvents.h"
|
||||
#include "mozilla/Telemetry.h" // for Telemetry
|
||||
|
@ -5,39 +5,49 @@
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#include "KeyboardScrollAnimation.h"
|
||||
#include "ScrollAnimationBezierPhysics.h"
|
||||
|
||||
#include "gfxPrefs.h"
|
||||
|
||||
namespace mozilla {
|
||||
namespace layers {
|
||||
|
||||
KeyboardScrollAnimation::KeyboardScrollAnimation(AsyncPanZoomController& aApzc,
|
||||
const nsPoint& aInitialPosition,
|
||||
KeyboardScrollAction::KeyboardScrollActionType aType)
|
||||
: GenericScrollAnimation(aApzc, aInitialPosition)
|
||||
static ScrollAnimationBezierPhysicsSettings
|
||||
SettingsForType(KeyboardScrollAction::KeyboardScrollActionType aType)
|
||||
{
|
||||
int32_t minMS = 0;
|
||||
int32_t maxMS = 0;
|
||||
|
||||
switch (aType) {
|
||||
case KeyboardScrollAction::eScrollCharacter:
|
||||
case KeyboardScrollAction::eScrollLine: {
|
||||
mOriginMaxMS = clamped(gfxPrefs::LineSmoothScrollMaxDurationMs(), 0, 10000);
|
||||
mOriginMinMS = clamped(gfxPrefs::LineSmoothScrollMinDurationMs(), 0, mOriginMaxMS);
|
||||
maxMS = clamped(gfxPrefs::LineSmoothScrollMaxDurationMs(), 0, 10000);
|
||||
minMS = clamped(gfxPrefs::LineSmoothScrollMinDurationMs(), 0, maxMS);
|
||||
break;
|
||||
}
|
||||
case KeyboardScrollAction::eScrollPage: {
|
||||
mOriginMaxMS = clamped(gfxPrefs::PageSmoothScrollMaxDurationMs(), 0, 10000);
|
||||
mOriginMinMS = clamped(gfxPrefs::PageSmoothScrollMinDurationMs(), 0, mOriginMaxMS);
|
||||
maxMS = clamped(gfxPrefs::PageSmoothScrollMaxDurationMs(), 0, 10000);
|
||||
minMS = clamped(gfxPrefs::PageSmoothScrollMinDurationMs(), 0, maxMS);
|
||||
break;
|
||||
}
|
||||
case KeyboardScrollAction::eScrollComplete: {
|
||||
mOriginMaxMS = clamped(gfxPrefs::OtherSmoothScrollMaxDurationMs(), 0, 10000);
|
||||
mOriginMinMS = clamped(gfxPrefs::OtherSmoothScrollMinDurationMs(), 0, mOriginMaxMS);
|
||||
maxMS = clamped(gfxPrefs::OtherSmoothScrollMaxDurationMs(), 0, 10000);
|
||||
minMS = clamped(gfxPrefs::OtherSmoothScrollMinDurationMs(), 0, maxMS);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// The pref is 100-based int percentage, while mIntervalRatio is 1-based ratio
|
||||
mIntervalRatio = ((double)gfxPrefs::SmoothScrollDurationToIntervalRatio()) / 100.0;
|
||||
mIntervalRatio = std::max(1.0, mIntervalRatio);
|
||||
double intervalRatio = ((double)gfxPrefs::SmoothScrollDurationToIntervalRatio()) / 100.0;
|
||||
intervalRatio = std::max(1.0, intervalRatio);
|
||||
return ScrollAnimationBezierPhysicsSettings { minMS, maxMS, intervalRatio };
|
||||
}
|
||||
|
||||
KeyboardScrollAnimation::KeyboardScrollAnimation(AsyncPanZoomController& aApzc,
|
||||
const nsPoint& aInitialPosition,
|
||||
KeyboardScrollAction::KeyboardScrollActionType aType)
|
||||
: GenericScrollAnimation(aApzc, aInitialPosition, SettingsForType(aType))
|
||||
{
|
||||
}
|
||||
|
||||
} // namespace layers
|
||||
|
@ -5,6 +5,7 @@
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#include "WheelScrollAnimation.h"
|
||||
#include "ScrollAnimationBezierPhysics.h"
|
||||
|
||||
#include "AsyncPanZoomController.h"
|
||||
#include "gfxPrefs.h"
|
||||
@ -13,31 +14,39 @@
|
||||
namespace mozilla {
|
||||
namespace layers {
|
||||
|
||||
WheelScrollAnimation::WheelScrollAnimation(AsyncPanZoomController& aApzc,
|
||||
const nsPoint& aInitialPosition,
|
||||
ScrollWheelInput::ScrollDeltaType aDeltaType)
|
||||
: GenericScrollAnimation(aApzc, aInitialPosition)
|
||||
static ScrollAnimationBezierPhysicsSettings
|
||||
SettingsForDeltaType(ScrollWheelInput::ScrollDeltaType aDeltaType)
|
||||
{
|
||||
mForceVerticalOverscroll = !mApzc.mScrollMetadata.AllowVerticalScrollWithWheel();
|
||||
int32_t minMS = 0;
|
||||
int32_t maxMS = 0;
|
||||
|
||||
switch (aDeltaType) {
|
||||
case ScrollWheelInput::SCROLLDELTA_PAGE:
|
||||
mOriginMaxMS = clamped(gfxPrefs::PageSmoothScrollMaxDurationMs(), 0, 10000);
|
||||
mOriginMinMS = clamped(gfxPrefs::PageSmoothScrollMinDurationMs(), 0, mOriginMaxMS);
|
||||
break;
|
||||
case ScrollWheelInput::SCROLLDELTA_PIXEL:
|
||||
mOriginMaxMS = clamped(gfxPrefs::PixelSmoothScrollMaxDurationMs(), 0, 10000);
|
||||
mOriginMinMS = clamped(gfxPrefs::PixelSmoothScrollMinDurationMs(), 0, mOriginMaxMS);
|
||||
break;
|
||||
case ScrollWheelInput::SCROLLDELTA_LINE:
|
||||
mOriginMaxMS = clamped(gfxPrefs::WheelSmoothScrollMaxDurationMs(), 0, 10000);
|
||||
mOriginMinMS = clamped(gfxPrefs::WheelSmoothScrollMinDurationMs(), 0, mOriginMaxMS);
|
||||
break;
|
||||
case ScrollWheelInput::SCROLLDELTA_PAGE:
|
||||
maxMS = clamped(gfxPrefs::PageSmoothScrollMaxDurationMs(), 0, 10000);
|
||||
minMS = clamped(gfxPrefs::PageSmoothScrollMinDurationMs(), 0, maxMS);
|
||||
break;
|
||||
case ScrollWheelInput::SCROLLDELTA_PIXEL:
|
||||
maxMS = clamped(gfxPrefs::PixelSmoothScrollMaxDurationMs(), 0, 10000);
|
||||
minMS = clamped(gfxPrefs::PixelSmoothScrollMinDurationMs(), 0, maxMS);
|
||||
break;
|
||||
case ScrollWheelInput::SCROLLDELTA_LINE:
|
||||
maxMS = clamped(gfxPrefs::WheelSmoothScrollMaxDurationMs(), 0, 10000);
|
||||
minMS = clamped(gfxPrefs::WheelSmoothScrollMinDurationMs(), 0, maxMS);
|
||||
break;
|
||||
}
|
||||
|
||||
// The pref is 100-based int percentage, while mIntervalRatio is 1-based ratio
|
||||
mIntervalRatio = ((double)gfxPrefs::SmoothScrollDurationToIntervalRatio()) / 100.0;
|
||||
mIntervalRatio = std::max(1.0, mIntervalRatio);
|
||||
double intervalRatio = ((double)gfxPrefs::SmoothScrollDurationToIntervalRatio()) / 100.0;
|
||||
intervalRatio = std::max(1.0, intervalRatio);
|
||||
return ScrollAnimationBezierPhysicsSettings { minMS, maxMS, intervalRatio };
|
||||
}
|
||||
|
||||
WheelScrollAnimation::WheelScrollAnimation(AsyncPanZoomController& aApzc,
|
||||
const nsPoint& aInitialPosition,
|
||||
ScrollWheelInput::ScrollDeltaType aDeltaType)
|
||||
: GenericScrollAnimation(aApzc, aInitialPosition, SettingsForDeltaType(aDeltaType))
|
||||
{
|
||||
mForceVerticalOverscroll = !mApzc.mScrollMetadata.AllowVerticalScrollWithWheel();
|
||||
}
|
||||
|
||||
} // namespace layers
|
||||
|
@ -404,6 +404,21 @@ private:
|
||||
DECL_GFX_PREF(Live, "general.smoothScroll.stopDecelerationWeighting",
|
||||
SmoothScrollStopDecelerationWeighting, float, 0.4f);
|
||||
|
||||
DECL_GFX_PREF(Live, "general.smoothScroll.msdPhysics.enabled",
|
||||
SmoothScrollMSDPhysicsEnabled, bool, false);
|
||||
DECL_GFX_PREF(Live, "general.smoothScroll.msdPhysics.continuousMotionMaxDeltaMS",
|
||||
SmoothScrollMSDPhysicsContinuousMotionMaxDeltaMS, int32_t, 120);
|
||||
DECL_GFX_PREF(Live, "general.smoothScroll.msdPhysics.motionBeginSpringConstant",
|
||||
SmoothScrollMSDPhysicsMotionBeginSpringConstant, int32_t, 1250);
|
||||
DECL_GFX_PREF(Live, "general.smoothScroll.msdPhysics.slowdownMinDeltaMS",
|
||||
SmoothScrollMSDPhysicsSlowdownMinDeltaMS, int32_t, 12);
|
||||
DECL_GFX_PREF(Live, "general.smoothScroll.msdPhysics.slowdownMinDeltaRatio",
|
||||
SmoothScrollMSDPhysicsSlowdownMinDeltaRatio, float, 1.3f);
|
||||
DECL_GFX_PREF(Live, "general.smoothScroll.msdPhysics.slowdownSpringConstant",
|
||||
SmoothScrollMSDPhysicsSlowdownSpringConstant, int32_t, 2000);
|
||||
DECL_GFX_PREF(Live, "general.smoothScroll.msdPhysics.regularSpringConstant",
|
||||
SmoothScrollMSDPhysicsRegularSpringConstant, int32_t, 1000);
|
||||
|
||||
DECL_GFX_PREF(Once, "gfx.android.rgb16.force", AndroidRGB16Force, bool, false);
|
||||
#if defined(ANDROID)
|
||||
DECL_GFX_PREF(Once, "gfx.apitrace.enabled", UseApitrace, bool, false);
|
||||
|
@ -3,22 +3,28 @@
|
||||
* 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 "AsyncScrollBase.h"
|
||||
#include "ScrollAnimationBezierPhysics.h"
|
||||
#include "gfxPrefs.h"
|
||||
|
||||
using namespace mozilla;
|
||||
|
||||
AsyncScrollBase::AsyncScrollBase(nsPoint aStartPos)
|
||||
: mIsFirstIteration(true)
|
||||
ScrollAnimationBezierPhysics::ScrollAnimationBezierPhysics(const nsPoint& aStartPos,
|
||||
const ScrollAnimationBezierPhysicsSettings& aSettings)
|
||||
: mSettings(aSettings)
|
||||
, mStartPos(aStartPos)
|
||||
, mIsFirstIteration(true)
|
||||
{
|
||||
}
|
||||
|
||||
void
|
||||
AsyncScrollBase::Update(TimeStamp aTime,
|
||||
nsPoint aDestination,
|
||||
const nsSize& aCurrentVelocity)
|
||||
ScrollAnimationBezierPhysics::Update(const TimeStamp& aTime,
|
||||
const nsPoint& aDestination,
|
||||
const nsSize& aCurrentVelocity)
|
||||
{
|
||||
if (mIsFirstIteration) {
|
||||
InitializeHistory(aTime);
|
||||
}
|
||||
|
||||
TimeDuration duration = ComputeDuration(aTime);
|
||||
nsSize currentVelocity = aCurrentVelocity;
|
||||
|
||||
@ -47,7 +53,7 @@ AsyncScrollBase::Update(TimeStamp aTime,
|
||||
}
|
||||
|
||||
TimeDuration
|
||||
AsyncScrollBase::ComputeDuration(TimeStamp aTime)
|
||||
ScrollAnimationBezierPhysics::ComputeDuration(const TimeStamp& aTime)
|
||||
{
|
||||
// Average last 3 delta durations (rounding errors up to 2ms are negligible for us)
|
||||
int32_t eventsDeltaMs = (aTime - mPrevEventTime[2]).ToMilliseconds() / 3;
|
||||
@ -60,29 +66,32 @@ AsyncScrollBase::ComputeDuration(TimeStamp aTime)
|
||||
// it's easier to follow, but reduce the duration to make it feel more snappy when
|
||||
// scrolling quickly. To reduce fluctuations of the duration, we average event
|
||||
// intervals using the recent 4 timestamps (now + three prev -> 3 intervals).
|
||||
int32_t durationMS = clamped<int32_t>(eventsDeltaMs * mIntervalRatio, mOriginMinMS, mOriginMaxMS);
|
||||
int32_t durationMS =
|
||||
clamped<int32_t>(eventsDeltaMs * mSettings.mIntervalRatio,
|
||||
mSettings.mMinMS, mSettings.mMaxMS);
|
||||
|
||||
return TimeDuration::FromMilliseconds(durationMS);
|
||||
}
|
||||
|
||||
void
|
||||
AsyncScrollBase::InitializeHistory(TimeStamp aTime)
|
||||
ScrollAnimationBezierPhysics::InitializeHistory(const TimeStamp& aTime)
|
||||
{
|
||||
// Starting a new scroll (i.e. not when extending an existing scroll animation),
|
||||
// create imaginary prev timestamps with maximum relevant intervals between them.
|
||||
|
||||
// Longest relevant interval (which results in maximum duration)
|
||||
TimeDuration maxDelta = TimeDuration::FromMilliseconds(mOriginMaxMS / mIntervalRatio);
|
||||
TimeDuration maxDelta =
|
||||
TimeDuration::FromMilliseconds(mSettings.mMaxMS / mSettings.mIntervalRatio);
|
||||
mPrevEventTime[0] = aTime - maxDelta;
|
||||
mPrevEventTime[1] = mPrevEventTime[0] - maxDelta;
|
||||
mPrevEventTime[2] = mPrevEventTime[1] - maxDelta;
|
||||
}
|
||||
|
||||
void
|
||||
AsyncScrollBase::InitTimingFunction(nsSMILKeySpline& aTimingFunction,
|
||||
nscoord aCurrentPos,
|
||||
nscoord aCurrentVelocity,
|
||||
nscoord aDestination)
|
||||
ScrollAnimationBezierPhysics::InitTimingFunction(nsSMILKeySpline& aTimingFunction,
|
||||
nscoord aCurrentPos,
|
||||
nscoord aCurrentVelocity,
|
||||
nscoord aDestination)
|
||||
{
|
||||
if (aDestination == aCurrentPos || gfxPrefs::SmoothScrollCurrentVelocityWeighting() == 0) {
|
||||
aTimingFunction.Init(0, 0, 1 - gfxPrefs::SmoothScrollStopDecelerationWeighting(), 1);
|
||||
@ -98,8 +107,12 @@ AsyncScrollBase::InitTimingFunction(nsSMILKeySpline& aTimingFunction,
|
||||
}
|
||||
|
||||
nsPoint
|
||||
AsyncScrollBase::PositionAt(TimeStamp aTime) const
|
||||
ScrollAnimationBezierPhysics::PositionAt(const TimeStamp& aTime)
|
||||
{
|
||||
if (IsFinished(aTime)) {
|
||||
return mDestination;
|
||||
}
|
||||
|
||||
double progressX = mTimingFunctionX.GetSplineValue(ProgressAt(aTime));
|
||||
double progressY = mTimingFunctionY.GetSplineValue(ProgressAt(aTime));
|
||||
return nsPoint(NSToCoordRound((1 - progressX) * mStartPos.x + progressX * mDestination.x),
|
||||
@ -107,8 +120,12 @@ AsyncScrollBase::PositionAt(TimeStamp aTime) const
|
||||
}
|
||||
|
||||
nsSize
|
||||
AsyncScrollBase::VelocityAt(TimeStamp aTime) const
|
||||
ScrollAnimationBezierPhysics::VelocityAt(const TimeStamp& aTime)
|
||||
{
|
||||
if (IsFinished(aTime)) {
|
||||
return nsSize(0, 0);
|
||||
}
|
||||
|
||||
double timeProgress = ProgressAt(aTime);
|
||||
return nsSize(VelocityComponent(timeProgress, mTimingFunctionX,
|
||||
mStartPos.x, mDestination.x),
|
||||
@ -117,10 +134,10 @@ AsyncScrollBase::VelocityAt(TimeStamp aTime) const
|
||||
}
|
||||
|
||||
nscoord
|
||||
AsyncScrollBase::VelocityComponent(double aTimeProgress,
|
||||
const nsSMILKeySpline& aTimingFunction,
|
||||
nscoord aStart,
|
||||
nscoord aDestination) const
|
||||
ScrollAnimationBezierPhysics::VelocityComponent(double aTimeProgress,
|
||||
const nsSMILKeySpline& aTimingFunction,
|
||||
nscoord aStart,
|
||||
nscoord aDestination) const
|
||||
{
|
||||
double dt, dxy;
|
||||
aTimingFunction.GetSplineDerivativeValues(aTimeProgress, dt, dxy);
|
@ -3,42 +3,50 @@
|
||||
* 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_layout_AsyncScrollBase_h_
|
||||
#define mozilla_layout_AsyncScrollBase_h_
|
||||
#ifndef mozilla_layout_ScrollAnimationBezierPhysics_h_
|
||||
#define mozilla_layout_ScrollAnimationBezierPhysics_h_
|
||||
|
||||
#include "mozilla/TimeStamp.h"
|
||||
#include "nsPoint.h"
|
||||
#include "ScrollAnimationPhysics.h"
|
||||
#include "nsSMILKeySpline.h"
|
||||
|
||||
namespace mozilla {
|
||||
|
||||
// This is the base class for driving scroll wheel animation on both the
|
||||
// compositor and main thread.
|
||||
class AsyncScrollBase
|
||||
struct ScrollAnimationBezierPhysicsSettings
|
||||
{
|
||||
// These values are minimum and maximum animation duration per event,
|
||||
// and a global ratio which defines how longer is the animation's duration
|
||||
// compared to the average recent events intervals (such that for a relatively
|
||||
// consistent events rate, the next event arrives before current animation ends)
|
||||
int32_t mMinMS;
|
||||
int32_t mMaxMS;
|
||||
double mIntervalRatio;
|
||||
};
|
||||
|
||||
// This class implements a cubic bezier timing function and automatically
|
||||
// adapts the animation duration based on the scrolling rate.
|
||||
class ScrollAnimationBezierPhysics : public ScrollAnimationPhysics
|
||||
{
|
||||
public:
|
||||
typedef mozilla::TimeStamp TimeStamp;
|
||||
typedef mozilla::TimeDuration TimeDuration;
|
||||
explicit ScrollAnimationBezierPhysics(const nsPoint& aStartPos,
|
||||
const ScrollAnimationBezierPhysicsSettings& aSettings);
|
||||
|
||||
explicit AsyncScrollBase(nsPoint aStartPos);
|
||||
|
||||
void Update(TimeStamp aTime,
|
||||
nsPoint aDestination,
|
||||
const nsSize& aCurrentVelocity);
|
||||
void Update(const TimeStamp& aTime,
|
||||
const nsPoint& aDestination,
|
||||
const nsSize& aCurrentVelocity) override;
|
||||
|
||||
// Get the velocity at a point in time in nscoords/sec.
|
||||
nsSize VelocityAt(TimeStamp aTime) const;
|
||||
nsSize VelocityAt(const TimeStamp& aTime) override;
|
||||
|
||||
// Returns the expected scroll position at a given point in time, in app
|
||||
// units, relative to the scroll frame.
|
||||
nsPoint PositionAt(TimeStamp aTime) const;
|
||||
nsPoint PositionAt(const TimeStamp& aTime) override;
|
||||
|
||||
bool IsFinished(TimeStamp aTime) {
|
||||
bool IsFinished(const TimeStamp& aTime) override {
|
||||
return aTime > mStartTime + mDuration;
|
||||
}
|
||||
|
||||
protected:
|
||||
double ProgressAt(TimeStamp aTime) const {
|
||||
double ProgressAt(const TimeStamp& aTime) const {
|
||||
return clamped((aTime - mStartTime) / mDuration, 0.0, 1.0);
|
||||
}
|
||||
|
||||
@ -49,10 +57,7 @@ protected:
|
||||
// Calculate duration, possibly dynamically according to events rate and
|
||||
// event origin. (also maintain previous timestamps - which are only used
|
||||
// here).
|
||||
TimeDuration ComputeDuration(TimeStamp aTime);
|
||||
|
||||
// Initialize event history.
|
||||
void InitializeHistory(TimeStamp aTime);
|
||||
TimeDuration ComputeDuration(const TimeStamp& aTime);
|
||||
|
||||
// Initializes the timing function in such a way that the current velocity is
|
||||
// preserved.
|
||||
@ -60,46 +65,29 @@ protected:
|
||||
nscoord aCurrentPos, nscoord aCurrentVelocity,
|
||||
nscoord aDestination);
|
||||
|
||||
// Initialize event history.
|
||||
void InitializeHistory(const TimeStamp& aTime);
|
||||
|
||||
// Cached Preferences values.
|
||||
ScrollAnimationBezierPhysicsSettings mSettings;
|
||||
|
||||
// mPrevEventTime holds previous 3 timestamps for intervals averaging (to
|
||||
// reduce duration fluctuations). When AsyncScroll is constructed and no
|
||||
// previous timestamps are available (indicated with mIsFirstIteration),
|
||||
// initialize mPrevEventTime using imaginary previous timestamps with maximum
|
||||
// relevant intervals between them.
|
||||
TimeStamp mPrevEventTime[3];
|
||||
bool mIsFirstIteration;
|
||||
|
||||
TimeStamp mStartTime;
|
||||
|
||||
// Cached Preferences value.
|
||||
//
|
||||
// These values are minimum and maximum animation duration per event origin,
|
||||
// and a global ratio which defines how longer is the animation's duration
|
||||
// compared to the average recent events intervals (such that for a relatively
|
||||
// consistent events rate, the next event arrives before current animation ends)
|
||||
int32_t mOriginMinMS;
|
||||
int32_t mOriginMaxMS;
|
||||
double mIntervalRatio;
|
||||
|
||||
nsPoint mStartPos;
|
||||
TimeDuration mDuration;
|
||||
nsPoint mDestination;
|
||||
TimeDuration mDuration;
|
||||
nsSMILKeySpline mTimingFunctionX;
|
||||
nsSMILKeySpline mTimingFunctionY;
|
||||
bool mIsFirstIteration;
|
||||
};
|
||||
|
||||
// Helper for accelerated wheel deltas. This can be called from the main thread
|
||||
// or the APZ Controller thread.
|
||||
static inline double
|
||||
ComputeAcceleratedWheelDelta(double aDelta, int32_t aCounter, int32_t aFactor)
|
||||
{
|
||||
if (!aDelta) {
|
||||
return aDelta;
|
||||
}
|
||||
return (aDelta * aCounter * double(aFactor) / 10);
|
||||
}
|
||||
|
||||
static const uint32_t kScrollSeriesTimeoutMs = 80; // in milliseconds
|
||||
|
||||
} // namespace mozilla
|
||||
|
||||
#endif // mozilla_layout_AsyncScrollBase_h_
|
||||
#endif // mozilla_layout_ScrollAnimationBezierPhysics_h_
|
109
layout/generic/ScrollAnimationMSDPhysics.cpp
Normal file
109
layout/generic/ScrollAnimationMSDPhysics.cpp
Normal file
@ -0,0 +1,109 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* 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 "ScrollAnimationMSDPhysics.h"
|
||||
#include "gfxPrefs.h"
|
||||
|
||||
using namespace mozilla;
|
||||
|
||||
ScrollAnimationMSDPhysics::ScrollAnimationMSDPhysics(const nsPoint& aStartPos)
|
||||
: mStartPos(aStartPos)
|
||||
, mModelX(0, 0, 0, gfxPrefs::SmoothScrollMSDPhysicsRegularSpringConstant(), 1)
|
||||
, mModelY(0, 0, 0, gfxPrefs::SmoothScrollMSDPhysicsRegularSpringConstant(), 1)
|
||||
, mIsFirstIteration(true)
|
||||
{
|
||||
}
|
||||
|
||||
void
|
||||
ScrollAnimationMSDPhysics::Update(const TimeStamp& aTime,
|
||||
const nsPoint& aDestination,
|
||||
const nsSize& aCurrentVelocity)
|
||||
{
|
||||
double springConstant = ComputeSpringConstant(aTime);
|
||||
|
||||
// mLastSimulatedTime is the most recent time that this animation has been
|
||||
// "observed" at. We don't want to update back to a state in the past, so we
|
||||
// set mStartTime to the more recent of mLastSimulatedTime and aTime.
|
||||
// aTime can be in the past if we're processing an input event whose internal
|
||||
// timestamp is in the past.
|
||||
if (mLastSimulatedTime && aTime < mLastSimulatedTime) {
|
||||
mStartTime = mLastSimulatedTime;
|
||||
} else {
|
||||
mStartTime = aTime;
|
||||
}
|
||||
|
||||
if (!mIsFirstIteration) {
|
||||
mStartPos = PositionAt(mStartTime);
|
||||
}
|
||||
|
||||
mLastSimulatedTime = mStartTime;
|
||||
mDestination = aDestination;
|
||||
mModelX = AxisPhysicsMSDModel(mStartPos.x, aDestination.x,
|
||||
aCurrentVelocity.width, springConstant, 1);
|
||||
mModelY = AxisPhysicsMSDModel(mStartPos.y, aDestination.y,
|
||||
aCurrentVelocity.height, springConstant, 1);
|
||||
mIsFirstIteration = false;
|
||||
}
|
||||
|
||||
double
|
||||
ScrollAnimationMSDPhysics::ComputeSpringConstant(const TimeStamp& aTime)
|
||||
{
|
||||
if (!mPreviousEventTime) {
|
||||
mPreviousEventTime = aTime;
|
||||
mPreviousDelta = TimeDuration();
|
||||
return gfxPrefs::SmoothScrollMSDPhysicsMotionBeginSpringConstant();
|
||||
}
|
||||
|
||||
TimeDuration delta = aTime - mPreviousEventTime;
|
||||
TimeDuration previousDelta = mPreviousDelta;
|
||||
|
||||
mPreviousEventTime = aTime;
|
||||
mPreviousDelta = delta;
|
||||
|
||||
double deltaMS = delta.ToMilliseconds();
|
||||
if (deltaMS >= gfxPrefs::SmoothScrollMSDPhysicsContinuousMotionMaxDeltaMS()) {
|
||||
return gfxPrefs::SmoothScrollMSDPhysicsMotionBeginSpringConstant();
|
||||
}
|
||||
|
||||
if (previousDelta &&
|
||||
deltaMS >= gfxPrefs::SmoothScrollMSDPhysicsSlowdownMinDeltaMS() &&
|
||||
deltaMS >= previousDelta.ToMilliseconds() * gfxPrefs::SmoothScrollMSDPhysicsSlowdownMinDeltaRatio()) {
|
||||
// The rate of events has slowed (the time delta between events has
|
||||
// increased) enough that we think that the current scroll motion is coming
|
||||
// to a stop. Use a stiffer spring in order to reach the destination more
|
||||
// quickly.
|
||||
return gfxPrefs::SmoothScrollMSDPhysicsSlowdownSpringConstant();
|
||||
}
|
||||
|
||||
return gfxPrefs::SmoothScrollMSDPhysicsRegularSpringConstant();
|
||||
}
|
||||
|
||||
void
|
||||
ScrollAnimationMSDPhysics::SimulateUntil(const TimeStamp& aTime)
|
||||
{
|
||||
if (!mLastSimulatedTime || aTime < mLastSimulatedTime) {
|
||||
return;
|
||||
}
|
||||
TimeDuration delta = aTime - mLastSimulatedTime;
|
||||
mModelX.Simulate(delta);
|
||||
mModelY.Simulate(delta);
|
||||
mLastSimulatedTime = aTime;
|
||||
}
|
||||
|
||||
nsPoint
|
||||
ScrollAnimationMSDPhysics::PositionAt(const TimeStamp& aTime)
|
||||
{
|
||||
SimulateUntil(aTime);
|
||||
return nsPoint(NSToCoordRound(mModelX.GetPosition()),
|
||||
NSToCoordRound(mModelY.GetPosition()));
|
||||
}
|
||||
|
||||
nsSize
|
||||
ScrollAnimationMSDPhysics::VelocityAt(const TimeStamp& aTime)
|
||||
{
|
||||
SimulateUntil(aTime);
|
||||
return nsSize(NSToCoordRound(mModelX.GetVelocity()),
|
||||
NSToCoordRound(mModelY.GetVelocity()));
|
||||
}
|
58
layout/generic/ScrollAnimationMSDPhysics.h
Normal file
58
layout/generic/ScrollAnimationMSDPhysics.h
Normal file
@ -0,0 +1,58 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* 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_layout_ScrollAnimationMSDPhysics_h_
|
||||
#define mozilla_layout_ScrollAnimationMSDPhysics_h_
|
||||
|
||||
#include "ScrollAnimationPhysics.h"
|
||||
#include "mozilla/layers/AxisPhysicsMSDModel.h"
|
||||
|
||||
namespace mozilla {
|
||||
|
||||
// This class implements a cubic MSD timing function and automatically
|
||||
// adapts the animation duration based on the scrolling rate.
|
||||
class ScrollAnimationMSDPhysics : public ScrollAnimationPhysics
|
||||
{
|
||||
public:
|
||||
typedef mozilla::layers::AxisPhysicsMSDModel AxisPhysicsMSDModel;
|
||||
|
||||
explicit ScrollAnimationMSDPhysics(const nsPoint& aStartPos);
|
||||
|
||||
void Update(const TimeStamp& aTime,
|
||||
const nsPoint& aDestination,
|
||||
const nsSize& aCurrentVelocity) override;
|
||||
|
||||
// Get the velocity at a point in time in nscoords/sec.
|
||||
nsSize VelocityAt(const TimeStamp& aTime) override;
|
||||
|
||||
// Returns the expected scroll position at a given point in time, in app
|
||||
// units, relative to the scroll frame.
|
||||
nsPoint PositionAt(const TimeStamp& aTime) override;
|
||||
|
||||
bool IsFinished(const TimeStamp& aTime) override {
|
||||
SimulateUntil(aTime);
|
||||
return mModelX.IsFinished(1) && mModelY.IsFinished(1);
|
||||
}
|
||||
|
||||
protected:
|
||||
double ComputeSpringConstant(const TimeStamp& aTime);
|
||||
void SimulateUntil(const TimeStamp& aTime);
|
||||
|
||||
TimeStamp mPreviousEventTime;
|
||||
TimeDuration mPreviousDelta;
|
||||
|
||||
TimeStamp mStartTime;
|
||||
|
||||
nsPoint mStartPos;
|
||||
nsPoint mDestination;
|
||||
TimeStamp mLastSimulatedTime;
|
||||
AxisPhysicsMSDModel mModelX;
|
||||
AxisPhysicsMSDModel mModelY;
|
||||
bool mIsFirstIteration;
|
||||
};
|
||||
|
||||
} // namespace mozilla
|
||||
|
||||
#endif // mozilla_layout_ScrollAnimationMSDPhysics_h_
|
48
layout/generic/ScrollAnimationPhysics.h
Normal file
48
layout/generic/ScrollAnimationPhysics.h
Normal file
@ -0,0 +1,48 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* 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_layout_ScrollAnimationPhysics_h_
|
||||
#define mozilla_layout_ScrollAnimationPhysics_h_
|
||||
|
||||
#include "mozilla/TimeStamp.h"
|
||||
#include "nsPoint.h"
|
||||
|
||||
namespace mozilla {
|
||||
|
||||
class ScrollAnimationPhysics
|
||||
{
|
||||
public:
|
||||
virtual void Update(const TimeStamp& aTime,
|
||||
const nsPoint& aDestination,
|
||||
const nsSize& aCurrentVelocity) = 0;
|
||||
|
||||
// Get the velocity at a point in time in nscoords/sec.
|
||||
virtual nsSize VelocityAt(const TimeStamp& aTime) = 0;
|
||||
|
||||
// Returns the expected scroll position at a given point in time, in app
|
||||
// units, relative to the scroll frame.
|
||||
virtual nsPoint PositionAt(const TimeStamp& aTime) = 0;
|
||||
|
||||
virtual bool IsFinished(const TimeStamp& aTime) = 0;
|
||||
|
||||
virtual ~ScrollAnimationPhysics() {}
|
||||
};
|
||||
|
||||
// Helper for accelerated wheel deltas. This can be called from the main thread
|
||||
// or the APZ Controller thread.
|
||||
static inline double
|
||||
ComputeAcceleratedWheelDelta(double aDelta, int32_t aCounter, int32_t aFactor)
|
||||
{
|
||||
if (!aDelta) {
|
||||
return aDelta;
|
||||
}
|
||||
return (aDelta * aCounter * double(aFactor) / 10);
|
||||
}
|
||||
|
||||
static const uint32_t kScrollSeriesTimeoutMs = 80; // in milliseconds
|
||||
|
||||
} // namespace mozilla
|
||||
|
||||
#endif // mozilla_layout_ScrollAnimationPhysics_h_
|
@ -68,7 +68,6 @@ with Files('nsVideoFrame.*'):
|
||||
BUG_COMPONENT = ('Core', 'Audio/Video')
|
||||
|
||||
EXPORTS += [
|
||||
'AsyncScrollBase.h',
|
||||
'nsCanvasFrame.h',
|
||||
'nsContainerFrame.h',
|
||||
'nsDirection.h',
|
||||
@ -101,6 +100,9 @@ EXPORTS += [
|
||||
'nsTextFrameUtils.h',
|
||||
'nsTextRunTransformations.h',
|
||||
'RubyUtils.h',
|
||||
'ScrollAnimationBezierPhysics.h',
|
||||
'ScrollAnimationMSDPhysics.h',
|
||||
'ScrollAnimationPhysics.h',
|
||||
'ScrollbarActivity.h',
|
||||
'ScrollSnap.h',
|
||||
'TextDrawTarget.h',
|
||||
@ -122,7 +124,6 @@ EXPORTS.mozilla.layout += [
|
||||
]
|
||||
|
||||
UNIFIED_SOURCES += [
|
||||
'AsyncScrollBase.cpp',
|
||||
'BlockReflowInput.cpp',
|
||||
'BRFrame.cpp',
|
||||
'CSSAlignUtils.cpp',
|
||||
@ -177,6 +178,8 @@ UNIFIED_SOURCES += [
|
||||
'ReflowInput.cpp',
|
||||
'ReflowOutput.cpp',
|
||||
'RubyUtils.cpp',
|
||||
'ScrollAnimationBezierPhysics.cpp',
|
||||
'ScrollAnimationMSDPhysics.cpp',
|
||||
'ScrollbarActivity.cpp',
|
||||
'ScrollSnap.cpp',
|
||||
'ScrollVelocityQueue.cpp',
|
||||
|
@ -57,7 +57,9 @@
|
||||
#include "nsIFrameInlines.h"
|
||||
#include "gfxPlatform.h"
|
||||
#include "gfxPrefs.h"
|
||||
#include "AsyncScrollBase.h"
|
||||
#include "ScrollAnimationPhysics.h"
|
||||
#include "ScrollAnimationBezierPhysics.h"
|
||||
#include "ScrollAnimationMSDPhysics.h"
|
||||
#include "ScrollSnap.h"
|
||||
#include "UnitTransforms.h"
|
||||
#include "nsPluginFrame.h"
|
||||
@ -1799,16 +1801,14 @@ private:
|
||||
|
||||
// AsyncScroll has ref counting.
|
||||
class ScrollFrameHelper::AsyncScroll final
|
||||
: public nsARefreshObserver,
|
||||
public AsyncScrollBase
|
||||
: public nsARefreshObserver
|
||||
{
|
||||
public:
|
||||
typedef mozilla::TimeStamp TimeStamp;
|
||||
typedef mozilla::TimeDuration TimeDuration;
|
||||
|
||||
explicit AsyncScroll(nsPoint aStartPos)
|
||||
: AsyncScrollBase(aStartPos)
|
||||
, mCallee(nullptr)
|
||||
explicit AsyncScroll()
|
||||
: mCallee(nullptr)
|
||||
{
|
||||
Telemetry::SetHistogramRecordingEnabled(
|
||||
Telemetry::FX_REFRESH_DRIVER_SYNC_SCROLL_FRAME_DELAY_MS, true);
|
||||
@ -1823,23 +1823,43 @@ private:
|
||||
}
|
||||
|
||||
public:
|
||||
void InitSmoothScroll(TimeStamp aTime, nsPoint aDestination,
|
||||
void InitSmoothScroll(TimeStamp aTime,
|
||||
nsPoint aInitialPosition, nsPoint aDestination,
|
||||
nsIAtom *aOrigin, const nsRect& aRange,
|
||||
const nsSize& aCurrentVelocity);
|
||||
void Init(const nsRect& aRange) {
|
||||
mAnimationPhysics = nullptr;
|
||||
mRange = aRange;
|
||||
}
|
||||
|
||||
bool IsSmoothScroll() { return mAnimationPhysics != nullptr; }
|
||||
|
||||
bool IsFinished(const TimeStamp& aTime) const {
|
||||
MOZ_RELEASE_ASSERT(mAnimationPhysics);
|
||||
return mAnimationPhysics->IsFinished(aTime);
|
||||
}
|
||||
|
||||
nsPoint PositionAt(const TimeStamp& aTime) const {
|
||||
MOZ_RELEASE_ASSERT(mAnimationPhysics);
|
||||
return mAnimationPhysics->PositionAt(aTime);
|
||||
}
|
||||
|
||||
nsSize VelocityAt(const TimeStamp& aTime) const {
|
||||
MOZ_RELEASE_ASSERT(mAnimationPhysics);
|
||||
return mAnimationPhysics->VelocityAt(aTime);
|
||||
}
|
||||
|
||||
// Most recent scroll origin.
|
||||
RefPtr<nsIAtom> mOrigin;
|
||||
|
||||
// Allowed destination positions around mDestination
|
||||
nsRect mRange;
|
||||
bool mIsSmoothScroll;
|
||||
|
||||
private:
|
||||
void InitPreferences(TimeStamp aTime, nsIAtom *aOrigin);
|
||||
|
||||
UniquePtr<ScrollAnimationPhysics> mAnimationPhysics;
|
||||
|
||||
// The next section is observer/callback management
|
||||
// Bodies of WillRefresh and RefreshDriver contain ScrollFrameHelper specific code.
|
||||
public:
|
||||
@ -1892,28 +1912,13 @@ private:
|
||||
* Calculate duration, possibly dynamically according to events rate and event origin.
|
||||
* (also maintain previous timestamps - which are only used here).
|
||||
*/
|
||||
void
|
||||
ScrollFrameHelper::AsyncScroll::InitPreferences(TimeStamp aTime, nsIAtom *aOrigin)
|
||||
static ScrollAnimationBezierPhysicsSettings
|
||||
ComputeBezierAnimationSettingsForOrigin(nsIAtom *aOrigin)
|
||||
{
|
||||
if (!aOrigin || aOrigin == nsGkAtoms::restore) {
|
||||
// We don't have special prefs for "restore", just treat it as "other".
|
||||
// "restore" scrolls are (for now) always instant anyway so unless something
|
||||
// changes we should never have aOrigin == nsGkAtoms::restore here.
|
||||
aOrigin = nsGkAtoms::other;
|
||||
}
|
||||
// Likewise we should never get APZ-triggered scrolls here, and if that changes
|
||||
// something is likely broken somewhere.
|
||||
MOZ_ASSERT(aOrigin != nsGkAtoms::apz);
|
||||
|
||||
// Read preferences only on first iteration or for a different event origin.
|
||||
if (!mIsFirstIteration && aOrigin == mOrigin) {
|
||||
return;
|
||||
}
|
||||
|
||||
mOrigin = aOrigin;
|
||||
mOriginMinMS = mOriginMaxMS = 0;
|
||||
int32_t minMS = 0;
|
||||
int32_t maxMS = 0;
|
||||
bool isOriginSmoothnessEnabled = false;
|
||||
mIntervalRatio = 1;
|
||||
double intervalRatio = 1;
|
||||
|
||||
// Default values for all preferences are defined in all.js
|
||||
static const int32_t kDefaultMinMS = 150, kDefaultMaxMS = 150;
|
||||
@ -1927,39 +1932,60 @@ ScrollFrameHelper::AsyncScroll::InitPreferences(TimeStamp aTime, nsIAtom *aOrigi
|
||||
if (isOriginSmoothnessEnabled) {
|
||||
nsAutoCString prefMin = prefBase + NS_LITERAL_CSTRING(".durationMinMS");
|
||||
nsAutoCString prefMax = prefBase + NS_LITERAL_CSTRING(".durationMaxMS");
|
||||
mOriginMinMS = Preferences::GetInt(prefMin.get(), kDefaultMinMS);
|
||||
mOriginMaxMS = Preferences::GetInt(prefMax.get(), kDefaultMaxMS);
|
||||
minMS = Preferences::GetInt(prefMin.get(), kDefaultMinMS);
|
||||
maxMS = Preferences::GetInt(prefMax.get(), kDefaultMaxMS);
|
||||
|
||||
static const int32_t kSmoothScrollMaxAllowedAnimationDurationMS = 10000;
|
||||
mOriginMaxMS = clamped(mOriginMaxMS, 0, kSmoothScrollMaxAllowedAnimationDurationMS);
|
||||
mOriginMinMS = clamped(mOriginMinMS, 0, mOriginMaxMS);
|
||||
maxMS = clamped(maxMS, 0, kSmoothScrollMaxAllowedAnimationDurationMS);
|
||||
minMS = clamped(minMS, 0, maxMS);
|
||||
}
|
||||
|
||||
// Keep the animation duration longer than the average event intervals
|
||||
// (to "connect" consecutive scroll animations before the scroll comes to a stop).
|
||||
static const double kDefaultDurationToIntervalRatio = 2; // Duplicated at all.js
|
||||
mIntervalRatio = Preferences::GetInt("general.smoothScroll.durationToIntervalRatio",
|
||||
kDefaultDurationToIntervalRatio * 100) / 100.0;
|
||||
intervalRatio = Preferences::GetInt("general.smoothScroll.durationToIntervalRatio",
|
||||
kDefaultDurationToIntervalRatio * 100) / 100.0;
|
||||
|
||||
// Duration should be at least as long as the intervals -> ratio is at least 1
|
||||
mIntervalRatio = std::max(1.0, mIntervalRatio);
|
||||
intervalRatio = std::max(1.0, intervalRatio);
|
||||
|
||||
if (mIsFirstIteration) {
|
||||
InitializeHistory(aTime);
|
||||
}
|
||||
return ScrollAnimationBezierPhysicsSettings { minMS, maxMS, intervalRatio };
|
||||
}
|
||||
|
||||
void
|
||||
ScrollFrameHelper::AsyncScroll::InitSmoothScroll(TimeStamp aTime,
|
||||
nsPoint aInitialPosition,
|
||||
nsPoint aDestination,
|
||||
nsIAtom *aOrigin,
|
||||
const nsRect& aRange,
|
||||
const nsSize& aCurrentVelocity)
|
||||
{
|
||||
InitPreferences(aTime, aOrigin);
|
||||
if (!aOrigin || aOrigin == nsGkAtoms::restore) {
|
||||
// We don't have special prefs for "restore", just treat it as "other".
|
||||
// "restore" scrolls are (for now) always instant anyway so unless something
|
||||
// changes we should never have aOrigin == nsGkAtoms::restore here.
|
||||
aOrigin = nsGkAtoms::other;
|
||||
}
|
||||
// Likewise we should never get APZ-triggered scrolls here, and if that changes
|
||||
// something is likely broken somewhere.
|
||||
MOZ_ASSERT(aOrigin != nsGkAtoms::apz);
|
||||
|
||||
// Read preferences only on first iteration or for a different event origin.
|
||||
if (!mAnimationPhysics || aOrigin != mOrigin) {
|
||||
mOrigin = aOrigin;
|
||||
if (gfxPrefs::SmoothScrollMSDPhysicsEnabled()) {
|
||||
mAnimationPhysics = MakeUnique<ScrollAnimationMSDPhysics>(aInitialPosition);
|
||||
} else {
|
||||
ScrollAnimationBezierPhysicsSettings settings =
|
||||
ComputeBezierAnimationSettingsForOrigin(mOrigin);
|
||||
mAnimationPhysics =
|
||||
MakeUnique<ScrollAnimationBezierPhysics>(aInitialPosition, settings);
|
||||
}
|
||||
}
|
||||
|
||||
mRange = aRange;
|
||||
|
||||
Update(aTime, aDestination, aCurrentVelocity);
|
||||
mAnimationPhysics->Update(aTime, aDestination, aCurrentVelocity);
|
||||
}
|
||||
|
||||
bool
|
||||
@ -2127,7 +2153,7 @@ ScrollFrameHelper::AsyncScrollCallback(ScrollFrameHelper* aInstance,
|
||||
}
|
||||
|
||||
nsRect range = aInstance->mAsyncScroll->mRange;
|
||||
if (aInstance->mAsyncScroll->mIsSmoothScroll) {
|
||||
if (aInstance->mAsyncScroll->IsSmoothScroll()) {
|
||||
if (!aInstance->mAsyncScroll->IsFinished(aTime)) {
|
||||
nsPoint destination = aInstance->mAsyncScroll->PositionAt(aTime);
|
||||
// Allow this scroll operation to land on any pixel boundary between the
|
||||
@ -2291,7 +2317,7 @@ ScrollFrameHelper::ScrollToWithOrigin(nsPoint aScrollPosition,
|
||||
currentVelocity.width = sv.x;
|
||||
currentVelocity.height = sv.y;
|
||||
if (mAsyncScroll) {
|
||||
if (mAsyncScroll->mIsSmoothScroll) {
|
||||
if (mAsyncScroll->IsSmoothScroll()) {
|
||||
currentVelocity = mAsyncScroll->VelocityAt(now);
|
||||
}
|
||||
mAsyncScroll = nullptr;
|
||||
@ -2372,7 +2398,7 @@ ScrollFrameHelper::ScrollToWithOrigin(nsPoint aScrollPosition,
|
||||
}
|
||||
|
||||
if (!mAsyncScroll) {
|
||||
mAsyncScroll = new AsyncScroll(GetScrollPosition());
|
||||
mAsyncScroll = new AsyncScroll();
|
||||
if (!mAsyncScroll->SetRefreshObserver(this)) {
|
||||
// Observer setup failed. Scroll the normal way.
|
||||
CompleteAsyncScroll(range, aOrigin);
|
||||
@ -2380,10 +2406,9 @@ ScrollFrameHelper::ScrollToWithOrigin(nsPoint aScrollPosition,
|
||||
}
|
||||
}
|
||||
|
||||
mAsyncScroll->mIsSmoothScroll = isSmoothScroll;
|
||||
|
||||
if (isSmoothScroll) {
|
||||
mAsyncScroll->InitSmoothScroll(now, mDestination, aOrigin, range, currentVelocity);
|
||||
mAsyncScroll->InitSmoothScroll(now, GetScrollPosition(), mDestination,
|
||||
aOrigin, range, currentVelocity);
|
||||
} else {
|
||||
mAsyncScroll->Init(range);
|
||||
}
|
||||
|
@ -2806,6 +2806,14 @@ pref("general.smoothScroll.durationToIntervalRatio", 200);
|
||||
// These two prefs determine the timing function.
|
||||
pref("general.smoothScroll.currentVelocityWeighting", "0.25");
|
||||
pref("general.smoothScroll.stopDecelerationWeighting", "0.4");
|
||||
// Alternative smooth scroll physics ("MSD" = Mass-Spring-Damper)
|
||||
pref("general.smoothScroll.msdPhysics.enabled", false);
|
||||
pref("general.smoothScroll.msdPhysics.continuousMotionMaxDeltaMS", 120);
|
||||
pref("general.smoothScroll.msdPhysics.motionBeginSpringConstant", 1250);
|
||||
pref("general.smoothScroll.msdPhysics.slowdownMinDeltaMS", 12);
|
||||
pref("general.smoothScroll.msdPhysics.slowdownMinDeltaRatio", "1.3");
|
||||
pref("general.smoothScroll.msdPhysics.slowdownSpringConstant", 2000);
|
||||
pref("general.smoothScroll.msdPhysics.regularSpringConstant", 1000);
|
||||
|
||||
pref("profile.confirm_automigration",true);
|
||||
// profile.migration_behavior determines how the profiles root is set
|
||||
|
@ -262,8 +262,8 @@ static const char contentSandboxRules[] = R"(
|
||||
|
||||
; Per-user and system-wide Extensions dir
|
||||
(allow file-read*
|
||||
(home-regex "/Library/Application Support/[^/]+/Extensions/[^/]/")
|
||||
(regex #"^/Library/Application Support/[^/]+/Extensions/[^/]/"))
|
||||
(home-regex "/Library/Application Support/[^/]+/Extensions/")
|
||||
(regex "^/Library/Application Support/[^/]+/Extensions/"))
|
||||
|
||||
; The following rules impose file access restrictions which get
|
||||
; more restrictive in higher levels. When file-origin-specific
|
||||
|
39
servo/Cargo.lock
generated
39
servo/Cargo.lock
generated
@ -4,7 +4,7 @@ version = "0.0.1"
|
||||
dependencies = [
|
||||
"ipc-channel 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"msg 0.0.1",
|
||||
"rust-webvr-api 0.8.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"rust-webvr-api 0.9.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"serde 1.0.14 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
@ -1217,6 +1217,11 @@ dependencies = [
|
||||
"libc 0.2.23 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "gvr-sys"
|
||||
version = "0.5.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
|
||||
[[package]]
|
||||
name = "half"
|
||||
version = "1.0.0"
|
||||
@ -2211,6 +2216,11 @@ dependencies = [
|
||||
"shared_library 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "ovr-mobile-sys"
|
||||
version = "0.3.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
|
||||
[[package]]
|
||||
name = "owning_ref"
|
||||
version = "0.3.3"
|
||||
@ -2337,7 +2347,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "precomputed-hash"
|
||||
version = "0.1.0"
|
||||
version = "0.1.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
|
||||
[[package]]
|
||||
@ -2503,19 +2513,20 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
|
||||
[[package]]
|
||||
name = "rust-webvr"
|
||||
version = "0.8.1"
|
||||
version = "0.9.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"gl_generator 0.5.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"gvr-sys 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"libloading 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"log 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"rust-webvr-api 0.8.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"time 0.1.37 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"ovr-mobile-sys 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"rust-webvr-api 0.9.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "rust-webvr-api"
|
||||
version = "0.8.2"
|
||||
version = "0.9.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"android_injected_glue 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
@ -2729,7 +2740,7 @@ dependencies = [
|
||||
"matches 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"phf 0.7.21 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"phf_codegen 0.7.21 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"precomputed-hash 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"precomputed-hash 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"servo_arc 0.0.1",
|
||||
"size_of_test 0.0.1",
|
||||
"smallvec 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
@ -3088,7 +3099,7 @@ dependencies = [
|
||||
"heapsize 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"lazy_static 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"phf_shared 0.7.21 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"precomputed-hash 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"precomputed-hash 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"serde 1.0.14 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"string_cache_codegen 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"string_cache_shared 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
@ -3152,7 +3163,7 @@ dependencies = [
|
||||
"owning_ref 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"parking_lot 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"pdqsort 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"precomputed-hash 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"precomputed-hash 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"rayon 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"regex 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"selectors 0.19.0",
|
||||
@ -3657,7 +3668,7 @@ dependencies = [
|
||||
"ipc-channel 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"log 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"msg 0.0.1",
|
||||
"rust-webvr 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"rust-webvr 0.9.4 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"script_traits 0.0.1",
|
||||
"servo_config 0.0.1",
|
||||
"webvr_traits 0.0.1",
|
||||
@ -3870,6 +3881,7 @@ dependencies = [
|
||||
"checksum gleam 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)" = "bf887141f0c2a83eae026cbf3fba74f0a5cb0f01d20e5cdfcd8c4ad39295be1e"
|
||||
"checksum glob 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)" = "8be18de09a56b60ed0edf84bc9df007e30040691af7acd1c41874faac5895bfb"
|
||||
"checksum glx 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "b280007fa9c7442cfd1e0b1addb8d1a59240267110e8705f8f7e2c7bfb7e2f72"
|
||||
"checksum gvr-sys 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)" = "e84ba5e13cd925de87b669475525f956f8e936e67ddb24fbb1a077d96bbe174c"
|
||||
"checksum half 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "63d68db75012a85555434ee079e7e6337931f87a087ab2988becbadf64673a7f"
|
||||
"checksum harfbuzz-sys 0.1.14 (registry+https://github.com/rust-lang/crates.io-index)" = "a2caaa66078fdfacea32db1351223697a1167ad2d4bbee6b8d4ca220ce5b10b3"
|
||||
"checksum heapsize 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "4c7593b1522161003928c959c20a2ca421c68e940d63d75573316a009e48a6d4"
|
||||
@ -3944,6 +3956,7 @@ dependencies = [
|
||||
"checksum ordered-float 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "da12c96037889ae0be29dd2bdd260e5a62a7df24e6466d5a15bb8131c1c200a8"
|
||||
"checksum osmesa-src 17.2.0-devel (git+https://github.com/servo/osmesa-src)" = "<none>"
|
||||
"checksum osmesa-sys 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "88cfece6e95d2e717e0872a7f53a8684712ad13822a7979bc760b9c77ec0013b"
|
||||
"checksum ovr-mobile-sys 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "b7b5f9389b2015f8340f0566c488f3e96735e2e8fd7b85d571832cd274ac2998"
|
||||
"checksum owning_ref 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "cdf84f41639e037b484f93433aa3897863b561ed65c6e59c7073d7c561710f37"
|
||||
"checksum parking_lot 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)" = "149d8f5b97f3c1133e3cfcd8886449959e856b557ff281e292b733d7c69e005e"
|
||||
"checksum parking_lot_core 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)" = "4f610cb9664da38e417ea3225f23051f589851999535290e077939838ab7a595"
|
||||
@ -3958,7 +3971,7 @@ dependencies = [
|
||||
"checksum pkg-config 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)" = "3a8b4c6b8165cd1a1cd4b9b120978131389f64bdaf456435caa41e630edba903"
|
||||
"checksum plane-split 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)" = "e57800a97ca52c556db6b6184a3201f05366ad5e11876f7d17e234589ca2fa26"
|
||||
"checksum png 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)" = "6535266009941ceac9a17e6d681cd2adc75611cd4833db853282e8d4c470239c"
|
||||
"checksum precomputed-hash 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "cdf1fc3616b3ef726a847f2cd2388c646ef6a1f1ba4835c2629004da48184150"
|
||||
"checksum precomputed-hash 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "925383efa346730478fb4838dbe9137d2a47675ad789c546d150a6e1dd4ab31c"
|
||||
"checksum procedural-masquerade 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "c93cdc1fb30af9ddf3debc4afbdb0f35126cbd99daa229dd76cdd5349b41d989"
|
||||
"checksum pulldown-cmark 0.0.8 (registry+https://github.com/rust-lang/crates.io-index)" = "1058d7bb927ca067656537eec4e02c2b4b70eaaa129664c5b90c111e20326f41"
|
||||
"checksum push-trait 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)" = "fdc13b1a53bc505b526086361221aaa612fefb9b0ecf2853f9d31f807764e004"
|
||||
@ -3973,8 +3986,8 @@ dependencies = [
|
||||
"checksum ref_slice 1.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "825740057197b7d43025e7faf6477eaabc03434e153233da02d1f44602f71527"
|
||||
"checksum regex 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "1731164734096285ec2a5ec7fea5248ae2f5485b3feeb0115af4fda2183b2d1b"
|
||||
"checksum regex-syntax 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)" = "ad890a5eef7953f55427c50575c680c42841653abd2b028b68cd223d157f62db"
|
||||
"checksum rust-webvr 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)" = "4514c041e0b1f7e00038acf19f0421c9cd77a629e0e111f319abbde714742003"
|
||||
"checksum rust-webvr-api 0.8.2 (registry+https://github.com/rust-lang/crates.io-index)" = "9ece2e3ecae072ebf033811082cd58ddb46910af1a7e26b0917fdf455a20aab3"
|
||||
"checksum rust-webvr 0.9.4 (registry+https://github.com/rust-lang/crates.io-index)" = "c1ab572fff7a623e973511c7fc615e9f74a2429946b826c5c16a2f017489b79a"
|
||||
"checksum rust-webvr-api 0.9.2 (registry+https://github.com/rust-lang/crates.io-index)" = "712e22ba3c03a7075b40842ae91029a0ab96a81f95e97c0cf623800ec0cbac07"
|
||||
"checksum rustc-demangle 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)" = "3058a43ada2c2d0b92b3ae38007a2d0fa5e9db971be260e0171408a4ff471c95"
|
||||
"checksum rustc-serialize 0.3.24 (registry+https://github.com/rust-lang/crates.io-index)" = "dcf128d1287d2ea9d80910b5f1120d0b8eede3fbf1abe91c40d39ea7d51e6fda"
|
||||
"checksum rustc_version 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)" = "c5f5376ea5e30ce23c03eb77cbe4962b988deead10910c372b226388b594c084"
|
||||
|
@ -6142,8 +6142,7 @@ class CGDictionary(CGThing):
|
||||
" } else if val.get().is_object() {\n"
|
||||
" val.get().to_object()\n"
|
||||
" } else {\n"
|
||||
" throw_type_error(cx, \"Value not an object.\");\n"
|
||||
" return Err(());\n"
|
||||
" return Ok(ConversionResult::Failure(\"Value is not an object.\".into()));\n"
|
||||
" };\n"
|
||||
" rooted!(in(cx) let object = object);\n"
|
||||
"${preInitial}"
|
||||
|
@ -12,8 +12,12 @@ use dom::bindings::codegen::Bindings::EventHandlerBinding::EventHandlerNonNull;
|
||||
use dom::bindings::codegen::Bindings::EventHandlerBinding::OnBeforeUnloadEventHandlerNonNull;
|
||||
use dom::bindings::codegen::Bindings::EventHandlerBinding::OnErrorEventHandlerNonNull;
|
||||
use dom::bindings::codegen::Bindings::EventListenerBinding::EventListener;
|
||||
use dom::bindings::codegen::Bindings::EventTargetBinding::AddEventListenerOptions;
|
||||
use dom::bindings::codegen::Bindings::EventTargetBinding::EventListenerOptions;
|
||||
use dom::bindings::codegen::Bindings::EventTargetBinding::EventTargetMethods;
|
||||
use dom::bindings::codegen::Bindings::WindowBinding::WindowMethods;
|
||||
use dom::bindings::codegen::UnionTypes::AddEventListenerOptionsOrBoolean;
|
||||
use dom::bindings::codegen::UnionTypes::EventListenerOptionsOrBoolean;
|
||||
use dom::bindings::codegen::UnionTypes::EventOrString;
|
||||
use dom::bindings::error::{Error, Fallible, report_pending_exception};
|
||||
use dom::bindings::inheritance::Castable;
|
||||
@ -543,14 +547,13 @@ impl EventTarget {
|
||||
event.fire(self);
|
||||
event
|
||||
}
|
||||
}
|
||||
|
||||
impl EventTargetMethods for EventTarget {
|
||||
// https://dom.spec.whatwg.org/#dom-eventtarget-addeventlistener
|
||||
fn AddEventListener(&self,
|
||||
ty: DOMString,
|
||||
listener: Option<Rc<EventListener>>,
|
||||
capture: bool) {
|
||||
pub fn add_event_listener(
|
||||
&self,
|
||||
ty: DOMString,
|
||||
listener: Option<Rc<EventListener>>,
|
||||
options: AddEventListenerOptions,
|
||||
) {
|
||||
let listener = match listener {
|
||||
Some(l) => l,
|
||||
None => return,
|
||||
@ -561,7 +564,11 @@ impl EventTargetMethods for EventTarget {
|
||||
Vacant(entry) => entry.insert(EventListeners(vec!())),
|
||||
};
|
||||
|
||||
let phase = if capture { ListenerPhase::Capturing } else { ListenerPhase::Bubbling };
|
||||
let phase = if options.parent.capture {
|
||||
ListenerPhase::Capturing
|
||||
} else {
|
||||
ListenerPhase::Bubbling
|
||||
};
|
||||
let new_entry = EventListenerEntry {
|
||||
phase: phase,
|
||||
listener: EventListenerType::Additive(listener)
|
||||
@ -572,10 +579,12 @@ impl EventTargetMethods for EventTarget {
|
||||
}
|
||||
|
||||
// https://dom.spec.whatwg.org/#dom-eventtarget-removeeventlistener
|
||||
fn RemoveEventListener(&self,
|
||||
ty: DOMString,
|
||||
listener: Option<Rc<EventListener>>,
|
||||
capture: bool) {
|
||||
pub fn remove_event_listener(
|
||||
&self,
|
||||
ty: DOMString,
|
||||
listener: Option<Rc<EventListener>>,
|
||||
options: EventListenerOptions,
|
||||
) {
|
||||
let ref listener = match listener {
|
||||
Some(l) => l,
|
||||
None => return,
|
||||
@ -583,7 +592,11 @@ impl EventTargetMethods for EventTarget {
|
||||
let mut handlers = self.handlers.borrow_mut();
|
||||
let entry = handlers.get_mut(&Atom::from(ty));
|
||||
for entry in entry {
|
||||
let phase = if capture { ListenerPhase::Capturing } else { ListenerPhase::Bubbling };
|
||||
let phase = if options.capture {
|
||||
ListenerPhase::Capturing
|
||||
} else {
|
||||
ListenerPhase::Bubbling
|
||||
};
|
||||
let old_entry = EventListenerEntry {
|
||||
phase: phase,
|
||||
listener: EventListenerType::Additive(listener.clone())
|
||||
@ -593,6 +606,28 @@ impl EventTargetMethods for EventTarget {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl EventTargetMethods for EventTarget {
|
||||
// https://dom.spec.whatwg.org/#dom-eventtarget-addeventlistener
|
||||
fn AddEventListener(
|
||||
&self,
|
||||
ty: DOMString,
|
||||
listener: Option<Rc<EventListener>>,
|
||||
options: AddEventListenerOptionsOrBoolean,
|
||||
) {
|
||||
self.add_event_listener(ty, listener, options.into())
|
||||
}
|
||||
|
||||
// https://dom.spec.whatwg.org/#dom-eventtarget-removeeventlistener
|
||||
fn RemoveEventListener(
|
||||
&self,
|
||||
ty: DOMString,
|
||||
listener: Option<Rc<EventListener>>,
|
||||
options: EventListenerOptionsOrBoolean,
|
||||
) {
|
||||
self.remove_event_listener(ty, listener, options.into())
|
||||
}
|
||||
|
||||
// https://dom.spec.whatwg.org/#dom-eventtarget-dispatchevent
|
||||
fn DispatchEvent(&self, event: &Event) -> Fallible<bool> {
|
||||
@ -612,3 +647,29 @@ impl VirtualMethods for EventTarget {
|
||||
None
|
||||
}
|
||||
}
|
||||
|
||||
impl From<AddEventListenerOptionsOrBoolean> for AddEventListenerOptions {
|
||||
fn from(options: AddEventListenerOptionsOrBoolean) -> Self {
|
||||
match options {
|
||||
AddEventListenerOptionsOrBoolean::AddEventListenerOptions(options) => {
|
||||
options
|
||||
},
|
||||
AddEventListenerOptionsOrBoolean::Boolean(capture) => {
|
||||
Self { parent: EventListenerOptions { capture } }
|
||||
},
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl From<EventListenerOptionsOrBoolean> for EventListenerOptions {
|
||||
fn from(options: EventListenerOptionsOrBoolean) -> Self {
|
||||
match options {
|
||||
EventListenerOptionsOrBoolean::EventListenerOptions(options) => {
|
||||
options
|
||||
},
|
||||
EventListenerOptionsOrBoolean::Boolean(capture) => {
|
||||
Self { capture }
|
||||
},
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -4,7 +4,8 @@
|
||||
|
||||
use dom::bindings::cell::DomRefCell;
|
||||
use dom::bindings::codegen::Bindings::EventListenerBinding::EventListener;
|
||||
use dom::bindings::codegen::Bindings::EventTargetBinding::EventTargetMethods;
|
||||
use dom::bindings::codegen::Bindings::EventTargetBinding::AddEventListenerOptions;
|
||||
use dom::bindings::codegen::Bindings::EventTargetBinding::EventListenerOptions;
|
||||
use dom::bindings::codegen::Bindings::MediaQueryListBinding::{self, MediaQueryListMethods};
|
||||
use dom::bindings::inheritance::Castable;
|
||||
use dom::bindings::reflector::DomObject;
|
||||
@ -97,14 +98,20 @@ impl MediaQueryListMethods for MediaQueryList {
|
||||
|
||||
// https://drafts.csswg.org/cssom-view/#dom-mediaquerylist-addlistener
|
||||
fn AddListener(&self, listener: Option<Rc<EventListener>>) {
|
||||
self.upcast::<EventTarget>().AddEventListener(DOMString::from_string("change".to_owned()),
|
||||
listener, false);
|
||||
self.upcast::<EventTarget>().add_event_listener(
|
||||
DOMString::from_string("change".to_owned()),
|
||||
listener,
|
||||
AddEventListenerOptions { parent: EventListenerOptions { capture: false } },
|
||||
);
|
||||
}
|
||||
|
||||
// https://drafts.csswg.org/cssom-view/#dom-mediaquerylist-removelistener
|
||||
fn RemoveListener(&self, listener: Option<Rc<EventListener>>) {
|
||||
self.upcast::<EventTarget>().RemoveEventListener(DOMString::from_string("change".to_owned()),
|
||||
listener, false);
|
||||
self.upcast::<EventTarget>().remove_event_listener(
|
||||
DOMString::from_string("change".to_owned()),
|
||||
listener,
|
||||
EventListenerOptions { capture: false },
|
||||
);
|
||||
}
|
||||
|
||||
// https://drafts.csswg.org/cssom-view/#dom-mediaquerylist-onchange
|
||||
|
@ -7,12 +7,27 @@
|
||||
|
||||
[Abstract, Exposed=(Window,Worker,Worklet)]
|
||||
interface EventTarget {
|
||||
void addEventListener(DOMString type,
|
||||
EventListener? listener,
|
||||
optional boolean capture = false);
|
||||
void removeEventListener(DOMString type,
|
||||
EventListener? listener,
|
||||
optional boolean capture = false);
|
||||
void addEventListener(
|
||||
DOMString type,
|
||||
EventListener? callback,
|
||||
optional (AddEventListenerOptions or boolean) options
|
||||
);
|
||||
|
||||
void removeEventListener(
|
||||
DOMString type,
|
||||
EventListener? callback,
|
||||
optional (EventListenerOptions or boolean) options
|
||||
);
|
||||
|
||||
[Throws]
|
||||
boolean dispatchEvent(Event event);
|
||||
};
|
||||
|
||||
dictionary EventListenerOptions {
|
||||
boolean capture = false;
|
||||
};
|
||||
|
||||
dictionary AddEventListenerOptions : EventListenerOptions {
|
||||
// boolean passive = false;
|
||||
// boolean once = false;
|
||||
};
|
||||
|
@ -17,6 +17,8 @@ max_log_level = ["log/release_max_level_info"]
|
||||
webdriver = ["webdriver_server"]
|
||||
energy-profiling = ["profile_traits/energy-profiling"]
|
||||
debugmozjs = ["script/debugmozjs"]
|
||||
googlevr = ["webvr/googlevr"]
|
||||
oculusvr = ["webvr/oculusvr"]
|
||||
|
||||
[dependencies]
|
||||
bluetooth_traits = {path = "../bluetooth_traits"}
|
||||
|
@ -61,7 +61,7 @@ ordered-float = "0.4"
|
||||
owning_ref = "0.3.3"
|
||||
parking_lot = "0.4"
|
||||
pdqsort = "0.1.0"
|
||||
precomputed-hash = "0.1"
|
||||
precomputed-hash = "0.1.1"
|
||||
rayon = "0.8"
|
||||
selectors = { path = "../selectors" }
|
||||
serde = {version = "1.0", optional = true, features = ["derive"]}
|
||||
|
@ -8,9 +8,10 @@
|
||||
|
||||
use Atom;
|
||||
use cssparser::{Delimiter, Parser, ParserInput, SourcePosition, Token, TokenSerializationType};
|
||||
use hash::{HashMap, HashSet};
|
||||
use parser::ParserContext;
|
||||
use precomputed_hash::PrecomputedHash;
|
||||
use properties::{CSSWideKeyword, DeclaredValue};
|
||||
use selector_map::{PrecomputedHashSet, PrecomputedHashMap};
|
||||
use selectors::parser::SelectorParseError;
|
||||
use servo_arc::Arc;
|
||||
use std::ascii::AsciiExt;
|
||||
@ -49,7 +50,7 @@ pub struct SpecifiedValue {
|
||||
last_token_type: TokenSerializationType,
|
||||
|
||||
/// Custom property names in var() functions.
|
||||
references: HashSet<Name>,
|
||||
references: PrecomputedHashSet<Name>,
|
||||
}
|
||||
|
||||
/// This struct is a cheap borrowed version of a `SpecifiedValue`.
|
||||
@ -57,7 +58,7 @@ pub struct BorrowedSpecifiedValue<'a> {
|
||||
css: &'a str,
|
||||
first_token_type: TokenSerializationType,
|
||||
last_token_type: TokenSerializationType,
|
||||
references: Option<&'a HashSet<Name>>,
|
||||
references: Option<&'a PrecomputedHashSet<Name>>,
|
||||
}
|
||||
|
||||
/// A computed value is just a set of tokens as well, until we resolve variables
|
||||
@ -99,23 +100,23 @@ pub type CustomPropertiesMap = OrderedMap<Name, ComputedValue>;
|
||||
#[derive(Clone, Debug, Eq, PartialEq)]
|
||||
pub struct OrderedMap<K, V>
|
||||
where
|
||||
K: Eq + Hash + Clone,
|
||||
K: PrecomputedHash + Hash + Eq + Clone,
|
||||
{
|
||||
/// Key index.
|
||||
index: Vec<K>,
|
||||
/// Key-value map.
|
||||
values: HashMap<K, V>,
|
||||
values: PrecomputedHashMap<K, V>,
|
||||
}
|
||||
|
||||
impl<K, V> OrderedMap<K, V>
|
||||
where
|
||||
K: Eq + Hash + Clone,
|
||||
K: Eq + PrecomputedHash + Hash + Clone,
|
||||
{
|
||||
/// Creates a new ordered map.
|
||||
pub fn new() -> Self {
|
||||
OrderedMap {
|
||||
index: Vec::new(),
|
||||
values: HashMap::new(),
|
||||
values: PrecomputedHashMap::default(),
|
||||
}
|
||||
}
|
||||
|
||||
@ -157,7 +158,7 @@ where
|
||||
fn remove<Q: ?Sized>(&mut self, key: &Q) -> Option<V>
|
||||
where
|
||||
K: Borrow<Q>,
|
||||
Q: Hash + Eq,
|
||||
Q: PrecomputedHash + Hash + Eq,
|
||||
{
|
||||
let index = match self.index.iter().position(|k| k.borrow() == key) {
|
||||
Some(p) => p,
|
||||
@ -174,7 +175,7 @@ where
|
||||
/// added to the key-value map.
|
||||
pub struct OrderedMapIterator<'a, K, V>
|
||||
where
|
||||
K: 'a + Eq + Hash + Clone, V: 'a,
|
||||
K: 'a + Eq + PrecomputedHash + Hash + Clone, V: 'a,
|
||||
{
|
||||
/// The OrderedMap itself.
|
||||
inner: &'a OrderedMap<K, V>,
|
||||
@ -184,7 +185,7 @@ where
|
||||
|
||||
impl<'a, K, V> Iterator for OrderedMapIterator<'a, K, V>
|
||||
where
|
||||
K: Eq + Hash + Clone,
|
||||
K: Eq + PrecomputedHash + Hash + Clone,
|
||||
{
|
||||
type Item = (&'a K, &'a V);
|
||||
|
||||
@ -239,9 +240,11 @@ impl ComputedValue {
|
||||
|
||||
impl SpecifiedValue {
|
||||
/// Parse a custom property SpecifiedValue.
|
||||
pub fn parse<'i, 't>(_context: &ParserContext, input: &mut Parser<'i, 't>)
|
||||
-> Result<Box<Self>, ParseError<'i>> {
|
||||
let mut references = Some(HashSet::new());
|
||||
pub fn parse<'i, 't>(
|
||||
_context: &ParserContext,
|
||||
input: &mut Parser<'i, 't>,
|
||||
) -> Result<Box<Self>, ParseError<'i>> {
|
||||
let mut references = Some(PrecomputedHashSet::default());
|
||||
let (first, css, last) = parse_self_contained_declaration_value(input, &mut references)?;
|
||||
Ok(Box::new(SpecifiedValue {
|
||||
css: css.into_owned(),
|
||||
@ -260,14 +263,14 @@ pub fn parse_non_custom_with_var<'i, 't>
|
||||
Ok((first_token_type, css))
|
||||
}
|
||||
|
||||
fn parse_self_contained_declaration_value<'i, 't>
|
||||
(input: &mut Parser<'i, 't>,
|
||||
references: &mut Option<HashSet<Name>>)
|
||||
-> Result<(
|
||||
TokenSerializationType,
|
||||
Cow<'i, str>,
|
||||
TokenSerializationType
|
||||
), ParseError<'i>> {
|
||||
fn parse_self_contained_declaration_value<'i, 't>(
|
||||
input: &mut Parser<'i, 't>,
|
||||
references: &mut Option<PrecomputedHashSet<Name>>
|
||||
) -> Result<
|
||||
(TokenSerializationType, Cow<'i, str>, TokenSerializationType),
|
||||
ParseError<'i>
|
||||
>
|
||||
{
|
||||
let start_position = input.position();
|
||||
let mut missing_closing_characters = String::new();
|
||||
let (first, last) = parse_declaration_value(input, references, &mut missing_closing_characters)?;
|
||||
@ -283,11 +286,11 @@ fn parse_self_contained_declaration_value<'i, 't>
|
||||
}
|
||||
|
||||
/// https://drafts.csswg.org/css-syntax-3/#typedef-declaration-value
|
||||
fn parse_declaration_value<'i, 't>
|
||||
(input: &mut Parser<'i, 't>,
|
||||
references: &mut Option<HashSet<Name>>,
|
||||
missing_closing_characters: &mut String)
|
||||
-> Result<(TokenSerializationType, TokenSerializationType), ParseError<'i>> {
|
||||
fn parse_declaration_value<'i, 't>(
|
||||
input: &mut Parser<'i, 't>,
|
||||
references: &mut Option<PrecomputedHashSet<Name>>,
|
||||
missing_closing_characters: &mut String
|
||||
) -> Result<(TokenSerializationType, TokenSerializationType), ParseError<'i>> {
|
||||
input.parse_until_before(Delimiter::Bang | Delimiter::Semicolon, |input| {
|
||||
// Need at least one token
|
||||
let start = input.state();
|
||||
@ -300,12 +303,11 @@ fn parse_declaration_value<'i, 't>
|
||||
|
||||
/// Like parse_declaration_value, but accept `!` and `;` since they are only
|
||||
/// invalid at the top level
|
||||
fn parse_declaration_value_block<'i, 't>
|
||||
(input: &mut Parser<'i, 't>,
|
||||
references: &mut Option<HashSet<Name>>,
|
||||
missing_closing_characters: &mut String)
|
||||
-> Result<(TokenSerializationType, TokenSerializationType),
|
||||
ParseError<'i>> {
|
||||
fn parse_declaration_value_block<'i, 't>(
|
||||
input: &mut Parser<'i, 't>,
|
||||
references: &mut Option<PrecomputedHashSet<Name>>,
|
||||
missing_closing_characters: &mut String
|
||||
) -> Result<(TokenSerializationType, TokenSerializationType), ParseError<'i>> {
|
||||
let mut token_start = input.position();
|
||||
let mut token = match input.next_including_whitespace_and_comments() {
|
||||
// FIXME: remove clone() when borrows are non-lexical
|
||||
@ -416,9 +418,10 @@ fn parse_declaration_value_block<'i, 't>
|
||||
}
|
||||
|
||||
// If the var function is valid, return Ok((custom_property_name, fallback))
|
||||
fn parse_var_function<'i, 't>(input: &mut Parser<'i, 't>,
|
||||
references: &mut Option<HashSet<Name>>)
|
||||
-> Result<(), ParseError<'i>> {
|
||||
fn parse_var_function<'i, 't>(
|
||||
input: &mut Parser<'i, 't>,
|
||||
references: &mut Option<PrecomputedHashSet<Name>>
|
||||
) -> Result<(), ParseError<'i>> {
|
||||
let name = input.expect_ident_cloned()?;
|
||||
let name: Result<_, ParseError> =
|
||||
parse_name(&name)
|
||||
@ -443,11 +446,13 @@ fn parse_var_function<'i, 't>(input: &mut Parser<'i, 't>,
|
||||
|
||||
/// Add one custom property declaration to a map, unless another with the same
|
||||
/// name was already there.
|
||||
pub fn cascade<'a>(custom_properties: &mut Option<OrderedMap<&'a Name, BorrowedSpecifiedValue<'a>>>,
|
||||
inherited: &'a Option<Arc<CustomPropertiesMap>>,
|
||||
seen: &mut HashSet<&'a Name>,
|
||||
name: &'a Name,
|
||||
specified_value: DeclaredValue<'a, Box<SpecifiedValue>>) {
|
||||
pub fn cascade<'a>(
|
||||
custom_properties: &mut Option<OrderedMap<&'a Name, BorrowedSpecifiedValue<'a>>>,
|
||||
inherited: &'a Option<Arc<CustomPropertiesMap>>,
|
||||
seen: &mut PrecomputedHashSet<&'a Name>,
|
||||
name: &'a Name,
|
||||
specified_value: DeclaredValue<'a, Box<SpecifiedValue>>
|
||||
) {
|
||||
let was_already_present = !seen.insert(name);
|
||||
if was_already_present {
|
||||
return;
|
||||
@ -514,18 +519,20 @@ pub fn finish_cascade(specified_values_map: Option<OrderedMap<&Name, BorrowedSpe
|
||||
/// The initial value of a custom property is represented by this property not
|
||||
/// being in the map.
|
||||
fn remove_cycles(map: &mut OrderedMap<&Name, BorrowedSpecifiedValue>) {
|
||||
let mut to_remove = HashSet::new();
|
||||
let mut to_remove = PrecomputedHashSet::default();
|
||||
{
|
||||
let mut visited = HashSet::new();
|
||||
let mut visited = PrecomputedHashSet::default();
|
||||
let mut stack = Vec::new();
|
||||
for name in &map.index {
|
||||
walk(map, name, &mut stack, &mut visited, &mut to_remove);
|
||||
|
||||
fn walk<'a>(map: &OrderedMap<&'a Name, BorrowedSpecifiedValue<'a>>,
|
||||
name: &'a Name,
|
||||
stack: &mut Vec<&'a Name>,
|
||||
visited: &mut HashSet<&'a Name>,
|
||||
to_remove: &mut HashSet<Name>) {
|
||||
fn walk<'a>(
|
||||
map: &OrderedMap<&'a Name, BorrowedSpecifiedValue<'a>>,
|
||||
name: &'a Name,
|
||||
stack: &mut Vec<&'a Name>,
|
||||
visited: &mut PrecomputedHashSet<&'a Name>,
|
||||
to_remove: &mut PrecomputedHashSet<Name>,
|
||||
) {
|
||||
let already_visited_before = !visited.insert(name);
|
||||
if already_visited_before {
|
||||
return
|
||||
@ -555,10 +562,11 @@ fn remove_cycles(map: &mut OrderedMap<&Name, BorrowedSpecifiedValue>) {
|
||||
}
|
||||
|
||||
/// Replace `var()` functions for all custom properties.
|
||||
fn substitute_all(specified_values_map: OrderedMap<&Name, BorrowedSpecifiedValue>)
|
||||
-> CustomPropertiesMap {
|
||||
fn substitute_all(
|
||||
specified_values_map: OrderedMap<&Name, BorrowedSpecifiedValue>
|
||||
) -> CustomPropertiesMap {
|
||||
let mut custom_properties_map = CustomPropertiesMap::new();
|
||||
let mut invalid = HashSet::new();
|
||||
let mut invalid = PrecomputedHashSet::default();
|
||||
for name in &specified_values_map.index {
|
||||
let value = specified_values_map.get(name).unwrap();
|
||||
|
||||
@ -576,13 +584,14 @@ fn substitute_all(specified_values_map: OrderedMap<&Name, BorrowedSpecifiedValue
|
||||
/// Also recursively record results for other custom properties referenced by `var()` functions.
|
||||
/// Return `Err(())` for invalid at computed time.
|
||||
/// or `Ok(last_token_type that was pushed to partial_computed_value)` otherwise.
|
||||
fn substitute_one(name: &Name,
|
||||
specified_value: &BorrowedSpecifiedValue,
|
||||
specified_values_map: &OrderedMap<&Name, BorrowedSpecifiedValue>,
|
||||
partial_computed_value: Option<&mut ComputedValue>,
|
||||
custom_properties_map: &mut CustomPropertiesMap,
|
||||
invalid: &mut HashSet<Name>)
|
||||
-> Result<TokenSerializationType, ()> {
|
||||
fn substitute_one(
|
||||
name: &Name,
|
||||
specified_value: &BorrowedSpecifiedValue,
|
||||
specified_values_map: &OrderedMap<&Name, BorrowedSpecifiedValue>,
|
||||
partial_computed_value: Option<&mut ComputedValue>,
|
||||
custom_properties_map: &mut CustomPropertiesMap,
|
||||
invalid: &mut PrecomputedHashSet<Name>,
|
||||
) -> Result<TokenSerializationType, ()> {
|
||||
if let Some(computed_value) = custom_properties_map.get(&name) {
|
||||
if let Some(partial_computed_value) = partial_computed_value {
|
||||
partial_computed_value.push_variable(computed_value)
|
||||
|
@ -693,8 +693,7 @@ impl PropertyDeclarationBlock {
|
||||
inherited_custom_properties: Option<Arc<::custom_properties::CustomPropertiesMap>>,
|
||||
) -> Option<Arc<::custom_properties::CustomPropertiesMap>> {
|
||||
let mut custom_properties = None;
|
||||
// FIXME: Use PrecomputedHasher instead.
|
||||
let mut seen_custom = HashSet::new();
|
||||
let mut seen_custom = PrecomputedHashSet::default();
|
||||
|
||||
for declaration in self.normal_declaration_iter() {
|
||||
if let PropertyDeclaration::Custom(ref name, ref value) = *declaration {
|
||||
|
@ -15,7 +15,6 @@ use app_units::Au;
|
||||
use servo_arc::{Arc, UniqueArc};
|
||||
use smallbitvec::SmallBitVec;
|
||||
use std::borrow::Cow;
|
||||
use hash::HashSet;
|
||||
use std::{fmt, mem, ops};
|
||||
use std::cell::RefCell;
|
||||
#[cfg(feature = "gecko")] use std::ptr;
|
||||
@ -35,6 +34,7 @@ use media_queries::Device;
|
||||
use parser::ParserContext;
|
||||
#[cfg(feature = "gecko")] use properties::longhands::system_font::SystemFont;
|
||||
use rule_cache::{RuleCache, RuleCacheConditions};
|
||||
use selector_map::PrecomputedHashSet;
|
||||
use selector_parser::PseudoElement;
|
||||
use selectors::parser::SelectorParseError;
|
||||
#[cfg(feature = "servo")] use servo_config::prefs::PREFS;
|
||||
@ -3272,7 +3272,7 @@ where
|
||||
|
||||
let inherited_custom_properties = inherited_style.custom_properties();
|
||||
let mut custom_properties = None;
|
||||
let mut seen_custom = HashSet::new();
|
||||
let mut seen_custom = PrecomputedHashSet::default();
|
||||
for (declaration, _cascade_level) in iter_declarations() {
|
||||
if let PropertyDeclaration::Custom(ref name, ref value) = *declaration {
|
||||
::custom_properties::cascade(
|
||||
|
@ -9,13 +9,17 @@ publish = false
|
||||
name = "webvr"
|
||||
path = "lib.rs"
|
||||
|
||||
[features]
|
||||
googlevr = ['rust-webvr/googlevr']
|
||||
oculusvr = ['rust-webvr/oculusvr']
|
||||
|
||||
[dependencies]
|
||||
canvas_traits = {path = "../canvas_traits"}
|
||||
euclid = "0.15"
|
||||
ipc-channel = "0.8"
|
||||
log = "0.3"
|
||||
msg = {path = "../msg"}
|
||||
rust-webvr = {version = "0.8", features = ["openvr"]}
|
||||
rust-webvr = {version = "0.9", features = ["openvr"]}
|
||||
script_traits = {path = "../script_traits"}
|
||||
servo_config = {path = "../config"}
|
||||
webvr_traits = {path = "../webvr_traits" }
|
||||
|
@ -12,5 +12,5 @@ path = "lib.rs"
|
||||
[dependencies]
|
||||
ipc-channel = "0.8"
|
||||
msg = {path = "../msg"}
|
||||
rust-webvr-api = {version = "0.8", features = ["serde-serialization"]}
|
||||
rust-webvr-api = {version = "0.9", features = ["serde-serialization"]}
|
||||
serde = "1.0"
|
||||
|
@ -34,6 +34,8 @@ max_log_level = ["log/release_max_level_info"]
|
||||
webdriver = ["libservo/webdriver_server"]
|
||||
energy-profiling = ["libservo/energy-profiling"]
|
||||
debugmozjs = ["libservo/debugmozjs"]
|
||||
googlevr = ["libservo/googlevr"]
|
||||
oculusvr = ["libservo/oculusvr"]
|
||||
|
||||
[dependencies]
|
||||
backtrace = "0.3"
|
||||
|
@ -309,6 +309,11 @@ class MachCommands(CommandBase):
|
||||
env['CPPFLAGS'] = ' '.join(["--sysroot", env['ANDROID_SYSROOT']])
|
||||
env["CMAKE_ANDROID_ARCH_ABI"] = self.config["android"]["lib"]
|
||||
env["CMAKE_TOOLCHAIN_FILE"] = path.join(self.android_support_dir(), "toolchain.cmake")
|
||||
# Set output dir for gradle aar files
|
||||
aar_out_dir = self.android_aar_dir()
|
||||
if not os.path.exists(aar_out_dir):
|
||||
os.makedirs(aar_out_dir)
|
||||
env["AAR_OUT_DIR"] = aar_out_dir
|
||||
|
||||
cargo_binary = "cargo" + BIN_SUFFIX
|
||||
|
||||
|
@ -551,6 +551,9 @@ class CommandBase(object):
|
||||
def android_build_dir(self, dev):
|
||||
return path.join(self.get_target_dir(), self.config["android"]["target"], "debug" if dev else "release")
|
||||
|
||||
def android_aar_dir(self):
|
||||
return path.join(self.context.topdir, "target", "android_aar")
|
||||
|
||||
def handle_android_target(self, target):
|
||||
if target == "arm-linux-androideabi":
|
||||
self.config["android"]["platform"] = "android-18"
|
||||
|
@ -180,7 +180,10 @@ class PackageCommands(CommandBase):
|
||||
@CommandArgument('--target', '-t',
|
||||
default=None,
|
||||
help='Package for given target platform')
|
||||
def package(self, release=False, dev=False, android=None, debug=False, debugger=None, target=None):
|
||||
@CommandArgument('--flavor', '-f',
|
||||
default=None,
|
||||
help='Package using the given Gradle flavor')
|
||||
def package(self, release=False, dev=False, android=None, debug=False, debugger=None, target=None, flavor=None):
|
||||
env = self.build_env()
|
||||
if android is None:
|
||||
android = self.config["build"]["android"]
|
||||
@ -206,7 +209,11 @@ class PackageCommands(CommandBase):
|
||||
else:
|
||||
build_mode = "Release"
|
||||
|
||||
task_name = "assemble" + build_type + build_mode
|
||||
flavor_name = "Main"
|
||||
if flavor is not None:
|
||||
flavor_name = flavor.title()
|
||||
|
||||
task_name = "assemble" + flavor_name + build_type + build_mode
|
||||
try:
|
||||
with cd(path.join("support", "android", "apk")):
|
||||
subprocess.check_call(["./gradlew", "--no-daemon", task_name], env=env)
|
||||
|
@ -33,6 +33,17 @@ android {
|
||||
}
|
||||
}
|
||||
|
||||
productFlavors {
|
||||
main {
|
||||
}
|
||||
googlevr {
|
||||
minSdkVersion 21
|
||||
}
|
||||
oculusvr {
|
||||
minSdkVersion 21
|
||||
}
|
||||
}
|
||||
|
||||
sourceSets {
|
||||
main {
|
||||
java.srcDirs = ['src/main/java']
|
||||
@ -145,7 +156,9 @@ android {
|
||||
// Call our custom NDK Build task using flavor parameters
|
||||
tasks.all {
|
||||
compileTask ->
|
||||
Pattern pattern = Pattern.compile(/^transformJackWithJackFor([\w\d]+)(Debug|Release)/);
|
||||
// Parse architecture name from gradle task name:
|
||||
// Examples: transformJackWithJackForMainArmv7Release, transformJackWithJackForOculusvrArmv7Release
|
||||
Pattern pattern = Pattern.compile(/^transformJackWithJackFor[A-Z][\w\d]+([A-Z][\w\d]+)(Debug|Release)/);
|
||||
Matcher matcher = pattern.matcher(compileTask.name);
|
||||
// You can use this alternative pattern when jackCompiler is disabled
|
||||
// Pattern pattern = Pattern.compile(/^compile([\w\d]+)(Debug|Release)/);
|
||||
@ -194,6 +207,10 @@ dependencies {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
googlevrCompile 'com.google.vr:sdk-base:1.70.0'
|
||||
googlevrCompile(name:'GVRService', ext:'aar')
|
||||
oculusvrCompile(name:'OVRService', ext:'aar')
|
||||
}
|
||||
|
||||
// Utility methods
|
||||
|
@ -0,0 +1,19 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- BEGIN_INCLUDE(manifest) -->
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.mozilla.servo">
|
||||
<application>
|
||||
<activity android:name=".MainActivity"
|
||||
android:screenOrientation="landscape"
|
||||
android:enableVrMode="@string/gvr_vr_mode_component"
|
||||
android:resizeableActivity="false">
|
||||
<!-- Intent filter that enables this app to be launched from the
|
||||
Daydream Home menu. -->
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.MAIN" />
|
||||
<category android:name="com.google.intent.category.DAYDREAM"/>
|
||||
</intent-filter>
|
||||
</activity>
|
||||
</application>
|
||||
|
||||
</manifest>
|
||||
<!-- END_INCLUDE(manifest) -->
|
@ -11,9 +11,11 @@ import android.os.Handler;
|
||||
import android.os.PowerManager;
|
||||
import android.preference.PreferenceManager;
|
||||
import android.util.Log;
|
||||
import android.view.SurfaceView;
|
||||
import android.view.View;
|
||||
import android.view.WindowManager;
|
||||
import android.webkit.URLUtil;
|
||||
import android.widget.FrameLayout;
|
||||
|
||||
import com.mozilla.servo.BuildConfig;
|
||||
|
||||
@ -66,20 +68,44 @@ public class MainActivity extends android.app.NativeActivity {
|
||||
}
|
||||
|
||||
JSONObject preferences = loadPreferences();
|
||||
boolean keepScreenOn = preferences.optBoolean("shell.keep_screen_on.enabled", false);
|
||||
mFullScreen = !preferences.optBoolean("shell.native-titlebar.enabled", false);
|
||||
String orientation = preferences.optString("shell.native-orientation", "both");
|
||||
|
||||
// Handle orientation preference
|
||||
if (orientation.equalsIgnoreCase("portrait")) {
|
||||
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
|
||||
boolean keepScreenOn = false;
|
||||
|
||||
if (BuildConfig.FLAVOR.contains("vr")) {
|
||||
// Force fullscreen mode and keep screen on for VR experiences.
|
||||
keepScreenOn = true;
|
||||
mFullScreen = true;
|
||||
}
|
||||
else if (orientation.equalsIgnoreCase("landscape")) {
|
||||
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
|
||||
else {
|
||||
keepScreenOn = preferences.optBoolean("shell.keep_screen_on.enabled", false);
|
||||
mFullScreen = !preferences.optBoolean("shell.native-titlebar.enabled", false);
|
||||
|
||||
String orientation = preferences.optString("shell.native-orientation", "both");
|
||||
|
||||
// Handle orientation preference
|
||||
if (orientation.equalsIgnoreCase("portrait")) {
|
||||
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
|
||||
}
|
||||
else if (orientation.equalsIgnoreCase("landscape")) {
|
||||
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
|
||||
}
|
||||
}
|
||||
|
||||
super.onCreate(savedInstanceState);
|
||||
|
||||
// NativeActivity ignores the Android view hierarchy because it’s designed
|
||||
// to take over the surface from the window to directly draw to it.
|
||||
// Inject a custom SurfaceView in order to support adding views on top of the browser.
|
||||
// (e.g. Native Banners, Daydream GVRLayout or other native views)
|
||||
getWindow().takeSurface(null);
|
||||
FrameLayout layout = new FrameLayout(this);
|
||||
layout.setLayoutParams(new FrameLayout.LayoutParams(FrameLayout.LayoutParams.MATCH_PARENT,
|
||||
FrameLayout.LayoutParams.MATCH_PARENT));
|
||||
SurfaceView nativeSurface = new SurfaceView(this);
|
||||
nativeSurface.getHolder().addCallback(this);
|
||||
layout.addView(nativeSurface, new FrameLayout.LayoutParams(FrameLayout.LayoutParams.MATCH_PARENT, FrameLayout.LayoutParams.MATCH_PARENT));
|
||||
setContentView(layout);
|
||||
|
||||
// Handle keep screen on preference
|
||||
if (keepScreenOn) {
|
||||
keepScreenOn();
|
||||
|
@ -0,0 +1,10 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- BEGIN_INCLUDE(manifest) -->
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.mozilla.servo">>
|
||||
<application>
|
||||
<meta-data android:name="com.samsung.android.vr.application.mode" android:value="vr_only"/>
|
||||
<activity android:name=".MainActivity" android:screenOrientation="landscape">
|
||||
</activity>
|
||||
</application>
|
||||
</manifest>
|
||||
<!-- END_INCLUDE(manifest) -->
|
@ -11,6 +11,9 @@ buildscript {
|
||||
allprojects {
|
||||
repositories {
|
||||
jcenter()
|
||||
flatDir {
|
||||
dirs rootDir.absolutePath + "/../../../target/android_aar"
|
||||
}
|
||||
}
|
||||
|
||||
buildDir = rootDir.absolutePath + "/../../../target/gradle"
|
||||
|
@ -1 +1 @@
|
||||
{"files":{".cargo-ok":"e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855","Cargo.toml":"2a05c2e707ff7794084cfb5de621a0944470c8e2592cfdb74da490d34c3ae902","LICENSE":"7ca6700600dfa9c9497bf5556365067daa802c871ea78239f129309c7a2048f7","src/lib.rs":"906713981c5a62ebd0226f6cdd56c754ec7ce589a1c4a7861fcdd54be971dbfc"},"package":"cdf1fc3616b3ef726a847f2cd2388c646ef6a1f1ba4835c2629004da48184150"}
|
||||
{"files":{".cargo-ok":"e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855","Cargo.toml":"594bc4437727edbf58c7cb9f88c3c1d80e89439dd4a505ef4771f9f344819386","LICENSE":"7ca6700600dfa9c9497bf5556365067daa802c871ea78239f129309c7a2048f7","src/lib.rs":"079a5f369a82b4573cca488a8c52a8427546e9050c89964a7b554215dd4da5f1"},"package":"925383efa346730478fb4838dbe9137d2a47675ad789c546d150a6e1dd4ab31c"}
|
16
third_party/rust/precomputed-hash/Cargo.toml
vendored
16
third_party/rust/precomputed-hash/Cargo.toml
vendored
@ -1,9 +1,21 @@
|
||||
# THIS FILE IS AUTOMATICALLY GENERATED BY CARGO
|
||||
#
|
||||
# When uploading crates to the registry Cargo will automatically
|
||||
# "normalize" Cargo.toml files for maximal compatibility
|
||||
# with all versions of Cargo and also rewrite `path` dependencies
|
||||
# to registry (e.g. crates.io) dependencies
|
||||
#
|
||||
# If you believe there's an error in this file please file an
|
||||
# issue against the rust-lang/cargo repository. If you're
|
||||
# editing this file be aware that the upstream Cargo.toml
|
||||
# will likely look very different (and much more reasonable)
|
||||
|
||||
[package]
|
||||
name = "precomputed-hash"
|
||||
version = "0.1.0"
|
||||
version = "0.1.1"
|
||||
authors = ["Emilio Cobos Álvarez <emilio@crisal.io>"]
|
||||
description = "A library intending to be a base dependency to expose a precomputed hash"
|
||||
license = "MIT"
|
||||
repository = "https://github.com/emilio/precomputed-hash"
|
||||
description = "A library intending to be a base dependency to expose a precomputed hash"
|
||||
|
||||
[dependencies]
|
||||
|
13
third_party/rust/precomputed-hash/src/lib.rs
vendored
13
third_party/rust/precomputed-hash/src/lib.rs
vendored
@ -7,3 +7,16 @@ pub trait PrecomputedHash {
|
||||
/// Return the precomputed hash for this item.
|
||||
fn precomputed_hash(&self) -> u32;
|
||||
}
|
||||
|
||||
// These are equivalent to the `std::Hash` impls.
|
||||
impl<'a, T: PrecomputedHash> PrecomputedHash for &'a T {
|
||||
fn precomputed_hash(&self) -> u32 {
|
||||
(**self).precomputed_hash()
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a, T: PrecomputedHash> PrecomputedHash for &'a mut T {
|
||||
fn precomputed_hash(&self) -> u32 {
|
||||
(**self).precomputed_hash()
|
||||
}
|
||||
}
|
||||
|
@ -242,8 +242,9 @@ class Theme {
|
||||
|
||||
/**
|
||||
* Unloads the currently applied theme.
|
||||
* @param {Object} targetWindow The window the theme should be unloaded from
|
||||
*/
|
||||
unload() {
|
||||
unload(targetWindow) {
|
||||
let lwtStyles = {
|
||||
headerURL: "",
|
||||
accentcolor: "",
|
||||
@ -254,6 +255,10 @@ class Theme {
|
||||
icons: {},
|
||||
};
|
||||
|
||||
if (targetWindow) {
|
||||
lwtStyles.window = getWinUtils(targetWindow).outerWindowID;
|
||||
}
|
||||
|
||||
for (let icon of ICONS) {
|
||||
lwtStyles.icons[`--${icon}--icon`] = "";
|
||||
}
|
||||
@ -313,7 +318,7 @@ this.theme = class extends ExtensionAPI {
|
||||
}
|
||||
this.theme.load(details, browserWindow);
|
||||
},
|
||||
reset: () => {
|
||||
reset: (windowId) => {
|
||||
if (!gThemesEnabled) {
|
||||
// Return early if themes are disabled.
|
||||
return;
|
||||
@ -324,7 +329,12 @@ this.theme = class extends ExtensionAPI {
|
||||
return;
|
||||
}
|
||||
|
||||
this.theme.unload();
|
||||
let browserWindow;
|
||||
if (windowId !== null) {
|
||||
browserWindow = windowTracker.getWindow(windowId, context);
|
||||
}
|
||||
|
||||
this.theme.unload(browserWindow);
|
||||
},
|
||||
},
|
||||
};
|
||||
|
@ -482,7 +482,14 @@
|
||||
"type": "function",
|
||||
"async": true,
|
||||
"description": "Removes the updates made to the theme.",
|
||||
"parameters": []
|
||||
"parameters": [
|
||||
{
|
||||
"type": "integer",
|
||||
"name": "windowId",
|
||||
"optional": true,
|
||||
"description": "The id of the window to reset. No id resets all windows."
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
|
@ -51,7 +51,9 @@ Var BrandFullName
|
||||
; We keep defines.nsi defined so that we get other things like
|
||||
; the version number, but we redefine BrandFullName
|
||||
!define MaintFullName "Mozilla Maintenance Service"
|
||||
!ifdef BrandFullName
|
||||
!undef BrandFullName
|
||||
!endif
|
||||
!define BrandFullName "${MaintFullName}"
|
||||
|
||||
!include common.nsh
|
||||
|
8
toolkit/library/gtest/rust/Cargo.lock
generated
8
toolkit/library/gtest/rust/Cargo.lock
generated
@ -1046,7 +1046,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "precomputed-hash"
|
||||
version = "0.1.0"
|
||||
version = "0.1.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
|
||||
[[package]]
|
||||
@ -1197,7 +1197,7 @@ dependencies = [
|
||||
"matches 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"phf 0.7.21 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"phf_codegen 0.7.21 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"precomputed-hash 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"precomputed-hash 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"servo_arc 0.0.1",
|
||||
"smallvec 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
@ -1318,7 +1318,7 @@ dependencies = [
|
||||
"owning_ref 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"parking_lot 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"pdqsort 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"precomputed-hash 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"precomputed-hash 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"rayon 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"regex 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"selectors 0.19.0",
|
||||
@ -1753,7 +1753,7 @@ dependencies = [
|
||||
"checksum phf_shared 0.7.21 (registry+https://github.com/rust-lang/crates.io-index)" = "07e24b0ca9643bdecd0632f2b3da6b1b89bbb0030e0b992afc1113b23a7bc2f2"
|
||||
"checksum pkg-config 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)" = "3a8b4c6b8165cd1a1cd4b9b120978131389f64bdaf456435caa41e630edba903"
|
||||
"checksum plane-split 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)" = "e57800a97ca52c556db6b6184a3201f05366ad5e11876f7d17e234589ca2fa26"
|
||||
"checksum precomputed-hash 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "cdf1fc3616b3ef726a847f2cd2388c646ef6a1f1ba4835c2629004da48184150"
|
||||
"checksum precomputed-hash 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "925383efa346730478fb4838dbe9137d2a47675ad789c546d150a6e1dd4ab31c"
|
||||
"checksum procedural-masquerade 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "9f566249236c6ca4340f7ca78968271f0ed2b0f234007a61b66f9ecd0af09260"
|
||||
"checksum quasi 0.32.0 (registry+https://github.com/rust-lang/crates.io-index)" = "18c45c4854d6d1cf5d531db97c75880feb91c958b0720f4ec1057135fec358b3"
|
||||
"checksum quasi_codegen 0.32.0 (registry+https://github.com/rust-lang/crates.io-index)" = "51b9e25fa23c044c1803f43ca59c98dac608976dd04ce799411edd58ece776d4"
|
||||
|
8
toolkit/library/rust/Cargo.lock
generated
8
toolkit/library/rust/Cargo.lock
generated
@ -1033,7 +1033,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "precomputed-hash"
|
||||
version = "0.1.0"
|
||||
version = "0.1.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
|
||||
[[package]]
|
||||
@ -1184,7 +1184,7 @@ dependencies = [
|
||||
"matches 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"phf 0.7.21 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"phf_codegen 0.7.21 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"precomputed-hash 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"precomputed-hash 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"servo_arc 0.0.1",
|
||||
"smallvec 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
@ -1305,7 +1305,7 @@ dependencies = [
|
||||
"owning_ref 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"parking_lot 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"pdqsort 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"precomputed-hash 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"precomputed-hash 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"rayon 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"regex 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"selectors 0.19.0",
|
||||
@ -1740,7 +1740,7 @@ dependencies = [
|
||||
"checksum phf_shared 0.7.21 (registry+https://github.com/rust-lang/crates.io-index)" = "07e24b0ca9643bdecd0632f2b3da6b1b89bbb0030e0b992afc1113b23a7bc2f2"
|
||||
"checksum pkg-config 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)" = "3a8b4c6b8165cd1a1cd4b9b120978131389f64bdaf456435caa41e630edba903"
|
||||
"checksum plane-split 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)" = "e57800a97ca52c556db6b6184a3201f05366ad5e11876f7d17e234589ca2fa26"
|
||||
"checksum precomputed-hash 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "cdf1fc3616b3ef726a847f2cd2388c646ef6a1f1ba4835c2629004da48184150"
|
||||
"checksum precomputed-hash 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "925383efa346730478fb4838dbe9137d2a47675ad789c546d150a6e1dd4ab31c"
|
||||
"checksum procedural-masquerade 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "9f566249236c6ca4340f7ca78968271f0ed2b0f234007a61b66f9ecd0af09260"
|
||||
"checksum quasi 0.32.0 (registry+https://github.com/rust-lang/crates.io-index)" = "18c45c4854d6d1cf5d531db97c75880feb91c958b0720f4ec1057135fec358b3"
|
||||
"checksum quasi_codegen 0.32.0 (registry+https://github.com/rust-lang/crates.io-index)" = "51b9e25fa23c044c1803f43ca59c98dac608976dd04ce799411edd58ece776d4"
|
||||
|
Loading…
Reference in New Issue
Block a user