Bug 1525662 - Part 3: Provide a hook for treating missing viewport specification as an explicit "width=device-width". r=botond
☠☠ backed out by 10f3bcf2a0ed ☠ ☠
authorJan Henning <jh+bugzilla@buttercookie.de>
Tue, 05 Mar 2019 18:01:13 +0000
changeset 520312 aaa8fbdbbe48b39e1323f1b0bd741a537b45b860
parent 520311 f07e25fac5b20976178fb2e4dd7f95a6e252207a
child 520313 32249c69fee9c516735e98805141c073750b107f
push id10862
push userffxbld-merge
push dateMon, 11 Mar 2019 13:01:11 +0000
treeherdermozilla-beta@a2e7f5c935da [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbotond
bugs1525662
milestone67.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 1525662 - Part 3: Provide a hook for treating missing viewport specification as an explicit "width=device-width". r=botond Ordinarily, when a page doesn't explicitly specify its viewport dimensions using a <meta> viewport tag, we treat is as a non-mobile-friendly desktop page and do some special viewport handling. For some document types however we might want to override that behaviour and treat the page as if "<meta name="viewport" content="width=device-width>" had explicitly been specified anyway. Differential Revision: https://phabricator.services.mozilla.com/D20953
dom/base/Document.cpp
dom/base/Document.h
--- a/dom/base/Document.cpp
+++ b/dom/base/Document.cpp
@@ -6476,16 +6476,18 @@ nsINode* Document::AdoptNode(nsINode& aA
   }
 
   NS_ASSERTION(adoptedNode->OwnerDoc() == this,
                "Should still be in the document we just got adopted into");
 
   return adoptedNode;
 }
 
+bool Document::UseWidthDeviceWidthFallbackViewport() const { return false; }
+
 void Document::ParseWidthAndHeightInMetaViewport(
     const nsAString& aWidthString, const nsAString& aHeightString,
     const nsAString& aScaleString) {
   // The width and height properties
   // https://drafts.csswg.org/css-device-adapt/#width-and-height-properties
   //
   // The width and height viewport <META> properties are translated into width
   // and height descriptors, setting the min-width/min-height value to
@@ -6515,16 +6517,19 @@ void Document::ParseWidthAndHeightInMeta
       }
     }
     // FIXME: Check the scale is not 'auto' once we support auto value for it.
   } else if (!aScaleString.IsEmpty()) {
     if (aHeightString.IsEmpty()) {
       mMinWidth = nsViewportInfo::ExtendToZoom;
       mMaxWidth = nsViewportInfo::ExtendToZoom;
     }
+  } else if (aHeightString.IsEmpty() && UseWidthDeviceWidthFallbackViewport()) {
+    mMinWidth = nsViewportInfo::ExtendToZoom;
+    mMaxWidth = nsViewportInfo::DeviceSize;
   }
 
   mMinHeight = nsViewportInfo::Auto;
   mMaxHeight = nsViewportInfo::Auto;
   if (!aHeightString.IsEmpty()) {
     mMinHeight = nsViewportInfo::ExtendToZoom;
     if (aHeightString.EqualsLiteral("device-height")) {
       mMaxHeight = nsViewportInfo::DeviceSize;
--- a/dom/base/Document.h
+++ b/dom/base/Document.h
@@ -3595,16 +3595,23 @@ class Document : public nsINode,
    * This method is virtual so that XULDocument can
    * override it.
    */
   virtual void InitialDocumentTranslationCompleted();
 
  protected:
   RefPtr<mozilla::dom::DocumentL10n> mDocumentL10n;
 
+  /**
+   * Return true when you want a document without explicitly specified viewport
+   * dimensions/scale to be treated as if "width=device-width" had in fact been
+   * specified.
+   */
+  virtual bool UseWidthDeviceWidthFallbackViewport() const;
+
  private:
   void InitializeLocalization(nsTArray<nsString>& aResourceIds);
 
   void ParseWidthAndHeightInMetaViewport(const nsAString& aWidthString,
                                          const nsAString& aHeightString,
                                          const nsAString& aScaleString);
 
   mozilla::dom::FlashClassification DocumentFlashClassificationInternal();