Bug 762221: Enable font hinting for "app" processes. r=jfkthame,jlebar

This commit is contained in:
Chris Jones 2012-08-23 01:22:19 -07:00
parent 201d23326e
commit 9c75d27a17
6 changed files with 55 additions and 22 deletions

View File

@ -225,6 +225,8 @@ ContentChild::ContentChild()
#ifdef ANDROID
,mScreenSize(0, 0)
#endif
, mIsForApp(false)
, mIsForBrowser(false)
{
// This process is a content process, so it's clearly running in
// multiprocess mode!
@ -920,12 +922,16 @@ ContentChild::RecvAppInfo(const nsCString& version, const nsCString& buildID)
}
bool
ContentChild::RecvSetID(const uint64_t &id)
ContentChild::RecvSetProcessAttributes(const uint64_t &id,
const bool& aIsForApp,
const bool& aIsForBrowser)
{
if (mID != uint64_t(-1)) {
NS_WARNING("Setting content child's ID twice?");
}
mID = id;
mIsForApp = aIsForApp;
mIsForBrowser = aIsForBrowser;
return true;
}

View File

@ -157,7 +157,9 @@ public:
virtual bool RecvCycleCollect();
virtual bool RecvAppInfo(const nsCString& version, const nsCString& buildID);
virtual bool RecvSetID(const uint64_t &id);
virtual bool RecvSetProcessAttributes(const uint64_t& id,
const bool& aIsForApp,
const bool& aIsForBrowser);
virtual bool RecvLastPrivateDocShellDestroyed();
@ -174,6 +176,9 @@ public:
uint64_t GetID() { return mID; }
bool IsForApp() { return mIsForApp; }
bool IsForBrowser() { return mIsForBrowser; }
BlobChild* GetOrCreateActorForBlob(nsIDOMBlob* aBlob);
private:
@ -205,6 +210,9 @@ private:
gfxIntSize mScreenSize;
#endif
bool mIsForApp;
bool mIsForBrowser;
static ContentChild* sSingleton;
DISALLOW_EVIL_CONSTRUCTORS(ContentChild);

View File

