Merge backout

This commit is contained in:
Ehsan Akhgari 2012-10-02 23:16:47 -04:00
commit e0a9d98ab1
47 changed files with 785 additions and 280 deletions

View File

@ -88,55 +88,6 @@
fun:_ZN13CrashReporter14SetupExtraDataEP7nsIFileRK19nsACString_internal
...
}
# Suppressing the suppression(s) to get Valgrind stacks with line numbers
#{
# Bug 793601
# Memcheck:Leak
# fun:malloc
# fun:_ZN2js15ArgumentsObject6createEP9JSContextPNS_10StackFrameE
# ...
#}
#{
# Bug 793602
# Memcheck:Leak
# fun:malloc
# fun:moz_xmalloc
# fun:_Z22NS_NewComputedDOMStylePN7mozilla3dom7ElementERK18nsAString_internalP12nsIPresShell
# fun:_ZN14nsGlobalWindow16GetComputedStyleEP13nsIDOMElementRK18nsAString_internalPP25nsIDOMCSSStyleDeclaration
# ...
#}
#{
# Bug 793603
# Memcheck:Leak
# fun:malloc
# fun:moz_xmalloc
# fun:_ZN18nsDeflateConverter15OnDataAvailableEP10nsIRequestP11nsISupportsP14nsIInputStreammj
# ...
#}
#{
# Bug 793605
# Memcheck:Leak
# fun:malloc
# fun:moz_xmalloc
# fun:_Z30nsStringInputStreamConstructorP11nsISupportsRK4nsIDPPv
# ...
#}
#{
# Bug 793606
# Memcheck:Leak
# fun:malloc
# fun:moz_xmalloc
# fun:_ZL27nsXMLHttpRequestConstructorP11nsISupportsRK4nsIDPPv
# ...
#}
#{
# Bug 793607
# Memcheck:Leak
# fun:malloc
# fun:moz_xmalloc
# fun:_ZN11nsZipWriter14AddEntryStreamERK19nsACString_internalliP14nsIInputStreambj
# ...
#}
{
Bug 793608
Memcheck:Leak

View File

@ -1183,9 +1183,9 @@ nsImageLoadingContent::UnbindFromTree(bool aDeep, bool aNullParent)
pusher.PushNull();
if (mCurrentRequestFlags & REQUEST_SHOULD_BE_TRACKED)
doc->RemoveImage(mCurrentRequest, nsIDocument::REQUEST_DISCARD);
doc->RemoveImage(mCurrentRequest);
if (mPendingRequestFlags & REQUEST_SHOULD_BE_TRACKED)
doc->RemoveImage(mPendingRequest, nsIDocument::REQUEST_DISCARD);
doc->RemoveImage(mPendingRequest);
}
nsresult

View File

@ -16,6 +16,7 @@
#include "mozilla/dom/bluetooth/BluetoothTypes.h"
#include "mozilla/Services.h"
#include "nsContentUtils.h"
#include "nsIAudioManager.h"
#include "nsIObserverService.h"
#include "nsIRadioInterfaceLayer.h"
#include "nsISystemMessagesInternal.h"
@ -26,6 +27,7 @@
#include <unistd.h> /* usleep() */
#define MOZSETTINGS_CHANGED_ID "mozsettings-changed"
#define BLUETOOTH_SCO_STATUS_CHANGED "bluetooth-sco-status-changed"
#define AUDIO_VOLUME_MASTER "audio.volume.master"
USING_BLUETOOTH_NAMESPACE
@ -82,14 +84,29 @@ CloseScoSocket()
{
MOZ_ASSERT(NS_IsMainThread());
nsCOMPtr<nsIAudioManager> am = do_GetService("@mozilla.org/telephony/audiomanager;1");
if (!am) {
NS_WARNING("Failed to get AudioManager Service!");
return;
}
am->SetForceForUse(am->USE_COMMUNICATION, am->FORCE_NONE);
BluetoothScoManager* sco = BluetoothScoManager::Get();
if (!sco) {
NS_WARNING("BluetoothScoManager is not available!");
return;
}
if (sco->GetConnected())
if (sco->GetConnected()) {
nsCOMPtr<nsIObserverService> obs = do_GetService("@mozilla.org/observer-service;1");
if (obs) {
if (NS_FAILED(obs->NotifyObservers(nullptr, BLUETOOTH_SCO_STATUS_CHANGED, nullptr))) {
NS_WARNING("Failed to notify bluetooth-sco-status-changed observsers!");
return;
}
}
sco->Disconnect();
}
}
BluetoothHfpManager::BluetoothHfpManager()

View File

@ -190,6 +190,9 @@ public:
MOZ_ASSERT(NS_IsMainThread());
nsCOMPtr<nsIAudioManager> am = do_GetService("@mozilla.org/telephony/audiomanager;1");
if (!am) {
NS_WARNING("Failed to get AudioManager service!");
}
am->SetForceForUse(am->USE_COMMUNICATION, am->FORCE_BT_SCO);
nsCOMPtr<nsIObserverService> obs = do_GetService("@mozilla.org/observer-service;1");

View File

