mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-09 11:25:00 +00:00
Merge b2g-inbound to m-c
This commit is contained in:
commit
3981da2427
@ -1,4 +1,4 @@
|
||||
{
|
||||
"revision": "ed107ffac75d42dbacc19f81d0e2650e34c83a16",
|
||||
"revision": "34b6a207b754b02ee836ed9c8293a47b997f714c",
|
||||
"repo_path": "/integration/gaia-central"
|
||||
}
|
||||
|
@ -52,6 +52,7 @@ SEARCH_PATHS = [
|
||||
'testing/mozbase/mozrunner',
|
||||
'testing/mozbase/mozsystemmonitor',
|
||||
'testing/mozbase/mozinfo',
|
||||
'testing/mozbase/moztest',
|
||||
'testing/mozbase/manifestdestiny',
|
||||
'xpcom/idl-parser',
|
||||
]
|
||||
|
@ -21,6 +21,7 @@ extern PRLogModuleInfo* GetDataChannelLog();
|
||||
|
||||
|
||||
#include "nsDOMDataChannelDeclarations.h"
|
||||
#include "nsDOMDataChannel.h"
|
||||
#include "nsIDOMFile.h"
|
||||
#include "nsIDOMDataChannel.h"
|
||||
#include "nsIDOMMessageEvent.h"
|
||||
@ -37,6 +38,12 @@ extern PRLogModuleInfo* GetDataChannelLog();
|
||||
|
||||
#include "DataChannel.h"
|
||||
|
||||
// Since we've moved the windows.h include down here, we have to explicitly
|
||||
// undef GetBinaryType, otherwise we'll get really odd conflicts
|
||||
#ifdef GetBinaryType
|
||||
#undef GetBinaryType
|
||||
#endif
|
||||
|
||||
using namespace mozilla;
|
||||
using namespace mozilla::dom;
|
||||
|
||||
@ -73,6 +80,13 @@ NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION_INHERITED(nsDOMDataChannel)
|
||||
NS_INTERFACE_MAP_ENTRY(nsIDOMDataChannel)
|
||||
NS_INTERFACE_MAP_END_INHERITING(nsDOMEventTargetHelper)
|
||||
|
||||
nsDOMDataChannel::nsDOMDataChannel(already_AddRefed<mozilla::DataChannel> aDataChannel)
|
||||
: mDataChannel(aDataChannel)
|
||||
, mBinaryType(DC_BINARY_TYPE_BLOB)
|
||||
{
|
||||
SetIsDOMBinding();
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsDOMDataChannel::Init(nsPIDOMWindow* aDOMWindow)
|
||||
{
|
||||
|
@ -10,22 +10,22 @@
|
||||
#include "mozilla/Attributes.h"
|
||||
#include "mozilla/dom/DataChannelBinding.h"
|
||||
#include "mozilla/dom/TypedArray.h"
|
||||
#include "mozilla/net/DataChannel.h"
|
||||
#include "mozilla/net/DataChannelListener.h"
|
||||
#include "nsDOMEventTargetHelper.h"
|
||||
#include "nsIDOMDataChannel.h"
|
||||
#include "nsIInputStream.h"
|
||||
|
||||
|
||||
namespace mozilla {
|
||||
class DataChannel;
|
||||
};
|
||||
|
||||
class nsDOMDataChannel : public nsDOMEventTargetHelper,
|
||||
public nsIDOMDataChannel,
|
||||
public mozilla::DataChannelListener
|
||||
{
|
||||
public:
|
||||
nsDOMDataChannel(already_AddRefed<mozilla::DataChannel> aDataChannel)
|
||||
: mDataChannel(aDataChannel)
|
||||
, mBinaryType(DC_BINARY_TYPE_BLOB)
|
||||
{
|
||||
SetIsDOMBinding();
|
||||
}
|
||||
|
||||
nsDOMDataChannel(already_AddRefed<mozilla::DataChannel> aDataChannel);
|
||||
~nsDOMDataChannel();
|
||||
|
||||
nsresult Init(nsPIDOMWindow* aDOMWindow);
|
||||
|
@ -89,7 +89,7 @@ ActivityProxy.prototype = {
|
||||
|
||||
cleanup: function actProxy_cleanup() {
|
||||
debug("cleanup");
|
||||
if (!this.cleanedUp) {
|
||||
if (cpmm && !this.cleanedUp) {
|
||||
cpmm.removeMessageListener("Activity:FireSuccess", this);
|
||||
cpmm.removeMessageListener("Activity:FireError", this);
|
||||
}
|
||||
|
@ -1065,10 +1065,10 @@ let RIL = {
|
||||
* @param on
|
||||
* Boolean indicating whether the screen should be on or off.
|
||||
*/
|
||||
setScreenState: function setScreenState(on) {
|
||||
setScreenState: function setScreenState(options) {
|
||||
Buf.newParcel(REQUEST_SCREEN_STATE);
|
||||
Buf.writeInt32(1);
|
||||
Buf.writeInt32(on ? 1 : 0);
|
||||
Buf.writeInt32(options.on ? 1 : 0);
|
||||
Buf.sendParcel();
|
||||
},
|
||||
|
||||
|
47
dom/system/gonk/tests/marionette/test_screen_state.js
Normal file
47
dom/system/gonk/tests/marionette/test_screen_state.js
Normal file
@ -0,0 +1,47 @@
|
||||
/* Any copyright is dedicated to the Public Domain.
|
||||
* http://creativecommons.org/publicdomain/zero/1.0/ */
|
||||
|
||||
MARIONETTE_TIMEOUT = 10000;
|
||||
|
||||
let Services = SpecialPowers.Services;
|
||||
|
||||
function testScreenState(on, expected, msg) {
|
||||
// send event to RadioInterface
|
||||
Services.obs.notifyObservers(null, 'screen-state-changed', on);
|
||||
// maybe rild/qemu needs some time to process the event
|
||||
window.setTimeout(function() {
|
||||
runEmulatorCmd('gsm report creg', function(result) {
|
||||
is(result.pop(), 'OK', '\'gsm report creg\' successful');
|
||||
ok(result.indexOf(expected) !== -1, msg);
|
||||
runNextTest();
|
||||
})}, 1000);
|
||||
}
|
||||
|
||||
function testScreenStateDisabled() {
|
||||
testScreenState('off', '+CREG: 1', 'screen is disabled');
|
||||
}
|
||||
|
||||
function testScreenStateEnabled() {
|
||||
testScreenState('on', '+CREG: 2', 'screen is enabled');
|
||||
}
|
||||
|
||||
let tests = [
|
||||
testScreenStateDisabled,
|
||||
testScreenStateEnabled
|
||||
];
|
||||
|
||||
function runNextTest() {
|
||||
let test = tests.shift();
|
||||
if (!test) {
|
||||
cleanUp();
|
||||
return;
|
||||
}
|
||||
|
||||
test();
|
||||
}
|
||||
|
||||
function cleanUp() {
|
||||
finish();
|
||||
}
|
||||
|
||||
runNextTest();
|
@ -602,7 +602,7 @@ nsEventStatus AsyncPanZoomController::OnScaleBegin(const PinchGestureInput& aEve
|
||||
}
|
||||
|
||||
SetState(PINCHING);
|
||||
mLastZoomFocus = aEvent.mFocusPoint;
|
||||
mLastZoomFocus = aEvent.mFocusPoint - mFrameMetrics.mCompositionBounds.TopLeft();
|
||||
|
||||
return nsEventStatus_eConsumeNoDefault;
|
||||
}
|
||||
@ -619,13 +619,14 @@ nsEventStatus AsyncPanZoomController::OnScale(const PinchGestureInput& aEvent) {
|
||||
return nsEventStatus_eConsumeNoDefault;
|
||||
}
|
||||
|
||||
ScreenToScreenScale spanRatio(aEvent.mCurrentSpan / aEvent.mPreviousSpan);
|
||||
float spanRatio = aEvent.mCurrentSpan / aEvent.mPreviousSpan;
|
||||
|
||||
{
|
||||
ReentrantMonitorAutoEnter lock(mMonitor);
|
||||
|
||||
CSSToScreenScale userZoom = mFrameMetrics.mZoom;
|
||||
ScreenPoint focusPoint = aEvent.mFocusPoint;
|
||||
ScreenPoint focusPoint = aEvent.mFocusPoint - mFrameMetrics.mCompositionBounds.TopLeft();
|
||||
CSSPoint cssFocusPoint = focusPoint / userZoom;
|
||||
|
||||
CSSPoint focusChange = (mLastZoomFocus - focusPoint) / userZoom;
|
||||
// If displacing by the change in focus point will take us off page bounds,
|
||||
@ -641,54 +642,35 @@ nsEventStatus AsyncPanZoomController::OnScale(const PinchGestureInput& aEvent) {
|
||||
// When we zoom in with focus, we can zoom too much towards the boundaries
|
||||
// that we actually go over them. These are the needed displacements along
|
||||
// either axis such that we don't overscroll the boundaries when zooming.
|
||||
gfx::Point neededDisplacement;
|
||||
CSSPoint neededDisplacement;
|
||||
|
||||
bool doScale = (spanRatio > ScreenToScreenScale(1.0) && userZoom < mMaxZoom) ||
|
||||
(spanRatio < ScreenToScreenScale(1.0) && userZoom > mMinZoom);
|
||||
|
||||
if (doScale) {
|
||||
spanRatio.scale = clamped(spanRatio.scale,
|
||||
mMinZoom.scale / userZoom.scale,
|
||||
mMaxZoom.scale / userZoom.scale);
|
||||
|
||||
switch (mX.ScaleWillOverscroll(spanRatio, focusPoint.x))
|
||||
{
|
||||
case Axis::OVERSCROLL_NONE:
|
||||
break;
|
||||
case Axis::OVERSCROLL_MINUS:
|
||||
case Axis::OVERSCROLL_PLUS:
|
||||
neededDisplacement.x = -mX.ScaleWillOverscrollAmount(spanRatio, focusPoint.x);
|
||||
break;
|
||||
case Axis::OVERSCROLL_BOTH:
|
||||
// If scaling this way will make us overscroll in both directions, then
|
||||
// we must already be at the maximum zoomed out amount. In this case, we
|
||||
// don't want to allow this scaling to go through and instead clamp it
|
||||
// here.
|
||||
doScale = false;
|
||||
break;
|
||||
}
|
||||
CSSToScreenScale realMinZoom = mMinZoom;
|
||||
CSSToScreenScale realMaxZoom = mMaxZoom;
|
||||
realMinZoom.scale = std::max(realMinZoom.scale,
|
||||
mFrameMetrics.mCompositionBounds.width / mFrameMetrics.mScrollableRect.width);
|
||||
realMinZoom.scale = std::max(realMinZoom.scale,
|
||||
mFrameMetrics.mCompositionBounds.height / mFrameMetrics.mScrollableRect.height);
|
||||
if (realMaxZoom < realMinZoom) {
|
||||
realMaxZoom = realMinZoom;
|
||||
}
|
||||
|
||||
if (doScale) {
|
||||
switch (mY.ScaleWillOverscroll(spanRatio, focusPoint.y))
|
||||
{
|
||||
case Axis::OVERSCROLL_NONE:
|
||||
break;
|
||||
case Axis::OVERSCROLL_MINUS:
|
||||
case Axis::OVERSCROLL_PLUS:
|
||||
neededDisplacement.y = -mY.ScaleWillOverscrollAmount(spanRatio, focusPoint.y);
|
||||
break;
|
||||
case Axis::OVERSCROLL_BOTH:
|
||||
doScale = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
bool doScale = (spanRatio > 1.0 && userZoom < realMaxZoom) ||
|
||||
(spanRatio < 1.0 && userZoom > realMinZoom);
|
||||
|
||||
if (doScale) {
|
||||
ScaleWithFocus(userZoom * spanRatio, focusPoint);
|
||||
spanRatio = clamped(spanRatio,
|
||||
realMinZoom.scale / userZoom.scale,
|
||||
realMaxZoom.scale / userZoom.scale);
|
||||
|
||||
if (neededDisplacement != gfx::Point()) {
|
||||
ScrollBy(CSSPoint::FromUnknownPoint(neededDisplacement));
|
||||
// Note that the spanRatio here should never put us into OVERSCROLL_BOTH because
|
||||
// up above we clamped it.
|
||||
neededDisplacement.x = -mX.ScaleWillOverscrollAmount(spanRatio, cssFocusPoint.x);
|
||||
neededDisplacement.y = -mY.ScaleWillOverscrollAmount(spanRatio, cssFocusPoint.y);
|
||||
|
||||
ScaleWithFocus(spanRatio, cssFocusPoint);
|
||||
|
||||
if (neededDisplacement != CSSPoint()) {
|
||||
ScrollBy(neededDisplacement);
|
||||
}
|
||||
|
||||
ScheduleComposite();
|
||||
@ -977,19 +959,14 @@ void AsyncPanZoomController::ScrollBy(const CSSPoint& aOffset) {
|
||||
mFrameMetrics.mScrollOffset += aOffset;
|
||||
}
|
||||
|
||||
void AsyncPanZoomController::ScaleWithFocus(const CSSToScreenScale& aZoom,
|
||||
const ScreenPoint& aFocus) {
|
||||
ScreenToScreenScale zoomFactor(aZoom.scale / mFrameMetrics.mZoom.scale);
|
||||
CSSToScreenScale resolution = mFrameMetrics.mZoom;
|
||||
|
||||
SetZoomAndResolution(aZoom);
|
||||
|
||||
// If the new scale is very small, we risk multiplying in huge rounding
|
||||
// errors, so don't bother adjusting the scroll offset.
|
||||
if (resolution.scale >= 0.01f) {
|
||||
zoomFactor.scale -= 1.0;
|
||||
mFrameMetrics.mScrollOffset += aFocus * zoomFactor / resolution;
|
||||
}
|
||||
void AsyncPanZoomController::ScaleWithFocus(float aScale,
|
||||
const CSSPoint& aFocus) {
|
||||
SetZoomAndResolution(CSSToScreenScale(mFrameMetrics.mZoom.scale * aScale));
|
||||
// We want to adjust the scroll offset such that the CSS point represented by aFocus remains
|
||||
// at the same position on the screen before and after the change in zoom. The below code
|
||||
// accomplishes this; see https://bugzilla.mozilla.org/show_bug.cgi?id=923431#c6 for an
|
||||
// in-depth explanation of how.
|
||||
mFrameMetrics.mScrollOffset = (mFrameMetrics.mScrollOffset + aFocus) - (aFocus / aScale);
|
||||
}
|
||||
|
||||
bool AsyncPanZoomController::EnlargeDisplayPortAlongAxis(float aSkateSizeMultiplier,
|
||||
@ -1350,8 +1327,8 @@ void AsyncPanZoomController::UpdateCompositionBounds(const ScreenIntRect& aCompo
|
||||
// has gone out of view, the buffer will be cleared elsewhere anyways.
|
||||
if (aCompositionBounds.width && aCompositionBounds.height &&
|
||||
oldCompositionBounds.width && oldCompositionBounds.height) {
|
||||
ScreenToScreenScale adjustmentFactor(float(aCompositionBounds.width) / float(oldCompositionBounds.width));
|
||||
SetZoomAndResolution(mFrameMetrics.mZoom * adjustmentFactor);
|
||||
float adjustmentFactor = float(aCompositionBounds.width) / float(oldCompositionBounds.width);
|
||||
SetZoomAndResolution(CSSToScreenScale(mFrameMetrics.mZoom.scale * adjustmentFactor));
|
||||
|
||||
// Repaint on a rotation so that our new resolution gets properly updated.
|
||||
RequestContentRepaint();
|
||||
|
@ -359,12 +359,10 @@ protected:
|
||||
/**
|
||||
* Scales the viewport by an amount (note that it multiplies this scale in to
|
||||
* the current scale, it doesn't set it to |aScale|). Also considers a focus
|
||||
* point so that the page zooms outward from that point.
|
||||
*
|
||||
* XXX: Fix focus point calculations.
|
||||
* point so that the page zooms inward/outward from that point.
|
||||
*/
|
||||
void ScaleWithFocus(const mozilla::CSSToScreenScale& aScale,
|
||||
const ScreenPoint& aFocus);
|
||||
void ScaleWithFocus(float aScale,
|
||||
const CSSPoint& aFocus);
|
||||
|
||||
/**
|
||||
* Schedules a composite on the compositor thread. Wrapper for
|
||||
|
@ -271,34 +271,25 @@ float Axis::DisplacementWillOverscrollAmount(float aDisplacement) {
|
||||
}
|
||||
}
|
||||
|
||||
Axis::Overscroll Axis::ScaleWillOverscroll(ScreenToScreenScale aScale, float aFocus) {
|
||||
float originAfterScale = (GetOrigin() + aFocus) * aScale.scale - aFocus;
|
||||
float Axis::ScaleWillOverscrollAmount(float aScale, float aFocus) {
|
||||
float originAfterScale = (GetOrigin() + aFocus) - (aFocus / aScale);
|
||||
|
||||
bool both = ScaleWillOverscrollBothSides(aScale);
|
||||
bool minus = originAfterScale < GetPageStart() * aScale.scale;
|
||||
bool plus = (originAfterScale + GetCompositionLength()) > GetPageEnd() * aScale.scale;
|
||||
bool minus = originAfterScale < GetPageStart();
|
||||
bool plus = (originAfterScale + (GetCompositionLength() / aScale)) > GetPageEnd();
|
||||
|
||||
if ((minus && plus) || both) {
|
||||
return OVERSCROLL_BOTH;
|
||||
// If we ever reach here it's a bug in the client code.
|
||||
MOZ_ASSERT(false, "In an OVERSCROLL_BOTH condition in ScaleWillOverscrollAmount");
|
||||
return 0;
|
||||
}
|
||||
if (minus) {
|
||||
return OVERSCROLL_MINUS;
|
||||
return originAfterScale - GetPageStart();
|
||||
}
|
||||
if (plus) {
|
||||
return OVERSCROLL_PLUS;
|
||||
}
|
||||
return OVERSCROLL_NONE;
|
||||
}
|
||||
|
||||
float Axis::ScaleWillOverscrollAmount(ScreenToScreenScale aScale, float aFocus) {
|
||||
float originAfterScale = (GetOrigin() + aFocus) * aScale.scale - aFocus;
|
||||
switch (ScaleWillOverscroll(aScale, aFocus)) {
|
||||
case OVERSCROLL_MINUS: return originAfterScale - GetPageStart() * aScale.scale;
|
||||
case OVERSCROLL_PLUS: return (originAfterScale + GetCompositionLength()) -
|
||||
NS_lround(GetPageEnd() * aScale.scale);
|
||||
// Don't handle OVERSCROLL_BOTH. Client code is expected to deal with it.
|
||||
default: return 0;
|
||||
return originAfterScale + (GetCompositionLength() / aScale) - GetPageEnd();
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
float Axis::GetVelocity() {
|
||||
@ -338,15 +329,13 @@ float Axis::GetPageLength() {
|
||||
return GetRectLength(pageRect);
|
||||
}
|
||||
|
||||
bool Axis::ScaleWillOverscrollBothSides(ScreenToScreenScale aScale) {
|
||||
bool Axis::ScaleWillOverscrollBothSides(float aScale) {
|
||||
const FrameMetrics& metrics = mAsyncPanZoomController->GetFrameMetrics();
|
||||
|
||||
CSSRect cssContentRect = metrics.mScrollableRect;
|
||||
CSSToScreenScale scale(metrics.mZoom.scale * aScale);
|
||||
CSSRect cssCompositionBounds = metrics.mCompositionBounds / scale;
|
||||
|
||||
CSSToScreenScale scale = metrics.mZoom * aScale;
|
||||
CSSIntRect cssCompositionBounds = RoundedIn(metrics.mCompositionBounds / scale);
|
||||
|
||||
return GetRectLength(cssContentRect) < GetRectLength(CSSRect(cssCompositionBounds));
|
||||
return GetRectLength(metrics.mScrollableRect) < GetRectLength(cssCompositionBounds);
|
||||
}
|
||||
|
||||
AxisX::AxisX(AsyncPanZoomController* aAsyncPanZoomController)
|
||||
|
@ -142,30 +142,19 @@ public:
|
||||
|
||||
/**
|
||||
* If a displacement will overscroll the axis, this returns the amount and in
|
||||
* what direction. Similar to getExcess() but takes a displacement to apply.
|
||||
* what direction. Similar to GetExcess() but takes a displacement to apply.
|
||||
*/
|
||||
float DisplacementWillOverscrollAmount(float aDisplacement);
|
||||
|
||||
/**
|
||||
* Gets the overscroll state of the axis given a scaling of the page. That is
|
||||
* to say, if the given scale is applied, this will tell you whether or not
|
||||
* it will overscroll, and in what direction.
|
||||
*
|
||||
* |aFocus| is the point at which the scale is focused at. We will offset the
|
||||
* scroll offset in such a way that it remains in the same place on the page
|
||||
* relative.
|
||||
*/
|
||||
Overscroll ScaleWillOverscroll(ScreenToScreenScale aScale, float aFocus);
|
||||
|
||||
/**
|
||||
* If a scale will overscroll the axis, this returns the amount and in what
|
||||
* direction. Similar to getExcess() but takes a displacement to apply.
|
||||
* direction. Similar to GetExcess() but takes a displacement to apply.
|
||||
*
|
||||
* |aFocus| is the point at which the scale is focused at. We will offset the
|
||||
* scroll offset in such a way that it remains in the same place on the page
|
||||
* relative.
|
||||
*/
|
||||
float ScaleWillOverscrollAmount(ScreenToScreenScale aScale, float aFocus);
|
||||
float ScaleWillOverscrollAmount(float aScale, float aFocus);
|
||||
|
||||
/**
|
||||
* Checks if an axis will overscroll in both directions by computing the
|
||||
@ -174,7 +163,7 @@ public:
|
||||
*
|
||||
* This gets called by ScaleWillOverscroll().
|
||||
*/
|
||||
bool ScaleWillOverscrollBothSides(ScreenToScreenScale aScale);
|
||||
bool ScaleWillOverscrollBothSides(float aScale);
|
||||
|
||||
float GetOrigin();
|
||||
float GetCompositionLength();
|
||||
|
@ -53,6 +53,11 @@ public:
|
||||
ReentrantMonitorAutoEnter lock(mMonitor);
|
||||
mFrameMetrics = metrics;
|
||||
}
|
||||
|
||||
FrameMetrics GetFrameMetrics() {
|
||||
ReentrantMonitorAutoEnter lock(mMonitor);
|
||||
return mFrameMetrics;
|
||||
}
|
||||
};
|
||||
|
||||
class TestAPZCTreeManager : public APZCTreeManager {
|
||||
@ -115,6 +120,112 @@ TEST(AsyncPanZoomController, Constructor) {
|
||||
apzc->SetFrameMetrics(TestFrameMetrics());
|
||||
}
|
||||
|
||||
TEST(AsyncPanZoomController, Pinch) {
|
||||
nsRefPtr<MockContentController> mcc = new MockContentController();
|
||||
nsRefPtr<TestAsyncPanZoomController> apzc = new TestAsyncPanZoomController(0, mcc);
|
||||
|
||||
FrameMetrics fm;
|
||||
fm.mViewport = CSSRect(0, 0, 980, 480);
|
||||
fm.mCompositionBounds = ScreenIntRect(200, 200, 100, 200);
|
||||
fm.mScrollableRect = CSSRect(0, 0, 980, 1000);
|
||||
fm.mScrollOffset = CSSPoint(300, 300);
|
||||
fm.mZoom = CSSToScreenScale(2.0);
|
||||
apzc->SetFrameMetrics(fm);
|
||||
// the visible area of the document in CSS pixels is x=300 y=300 w=50 h=100
|
||||
|
||||
EXPECT_CALL(*mcc, SendAsyncScrollDOMEvent(_,_,_)).Times(2);
|
||||
EXPECT_CALL(*mcc, RequestContentRepaint(_)).Times(1);
|
||||
|
||||
apzc->HandleInputEvent(PinchGestureInput(PinchGestureInput::PINCHGESTURE_START,
|
||||
0,
|
||||
ScreenPoint(250, 300),
|
||||
10.0,
|
||||
10.0));
|
||||
apzc->HandleInputEvent(PinchGestureInput(PinchGestureInput::PINCHGESTURE_SCALE,
|
||||
0,
|
||||
ScreenPoint(250, 300),
|
||||
12.5,
|
||||
10.0));
|
||||
apzc->HandleInputEvent(PinchGestureInput(PinchGestureInput::PINCHGESTURE_END,
|
||||
0,
|
||||
ScreenPoint(250, 300),
|
||||
12.5,
|
||||
12.5));
|
||||
|
||||
// the visible area of the document in CSS pixels is now x=305 y=310 w=40 h=80
|
||||
fm = apzc->GetFrameMetrics();
|
||||
EXPECT_EQ(fm.mZoom.scale, 2.5f);
|
||||
EXPECT_EQ(fm.mScrollOffset.x, 305);
|
||||
EXPECT_EQ(fm.mScrollOffset.y, 310);
|
||||
|
||||
// part 2 of the test, move to the top-right corner of the page and pinch and
|
||||
// make sure we stay in the correct spot
|
||||
fm.mZoom = CSSToScreenScale(2.0);
|
||||
fm.mScrollOffset = CSSPoint(930, 5);
|
||||
apzc->SetFrameMetrics(fm);
|
||||
// the visible area of the document in CSS pixels is x=930 y=5 w=50 h=100
|
||||
|
||||
apzc->HandleInputEvent(PinchGestureInput(PinchGestureInput::PINCHGESTURE_START,
|
||||
0,
|
||||
ScreenPoint(250, 300),
|
||||
10.0,
|
||||
10.0));
|
||||
apzc->HandleInputEvent(PinchGestureInput(PinchGestureInput::PINCHGESTURE_SCALE,
|
||||
0,
|
||||
ScreenPoint(250, 300),
|
||||
5.0,
|
||||
10.0));
|
||||
apzc->HandleInputEvent(PinchGestureInput(PinchGestureInput::PINCHGESTURE_END,
|
||||
0,
|
||||
ScreenPoint(250, 300),
|
||||
5.0,
|
||||
5.0));
|
||||
|
||||
// the visible area of the document in CSS pixels is now x=880 y=0 w=100 h=200
|
||||
fm = apzc->GetFrameMetrics();
|
||||
EXPECT_EQ(fm.mZoom.scale, 1.0f);
|
||||
EXPECT_EQ(fm.mScrollOffset.x, 880);
|
||||
EXPECT_EQ(fm.mScrollOffset.y, 0);
|
||||
}
|
||||
|
||||
TEST(AsyncPanZoomController, Overzoom) {
|
||||
nsRefPtr<MockContentController> mcc = new MockContentController();
|
||||
nsRefPtr<TestAsyncPanZoomController> apzc = new TestAsyncPanZoomController(0, mcc);
|
||||
|
||||
FrameMetrics fm;
|
||||
fm.mViewport = CSSRect(0, 0, 100, 100);
|
||||
fm.mCompositionBounds = ScreenIntRect(0, 0, 100, 100);
|
||||
fm.mScrollableRect = CSSRect(0, 0, 125, 150);
|
||||
fm.mScrollOffset = CSSPoint(10, 0);
|
||||
fm.mZoom = CSSToScreenScale(1.0);
|
||||
apzc->SetFrameMetrics(fm);
|
||||
// the visible area of the document in CSS pixels is x=10 y=0 w=100 h=100
|
||||
|
||||
EXPECT_CALL(*mcc, SendAsyncScrollDOMEvent(_,_,_)).Times(1);
|
||||
EXPECT_CALL(*mcc, RequestContentRepaint(_)).Times(1);
|
||||
|
||||
apzc->HandleInputEvent(PinchGestureInput(PinchGestureInput::PINCHGESTURE_START,
|
||||
0,
|
||||
ScreenPoint(50, 50),
|
||||
10.0,
|
||||
10.0));
|
||||
apzc->HandleInputEvent(PinchGestureInput(PinchGestureInput::PINCHGESTURE_SCALE,
|
||||
0,
|
||||
ScreenPoint(50, 50),
|
||||
5.0,
|
||||
10.0));
|
||||
apzc->HandleInputEvent(PinchGestureInput(PinchGestureInput::PINCHGESTURE_END,
|
||||
0,
|
||||
ScreenPoint(50, 50),
|
||||
5.0,
|
||||
5.0));
|
||||
|
||||
fm = apzc->GetFrameMetrics();
|
||||
EXPECT_EQ(fm.mZoom.scale, 0.8f);
|
||||
EXPECT_EQ(fm.mScrollOffset.x, 0);
|
||||
EXPECT_EQ(fm.mScrollOffset.y, 0);
|
||||
}
|
||||
|
||||
TEST(AsyncPanZoomController, SimpleTransform) {
|
||||
TimeStamp testStartTime = TimeStamp::Now();
|
||||
// RefCounted class can't live in the stack
|
||||
|
@ -69,7 +69,6 @@ typedef gfx::ScaleFactor<LayoutDevicePixel, ScreenPixel> LayoutDeviceToScreenSca
|
||||
typedef gfx::ScaleFactor<ScreenPixel, LayoutDevicePixel> ScreenToLayoutDeviceScale;
|
||||
typedef gfx::ScaleFactor<LayerPixel, ScreenPixel> LayerToScreenScale;
|
||||
typedef gfx::ScaleFactor<ScreenPixel, LayerPixel> ScreenToLayerScale;
|
||||
typedef gfx::ScaleFactor<ScreenPixel, ScreenPixel> ScreenToScreenScale;
|
||||
|
||||
/*
|
||||
* The pixels that content authors use to specify sizes in.
|
||||
|
@ -24,6 +24,7 @@
|
||||
#include "nsITimer.h"
|
||||
#include "mozilla/Mutex.h"
|
||||
#include "DataChannelProtocol.h"
|
||||
#include "DataChannelListener.h"
|
||||
#ifdef SCTP_DTLS_SUPPORTED
|
||||
#include "mtransport/sigslot.h"
|
||||
#include "mtransport/transportflow.h"
|
||||
@ -91,29 +92,6 @@ public:
|
||||
char *mData;
|
||||
};
|
||||
|
||||
// Implemented by consumers of a Channel to receive messages.
|
||||
// Can't nest it in DataChannelConnection because C++ doesn't allow forward
|
||||
// refs to embedded classes
|
||||
class DataChannelListener {
|
||||
public:
|
||||
virtual ~DataChannelListener() {}
|
||||
|
||||
// Called when a DOMString message is received.
|
||||
virtual nsresult OnMessageAvailable(nsISupports *aContext,
|
||||
const nsACString& message) = 0;
|
||||
|
||||
// Called when a binary message is received.
|
||||
virtual nsresult OnBinaryMessageAvailable(nsISupports *aContext,
|
||||
const nsACString& message) = 0;
|
||||
|
||||
// Called when the channel is connected
|
||||
virtual nsresult OnChannelConnected(nsISupports *aContext) = 0;
|
||||
|
||||
// Called when the channel is closed
|
||||
virtual nsresult OnChannelClosed(nsISupports *aContext) = 0;
|
||||
};
|
||||
|
||||
|
||||
// One per PeerConnection
|
||||
class DataChannelConnection: public nsITimerCallback
|
||||
#ifdef SCTP_DTLS_SUPPORTED
|
||||
|
39
netwerk/sctp/datachannel/DataChannelListener.h
Normal file
39
netwerk/sctp/datachannel/DataChannelListener.h
Normal file
@ -0,0 +1,39 @@
|
||||
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* vim: set ts=2 et sw=2 tw=80: */
|
||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
||||
* You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#ifndef NETWERK_SCTP_DATACHANNEL_DATACHANNELLISTENER_H_
|
||||
#define NETWERK_SCTP_DATACHANNEL_DATACHANNELLISTENER_H_
|
||||
|
||||
#include "nsISupports.h"
|
||||
#include "nsString.h"
|
||||
|
||||
namespace mozilla {
|
||||
|
||||
// Implemented by consumers of a Channel to receive messages.
|
||||
// Can't nest it in DataChannelConnection because C++ doesn't allow forward
|
||||
// refs to embedded classes
|
||||
class DataChannelListener {
|
||||
public:
|
||||
virtual ~DataChannelListener() {}
|
||||
|
||||
// Called when a DOMString message is received.
|
||||
virtual nsresult OnMessageAvailable(nsISupports *aContext,
|
||||
const nsACString& message) = 0;
|
||||
|
||||
// Called when a binary message is received.
|
||||
virtual nsresult OnBinaryMessageAvailable(nsISupports *aContext,
|
||||
const nsACString& message) = 0;
|
||||
|
||||
// Called when the channel is connected
|
||||
virtual nsresult OnChannelConnected(nsISupports *aContext) = 0;
|
||||
|
||||
// Called when the channel is closed
|
||||
virtual nsresult OnChannelClosed(nsISupports *aContext) = 0;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
@ -10,7 +10,8 @@ MODULE = 'necko'
|
||||
|
||||
EXPORTS.mozilla.net += [
|
||||
'DataChannel.h',
|
||||
'DataChannelProtocol.h',
|
||||
'DataChannelListener.h',
|
||||
'DataChannelProtocol.h'
|
||||
]
|
||||
|
||||
CPP_SOURCES += [
|
||||
|
Loading…
Reference in New Issue
Block a user