Bug 1096093 - Add infrastructure for LookAndFeel metric caching, and allowing the parent process to send down cache to content process. r=jimm.

This commit is contained in:
Mike Conley 2015-04-22 10:58:15 -04:00
parent 8d1c0b939a
commit 188eaa0301
9 changed files with 104 additions and 2 deletions

View File

@ -23,6 +23,7 @@
#ifdef ACCESSIBILITY
#include "mozilla/a11y/DocAccessibleChild.h"
#endif
#include "mozilla/LookAndFeel.h"
#include "mozilla/Preferences.h"
#include "mozilla/ProcessHangMonitorIPC.h"
#include "mozilla/docshell/OfflineCacheUpdateChild.h"
@ -53,6 +54,7 @@
#include "mozilla/net/NeckoChild.h"
#include "mozilla/plugins/PluginInstanceParent.h"
#include "mozilla/plugins/PluginModuleParent.h"
#include "mozilla/widget/WidgetMessageUtils.h"
#if defined(MOZ_CONTENT_SANDBOX)
#if defined(XP_WIN)

View File

@ -76,6 +76,7 @@
#include "mozilla/layers/CompositorParent.h"
#include "mozilla/layers/ImageBridgeParent.h"
#include "mozilla/layers/SharedBufferManagerParent.h"
#include "mozilla/LookAndFeel.h"
#include "mozilla/net/NeckoParent.h"
#include "mozilla/plugins/PluginBridge.h"
#include "mozilla/Preferences.h"
@ -2887,6 +2888,7 @@ ContentParent::RecvAddNewProcess(const uint32_t& aPid,
InfallibleTArray<nsString> unusedDictionaries;
ClipboardCapabilities clipboardCaps;
DomainPolicyClone domainPolicy;
RecvGetXPCOMProcessAttributes(&isOffline, &isLangRTL, &unusedDictionaries,
&clipboardCaps, &domainPolicy);
mozilla::unused << content->SendSetOffline(isOffline);
@ -4037,6 +4039,13 @@ ContentParent::RecvGetSystemMemory(const uint64_t& aGetterId)
return true;
}
bool
ContentParent::RecvGetLookAndFeelCache(nsTArray<LookAndFeelInt>&& aLookAndFeelIntCache)
{
aLookAndFeelIntCache = LookAndFeel::GetIntCache();
return true;
}
bool
ContentParent::RecvIsSecureURI(const uint32_t& type,
const URIParams& uri,

View File

@ -543,8 +543,7 @@ private:
bool* aIsLangRTL,
InfallibleTArray<nsString>* dictionaries,
ClipboardCapabilities* clipboardCaps,
DomainPolicyClone* domainPolicy)
override;
DomainPolicyClone* domainPolicy) override;
virtual bool DeallocPJavaScriptParent(mozilla::jsipc::PJavaScriptParent*) override;
@ -756,6 +755,8 @@ private:
const bool& aHidden) override;
virtual bool RecvGetSystemMemory(const uint64_t& getterId) override;
virtual bool RecvGetLookAndFeelCache(nsTArray<LookAndFeelInt>&& aLookAndFeelIntCache) override;
virtual bool RecvDataStoreGetStores(
const nsString& aName,
const nsString& aOwner,

View File

@ -87,6 +87,7 @@ using mozilla::hal::ProcessPriority from "mozilla/HalTypes.h";
using gfxIntSize from "nsSize.h";
using mozilla::dom::TabId from "mozilla/dom/ipc/IdType.h";
using mozilla::dom::ContentParentId from "mozilla/dom/ipc/IdType.h";
using struct LookAndFeelInt from "mozilla/widget/WidgetMessageUtils.h";
union ChromeRegistryItem
{
@ -690,6 +691,8 @@ parent:
sync IsSecureURI(uint32_t type, URIParams uri, uint32_t flags)
returns (bool isSecureURI);
sync GetLookAndFeelCache(LookAndFeelInt[] lookAndFeelIntCache);
PHal();
PIcc(uint32_t serviceId);

View File

@ -15,6 +15,12 @@
struct gfxFontStyle;
struct LookAndFeelInt
{
int32_t id;
int32_t value;
};
namespace mozilla {
class LookAndFeel
@ -583,6 +589,13 @@ public:
* cached data would be released.
*/
static void Refresh();
/**
* If the implementation is caching values, these accessors allow the
* cache to be exported and imported.
*/
static nsTArray<LookAndFeelInt> GetIntCache();
static void SetIntCache(const nsTArray<LookAndFeelInt>& aLookAndFeelIntCache);
};
} // namespace mozilla

View File

@ -0,0 +1,39 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#ifndef mozilla_WidgetMessageUtils_h
#define mozilla_WidgetMessageUtils_h
#include "ipc/IPCMessageUtils.h"
#include "mozilla/LookAndFeel.h"
namespace IPC {
template<>
struct ParamTraits<LookAndFeelInt>
{
typedef LookAndFeelInt paramType;
static void Write(Message* aMsg, const paramType& aParam)
{
WriteParam(aMsg, aParam.id);
WriteParam(aMsg, aParam.value);
}
static bool Read(const Message* aMsg, void** aIter, paramType* aResult)
{
int32_t id, value;
if (ReadParam(aMsg, aIter, &id) &&
ReadParam(aMsg, aIter, &value)) {
aResult->id = id;
aResult->value = value;
return true;
}
return false;
}
};
} // namespace IPC
#endif // WidgetMessageUtils_h

View File

@ -133,6 +133,7 @@ EXPORTS.mozilla += [
EXPORTS.mozilla.widget += [
'PuppetBidiKeyboard.h',
'WidgetMessageUtils.h',
]
UNIFIED_SOURCES += [

View File

@ -13,6 +13,7 @@
#include "nsFont.h"
#include "mozilla/Preferences.h"
#include "mozilla/gfx/2D.h"
#include "mozilla/widget/WidgetMessageUtils.h"
#include "gfxPlatform.h"
#include "qcms.h"
@ -453,6 +454,15 @@ nsXPLookAndFeel::Init()
if (NS_SUCCEEDED(Preferences::GetBool("ui.use_native_colors", &val))) {
sUseNativeColors = val;
}
if (XRE_GetProcessType() == GeckoProcessType_Content) {
mozilla::dom::ContentChild* cc =
mozilla::dom::ContentChild::GetSingleton();
nsTArray<LookAndFeelInt> lookAndFeelIntCache;
cc->SendGetLookAndFeelCache(lookAndFeelIntCache);
LookAndFeel::SetIntCache(lookAndFeelIntCache);
}
}
nsXPLookAndFeel::~nsXPLookAndFeel()
@ -703,6 +713,12 @@ nsXPLookAndFeel::RefreshImpl()
sCachedColorBits[i] = 0;
}
nsTArray<LookAndFeelInt>
nsXPLookAndFeel::GetIntCacheImpl()
{
return nsTArray<LookAndFeelInt>();
}
namespace mozilla {
// static
@ -763,4 +779,18 @@ LookAndFeel::Refresh()
nsLookAndFeel::GetInstance()->RefreshImpl();
}
// static
nsTArray<LookAndFeelInt>
LookAndFeel::GetIntCache()
{
return nsLookAndFeel::GetInstance()->GetIntCacheImpl();
}
// static
void
LookAndFeel::SetIntCache(const nsTArray<LookAndFeelInt>& aLookAndFeelIntCache)
{
return nsLookAndFeel::GetInstance()->SetIntCacheImpl(aLookAndFeelIntCache);
}
} // namespace mozilla

View File

@ -7,6 +7,7 @@
#define __nsXPLookAndFeel
#include "mozilla/LookAndFeel.h"
#include "nsTArray.h"
class nsLookAndFeel;
@ -79,6 +80,9 @@ public:
return 600;
}
virtual nsTArray<LookAndFeelInt> GetIntCacheImpl();
virtual void SetIntCacheImpl(const nsTArray<LookAndFeelInt>& aLookAndFeelIntCache) {}
protected:
nsXPLookAndFeel();