@ -186,7 +186,8 @@ ContentParent::PreallocateAppProcess()
}
sPreallocatedAppProcess =
new ContentParent(MAGIC_PREALLOCATED_APP_MANIFEST_URL);
new ContentParent(MAGIC_PREALLOCATED_APP_MANIFEST_URL,
/*isBrowserElement=*/false);
sPreallocatedAppProcess->Init();
}
@ -248,7 +249,7 @@ ContentParent::ShutDown()
}
/*static*/ ContentParent*
ContentParent::GetNewOrUsed()
ContentParent::GetNewOrUsed(bool aForBrowserElement)
{
if (!gNonAppContentParents)
gNonAppContentParents = new nsTArray<ContentParent*>();
@ -265,7 +266,8 @@ ContentParent::GetNewOrUsed()
}
nsRefPtr<ContentParent> p =
new ContentParent(/* appManifestURL = */ EmptyString());
new ContentParent(/* appManifestURL = */ EmptyString(),
aForBrowserElement);
p->Init();
gNonAppContentParents->AppendElement(p);
return p;
@ -274,8 +276,14 @@ ContentParent::GetNewOrUsed()
/*static*/ TabParent*
ContentParent::CreateBrowser(mozIApplication* aApp, bool aIsBrowserElement)
{
// We currently don't set the <app> ancestor for <browser> content
// correctly. This assertion is to notify the person who fixes
// this code that they need to reevaluate places here where we may
// make bad assumptions based on that bug.
MOZ_ASSERT(!aApp || !aIsBrowserElement);
if (!aApp) {
if (ContentParent* cp = GetNewOrUsed()) {
if (ContentParent* cp = GetNewOrUsed(aIsBrowserElement)) {
nsRefPtr<TabParent> tp(new TabParent(aApp, aIsBrowserElement));
return static_cast<TabParent*>(
cp->SendPBrowserConstructor(
@ -321,7 +329,7 @@ ContentParent::CreateBrowser(mozIApplication* aApp, bool aIsBrowserElement)
p->SetManifestFromPreallocated(manifestURL);
} else {
NS_WARNING("Unable to use pre-allocated app process");
p = new ContentParent(manifestURL);
p = new ContentParent(manifestURL, aIsBrowserElement);
p->Init();
}
gAppContentParents->Put(manifestURL, p);
@ -647,7 +655,8 @@ ContentParent::GetTestShellSingleton()
return static_cast<TestShellParent*>(ManagedPTestShellParent()[0]);
}
ContentParent::ContentParent(const nsAString& aAppManifestURL)
ContentParent::ContentParent(const nsAString& aAppManifestURL,
bool aIsForBrowser)
: mGeolocationWatchID(-1)
, mRunToCompletionDepth(0)
, mShouldCallUnblockChild(false)
@ -671,7 +680,8 @@ ContentParent::ContentParent(const nsAString& aAppManifestURL)
mSubprocess->AsyncLaunch();
}
Open(mSubprocess->GetChannel(), mSubprocess->GetChildProcessHandle());
unused << SendSetID(gContentChildID++);
unused << SendSetProcessAttributes(gContentChildID++,
IsForApp(), aIsForBrowser);
// NB: internally, this will send an IPC message to the child
// process to get it to create the CompositorChild. This

View File

@ -65,7 +65,7 @@ public:
/** Shut down the content-process machinery. */
static void ShutDown();
static ContentParent* GetNewOrUsed();
static ContentParent* GetNewOrUsed(bool aForBrowserElement = false);
/**
* Get or create a content process for the given app descriptor,
@ -129,7 +129,7 @@ private:
using PContentParent::SendPBrowserConstructor;
using PContentParent::SendPTestShellConstructor;
ContentParent(const nsAString& aAppManifestURL);
ContentParent(const nsAString& aAppManifestURL, bool aIsForBrowser);
virtual ~ContentParent();
void Init();

View File

@ -192,6 +192,17 @@ child:
PTestShell();
/**
* Tell the content process some attributes of itself. This is
* the first message received by content processes after startup.
*
* |id| is a unique ID among all subprocesses. When |isForApp &&
* isForBrowser|, we're loading <browser> for an app. When
* |isForBrowser|, we're loading <browser>. When |!isForApp &&
* !isForBrowser|, we're probably loading <xul:browser remote>.
*/
SetProcessAttributes(uint64_t id, bool isForApp, bool isForBrowser);
RegisterChrome(ChromePackage[] packages, ResourceMapping[] resources,
OverrideMapping[] overrides, nsCString locale);
@ -222,8 +233,6 @@ child:
AppInfo(nsCString version, nsCString buildID);
SetID(uint64_t id);
// Notify child that last-pb-context-exited notification was observed
LastPrivateDocShellDestroyed();

View File

@ -3,11 +3,14 @@
* 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/basictypes.h"
#include "gfxAndroidPlatform.h"
#include "mozilla/gfx/2D.h"
#include "gfxFT2FontList.h"
#include "gfxImageSurface.h"
#include "mozilla/dom/ContentChild.h"
#include "nsXULAppAPI.h"
#include "nsIScreen.h"
#include "nsIScreenManager.h"
@ -17,6 +20,7 @@
#include "ft2build.h"
#include FT_FREETYPE_H
using namespace mozilla;
using namespace mozilla::dom;
using namespace mozilla::gfx;
static FT_Library gPlatformFTLibrary = NULL;
@ -190,15 +194,11 @@ gfxAndroidPlatform::FontHintingEnabled()
// want to re-enable hinting.
return false;
#else
// Otherwise, if we're in a content process, assume we don't want
// hinting.
//
// XXX when we use content processes to load "apps", we'll want to
// configure this dynamically based on whether we're an "app
// content process" or a "browser content process". The former
// wants hinting, the latter doesn't since it might be
// non-reflow-zoomed.
return (XRE_GetProcessType() != GeckoProcessType_Content);
// Otherwise, enable hinting unless we're in a content process
// that might be used for non-reflowing zoom.
return (XRE_GetProcessType() != GeckoProcessType_Content ||
(ContentChild::GetSingleton()->IsForApp() &&
!ContentChild::GetSingleton()->IsForBrowser()));
#endif // MOZ_USING_ANDROID_JAVA_WIDGETS
}