Bug 1175940 - UIResolutionChanged should not trigger sync messages from content to chrome. r=mconley

This commit is contained in:
Gabor Krizsanits 2015-08-13 16:42:19 +02:00
parent 5d9d0a3ebd
commit bb874971f0
5 changed files with 18 additions and 8 deletions

View File

@ -723,8 +723,13 @@ child:
/** /**
* Tell the child that the UI resolution changed for the containing * Tell the child that the UI resolution changed for the containing
* window. * window.
* To avoid some sync messages from child to parent, we also send the dpi
* and default scale with the notification.
* If we don't know the dpi and default scale, we just pass in a negative
* value (-1) but in the majority of the cases this saves us from two
* sync requests from the child to the parent.
*/ */
UIResolutionChanged(); UIResolutionChanged(float dpi, double scale);
/** /**
* Tell the child that the system theme has changed, and that a repaint * Tell the child that the system theme has changed, and that a repaint

View File

@ -2904,12 +2904,12 @@ TabChild::RecvRequestNotifyAfterRemotePaint()
} }
bool bool
TabChild::RecvUIResolutionChanged() TabChild::RecvUIResolutionChanged(const float& aDpi, const double& aScale)
{ {
ScreenIntSize oldScreenSize = GetInnerSize(); ScreenIntSize oldScreenSize = GetInnerSize();
mDPI = 0; mDPI = 0;
mDefaultScale = 0; mDefaultScale = 0;
static_cast<PuppetWidget*>(mPuppetWidget.get())->ClearBackingScaleCache(); static_cast<PuppetWidget*>(mPuppetWidget.get())->UpdateBackingScaleCache(aDpi, aScale);
nsCOMPtr<nsIDocument> document(GetDocument()); nsCOMPtr<nsIDocument> document(GetDocument());
nsCOMPtr<nsIPresShell> presShell = document->GetShell(); nsCOMPtr<nsIPresShell> presShell = document->GetShell();
if (presShell) { if (presShell) {

View File

@ -472,7 +472,7 @@ public:
return GetFrom(docShell); return GetFrom(docShell);
} }
virtual bool RecvUIResolutionChanged() override; virtual bool RecvUIResolutionChanged(const float& aDpi, const double& aScale) override;
virtual bool RecvThemeChanged(nsTArray<LookAndFeelInt>&& aLookAndFeelIntCache) override; virtual bool RecvThemeChanged(nsTArray<LookAndFeelInt>&& aLookAndFeelIntCache) override;

View File

@ -1059,7 +1059,11 @@ TabParent::UIResolutionChanged()
// mDPI being greater than 0, so this invalidates it. // mDPI being greater than 0, so this invalidates it.
mDPI = -1; mDPI = -1;
TryCacheDPIAndScale(); TryCacheDPIAndScale();
unused << SendUIResolutionChanged(); // If mDPI was set to -1 to invalidate it and then TryCacheDPIAndScale
// fails to cache the values, then mDefaultScale.scale might be invalid.
// We don't want to send that value to content. Just send -1 for it too in
// that case.
unused << SendUIResolutionChanged(mDPI, mDPI < 0 ? -1.0 : mDefaultScale.scale);
} }
} }

View File

@ -196,10 +196,11 @@ public:
virtual bool NeedsPaint() override; virtual bool NeedsPaint() override;
virtual TabChild* GetOwningTabChild() override { return mTabChild; } virtual TabChild* GetOwningTabChild() override { return mTabChild; }
virtual void ClearBackingScaleCache()
void UpdateBackingScaleCache(float aDpi, double aScale)
{ {
mDPI = -1; mDPI = aDpi;
mDefaultScale = -1; mDefaultScale = aScale;
} }
nsIntSize GetScreenDimensions(); nsIntSize GetScreenDimensions();