Bug 1350643 - Part 7: Remove sync GetDPI/DefaultScale/WidgetRounding. Use primary screen's value until RecvShow. r=kanru

MozReview-Commit-ID: GlDMNecWp3j

--HG--
extra : rebase_source : 1f8573df8845c100172f41febc5a84bbcd069769
This commit is contained in:
Samael Wang 2017-05-19 18:20:18 +08:00
Родитель f41a004bb1
Коммит e90e4d4b15
10 изменённых файлов: 37 добавлений и 156 удалений

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

@ -2726,6 +2726,11 @@ nsFrameLoader::UpdatePositionAndSize(nsSubDocumentFrame *aIFrame)
if (IsRemoteFrame()) {
if (mRemoteBrowser) {
ScreenIntSize size = aIFrame->GetSubdocumentSize();
// If we were not able to show remote frame before, we should probably
// retry now to send correct showInfo.
if (!mRemoteBrowserShown) {
ShowRemoteFrame(size, aIFrame);
}
nsIntRect dimensions;
NS_ENSURE_SUCCESS(GetWindowDimensions(dimensions), NS_ERROR_FAILURE);
mLazySize = size;

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

@ -1020,8 +1020,9 @@ ContentChild::ProvideWindowCommon(TabChild* aTabOpener,
nsCOMPtr<nsILoadContext> context = do_QueryInterface(openerShell);
showInfo = ShowInfo(EmptyString(), false,
context->UsePrivateBrowsing(), true, false,
aTabOpener->mDPI, aTabOpener->mRounding,
aTabOpener->mDefaultScale);
aTabOpener->WebWidget()->GetDPI(),
aTabOpener->WebWidget()->RoundsWidgetCoordinatesTo(),
aTabOpener->WebWidget()->GetDefaultScale().scale);
}
newChild->SetMaxTouchPoints(maxTouchPoints);

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

@ -359,21 +359,6 @@ parent:
sync IsParentWindowMainWidgetVisible() returns (bool visible);
/**
* Gets the DPI of the screen corresponding to this browser.
*/
sync GetDPI() returns (float value);
/**
* Gets the default scaling factor of the screen corresponding to this browser.
*/
sync GetDefaultScale() returns (double value);
/**
* Gets the rounding of coordinates in the widget.
*/
sync GetWidgetRounding() returns (int32_t value);
/**
* Set the native cursor.
* @param value

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

@ -390,9 +390,6 @@ TabChild::TabChild(nsIContentChild* aManager,
, mHasValidInnerSize(false)
, mDestroyed(false)
, mUniqueId(aTabId)
, mDPI(0)
, mRounding(0)
, mDefaultScale(0)
, mIsTransparent(false)
, mIPCOpen(false)
, mParentIsActive(false)
@ -1135,6 +1132,15 @@ TabChild::DoFakeShow(const TextureFactoryIdentifier& aTextureFactoryIdentifier,
void
TabChild::ApplyShowInfo(const ShowInfo& aInfo)
{
// Even if we already set real show info, the dpi / rounding & scale may still
// be invalid (if TabParent wasn't able to get widget it would just send 0).
// So better to always set up-to-date values here.
if (aInfo.dpi() > 0) {
mPuppetWidget->UpdateBackingScaleCache(aInfo.dpi(),
aInfo.widgetRounding(),
aInfo.defaultScale());
}
if (mDidSetRealShowInfo) {
return;
}
@ -1175,9 +1181,6 @@ TabChild::ApplyShowInfo(const ShowInfo& aInfo)
}
}
}
mDPI = aInfo.dpi();
mRounding = aInfo.widgetRounding();
mDefaultScale = aInfo.defaultScale();
mIsTransparent = aInfo.isTransparent();
}
@ -2691,56 +2694,6 @@ TabChild::InitAPZState()
cbc->SendPAPZConstructor(apzChild, mLayersId);
}
void
TabChild::GetDPI(float* aDPI)
{
*aDPI = -1.0;
if (!(mDidFakeShow || mDidSetRealShowInfo)) {
return;
}
if (mDPI > 0) {
*aDPI = mDPI;
return;
}
// Fallback to a sync call if needed.
SendGetDPI(aDPI);
}
void
TabChild::GetDefaultScale(double* aScale)
{
*aScale = -1.0;
if (!(mDidFakeShow || mDidSetRealShowInfo)) {
return;
}
if (mDefaultScale > 0) {
*aScale = mDefaultScale;
return;
}
// Fallback to a sync call if needed.
SendGetDefaultScale(aScale);
}
void
TabChild::GetWidgetRounding(int32_t* aRounding)
{
*aRounding = 1;
if (!(mDidFakeShow || mDidSetRealShowInfo)) {
return;
}
if (mRounding > 0) {
*aRounding = mRounding;
return;
}
// Fallback to a sync call if needed.
SendGetWidgetRounding(aRounding);
}
void
TabChild::NotifyPainted()
{
@ -3138,10 +3091,9 @@ TabChild::RecvUIResolutionChanged(const float& aDpi,
const double& aScale)
{
ScreenIntSize oldScreenSize = GetInnerSize();
mDPI = 0;
mRounding = 0;
mDefaultScale = 0;
static_cast<PuppetWidget*>(mPuppetWidget.get())->UpdateBackingScaleCache(aDpi, aRounding, aScale);
if (aDpi > 0) {
mPuppetWidget->UpdateBackingScaleCache(aDpi, aRounding, aScale);
}
nsCOMPtr<nsIDocument> document(GetDocument());
nsCOMPtr<nsIPresShell> presShell = document->GetShell();
if (presShell) {

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

@ -502,13 +502,6 @@ public:
virtual PuppetWidget* WebWidget() override { return mPuppetWidget; }
/** Return the DPI of the widget this TabChild draws to. */
void GetDPI(float* aDPI);
void GetDefaultScale(double *aScale);
void GetWidgetRounding(int32_t* aRounding);
bool IsTransparent() const { return mIsTransparent; }
void GetMaxTouchPoints(uint32_t* aTouchPoints)
@ -855,9 +848,6 @@ private:
Maybe<mozilla::layers::CompositorOptions> mCompositorOptions;
friend class ContentChild;
float mDPI;
int32_t mRounding;
double mDefaultScale;
bool mIsTransparent;

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

@ -2349,39 +2349,6 @@ TabParent::RecvIsParentWindowMainWidgetVisible(bool* aIsVisible)
return IPC_OK();
}
mozilla::ipc::IPCResult
TabParent::RecvGetDPI(float* aValue)
{
TryCacheDPIAndScale();
MOZ_ASSERT(mDPI > 0 || mFrameElement,
"Must not ask for DPI before OwnerElement is received!");
*aValue = mDPI;
return IPC_OK();
}
mozilla::ipc::IPCResult
TabParent::RecvGetDefaultScale(double* aValue)
{
TryCacheDPIAndScale();
MOZ_ASSERT(mDefaultScale.scale > 0 || mFrameElement,
"Must not ask for scale before OwnerElement is received!");
*aValue = mDefaultScale.scale;
return IPC_OK();
}
mozilla::ipc::IPCResult
TabParent::RecvGetWidgetRounding(int32_t* aValue)
{
TryCacheDPIAndScale();
MOZ_ASSERT(mRounding > 0 || mFrameElement,
"Must not ask for rounding before OwnerElement is received!");
*aValue = mRounding;
return IPC_OK();
}
already_AddRefed<nsIWidget>
TabParent::GetTopLevelWidget()
{

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

@ -299,11 +299,6 @@ public:
virtual mozilla::ipc::IPCResult RecvHideTooltip() override;
virtual mozilla::ipc::IPCResult RecvGetDPI(float* aValue) override;
virtual mozilla::ipc::IPCResult RecvGetDefaultScale(double* aValue) override;
virtual mozilla::ipc::IPCResult RecvGetWidgetRounding(int32_t* aValue) override;
virtual mozilla::ipc::IPCResult RecvSetNativeChildOfShareableWindow(const uintptr_t& childWindow) override;

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

@ -279,6 +279,11 @@ nsDeviceContext::SetDPI(double* aScale)
mAppUnitsPerDevPixelAtUnitFullZoom =
NS_lround((AppUnitsPerCSSPixel() * 96) / dpi);
} else {
nsCOMPtr<nsIScreen> primaryScreen;
ScreenManager& screenManager = ScreenManager::GetSingleton();
screenManager.GetPrimaryScreen(getter_AddRefs(primaryScreen));
MOZ_ASSERT(primaryScreen);
// A value of -1 means use the maximum of 96 and the system DPI.
// A value of 0 means use the system DPI. A positive value is used as the DPI.
// This sets the physical size of a device pixel and thus controls the
@ -288,8 +293,13 @@ nsDeviceContext::SetDPI(double* aScale)
if (prefDPI > 0) {
dpi = prefDPI;
} else if (mWidget) {
// PuppetWidget could return -1 if the value's not available yet.
dpi = mWidget->GetDPI();
// In case that the widget returns -1, use the primary screen's
// value as default.
if (dpi < 0) {
primaryScreen->GetDpi(&dpi);
}
if (prefDPI < 0) {
dpi = std::max(96.0f, dpi);
}
@ -308,6 +318,11 @@ nsDeviceContext::SetDPI(double* aScale)
mWidget ? mWidget->GetDefaultScale()
: CSSToLayoutDeviceScale(1.0);
devPixelsPerCSSPixel = scale.scale;
// In case that the widget returns -1, use the primary screen's
// value as default.
if (devPixelsPerCSSPixel < 0) {
primaryScreen->GetDefaultCSSScaleFactor(&devPixelsPerCSSPixel);
}
if (aScale) {
*aScale = devPixelsPerCSSPixel;
}

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

@ -833,11 +833,6 @@ description =
description =
[PBrowser::IsParentWindowMainWidgetVisible]
description =
[PBrowser::GetDPI]
description =
[PBrowser::GetDefaultScale]
description =
[PBrowser::GetWidgetRounding]
description =
[PBrowser::RequestNativeKeyBindings]
description =

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

@ -88,7 +88,7 @@ PuppetWidget::PuppetWidget(TabChild* aTabChild)
: mTabChild(aTabChild)
, mMemoryPressureObserver(nullptr)
, mDPI(-1)
, mRounding(-1)
, mRounding(1)
, mDefaultScale(-1)
, mCursorHotspotX(0)
, mCursorHotspotY(0)
@ -1152,42 +1152,18 @@ PuppetWidget::NeedsPaint()
float
PuppetWidget::GetDPI()
{
if (mDPI < 0) {
if (mTabChild) {
mTabChild->GetDPI(&mDPI);
} else {
mDPI = 96.0;
}
}
return mDPI;
}
double
PuppetWidget::GetDefaultScaleInternal()
{
if (mDefaultScale < 0) {
if (mTabChild) {
mTabChild->GetDefaultScale(&mDefaultScale);
} else {
mDefaultScale = 1;
}
}
return mDefaultScale;
}
int32_t
PuppetWidget::RoundsWidgetCoordinatesTo()
{
if (mRounding < 0) {
if (mTabChild) {
mTabChild->GetWidgetRounding(&mRounding);
} else {
mRounding = 1;
}
}
return mRounding;
}