@ -9,7 +9,6 @@
#include <android/log.h>
#include "AndroidBridge.h"
#include "nsNPAPIPluginInstance.h"
#include "nsIPluginInstanceOwner.h"
#include "nsPluginInstanceOwner.h"
#include "nsWindow.h"
#include "mozilla/dom/ScreenOrientation.h"
@ -22,12 +21,6 @@ using namespace mozilla;
using namespace mozilla::widget;
using namespace mozilla::dom;
static nsresult GetOwner(NPP instance, nsPluginInstanceOwner** owner) {
nsNPAPIPluginInstance* pinst = static_cast<nsNPAPIPluginInstance*>(instance->ndata);
return pinst->GetOwner((nsIPluginInstanceOwner**)owner);
}
void
anp_window_setVisibleRects(NPP instance, const ANPRectI rects[], int32_t count)
{
@ -64,8 +57,10 @@ anp_window_showKeyboard(NPP instance, bool value)
void
anp_window_requestFullScreen(NPP instance)
{
nsRefPtr<nsPluginInstanceOwner> owner;
if (NS_FAILED(GetOwner(instance, getter_AddRefs(owner)))) {
nsNPAPIPluginInstance* inst = static_cast<nsNPAPIPluginInstance*>(instance->ndata);
nsRefPtr<nsPluginInstanceOwner> owner = inst->GetOwner();
if (!owner) {
return;
}
@ -75,8 +70,10 @@ anp_window_requestFullScreen(NPP instance)
void
anp_window_exitFullScreen(NPP instance)
{
nsRefPtr<nsPluginInstanceOwner> owner;
if (NS_FAILED(GetOwner(instance, getter_AddRefs(owner)))) {
nsNPAPIPluginInstance* inst = static_cast<nsNPAPIPluginInstance*>(instance->ndata);
nsRefPtr<nsPluginInstanceOwner> owner = inst->GetOwner();
if (!owner) {
return;
}

View File

@ -23,7 +23,7 @@
#include "nsIDOMElement.h"
#include "prmem.h"
#include "nsIContent.h"
#include "nsIPluginInstanceOwner.h"
#include "nsPluginInstanceOwner.h"
#include "mozilla/HashFunctions.h"
#define NPRUNTIME_JSCLASS_NAME "NPObject JS wrapper class"
@ -322,8 +322,7 @@ GetJSContext(NPP npp)
nsNPAPIPluginInstance *inst = (nsNPAPIPluginInstance *)npp->ndata;
NS_ENSURE_TRUE(inst, nullptr);
nsCOMPtr<nsIPluginInstanceOwner> owner;
inst->GetOwner(getter_AddRefs(owner));
nsRefPtr<nsPluginInstanceOwner> owner = inst->GetOwner();
NS_ENSURE_TRUE(owner, nullptr);
nsCOMPtr<nsIDocument> doc;

View File

@ -23,6 +23,7 @@
#include "nsIServiceManager.h"
#include "nsThreadUtils.h"
#include "mozilla/Preferences.h"
#include "nsPluginInstanceOwner.h"
#include "nsPluginsDir.h"
#include "nsPluginSafety.h"
@ -624,8 +625,7 @@ GetDocumentFromNPP(NPP npp)
PluginDestructionGuard guard(inst);
nsCOMPtr<nsIPluginInstanceOwner> owner;
inst->GetOwner(getter_AddRefs(owner));
nsRefPtr<nsPluginInstanceOwner> owner = inst->GetOwner();
NS_ENSURE_TRUE(owner, nullptr);
nsCOMPtr<nsIDocument> doc;
@ -1941,8 +1941,7 @@ _getvalue(NPP npp, NPNVariable variable, void *result)
nsNPAPIPluginInstance *inst = (nsNPAPIPluginInstance *) npp->ndata;
nsCOMPtr<nsIPluginInstanceOwner> owner;
inst->GetOwner(getter_AddRefs(owner));
nsRefPtr<nsPluginInstanceOwner> owner = inst->GetOwner();
NS_ENSURE_TRUE(owner, NPERR_NO_ERROR);
if (NS_SUCCEEDED(owner->GetNetscapeWindow(result))) {

View File

@ -20,6 +20,7 @@
#include "nsPluginSafety.h"
#include "nsPluginLogging.h"
#include "nsContentUtils.h"
#include "nsPluginInstanceOwner.h"
#include "nsIDocument.h"
#include "nsIScriptGlobalObject.h"
@ -221,7 +222,7 @@ nsNPAPIPluginInstance::StopTime()
return mStopTime;
}
nsresult nsNPAPIPluginInstance::Initialize(nsNPAPIPlugin *aPlugin, nsIPluginInstanceOwner* aOwner, const char* aMIMEType)
nsresult nsNPAPIPluginInstance::Initialize(nsNPAPIPlugin *aPlugin, nsPluginInstanceOwner* aOwner, const char* aMIMEType)
{
PLUGIN_LOG(PLUGIN_LOG_NORMAL, ("nsNPAPIPluginInstance::Initialize this=%p\n",this));
@ -320,13 +321,13 @@ nsresult nsNPAPIPluginInstance::Stop()
already_AddRefed<nsPIDOMWindow>
nsNPAPIPluginInstance::GetDOMWindow()
{
nsCOMPtr<nsIPluginInstanceOwner> owner;
GetOwner(getter_AddRefs(owner));
if (!owner)
if (!mOwner)
return nullptr;
nsRefPtr<nsPluginInstanceOwner> deathGrip(mOwner);
nsCOMPtr<nsIDocument> doc;
owner->GetDocument(getter_AddRefs(doc));
mOwner->GetDocument(getter_AddRefs(doc));
if (!doc)
return nullptr;
@ -339,39 +340,33 @@ nsNPAPIPluginInstance::GetDOMWindow()
nsresult
nsNPAPIPluginInstance::GetTagType(nsPluginTagType *result)
{
if (mOwner) {
nsCOMPtr<nsIPluginTagInfo> tinfo(do_QueryInterface(mOwner));
if (tinfo)
return tinfo->GetTagType(result);
if (!mOwner) {
return NS_ERROR_FAILURE;
}
return NS_ERROR_FAILURE;
return mOwner->GetTagType(result);
}
nsresult
nsNPAPIPluginInstance::GetAttributes(uint16_t& n, const char*const*& names,
const char*const*& values)
{
if (mOwner) {
nsCOMPtr<nsIPluginTagInfo> tinfo(do_QueryInterface(mOwner));
if (tinfo)
return tinfo->GetAttributes(n, names, values);
if (!mOwner) {
return NS_ERROR_FAILURE;
}
return NS_ERROR_FAILURE;
return mOwner->GetAttributes(n, names, values);
}
nsresult
nsNPAPIPluginInstance::GetParameters(uint16_t& n, const char*const*& names,
const char*const*& values)
{
if (mOwner) {
nsCOMPtr<nsIPluginTagInfo> tinfo(do_QueryInterface(mOwner));
if (tinfo)
return tinfo->GetParameters(n, names, values);
if (!mOwner) {
return NS_ERROR_FAILURE;
}
return NS_ERROR_FAILURE;
return mOwner->GetParameters(n, names, values);
}
nsresult
@ -791,14 +786,12 @@ void nsNPAPIPluginInstance::RedrawPlugin()
void nsNPAPIPluginInstance::SetEventModel(NPEventModel aModel)
{
// the event model needs to be set for the object frame immediately
nsCOMPtr<nsIPluginInstanceOwner> owner;
GetOwner(getter_AddRefs(owner));
if (!owner) {
if (!mOwner) {
NS_WARNING("Trying to set event model without a plugin instance owner!");
return;
}
owner->SetEventModel(aModel);
mOwner->SetEventModel(aModel);
}
#endif
@ -1519,11 +1512,7 @@ nsNPAPIPluginInstance::GetDOMElement(nsIDOMElement* *result)
return NS_ERROR_FAILURE;
}
nsCOMPtr<nsIPluginTagInfo> tinfo(do_QueryInterface(mOwner));
if (tinfo)
return tinfo->GetDOMElement(result);
return NS_ERROR_FAILURE;
return mOwner->GetDOMElement(result);
}
nsresult
@ -1532,12 +1521,10 @@ nsNPAPIPluginInstance::InvalidateRect(NPRect *invalidRect)
if (RUNNING != mRunning)
return NS_OK;
nsCOMPtr<nsIPluginInstanceOwner> owner;
GetOwner(getter_AddRefs(owner));
if (!owner)
if (!mOwner)
return NS_ERROR_FAILURE;
return owner->InvalidateRect(invalidRect);
return mOwner->InvalidateRect(invalidRect);
}
nsresult
@ -1546,12 +1533,10 @@ nsNPAPIPluginInstance::InvalidateRegion(NPRegion invalidRegion)
if (RUNNING != mRunning)
return NS_OK;
nsCOMPtr<nsIPluginInstanceOwner> owner;
GetOwner(getter_AddRefs(owner));
if (!owner)
if (!mOwner)
return NS_ERROR_FAILURE;
return owner->InvalidateRegion(invalidRegion);
return mOwner->InvalidateRegion(invalidRegion);
}
nsresult
@ -1568,15 +1553,15 @@ nsNPAPIPluginInstance::GetMIMEType(const char* *result)
nsresult
nsNPAPIPluginInstance::GetJSContext(JSContext* *outContext)
{
nsCOMPtr<nsIPluginInstanceOwner> owner;
GetOwner(getter_AddRefs(owner));
if (!owner)
if (!mOwner)
return NS_ERROR_FAILURE;
nsRefPtr<nsPluginInstanceOwner> deathGrip(mOwner);
*outContext = NULL;
nsCOMPtr<nsIDocument> document;
nsresult rv = owner->GetDocument(getter_AddRefs(document));
nsresult rv = mOwner->GetDocument(getter_AddRefs(document));
if (NS_SUCCEEDED(rv) && document) {
nsIScriptGlobalObject *global = document->GetScriptGlobalObject();
@ -1593,20 +1578,16 @@ nsNPAPIPluginInstance::GetJSContext(JSContext* *outContext)
return rv;
}
nsresult
nsNPAPIPluginInstance::GetOwner(nsIPluginInstanceOwner **aOwner)
nsPluginInstanceOwner*
nsNPAPIPluginInstance::GetOwner()
{
NS_ENSURE_ARG_POINTER(aOwner);
*aOwner = mOwner;
NS_IF_ADDREF(mOwner);
return (mOwner ? NS_OK : NS_ERROR_FAILURE);
return mOwner;
}
nsresult
nsNPAPIPluginInstance::SetOwner(nsIPluginInstanceOwner *aOwner)
void
nsNPAPIPluginInstance::SetOwner(nsPluginInstanceOwner *aOwner)
{
mOwner = aOwner;
return NS_OK;
}
nsresult
@ -1618,14 +1599,6 @@ nsNPAPIPluginInstance::ShowStatus(const char* message)
return NS_ERROR_FAILURE;
}
nsresult
nsNPAPIPluginInstance::InvalidateOwner()
{
mOwner = nullptr;
return NS_OK;
}
nsresult
nsNPAPIPluginInstance::AsyncSetWindow(NPWindow& window)
{

View File

@ -34,6 +34,7 @@ class nsPluginStreamListenerPeer; // browser-initiated stream class
class nsNPAPIPluginStreamListener; // plugin-initiated stream class
class nsIPluginInstanceOwner;
class nsIOutputStream;
class nsPluginInstanceOwner;
#if defined(OS_WIN)
const NPDrawingModel kDefaultDrawingModel = NPDrawingModelSyncWin;
@ -67,7 +68,7 @@ private:
public:
NS_DECL_ISUPPORTS
nsresult Initialize(nsNPAPIPlugin *aPlugin, nsIPluginInstanceOwner* aOwner, const char* aMIMEType);
nsresult Initialize(nsNPAPIPlugin *aPlugin, nsPluginInstanceOwner* aOwner, const char* aMIMEType);
nsresult Start();
nsresult Stop();
nsresult SetWindow(NPWindow* window);
@ -97,10 +98,9 @@ public:
nsresult InvalidateRegion(NPRegion invalidRegion);
nsresult GetMIMEType(const char* *result);
nsresult GetJSContext(JSContext* *outContext);
nsresult GetOwner(nsIPluginInstanceOwner **aOwner);
nsresult SetOwner(nsIPluginInstanceOwner *aOwner);
nsPluginInstanceOwner* GetOwner();
void SetOwner(nsPluginInstanceOwner *aOwner);
nsresult ShowStatus(const char* message);
nsresult InvalidateOwner();
#if defined(MOZ_WIDGET_QT) && (MOZ_PLATFORM_MAEMO == 6)
nsresult HandleGUIEvent(const nsGUIEvent& anEvent, bool* handled);
#endif
@ -335,7 +335,7 @@ private:
// Weak pointer to the owner. The owner nulls this out (by calling
// InvalidateOwner()) when it's no longer our owner.
nsIPluginInstanceOwner *mOwner;
nsPluginInstanceOwner *mOwner;
nsTArray<nsNPAPITimer*> mTimers;

View File

@ -611,8 +611,7 @@ nsresult nsPluginHost::GetURLWithHeaders(nsNPAPIPluginInstance* pluginInst,
return rv;
if (target) {
nsCOMPtr<nsIPluginInstanceOwner> owner;
rv = pluginInst->GetOwner(getter_AddRefs(owner));
nsRefPtr<nsPluginInstanceOwner> owner = pluginInst->GetOwner();
if (owner) {
if ((0 == PL_strcmp(target, "newwindow")) ||
(0 == PL_strcmp(target, "_new")))
@ -700,8 +699,7 @@ nsresult nsPluginHost::PostURL(nsISupports* pluginInst,
}
if (target) {
nsCOMPtr<nsIPluginInstanceOwner> owner;
rv = instance->GetOwner(getter_AddRefs(owner));
nsRefPtr<nsPluginInstanceOwner> owner = instance->GetOwner();
if (owner) {
if ((0 == PL_strcmp(target, "newwindow")) ||
(0 == PL_strcmp(target, "_new"))) {
@ -1158,7 +1156,7 @@ nsPluginHost::TagForPlugin(nsNPAPIPlugin* aPlugin)
nsresult nsPluginHost::SetUpPluginInstance(const char *aMimeType,
nsIURI *aURL,
nsIPluginInstanceOwner *aOwner)
nsPluginInstanceOwner *aOwner)
{
NS_ENSURE_ARG_POINTER(aOwner);
@ -1192,7 +1190,7 @@ nsresult nsPluginHost::SetUpPluginInstance(const char *aMimeType,
nsresult
nsPluginHost::TrySetUpPluginInstance(const char *aMimeType,
nsIURI *aURL,
nsIPluginInstanceOwner *aOwner)
nsPluginInstanceOwner *aOwner)
{
#ifdef PLUGIN_LOGGING
nsAutoCString urlSpec;
@ -3070,8 +3068,7 @@ nsresult nsPluginHost::NewPluginURLStream(const nsString& aURL,
// get the full URL of the document that the plugin is embedded
// in to create an absolute url in case aURL is relative
nsCOMPtr<nsIDocument> doc;
nsCOMPtr<nsIPluginInstanceOwner> owner;
aInstance->GetOwner(getter_AddRefs(owner));
nsRefPtr<nsPluginInstanceOwner> owner = aInstance->GetOwner();
if (owner) {
rv = owner->GetDocument(getter_AddRefs(doc));
if (NS_SUCCEEDED(rv) && doc) {
@ -3087,10 +3084,9 @@ nsresult nsPluginHost::NewPluginURLStream(const nsString& aURL,
if (NS_FAILED(rv))
return rv;
nsCOMPtr<nsIPluginTagInfo> pti = do_QueryInterface(owner);
nsCOMPtr<nsIDOMElement> element;
if (pti)
pti->GetDOMElement(getter_AddRefs(element));
if (owner)
owner->GetDOMElement(getter_AddRefs(element));
int16_t shouldLoad = nsIContentPolicy::ACCEPT;
rv = NS_CheckContentLoadPolicy(nsIContentPolicy::TYPE_OBJECT_SUBREQUEST,
@ -3194,8 +3190,7 @@ nsPluginHost::DoURLLoadSecurityCheck(nsNPAPIPluginInstance *aInstance,
return NS_OK;
// get the URL of the document that loaded the plugin
nsCOMPtr<nsIPluginInstanceOwner> owner;
aInstance->GetOwner(getter_AddRefs(owner));
nsRefPtr<nsPluginInstanceOwner> owner = aInstance->GetOwner();
if (!owner)
return NS_ERROR_FAILURE;
@ -3443,8 +3438,7 @@ nsPluginHost::HandleBadPlugin(PRLibrary* aLibrary, nsNPAPIPluginInstance *aInsta
if (mDontShowBadPluginMessage)
return NS_OK;
nsCOMPtr<nsIPluginInstanceOwner> owner;
aInstance->GetOwner(getter_AddRefs(owner));
nsRefPtr<nsPluginInstanceOwner> owner = aInstance->GetOwner();
nsCOMPtr<nsIPrompt> prompt;
GetPrompt(owner, getter_AddRefs(prompt));
@ -4076,8 +4070,7 @@ nsPluginHost::DestroyRunningInstances(nsISupportsArray* aReloadDocs, nsPluginTag
// removing duplicates. These will be reframed (embedded) or reloaded (full-page) later
// to kickstart our instances.
if (aReloadDocs) {
nsCOMPtr<nsIPluginInstanceOwner> owner;
instance->GetOwner(getter_AddRefs(owner));
nsRefPtr<nsPluginInstanceOwner> owner = instance->GetOwner();
if (owner) {
nsCOMPtr<nsIDocument> doc;
owner->GetDocument(getter_AddRefs(doc));

View File

@ -82,7 +82,7 @@ public:
nsresult SetUpPluginInstance(const char *aMimeType,
nsIURI *aURL,
nsIPluginInstanceOwner *aOwner);
nsPluginInstanceOwner *aOwner);
nsresult IsPluginEnabledForType(const char* aMimeType);
nsresult IsPluginEnabledForExtension(const char* aExtension, const char* &aMimeType);
bool IsPluginClickToPlayForType(const char *aMimeType);
@ -214,7 +214,7 @@ public:
private:
nsresult
TrySetUpPluginInstance(const char *aMimeType, nsIURI *aURL, nsIPluginInstanceOwner *aOwner);
TrySetUpPluginInstance(const char *aMimeType, nsIURI *aURL, nsPluginInstanceOwner *aOwner);
nsresult
NewEmbeddedPluginStream(nsIURI* aURL, nsObjectLoadingContent *aContent, nsNPAPIPluginInstance* aInstance);

View File

@ -22,9 +22,6 @@
#include "gfxXlibSurface.h"
/* X headers suck */
enum { XKeyPress = KeyPress };
#ifdef KeyPress
#undef KeyPress
#endif
#include "mozilla/X11Util.h"
using mozilla::DefaultXDisplay;
#endif
@ -395,7 +392,7 @@ nsPluginInstanceOwner::~nsPluginInstanceOwner()
#endif
if (mInstance) {
mInstance->InvalidateOwner();
mInstance->SetOwner(nullptr);
}
}
@ -412,10 +409,10 @@ nsPluginInstanceOwner::SetInstance(nsNPAPIPluginInstance *aInstance)
NS_ASSERTION(!mInstance || !aInstance, "mInstance should only be set or unset!");
// If we're going to null out mInstance after use, be sure to call
// mInstance->InvalidateOwner() here, since it now won't be called
// mInstance->SetOwner(nullptr) here, since it now won't be called
// from our destructor. This fixes bug 613376.
if (mInstance && !aInstance) {
mInstance->InvalidateOwner();
mInstance->SetOwner(nullptr);
#ifdef MOZ_WIDGET_ANDROID
RemovePluginView();
@ -1939,7 +1936,7 @@ nsresult nsPluginInstanceOwner::Text(nsIDOMEvent* aTextEvent)
}
#endif
nsresult nsPluginInstanceOwner::KeyPress(nsIDOMEvent* aKeyEvent)
nsresult nsPluginInstanceOwner::ProcessKeyPress(nsIDOMEvent* aKeyEvent)
{
#ifdef XP_MACOSX
#ifndef NP_NO_CARBON
@ -2009,7 +2006,7 @@ nsresult nsPluginInstanceOwner::DispatchKeyToPlugin(nsIDOMEvent* aKeyEvent)
}
nsresult
nsPluginInstanceOwner::MouseDown(nsIDOMEvent* aMouseEvent)
nsPluginInstanceOwner::ProcessMouseDown(nsIDOMEvent* aMouseEvent)
{
#if !defined(XP_MACOSX)
if (!mPluginWindow || (mPluginWindow->type == NPWindowTypeWindow))
@ -2076,7 +2073,7 @@ nsPluginInstanceOwner::HandleEvent(nsIDOMEvent* aEvent)
return DispatchFocusToPlugin(aEvent);
}
if (eventType.EqualsLiteral("mousedown")) {
return MouseDown(aEvent);
return ProcessMouseDown(aEvent);
}
if (eventType.EqualsLiteral("mouseup")) {
// Don't send a mouse-up event to the plugin if it isn't focused. This can
@ -2101,7 +2098,7 @@ nsPluginInstanceOwner::HandleEvent(nsIDOMEvent* aEvent)
return DispatchKeyToPlugin(aEvent);
}
if (eventType.EqualsLiteral("keypress")) {
return KeyPress(aEvent);
return ProcessKeyPress(aEvent);
}
#if defined(MOZ_WIDGET_QT) && (MOZ_PLATFORM_MAEMO == 6)
if (eventType.EqualsLiteral("text")) {

View File

@ -20,11 +20,6 @@
#include "nsWeakReference.h"
#include "gfxRect.h"
// X.h defines KeyPress
#ifdef KeyPress
#undef KeyPress
#endif
#ifdef XP_MACOSX
#include "mozilla/gfx/QuartzSupport.h"
#include <ApplicationServices/ApplicationServices.h>
@ -51,11 +46,6 @@ class gfxXlibSurface;
#include <os2.h>
#endif
// X.h defines KeyPress
#ifdef KeyPress
#undef KeyPress
#endif
class nsPluginInstanceOwner : public nsIPluginInstanceOwner,
public nsIPluginTagInfo,
public nsIDOMEventListener,
@ -93,8 +83,8 @@ public:
// nsIDOMEventListener interfaces
NS_DECL_NSIDOMEVENTLISTENER
nsresult MouseDown(nsIDOMEvent* aKeyEvent);
nsresult KeyPress(nsIDOMEvent* aKeyEvent);
nsresult ProcessMouseDown(nsIDOMEvent* aKeyEvent);
nsresult ProcessKeyPress(nsIDOMEvent* aKeyEvent);
#if defined(MOZ_WIDGET_QT) && (MOZ_PLATFORM_MAEMO == 6)
nsresult Text(nsIDOMEvent* aTextEvent);
#endif

View File

@ -794,8 +794,7 @@ nsresult nsPluginStreamListenerPeer::ServeStreamAsFile(nsIRequest *request,
// mPluginInstance->Stop calls mPStreamListener->CleanUpStream(), so stream will be properly clean up
mPluginInstance->Stop();
mPluginInstance->Start();
nsCOMPtr<nsIPluginInstanceOwner> owner;
mPluginInstance->GetOwner(getter_AddRefs(owner));
nsRefPtr<nsPluginInstanceOwner> owner = mPluginInstance->GetOwner();
if (owner) {
NPWindow* window = nullptr;
owner->GetWindow(window);
@ -1252,8 +1251,7 @@ nsPluginStreamListenerPeer::GetInterfaceGlobal(const nsIID& aIID, void** result)
return NS_ERROR_FAILURE;
}
nsCOMPtr<nsIPluginInstanceOwner> owner;
mPluginInstance->GetOwner(getter_AddRefs(owner));
nsRefPtr<nsPluginInstanceOwner> owner = mPluginInstance->GetOwner();
if (owner) {
nsCOMPtr<nsIDocument> doc;
nsresult rv = owner->GetDocument(getter_AddRefs(doc));

View File

@ -36,7 +36,6 @@ using namespace mozilla;
// A bitwise variable for recording what kind of headset is attached.
static int sHeadsetState;
static const char* sDeviceAddress;
static int kBtSampleRate = 8000;
static bool
@ -80,10 +79,6 @@ InternalSetAudioRoutesICS(SwitchState aState)
AudioSystem::setDeviceConnectionState(AUDIO_DEVICE_OUT_WIRED_HEADPHONE,
AUDIO_POLICY_DEVICE_STATE_AVAILABLE, "");
sHeadsetState |= AUDIO_DEVICE_OUT_WIRED_HEADPHONE;
} else if (aState == SWITCH_STATE_BLUETOOTH_SCO) {
AudioSystem::setDeviceConnectionState(AUDIO_DEVICE_OUT_BLUETOOTH_SCO_HEADSET,
AUDIO_POLICY_DEVICE_STATE_AVAILABLE, sDeviceAddress);
sHeadsetState |= AUDIO_DEVICE_OUT_BLUETOOTH_SCO_HEADSET;
} else if (aState == SWITCH_STATE_OFF) {
AudioSystem::setDeviceConnectionState(static_cast<audio_devices_t>(sHeadsetState),
AUDIO_POLICY_DEVICE_STATE_UNAVAILABLE, "");
@ -135,12 +130,22 @@ AudioManager::Observe(nsISupports* aSubject,
const PRUnichar* aData)
{
if (!strcmp(aTopic, BLUETOOTH_SCO_STATUS_CHANGED)) {
String8 cmd;
cmd.appendFormat("bt_samplerate=%d", kBtSampleRate);
AudioSystem::setParameters(0, cmd);
if (aData) {
String8 cmd;
cmd.appendFormat("bt_samplerate=%d", kBtSampleRate);
AudioSystem::setParameters(0, cmd);
const char* address = NS_ConvertUTF16toUTF8(nsDependentString(aData)).get();
AudioSystem::setDeviceConnectionState(AUDIO_DEVICE_OUT_BLUETOOTH_SCO_HEADSET,
AUDIO_POLICY_DEVICE_STATE_AVAILABLE, address);
AudioSystem::setDeviceConnectionState(AUDIO_DEVICE_IN_BLUETOOTH_SCO_HEADSET,
AUDIO_POLICY_DEVICE_STATE_AVAILABLE, address);
} else {
AudioSystem::setDeviceConnectionState(AUDIO_DEVICE_OUT_BLUETOOTH_SCO_HEADSET,
AUDIO_POLICY_DEVICE_STATE_UNAVAILABLE, "");
AudioSystem::setDeviceConnectionState(AUDIO_DEVICE_IN_BLUETOOTH_SCO_HEADSET,
AUDIO_POLICY_DEVICE_STATE_UNAVAILABLE, "");
}
sDeviceAddress = NS_ConvertUTF16toUTF8(nsDependentString(aData)).get();
InternalSetAudioRoutes(SwitchState::SWITCH_STATE_BLUETOOTH_SCO);
return NS_OK;
}
return NS_ERROR_UNEXPECTED;

View File

@ -3482,36 +3482,42 @@ WorkerPrivate::NotifyInternal(JSContext* aCx, Status aStatus)
// Let all our features know the new status.
NotifyFeatures(aCx, aStatus);
// There's nothing to do here if we never succeeded in running the worker
// script or if the close handler has already run.
if (!JS_GetGlobalObject(aCx) || mCloseHandlerFinished) {
// If this is the first time our status has changed then we need to clear the
// main event queue.
if (previousStatus == Running) {
MutexAutoLock lock(mMutex);
ClearQueue(&mQueue);
}
// If we've run the close handler, we don't need to do anything else.
if (mCloseHandlerFinished) {
return true;
}
// If this is the first time our status has changed then we need to clear the
// main event queue. We also need to schedule the close handler unless we're
// being shut down.
if (previousStatus == Running) {
// If the worker script never ran, or failed to compile, we don't need to do
// anything else, except pretend that we ran the close handler.
if (!JS_GetGlobalObject(aCx)) {
mCloseHandlerStarted = true;
mCloseHandlerFinished = true;
return true;
}
// If this is the first time our status has changed we also need to schedule
// the close handler unless we're being shut down.
if (previousStatus == Running && aStatus != Killing) {
NS_ASSERTION(!mCloseHandlerStarted && !mCloseHandlerFinished,
"This is impossible!");
{
MutexAutoLock lock(mMutex);
ClearQueue(&mQueue);
nsRefPtr<CloseEventRunnable> closeRunnable = new CloseEventRunnable(this);
MutexAutoLock lock(mMutex);
if (!mQueue.Push(closeRunnable)) {
NS_WARNING("Failed to push closeRunnable!");
return false;
}
if (aStatus != Killing) {
nsRefPtr<CloseEventRunnable> closeRunnable = new CloseEventRunnable(this);
MutexAutoLock lock(mMutex);
if (!mQueue.Push(closeRunnable)) {
NS_WARNING("Failed to push closeRunnable!");
return false;
}
closeRunnable.forget();
}
closeRunnable.forget();
}
if (aStatus == Closing) {

View File

@ -13,10 +13,13 @@
#include "ipc/AutoOpenSurface.h"
#include "nsDeviceContext.h"
#include "sampler.h"
#include "mozilla/gfx/2D.h"
namespace mozilla {
namespace layers {
using namespace gfx;
nsIntRect
ThebesLayerBuffer::GetQuadrantRectangle(XSide aXSide, YSide aYSide)
{
@ -60,7 +63,18 @@ ThebesLayerBuffer::DrawBufferQuadrant(gfxContext* aTarget,
true);
gfxPoint quadrantTranslation(quadrantRect.x, quadrantRect.y);
nsRefPtr<gfxPattern> pattern = new gfxPattern(EnsureBuffer());
EnsureBuffer();
if (!BufferValid()) {
return;
}
nsRefPtr<gfxPattern> pattern;
if (mBuffer) {
pattern = new gfxPattern(mBuffer);
} else {
RefPtr<SourceSurface> source = mDTBuffer->Snapshot();
pattern = new gfxPattern(source, Matrix());
}
#ifdef MOZ_GFX_OPTIMIZE_MOBILE
gfxPattern::GraphicsFilter filter = gfxPattern::FILTER_NEAREST;
@ -116,7 +130,11 @@ ThebesLayerBuffer::DrawBufferWithRotation(gfxContext* aTarget, float aOpacity,
already_AddRefed<gfxContext>
ThebesLayerBuffer::GetContextForQuadrantUpdate(const nsIntRect& aBounds)
{
nsRefPtr<gfxContext> ctx = new gfxContext(EnsureBuffer());
EnsureBuffer();
if (!BufferValid()) {
return nullptr;
}
nsRefPtr<gfxContext> ctx = mBuffer ? new gfxContext(mBuffer) : new gfxContext(mDTBuffer);
// Figure out which quadrant to draw in
int32_t xBoundary = mBufferRect.XMost() - mBufferRotation.x;
@ -133,7 +151,13 @@ ThebesLayerBuffer::GetContextForQuadrantUpdate(const nsIntRect& aBounds)
gfxASurface::gfxContentType
ThebesLayerBuffer::BufferContentType()
{
return mBuffer ? mBuffer->GetContentType() : mBufferProvider->ContentType();
if (mBuffer) {
return mBuffer->GetContentType();
}
if (mDTBuffer) {
return ContentForFormat(mDTBuffer->GetFormat());
}
return mBufferProvider->ContentType();
}
bool
@ -144,19 +168,29 @@ ThebesLayerBuffer::BufferSizeOkFor(const nsIntSize& aSize)
aSize < mBufferRect.Size()));
}
gfxASurface*
void
ThebesLayerBuffer::EnsureBuffer()
{
if (!mBuffer && mBufferProvider) {
mBuffer = mBufferProvider->Get();
if (mBuffer || mDTBuffer) {
return;
}
if (!mBufferProvider) {
NS_ASSERTION(false, "Doesn't have mBuffer, mDTBuffer or mBufferProvider");
return;
}
if (gfxPlatform::GetPlatform()->SupportsAzureContent()) {
mDTBuffer = mBufferProvider->GetDrawTarget();
NS_ASSERTION(mDTBuffer, "Failed to create DrawTarget");
} else {
mBuffer = mBufferProvider->Get();
NS_ASSERTION(mBuffer, "Failed to create buffer");
}
return mBuffer;
}
bool
ThebesLayerBuffer::HaveBuffer()
{
return mBuffer || mBufferProvider;
return mBuffer || mDTBuffer || mBufferProvider;
}
static void
@ -253,6 +287,7 @@ ThebesLayerBuffer::BeginPaint(ThebesLayer* aLayer, ContentType aContentType,
nsIntRect drawBounds = result.mRegionToDraw.GetBounds();
nsRefPtr<gfxASurface> destBuffer;
RefPtr<DrawTarget> destDT;
uint32_t bufferFlags = canHaveRotation ? ALLOW_REPEAT : 0;
if (canReuseBuffer) {
nsIntRect keepArea;
@ -274,10 +309,21 @@ ThebesLayerBuffer::BeginPaint(ThebesLayer* aLayer, ContentType aContentType,
// The stuff we need to redraw will wrap around an edge of the
// buffer, so move the pixels we can keep into a position that
// lets us redraw in just one quadrant.
if (mBufferRotation == nsIntPoint(0,0)) {
nsIntRect srcRect(nsIntPoint(0, 0), mBufferRect.Size());
EnsureBuffer();
if (!BufferValid())
return result;
nsIntPoint dest = mBufferRect.TopLeft() - destBufferRect.TopLeft();
EnsureBuffer()->MovePixels(srcRect, dest);
if (mBuffer) {
nsIntRect srcRect(nsIntPoint(0, 0), mBufferRect.Size());
mBuffer->MovePixels(srcRect, dest);
} else {
IntRect srcRect(0, 0, mBufferRect.width, mBufferRect.height);
RefPtr<SourceSurface> snapshot = mDTBuffer->Snapshot();
mDTBuffer->CopySurface(snapshot, srcRect, IntPoint(dest.x, dest.y));
}
result.mDidSelfCopy = true;
// Don't set destBuffer; we special-case self-copies, and
// just did the necessary work above.
@ -286,8 +332,12 @@ ThebesLayerBuffer::BeginPaint(ThebesLayer* aLayer, ContentType aContentType,
// We can't do a real self-copy because the buffer is rotated.
// So allocate a new buffer for the destination.
destBufferRect = ComputeBufferRect(neededRegion.GetBounds());
destBuffer = CreateBuffer(contentType, destBufferRect.Size(), bufferFlags);
if (!destBuffer)
if (gfxPlatform::GetPlatform()->SupportsAzureContent()) {
destDT = CreateDrawTarget(destBufferRect.Size(), contentType);
} else {
destBuffer = CreateBuffer(contentType, destBufferRect.Size(), bufferFlags);
}
if (!destBuffer && !destDT)
return result;
}
} else {
@ -303,8 +353,12 @@ ThebesLayerBuffer::BeginPaint(ThebesLayer* aLayer, ContentType aContentType,
}
} else {
// The buffer's not big enough, so allocate a new one
destBuffer = CreateBuffer(contentType, destBufferRect.Size(), bufferFlags);
if (!destBuffer)
if (gfxPlatform::GetPlatform()->SupportsAzureContent()) {
destDT = CreateDrawTarget(destBufferRect.Size(), contentType);
} else {
destBuffer = CreateBuffer(contentType, destBufferRect.Size(), bufferFlags);
}
if (!destBuffer && !destDT)
return result;
}
NS_ASSERTION(!(aFlags & PAINT_WILL_RESAMPLE) || destBufferRect == neededRegion.GetBounds(),
@ -312,19 +366,23 @@ ThebesLayerBuffer::BeginPaint(ThebesLayer* aLayer, ContentType aContentType,
// If we have no buffered data already, then destBuffer will be a fresh buffer
// and we do not need to clear it below.
bool isClear = mBuffer == nullptr;
bool isClear = !mBuffer && !mDTBuffer;
if (destBuffer) {
if (destBuffer || destDT) {
if (HaveBuffer()) {
// Copy the bits
nsRefPtr<gfxContext> tmpCtx = new gfxContext(destBuffer);
nsRefPtr<gfxContext> tmpCtx = destBuffer ? new gfxContext(destBuffer) : new gfxContext(destDT);
nsIntPoint offset = -destBufferRect.TopLeft();
tmpCtx->SetOperator(gfxContext::OPERATOR_SOURCE);
tmpCtx->Translate(gfxPoint(offset.x, offset.y));
DrawBufferWithRotation(tmpCtx, 1.0);
}
mBuffer = destBuffer.forget();
if (destBuffer) {
mBuffer = destBuffer.forget();
} else {
mDTBuffer = destDT.forget();
}
mBufferRect = destBufferRect;
mBufferRotation = nsIntPoint(0,0);
}

View File

@ -8,6 +8,7 @@
#include "gfxContext.h"
#include "gfxASurface.h"
#include "gfxPlatform.h"
#include "nsRegion.h"
namespace mozilla {
@ -69,6 +70,7 @@ public:
void Clear()
{
mBuffer = nullptr;
mDTBuffer = nullptr;
mBufferProvider = nullptr;
mBufferRect.SetEmpty();
}
@ -127,11 +129,32 @@ public:
virtual already_AddRefed<gfxASurface>
CreateBuffer(ContentType aType, const nsIntSize& aSize, uint32_t aFlags) = 0;
/**
* Return a new DrawTarget of |aSize| with SurfaceFormat |aFormat|.
*/
virtual TemporaryRef<gfx::DrawTarget>
CreateDrawTarget(const gfx::IntSize& aSize, gfx::SurfaceFormat aFormat)
{
return gfxPlatform::GetPlatform()->CreateOffscreenDrawTarget(aSize, aFormat);
}
/**
* Return a new DrawTarget of |aSize| with ContentType |aContent|.
*/
TemporaryRef<gfx::DrawTarget>
CreateDrawTarget(const nsIntSize& aSize, ContentType aContent)
{
gfx::SurfaceFormat format = gfx::SurfaceFormatForImageFormat(
gfxPlatform::GetPlatform()->OptimalFormatForContent(aContent));
return CreateDrawTarget(gfx::IntSize(aSize.width, aSize.height), format);
}
/**
* Get the underlying buffer, if any. This is useful because we can pass
* in the buffer as the default "reference surface" if there is one.
* Don't use it for anything else!
*/
gfx::DrawTarget* GetDT() { return mDTBuffer; }
gfxASurface* GetBuffer() { return mBuffer; }
protected:
@ -174,6 +197,17 @@ protected:
return tmp.forget();
}
TemporaryRef<gfx::DrawTarget>
SetDT(gfx::DrawTarget* aBuffer,
const nsIntRect& aBufferRect, const nsIntPoint& aBufferRotation)
{
RefPtr<gfx::DrawTarget> tmp = mDTBuffer.forget();
mDTBuffer = aBuffer;
mBufferRect = aBufferRect;
mBufferRotation = aBufferRotation;
return tmp.forget();
}
/**
* Set the buffer provider only. This is used with surfaces that
* require explicit map/unmap, which |aProvider| is used to do on
@ -190,6 +224,7 @@ protected:
mBufferProvider = aProvider;
if (!mBufferProvider) {
mBuffer = nullptr;
mDTBuffer = nullptr;
} else {
// Only this buffer provider can give us a buffer. If we
// already have one, something has gone wrong.
@ -215,15 +250,24 @@ private:
gfxASurface::gfxContentType BufferContentType();
bool BufferSizeOkFor(const nsIntSize& aSize);
/**
* If the buffer hasn't been mapped, map it and return it.
* If the buffer hasn't been mapped, map it.
*/
gfxASurface* EnsureBuffer();
void EnsureBuffer();
/**
* Check if the buffer is valid
*/
bool BufferValid() {
return mBuffer || mDTBuffer;
}
/**
* True if we have a buffer where we can get it (but not necessarily
* mapped currently).
*/
bool HaveBuffer();
RefPtr<gfx::DrawTarget> mDTBuffer;
nsRefPtr<gfxASurface> mBuffer;
/**
* This member is only set transiently. It's used to map mBuffer

View File

@ -64,11 +64,38 @@ BasicThebesLayerBuffer::CreateBuffer(ContentType aType,
return mLayer->CreateBuffer(aType, aSize);
}
TemporaryRef<DrawTarget>
BasicThebesLayerBuffer::CreateDrawTarget(const IntSize& aSize, SurfaceFormat aFormat)
{
return mLayer->CreateDrawTarget(aSize, aFormat);
}
void
BasicThebesLayerBuffer::SetBackingBufferAndUpdateFrom(
gfxASurface* aBuffer,
gfxASurface* aSource, const nsIntRect& aRect, const nsIntPoint& aRotation,
const nsIntRegion& aUpdateRegion)
{
SetBackingBuffer(aBuffer, aRect, aRotation);
nsRefPtr<gfxContext> destCtx =
GetContextForQuadrantUpdate(aUpdateRegion.GetBounds());
if (!destCtx) {
return;
}
destCtx->SetOperator(gfxContext::OPERATOR_SOURCE);
if (IsClippingCheap(destCtx, aUpdateRegion)) {
gfxUtils::ClipToRegion(destCtx, aUpdateRegion);
}
BasicThebesLayerBuffer srcBuffer(aSource, aRect, aRotation);
srcBuffer.DrawBufferWithRotation(destCtx, 1.0);
}
void
BasicThebesLayerBuffer::SetBackingBufferAndUpdateFrom(
DrawTarget* aBuffer,
DrawTarget* aSource, const nsIntRect& aRect, const nsIntPoint& aRotation,
const nsIntRegion& aUpdateRegion)
{
SetBackingBuffer(aBuffer, aRect, aRotation);
nsRefPtr<gfxContext> destCtx =

View File

@ -8,6 +8,8 @@
#include "BasicLayersImpl.h"
#include "mozilla/gfx/2D.h"
namespace mozilla {
namespace layers {
@ -39,6 +41,10 @@ public:
virtual already_AddRefed<gfxASurface>
CreateBuffer(ContentType aType, const nsIntSize& aSize, uint32_t aFlags);
virtual TemporaryRef<mozilla::gfx::DrawTarget>
CreateDrawTarget(const mozilla::gfx::IntSize& aSize,
mozilla::gfx::SurfaceFormat aFormat);
/**
* Swap out the old backing buffer for |aBuffer| and attributes.
*/
@ -55,11 +61,27 @@ public:
oldBuffer = SetBuffer(aBuffer, aRect, aRotation);
}
void SetBackingBuffer(mozilla::gfx::DrawTarget* aBuffer,
const nsIntRect& aRect, const nsIntPoint& aRotation)
{
mozilla::gfx::IntSize prevSize = mozilla::gfx::IntSize(BufferRect().width, BufferRect().height);
mozilla::gfx::IntSize newSize = aBuffer->GetSize();
NS_ABORT_IF_FALSE(newSize == prevSize,
"Swapped-in buffer size doesn't match old buffer's!");
RefPtr<mozilla::gfx::DrawTarget> oldBuffer;
oldBuffer = SetDT(aBuffer, aRect, aRotation);
}
void SetBackingBufferAndUpdateFrom(
gfxASurface* aBuffer,
gfxASurface* aSource, const nsIntRect& aRect, const nsIntPoint& aRotation,
const nsIntRegion& aUpdateRegion);
void SetBackingBufferAndUpdateFrom(
mozilla::gfx::DrawTarget* aBuffer,
mozilla::gfx::DrawTarget* aSource, const nsIntRect& aRect, const nsIntPoint& aRotation,
const nsIntRegion& aUpdateRegion);
/**
* When BasicThebesLayerBuffer is used with layers that hold
* SurfaceDescriptor, this buffer only has a valid gfxASurface in
@ -91,6 +113,14 @@ private:
SetBuffer(aBuffer, aRect, aRotation);
}
BasicThebesLayerBuffer(mozilla::gfx::DrawTarget* aBuffer,
const nsIntRect& aRect, const nsIntPoint& aRotation)
: ThebesLayerBuffer(ContainsVisibleBounds)
{
SetDT(aBuffer, aRect, aRotation);
}
BasicThebesLayer* mLayer;
};
@ -138,6 +168,13 @@ protected:
NS_RUNTIMEABORT("ShadowThebesLayer can't paint content");
return nullptr;
}
virtual TemporaryRef<mozilla::gfx::DrawTarget>
CreateDrawTarget(const mozilla::gfx::IntSize&, mozilla::gfx::SurfaceFormat)
{
NS_RUNTIMEABORT("ShadowThebesLayer can't paint content");
return nullptr;
}
};
}

View File

@ -8,6 +8,7 @@
#include "nsIWidget.h"
#include "RenderTrace.h"
#include "sampler.h"
#include "gfxSharedImageSurface.h"
#include "prprf.h"
@ -35,6 +36,13 @@ BasicThebesLayer::CreateBuffer(Buffer::ContentType aType, const nsIntSize& aSize
aType, gfxIntSize(aSize.width, aSize.height));
}
TemporaryRef<DrawTarget>
BasicThebesLayer::CreateDrawTarget(const IntSize& aSize, SurfaceFormat aFormat)
{
return gfxPlatform::GetPlatform()->CreateOffscreenDrawTarget(aSize, aFormat);
}
static nsIntRegion
IntersectWithClip(const nsIntRegion& aRegion, gfxContext* aContext)
{
@ -265,6 +273,10 @@ struct NS_STACK_CLASS AutoBufferTracker {
gfxASurface* GetInitialBuffer() { return mInitialBuffer.ref().Get(); }
DrawTarget* GetInitialDrawTarget() {
return mInitialBuffer.ref().GetDrawTarget();
}
gfxASurface*
CreatedBuffer(const SurfaceDescriptor& aDescriptor) {
Maybe<AutoOpenSurface>* surface = mNewBuffers.AppendElement();
@ -346,8 +358,10 @@ BasicShadowableThebesLayer::SyncFrontBufferToBackBuffer()
MOZ_ASSERT(mBufferTracker);
nsRefPtr<gfxASurface> backBuffer = mBuffer.GetBuffer();
DrawTarget* backDT = mBuffer.GetDT();
if (!IsSurfaceDescriptorValid(mBackBuffer)) {
MOZ_ASSERT(!backBuffer);
MOZ_ASSERT(!backBuffer && !backDT);
MOZ_ASSERT(mROFrontBuffer.type() == OptionalThebesBuffer::TThebesBuffer);
const ThebesBuffer roFront = mROFrontBuffer.get_ThebesBuffer();
AutoOpenSurface roFrontBuffer(OPEN_READ_ONLY, roFront.buffer());
@ -355,8 +369,12 @@ BasicShadowableThebesLayer::SyncFrontBufferToBackBuffer()
}
mFrontAndBackBufferDiffer = false;
if (!backBuffer) {
backBuffer = mBufferTracker->GetInitialBuffer();
if (!backBuffer && !backDT) {
if (gfxPlatform::GetPlatform()->SupportsAzureContent()) {
backDT = mBufferTracker->GetInitialDrawTarget();
} else {
backBuffer = mBufferTracker->GetInitialBuffer();
}
}
if (OptionalThebesBuffer::Tnull_t == mROFrontBuffer.type()) {
@ -365,7 +383,11 @@ BasicShadowableThebesLayer::SyncFrontBufferToBackBuffer()
// to a texture it owns, then we probably got back the same buffer
// we pushed in the update and all is well. If not, ...
mValidRegion = mFrontValidRegion;
mBuffer.SetBackingBuffer(backBuffer, mBackBufferRect, mBackBufferRectRotation);
if (backDT) {
mBuffer.SetBackingBuffer(backDT, mBackBufferRect, mBackBufferRectRotation);
} else {
mBuffer.SetBackingBuffer(backBuffer, mBackBufferRect, mBackBufferRectRotation);
}
return;
}
@ -378,10 +400,19 @@ BasicShadowableThebesLayer::SyncFrontBufferToBackBuffer()
const ThebesBuffer roFront = mROFrontBuffer.get_ThebesBuffer();
AutoOpenSurface autoROFront(OPEN_READ_ONLY, roFront.buffer());
mBuffer.SetBackingBufferAndUpdateFrom(
backBuffer,
autoROFront.Get(), roFront.rect(), roFront.rotation(),
mFrontUpdatedRegion);
if (backDT) {
mBuffer.SetBackingBufferAndUpdateFrom(
backDT,
autoROFront.GetDrawTarget(), roFront.rect(), roFront.rotation(),
mFrontUpdatedRegion);
} else {
mBuffer.SetBackingBufferAndUpdateFrom(
backBuffer,
autoROFront.Get(), roFront.rect(), roFront.rotation(),
mFrontUpdatedRegion);
}
mIsNewBuffer = false;
// Now the new back buffer has the same (interesting) pixels as the
// new front buffer, and mValidRegion et al. are correct wrt the new
@ -469,6 +500,50 @@ BasicShadowableThebesLayer::CreateBuffer(Buffer::ContentType aType,
return buffer.forget();
}
TemporaryRef<DrawTarget>
BasicShadowableThebesLayer::CreateDrawTarget(const IntSize& aSize,
SurfaceFormat aFormat)
{
if (!HasShadow()) {
return BasicThebesLayer::CreateDrawTarget(aSize, aFormat);
}
MOZ_LAYERS_LOG(("BasicShadowableThebes(%p): creating %d x %d buffer(x2)",
this,
aSize.width, aSize.height));
if (IsSurfaceDescriptorValid(mBackBuffer)) {
BasicManager()->DestroyedThebesBuffer(BasicManager()->Hold(this),
mBackBuffer);
mBackBuffer = SurfaceDescriptor();
}
// XXX error handling
if (!BasicManager()->AllocBuffer(gfxIntSize(aSize.width, aSize.height),
mozilla::gfx::ContentForFormat(aFormat),
&mBackBuffer)) {
NS_RUNTIMEABORT("creating ThebesLayer 'back buffer' failed!");
}
NS_ABORT_IF_FALSE(!mIsNewBuffer,
"Bad! Did we create a buffer twice without painting?");
mIsNewBuffer = true;
mozilla::ipc::Shmem shm = mBackBuffer.get_Shmem();
if (!shm.IsWritable()) {
NS_RUNTIMEABORT("shmem not writable!");
return nullptr;
}
SharedImageInfo* shmInfo = gfxSharedImageSurface::GetShmInfoPtr(shm);
unsigned char* data = shm.get<unsigned char>();
int stride = gfxASurface::FormatStrideForWidth(
static_cast<gfxASurface::gfxImageFormat>(shmInfo->format), aSize.width);
return gfxPlatform::GetPlatform()->CreateDrawTargetForData(data, aSize, stride, aFormat);
}
void
BasicShadowableThebesLayer::Disconnect()
{

View File

@ -7,6 +7,7 @@
#define GFX_BASICTHEBESLAYER_H
#include "mozilla/layers/PLayersParent.h"
#include "mozilla/gfx/2D.h"
#include "BasicBuffers.h"
namespace mozilla {
@ -53,6 +54,11 @@ public:
virtual already_AddRefed<gfxASurface>
CreateBuffer(Buffer::ContentType aType, const nsIntSize& aSize);
virtual TemporaryRef<mozilla::gfx::DrawTarget>
CreateDrawTarget(const mozilla::gfx::IntSize& aSize,
mozilla::gfx::SurfaceFormat aFormat);
virtual void ComputeEffectiveTransforms(const gfx3DMatrix& aTransformToSurface)
{
if (!BasicManager()->IsRetained()) {
@ -168,6 +174,11 @@ private:
virtual already_AddRefed<gfxASurface>
CreateBuffer(Buffer::ContentType aType, const nsIntSize& aSize) MOZ_OVERRIDE;
virtual TemporaryRef<mozilla::gfx::DrawTarget>
CreateDrawTarget(const mozilla::gfx::IntSize& aSize,
mozilla::gfx::SurfaceFormat aFormat) MOZ_OVERRIDE;
void DestroyBackBuffer()
{
if (IsSurfaceDescriptorValid(mBackBuffer)) {

View File

@ -11,6 +11,7 @@
#include "base/basictypes.h"
#include "gfxASurface.h"
#include "mozilla/gfx/2D.h"
#include "mozilla/layers/PLayers.h"
#include "ShadowLayers.h"
@ -44,6 +45,8 @@ public:
/** This can't escape the scope of AutoOpenSurface. */
gfxASurface* Get();
mozilla::gfx::DrawTarget* GetDrawTarget();
/**
* This can't escape the scope of AutoOpenSurface.
*
@ -60,6 +63,7 @@ public:
private:
SurfaceDescriptor mDescriptor;
nsRefPtr<gfxASurface> mSurface;
RefPtr<mozilla::gfx::DrawTarget> mDrawTarget;
nsRefPtr<gfxImageSurface> mSurfaceAsImage;
OpenMode mMode;

View File

@ -486,6 +486,40 @@ ShadowLayerForwarder::OpenDescriptor(OpenMode aMode,
}
}
/*static*/ TemporaryRef<mozilla::gfx::DrawTarget>
ShadowLayerForwarder::OpenDescriptorForDrawTarget(OpenMode aMode,
const SurfaceDescriptor& aSurface)
{
switch (aSurface.type()) {
case SurfaceDescriptor::TShmem: {
mozilla::ipc::Shmem shm = aSurface.get_Shmem();
if (!shm.IsWritable()) {
NS_RUNTIMEABORT("shmem not writable!");
return nullptr;
}
SharedImageInfo* shmInfo = gfxSharedImageSurface::GetShmInfoPtr(shm);
unsigned char* data = shm.get<unsigned char>();
gfxASurface::gfxImageFormat imgFormat =
static_cast<gfxASurface::gfxImageFormat>(shmInfo->format);
mozilla::gfx::SurfaceFormat surfFormat =
mozilla::gfx::SurfaceFormatForImageFormat(imgFormat);
mozilla::gfx::IntSize size(shmInfo->width, shmInfo->height);
int stride = gfxASurface::FormatStrideForWidth(imgFormat, size.width);
return gfxPlatform::GetPlatform()->CreateDrawTargetForData(data, size,
stride, surfFormat);
}
default:
NS_RUNTIMEABORT("unexpected SurfaceDescriptor type!");
return nullptr;
}
}
/*static*/ gfxContentType
ShadowLayerForwarder::GetDescriptorSurfaceContentType(
const SurfaceDescriptor& aDescriptor, OpenMode aMode,
@ -710,6 +744,15 @@ AutoOpenSurface::Get()
return mSurface.get();
}
mozilla::gfx::DrawTarget*
AutoOpenSurface::GetDrawTarget()
{
if (!mDrawTarget) {
mDrawTarget = ShadowLayerForwarder::OpenDescriptorForDrawTarget(mMode, mDescriptor);
}
return mDrawTarget.get();
}
gfxImageSurface*
AutoOpenSurface::GetAsImage()
{

View File

@ -9,6 +9,7 @@
#define mozilla_layers_ShadowLayers_h 1
#include "gfxASurface.h"
#include "mozilla/gfx/2D.h"
#include "GLDefs.h"
#include "ImageLayers.h"
@ -368,6 +369,9 @@ private:
static already_AddRefed<gfxASurface>
OpenDescriptor(OpenMode aMode, const SurfaceDescriptor& aSurface);
static TemporaryRef<mozilla::gfx::DrawTarget>
OpenDescriptorForDrawTarget(OpenMode aMode, const SurfaceDescriptor& aSurface);
static already_AddRefed<gfxASurface>
PlatformOpenDescriptor(OpenMode aMode, const SurfaceDescriptor& aDescriptor);

View File

@ -227,6 +227,40 @@ inline gfxASurface::gfxContentType ContentForFormat(const SurfaceFormat &aFormat
}
}
inline SurfaceFormat SurfaceFormatForImageFormat(const gfxASurface::gfxImageFormat &aImageFormat)
{
switch (aImageFormat) {
case gfxASurface::ImageFormatARGB32:
return FORMAT_B8G8R8A8;
case gfxASurface::ImageFormatRGB24:
return FORMAT_B8G8R8X8;
case gfxASurface::ImageFormatA8:
case gfxASurface::ImageFormatA1:
return FORMAT_A8;
case gfxASurface::ImageFormatRGB16_565:
return FORMAT_R5G6B5;
case gfxASurface::ImageFormatUnknown:
default:
return FORMAT_B8G8R8A8;
}
}
inline gfxASurface::gfxImageFormat ImageFormatForSurfaceFormat(const SurfaceFormat &aFormat)
{
switch (aFormat) {
case FORMAT_B8G8R8A8:
return gfxASurface::ImageFormatARGB32;
case FORMAT_B8G8R8X8:
return gfxASurface::ImageFormatRGB24;
case FORMAT_A8:
return gfxASurface::ImageFormatA8;
case FORMAT_R5G6B5:
return gfxASurface::ImageFormatRGB16_565;
default:
return gfxASurface::ImageFormatARGB32;
}
}
inline CompositionOp CompositionOpForOp(gfxContext::GraphicsOperator aOp)
{
switch (aOp) {

View File

@ -14,14 +14,8 @@ using namespace mozilla::ipc;
static const cairo_user_data_key_t SHM_KEY = {0};
struct SharedImageInfo {
int32_t width;
int32_t height;
int32_t format;
};
static SharedImageInfo*
GetShmInfoPtr(const Shmem& aShmem)
/*static*/ SharedImageInfo*
gfxSharedImageSurface::GetShmInfoPtr(const Shmem& aShmem)
{
return reinterpret_cast<SharedImageInfo*>
(aShmem.get<char>() + aShmem.Size<char>() - sizeof(SharedImageInfo));

View File

@ -13,6 +13,12 @@
#include "gfxASurface.h"
#include "gfxImageSurface.h"
struct SharedImageInfo {
PRInt32 width;
PRInt32 height;
PRInt32 format;
};
class THEBES_API gfxSharedImageSurface : public gfxImageSurface {
typedef mozilla::ipc::SharedMemory SharedMemory;
typedef mozilla::ipc::Shmem Shmem;
@ -62,6 +68,8 @@ public:
static bool IsSharedImage(gfxASurface *aSurface);
static SharedImageInfo* GetShmInfoPtr(const Shmem& aShmem);
private:
gfxSharedImageSurface(const gfxIntSize&, gfxImageFormat, const Shmem&);

View File

@ -62,7 +62,6 @@ enum SwitchState {
SWITCH_STATE_OFF,
SWITCH_STATE_HEADSET, // Headphone with microphone
SWITCH_STATE_HEADPHONE, // without microphone
SWITCH_STATE_BLUETOOTH_SCO,
NUM_SWITCH_STATE
};

View File

@ -2837,20 +2837,6 @@ FrameLayerBuilder::BuildContainerLayerFor(nsDisplayListBuilder* aBuilder,
data->AddFrame(aContainerFrame);
entry->mContainerLayerGeneration = mContainerLayerGeneration;
}
nsAutoTArray<nsIFrame*,4> mergedFrames;
if (aContainerItem) {
aContainerItem->GetMergedFrames(&mergedFrames);
}
for (uint32_t i = 0; i < mergedFrames.Length(); ++i) {
nsIFrame* mergedFrame = mergedFrames[i];
entry = mNewDisplayItemData.PutEntry(mergedFrame);
if (entry) {
entry->mContainerLayerGeneration = mContainerLayerGeneration;
entry->mData.AppendElement(data);
data->AddFrame(mergedFrame);
}
}
}
nsRect bounds;

View File

@ -5280,17 +5280,17 @@ PresShell::Paint(nsIView* aViewToPaint,
} else {
LayerProperties::ClearInvalidations(layerManager->GetRoot());
}
if (!invalid.IsEmpty()) {
if (props) {
if (props) {
if (!invalid.IsEmpty()) {
nsRect rect(presContext->DevPixelsToAppUnits(invalid.x),
presContext->DevPixelsToAppUnits(invalid.y),
presContext->DevPixelsToAppUnits(invalid.width),
presContext->DevPixelsToAppUnits(invalid.height));
aViewToPaint->GetViewManager()->InvalidateViewNoSuppression(aViewToPaint, rect);
presContext->NotifyInvalidation(invalid, 0);
} else {
aViewToPaint->GetViewManager()->InvalidateView(aViewToPaint);
}
} else {
aViewToPaint->GetViewManager()->InvalidateView(aViewToPaint);
}
frame->UpdatePaintCountForPaintedPresShells();

View File

@ -22,6 +22,7 @@
#include "nsDisplayList.h"
#include "nsCSSFrameConstructor.h"
#include "nsFrameManager.h"
#include "gfxPlatform.h"
// for focus
#include "nsIScrollableFrame.h"
@ -210,12 +211,32 @@ nsDisplayCanvasBackground::Paint(nsDisplayListBuilder* aBuilder,
#ifndef MOZ_GFX_OPTIMIZE_MOBILE
if (IsSingleFixedPositionImage(aBuilder, bgClipRect) && aBuilder->IsPaintingToWindow() && !aBuilder->IsCompositingCheap()) {
surf = static_cast<gfxASurface*>(GetUnderlyingFrame()->Properties().Get(nsIFrame::CachedBackgroundImage()));
nsRefPtr<gfxASurface> destSurf = dest->CurrentSurface();
if (surf && surf->GetType() == destSurf->GetType()) {
BlitSurface(dest, mDestRect, surf);
return;
if (dest->IsCairo()) {
nsRefPtr<gfxASurface> destSurf = dest->CurrentSurface();
if (surf && surf->GetType() == destSurf->GetType()) {
BlitSurface(dest, mDestRect, surf);
return;
}
surf = destSurf->CreateSimilarSurface(
gfxASurface::CONTENT_COLOR_ALPHA,
gfxIntSize(ceil(mDestRect.width), ceil(mDestRect.height)));
} else {
if (surf) {
mozilla::gfx::DrawTarget* dt = dest->GetDrawTarget();
mozilla::RefPtr<mozilla::gfx::SourceSurface> source =
gfxPlatform::GetPlatform()->GetSourceSurfaceForSurface(dt, surf);
if (source) {
// Could be non-integer pixel alignment
dt->DrawSurface(source,
mozilla::gfx::Rect(mDestRect.x, mDestRect.y, mDestRect.width, mDestRect.height),
mozilla::gfx::Rect(0, 0, mDestRect.width, mDestRect.height));
return;
}
}
surf = gfxPlatform::GetPlatform()->CreateOffscreenImageSurface(
gfxIntSize(ceil(mDestRect.width), ceil(mDestRect.height)),
gfxASurface::CONTENT_COLOR_ALPHA);
}
surf = destSurf->CreateSimilarSurface(gfxASurface::CONTENT_COLOR_ALPHA, gfxIntSize(ceil(mDestRect.width), ceil(mDestRect.height)));
if (surf) {
ctx = new gfxContext(surf);
ctx->Translate(-gfxPoint(mDestRect.x, mDestRect.y));

View File

@ -112,6 +112,7 @@ nsSimplePageSequenceFrame::nsSimplePageSequenceFrame(nsStyleContext* aContext) :
nsSimplePageSequenceFrame::~nsSimplePageSequenceFrame()
{
delete mPageData;
ResetPrintCanvasList();
}
NS_QUERYFRAME_HEAD(nsSimplePageSequenceFrame)

View File

@ -44,6 +44,34 @@ nsPagePrintTimer::StartTimer(bool aUseDelay)
return result;
}
nsresult
nsPagePrintTimer::StartWatchDogTimer()
{
nsresult result;
if (mWatchDogTimer) {
mWatchDogTimer->Cancel();
}
mWatchDogTimer = do_CreateInstance("@mozilla.org/timer;1", &result);
if (NS_FAILED(result)) {
NS_WARNING("unable to start the timer");
} else {
// Instead of just doing one timer for a long period do multiple so we
// can check if the user cancelled the printing.
mWatchDogTimer->InitWithCallback(this, WATCH_DOG_INTERVAL,
nsITimer::TYPE_ONE_SHOT);
}
return result;
}
void
nsPagePrintTimer::StopWatchDogTimer()
{
if (mWatchDogTimer) {
mWatchDogTimer->Cancel();
mWatchDogTimer = nullptr;
}
}
//nsRunnable
NS_IMETHODIMP
nsPagePrintTimer::Run()
@ -61,6 +89,7 @@ nsPagePrintTimer::Run()
// now clean up print or print the next webshell
if (mPrintEngine->DonePrintingPages(mPrintObj, NS_OK)) {
initNewTimer = false;
mDone = true;
}
}
@ -72,7 +101,7 @@ nsPagePrintTimer::Run()
++mFiringCount;
nsresult result = StartTimer(inRange);
if (NS_FAILED(result)) {
donePrinting = true; // had a failure.. we are finished..
mDone = true; // had a failure.. we are finished..
mPrintEngine->SetIsPrinting(false);
}
}
@ -83,11 +112,37 @@ nsPagePrintTimer::Run()
NS_IMETHODIMP
nsPagePrintTimer::Notify(nsITimer *timer)
{
// When finished there may be still pending notifications, which we can just
// ignore.
if (mDone) {
return NS_OK;
}
// There are three things that call Notify with different values for timer:
// 1) the delay between pages (timer == mTimer)
// 2) canvasPrintState done (timer == null)
// 3) the watch dog timer (timer == mWatchDogTimer)
if (timer && timer == mWatchDogTimer) {
mWatchDogCount++;
if (mWatchDogCount > WATCH_DOG_MAX_COUNT) {
Fail();
return NS_OK;
}
} else if(!timer) {
// Reset the counter since a mozPrintCallback has finished.
mWatchDogCount = 0;
}
if (mDocViewerPrint) {
bool donePrePrint = mPrintEngine->PrePrintPage();
if (donePrePrint) {
StopWatchDogTimer();
NS_DispatchToMainThread(this);
} else {
// Start the watch dog if we're waiting for preprint to ensure that if any
// mozPrintCallbacks take to long we error out.
StartWatchDogTimer();
}
}
@ -98,6 +153,8 @@ nsresult
nsPagePrintTimer::Start(nsPrintObject* aPO)
{
mPrintObj = aPO;
mWatchDogCount = 0;
mDone = false;
return StartTimer(false);
}
@ -109,4 +166,15 @@ nsPagePrintTimer::Stop()
mTimer->Cancel();
mTimer = nullptr;
}
StopWatchDogTimer();
}
void
nsPagePrintTimer::Fail()
{
mDone = true;
Stop();
if (mPrintEngine) {
mPrintEngine->CleanupOnFailure(NS_OK, false);
}
}

View File

@ -33,6 +33,8 @@ public:
, mDelay(aDelay)
, mFiringCount(0)
, mPrintObj(nullptr)
, mWatchDogCount(0)
, mDone(false)
{
mDocViewerPrint->IncrementDestroyRefCount();
}
@ -48,13 +50,22 @@ public:
private:
nsresult StartTimer(bool aUseDelay);
nsresult StartWatchDogTimer();
void StopWatchDogTimer();
void Fail();
nsPrintEngine* mPrintEngine;
nsCOMPtr<nsIDocumentViewerPrint> mDocViewerPrint;
nsCOMPtr<nsITimer> mTimer;
nsCOMPtr<nsITimer> mWatchDogTimer;
uint32_t mDelay;
uint32_t mFiringCount;
nsPrintObject * mPrintObj;
uint32_t mWatchDogCount;
bool mDone;
static const uint32_t WATCH_DOG_INTERVAL = 1000;
static const uint32_t WATCH_DOG_MAX_COUNT = 10;
};

View File

@ -166,6 +166,12 @@
</intent-filter>
</receiver>
<receiver android:name="org.mozilla.gecko.ReferrerReceiver" android:exported="true">
<intent-filter>
<action android:name="com.android.vending.INSTALL_REFERRER" />
</intent-filter>
</receiver>
<activity android:name="Restarter"
android:process="@ANDROID_PACKAGE_NAME@Restarter"
android:theme="@style/Gecko">

View File

@ -172,6 +172,7 @@ FENNEC_JAVA_FILES = \
GeckoScreenOrientationListener.java \
UpdateService.java \
GeckoUpdateReceiver.java \
ReferrerReceiver.java \
$(NULL)
ifdef MOZ_WEBSMS_BACKEND
@ -359,6 +360,7 @@ RES_LAYOUT = \
res/layout/tabs_tray.xml \
res/layout/list_item_header.xml \
res/layout/select_dialog_list.xml \
res/layout/select_dialog_multichoice.xml \
res/layout/abouthome_addon_row.xml \
res/layout/abouthome_last_tabs_row.xml \
res/layout/abouthome_promo_box.xml \
@ -889,6 +891,7 @@ RES_DRAWABLE_XLARGE_XHDPI_V11 = \
RES_COLOR = \
res/color/menu_item_title.xml \
res/color/select_item_multichoice.xml \
$(NULL)
RES_MENU = \

View File

@ -292,7 +292,7 @@ public class PromptService implements OnClickListener, OnCancelListener, OnItemC
int resourceId = android.R.layout.select_dialog_item;
if (mSelected != null && mSelected.length > 0) {
if (aMultipleSelection) {
resourceId = android.R.layout.select_dialog_multichoice;
resourceId = R.layout.select_dialog_multichoice;
} else {
resourceId = android.R.layout.select_dialog_singlechoice;
}

View File

@ -0,0 +1,71 @@
/* -*- Mode: Java; c-basic-offset: 4; tab-width: 20; indent-tabs-mode: nil; -*-
* 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/. */
package org.mozilla.gecko;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.util.Log;
import java.net.URLDecoder;
import java.util.HashMap;
public class ReferrerReceiver
extends BroadcastReceiver
{
private static final String LOGTAG = "GeckoReferrerReceiver";
public static final String ACTION_INSTALL_REFERRER = "com.android.vending.INSTALL_REFERRER";
public static final String UTM_SOURCE = "mozilla";
@Override
public void onReceive(Context context, Intent intent) {
if (ACTION_INSTALL_REFERRER.equals(intent.getAction())) {
String referrer = intent.getStringExtra("referrer");
if (referrer == null)
return;
HashMap<String, String> values = new HashMap<String, String>();
try {
String referrers[] = referrer.split("&");
for (String referrerValue : referrers) {
String keyValue[] = referrerValue.split("=");
values.put(URLDecoder.decode(keyValue[0]), URLDecoder.decode(keyValue[1]));
}
} catch (Exception e) {
}
String source = values.get("utm_source");
String campaign = values.get("utm_campaign");
if (source != null && UTM_SOURCE.equals(source) && campaign != null) {
try {
JSONObject idPref = new JSONObject();
idPref.put("name", "distribution.id");
idPref.put("type", "string");
idPref.put("value", "playstore");
JSONObject versionPref = new JSONObject();
versionPref.put("name", "distribution.version");
versionPref.put("type", "string");
versionPref.put("value", campaign);
// Try to make sure the prefs are written as a group
GeckoEvent idEvent = GeckoEvent.createBroadcastEvent("Preferences:Set", idPref.toString());
GeckoAppShell.sendEventToGecko(idEvent);
GeckoEvent versionEvent = GeckoEvent.createBroadcastEvent("Preferences:Set", versionPref.toString());
GeckoAppShell.sendEventToGecko(versionEvent);
} catch (JSONException e) {
Log.e(LOGTAG, "Error setting distribution prefs", e);
}
}
}
}
}

View File

@ -123,10 +123,14 @@ public class WebAppAllocator {
return index;
}
public synchronized void releaseIndex(int index) {
mPrefs.edit()
.remove(appKey(index))
.remove(iconKey(index))
.apply();
public synchronized void releaseIndex(final int index) {
GeckoBackgroundThread.getHandler().post(new Runnable() {
public void run() {
mPrefs.edit()
.remove(appKey(index))
.remove(iconKey(index))
.commit();
}
});
}
}

View File

@ -0,0 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_enabled="false" android:color="#999" />
<item android:color="#000"/>
</selector>

View File

@ -0,0 +1,21 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright (C) 2008 The Android Open Source Project
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<CheckedTextView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@android:id/text1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
style="@style/GeckoList.ListItem"/>

View File

@ -3,7 +3,7 @@
- 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/. -->
<resources>
<resources xmlns:android="http://schemas.android.com/apk/res/android">
<!--
Only overriden styles for Honeycomb/Ice cream sandwich are specified here.
@ -22,6 +22,17 @@
<item name="android:listSelector">@drawable/action_bar_button</item>
</style>
<style name="GeckoList.ListItem">
<item name="android:textColor">@color/select_item_multichoice</item>
<item name="android:minHeight">?android:attr/listPreferredItemHeight</item>
<item name="android:textAppearance">?android:attr/textAppearanceLarge</item>
<item name="android:gravity">center_vertical</item>
<item name="android:paddingLeft">12dip</item>
<item name="android:paddingRight">7dip</item>
<item name="android:checkMark">?android:attr/listChoiceIndicatorMultiple</item>
<item name="android:ellipsize">marquee</item>
</style>
<!-- AwesomeBar -->
<style name="AwesomeBar">
<item name="android:layout_width">fill_parent</item>

View File

@ -11,6 +11,19 @@
<item name="android:layout_height">fill_parent</item>
</style>
<style name="GeckoList" parent="android:style/Widget.ListView">
</style>
<style name="GeckoList.ListItem">
<item name="android:minHeight">?android:attr/listPreferredItemHeight</item>
<item name="android:textAppearance">?android:attr/textAppearanceLargeInverse</item>
<item name="android:gravity">center_vertical</item>
<item name="android:paddingLeft">12dip</item>
<item name="android:paddingRight">7dip</item>
<item name="android:checkMark">?android:attr/listChoiceIndicatorMultiple</item>
<item name="android:ellipsize">marquee</item>
</style>
<!-- Horizontal Layout -->
<style name="Layout.Horizontal">
<item name="android:orientation">horizontal</item>

View File

@ -40,6 +40,12 @@
#include "mozilla/net/NeckoCommon.h"
#ifdef XP_MACOSX
// for chflags()
#include <sys/stat.h>
#include <unistd.h>
#endif
using namespace mozilla;
/******************************************************************************
@ -725,6 +731,16 @@ nsCacheProfilePrefObserver::ReadPrefs(nsIPrefBranch* branch)
mDiskCacheParentDirectory = do_QueryInterface(directory, &rv);
}
if (mDiskCacheParentDirectory) {
#ifdef XP_MACOSX
// ensure that this directory is not indexed by Spotlight
// (bug 718910). it may already exist, so we "just do it."
nsAutoCString cachePD;
if (NS_SUCCEEDED(mDiskCacheParentDirectory->GetNativePath(cachePD))) {
if (chflags(cachePD.get(), UF_HIDDEN)) {
NS_WARNING("Failed to set CacheParentDirectory to HIDDEN.");
}
}
#endif
bool firstSmartSizeRun;
rv = branch->GetBoolPref(DISK_CACHE_SMART_SIZE_FIRST_RUN_PREF,
&firstSmartSizeRun);

View File

@ -4,6 +4,8 @@
from __future__ import unicode_literals
import os
from mozbuild.testing.test import TestRunner

View File

@ -1489,8 +1489,6 @@ namespace mozilla {
}
void CleanUpWidgetTracing() {
if (sTracerRunnable)
delete sTracerRunnable;
sTracerRunnable = nullptr;
}