зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1500876 - Remove PContent::GetSystemColors sync IPC. r=snorp,mccr8
Content process of Android uses sync IPC when initializing LookAndFeel. But current e10s has LookAndFeel cache for start up of content process. So we should use it, then remove sync IPC for start up performance Differential Revision: https://phabricator.services.mozilla.com/D9750 --HG-- extra : moz-landing-system : lando
This commit is contained in:
Родитель
59673d02d1
Коммит
90f9f1ea2a
|
@ -3077,26 +3077,6 @@ ContentParent::RecvPlayEventSound(const uint32_t& aEventId)
|
|||
return IPC_OK();
|
||||
}
|
||||
|
||||
mozilla::ipc::IPCResult
|
||||
ContentParent::RecvGetSystemColors(const uint32_t& colorsCount,
|
||||
InfallibleTArray<uint32_t>* colors)
|
||||
{
|
||||
#ifdef MOZ_WIDGET_ANDROID
|
||||
NS_ASSERTION(AndroidBridge::Bridge() != nullptr, "AndroidBridge is not available");
|
||||
if (AndroidBridge::Bridge() == nullptr) {
|
||||
// Do not fail - the colors won't be right, but it's not critical
|
||||
return IPC_OK();
|
||||
}
|
||||
|
||||
colors->AppendElements(colorsCount);
|
||||
|
||||
// The array elements correspond to the members of AndroidSystemColors structure,
|
||||
// so just pass the pointer to the elements buffer
|
||||
AndroidBridge::Bridge()->GetSystemColors((AndroidSystemColors*)colors->Elements());
|
||||
#endif
|
||||
return IPC_OK();
|
||||
}
|
||||
|
||||
mozilla::ipc::IPCResult
|
||||
ContentParent::RecvGetIconForExtension(const nsCString& aFileExt,
|
||||
const uint32_t& aIconSize,
|
||||
|
|
|
@ -1033,9 +1033,6 @@ private:
|
|||
virtual mozilla::ipc::IPCResult RecvBeep() override;
|
||||
virtual mozilla::ipc::IPCResult RecvPlayEventSound(const uint32_t& aEventId) override;
|
||||
|
||||
virtual mozilla::ipc::IPCResult RecvGetSystemColors(const uint32_t& colorsCount,
|
||||
InfallibleTArray<uint32_t>* colors) override;
|
||||
|
||||
virtual mozilla::ipc::IPCResult RecvGetIconForExtension(const nsCString& aFileExt,
|
||||
const uint32_t& aIconSize,
|
||||
InfallibleTArray<uint8_t>* bits) override;
|
||||
|
|
|
@ -892,9 +892,6 @@ parent:
|
|||
async Beep() compress;
|
||||
async PlayEventSound(uint32_t aEventId) compress;
|
||||
|
||||
sync GetSystemColors(uint32_t colorsCount)
|
||||
returns (uint32_t[] colors);
|
||||
|
||||
sync GetIconForExtension(nsCString aFileExt, uint32_t aIconSize)
|
||||
returns (uint8_t[] bits);
|
||||
|
||||
|
|
|
@ -874,8 +874,6 @@ description =
|
|||
description =
|
||||
[PContent::GetExternalClipboardFormats]
|
||||
description = Retrieve supported clipboard formats synchronously
|
||||
[PContent::GetSystemColors]
|
||||
description =
|
||||
[PContent::GetIconForExtension]
|
||||
description =
|
||||
[PContent::GetShowPasswordSetting]
|
||||
|
|
|
@ -19,7 +19,10 @@ struct gfxFontStyle;
|
|||
struct LookAndFeelInt
|
||||
{
|
||||
int32_t id;
|
||||
int32_t value;
|
||||
union {
|
||||
int32_t value;
|
||||
nscolor colorValue;
|
||||
};
|
||||
};
|
||||
|
||||
namespace mozilla {
|
||||
|
|
|
@ -54,30 +54,6 @@ nsLookAndFeel::GetSystemColors()
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsLookAndFeel::CallRemoteGetSystemColors()
|
||||
{
|
||||
// An array has to be used to get data from remote process
|
||||
InfallibleTArray<uint32_t> colors;
|
||||
uint32_t colorsCount = sizeof(AndroidSystemColors) / sizeof(nscolor);
|
||||
|
||||
if (!ContentChild::GetSingleton()->SendGetSystemColors(colorsCount, &colors))
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
NS_ASSERTION(colors.Length() == colorsCount, "System colors array is incomplete");
|
||||
if (colors.Length() == 0)
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
if (colors.Length() < colorsCount)
|
||||
colorsCount = colors.Length();
|
||||
|
||||
// Array elements correspond to the members of mSystemColors structure,
|
||||
// so just copy the memory block
|
||||
memcpy(&mSystemColors, colors.Elements(), sizeof(nscolor) * colorsCount);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
void
|
||||
nsLookAndFeel::NativeInit()
|
||||
{
|
||||
|
@ -520,13 +496,11 @@ void
|
|||
nsLookAndFeel::EnsureInitSystemColors()
|
||||
{
|
||||
if (!mInitializedSystemColors) {
|
||||
nsresult rv;
|
||||
if (XRE_IsParentProcess()) {
|
||||
rv = GetSystemColors();
|
||||
} else {
|
||||
rv = CallRemoteGetSystemColors();
|
||||
nsresult rv = GetSystemColors();
|
||||
mInitializedSystemColors = NS_SUCCEEDED(rv);
|
||||
}
|
||||
mInitializedSystemColors = NS_SUCCEEDED(rv);
|
||||
// Child process will set system color cache from ContentParent.
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -542,3 +516,84 @@ nsLookAndFeel::EnsureInitShowPassword()
|
|||
mInitializedShowPassword = true;
|
||||
}
|
||||
}
|
||||
|
||||
nsTArray<LookAndFeelInt>
|
||||
nsLookAndFeel::GetIntCacheImpl()
|
||||
{
|
||||
MOZ_ASSERT(XRE_IsParentProcess());
|
||||
EnsureInitSystemColors();
|
||||
MOZ_ASSERT(mInitializedSystemColors);
|
||||
|
||||
nsTArray<LookAndFeelInt> lookAndFeelCache =
|
||||
nsXPLookAndFeel::GetIntCacheImpl();
|
||||
lookAndFeelCache.SetCapacity(sizeof(AndroidSystemColors) / sizeof(nscolor));
|
||||
|
||||
LookAndFeelInt laf;
|
||||
laf.id = eColorID_WindowForeground;
|
||||
laf.colorValue = mSystemColors.textColorPrimary;
|
||||
lookAndFeelCache.AppendElement(laf);
|
||||
|
||||
laf.id = eColorID_WidgetBackground;
|
||||
laf.colorValue = mSystemColors.colorBackground;
|
||||
lookAndFeelCache.AppendElement(laf);
|
||||
|
||||
laf.id = eColorID_WidgetForeground;
|
||||
laf.colorValue = mSystemColors.colorForeground;
|
||||
lookAndFeelCache.AppendElement(laf);
|
||||
|
||||
laf.id = eColorID_WidgetSelectBackground;
|
||||
laf.colorValue = mSystemColors.textColorHighlight;
|
||||
lookAndFeelCache.AppendElement(laf);
|
||||
|
||||
laf.id = eColorID_WidgetSelectForeground;
|
||||
laf.colorValue = mSystemColors.textColorPrimaryInverse;
|
||||
lookAndFeelCache.AppendElement(laf);
|
||||
|
||||
laf.id = eColorID_inactivecaptiontext;
|
||||
laf.colorValue = mSystemColors.textColorTertiary;
|
||||
lookAndFeelCache.AppendElement(laf);
|
||||
|
||||
laf.id = eColorID_windowtext;
|
||||
laf.colorValue = mSystemColors.textColorPrimary;
|
||||
lookAndFeelCache.AppendElement(laf);
|
||||
|
||||
// XXX The following colors are unused.
|
||||
// - textColorTertiaryInverse
|
||||
// - panelColorForeground
|
||||
// - panelColorBackground
|
||||
|
||||
return lookAndFeelCache;
|
||||
}
|
||||
|
||||
void
|
||||
nsLookAndFeel::SetIntCacheImpl(const nsTArray<LookAndFeelInt>& aLookAndFeelCache)
|
||||
{
|
||||
for (auto entry : aLookAndFeelCache) {
|
||||
switch (entry.id) {
|
||||
case eColorID_WindowForeground:
|
||||
mSystemColors.textColorPrimary = entry.colorValue;
|
||||
break;
|
||||
case eColorID_WidgetBackground:
|
||||
mSystemColors.colorBackground = entry.colorValue;
|
||||
break;
|
||||
case eColorID_WidgetForeground:
|
||||
mSystemColors.colorForeground = entry.colorValue;
|
||||
break;
|
||||
case eColorID_WidgetSelectBackground:
|
||||
mSystemColors.textColorHighlight = entry.colorValue;
|
||||
break;
|
||||
case eColorID_WidgetSelectForeground:
|
||||
mSystemColors.textColorPrimaryInverse = entry.colorValue;
|
||||
break;
|
||||
case eColorID_inactivecaptiontext:
|
||||
mSystemColors.textColorTertiary = entry.colorValue;
|
||||
break;
|
||||
case eColorID_windowtext:
|
||||
mSystemColors.textColorPrimary = entry.colorValue;
|
||||
break;
|
||||
default:
|
||||
MOZ_ASSERT(false);
|
||||
}
|
||||
}
|
||||
mInitializedSystemColors = true;
|
||||
}
|
||||
|
|
|
@ -24,6 +24,9 @@ public:
|
|||
virtual bool GetEchoPasswordImpl() override;
|
||||
virtual uint32_t GetPasswordMaskDelayImpl() override;
|
||||
virtual char16_t GetPasswordCharacterImpl() override;
|
||||
virtual nsTArray<LookAndFeelInt> GetIntCacheImpl() override;
|
||||
virtual void SetIntCacheImpl(
|
||||
const nsTArray<LookAndFeelInt>& aLookAndFeelIntCache) override;
|
||||
|
||||
void SetPrefersReducedMotionOverrideForTest(bool aValue)
|
||||
{
|
||||
|
@ -45,7 +48,6 @@ protected:
|
|||
static bool mPrefersReducedMotionForTest;
|
||||
|
||||
nsresult GetSystemColors();
|
||||
nsresult CallRemoteGetSystemColors();
|
||||
|
||||
void EnsureInitSystemColors();
|
||||
void EnsureInitShowPassword();
|
||||
|
|
Загрузка…
Ссылка в новой задаче