Bug 900592 - Correctly size plugins on Android according to resolution r=kats,bsmedberg a=blassey
authorJames Willcox <snorp@snorp.net>
Wed, 22 Jan 2014 21:15:15 -0600
changeset 167979 85dea29cbde9992e443c792720ab8fceba52f85e
parent 167978 cd615489ee57b9a09a5993408cbc5873bd4b63e4
child 167980 50293ac6deb8302d8a97ff4814cfacdf88334ab4
push id428
push userbbajaj@mozilla.com
push dateTue, 28 Jan 2014 00:16:25 +0000
treeherdermozilla-release@cd72a7ff3a75 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerskats, bsmedberg, blassey
bugs900592
milestone27.0
Bug 900592 - Correctly size plugins on Android according to resolution r=kats,bsmedberg a=blassey
dom/plugins/base/nsPluginInstanceOwner.cpp
layout/base/nsIPresShell.h
layout/base/nsPresShell.cpp
layout/base/nsPresShell.h
--- a/dom/plugins/base/nsPluginInstanceOwner.cpp
+++ b/dom/plugins/base/nsPluginInstanceOwner.cpp
@@ -167,19 +167,18 @@ nsPluginInstanceOwner::GetImageContainer
   // for what we do on other versions.
   if (AndroidBridge::Bridge()->GetAPIVersion() < 11)
     return nullptr;
 
   LayoutDeviceRect r = GetPluginRect();
 
   // NotifySize() causes Flash to do a bunch of stuff like ask for surfaces to render
   // into, set y-flip flags, etc, so we do this at the beginning.
-  float xResolution = mObjectFrame->PresContext()->GetRootPresContext()->PresShell()->GetXResolution();
-  float yResolution = mObjectFrame->PresContext()->GetRootPresContext()->PresShell()->GetYResolution();
-  ScreenSize screenSize = (r * LayoutDeviceToScreenScale(xResolution, yResolution)).Size();
+  gfxSize resolution = static_cast<nsIPresShell_MOZILLA27*>(mObjectFrame->PresContext()->PresShell())->GetCumulativeResolution();
+  ScreenSize screenSize = (r * LayoutDeviceToScreenScale(resolution.width, resolution.height)).Size();
   mInstance->NotifySize(nsIntSize(screenSize.width, screenSize.height));
   
   container = LayerManager::CreateImageContainer();
 
   ImageFormat format = ImageFormat::SHARED_TEXTURE;
   nsRefPtr<Image> img = container->CreateImage(&format, 1);
 
   SharedTextureImage::Data data;
--- a/layout/base/nsIPresShell.h
+++ b/layout/base/nsIPresShell.h
@@ -1601,9 +1601,14 @@ protected:
   nscoord mMaxLineBoxWidth;
   
   // If a document belongs to an invisible DocShell, this flag must be set
   // to true, so we can avoid any paint calls for widget related to this
   // presshell.
   bool mIsNeverPainting;
 };
 
+class nsIPresShell_MOZILLA27 : public nsIPresShell {
+public:
+  virtual gfxSize GetCumulativeResolution() = 0;
+};
+
 #endif /* nsIPresShell_h___ */
--- a/layout/base/nsPresShell.cpp
+++ b/layout/base/nsPresShell.cpp
@@ -5045,17 +5045,27 @@ nsresult PresShell::SetResolution(float 
   if (aXResolution == mXResolution && aYResolution == mYResolution) {
     return NS_OK;
   }
   RenderingState state(this);
   state.mXResolution = aXResolution;
   state.mYResolution = aYResolution;
   SetRenderingState(state);
   return NS_OK;
- }
+}
+
+gfxSize PresShell::GetCumulativeResolution()
+{
+  gfxSize resolution = GetResolution();
+  nsCOMPtr<nsIPresShell> parent = GetParentPresShell();
+  if (parent) {
+    resolution = resolution * static_cast<nsIPresShell_MOZILLA27*>(parent.get())->GetCumulativeResolution();
+  }
+  return resolution;
+} 
 
 void PresShell::SetRenderingState(const RenderingState& aState)
 {
   if (mRenderFlags != aState.mRenderFlags) {
     // Rendering state changed in a way that forces us to flush any
     // retained layers we might already have.
     LayerManager* manager = GetLayerManager();
     if (manager) {
--- a/layout/base/nsPresShell.h
+++ b/layout/base/nsPresShell.h
@@ -49,17 +49,17 @@ class ReflowCountMgr;
 
 class nsPresShellEventCB;
 class nsAutoCauseReflowNotifier;
 
 // 250ms.  This is actually pref-controlled, but we use this value if we fail
 // to get the pref for any reason.
 #define PAINTLOCK_EVENT_DELAY 250
 
-class PresShell : public nsIPresShell,
+class PresShell : public nsIPresShell_MOZILLA27,
                   public nsStubDocumentObserver,
                   public nsISelectionController, public nsIObserver,
                   public nsSupportsWeakReference
 {
 public:
   PresShell();
 
   NS_DECL_AND_IMPL_ZEROING_OPERATOR_NEW
@@ -175,16 +175,17 @@ public:
 
   virtual LayerManager* GetLayerManager() MOZ_OVERRIDE;
 
   virtual void SetIgnoreViewportScrolling(bool aIgnore) MOZ_OVERRIDE;
 
   virtual void SetDisplayPort(const nsRect& aDisplayPort);
 
   virtual nsresult SetResolution(float aXResolution, float aYResolution) MOZ_OVERRIDE;
+  virtual gfxSize GetCumulativeResolution() MOZ_OVERRIDE; // nsIPresShell_MOZILLA27
 
   //nsIViewObserver interface
 
   virtual void Paint(nsView* aViewToPaint, const nsRegion& aDirtyRegion,
                      uint32_t aFlags) MOZ_OVERRIDE;
   virtual nsresult HandleEvent(nsIFrame* aFrame,
                                mozilla::WidgetGUIEvent* aEvent,
                                bool aDontRetargetEvents,