Bug 940036 - 3rd party gaia apps should set a meta-viewport tag. r=kats
authorVivien Nicolas <vnicolas@mozilla.com>
Tue, 03 Dec 2013 16:10:26 +0100
changeset 173455 f33904f2323d941e52ef3f8fa7a67410fafde16c
parent 173454 4771c427c785c88d0f1950ad3303a125d1028069
child 173456 30a98b93ba256498bdbeef2008c4c469beda973c
push id3224
push userlsblakk@mozilla.com
push dateTue, 04 Feb 2014 01:06:49 +0000
treeherdermozilla-beta@60c04d0987f1 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerskats
bugs940036
milestone28.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 940036 - 3rd party gaia apps should set a meta-viewport tag. r=kats
content/base/public/nsViewportInfo.h
content/base/src/nsDocument.cpp
content/base/src/nsDocument.h
--- a/content/base/public/nsViewportInfo.h
+++ b/content/base/public/nsViewportInfo.h
@@ -20,20 +20,21 @@ static const int32_t  kViewportDefaultSc
 
 /**
  * Information retrieved from the <meta name="viewport"> tag. See
  * nsContentUtils::GetViewportInfo for more information on this functionality.
  */
 class MOZ_STACK_CLASS nsViewportInfo
 {
   public:
-    nsViewportInfo(const mozilla::ScreenIntSize& aDisplaySize) :
+    nsViewportInfo(const mozilla::ScreenIntSize& aDisplaySize,
+                   bool aAllowZoom = true) :
       mDefaultZoom(1.0),
       mAutoSize(true),
-      mAllowZoom(true)
+      mAllowZoom(aAllowZoom)
     {
         mSize = mozilla::gfx::RoundedToInt(mozilla::ScreenSize(aDisplaySize) / mDefaultZoom);
         mozilla::CSSToLayoutDeviceScale pixelRatio(1.0f);
         mMinZoom = pixelRatio * kViewportMinScale;
         mMaxZoom = pixelRatio * kViewportMaxScale;
         ConstrainViewportValues();
     }
 
--- a/content/base/src/nsDocument.cpp
+++ b/content/base/src/nsDocument.cpp
@@ -6826,16 +6826,18 @@ nsIDocument::AdoptNode(nsINode& aAdopted
 }
 
 nsViewportInfo
 nsDocument::GetViewportInfo(const ScreenIntSize& aDisplaySize)
 {
   switch (mViewportType) {
   case DisplayWidthHeight:
     return nsViewportInfo(aDisplaySize);
+  case DisplayWidthHeightNoZoom:
+    return nsViewportInfo(aDisplaySize, /* allowZoom */ false);
   case Unknown:
   {
     nsAutoString viewport;
     GetHeaderData(nsGkAtoms::viewport, viewport);
     if (viewport.IsEmpty()) {
       // If the docType specifies that we are on a site optimized for mobile,
       // then we want to return specially crafted defaults for the viewport info.
       nsCOMPtr<nsIDOMDocumentType> docType;
@@ -6856,16 +6858,31 @@ nsDocument::GetViewportInfo(const Screen
       }
 
       nsAutoString handheldFriendly;
       GetHeaderData(nsGkAtoms::handheldFriendly, handheldFriendly);
       if (handheldFriendly.EqualsLiteral("true")) {
         mViewportType = DisplayWidthHeight;
         return nsViewportInfo(aDisplaySize);
       }
+
+      // Bug 940036. This is bad. When FirefoxOS was built, apps installed
+      // where not using the AsyncPanZoom code. As a result a lot of apps
+      // in the marketplace does not use it yet and instead are built to
+      // render correctly in FirefoxOS only. For a smooth transition the above
+      // code force installed apps to render as if they have a viewport with
+      // content="width=device-width, height=device-height, user-scalable=no".
+      // This could be safely remove once it is known that most apps in the
+      // marketplace use it and that users does not use an old version of the
+      // app that does not use it.
+      nsCOMPtr<nsIDocShell> docShell(mDocumentContainer);
+      if (docShell && docShell->GetIsApp()) {
+        mViewportType = DisplayWidthHeightNoZoom;
+        return nsViewportInfo(aDisplaySize, /* allowZoom */ false);
+      }
     }
 
     nsAutoString minScaleStr;
     GetHeaderData(nsGkAtoms::viewport_minimum_scale, minScaleStr);
 
     nsresult errorCode;
     mScaleMinFloat = LayoutDeviceToScreenScale(minScaleStr.ToFloat(&errorCode));
 
--- a/content/base/src/nsDocument.h
+++ b/content/base/src/nsDocument.h
@@ -1385,16 +1385,17 @@ private:
 
   // Tracking for plugins in the document.
   nsTHashtable< nsPtrHashKey<nsIObjectLoadingContent> > mPlugins;
 
   nsRefPtr<mozilla::dom::UndoManager> mUndoManager;
 
   enum ViewportType {
     DisplayWidthHeight,
+    DisplayWidthHeightNoZoom,
     Specified,
     Unknown
   };
 
   ViewportType mViewportType;
 
   // These member variables cache information about the viewport so we don't have to
   // recalculate it each time.