This commit is contained in:
Ryan VanderMeulen 2014-04-15 23:26:35 -04:00
Родитель 1228913846 fa9338fee5
Коммит fa7c5ad357
140 изменённых файлов: 1879 добавлений и 797 удалений

Просмотреть файл

@ -597,7 +597,7 @@ PivotContext.prototype = {
while (parent && (parent = parent.parent)) {
ancestry.push(parent);
}
} catch (e) {
} catch (x) {
// A defunct accessible will raise an exception geting parent.
Logger.debug('Failed to get parent:', x);
}

Просмотреть файл

@ -274,7 +274,6 @@ pref("ui.dragThresholdY", 25);
pref("layers.offmainthreadcomposition.enabled", true);
#ifndef MOZ_WIDGET_GONK
pref("dom.ipc.tabs.disabled", true);
pref("layers.acceleration.disabled", true);
pref("layers.offmainthreadcomposition.async-animations", false);
pref("layers.async-video.enabled", false);
#else

Просмотреть файл

@ -1,3 +1,4 @@
. "$topsrcdir/b2g/config/mozconfigs/common"
. $topsrcdir/build/macosx/mozconfig.common
ac_add_options --enable-update-channel=${MOZ_UPDATE_CHANNEL}

Просмотреть файл

@ -1,3 +1,4 @@
. "$topsrcdir/b2g/config/mozconfigs/common"
. $topsrcdir/build/macosx/mozconfig.common
ac_add_options --enable-update-channel=${MOZ_UPDATE_CHANNEL}

Просмотреть файл

@ -753,17 +753,19 @@ WriteBitmap(nsIFile* aFile, imgIContainer* aImage)
{
nsresult rv;
nsRefPtr<gfxASurface> thebesSurface =
RefPtr<SourceSurface> surface =
aImage->GetFrame(imgIContainer::FRAME_FIRST,
imgIContainer::FLAG_SYNC_DECODE);
NS_ENSURE_TRUE(thebesSurface, NS_ERROR_FAILURE);
NS_ENSURE_TRUE(surface, NS_ERROR_FAILURE);
nsRefPtr<gfxImageSurface> thebesImageSurface =
thebesSurface->GetAsReadableARGB32ImageSurface();
NS_ENSURE_TRUE(thebesImageSurface, NS_ERROR_FAILURE);
// For either of the following formats we want to set the biBitCount member
// of the BITMAPINFOHEADER struct to 32, below. For that value the bitmap
// format defines that the A8/X8 WORDs in the bitmap byte stream be ignored
// for the BI_RGB value we use for the biCompression member.
MOZ_ASSERT(surface->GetFormat() == SurfaceFormat::B8G8R8A8 ||
surface->GetFormat() == SurfaceFormat::B8G8R8X8);
RefPtr<DataSourceSurface> dataSurface =
thebesImageSurface->CopyToB8G8R8A8DataSourceSurface();
RefPtr<DataSourceSurface> dataSurface = surface->GetDataSurface();
NS_ENSURE_TRUE(dataSurface, NS_ERROR_FAILURE);
int32_t width = dataSurface->GetSize().width;

Просмотреть файл

@ -229,6 +229,7 @@ LOCAL_INCLUDES += [
'/layout/svg',
'/layout/xul',
'/netwerk/base/src',
'/xpcom/ds',
]
if CONFIG['GNU_CC'] and CONFIG['MOZ_WIDGET_TOOLKIT'] == 'android':

Просмотреть файл

@ -124,6 +124,7 @@
#include "nsILineBreaker.h"
#include "nsILoadContext.h"
#include "nsILoadGroup.h"
#include "nsIMemoryReporter.h"
#include "nsIMIMEService.h"
#include "nsINode.h"
#include "nsINodeInfo.h"

Просмотреть файл

@ -100,9 +100,11 @@
#undef free // apparently defined by some windows header, clashing with a free()
// method in SkTypes.h
#ifdef USE_SKIA
#include "SkiaGLGlue.h"
#include "SurfaceStream.h"
#include "SurfaceTypes.h"
#endif
using mozilla::gl::GLContext;
using mozilla::gl::SkiaGLGlue;
@ -900,6 +902,7 @@ CanvasRenderingContext2D::EnsureTarget()
SkiaGLGlue* glue = gfxPlatform::GetPlatform()->GetSkiaGLGlue();
#if USE_SKIA
if (glue && glue->GetGrContext() && glue->GetGLContext()) {
mTarget = Factory::CreateDrawTargetSkiaWithGrContext(glue->GetGrContext(), size, format);
if (mTarget) {
@ -909,6 +912,7 @@ CanvasRenderingContext2D::EnsureTarget()
printf_stderr("Failed to create a SkiaGL DrawTarget, falling back to software\n");
}
}
#endif
if (!mTarget) {
mTarget = layerManager->CreateDrawTarget(size, format);
}
@ -4244,12 +4248,14 @@ CanvasRenderingContext2D::GetCanvasLayer(nsDisplayListBuilder* aBuilder,
CanvasLayer::Data data;
if (mStream) {
#ifdef USE_SKIA
SkiaGLGlue* glue = gfxPlatform::GetPlatform()->GetSkiaGLGlue();
if (glue) {
data.mGLContext = glue->GetGLContext();
data.mStream = mStream.get();
}
#endif
} else {
data.mDrawTarget = mTarget;
}
@ -4292,7 +4298,9 @@ CanvasRenderingContext2D::GetCanvasLayer(nsDisplayListBuilder* aBuilder,
if (glue) {
canvasLayer->SetPreTransactionCallback(
CanvasRenderingContext2DUserData::PreTransactionCallback, userData);
#if USE_SKIA
data.mGLContext = glue->GetGLContext();
#endif
data.mStream = mStream.get();
data.mTexID = (uint32_t)((uintptr_t)mTarget->GetNativeSurface(NativeSurfaceType::OPENGL_TEXTURE));
}

Просмотреть файл

@ -4674,24 +4674,15 @@ HTMLInputElement::GetValueAsDate(const nsAString& aValue,
return false;
}
uint32_t endOfYearOffset = 0;
for (; NS_IsAsciiDigit(aValue[endOfYearOffset]); ++endOfYearOffset);
// The year must be at least 4 digits long.
if (aValue[endOfYearOffset] != '-' || endOfYearOffset < 4) {
uint32_t endOfYearOffset = aValue.Length() - 6;
if (aValue[endOfYearOffset] != '-' ||
aValue[endOfYearOffset + 3] != '-') {
return false;
}
// Now, we know where is the next '-' and what should be the size of the
// string.
if (aValue[endOfYearOffset + 3] != '-' ||
aValue.Length() != 10 + (endOfYearOffset - 4)) {
return false;
}
nsresult ec;
*aYear = PromiseFlatString(StringHead(aValue, endOfYearOffset)).ToInteger(&ec);
if (NS_FAILED(ec) || *aYear == 0) {
if (!DigitSubStringToNumber(aValue, 0, endOfYearOffset, aYear) ||
*aYear < 1) {
return false;
}

Просмотреть файл

@ -13,7 +13,7 @@
#include "nsIThread.h"
#include "mozilla/Monitor.h"
#include "nsISupportsImpl.h"
#include "nsObserverService.h"
#include "nsIObserver.h"
class AsyncLatencyLogger;
class LogEvent;

Просмотреть файл

@ -23,12 +23,14 @@ class SharedThreadPool;
// they're received, and are guaranteed to not be executed concurrently.
// They may be executed on different threads, and a memory barrier is used
// to make this threadsafe for objects that aren't already threadsafe.
class MediaTaskQueue : public AtomicRefCounted<MediaTaskQueue> {
public:
MOZ_DECLARE_REFCOUNTED_TYPENAME(MediaTaskQueue)
MediaTaskQueue(TemporaryRef<SharedThreadPool> aPool);
class MediaTaskQueue MOZ_FINAL {
~MediaTaskQueue();
public:
NS_INLINE_DECL_THREADSAFE_REFCOUNTING(MediaTaskQueue)
MediaTaskQueue(TemporaryRef<SharedThreadPool> aPool);
nsresult Dispatch(nsIRunnable* aRunnable);
// Removes all pending tasks from the task queue, and blocks until

Просмотреть файл

@ -143,11 +143,13 @@ public:
// MediaTaskQueue passed into the PlatformDecoderModules's Create*Decoder()
// function. This may not be necessary for platforms with async APIs
// for decoding.
class MediaDataDecoder : public AtomicRefCounted<MediaDataDecoder> {
public:
MOZ_DECLARE_REFCOUNTED_TYPENAME(MediaDataDecoder)
class MediaDataDecoder {
protected:
virtual ~MediaDataDecoder() {};
public:
NS_INLINE_DECL_THREADSAFE_REFCOUNTING(MediaDataDecoder)
// Initialize the decoder. The decoder should be ready to decode after
// this returns. The decoder should do any initialization here, rather
// than in its constructor or PlatformDecoderModule::Create*Decoder(),

Просмотреть файл

@ -14,12 +14,14 @@
namespace mozilla {
class MFTDecoder : public AtomicRefCounted<MFTDecoder> {
public:
MOZ_DECLARE_REFCOUNTED_TYPENAME(MTFDecoder)
MFTDecoder();
class MFTDecoder MOZ_FINAL {
~MFTDecoder();
public:
NS_INLINE_DECL_THREADSAFE_REFCOUNTING(MFTDecoder)
MFTDecoder();
// Creates the MFT. First thing to do as part of setup.
//
// Params:

Просмотреть файл

@ -0,0 +1,296 @@
/* 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 "gtest/gtest.h"
#include <algorithm>
#include "mozilla/ArrayUtils.h"
#include "VP8TrackEncoder.h"
#include "ImageContainer.h"
#include "MediaStreamGraph.h"
#include "WebMWriter.h" // TODO: it's weird to include muxer header to get the class definition of VP8 METADATA
using ::testing::TestWithParam;
using ::testing::Values;
using namespace mozilla::layers;
using namespace mozilla;
// A helper object to generate of different YUV planes.
class YUVBufferGenerator {
public:
YUVBufferGenerator() {}
void Init(const mozilla::gfx::IntSize &aSize)
{
mImageSize = aSize;
int yPlaneLen = aSize.width * aSize.height;
int cbcrPlaneLen = (yPlaneLen + 1) / 2;
int frameLen = yPlaneLen + cbcrPlaneLen;
// Generate source buffer.
mSourceBuffer.SetLength(frameLen);
// Fill Y plane.
memset(mSourceBuffer.Elements(), 0x10, yPlaneLen);
// Fill Cb/Cr planes.
memset(mSourceBuffer.Elements() + yPlaneLen, 0x80, cbcrPlaneLen);
}
mozilla::gfx::IntSize GetSize() const
{
return mImageSize;
}
void Generate(nsTArray<nsRefPtr<Image> > &aImages)
{
aImages.AppendElement(CreateI420Image());
aImages.AppendElement(CreateNV12Image());
aImages.AppendElement(CreateNV21Image());
}
private:
Image *CreateI420Image()
{
PlanarYCbCrImage *image = new PlanarYCbCrImage(new BufferRecycleBin());
PlanarYCbCrData data;
const uint32_t yPlaneSize = mImageSize.width * mImageSize.height;
const uint32_t halfWidth = (mImageSize.width + 1) / 2;
const uint32_t halfHeight = (mImageSize.height + 1) / 2;
const uint32_t uvPlaneSize = halfWidth * halfHeight;
// Y plane.
uint8_t *y = mSourceBuffer.Elements();
data.mYChannel = y;
data.mYSize.width = mImageSize.width;
data.mYSize.height = mImageSize.height;
data.mYStride = mImageSize.width;
data.mYSkip = 0;
// Cr plane.
uint8_t *cr = y + yPlaneSize + uvPlaneSize;
data.mCrChannel = cr;
data.mCrSkip = 0;
// Cb plane
uint8_t *cb = y + yPlaneSize;
data.mCbChannel = cb;
data.mCbSkip = 0;
// CrCb plane vectors.
data.mCbCrStride = halfWidth;
data.mCbCrSize.width = halfWidth;
data.mCbCrSize.height = halfHeight;
image->SetData(data);
return image;
}
Image *CreateNV12Image()
{
PlanarYCbCrImage *image = new PlanarYCbCrImage(new BufferRecycleBin());
PlanarYCbCrData data;
const uint32_t yPlaneSize = mImageSize.width * mImageSize.height;
const uint32_t halfWidth = (mImageSize.width + 1) / 2;
const uint32_t halfHeight = (mImageSize.height + 1) / 2;
// Y plane.
uint8_t *y = mSourceBuffer.Elements();
data.mYChannel = y;
data.mYSize.width = mImageSize.width;
data.mYSize.height = mImageSize.height;
data.mYStride = mImageSize.width;
data.mYSkip = 0;
// Cr plane.
uint8_t *cr = y + yPlaneSize;
data.mCrChannel = cr;
data.mCrSkip = 1;
// Cb plane
uint8_t *cb = y + yPlaneSize + 1;
data.mCbChannel = cb;
data.mCbSkip = 1;
// 4:2:0.
data.mCbCrStride = mImageSize.width;
data.mCbCrSize.width = halfWidth;
data.mCbCrSize.height = halfHeight;
image->SetData(data);
return image;
}
Image *CreateNV21Image()
{
PlanarYCbCrImage *image = new PlanarYCbCrImage(new BufferRecycleBin());
PlanarYCbCrData data;
const uint32_t yPlaneSize = mImageSize.width * mImageSize.height;
const uint32_t halfWidth = (mImageSize.width + 1) / 2;
const uint32_t halfHeight = (mImageSize.height + 1) / 2;
// Y plane.
uint8_t *y = mSourceBuffer.Elements();
data.mYChannel = y;
data.mYSize.width = mImageSize.width;
data.mYSize.height = mImageSize.height;
data.mYStride = mImageSize.width;
data.mYSkip = 0;
// Cr plane.
uint8_t *cr = y + yPlaneSize + 1;
data.mCrChannel = cr;
data.mCrSkip = 1;
// Cb plane
uint8_t *cb = y + yPlaneSize;
data.mCbChannel = cb;
data.mCbSkip = 1;
// 4:2:0.
data.mCbCrStride = mImageSize.width;
data.mCbCrSize.width = halfWidth;
data.mCbCrSize.height = halfHeight;
image->SetData(data);
return image;
}
private:
mozilla::gfx::IntSize mImageSize;
nsTArray<uint8_t> mSourceBuffer;
};
struct InitParam {
bool mShouldSucceed; // This parameter should cause success or fail result
int mWidth; // frame width
int mHeight; // frame height
mozilla::TrackRate mTrackRate; // track rate. 90K is the most commond track rate.
};
class TestVP8TrackEncoder: public VP8TrackEncoder
{
public:
::testing::AssertionResult TestInit(const InitParam &aParam)
{
nsresult result = Init(aParam.mWidth, aParam.mHeight, aParam.mWidth, aParam.mHeight, aParam.mTrackRate);
if (((NS_FAILED(result) && aParam.mShouldSucceed)) || (NS_SUCCEEDED(result) && !aParam.mShouldSucceed))
{
return ::testing::AssertionFailure()
<< " width = " << aParam.mWidth
<< " height = " << aParam.mHeight
<< " TrackRate = " << aParam.mTrackRate << ".";
}
else
{
return ::testing::AssertionSuccess();
}
}
};
// Init test
TEST(VP8VideoTrackEncoder, Initialization)
{
InitParam params[] = {
// Failure cases.
{ false, 640, 480, 0 }, // Trackrate should be larger than 1.
{ false, 640, 480, -1 }, // Trackrate should be larger than 1.
{ false, 0, 0, 90000 }, // Height/ width should be larger than 1.
{ false, 0, 1, 90000 }, // Height/ width should be larger than 1.
{ false, 1, 0, 90000}, // Height/ width should be larger than 1.
// Success cases
{ true, 640, 480, 90000}, // Standard VGA
{ true, 800, 480, 90000}, // Standard WVGA
{ true, 960, 540, 90000}, // Standard qHD
{ true, 1280, 720, 90000} // Standard HD
};
for (size_t i = 0; i < ArrayLength(params); i++)
{
TestVP8TrackEncoder encoder;
EXPECT_TRUE(encoder.TestInit(params[i]));
}
}
// Get MetaData test
TEST(VP8VideoTrackEncoder, FetchMetaData)
{
InitParam params[] = {
// Success cases
{ true, 640, 480, 90000}, // Standard VGA
{ true, 800, 480, 90000}, // Standard WVGA
{ true, 960, 540, 90000}, // Standard qHD
{ true, 1280, 720, 90000} // Standard HD
};
for (size_t i = 0; i < ArrayLength(params); i++)
{
TestVP8TrackEncoder encoder;
EXPECT_TRUE(encoder.TestInit(params[i]));
nsRefPtr<TrackMetadataBase> meta = encoder.GetMetadata();
nsRefPtr<VP8Metadata> vp8Meta(static_cast<VP8Metadata*>(meta.get()));
// METADATA should be depend on how to initiate encoder.
EXPECT_TRUE(vp8Meta->mWidth == params[i].mWidth);
EXPECT_TRUE(vp8Meta->mHeight == params[i].mHeight);
}
}
// Encode test
TEST(VP8VideoTrackEncoder, FrameEncode)
{
// Initiate VP8 encoder
TestVP8TrackEncoder encoder;
InitParam param = {true, 640, 480, 90000};
encoder.TestInit(param);
// Create YUV images as source.
nsTArray<nsRefPtr<Image>> images;
YUVBufferGenerator generator;
generator.Init(mozilla::gfx::IntSize(640, 480));
generator.Generate(images);
// Put generated YUV frame into video segment.
// Duration of each frame is 1 second.
VideoSegment segment;
for (nsTArray<nsRefPtr<Image>>::size_type i = 0; i < images.Length(); i++)
{
nsRefPtr<Image> image = images[i];
segment.AppendFrame(image.forget(), mozilla::TrackTicks(90000), generator.GetSize());
}
// track change notification.
encoder.NotifyQueuedTrackChanges(nullptr, 0, 0, 0, 0, segment);
// Pull Encoded Data back from encoder.
EncodedFrameContainer container;
EXPECT_TRUE(NS_SUCCEEDED(encoder.GetEncodedTrack(container)));
}
// EOS test
TEST(VP8VideoTrackEncoder, EncodeComplete)
{
// Initiate VP8 encoder
TestVP8TrackEncoder encoder;
InitParam param = {true, 640, 480, 90000};
encoder.TestInit(param);
// track end notification.
VideoSegment segment;
encoder.NotifyQueuedTrackChanges(nullptr, 0, 0, 0, MediaStreamListener::TRACK_EVENT_ENDED, segment);
// Pull Encoded Data back from encoder. Since we have sent
// EOS to encoder, encoder.GetEncodedTrack should return
// NS_OK immidiately.
EncodedFrameContainer container;
EXPECT_TRUE(NS_SUCCEEDED(encoder.GetEncodedTrack(container)));
}

Просмотреть файл

@ -11,6 +11,10 @@ UNIFIED_SOURCES += [
'TestTrackEncoder.cpp',
]
if CONFIG['MOZ_WEBM_ENCODER']:
UNIFIED_SOURCES += ['TestVideoTrackEncoder.cpp',
]
EXPORT_LIBRARY = True
include('/ipc/chromium/chromium-config.mozbuild')

Просмотреть файл

@ -8,6 +8,8 @@
#include "mozilla/EventStates.h"
#include "mozilla/dom/SVGFEImageElementBinding.h"
#include "mozilla/dom/SVGFilterElement.h"
#include "mozilla/gfx/2D.h"
#include "mozilla/RefPtr.h"
#include "nsContentUtils.h"
#include "nsLayoutUtils.h"
#include "nsSVGUtils.h"
@ -211,22 +213,16 @@ SVGFEImageElement::GetPrimitiveDescription(nsSVGFilterInstance* aInstance,
currentRequest->GetImage(getter_AddRefs(imageContainer));
}
nsRefPtr<gfxASurface> currentFrame;
RefPtr<SourceSurface> image;
if (imageContainer) {
currentFrame =
imageContainer->GetFrame(imgIContainer::FRAME_CURRENT,
imgIContainer::FLAG_SYNC_DECODE);
image = imageContainer->GetFrame(imgIContainer::FRAME_CURRENT,
imgIContainer::FLAG_SYNC_DECODE);
}
if (!currentFrame) {
if (!image) {
return FilterPrimitiveDescription(PrimitiveType::Empty);
}
gfxPlatform* platform = gfxPlatform::GetPlatform();
DrawTarget* dt = platform->ScreenReferenceDrawTarget();
RefPtr<SourceSurface> image =
platform->GetSourceSurfaceForSurface(dt, currentFrame);
IntSize nativeSize;
imageContainer->GetWidth(&nativeSize.width);
imageContainer->GetHeight(&nativeSize.height);

Просмотреть файл

@ -9,17 +9,17 @@ const Cc = Components.classes;
const Ci = Components.interfaces;
const Cr = Components.results;
Cu.import("resource://gre/modules/FileUtils.jsm");
Cu.import("resource://gre/modules/osfile.jsm");
Cu.import("resource://gre/modules/Services.jsm");
Cu.import("resource://gre/modules/Task.jsm");
Cu.import("resource://gre/modules/WebappOSUtils.jsm");
Cu.import("resource://gre/modules/XPCOMUtils.jsm");
Cu.import("resource://gre/modules/Promise.jsm");
XPCOMUtils.defineLazyServiceGetter(this, "NetworkUtil",
"@mozilla.org/network/util;1",
"nsINetUtil");
XPCOMUtils.defineLazyModuleGetter(this, "FileUtils",
"resource://gre/modules/FileUtils.jsm");
XPCOMUtils.defineLazyModuleGetter(this, "WebappOSUtils",
"resource://gre/modules/WebappOSUtils.jsm");
XPCOMUtils.defineLazyModuleGetter(this, "NetUtil",
"resource://gre/modules/NetUtil.jsm");
@ -342,7 +342,8 @@ this.AppsUtils = {
checkManifestContentType(aInstallOrigin, aWebappOrigin, aContentType) {
let hadCharset = { };
let charset = { };
let contentType = NetworkUtil.parseContentType(aContentType, charset, hadCharset);
let netutil = Cc["@mozilla.org/network/util;1"].getService(Ci.nsINetUtil);
let contentType = netutil.parseContentType(aContentType, charset, hadCharset);
if (aInstallOrigin != aWebappOrigin &&
contentType != "application/x-web-app-manifest+json") {
return false;

Просмотреть файл

@ -8,7 +8,7 @@
#define mozilla_dom_bluetooth_bluetoothprofilecontroller_h__
#include "BluetoothUuid.h"
#include "mozilla/RefPtr.h"
#include "nsISupportsImpl.h"
#include "nsAutoPtr.h"
#include "nsITimer.h"
@ -57,10 +57,12 @@ class BluetoothProfileManagerBase;
class BluetoothReplyRunnable;
typedef void (*BluetoothProfileControllerCallback)();
class BluetoothProfileController : public RefCounted<BluetoothProfileController>
class BluetoothProfileController MOZ_FINAL
{
~BluetoothProfileController();
public:
MOZ_DECLARE_REFCOUNTED_TYPENAME(BluetoothProfileController)
NS_INLINE_DECL_REFCOUNTING(BluetoothProfileController)
/**
* @param aConnect: If it's a connect request, the value should be set
* to true. For disconnect request, set it to false.
@ -83,7 +85,6 @@ public:
BluetoothProfileControllerCallback aCallback,
uint16_t aServiceUuid,
uint32_t aCod = 0);
~BluetoothProfileController();
/**
* The controller starts connecting/disconnecting profiles one by one

Просмотреть файл

@ -29,6 +29,27 @@ const ContentPanning = {
hybridEvents: false,
init: function cp_init() {
// If APZ is enabled, we do active element handling in C++
// (see widget/xpwidgets/ActiveElementManager.h), and panning
// itself in APZ, so we don't need to handle any touch events here.
if (docShell.asyncPanZoomEnabled === false) {
this._setupListenersForPanning();
}
addEventListener("unload",
this._unloadHandler.bind(this),
/* useCapture = */ false,
/* wantsUntrusted = */ false);
addMessageListener("Viewport:Change", this._recvViewportChange.bind(this));
addMessageListener("Gesture:DoubleTap", this._recvDoubleTap.bind(this));
addEventListener("visibilitychange", this._handleVisibilityChange.bind(this));
kObservedEvents.forEach((topic) => {
Services.obs.addObserver(this, topic, false);
});
},
_setupListenersForPanning: function cp_setupListenersForPanning() {
var events;
try {
content.document.createEvent('TouchEvent');
@ -60,18 +81,6 @@ const ContentPanning = {
this.handleEvent.bind(this),
/* useCapture = */ false);
}.bind(this));
addEventListener("unload",
this._unloadHandler.bind(this),
/* useCapture = */ false,
/* wantsUntrusted = */ false);
addMessageListener("Viewport:Change", this._recvViewportChange.bind(this));
addMessageListener("Gesture:DoubleTap", this._recvDoubleTap.bind(this));
addEventListener("visibilitychange", this._handleVisibilityChange.bind(this));
kObservedEvents.forEach((topic) => {
Services.obs.addObserver(this, topic, false);
});
},
handleEvent: function cp_handleEvent(evt) {
@ -195,8 +204,7 @@ const ContentPanning = {
// We prevent start events to avoid sending a focus event at the end of this
// touch series. See bug 889717.
if (docShell.asyncPanZoomEnabled === false &&
(this.panning || this.preventNextClick)) {
if ((this.panning || this.preventNextClick)) {
evt.preventDefault();
}
},
@ -235,7 +243,7 @@ const ContentPanning = {
let view = target.ownerDocument ? target.ownerDocument.defaultView
: target;
view.addEventListener('click', this, true, true);
} else if (docShell.asyncPanZoomEnabled === false) {
} else {
// We prevent end events to avoid sending a focus event. See bug 889717.
evt.preventDefault();
}
@ -284,18 +292,15 @@ const ContentPanning = {
return;
}
// If the application is not managed by the AsyncPanZoomController, then
// scroll manually.
if (docShell.asyncPanZoomEnabled === false) {
this.scrollCallback(delta.scale(-1));
}
// Scroll manually.
this.scrollCallback(delta.scale(-1));
if (!this.panning && isPan) {
this.panning = true;
this._activationTimer.cancel();
}
if (this.panning && docShell.asyncPanZoomEnabled === false) {
if (this.panning) {
// Only do this when we're actually executing a pan gesture.
// Otherwise synthetic mouse events will be canceled.
evt.stopPropagation();
@ -592,9 +597,8 @@ const ContentPanning = {
delete this.primaryPointerId;
this._activationTimer.cancel();
// If there is a scroll action but the application is not managed by
// the AsyncPanZoom controller, let's do a manual kinetic panning action.
if (this.panning && docShell.asyncPanZoomEnabled === false) {
// If there is a scroll action, let's do a manual kinetic panning action.
if (this.panning) {
KineticPanning.start(this);
}
},

Просмотреть файл

@ -19,8 +19,6 @@
#include "DeviceStorageFileDescriptor.h"
#include "CameraControlListener.h"
class DeviceStorageFileDescriptor;
namespace mozilla {
namespace layers {

Просмотреть файл

@ -9,7 +9,7 @@
#include "nsPIDOMWindow.h"
#include "mozilla/Services.h"
#include "nsContentPermissionHelper.h"
#include "nsObserverService.h"
#include "nsIObserverService.h"
#include "nsIPermissionManager.h"
#include "DOMCameraControl.h"
#include "nsDOMClassInfo.h"

Просмотреть файл

@ -10,7 +10,7 @@
#include "nsAutoPtr.h"
#include "nsISupportsImpl.h"
class DeviceStorageFileDescriptor;
struct DeviceStorageFileDescriptor;
class nsIFile;

Просмотреть файл

@ -321,13 +321,7 @@ private:
friend class WatchFileEvent;
friend class DeviceStorageRequest;
class VolumeNameCache : public mozilla::RefCounted<VolumeNameCache>
{
public:
MOZ_DECLARE_REFCOUNTED_TYPENAME(VolumeNameCache)
nsTArray<nsString> mVolumeNames;
};
static mozilla::StaticRefPtr<VolumeNameCache> sVolumeNameCache;
static mozilla::StaticAutoPtr<nsTArray<nsString>> sVolumeNameCache;
#ifdef MOZ_WIDGET_GONK
nsString mLastStatus;

Просмотреть файл

@ -9,11 +9,9 @@
#include "mozilla/ipc/FileDescriptor.h"
class DeviceStorageFileDescriptor MOZ_FINAL
: public mozilla::RefCounted<DeviceStorageFileDescriptor>
struct DeviceStorageFileDescriptor MOZ_FINAL
{
public:
MOZ_DECLARE_REFCOUNTED_TYPENAME(DeviceStorageFileDescriptor)
NS_INLINE_DECL_REFCOUNTING(DeviceStorageFileDescriptor)
nsRefPtr<DeviceStorageFile> mDSFile;
mozilla::ipc::FileDescriptor mFileDescriptor;
};

Просмотреть файл

@ -9,7 +9,7 @@
#include "mozilla/dom/devicestorage/PDeviceStorageRequestChild.h"
class DeviceStorageFile;
class DeviceStorageFileDescriptor;
struct DeviceStorageFileDescriptor;
namespace mozilla {
namespace dom {

Просмотреть файл

@ -115,15 +115,16 @@ DeviceStorageUsedSpaceCache::CreateOrGet()
return sDeviceStorageUsedSpaceCache;
}
TemporaryRef<DeviceStorageUsedSpaceCache::CacheEntry>
already_AddRefed<DeviceStorageUsedSpaceCache::CacheEntry>
DeviceStorageUsedSpaceCache::GetCacheEntry(const nsAString& aStorageName)
{
nsTArray<RefPtr<CacheEntry> >::size_type numEntries = mCacheEntries.Length();
nsTArray<RefPtr<CacheEntry> >::index_type i;
nsTArray<nsRefPtr<CacheEntry>>::size_type numEntries = mCacheEntries.Length();
nsTArray<nsRefPtr<CacheEntry>>::index_type i;
for (i = 0; i < numEntries; i++) {
RefPtr<CacheEntry> cacheEntry = mCacheEntries[i];
nsRefPtr<CacheEntry>& cacheEntry = mCacheEntries[i];
if (cacheEntry->mStorageName.Equals(aStorageName)) {
return cacheEntry;
nsRefPtr<CacheEntry> addRefedCacheEntry = cacheEntry;
return addRefedCacheEntry.forget();
}
}
return nullptr;
@ -149,7 +150,7 @@ DeviceStorageUsedSpaceCache::AccumUsedSizes(const nsAString& aStorageName,
uint64_t* aMusicSoFar,
uint64_t* aTotalSoFar)
{
RefPtr<CacheEntry> cacheEntry = GetCacheEntry(aStorageName);
nsRefPtr<CacheEntry> cacheEntry = GetCacheEntry(aStorageName);
if (!cacheEntry || cacheEntry->mDirty) {
return NS_ERROR_NOT_AVAILABLE;
}
@ -174,7 +175,7 @@ DeviceStorageUsedSpaceCache::SetUsedSizes(const nsAString& aStorageName,
uint64_t aMusicSize,
uint64_t aTotalUsedSize)
{
RefPtr<CacheEntry> cacheEntry = GetCacheEntry(aStorageName);
nsRefPtr<CacheEntry> cacheEntry = GetCacheEntry(aStorageName);
if (!cacheEntry) {
cacheEntry = new CacheEntry;
cacheEntry->mStorageName = aStorageName;
@ -189,10 +190,10 @@ DeviceStorageUsedSpaceCache::SetUsedSizes(const nsAString& aStorageName,
cacheEntry->mDirty = false;
}
class GlobalDirs : public RefCounted<GlobalDirs>
class GlobalDirs
{
public:
MOZ_DECLARE_REFCOUNTED_TYPENAME(GlobalDirs)
NS_INLINE_DECL_REFCOUNTING(GlobalDirs)
#if !defined(MOZ_WIDGET_GONK)
nsCOMPtr<nsIFile> pictures;
nsCOMPtr<nsIFile> videos;
@ -3179,16 +3180,15 @@ nsDOMDeviceStorage::Shutdown()
obs->RemoveObserver(this, "disk-space-watcher");
}
StaticRefPtr<nsDOMDeviceStorage::VolumeNameCache>
nsDOMDeviceStorage::sVolumeNameCache;
StaticAutoPtr<nsTArray<nsString>> nsDOMDeviceStorage::sVolumeNameCache;
// static
void
nsDOMDeviceStorage::GetOrderedVolumeNames(
nsDOMDeviceStorage::VolumeNameArray &aVolumeNames)
{
if (sVolumeNameCache && sVolumeNameCache->mVolumeNames.Length() > 0) {
aVolumeNames.AppendElements(sVolumeNameCache->mVolumeNames);
if (sVolumeNameCache && sVolumeNameCache->Length() > 0) {
aVolumeNames.AppendElements(*sVolumeNameCache);
return;
}
#ifdef MOZ_WIDGET_GONK
@ -3209,8 +3209,8 @@ nsDOMDeviceStorage::GetOrderedVolumeNames(
if (aVolumeNames.IsEmpty()) {
aVolumeNames.AppendElement(EmptyString());
}
sVolumeNameCache = new VolumeNameCache;
sVolumeNameCache->mVolumeNames.AppendElements(aVolumeNames);
sVolumeNameCache = new nsTArray<nsString>;
sVolumeNameCache->AppendElements(aVolumeNames);
}
// static

Просмотреть файл

@ -29,7 +29,6 @@ class nsPIDOMWindow;
#include "prtime.h"
#include "DeviceStorage.h"
#include "mozilla/dom/devicestorage/DeviceStorageRequestChild.h"
#include "mozilla/RefPtr.h"
#include "mozilla/StaticPtr.h"
namespace mozilla {
@ -80,7 +79,7 @@ public:
NS_IMETHOD Run() MOZ_OVERRIDE
{
mozilla::RefPtr<DeviceStorageUsedSpaceCache::CacheEntry> cacheEntry;
nsRefPtr<DeviceStorageUsedSpaceCache::CacheEntry> cacheEntry;
cacheEntry = mCache->GetCacheEntry(mStorageName);
if (cacheEntry) {
cacheEntry->mDirty = true;
@ -120,10 +119,10 @@ public:
private:
friend class InvalidateRunnable;
class CacheEntry : public mozilla::RefCounted<CacheEntry>
struct CacheEntry
{
public:
MOZ_DECLARE_REFCOUNTED_TYPENAME(DeviceStorageUsedSpaceCache::CacheEntry)
NS_INLINE_DECL_REFCOUNTING(DeviceStorageUsedSpaceCache::CacheEntry)
bool mDirty;
nsString mStorageName;
int64_t mFreeBytes;
@ -132,9 +131,9 @@ private:
uint64_t mMusicUsedSize;
uint64_t mTotalUsedSize;
};
mozilla::TemporaryRef<CacheEntry> GetCacheEntry(const nsAString& aStorageName);
already_AddRefed<CacheEntry> GetCacheEntry(const nsAString& aStorageName);
nsTArray<mozilla::RefPtr<CacheEntry> > mCacheEntries;
nsTArray<nsRefPtr<CacheEntry>> mCacheEntries;
nsCOMPtr<nsIThread> mIOThread;

Просмотреть файл

@ -12,7 +12,7 @@ interface nsIDOMEventListener;
interface nsIFile;
%{C++
class DeviceStorageFileDescriptor;
struct DeviceStorageFileDescriptor;
%}
[ptr] native DeviceStorageFdPtr(DeviceStorageFileDescriptor);

Просмотреть файл

@ -50,6 +50,7 @@ using struct mozilla::layers::TextureFactoryIdentifier from "mozilla/layers/Comp
using mozilla::CSSPoint from "Units.h";
using mozilla::CSSToScreenScale from "Units.h";
using mozilla::CommandInt from "mozilla/EventForwards.h";
using mozilla::layers::GeckoContentController::APZStateChange from "mozilla/layers/GeckoContentController.h";
namespace mozilla {
namespace dom {
@ -410,11 +411,10 @@ child:
HandleLongTapUp(CSSPoint point, ScrollableLayerGuid aGuid);
/**
* Notifies the child that the parent has begun or finished transforming
* the visible child content area. Useful for showing/hiding scrollbars.
* Notifies the child about various APZ state changes.
* See GeckoContentController::NotifyAPZStateChange() for details.
*/
NotifyTransformBegin(ViewID aViewId);
NotifyTransformEnd(ViewID aViewId);
NotifyAPZStateChange(ViewID aViewId, APZStateChange aChange, int aArg);
/**
* Sending an activate message moves focus to the child.

Просмотреть файл

@ -74,6 +74,7 @@
#include "mozilla/gfx/Matrix.h"
#include "UnitTransforms.h"
#include "ClientLayerManager.h"
#include "ActiveElementManager.h"
#include "nsColorPickerProxy.h"
@ -687,6 +688,7 @@ TabChild::TabChild(ContentChild* aManager, const TabContext& aContext, uint32_t
, mContextMenuHandled(false)
, mWaitingTouchListeners(false)
, mIgnoreKeyPressEvent(false)
, mActiveElementManager(new ActiveElementManager())
{
if (!sActiveDurationMsSet) {
Preferences::AddIntVarCache(&sActiveDurationMs,
@ -1730,23 +1732,49 @@ TabChild::RecvHandleLongTapUp(const CSSPoint& aPoint, const ScrollableLayerGuid&
}
bool
TabChild::RecvNotifyTransformBegin(const ViewID& aViewId)
TabChild::RecvNotifyAPZStateChange(const ViewID& aViewId,
const APZStateChange& aChange,
const int& aArg)
{
nsIScrollableFrame* sf = nsLayoutUtils::FindScrollableFrameFor(aViewId);
nsIScrollbarOwner* scrollbarOwner = do_QueryFrame(sf);
if (scrollbarOwner) {
scrollbarOwner->ScrollbarActivityStarted();
switch (aChange)
{
case APZStateChange::TransformBegin:
{
nsIScrollableFrame* sf = nsLayoutUtils::FindScrollableFrameFor(aViewId);
nsIScrollbarOwner* scrollbarOwner = do_QueryFrame(sf);
if (scrollbarOwner) {
scrollbarOwner->ScrollbarActivityStarted();
}
break;
}
return true;
}
bool
TabChild::RecvNotifyTransformEnd(const ViewID& aViewId)
{
nsIScrollableFrame* sf = nsLayoutUtils::FindScrollableFrameFor(aViewId);
nsIScrollbarOwner* scrollbarOwner = do_QueryFrame(sf);
if (scrollbarOwner) {
scrollbarOwner->ScrollbarActivityStopped();
case APZStateChange::TransformEnd:
{
nsIScrollableFrame* sf = nsLayoutUtils::FindScrollableFrameFor(aViewId);
nsIScrollbarOwner* scrollbarOwner = do_QueryFrame(sf);
if (scrollbarOwner) {
scrollbarOwner->ScrollbarActivityStopped();
}
break;
}
case APZStateChange::StartTouch:
{
mActiveElementManager->HandleTouchStart(aArg);
break;
}
case APZStateChange::StartPanning:
{
mActiveElementManager->HandlePanStart();
break;
}
case APZStateChange::EndTouch:
{
mActiveElementManager->HandleTouchEnd(aArg);
break;
}
default:
// APZStateChange has a 'sentinel' value, and the compiler complains
// if an enumerator is not handled and there is no 'default' case.
break;
}
return true;
}
@ -1951,6 +1979,10 @@ TabChild::RecvRealTouchEvent(const WidgetTouchEvent& aEvent,
return true;
}
if (aEvent.message == NS_TOUCH_START && localEvent.touches.Length() > 0) {
mActiveElementManager->SetTargetElement(localEvent.touches[0]->Target());
}
nsCOMPtr<nsPIDOMWindow> outerWindow = do_GetInterface(WebNavigation());
nsCOMPtr<nsPIDOMWindow> innerWindow = outerWindow->GetCurrentInnerWindow();

Просмотреть файл

@ -42,6 +42,10 @@ namespace layout {
class RenderFrameChild;
}
namespace widget {
class ActiveElementManager;
}
namespace dom {
class TabChild;
@ -228,6 +232,7 @@ class TabChild : public PBrowserChild,
typedef mozilla::dom::ClonedMessageData ClonedMessageData;
typedef mozilla::layout::RenderFrameChild RenderFrameChild;
typedef mozilla::layout::ScrollingBehavior ScrollingBehavior;
typedef mozilla::widget::ActiveElementManager ActiveElementManager;
public:
/**
@ -296,8 +301,9 @@ public:
const mozilla::layers::ScrollableLayerGuid& aGuid) MOZ_OVERRIDE;
virtual bool RecvHandleLongTapUp(const CSSPoint& aPoint,
const mozilla::layers::ScrollableLayerGuid& aGuid) MOZ_OVERRIDE;
virtual bool RecvNotifyTransformBegin(const ViewID& aViewId) MOZ_OVERRIDE;
virtual bool RecvNotifyTransformEnd(const ViewID& aViewId) MOZ_OVERRIDE;
virtual bool RecvNotifyAPZStateChange(const ViewID& aViewId,
const APZStateChange& aChange,
const int& aArg) MOZ_OVERRIDE;
virtual bool RecvActivate() MOZ_OVERRIDE;
virtual bool RecvDeactivate() MOZ_OVERRIDE;
virtual bool RecvMouseEvent(const nsString& aType,
@ -544,6 +550,7 @@ private:
void FireSingleTapEvent(LayoutDevicePoint aPoint);
bool mIgnoreKeyPressEvent;
nsRefPtr<ActiveElementManager> mActiveElementManager;
DISALLOW_EVIL_CONSTRUCTORS(TabChild);
};

Просмотреть файл

@ -554,17 +554,12 @@ void TabParent::HandleLongTapUp(const CSSPoint& aPoint,
}
}
void TabParent::NotifyTransformBegin(ViewID aViewId)
void TabParent::NotifyAPZStateChange(ViewID aViewId,
APZStateChange aChange,
int aArg)
{
if (!mIsDestroyed) {
unused << SendNotifyTransformBegin(aViewId);
}
}
void TabParent::NotifyTransformEnd(ViewID aViewId)
{
if (!mIsDestroyed) {
unused << SendNotifyTransformEnd(aViewId);
unused << SendNotifyAPZStateChange(aViewId, aChange, aArg);
}
}

Просмотреть файл

@ -212,8 +212,9 @@ public:
void HandleLongTapUp(const CSSPoint& aPoint,
int32_t aModifiers,
const ScrollableLayerGuid& aGuid);
void NotifyTransformBegin(ViewID aViewId);
void NotifyTransformEnd(ViewID aViewId);
void NotifyAPZStateChange(ViewID aViewId,
APZStateChange aChange,
int aArg);
void Activate();
void Deactivate();

Просмотреть файл

@ -11,7 +11,7 @@
#include "nsGlobalWindow.h"
#include "nsClassHashtable.h"
#include "nsRefPtrHashtable.h"
#include "nsObserverService.h"
#include "nsIObserver.h"
#include "nsIPrefService.h"
#include "nsIPrefBranch.h"

Просмотреть файл

@ -163,12 +163,12 @@ private:
/***************************************************************************/
class AutoMounter : public RefCounted<AutoMounter>
class AutoMounter
{
public:
MOZ_DECLARE_REFCOUNTED_TYPENAME(AutoMounter)
NS_INLINE_DECL_REFCOUNTING(AutoMounter)
typedef nsTArray<RefPtr<Volume> > VolumeArray;
typedef nsTArray<RefPtr<Volume>> VolumeArray;
AutoMounter()
: mResponseCallback(new AutoMounterResponseCallback),
@ -692,21 +692,21 @@ UsbCableEventIOThread()
*
**************************************************************************/
class UsbCableObserver : public SwitchObserver,
public RefCounted<UsbCableObserver>
class UsbCableObserver MOZ_FINAL : public SwitchObserver
{
public:
MOZ_DECLARE_REFCOUNTED_TYPENAME(UsbCableObserver)
UsbCableObserver()
{
RegisterSwitchObserver(SWITCH_USB, this);
}
~UsbCableObserver()
{
UnregisterSwitchObserver(SWITCH_USB, this);
}
public:
NS_INLINE_DECL_REFCOUNTING(UsbCableObserver)
UsbCableObserver()
{
RegisterSwitchObserver(SWITCH_USB, this);
}
virtual void Notify(const SwitchEvent& aEvent)
{
DBG("UsbCable switch device: %d state: %s\n",

Просмотреть файл

@ -9,7 +9,7 @@
#include "nsIVolume.h"
#include "nsString.h"
#include "mozilla/Observer.h"
#include "mozilla/RefPtr.h"
#include "nsISupportsImpl.h"
#include "nsWhitespaceTokenizer.h"
namespace mozilla {
@ -24,10 +24,11 @@ namespace system {
*
***************************************************************************/
class Volume : public RefCounted<Volume>
class Volume MOZ_FINAL
{
public:
MOZ_DECLARE_REFCOUNTED_TYPENAME(Volume)
NS_INLINE_DECL_REFCOUNTING(Volume)
Volume(const nsCSubstring& aVolumeName);
typedef long STATE; // States are now defined in nsIVolume.idl

Просмотреть файл

@ -6,6 +6,7 @@
#define mozilla_system_volumecommand_h__
#include "nsString.h"
#include "nsISupportsImpl.h"
#include "mozilla/RefPtr.h"
#include <algorithm>
#include <vold/ResponseCode.h>
@ -32,15 +33,16 @@ class VolumeCommand;
*
***************************************************************************/
class VolumeResponseCallback : public RefCounted<VolumeResponseCallback>
class VolumeResponseCallback
{
protected:
virtual ~VolumeResponseCallback() {}
public:
MOZ_DECLARE_REFCOUNTED_TYPENAME(VolumeResponseCallback)
NS_INLINE_DECL_REFCOUNTING(VolumeResponseCallback)
VolumeResponseCallback()
: mResponseCode(0), mPending(false) {}
virtual ~VolumeResponseCallback() {}
bool Done() const
{
// Response codes from the 200, 400, and 500 series all indicated that
@ -106,10 +108,14 @@ private:
*
***************************************************************************/
class VolumeCommand : public RefCounted<VolumeCommand>
class VolumeCommand
{
protected:
virtual ~VolumeCommand() {}
public:
MOZ_DECLARE_REFCOUNTED_TYPENAME(VolumeCommand)
NS_INLINE_DECL_REFCOUNTING(VolumeCommand)
VolumeCommand(VolumeResponseCallback* aCallback)
: mBytesConsumed(0),
mCallback(aCallback)
@ -124,8 +130,6 @@ public:
SetCmd(aCommand);
}
virtual ~VolumeCommand() {}
void SetCmd(const nsACString& aCommand)
{
mCmd.Truncate();

Просмотреть файл

@ -11,7 +11,7 @@
#include "base/message_loop.h"
#include "mozilla/FileUtils.h"
#include "mozilla/Observer.h"
#include "mozilla/RefPtr.h"
#include "nsISupportsImpl.h"
#include "nsString.h"
#include "nsTArray.h"
@ -73,16 +73,16 @@ namespace system {
*
***************************************************************************/
class VolumeManager : public MessageLoopForIO::LineWatcher,
public RefCounted<VolumeManager>
class VolumeManager MOZ_FINAL : public MessageLoopForIO::LineWatcher
{
public:
MOZ_DECLARE_REFCOUNTED_TYPENAME(VolumeManager)
virtual ~VolumeManager();
typedef nsTArray<RefPtr<Volume> > VolumeArray;
public:
NS_INLINE_DECL_REFCOUNTING(VolumeManager)
typedef nsTArray<RefPtr<Volume>> VolumeArray;
VolumeManager();
virtual ~VolumeManager();
//-----------------------------------------------------------------------
//

Просмотреть файл

@ -19,14 +19,15 @@ class nsVolumeService;
* class, but whose methods are called from IOThread.
*/
class VolumeServiceIOThread : public VolumeManager::StateObserver,
public Volume::EventObserver,
public RefCounted<VolumeServiceIOThread>
public Volume::EventObserver
{
public:
MOZ_DECLARE_REFCOUNTED_TYPENAME(VolumeServiceIOThread)
VolumeServiceIOThread(nsVolumeService* aVolumeService);
~VolumeServiceIOThread();
public:
NS_INLINE_DECL_REFCOUNTING(VolumeServiceIOThread)
VolumeServiceIOThread(nsVolumeService* aVolumeService);
private:
void UpdateAllVolumes();

Просмотреть файл

@ -53,11 +53,12 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=821850
is(typeof bound.wrappedJSObject.unexposedProperty, 'undefined',
"Unexposed property should not be defined in content");
// Check that here document.QueryInterface works
ok("QueryInterface" in document,
"Should have a document.QueryInterface here");
is(document.QueryInterface(Components.interfaces.nsIDOMDocument),
document, "Should be able to QI the document");
// Check that here HTMLImageElement.QueryInterface works
var img = document.querySelector("img");
ok("QueryInterface" in img,
"Should have a img.QueryInterface here");
is(img.QueryInterface(Components.interfaces.nsIImageLoadingContent),
img, "Should be able to QI the image");
// Make sure standard constructors work right in the presence of
// sandboxPrototype and Xray-resolved constructors.
@ -289,6 +290,7 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=821850
<div id="content">
<div id="bound">Bound element</div>
<div id="bound2">Bound element</div>
<img/>
</div>
<pre id="test">
</pre>

Просмотреть файл

@ -165,34 +165,34 @@ INSERT_TESTS = {
'tests': [
{ 'id': 'IIMG:url_TEXT-1_SC',
'rte1-id': 'a-insertimage-0',
'desc': 'Insert image with URL "http://goo.gl/bar.png"',
'value': 'http://goo.gl/bar.png',
'desc': 'Insert image with URL "bar.png"',
'value': 'bar.png',
'checkAttrs': True,
'pad': 'foo^bar',
'expected': [ 'foo<img src="http://goo.gl/bar.png">|bar',
'foo<img src="http://goo.gl/bar.png">^bar' ] },
'expected': [ 'foo<img src="bar.png">|bar',
'foo<img src="bar.png">^bar' ] },
{ 'id': 'IIMG:url_IMG-1_SO',
'desc': 'Change existing image to new URL, selection on <img>',
'value': 'http://baz.com/quz.png',
'value': 'quz.png',
'checkAttrs': True,
'pad': '<span>foo{<img src="http://goo.gl/bar.png">}bar</span>',
'expected': [ '<span>foo<img src="http://baz.com/quz.png"/>|bar</span>',
'<span>foo<img src="http://baz.com/quz.png"/>^bar</span>' ] },
'pad': '<span>foo{<img src="bar.png">}bar</span>',
'expected': [ '<span>foo<img src="quz.png"/>|bar</span>',
'<span>foo<img src="quz.png"/>^bar</span>' ] },
{ 'id': 'IIMG:url_SPAN-IMG-1_SO',
'desc': 'Change existing image to new URL, selection in text surrounding <img>',
'value': 'http://baz.com/quz.png',
'value': 'quz.png',
'checkAttrs': True,
'pad': 'foo[<img src="http://goo.gl/bar.png">]bar',
'expected': [ 'foo<img src="http://baz.com/quz.png"/>|bar',
'foo<img src="http://baz.com/quz.png"/>^bar' ] },
'pad': 'foo[<img src="bar.png">]bar',
'expected': [ 'foo<img src="quz.png"/>|bar',
'foo<img src="quz.png"/>^bar' ] },
{ 'id': 'IIMG:._SPAN-IMG-1_SO',
'desc': 'Remove existing image or URL, selection on <img>',
'value': '',
'checkAttrs': True,
'pad': '<span>foo{<img src="http://goo.gl/bar.png">}bar</span>',
'pad': '<span>foo{<img src="bar.png">}bar</span>',
'expected': [ '<span>foo^bar</span>',
'<span>foo<img>|bar</span>',
'<span>foo<img>^bar</span>',
@ -203,7 +203,7 @@ INSERT_TESTS = {
'desc': 'Remove existing image or URL, selection in text surrounding <img>',
'value': '',
'checkAttrs': True,
'pad': 'foo[<img src="http://goo.gl/bar.png">]bar',
'pad': 'foo[<img src="bar.png">]bar',
'expected': [ 'foo^bar',
'foo<img>|bar',
'foo<img>^bar',

Просмотреть файл

@ -416,7 +416,7 @@ public:
*/
virtual TemporaryRef<DataSourceSurface> GetDataSurface();
DebugOnly<bool> mIsMapped;
bool mIsMapped;
};
/* This is an abstract object that accepts path segments. */

Просмотреть файл

@ -25,19 +25,21 @@ CopySurfaceDataToPackedArray(uint8_t* aSrc, uint8_t* aDst, IntSize aSrcSize,
/**
* Convert aSurface to a packed buffer in BGRA format. The pixel data is
* returned in a buffer allocated with new uint8_t[].
* returned in a buffer allocated with new uint8_t[]. The caller then has
* ownership of the buffer and is responsible for delete[]'ing it.
*/
uint8_t*
SurfaceToPackedBGRA(DataSourceSurface *aSurface);
/**
* Convert aSurface to a packed buffer in BGR format. The pixel data is
* returned in a buffer allocated with new uint8_t[].
* returned in a buffer allocated with new uint8_t[]. The caller then has
* ownership of the buffer and is responsible for delete[]'ing it.
*
* This function is currently only intended for use with surfaces of format
* SurfaceFormat::B8G8R8X8 since the X components of the pixel data are simply
* dropped (no attempt is made to un-pre-multiply alpha from the color
* components).
* SurfaceFormat::B8G8R8X8 since the X components of the pixel data (if any)
* are simply dropped (no attempt is made to un-pre-multiply alpha from the
* color components).
*/
uint8_t*
SurfaceToPackedBGR(DataSourceSurface *aSurface);

Просмотреть файл

@ -26,6 +26,7 @@
#include "mozilla/layers/CompositorTypes.h"
#include "FrameMetrics.h"
#include "FilterSupport.h"
#include "mozilla/layers/GeckoContentController.h"
#ifdef _MSC_VER
#pragma warning( disable : 4800 )
@ -1069,6 +1070,16 @@ struct ParamTraits<mozilla::gfx::FilterDescription>
}
};
typedef mozilla::layers::GeckoContentController::APZStateChange APZStateChange;
template <>
struct ParamTraits<APZStateChange>
: public ContiguousTypedEnumSerializer<
APZStateChange,
APZStateChange::TransformBegin,
APZStateChange::APZStateChangeSentinel>
{};
} /* namespace IPC */
#endif /* __GFXMESSAGEUTILS_H__ */

Просмотреть файл

@ -137,18 +137,12 @@ enum SurfaceInitMode
/**
* A base class for a platform-dependent helper for use by TextureHost.
*/
class CompositorBackendSpecificData : public RefCounted<CompositorBackendSpecificData>
class CompositorBackendSpecificData
{
public:
MOZ_DECLARE_REFCOUNTED_TYPENAME(CompositorBackendSpecificData)
CompositorBackendSpecificData()
{
MOZ_COUNT_CTOR(CompositorBackendSpecificData);
}
virtual ~CompositorBackendSpecificData()
{
MOZ_COUNT_DTOR(CompositorBackendSpecificData);
}
NS_INLINE_DECL_REFCOUNTING(CompositorBackendSpecificData)
protected:
virtual ~CompositorBackendSpecificData() {}
};
/**
@ -195,21 +189,20 @@ public:
* The target and viewport methods can be called before any DrawQuad call and
* affect any subsequent DrawQuad calls.
*/
class Compositor : public RefCounted<Compositor>
class Compositor
{
protected:
virtual ~Compositor() {}
public:
MOZ_DECLARE_REFCOUNTED_TYPENAME(Compositor)
NS_INLINE_DECL_REFCOUNTING(Compositor)
Compositor(PCompositorParent* aParent = nullptr)
: mCompositorID(0)
, mDiagnosticTypes(DIAGNOSTIC_NONE)
, mParent(aParent)
, mScreenRotation(ROTATION_0)
{
MOZ_COUNT_CTOR(Compositor);
}
virtual ~Compositor()
{
MOZ_COUNT_DTOR(Compositor);
}
virtual TemporaryRef<DataTextureSource> CreateDataTextureSource(TextureFlags aFlags = 0) = 0;

Просмотреть файл

@ -37,15 +37,18 @@ namespace layers {
* to the compositor by the compositable host as a parameter to DrawQuad.
*/
struct Effect : public RefCounted<Effect>
struct Effect
{
MOZ_DECLARE_REFCOUNTED_TYPENAME(Effect)
NS_INLINE_DECL_REFCOUNTING(Effect)
Effect(EffectTypes aType) : mType(aType) {}
EffectTypes mType;
virtual void PrintInfo(nsACString& aTo, const char* aPrefix) = 0;
protected:
virtual ~Effect() {}
virtual void PrintInfo(nsACString& aTo, const char* aPrefix) =0;
};
// Render from a texture

Просмотреть файл

@ -68,14 +68,16 @@ class TextureClientData;
* where we have a different way of interfacing with the textures - in terms of
* drawing into the compositable and/or passing its contents to the compostior.
*/
class CompositableClient : public AtomicRefCounted<CompositableClient>
class CompositableClient
{
public:
MOZ_DECLARE_REFCOUNTED_TYPENAME(CompositableClient)
CompositableClient(CompositableForwarder* aForwarder, TextureFlags aFlags = 0);
protected:
virtual ~CompositableClient();
public:
NS_INLINE_DECL_THREADSAFE_REFCOUNTING(CompositableClient)
CompositableClient(CompositableForwarder* aForwarder, TextureFlags aFlags = 0);
virtual TextureInfo GetTextureInfo() const = 0;
LayersBackend GetCompositorBackendType() const;

Просмотреть файл

@ -19,14 +19,8 @@ namespace layers {
class ISurfaceAllocator;
class SimpleTextureClientPool : public RefCounted<SimpleTextureClientPool>
class SimpleTextureClientPool
{
public:
MOZ_DECLARE_REFCOUNTED_TYPENAME(SimpleTextureClientPool)
SimpleTextureClientPool(gfx::SurfaceFormat aFormat, gfx::IntSize aSize,
ISurfaceAllocator *aAllocator);
~SimpleTextureClientPool()
{
for (auto it = mOutstandingTextureClients.begin(); it != mOutstandingTextureClients.end(); ++it) {
@ -34,6 +28,12 @@ public:
}
}
public:
NS_INLINE_DECL_REFCOUNTING(SimpleTextureClientPool)
SimpleTextureClientPool(gfx::SurfaceFormat aFormat, gfx::IntSize aSize,
ISurfaceAllocator *aAllocator);
/**
* If a TextureClient is AutoRecycled, when the last reference is
* released this object will be automatically return to the pool as

Просмотреть файл

@ -75,23 +75,17 @@ namespace layers {
* TextureClient's data until the compositor side confirmed that it is safe to
* deallocte or recycle the it.
*/
class TextureChild : public PTextureChild
, public AtomicRefCounted<TextureChild>
class TextureChild MOZ_FINAL : public PTextureChild
{
public:
MOZ_DECLARE_REFCOUNTED_TYPENAME(TextureChild)
NS_INLINE_DECL_THREADSAFE_REFCOUNTING(TextureChild)
TextureChild()
: mForwarder(nullptr)
, mTextureData(nullptr)
, mTextureClient(nullptr)
, mIPCOpen(false)
{
MOZ_COUNT_CTOR(TextureChild);
}
~TextureChild()
{
MOZ_COUNT_DTOR(TextureChild);
}
bool Recv__delete__() MOZ_OVERRIDE;

Просмотреть файл

@ -18,13 +18,15 @@ namespace layers {
class ISurfaceAllocator;
class TextureClientPool : public RefCounted<TextureClientPool>
class TextureClientPool MOZ_FINAL
{
~TextureClientPool();
public:
MOZ_DECLARE_REFCOUNTED_TYPENAME(TextureClientPool)
NS_INLINE_DECL_REFCOUNTING(TextureClientPool)
TextureClientPool(gfx::SurfaceFormat aFormat, gfx::IntSize aSize,
ISurfaceAllocator *aAllocator);
~TextureClientPool();
/**
* Gets an allocated TextureClient of size and format that are determined

Просмотреть файл

@ -47,11 +47,13 @@ class ClientLayerManager;
// A class to help implement copy-on-write semantics for shared tiles.
class gfxSharedReadLock : public AtomicRefCounted<gfxSharedReadLock> {
public:
MOZ_DECLARE_REFCOUNTED_TYPENAME(gfxSharedReadLock)
class gfxSharedReadLock {
protected:
virtual ~gfxSharedReadLock() {}
public:
NS_INLINE_DECL_THREADSAFE_REFCOUNTING(gfxSharedReadLock)
virtual int32_t ReadLock() = 0;
virtual int32_t ReadUnlock() = 0;
virtual int32_t GetReadCount() = 0;

Просмотреть файл

@ -779,7 +779,6 @@ APZCTreeManager::HandOffFling(AsyncPanZoomController* aPrev, ScreenPoint aVeloci
next->TakeOverFling(transformedVelocity);
}
bool
APZCTreeManager::FlushRepaintsForOverscrollHandoffChain()
{
@ -796,6 +795,30 @@ APZCTreeManager::FlushRepaintsForOverscrollHandoffChain()
return true;
}
bool
APZCTreeManager::CanBePanned(AsyncPanZoomController* aApzc)
{
MonitorAutoLock lock(mTreeLock); // to access mOverscrollHandoffChain
// Find |aApzc| in the handoff chain.
uint32_t i;
for (i = 0; i < mOverscrollHandoffChain.length(); ++i) {
if (mOverscrollHandoffChain[i] == aApzc) {
break;
}
}
// See whether any APZC in the handoff chain starting from |aApzc|
// has room to be panned.
for (uint32_t j = i; j < mOverscrollHandoffChain.length(); ++j) {
if (mOverscrollHandoffChain[j]->IsPannable()) {
return true;
}
}
return false;
}
bool
APZCTreeManager::HitTestAPZC(const ScreenIntPoint& aPoint)
{

Просмотреть файл

@ -214,6 +214,7 @@ public:
* Sets allowed touch behavior values for current touch-session for specific apzc (determined by guid).
* Should be invoked by the widget. Each value of the aValues arrays corresponds to the different
* touch point that is currently active.
* Must be called after receiving the TOUCH_START event that starts the touch-session.
*/
void SetAllowedTouchBehavior(const ScrollableLayerGuid& aGuid,
const nsTArray<TouchBehaviorFlags>& aValues);
@ -271,6 +272,13 @@ public:
bool FlushRepaintsForOverscrollHandoffChain();
/**
* Determine whether |aApzc|, or any APZC along its overscroll handoff chain,
* has room to be panned.
* Expects the overscroll handoff chain to already be built.
*/
bool CanBePanned(AsyncPanZoomController* aApzc);
protected:
// Protected destructor, to discourage deletion outside of Release():
virtual ~APZCTreeManager();

Просмотреть файл

@ -61,22 +61,21 @@ struct ViewTransform {
* short circuit that stuff to directly affect layers as they are composited,
* for example, off-main thread animation, async video, async pan/zoom.
*/
class AsyncCompositionManager MOZ_FINAL : public RefCounted<AsyncCompositionManager>
class AsyncCompositionManager MOZ_FINAL
{
friend class AutoResolveRefLayers;
public:
MOZ_DECLARE_REFCOUNTED_TYPENAME(AsyncCompositionManager)
NS_INLINE_DECL_REFCOUNTING(AsyncCompositionManager)
AsyncCompositionManager(LayerManagerComposite* aManager)
: mLayerManager(aManager)
, mIsFirstPaint(false)
, mLayersUpdated(false)
, mReadyForCompose(true)
{
MOZ_COUNT_CTOR(AsyncCompositionManager);
}
~AsyncCompositionManager()
{
MOZ_COUNT_DTOR(AsyncCompositionManager);
}
/**

Просмотреть файл

@ -56,18 +56,18 @@ struct EffectChain;
/**
* A base class for doing CompositableHost and platform dependent task on TextureHost.
*/
class CompositableBackendSpecificData : public RefCounted<CompositableBackendSpecificData>
class CompositableBackendSpecificData
{
protected:
virtual ~CompositableBackendSpecificData() { }
public:
MOZ_DECLARE_REFCOUNTED_TYPENAME(CompositableBackendSpecificData)
NS_INLINE_DECL_REFCOUNTING(CompositableBackendSpecificData)
CompositableBackendSpecificData()
{
MOZ_COUNT_CTOR(CompositableBackendSpecificData);
}
virtual ~CompositableBackendSpecificData()
{
MOZ_COUNT_DTOR(CompositableBackendSpecificData);
}
virtual void SetCompositor(Compositor* aCompositor) {}
virtual void ClearData()
{
@ -124,14 +124,15 @@ protected:
* will use its TextureHost(s) and call Compositor::DrawQuad to do the actual
* rendering.
*/
class CompositableHost : public RefCounted<CompositableHost>
class CompositableHost
{
public:
MOZ_DECLARE_REFCOUNTED_TYPENAME(CompositableHost)
CompositableHost(const TextureInfo& aTextureInfo);
protected:
virtual ~CompositableHost();
public:
NS_INLINE_DECL_REFCOUNTING(CompositableHost)
CompositableHost(const TextureInfo& aTextureInfo);
static TemporaryRef<CompositableHost> Create(const TextureInfo& aTextureInfo);
virtual CompositableType GetType() = 0;

Просмотреть файл

@ -7,6 +7,7 @@
#define GFX_TextRenderer_H
#include "mozilla/gfx/2D.h"
#include "nsISupportsImpl.h"
#include <string>
namespace mozilla {
@ -14,10 +15,11 @@ namespace layers {
class Compositor;
class TextRenderer : public RefCounted<TextRenderer>
class TextRenderer
{
public:
MOZ_DECLARE_REFCOUNTED_TYPENAME(TextRenderer)
NS_INLINE_DECL_REFCOUNTING(TextRenderer)
TextRenderer(Compositor *aCompositor)
: mCompositor(aCompositor)
{

Просмотреть файл

@ -80,13 +80,16 @@ public:
*
* This class is used on the compositor side.
*/
class TextureSource : public RefCounted<TextureSource>
class TextureSource
{
public:
MOZ_DECLARE_REFCOUNTED_TYPENAME(TextureSource)
TextureSource();
protected:
virtual ~TextureSource();
public:
NS_INLINE_DECL_REFCOUNTING(TextureSource)
TextureSource();
/**
* Return the size of the texture in texels.
* If this is a tile iterator, GetSize must return the size of the current tile.

Просмотреть файл

@ -132,6 +132,7 @@ namespace mozilla {
namespace layers {
typedef mozilla::layers::AllowedTouchBehavior AllowedTouchBehavior;
typedef GeckoContentController::APZStateChange APZStateChange;
/*
* The following prefs are used to control the behaviour of the APZC.
@ -420,9 +421,6 @@ AsyncPanZoomController::AsyncPanZoomController(uint64_t aLayersId,
mCurrentAsyncScrollOffset(0, 0),
mAsyncScrollTimeoutTask(nullptr),
mHandlingTouchQueue(false),
mAllowedTouchBehaviorSet(false),
mPreventDefault(false),
mPreventDefaultSet(false),
mTreeManager(aTreeManager),
mScrollParentId(FrameMetrics::NULL_SCROLL_ID),
mAPZCId(sAsyncPanZoomControllerCount++),
@ -498,6 +496,12 @@ AsyncPanZoomController::GetTouchStartTolerance()
}
nsEventStatus AsyncPanZoomController::ReceiveInputEvent(const InputData& aEvent) {
if (aEvent.mInputType == MULTITOUCH_INPUT &&
aEvent.AsMultiTouchInput().mType == MultiTouchInput::MULTITOUCH_START) {
// Starting a new touch block, clear old touch block state.
mTouchBlockState = TouchBlockState();
}
// If we may have touch listeners and touch action property is enabled, we
// enable the machinery that allows touch listeners to preventDefault any touch inputs
// and also waits for the allowed touch behavior values to be received from the outside.
@ -509,10 +513,6 @@ nsEventStatus AsyncPanZoomController::ReceiveInputEvent(const InputData& aEvent)
(mState == NOTHING || mState == TOUCHING || IsPanningState(mState))) {
const MultiTouchInput& multiTouchInput = aEvent.AsMultiTouchInput();
if (multiTouchInput.mType == MultiTouchInput::MULTITOUCH_START) {
mAllowedTouchBehaviors.Clear();
mAllowedTouchBehaviorSet = false;
mPreventDefault = false;
mPreventDefaultSet = false;
SetState(WAITING_CONTENT_RESPONSE);
}
}
@ -615,11 +615,18 @@ nsEventStatus AsyncPanZoomController::OnTouchStart(const MultiTouchInput& aEvent
case FLING:
CancelAnimation();
// Fall through.
case NOTHING:
case NOTHING: {
mX.StartTouch(point.x);
mY.StartTouch(point.y);
APZCTreeManager* treeManagerLocal = mTreeManager;
if (treeManagerLocal) {
bool touchCanBePan = treeManagerLocal->CanBePanned(this);
mGeckoContentController->NotifyAPZStateChange(
GetGuid(), APZStateChange::StartTouch, touchCanBePan);
}
SetState(TOUCHING);
break;
}
case TOUCHING:
case PANNING:
case PANNING_LOCKED_X:
@ -698,6 +705,8 @@ nsEventStatus AsyncPanZoomController::OnTouchMove(const MultiTouchInput& aEvent)
nsEventStatus AsyncPanZoomController::OnTouchEnd(const MultiTouchInput& aEvent) {
APZC_LOG("%p got a touch-end in state %d\n", this, mState);
OnTouchEndOrCancel();
// In case no touch behavior triggered previously we can avoid sending
// scroll events or requesting content repaint. This condition is added
// to make tests consistent - in case touch-action is NONE (and therefore
@ -764,6 +773,7 @@ nsEventStatus AsyncPanZoomController::OnTouchEnd(const MultiTouchInput& aEvent)
nsEventStatus AsyncPanZoomController::OnTouchCancel(const MultiTouchInput& aEvent) {
APZC_LOG("%p got a touch-cancel in state %d\n", this, mState);
OnTouchEndOrCancel();
SetState(NOTHING);
return nsEventStatus_eConsumeNoDefault;
}
@ -929,15 +939,12 @@ nsEventStatus AsyncPanZoomController::OnLongPressUp(const TapGestureInput& aEven
return nsEventStatus_eIgnore;
}
nsEventStatus AsyncPanZoomController::OnSingleTapUp(const TapGestureInput& aEvent) {
APZC_LOG("%p got a single-tap-up in state %d\n", this, mState);
nsEventStatus AsyncPanZoomController::GenerateSingleTap(const ScreenIntPoint& aPoint, mozilla::Modifiers aModifiers) {
nsRefPtr<GeckoContentController> controller = GetGeckoContentController();
// If mZoomConstraints.mAllowDoubleTapZoom is true we wait for a call to OnSingleTapConfirmed before
// sending event to content
if (controller && !mZoomConstraints.mAllowDoubleTapZoom) {
int32_t modifiers = WidgetModifiersToDOMModifiers(aEvent.modifiers);
if (controller) {
CSSPoint geckoScreenPoint;
if (ConvertToGecko(aEvent.mPoint, &geckoScreenPoint)) {
if (ConvertToGecko(aPoint, &geckoScreenPoint)) {
int32_t modifiers = WidgetModifiersToDOMModifiers(aModifiers);
// Because this may be being running as part of APZCTreeManager::ReceiveInputEvent,
// calling controller->HandleSingleTap directly might mean that content receives
// the single tap message before the corresponding touch-up. To avoid that we
@ -947,30 +954,33 @@ nsEventStatus AsyncPanZoomController::OnSingleTapUp(const TapGestureInput& aEven
NewRunnableMethod(controller.get(), &GeckoContentController::HandleSingleTap,
geckoScreenPoint, modifiers, GetGuid()),
0);
mTouchBlockState.mSingleTapOccurred = true;
return nsEventStatus_eConsumeNoDefault;
}
}
return nsEventStatus_eIgnore;
}
nsEventStatus AsyncPanZoomController::OnSingleTapConfirmed(const TapGestureInput& aEvent) {
APZC_LOG("%p got a single-tap-confirmed in state %d\n", this, mState);
nsRefPtr<GeckoContentController> controller = GetGeckoContentController();
if (controller) {
int32_t modifiers = WidgetModifiersToDOMModifiers(aEvent.modifiers);
CSSPoint geckoScreenPoint;
if (ConvertToGecko(aEvent.mPoint, &geckoScreenPoint)) {
// See comment in OnSingleTapUp as to why we do this in PostDelayedTask.
controller->PostDelayedTask(
NewRunnableMethod(controller.get(), &GeckoContentController::HandleSingleTap,
geckoScreenPoint, modifiers, GetGuid()),
0);
return nsEventStatus_eConsumeNoDefault;
}
void AsyncPanZoomController::OnTouchEndOrCancel() {
mGeckoContentController->NotifyAPZStateChange(
GetGuid(), APZStateChange::EndTouch, mTouchBlockState.mSingleTapOccurred);
}
nsEventStatus AsyncPanZoomController::OnSingleTapUp(const TapGestureInput& aEvent) {
APZC_LOG("%p got a single-tap-up in state %d\n", this, mState);
// If mZoomConstraints.mAllowDoubleTapZoom is true we wait for a call to OnSingleTapConfirmed before
// sending event to content
if (!mZoomConstraints.mAllowDoubleTapZoom) {
return GenerateSingleTap(aEvent.mPoint, aEvent.modifiers);
}
return nsEventStatus_eIgnore;
}
nsEventStatus AsyncPanZoomController::OnSingleTapConfirmed(const TapGestureInput& aEvent) {
APZC_LOG("%p got a single-tap-confirmed in state %d\n", this, mState);
return GenerateSingleTap(aEvent.mPoint, aEvent.modifiers);
}
nsEventStatus AsyncPanZoomController::OnDoubleTap(const TapGestureInput& aEvent) {
APZC_LOG("%p got a double-tap in state %d\n", this, mState);
nsRefPtr<GeckoContentController> controller = GetGeckoContentController();
@ -1092,15 +1102,17 @@ nsEventStatus AsyncPanZoomController::StartPanning(const MultiTouchInput& aEvent
} else {
if (GetAxisLockMode() == FREE) {
SetState(PANNING);
return nsEventStatus_eConsumeNoDefault;
} else {
HandlePanning(angle);
}
HandlePanning(angle);
}
if (IsPanningState(mState)) {
mGeckoContentController->NotifyAPZStateChange(GetGuid(), APZStateChange::StartPanning);
return nsEventStatus_eConsumeNoDefault;
}
// Don't consume an event that didn't trigger a panning.
return IsPanningState(mState) ? nsEventStatus_eConsumeNoDefault
: nsEventStatus_eIgnore;
return nsEventStatus_eIgnore;
}
void AsyncPanZoomController::UpdateWithTouchAtDevicePoint(const MultiTouchInput& aEvent) {
@ -1445,6 +1457,11 @@ void AsyncPanZoomController::FlushRepaintForOverscrollHandoff() {
UpdateSharedCompositorFrameMetrics();
}
bool AsyncPanZoomController::IsPannable() const {
ReentrantMonitorAutoEnter lock(mMonitor);
return mX.HasRoomToPan() || mY.HasRoomToPan();
}
void AsyncPanZoomController::RequestContentRepaint() {
RequestContentRepaint(mFrameMetrics);
}
@ -1890,8 +1907,8 @@ void AsyncPanZoomController::ZoomToRect(CSSRect aRect) {
}
void AsyncPanZoomController::ContentReceivedTouch(bool aPreventDefault) {
mPreventDefaultSet = true;
mPreventDefault = aPreventDefault;
mTouchBlockState.mPreventDefaultSet = true;
mTouchBlockState.mPreventDefault = aPreventDefault;
CheckContentResponse();
}
@ -1899,11 +1916,11 @@ void AsyncPanZoomController::CheckContentResponse() {
bool canProceedToTouchState = true;
if (mFrameMetrics.mMayHaveTouchListeners) {
canProceedToTouchState &= mPreventDefaultSet;
canProceedToTouchState &= mTouchBlockState.mPreventDefaultSet;
}
if (mTouchActionPropertyEnabled) {
canProceedToTouchState &= mAllowedTouchBehaviorSet;
canProceedToTouchState &= mTouchBlockState.mAllowedTouchBehaviorSet;
}
if (!canProceedToTouchState) {
@ -1916,14 +1933,14 @@ void AsyncPanZoomController::CheckContentResponse() {
}
if (mState == WAITING_CONTENT_RESPONSE) {
if (!mPreventDefault) {
if (!mTouchBlockState.mPreventDefault) {
SetState(NOTHING);
}
mHandlingTouchQueue = true;
while (!mTouchQueue.IsEmpty()) {
if (!mPreventDefault) {
if (!mTouchBlockState.mPreventDefault) {
HandleInputEvent(mTouchQueue[0]);
}
@ -1947,8 +1964,8 @@ bool AsyncPanZoomController::TouchActionAllowZoom() {
// Pointer events specification implies all touch points to allow zoom
// to perform it.
for (size_t i = 0; i < mAllowedTouchBehaviors.Length(); i++) {
if (!(mAllowedTouchBehaviors[i] & AllowedTouchBehavior::ZOOM)) {
for (size_t i = 0; i < mTouchBlockState.mAllowedTouchBehaviors.Length(); i++) {
if (!(mTouchBlockState.mAllowedTouchBehaviors[i] & AllowedTouchBehavior::ZOOM)) {
return false;
}
}
@ -1958,8 +1975,8 @@ bool AsyncPanZoomController::TouchActionAllowZoom() {
AsyncPanZoomController::TouchBehaviorFlags
AsyncPanZoomController::GetTouchBehavior(uint32_t touchIndex) {
if (touchIndex < mAllowedTouchBehaviors.Length()) {
return mAllowedTouchBehaviors[touchIndex];
if (touchIndex < mTouchBlockState.mAllowedTouchBehaviors.Length()) {
return mTouchBlockState.mAllowedTouchBehaviors[touchIndex];
}
return DefaultTouchBehavior;
}
@ -1973,9 +1990,9 @@ AsyncPanZoomController::GetAllowedTouchBehavior(ScreenIntPoint& aPoint) {
}
void AsyncPanZoomController::SetAllowedTouchBehavior(const nsTArray<TouchBehaviorFlags>& aBehaviors) {
mAllowedTouchBehaviors.Clear();
mAllowedTouchBehaviors.AppendElements(aBehaviors);
mAllowedTouchBehaviorSet = true;
mTouchBlockState.mAllowedTouchBehaviors.Clear();
mTouchBlockState.mAllowedTouchBehaviors.AppendElements(aBehaviors);
mTouchBlockState.mAllowedTouchBehaviorSet = true;
CheckContentResponse();
}
@ -1992,11 +2009,11 @@ void AsyncPanZoomController::SetState(PanZoomState aNewState) {
if (mGeckoContentController) {
if (!IsTransformingState(oldState) && IsTransformingState(aNewState)) {
mGeckoContentController->NotifyTransformBegin(
ScrollableLayerGuid(mLayersId, mFrameMetrics.mPresShellId, mFrameMetrics.GetScrollId()));
mGeckoContentController->NotifyAPZStateChange(
GetGuid(), APZStateChange::TransformBegin);
} else if (IsTransformingState(oldState) && !IsTransformingState(aNewState)) {
mGeckoContentController->NotifyTransformEnd(
ScrollableLayerGuid(mLayersId, mFrameMetrics.mPresShellId, mFrameMetrics.GetScrollId()));
mGeckoContentController->NotifyAPZStateChange(
GetGuid(), APZStateChange::TransformEnd);
}
}
}

Просмотреть файл

@ -315,6 +315,8 @@ public:
* Sets allowed touch behavior for current touch session.
* This method is invoked by the APZCTreeManager which in its turn invoked by
* the widget after performing touch-action values retrieving.
* Must be called after receiving the TOUCH_START even that started the
* touch session.
*/
void SetAllowedTouchBehavior(const nsTArray<TouchBehaviorFlags>& aBehaviors);
@ -332,6 +334,11 @@ public:
mTestAsyncScrollOffset = aPoint;
}
/**
* Returns whether this APZC has room to be panned (in any direction).
*/
bool IsPannable() const;
protected:
// Protected destructor, to discourage deletion outside of Release():
~AsyncPanZoomController();
@ -557,6 +564,36 @@ private:
was not set yet. we still need to abort animations. */
};
// State related to a single touch block. Does not persist across touch blocks.
struct TouchBlockState {
TouchBlockState()
: mAllowedTouchBehaviorSet(false),
mPreventDefault(false),
mPreventDefaultSet(false),
mSingleTapOccurred(false)
{}
// Values of allowed touch behavior for touch points of this touch block.
// Since there are maybe a few current active touch points per time (multitouch case)
// and each touch point should have its own value of allowed touch behavior- we're
// keeping an array of allowed touch behavior values, not the single value.
nsTArray<TouchBehaviorFlags> mAllowedTouchBehaviors;
// Specifies whether mAllowedTouchBehaviors is set for this touch events block.
bool mAllowedTouchBehaviorSet;
// Flag used to specify that content prevented the default behavior of this
// touch events block.
bool mPreventDefault;
// Specifies whether mPreventDefault property is set for this touch events block.
bool mPreventDefaultSet;
// Specifies whether a single tap event was generated during this touch block.
bool mSingleTapOccurred;
};
/*
* Returns whether current touch behavior values allow zooming.
*/
@ -617,6 +654,12 @@ private:
// changes, as it corresponds to the scale portion of those transforms.
void UpdateTransformScale();
// Helper function for OnSingleTapUp() and OnSingleTapConfirmed().
nsEventStatus GenerateSingleTap(const ScreenIntPoint& aPoint, mozilla::Modifiers aModifiers);
// Common processing at the end of a touch block.
void OnTouchEndOrCancel();
uint64_t mLayersId;
nsRefPtr<CompositorParent> mCompositorParent;
PCompositorParent* mCrossProcessCompositorParent;
@ -643,7 +686,9 @@ protected:
// monitor should be held. When setting |mState|, either the SetState()
// function can be used, or the monitor can be held and then |mState| updated.
// IMPORTANT: See the note about lock ordering at the top of APZCTreeManager.h.
ReentrantMonitor mMonitor;
// This is mutable to allow entering it from 'const' methods; doing otherwise
// would significantly limit what methods could be 'const'.
mutable ReentrantMonitor mMonitor;
// Specifies whether we should use touch-action css property. Initialized from
// the preferences. This property (in comparison with the global one) simplifies
@ -718,21 +763,8 @@ private:
// and we don't want to queue the events back up again.
bool mHandlingTouchQueue;
// Values of allowed touch behavior for current touch points.
// Since there are maybe a few current active touch points per time (multitouch case)
// and each touch point should have its own value of allowed touch behavior- we're
// keeping an array of allowed touch behavior values, not the single value.
nsTArray<TouchBehaviorFlags> mAllowedTouchBehaviors;
// Specifies whether mAllowedTouchBehaviors is set for current touch events block.
bool mAllowedTouchBehaviorSet;
// Flag used to specify that content prevented the default behavior of the current
// touch events block.
bool mPreventDefault;
// Specifies whether mPreventDefault property is set for current touch events block.
bool mPreventDefaultSet;
// Stores information about the current touch block.
TouchBlockState mTouchBlockState;
// Extra offset to add in SampleContentTransformForFrame for testing
CSSPoint mTestAsyncScrollOffset;

Просмотреть файл

@ -207,30 +207,30 @@ void Axis::SetVelocity(float aVelocity) {
mVelocity = aVelocity;
}
float Axis::GetCompositionEnd() {
float Axis::GetCompositionEnd() const {
return GetOrigin() + GetCompositionLength();
}
float Axis::GetPageEnd() {
float Axis::GetPageEnd() const {
return GetPageStart() + GetPageLength();
}
float Axis::GetOrigin() {
float Axis::GetOrigin() const {
CSSPoint origin = mAsyncPanZoomController->GetFrameMetrics().GetScrollOffset();
return GetPointOffset(origin);
}
float Axis::GetCompositionLength() {
float Axis::GetCompositionLength() const {
const FrameMetrics& metrics = mAsyncPanZoomController->GetFrameMetrics();
return GetRectLength(metrics.CalculateCompositedRectInCssPixels());
}
float Axis::GetPageStart() {
float Axis::GetPageStart() const {
CSSRect pageRect = mAsyncPanZoomController->GetFrameMetrics().mScrollableRect;
return GetRectOffset(pageRect);
}
float Axis::GetPageLength() {
float Axis::GetPageLength() const {
CSSRect pageRect = mAsyncPanZoomController->GetFrameMetrics().mScrollableRect;
return GetRectLength(pageRect);
}
@ -244,23 +244,29 @@ bool Axis::ScaleWillOverscrollBothSides(float aScale) {
return GetRectLength(metrics.mScrollableRect) < GetRectLength(cssCompositionBounds);
}
bool Axis::HasRoomToPan() const {
return GetOrigin() > GetPageStart()
|| GetCompositionEnd() < GetPageEnd();
}
AxisX::AxisX(AsyncPanZoomController* aAsyncPanZoomController)
: Axis(aAsyncPanZoomController)
{
}
float AxisX::GetPointOffset(const CSSPoint& aPoint)
float AxisX::GetPointOffset(const CSSPoint& aPoint) const
{
return aPoint.x;
}
float AxisX::GetRectLength(const CSSRect& aRect)
float AxisX::GetRectLength(const CSSRect& aRect) const
{
return aRect.width;
}
float AxisX::GetRectOffset(const CSSRect& aRect)
float AxisX::GetRectOffset(const CSSRect& aRect) const
{
return aRect.x;
}
@ -271,17 +277,17 @@ AxisY::AxisY(AsyncPanZoomController* aAsyncPanZoomController)
}
float AxisY::GetPointOffset(const CSSPoint& aPoint)
float AxisY::GetPointOffset(const CSSPoint& aPoint) const
{
return aPoint.y;
}
float AxisY::GetRectLength(const CSSRect& aRect)
float AxisY::GetRectLength(const CSSRect& aRect) const
{
return aRect.height;
}
float AxisY::GetRectOffset(const CSSRect& aRect)
float AxisY::GetRectOffset(const CSSRect& aRect) const
{
return aRect.y;
}

Просмотреть файл

@ -170,18 +170,23 @@ public:
*/
bool ScaleWillOverscrollBothSides(float aScale);
float GetOrigin();
float GetCompositionLength();
float GetPageStart();
float GetPageLength();
float GetCompositionEnd();
float GetPageEnd();
/**
* Returns whether there is room to pan on this axis in either direction.
*/
bool HasRoomToPan() const;
float GetOrigin() const;
float GetCompositionLength() const;
float GetPageStart() const;
float GetPageLength() const;
float GetCompositionEnd() const;
float GetPageEnd() const;
int32_t GetPos() const { return mPos; }
virtual float GetPointOffset(const CSSPoint& aPoint) = 0;
virtual float GetRectLength(const CSSRect& aRect) = 0;
virtual float GetRectOffset(const CSSRect& aRect) = 0;
virtual float GetPointOffset(const CSSPoint& aPoint) const = 0;
virtual float GetRectLength(const CSSRect& aRect) const = 0;
virtual float GetRectOffset(const CSSRect& aRect) const = 0;
protected:
int32_t mPos;
@ -195,17 +200,17 @@ protected:
class AxisX : public Axis {
public:
AxisX(AsyncPanZoomController* mAsyncPanZoomController);
virtual float GetPointOffset(const CSSPoint& aPoint);
virtual float GetRectLength(const CSSRect& aRect);
virtual float GetRectOffset(const CSSRect& aRect);
virtual float GetPointOffset(const CSSPoint& aPoint) const;
virtual float GetRectLength(const CSSRect& aRect) const;
virtual float GetRectOffset(const CSSRect& aRect) const;
};
class AxisY : public Axis {
public:
AxisY(AsyncPanZoomController* mAsyncPanZoomController);
virtual float GetPointOffset(const CSSPoint& aPoint);
virtual float GetRectLength(const CSSRect& aRect);
virtual float GetRectOffset(const CSSRect& aRect);
virtual float GetPointOffset(const CSSPoint& aPoint) const;
virtual float GetRectLength(const CSSRect& aRect) const;
virtual float GetRectOffset(const CSSRect& aRect) const;
};
}

Просмотреть файл

@ -113,13 +113,42 @@ public:
return false;
}
MOZ_BEGIN_NESTED_ENUM_CLASS(APZStateChange, int8_t)
/**
* APZ started modifying the view (including panning, zooming, and fling).
*/
TransformBegin,
/**
* APZ finished modifying the view.
*/
TransformEnd,
/**
* APZ started a touch.
* |aArg| is 1 if touch can be a pan, 0 otherwise.
*/
StartTouch,
/**
* APZ started a pan.
*/
StartPanning,
/**
* APZ finished processing a touch.
* |aArg| is 1 if touch was a click, 0 otherwise.
*/
EndTouch,
APZStateChangeSentinel
MOZ_END_NESTED_ENUM_CLASS(APZStateChange)
/**
* General tranformation notices for consumers. These fire any time
* the apzc is modifying the view, including panning, zooming, and
* fling.
* General notices of APZ state changes for consumers.
* |aGuid| identifies the APZC originating the state change.
* |aChange| identifies the type of state change
* |aArg| is used by some state changes to pass extra information (see
* the documentation for each state change above)
*/
virtual void NotifyTransformBegin(const ScrollableLayerGuid& aGuid) {}
virtual void NotifyTransformEnd(const ScrollableLayerGuid& aGuid) {}
virtual void NotifyAPZStateChange(const ScrollableLayerGuid& aGuid,
APZStateChange aChange,
int aArg = 0) {}
GeckoContentController() {}
@ -128,6 +157,8 @@ protected:
virtual ~GeckoContentController() {}
};
MOZ_FINISH_NESTED_ENUM_CLASS(GeckoContentController::APZStateChange)
}
}

Просмотреть файл

@ -23,10 +23,9 @@ class RenderFrameChild;
namespace layers {
class LayerTransactionChild : public PLayerTransactionChild
, public AtomicRefCounted<LayerTransactionChild>
{
public:
MOZ_DECLARE_REFCOUNTED_TYPENAME(LayerTransactionChild)
NS_INLINE_DECL_THREADSAFE_REFCOUNTING(LayerTransactionChild)
/**
* Clean this up, finishing with Send__delete__().
*
@ -43,8 +42,6 @@ protected:
: mIPCOpen(false)
{}
~LayerTransactionChild() { }
friend class AtomicRefCounted<LayerTransactionChild>;
friend class detail::RefCounted<LayerTransactionChild, detail::AtomicRefCount>;
virtual PGrallocBufferChild*
AllocPGrallocBufferChild(const IntSize&,

Просмотреть файл

@ -64,13 +64,14 @@ struct EffectChain;
* This is primarily intended for direct texturing APIs that need to attach
* shared objects (such as an EGLImage) to a gl texture.
*/
class CompositorTexturePoolOGL : public RefCounted<CompositorTexturePoolOGL>
class CompositorTexturePoolOGL
{
public:
MOZ_DECLARE_REFCOUNTED_TYPENAME(CompositorTexturePoolOGL)
protected:
virtual ~CompositorTexturePoolOGL() {}
public:
NS_INLINE_DECL_REFCOUNTING(CompositorTexturePoolOGL)
virtual void Clear() = 0;
virtual GLuint GetTexture(GLenum aTarget, GLenum aEnum) = 0;

Просмотреть файл

@ -230,10 +230,10 @@ namespace FilterWrappers {
// Internally, this is achieved by wrapping the original FilterNode with
// conversion FilterNodes. These filter nodes are cached in such a way that no
// repeated or back-and-forth conversions happen.
class FilterCachedColorModels : public RefCounted<FilterCachedColorModels>
class FilterCachedColorModels
{
public:
MOZ_DECLARE_REFCOUNTED_TYPENAME(FilterCachedColorModels)
NS_INLINE_DECL_REFCOUNTING(FilterCachedColorModels)
// aFilter can be null. In that case, ForColorModel will return a non-null
// completely transparent filter for all color models.
FilterCachedColorModels(DrawTarget* aDT,

Просмотреть файл

@ -34,7 +34,7 @@ typedef enum {
nsLineStyle_kDotted = 3
} nsLineStyle;
class nsRenderingContext
class nsRenderingContext MOZ_FINAL
{
typedef mozilla::gfx::UserData UserData;
typedef mozilla::gfx::UserDataKey UserDataKey;
@ -42,7 +42,6 @@ class nsRenderingContext
public:
nsRenderingContext() : mP2A(0.) {}
// ~nsRenderingContext() {}
NS_INLINE_DECL_REFCOUNTING(nsRenderingContext)
@ -130,7 +129,12 @@ public:
return mUserData.Remove(key);
}
protected:
private:
// Private destructor, to discourage deletion outside of Release():
~nsRenderingContext()
{
}
int32_t GetMaxChunkLength();
nsRefPtr<gfxContext> mThebes;

Просмотреть файл

@ -168,7 +168,14 @@ FrameMetrics TestFrameMetrics() {
* consumed them and triggered scrolling behavior.
*/
static
void ApzcPan(AsyncPanZoomController* apzc, TestAPZCTreeManager* aTreeManager, int& aTime, int aTouchStartY, int aTouchEndY, bool expectIgnoredPan = false, bool hasTouchListeners = false) {
void ApzcPan(AsyncPanZoomController* apzc,
TestAPZCTreeManager* aTreeManager,
int& aTime,
int aTouchStartY,
int aTouchEndY,
bool expectIgnoredPan = false,
bool hasTouchListeners = false,
nsTArray<uint32_t>* aAllowedTouchBehaviors = nullptr) {
const int TIME_BETWEEN_TOUCH_EVENT = 100;
const int OVERCOME_TOUCH_TOLERANCE = 100;
@ -198,6 +205,11 @@ void ApzcPan(AsyncPanZoomController* apzc, TestAPZCTreeManager* aTreeManager, in
EXPECT_EQ(status, touchStartStatus);
// APZC should be in TOUCHING state
// Allowed touch behaviours must be set after sending touch-start.
if (aAllowedTouchBehaviors) {
apzc->SetAllowedTouchBehavior(*aAllowedTouchBehaviors);
}
nsEventStatus touchMoveStatus;
if (expectIgnoredPan) {
// APZC should ignore panning, be in TOUCHING state and therefore return eIgnore.
@ -254,12 +266,11 @@ void DoPanTest(bool aShouldTriggerScroll, bool aShouldUseTouchAction, uint32_t a
ScreenPoint pointOut;
ViewTransform viewTransformOut;
nsTArray<uint32_t> values;
values.AppendElement(aBehavior);
nsTArray<uint32_t> allowedTouchBehaviors;
allowedTouchBehaviors.AppendElement(aBehavior);
// Pan down
apzc->SetAllowedTouchBehavior(values);
ApzcPan(apzc, tm, time, touchStart, touchEnd, !aShouldTriggerScroll);
ApzcPan(apzc, tm, time, touchStart, touchEnd, !aShouldTriggerScroll, false, &allowedTouchBehaviors);
apzc->SampleContentTransformForFrame(testStartTime, &viewTransformOut, pointOut);
if (aShouldTriggerScroll) {
@ -271,8 +282,7 @@ void DoPanTest(bool aShouldTriggerScroll, bool aShouldUseTouchAction, uint32_t a
}
// Pan back
apzc->SetAllowedTouchBehavior(values);
ApzcPan(apzc, tm, time, touchEnd, touchStart, !aShouldTriggerScroll);
ApzcPan(apzc, tm, time, touchEnd, touchStart, !aShouldTriggerScroll, false, &allowedTouchBehaviors);
apzc->SampleContentTransformForFrame(testStartTime, &viewTransformOut, pointOut);
EXPECT_EQ(pointOut, ScreenPoint());
@ -613,11 +623,10 @@ TEST_F(AsyncPanZoomControllerTester, PanWithPreventDefault) {
ViewTransform viewTransformOut;
// Pan down
nsTArray<uint32_t> values;
values.AppendElement(mozilla::layers::AllowedTouchBehavior::VERTICAL_PAN);
nsTArray<uint32_t> allowedTouchBehaviors;
allowedTouchBehaviors.AppendElement(mozilla::layers::AllowedTouchBehavior::VERTICAL_PAN);
apzc->SetTouchActionEnabled(true);
apzc->SetAllowedTouchBehavior(values);
ApzcPan(apzc, tm, time, touchStart, touchEnd, true, true);
ApzcPan(apzc, tm, time, touchStart, touchEnd, true, true, &allowedTouchBehaviors);
// Send the signal that content has handled and preventDefaulted the touch
// events. This flushes the event queue.
@ -746,16 +755,18 @@ DoLongPressTest(bool aShouldUseTouchAction, uint32_t aBehavior) {
apzc->NotifyLayersUpdated(TestFrameMetrics(), true);
apzc->UpdateZoomConstraints(ZoomConstraints(false, false, CSSToScreenScale(1.0), CSSToScreenScale(1.0)));
nsTArray<uint32_t> values;
values.AppendElement(aBehavior);
apzc->SetTouchActionEnabled(aShouldUseTouchAction);
apzc->SetAllowedTouchBehavior(values);
int time = 0;
nsEventStatus status = ApzcDown(apzc, 10, 10, time);
EXPECT_EQ(nsEventStatus_eConsumeNoDefault, status);
// SetAllowedTouchBehavior() must be called after sending touch-start.
nsTArray<uint32_t> allowedTouchBehaviors;
allowedTouchBehaviors.AppendElement(aBehavior);
apzc->SetAllowedTouchBehavior(allowedTouchBehaviors);
MockFunction<void(std::string checkPointName)> check;
{

Просмотреть файл

@ -73,12 +73,14 @@
#include "TexturePoolOGL.h"
#endif
#ifdef USE_SKIA
#include "mozilla/Hal.h"
#ifdef USE_SKIA
#include "skia/SkGraphics.h"
#include "SkiaGLGlue.h"
#else
class mozilla::gl::SkiaGLGlue : public GenericAtomicRefCounted {
};
#endif
#include "mozilla/Preferences.h"
@ -928,7 +930,9 @@ gfxPlatform::InitializeSkiaCacheLimits()
printf_stderr("Determined SkiaGL cache limits: Size %i, Items: %i\n", cacheSizeLimit, cacheItemLimit);
#endif
#ifdef USE_SKIA_GPU
mSkiaGlue->GetGrContext()->setTextureCacheLimits(cacheItemLimit, cacheSizeLimit);
#endif
}
}

Просмотреть файл

@ -12,7 +12,7 @@
#include "nsDataHashtable.h"
#include "nsHashKeys.h"
#include "nsIPropertyBag2.h"
#include "nsObserverService.h"
#include "nsIObserverService.h"
using namespace mozilla;
using namespace mozilla::hal;

Просмотреть файл

@ -12,7 +12,8 @@
#include <mozilla/dom/battery/Constants.h>
#include <mozilla/Services.h>
#include <nsObserverService.h>
#include <nsIObserverService.h>
#include <nsIObserver.h>
#include <dlfcn.h>

Просмотреть файл

@ -294,11 +294,11 @@ public:
} // anonymous namespace
class BatteryObserver : public IUeventObserver,
public RefCounted<BatteryObserver>
class BatteryObserver : public IUeventObserver
{
public:
MOZ_DECLARE_REFCOUNTED_TYPENAME(BatteryObserver)
NS_INLINE_DECL_REFCOUNTING(BatteryObserver)
BatteryObserver()
:mUpdater(new BatteryUpdater())
{

Просмотреть файл

@ -51,10 +51,11 @@ namespace hal_impl {
* SWITCH_STATE=0
* SEQNUM=5038
*/
class SwitchHandler : public RefCounted<SwitchHandler>
class SwitchHandler
{
public:
MOZ_DECLARE_REFCOUNTED_TYPENAME(SwitchHandler)
NS_INLINE_DECL_REFCOUNTING(SwitchHandler)
SwitchHandler(const char* aDevPath, SwitchDevice aDevice)
: mDevPath(aDevPath),
mState(SWITCH_STATE_UNKNOWN),
@ -230,21 +231,20 @@ private:
SwitchEvent mEvent;
};
class SwitchEventObserver : public IUeventObserver,
public RefCounted<SwitchEventObserver>
class SwitchEventObserver MOZ_FINAL : public IUeventObserver
{
public:
MOZ_DECLARE_REFCOUNTED_TYPENAME(SwitchEventObserver)
SwitchEventObserver() : mEnableCount(0)
{
Init();
}
~SwitchEventObserver()
{
mHandler.Clear();
}
public:
NS_INLINE_DECL_REFCOUNTING(SwitchEventObserver)
SwitchEventObserver() : mEnableCount(0)
{
Init();
}
int GetEnableCount()
{
return mEnableCount;

Просмотреть файл

@ -13,6 +13,8 @@
#include "gfxRect.h"
#include "GraphicsFilter.h"
#include "gfxASurface.h"
#include "mozilla/gfx/2D.h"
#include "mozilla/RefPtr.h"
#include "nsRect.h"
#include "nsSize.h"
#include "limits.h"
@ -55,7 +57,7 @@ native nsSize(nsSize);
native Orientation(mozilla::image::Orientation);
[ref] native TimeStamp(mozilla::TimeStamp);
[ptr] native SVGImageContext(mozilla::SVGImageContext);
native already_AddRefed_gfxASurface(already_AddRefed<gfxASurface>);
native TempRefSourceSurface(mozilla::TemporaryRef<mozilla::gfx::SourceSurface>);
/**
@ -65,7 +67,7 @@ native already_AddRefed_gfxASurface(already_AddRefed<gfxASurface>);
*
* Internally, imgIContainer also manages animation of images.
*/
[scriptable, builtinclass, uuid(8b7db7dd-bfe9-40d3-9114-3a79c0658afd)]
[scriptable, builtinclass, uuid(503a830c-734d-4362-91f6-73f83ac59646)]
interface imgIContainer : nsISupports
{
/**
@ -150,6 +152,7 @@ interface imgIContainer : nsISupports
const long FLAG_DECODE_NO_COLORSPACE_CONVERSION = 0x4;
const long FLAG_CLAMP = 0x8;
const long FLAG_HIGH_QUALITY_SCALING = 0x10;
const long FLAG_WANT_DATA_SURFACE = 0x20;
/**
* Constants for specifying various "special" frames.
@ -173,9 +176,8 @@ interface imgIContainer : nsISupports
* @param aWhichFrame Frame specifier of the FRAME_* variety.
* @param aFlags Flags of the FLAG_* variety
*/
[noscript, notxpcom] already_AddRefed_gfxASurface
getFrame(in uint32_t aWhichFrame,
in uint32_t aFlags);
[noscript, notxpcom] TempRefSourceSurface getFrame(in uint32_t aWhichFrame,
in uint32_t aFlags);
/**
* Whether the given frame is opaque; that is, needs the background painted

Просмотреть файл

@ -6,11 +6,15 @@
#include "gfxDrawable.h"
#include "gfxPlatform.h"
#include "gfxUtils.h"
#include "mozilla/gfx/2D.h"
#include "mozilla/RefPtr.h"
#include "ClippedImage.h"
#include "Orientation.h"
#include "SVGImageContext.h"
using namespace mozilla;
using namespace mozilla::gfx;
using mozilla::layers::LayerManager;
using mozilla::layers::ImageContainer;
@ -20,7 +24,7 @@ namespace image {
class ClippedImageCachedSurface
{
public:
ClippedImageCachedSurface(mozilla::gfx::DrawTarget* aSurface,
ClippedImageCachedSurface(TemporaryRef<SourceSurface> aSurface,
const nsIntSize& aViewportSize,
const SVGImageContext* aSVGContext,
float aFrame,
@ -49,13 +53,12 @@ public:
mFlags == aFlags;
}
already_AddRefed<gfxASurface> Surface() {
nsRefPtr<gfxASurface> surf = gfxPlatform::GetPlatform()->GetThebesSurfaceForDrawTarget(mSurface);
return surf.forget();
TemporaryRef<SourceSurface> Surface() {
return mSurface;
}
private:
nsRefPtr<mozilla::gfx::DrawTarget> mSurface;
RefPtr<SourceSurface> mSurface;
const nsIntSize mViewportSize;
Maybe<SVGImageContext> mSVGContext;
const float mFrame;
@ -209,14 +212,14 @@ ClippedImage::GetIntrinsicRatio(nsSize* aRatio)
return NS_OK;
}
NS_IMETHODIMP_(already_AddRefed<gfxASurface>)
NS_IMETHODIMP_(TemporaryRef<SourceSurface>)
ClippedImage::GetFrame(uint32_t aWhichFrame,
uint32_t aFlags)
{
return GetFrameInternal(mClip.Size(), nullptr, aWhichFrame, aFlags);
}
already_AddRefed<gfxASurface>
TemporaryRef<SourceSurface>
ClippedImage::GetFrameInternal(const nsIntSize& aViewportSize,
const SVGImageContext* aSVGContext,
uint32_t aWhichFrame,
@ -232,13 +235,11 @@ ClippedImage::GetFrameInternal(const nsIntSize& aViewportSize,
frameToDraw,
aFlags)) {
// Create a surface to draw into.
mozilla::RefPtr<mozilla::gfx::DrawTarget> target;
nsRefPtr<gfxContext> ctx;
RefPtr<DrawTarget> target = gfxPlatform::GetPlatform()->
CreateOffscreenContentDrawTarget(IntSize(mClip.width, mClip.height),
SurfaceFormat::B8G8R8A8);
target = gfxPlatform::GetPlatform()->
CreateOffscreenContentDrawTarget(gfx::IntSize(mClip.width, mClip.height),
gfx::SurfaceFormat::B8G8R8A8);
ctx = new gfxContext(target);
nsRefPtr<gfxContext> ctx = new gfxContext(target);
// Create our callback.
nsRefPtr<gfxDrawingCallback> drawTileCallback =
@ -254,7 +255,7 @@ ClippedImage::GetFrameInternal(const nsIntSize& aViewportSize,
GraphicsFilter::FILTER_FAST);
// Cache the resulting surface.
mCachedSurface = new ClippedImageCachedSurface(target,
mCachedSurface = new ClippedImageCachedSurface(target->Snapshot(),
aViewportSize,
aSVGContext,
frameToDraw,
@ -322,7 +323,7 @@ ClippedImage::Draw(gfxContext* aContext,
if (MustCreateSurface(aContext, aUserSpaceToImageSpace, sourceRect, aSubimage, aFlags)) {
// Create a temporary surface containing a single tile of this image.
// GetFrame will call DrawSingleTile internally.
nsRefPtr<gfxASurface> surface =
RefPtr<SourceSurface> surface =
GetFrameInternal(aViewportSize, aSVGContext, aWhichFrame, aFlags);
NS_ENSURE_TRUE(surface, NS_ERROR_FAILURE);

Просмотреть файл

@ -7,7 +7,9 @@
#define MOZILLA_IMAGELIB_CLIPPEDIMAGE_H_
#include "ImageWrapper.h"
#include "mozilla/gfx/2D.h"
#include "mozilla/Maybe.h"
#include "mozilla/RefPtr.h"
namespace mozilla {
namespace image {
@ -24,6 +26,8 @@ class DrawSingleTileCallback;
*/
class ClippedImage : public ImageWrapper
{
typedef mozilla::gfx::SourceSurface SourceSurface;
public:
NS_DECL_ISUPPORTS
@ -35,8 +39,8 @@ public:
NS_IMETHOD GetHeight(int32_t* aHeight) MOZ_OVERRIDE;
NS_IMETHOD GetIntrinsicSize(nsSize* aSize) MOZ_OVERRIDE;
NS_IMETHOD GetIntrinsicRatio(nsSize* aRatio) MOZ_OVERRIDE;
NS_IMETHOD_(already_AddRefed<gfxASurface>) GetFrame(uint32_t aWhichFrame,
uint32_t aFlags) MOZ_OVERRIDE;
NS_IMETHOD_(mozilla::TemporaryRef<SourceSurface>)
GetFrame(uint32_t aWhichFrame, uint32_t aFlags) MOZ_OVERRIDE;
NS_IMETHOD GetImageContainer(mozilla::layers::LayerManager* aManager,
mozilla::layers::ImageContainer** _retval) MOZ_OVERRIDE;
NS_IMETHOD Draw(gfxContext* aContext,
@ -55,10 +59,11 @@ protected:
ClippedImage(Image* aImage, nsIntRect aClip);
private:
already_AddRefed<gfxASurface> GetFrameInternal(const nsIntSize& aViewportSize,
const SVGImageContext* aSVGContext,
uint32_t aWhichFrame,
uint32_t aFlags);
mozilla::TemporaryRef<SourceSurface>
GetFrameInternal(const nsIntSize& aViewportSize,
const SVGImageContext* aSVGContext,
uint32_t aWhichFrame,
uint32_t aFlags);
bool ShouldClip();
bool MustCreateSurface(gfxContext* aContext,
const gfxMatrix& aTransform,

Просмотреть файл

@ -5,6 +5,8 @@
#include "FrozenImage.h"
using namespace mozilla::gfx;
namespace mozilla {
namespace image {
@ -40,7 +42,7 @@ FrozenImage::GetAnimated(bool* aAnimated)
return rv;
}
NS_IMETHODIMP_(already_AddRefed<gfxASurface>)
NS_IMETHODIMP_(TemporaryRef<SourceSurface>)
FrozenImage::GetFrame(uint32_t aWhichFrame,
uint32_t aFlags)
{

Просмотреть файл

@ -7,6 +7,8 @@
#define MOZILLA_IMAGELIB_FROZENIMAGE_H_
#include "ImageWrapper.h"
#include "mozilla/gfx/2D.h"
#include "mozilla/RefPtr.h"
namespace mozilla {
namespace image {
@ -24,6 +26,8 @@ namespace image {
*/
class FrozenImage : public ImageWrapper
{
typedef mozilla::gfx::SourceSurface SourceSurface;
public:
NS_DECL_ISUPPORTS
@ -34,8 +38,8 @@ public:
virtual void DecrementAnimationConsumers() MOZ_OVERRIDE;
NS_IMETHOD GetAnimated(bool* aAnimated) MOZ_OVERRIDE;
NS_IMETHOD_(already_AddRefed<gfxASurface>) GetFrame(uint32_t aWhichFrame,
uint32_t aFlags) MOZ_OVERRIDE;
NS_IMETHOD_(TemporaryRef<SourceSurface>)
GetFrame(uint32_t aWhichFrame, uint32_t aFlags) MOZ_OVERRIDE;
NS_IMETHOD_(bool) FrameIsOpaque(uint32_t aWhichFrame) MOZ_OVERRIDE;
NS_IMETHOD GetImageContainer(layers::LayerManager* aManager,
layers::ImageContainer** _retval) MOZ_OVERRIDE;

Просмотреть файл

@ -4,10 +4,14 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "ImageWrapper.h"
#include "mozilla/gfx/2D.h"
#include "mozilla/RefPtr.h"
#include "Orientation.h"
#include "mozilla/MemoryReporting.h"
using mozilla::gfx::DataSourceSurface;
using mozilla::gfx::SourceSurface;
using mozilla::layers::LayerManager;
using mozilla::layers::ImageContainer;
@ -196,7 +200,7 @@ ImageWrapper::GetAnimated(bool* aAnimated)
return mInnerImage->GetAnimated(aAnimated);
}
NS_IMETHODIMP_(already_AddRefed<gfxASurface>)
NS_IMETHODIMP_(TemporaryRef<SourceSurface>)
ImageWrapper::GetFrame(uint32_t aWhichFrame,
uint32_t aFlags)
{

Просмотреть файл

@ -11,6 +11,8 @@
#include "OrientedImage.h"
using namespace mozilla::gfx;
using std::swap;
using mozilla::layers::LayerManager;
using mozilla::layers::ImageContainer;
@ -75,7 +77,7 @@ OrientedImage::GetIntrinsicRatio(nsSize* aRatio)
return rv;
}
NS_IMETHODIMP_(already_AddRefed<gfxASurface>)
NS_IMETHODIMP_(TemporaryRef<SourceSurface>)
OrientedImage::GetFrame(uint32_t aWhichFrame,
uint32_t aFlags)
{
@ -87,12 +89,12 @@ OrientedImage::GetFrame(uint32_t aWhichFrame,
// Get the underlying dimensions.
int32_t width, height;
rv = InnerImage()->GetWidth(&width);
NS_ENSURE_SUCCESS(rv, nullptr);
rv = InnerImage()->GetHeight(&height);
NS_ENSURE_SUCCESS(rv, nullptr);
if (mOrientation.SwapsWidthAndHeight()) {
rv = InnerImage()->GetWidth(&height);
rv = NS_FAILED(rv) ? rv : InnerImage()->GetHeight(&width);
} else {
rv = InnerImage()->GetWidth(&width);
rv = NS_FAILED(rv) ? rv : InnerImage()->GetHeight(&height);
swap(width, height);
}
NS_ENSURE_SUCCESS(rv, nullptr);
@ -108,12 +110,12 @@ OrientedImage::GetFrame(uint32_t aWhichFrame,
}
// Create a surface to draw into.
mozilla::RefPtr<mozilla::gfx::DrawTarget> target;
target = gfxPlatform::GetPlatform()->
CreateOffscreenContentDrawTarget(gfx::IntSize(width, height), surfaceFormat);
mozilla::RefPtr<DrawTarget> target =
gfxPlatform::GetPlatform()->
CreateOffscreenContentDrawTarget(IntSize(width, height), surfaceFormat);
// Create our drawable.
nsRefPtr<gfxASurface> innerSurface =
RefPtr<SourceSurface> innerSurface =
InnerImage()->GetFrame(aWhichFrame, aFlags);
NS_ENSURE_TRUE(innerSurface, nullptr);
nsRefPtr<gfxDrawable> drawable =
@ -126,10 +128,7 @@ OrientedImage::GetFrame(uint32_t aWhichFrame,
imageRect, imageRect, imageRect, imageRect,
imageFormat, GraphicsFilter::FILTER_FAST);
nsRefPtr<gfxASurface> surface = gfxPlatform::GetPlatform()->
GetThebesSurfaceForDrawTarget(target);
return surface.forget();
return target->Snapshot();
}
NS_IMETHODIMP

Просмотреть файл

@ -7,6 +7,8 @@
#define MOZILLA_IMAGELIB_ORIENTEDIMAGE_H_
#include "ImageWrapper.h"
#include "mozilla/gfx/2D.h"
#include "mozilla/RefPtr.h"
#include "Orientation.h"
namespace mozilla {
@ -21,6 +23,8 @@ namespace image {
*/
class OrientedImage : public ImageWrapper
{
typedef mozilla::gfx::SourceSurface SourceSurface;
public:
NS_DECL_ISUPPORTS
@ -32,8 +36,8 @@ public:
NS_IMETHOD GetHeight(int32_t* aHeight) MOZ_OVERRIDE;
NS_IMETHOD GetIntrinsicSize(nsSize* aSize) MOZ_OVERRIDE;
NS_IMETHOD GetIntrinsicRatio(nsSize* aRatio) MOZ_OVERRIDE;
NS_IMETHOD_(already_AddRefed<gfxASurface>) GetFrame(uint32_t aWhichFrame,
uint32_t aFlags) MOZ_OVERRIDE;
NS_IMETHOD_(mozilla::TemporaryRef<SourceSurface>)
GetFrame(uint32_t aWhichFrame, uint32_t aFlags) MOZ_OVERRIDE;
NS_IMETHOD GetImageContainer(mozilla::layers::LayerManager* aManager,
mozilla::layers::ImageContainer** _retval) MOZ_OVERRIDE;
NS_IMETHOD Draw(gfxContext* aContext,

Просмотреть файл

@ -3,13 +3,17 @@
* 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 "base/histogram.h"
// Must #include ImageLogging.h before any IPDL-generated files or other files that #include prlog.h
#include "ImageLogging.h"
#include "RasterImage.h"
#include "base/histogram.h"
#include "gfxPlatform.h"
#include "nsComponentManagerUtils.h"
#include "imgDecoderObserver.h"
#include "nsError.h"
#include "Decoder.h"
#include "RasterImage.h"
#include "nsAutoPtr.h"
#include "prenv.h"
#include "prsystem.h"
@ -30,6 +34,8 @@
#include "gfxContext.h"
#include "mozilla/gfx/2D.h"
#include "mozilla/RefPtr.h"
#include "mozilla/MemoryReporting.h"
#include "mozilla/Services.h"
#include "mozilla/Preferences.h"
@ -48,6 +54,7 @@
#endif
using namespace mozilla;
using namespace mozilla::gfx;
using namespace mozilla::image;
using namespace mozilla::layers;
@ -880,9 +887,9 @@ RasterImage::CopyFrame(uint32_t aWhichFrame,
}
//******************************************************************************
/* [noscript] gfxASurface getFrame(in uint32_t aWhichFrame,
* in uint32_t aFlags); */
NS_IMETHODIMP_(already_AddRefed<gfxASurface>)
/* [noscript] SourceSurface getFrame(in uint32_t aWhichFrame,
* in uint32_t aFlags); */
NS_IMETHODIMP_(TemporaryRef<SourceSurface>)
RasterImage::GetFrame(uint32_t aWhichFrame,
uint32_t aFlags)
{
@ -951,7 +958,22 @@ RasterImage::GetFrame(uint32_t aWhichFrame,
framesurf = imgsurf;
}
return framesurf.forget();
RefPtr<SourceSurface> result;
// As far as Moz2D is concerned, SourceSurface contains premultiplied alpha.
// If we're abusing it to contain non-premultiplied alpha then we want to
// avoid having Moz2D do any conversions on it (like copy to another
// surface). Hence why we try to wrap framesurf's data here for
// FLAG_DECODE_NO_PREMULTIPLY_ALPHA.
if ((aFlags & FLAG_WANT_DATA_SURFACE) != 0 ||
(aFlags & FLAG_DECODE_NO_PREMULTIPLY_ALPHA) != 0) {
result = gfxPlatform::GetPlatform()->GetWrappedDataSourceSurface(framesurf);
}
if (!result) {
result = gfxPlatform::GetPlatform()->GetSourceSurfaceForSurface(nullptr,
framesurf);
}
return result.forget();
}
already_AddRefed<layers::Image>
@ -964,8 +986,8 @@ RasterImage::GetCurrentImage()
return nullptr;
}
nsRefPtr<gfxASurface> imageSurface = GetFrame(FRAME_CURRENT, FLAG_NONE);
if (!imageSurface) {
RefPtr<SourceSurface> surface = GetFrame(FRAME_CURRENT, FLAG_NONE);
if (!surface) {
// The OS threw out some or all of our buffer. Start decoding again.
// GetFrame will only return null in the case that the image was
// discarded. We already checked that the image is decoded, so other
@ -982,7 +1004,7 @@ RasterImage::GetCurrentImage()
CairoImage::Data cairoData;
GetWidth(&cairoData.mSize.width);
GetHeight(&cairoData.mSize.height);
cairoData.mSourceSurface = gfxPlatform::GetPlatform()->GetSourceSurfaceForSurface(nullptr, imageSurface);
cairoData.mSourceSurface = surface;
nsRefPtr<layers::Image> image = mImageContainer->CreateImage(ImageFormat::CAIRO_SURFACE);
NS_ASSERTION(image, "Failed to create Image");

Просмотреть файл

@ -110,10 +110,11 @@ private:
* A CachedSurface associates a surface with a key that uniquely identifies that
* surface.
*/
class CachedSurface : public RefCounted<CachedSurface>
class CachedSurface
{
public:
MOZ_DECLARE_REFCOUNTED_TYPENAME(CachedSurface)
NS_INLINE_DECL_REFCOUNTING(CachedSurface)
CachedSurface(DrawTarget* aTarget,
const IntSize aTargetSize,
const Cost aCost,
@ -156,10 +157,11 @@ private:
* destroyed or invalidated. Since this will happen frequently, it makes sense
* to make it cheap by storing the surfaces for each image separately.
*/
class ImageSurfaceCache : public RefCounted<ImageSurfaceCache>
class ImageSurfaceCache
{
public:
MOZ_DECLARE_REFCOUNTED_TYPENAME(ImageSurfaceCache)
NS_INLINE_DECL_REFCOUNTING(ImageSurfaceCache)
typedef nsRefPtrHashtable<nsGenericHashKey<SurfaceKey>, CachedSurface> SurfaceTable;
bool IsEmpty() const { return mSurfaces.Count() == 0; }

Просмотреть файл

@ -649,9 +649,9 @@ VectorImage::FrameIsOpaque(uint32_t aWhichFrame)
}
//******************************************************************************
/* [noscript] gfxASurface getFrame(in uint32_t aWhichFrame,
* in uint32_t aFlags; */
NS_IMETHODIMP_(already_AddRefed<gfxASurface>)
/* [noscript] SourceSurface getFrame(in uint32_t aWhichFrame,
* in uint32_t aFlags; */
NS_IMETHODIMP_(TemporaryRef<SourceSurface>)
VectorImage::GetFrame(uint32_t aWhichFrame,
uint32_t aFlags)
{
@ -674,27 +674,14 @@ VectorImage::GetFrame(uint32_t aWhichFrame,
return nullptr;
}
// Create a surface that we'll ultimately return
// ---------------------------------------------
// Make our surface the size of what will ultimately be drawn to it.
// (either the full image size, or the restricted region)
gfxIntSize surfaceSize(imageIntSize.width, imageIntSize.height);
nsRefPtr<gfxImageSurface> surface =
new gfxImageSurface(surfaceSize, gfxImageFormat::ARGB32);
RefPtr<DrawTarget> drawTarget =
Factory::CreateDrawTargetForData(BackendType::CAIRO,
surface->Data(),
IntSize(imageIntSize.width,
RefPtr<DrawTarget> dt = gfxPlatform::GetPlatform()->
CreateOffscreenContentDrawTarget(IntSize(imageIntSize.width,
imageIntSize.height),
surface->Stride(),
SurfaceFormat::B8G8R8A8);
nsRefPtr<gfxContext> context = new gfxContext(dt);
nsRefPtr<gfxContext> context = new gfxContext(drawTarget);
// Draw to our surface!
// --------------------
nsresult rv = Draw(context, GraphicsFilter::FILTER_NEAREST, gfxMatrix(),
gfxRect(gfxPoint(0,0), gfxIntSize(imageIntSize.width,
imageIntSize.height)),
@ -702,7 +689,7 @@ VectorImage::GetFrame(uint32_t aWhichFrame,
imageIntSize, nullptr, aWhichFrame, aFlags);
NS_ENSURE_SUCCESS(rv, nullptr);
return surface.forget();
return dt->Snapshot();
}
//******************************************************************************

Просмотреть файл

@ -6,6 +6,7 @@
#include "imgTools.h"
#include "gfxUtils.h"
#include "mozilla/gfx/2D.h"
#include "mozilla/RefPtr.h"
#include "nsCOMPtr.h"
@ -97,20 +98,6 @@ NS_IMETHODIMP imgTools::DecodeImage(nsIInputStream* aInStr,
return NS_OK;
}
static TemporaryRef<SourceSurface>
GetFirstImageFrame(imgIContainer *aContainer)
{
nsRefPtr<gfxASurface> frame =
aContainer->GetFrame(imgIContainer::FRAME_FIRST,
imgIContainer::FLAG_SYNC_DECODE);
NS_ENSURE_TRUE(frame, nullptr);
nsRefPtr<gfxImageSurface> imageSurface = frame->CopyToARGB32ImageSurface();
NS_ENSURE_TRUE(imageSurface, nullptr);
return imageSurface->CopyToB8G8R8A8DataSourceSurface();
}
/**
* This takes a DataSourceSurface rather than a SourceSurface because some
* of the callers have a DataSourceSurface and we don't want to call
@ -161,10 +148,22 @@ NS_IMETHODIMP imgTools::EncodeImage(imgIContainer *aContainer,
nsIInputStream **aStream)
{
// Use frame 0 from the image container.
RefPtr<SourceSurface> frame = GetFirstImageFrame(aContainer);
RefPtr<SourceSurface> frame =
aContainer->GetFrame(imgIContainer::FRAME_FIRST,
imgIContainer::FLAG_SYNC_DECODE);
NS_ENSURE_TRUE(frame, NS_ERROR_FAILURE);
RefPtr<DataSourceSurface> dataSurface = frame->GetDataSurface();
RefPtr<DataSourceSurface> dataSurface;
if (frame->GetFormat() == SurfaceFormat::B8G8R8A8) {
dataSurface = frame->GetDataSurface();
} else {
// Convert format to SurfaceFormat::B8G8R8A8
dataSurface = gfxUtils::
CopySurfaceToDataSourceSurfaceWithFormat(frame,
SurfaceFormat::B8G8R8A8);
}
NS_ENSURE_TRUE(dataSurface, NS_ERROR_FAILURE);
return EncodeImageData(dataSurface, aMimeType, aOutputOptions, aStream);
@ -186,7 +185,9 @@ NS_IMETHODIMP imgTools::EncodeScaledImage(imgIContainer *aContainer,
}
// Use frame 0 from the image container.
RefPtr<SourceSurface> frame = GetFirstImageFrame(aContainer);
RefPtr<SourceSurface> frame =
aContainer->GetFrame(imgIContainer::FRAME_FIRST,
imgIContainer::FLAG_SYNC_DECODE);
NS_ENSURE_TRUE(frame, NS_ERROR_FAILURE);
int32_t frameWidth = frame->GetSize().width;
@ -247,7 +248,9 @@ NS_IMETHODIMP imgTools::EncodeCroppedImage(imgIContainer *aContainer,
}
// Use frame 0 from the image container.
RefPtr<SourceSurface> frame = GetFirstImageFrame(aContainer);
RefPtr<SourceSurface> frame =
aContainer->GetFrame(imgIContainer::FRAME_FIRST,
imgIContainer::FLAG_SYNC_DECODE);
NS_ENSURE_TRUE(frame, NS_ERROR_FAILURE);
int32_t frameWidth = frame->GetSize().width;

Просмотреть файл

@ -16,6 +16,7 @@
#include "nsAutoPtr.h"
#include "nsString.h"
#include "nsThreadUtils.h"
#include "mozilla/RefPtr.h"
#define CHROMIUM_LOG(args...) __android_log_print(ANDROID_LOG_INFO, "Gonk", args)

Просмотреть файл

@ -5,7 +5,7 @@
#ifndef mozilla_system_netd_h__
#define mozilla_system_netd_h__
#include "mozilla/RefPtr.h"
#include "nsISupportsImpl.h"
#include "nsAutoPtr.h"
#include "base/message_loop.h"
#include "mozilla/FileUtils.h"
@ -26,11 +26,14 @@ struct NetdCommand
size_t mSize;
};
class NetdConsumer : public mozilla::RefCounted<NetdConsumer>
class NetdConsumer
{
public:
MOZ_DECLARE_REFCOUNTED_TYPENAME(NetdConsumer)
protected:
virtual ~NetdConsumer() { }
public:
NS_INLINE_DECL_REFCOUNTING(NetdConsumer)
virtual void MessageReceived(NetdCommand* aMessage) = 0;
};
@ -39,15 +42,15 @@ class NetdWriteTask : public Task
virtual void Run();
};
class NetdClient : public MessageLoopForIO::LineWatcher,
public RefCounted<NetdClient>
class NetdClient : public MessageLoopForIO::LineWatcher
{
virtual ~NetdClient();
public:
MOZ_DECLARE_REFCOUNTED_TYPENAME(NetdClient)
NS_INLINE_DECL_REFCOUNTING(NetdClient)
typedef std::queue<NetdCommand*> NetdCommandQueue;
NetdClient();
virtual ~NetdClient();
static void Start();
static void SendNetdCommandIOThread(NetdCommand* aMessage);

Просмотреть файл

@ -135,14 +135,16 @@ enum SocketConnectionStatus {
SOCKET_CONNECTED = 3
};
class UnixSocketConsumer : public AtomicRefCounted<UnixSocketConsumer>
class UnixSocketConsumer
{
public:
MOZ_DECLARE_REFCOUNTED_TYPENAME(UnixSocketConsumer)
UnixSocketConsumer();
protected:
virtual ~UnixSocketConsumer();
public:
NS_INLINE_DECL_THREADSAFE_REFCOUNTING(UnixSocketConsumer)
UnixSocketConsumer();
SocketConnectionStatus GetConnectionStatus() const
{
MOZ_ASSERT(NS_IsMainThread());

Просмотреть файл

@ -439,6 +439,8 @@ JavaScriptChild::AnswerIsExtensible(const ObjectId &objId, ReturnStatus *rs, boo
if (!obj)
return false;
JSAutoCompartment comp(cx, obj);
bool extensible;
if (!JS_IsExtensible(cx, obj, &extensible))
return fail(cx, rs);

Просмотреть файл

@ -0,0 +1,13 @@
// |jit-test| ion-eager
function test0(v) {
return (2147483648-Math.max(1.1,-(((2<<(-v|v))-3)|0)))|0;
}
assertEq(test0(1.6), 2147483645);
assertEq(test0(437348122.9), 2147483646);
function test1(v) {
return (2147483648+Math.min(v,0))|0;
}
assertEq(test1(2.1), -2147483648)
assertEq(test1(-0.1), 2147483647)

Просмотреть файл

@ -1,6 +1,9 @@
load(libdir + "asserts.js");
/*
* Call the trap with the handler as the this value, the target as the first
* argument, and the original arguments as the third argument.
*
* Hooks that don't return an object must throw.
*/
var target = function () {};
var handler = {
@ -12,4 +15,4 @@ var handler = {
assertEq(args[1], 3);
}
}
assertEq(new (new Proxy(target, handler))(2, 3), undefined);
assertThrowsInstanceOf(function () {new (new Proxy(target, handler))(2, 3)}, TypeError);

Просмотреть файл

@ -4374,6 +4374,7 @@ ICGetElemNativeCompiler::generateStubCode(MacroAssembler &masm)
// Load function in scratchReg and ensure that it has a jit script.
masm.loadPtr(Address(BaselineStubReg, ICGetElemNativeGetterStub::offsetOfGetter()),
scratchReg);
masm.branchIfFunctionHasNoScript(scratchReg, popR1 ? &failurePopR1 : &failure);
masm.loadPtr(Address(scratchReg, JSFunction::offsetOfNativeOrScript()), scratchReg);
masm.loadBaselineOrIonRaw(scratchReg, scratchReg, SequentialExecution,
popR1 ? &failurePopR1 : &failure);
@ -4805,6 +4806,22 @@ ICGetElem_Arguments::Compiler::generateStubCode(MacroAssembler &masm)
// SetElem_Fallback
//
static bool
SetElemDenseAddHasSameShapes(ICSetElem_DenseAdd *stub, JSObject *obj)
{
size_t numShapes = stub->protoChainDepth() + 1;
for (size_t i = 0; i < numShapes; i++) {
static const size_t MAX_DEPTH = ICSetElem_DenseAdd::MAX_PROTO_CHAIN_DEPTH;
if (obj->lastProperty() != stub->toImplUnchecked<MAX_DEPTH>()->shape(i))
return false;
obj = obj->getProto();
if (!obj && i != numShapes - 1)
return false;
}
return true;
}
static bool
DenseSetElemStubExists(JSContext *cx, ICStub::Kind kind, ICSetElem_Fallback *stub, HandleObject obj)
{
@ -4819,11 +4836,8 @@ DenseSetElemStubExists(JSContext *cx, ICStub::Kind kind, ICSetElem_Fallback *stu
if (kind == ICStub::SetElem_DenseAdd && iter->isSetElem_DenseAdd()) {
ICSetElem_DenseAdd *dense = iter->toSetElem_DenseAdd();
if (obj->lastProperty() == dense->toImplUnchecked<0>()->shape(0) &&
obj->getType(cx) == dense->type())
{
if (obj->getType(cx) == dense->type() && SetElemDenseAddHasSameShapes(dense, obj))
return true;
}
}
}
return false;

Просмотреть файл

@ -3555,6 +3555,7 @@ class ICSetElem_DenseAdd : public ICUpdatedStub
return type_;
}
size_t protoChainDepth() const {
MOZ_ASSERT(extra_ <= MAX_PROTO_CHAIN_DEPTH);
return extra_;
}

Просмотреть файл

@ -3016,9 +3016,6 @@ AutoDebugModeInvalidation::~AutoDebugModeInvalidation()
if (needInvalidation_ == NoNeed)
return;
// Invalidate the stack if any compartments toggled from on->off, because
// we allow scripts to be on stack when turning off debug mode.
bool invalidateStack = needInvalidation_ == ToggledOff;
Zone *zone = zone_ ? zone_ : comp_->zone();
JSRuntime *rt = zone->runtimeFromMainThread();
FreeOp *fop = rt->defaultFreeOp();
@ -3030,31 +3027,24 @@ AutoDebugModeInvalidation::~AutoDebugModeInvalidation()
StopAllOffThreadCompilations(comp);
}
if (invalidateStack) {
jit::MarkActiveBaselineScripts(zone);
jit::MarkActiveBaselineScripts(zone);
for (JitActivationIterator iter(rt); !iter.done(); ++iter) {
JSCompartment *comp = iter.activation()->compartment();
if ((comp_ && comp_ == comp) ||
(zone_ && zone_ == comp->zone() && comp->principals))
{
IonContext ictx(CompileRuntime::get(rt));
AutoFlushCache afc("AutoDebugModeInvalidation", rt->jitRuntime());
IonSpew(IonSpew_Invalidate, "Invalidating frames for debug mode toggle");
InvalidateActivation(fop, iter.jitTop(), true);
}
for (JitActivationIterator iter(rt); !iter.done(); ++iter) {
JSCompartment *comp = iter.activation()->compartment();
if ((comp_ && comp_ == comp) || (zone_ && zone_ == comp->zone())) {
IonContext ictx(CompileRuntime::get(rt));
AutoFlushCache afc("AutoDebugModeInvalidation", rt->jitRuntime());
IonSpew(IonSpew_Invalidate, "Invalidating frames for debug mode toggle");
InvalidateActivation(fop, iter.jitTop(), true);
}
}
for (gc::CellIter i(zone, gc::FINALIZE_SCRIPT); !i.done(); i.next()) {
JSScript *script = i.get<JSScript>();
if ((comp_ && script->compartment() == comp_) ||
(zone_ && script->compartment()->principals))
{
if ((comp_ && script->compartment() == comp_) || zone_) {
FinishInvalidation<SequentialExecution>(fop, script);
FinishInvalidation<ParallelExecution>(fop, script);
FinishDiscardBaselineScript(fop, script);
// script->clearAnalysis();
script->resetUseCount();
} else if (script->hasBaselineScript()) {
script->baselineScript()->resetActive();

Просмотреть файл

@ -437,3 +437,5 @@ MSG_DEF(JSMSG_SETPROTOTYPEOF_FAIL, 382, 1, JSEXN_TYPEERR, "[[SetPrototypeOf
MSG_DEF(JSMSG_INVALID_ARG_TYPE, 383, 3, JSEXN_TYPEERR, "Invalid type: {0} can't be a{1} {2}")
MSG_DEF(JSMSG_TERMINATED, 384, 1, JSEXN_ERR, "Script terminated by timeout at:\n{0}")
MSG_DEF(JSMSG_NO_SUCH_SELF_HOSTED_PROP, 385, 1, JSEXN_ERR, "No such property on self-hosted object: {0}")
MSG_DEF(JSMSG_PROXY_EXTENSIBILITY, 386, 0, JSEXN_TYPEERR, "proxy must report same extensiblitity as target")
MSG_DEF(JSMSG_PROXY_CONSTRUCT_OBJECT, 387, 0, JSEXN_TYPEERR, "proxy [[Construct]] must return an object")

Просмотреть файл

@ -1077,12 +1077,6 @@ ScriptedIndirectProxyHandler::fun_toString(JSContext *cx, HandleObject proxy, un
ScriptedIndirectProxyHandler ScriptedIndirectProxyHandler::singleton;
static JSObject *
GetDirectProxyHandlerObject(JSObject *proxy)
{
return proxy->as<ProxyObject>().extra(0).toObjectOrNull();
}
/* Derived class for all scripted direct proxy handlers. */
class ScriptedDirectProxyHandler : public DirectProxyHandler {
public:
@ -1114,6 +1108,9 @@ class ScriptedDirectProxyHandler : public DirectProxyHandler {
virtual bool iterate(JSContext *cx, HandleObject proxy, unsigned flags,
MutableHandleValue vp) MOZ_OVERRIDE;
/* ES6 Harmony traps */
virtual bool isExtensible(JSContext *cx, HandleObject proxy, bool *extensible) MOZ_OVERRIDE;
/* Spidermonkey extensions. */
virtual bool call(JSContext *cx, HandleObject proxy, const CallArgs &args) MOZ_OVERRIDE;
virtual bool construct(JSContext *cx, HandleObject proxy, const CallArgs &args) MOZ_OVERRIDE;
@ -1365,6 +1362,16 @@ IdToValue(JSContext *cx, HandleId id, MutableHandleValue value)
return true;
}
// Get the [[ProxyHandler]] of a scripted direct proxy.
//
// NB: This *must* stay synched with proxy().
static JSObject *
GetDirectProxyHandlerObject(JSObject *proxy)
{
JS_ASSERT(proxy->as<ProxyObject>().handler() == &ScriptedDirectProxyHandler::singleton);
return proxy->as<ProxyObject>().extra(0).toObjectOrNull();
}
// TrapGetOwnProperty(O, P)
static bool
TrapGetOwnProperty(JSContext *cx, HandleObject proxy, HandleId id, MutableHandleValue rval)
@ -2225,6 +2232,42 @@ ScriptedDirectProxyHandler::keys(JSContext *cx, HandleObject proxy, AutoIdVector
return ArrayToIdVector(cx, proxy, target, trapResult, props, JSITER_OWNONLY, cx->names().keys);
}
// ES6 (5 April, 2014) 9.5.3 Proxy.[[IsExtensible]](P)
bool
ScriptedDirectProxyHandler::isExtensible(JSContext *cx, HandleObject proxy, bool *extensible)
{
RootedObject handler(cx, GetDirectProxyHandlerObject(proxy));
RootedObject target(cx, proxy->as<ProxyObject>().target());
RootedValue trap(cx);
if (!JSObject::getProperty(cx, handler, handler, cx->names().isExtensible, &trap))
return false;
if (trap.isUndefined())
return DirectProxyHandler::isExtensible(cx, proxy, extensible);
Value argv[] = {
ObjectValue(*target)
};
RootedValue trapResult(cx);
if (!Invoke(cx, ObjectValue(*handler), trap, ArrayLength(argv), argv, &trapResult))
return false;
bool booleanTrapResult = ToBoolean(trapResult);
bool targetResult;
if (!JSObject::isExtensible(cx, target, &targetResult))
return false;
if (targetResult != booleanTrapResult) {
JS_ReportErrorNumber(cx, js_GetErrorMessage, nullptr, JSMSG_PROXY_EXTENSIBILITY);
return false;
}
*extensible = booleanTrapResult;
return true;
}
bool
ScriptedDirectProxyHandler::iterate(JSContext *cx, HandleObject proxy, unsigned flags,
MutableHandleValue vp)
@ -2305,7 +2348,13 @@ ScriptedDirectProxyHandler::construct(JSContext *cx, HandleObject proxy, const C
ObjectValue(*argsArray)
};
RootedValue thisValue(cx, ObjectValue(*handler));
return Invoke(cx, thisValue, trap, ArrayLength(constructArgv), constructArgv, args.rval());
if (!Invoke(cx, thisValue, trap, ArrayLength(constructArgv), constructArgv, args.rval()))
return false;
if (!args.rval().isObject()) {
JS_ReportErrorNumber(cx, js_GetErrorMessage, nullptr, JSMSG_PROXY_CONSTRUCT_OBJECT);
return false;
}
return true;
}
ScriptedDirectProxyHandler ScriptedDirectProxyHandler::singleton;

Просмотреть файл

@ -0,0 +1,18 @@
function bogusConstruct(target) { return 4; }
function bogusConstructUndefined(target) { }
var handler = { construct: bogusConstruct }
function callable() {}
var p = new Proxy(callable, handler);
assertThrowsInstanceOf(function () { new p(); }, TypeError,
"[[Construct must throw if an object is not returned.");
handler.construct = bogusConstructUndefined;
assertThrowsInstanceOf(function () { new p(); }, TypeError,
"[[Construct must throw if an object is not returned.");
if (typeof reportCompare === "function")
reportCompare(0,0, "OK");

Просмотреть файл

@ -0,0 +1,94 @@
// Test ES6 Proxy trap compliance for Object.isExtensible() on exotic proxy
// objects.
var unsealed = {};
var sealed = Object.seal({});
var handler = {};
assertEq(Object.isExtensible(unsealed), true);
assertEq(Object.isExtensible(sealed), false);
var targetSealed = new Proxy(sealed, handler);
var targetUnsealed = new Proxy(unsealed, handler);
var handlerCalled = false;
// without traps, forward to the target
// First, make sure we get the obvious answer on a non-exotic target.
assertEq(Object.isExtensible(targetSealed), false, "Must forward to target without hook.");
assertEq(Object.isExtensible(targetUnsealed), true, "Must forward to target without hook.");
// Now, keep everyone honest. What if the target itself is a proxy?
function ensureCalled() { handlerCalled = true; return true; }
var proxyTarget = new Proxy({}, { isExtensible : ensureCalled });
assertEq(Object.isExtensible(new Proxy(proxyTarget, {})), true, "Must forward to target without hook.");
assertEq(handlerCalled, true, "Must forward to target without hook.");
// with traps, makes sure that the handler is called, and that we throw if the
// trap disagrees with the target
function testExtensible(obj, shouldThrow, expectedResult)
{
handlerCalled = false;
if (shouldThrow)
assertThrowsInstanceOf(function () { Object.isExtensible(obj); },
TypeError, "Must throw if handler and target disagree.");
else
assertEq(Object.isExtensible(obj), expectedResult, "Must return the correct value.");
assertEq(handlerCalled, true, "Must call handler trap if present");
}
// What if the trap says it's necessarily sealed?
function fakeSealed() { handlerCalled = true; return false; }
handler.isExtensible = fakeSealed;
testExtensible(targetSealed, false, false);
testExtensible(targetUnsealed, true);
// What if the trap says it's never sealed?
function fakeUnsealed() { handlerCalled = true; return true; }
handler.isExtensible = fakeUnsealed;
testExtensible(targetSealed, true);
testExtensible(targetUnsealed, false, true);
// make sure we are able to prevent further extensions mid-flight and throw if the
// hook tries to lie.
function makeSealedTruth(target) { handlerCalled = true; Object.preventExtensions(target); return false; }
function makeSealedLie(target) { handlerCalled = true; Object.preventExtensions(target); return true; }
handler.isExtensible = makeSealedTruth;
testExtensible(new Proxy({}, handler), false, false);
handler.isExtensible = makeSealedLie;
testExtensible(new Proxy({}, handler), true);
// What if the trap doesn't directly return a boolean?
function falseyNonBool() { handlerCalled = true; return undefined; }
handler.isExtensible = falseyNonBool;
testExtensible(targetSealed, false, false);
testExtensible(targetUnsealed, true);
function truthyNonBool() { handlerCalled = true; return {}; }
handler.isExtensible = truthyNonBool;
testExtensible(targetSealed, true);
testExtensible(targetUnsealed, false, true);
// What if the trap throws?
function ExtensibleError() { }
ExtensibleError.prototype = new Error();
ExtensibleError.prototype.constructor = ExtensibleError;
function throwFromTrap() { throw new ExtensibleError(); }
handler.isExtensible = throwFromTrap;
// exercise some other code paths and make sure that they invoke the trap and
// can handle the ensuing error.
assertThrowsInstanceOf(function () { Object.isExtensible(targetSealed); },
ExtensibleError, "Must throw if the trap does.");
assertThrowsInstanceOf(function () { Object.isFrozen(targetSealed); },
ExtensibleError, "Must throw if the trap does.");
assertThrowsInstanceOf(function () { Object.isSealed(targetSealed); },
ExtensibleError, "Must throw if the trap does.");
// What if the trap likes to re-ask old questions?
function recurse() { return Object.isExtensible(targetSealed); }
handler.isExtensible = recurse;
assertThrowsInstanceOf(function () { Object.isExtensible(targetSealed); },
InternalError, "Should allow and detect infinite recurison.");
reportCompare(0, 0, "OK");

Просмотреть файл

@ -103,6 +103,7 @@
macro(int8, int8, "int8") \
macro(int16, int16, "int16") \
macro(int32, int32, "int32") \
macro(isExtensible, isExtensible, "isExtensible") \
macro(iterator, iterator, "iterator") \
macro(iteratorIntrinsic, iteratorIntrinsic, "__iterator__") \
macro(join, join, "join") \

Просмотреть файл

@ -286,7 +286,7 @@
macro(JSOP_UNUSED52, 52, "unused52", NULL, 1, 0, 0, JOF_BYTE) \
\
macro(JSOP_GETPROP, 53, "getprop", NULL, 5, 1, 1, JOF_ATOM|JOF_PROP|JOF_TYPESET|JOF_TMPSLOT3) \
macro(JSOP_SETPROP, 54, "setprop", NULL, 5, 2, 1, JOF_ATOM|JOF_PROP|JOF_SET|JOF_DETECTING|JOF_TMPSLOT) \
macro(JSOP_SETPROP, 54, "setprop", NULL, 5, 2, 1, JOF_ATOM|JOF_PROP|JOF_SET|JOF_DETECTING) \
macro(JSOP_GETELEM, 55, "getelem", NULL, 1, 2, 1, JOF_BYTE |JOF_ELEM|JOF_TYPESET|JOF_LEFTASSOC) \
macro(JSOP_SETELEM, 56, "setelem", NULL, 1, 3, 1, JOF_BYTE |JOF_ELEM|JOF_SET|JOF_DETECTING) \
macro(JSOP_UNUSED57, 57, "unused57", NULL, 1, 0, 0, JOF_BYTE) \

Просмотреть файл

@ -46,9 +46,10 @@ enum LayerState {
LAYER_SVG_EFFECTS
};
class RefCountedRegion : public RefCounted<RefCountedRegion> {
class RefCountedRegion {
public:
MOZ_DECLARE_REFCOUNTED_TYPENAME(RefCountedRegion)
NS_INLINE_DECL_REFCOUNTING(RefCountedRegion)
RefCountedRegion() : mIsInfinite(false) {}
nsRegion mRegion;
bool mIsInfinite;

Некоторые файлы не были показаны из-за слишком большого количества измененных файлов Показать больше