Bug 1328868 - Part 3 - Make the effective text zoom retrievable from JS. r?tnikkel draft
authorJan Henning <jh+bugzilla@buttercookie.de>
Sat, 25 Feb 2017 19:27:15 +0100
changeset 508546 da6c324443797c8c5225220caeae3413312a7f94
parent 508545 cc6fc40bf63b9bfb6ee42bfe2eb833952317664f
child 508547 0e780ee88267d5c3ebb1077474a8057c1866c452
child 551340 6480950afebf0c74284e66778eda3c4b20c0db1e
child 551348 de70a37fa4106fa84b61c263dfc2f64e86c73f62
push id50868
push usermozilla@buttercookie.de
push dateFri, 24 Mar 2017 17:08:10 +0000
reviewerstnikkel
bugs1328868
milestone55.0a1
Bug 1328868 - Part 3 - Make the effective text zoom retrievable from JS. r?tnikkel We want to read this value during testing. MozReview-Commit-ID: FVA7VdvSTEt
docshell/base/nsIContentViewer.idl
layout/base/nsDocumentViewer.cpp
toolkit/content/widgets/browser.xml
--- a/docshell/base/nsIContentViewer.idl
+++ b/docshell/base/nsIContentViewer.idl
@@ -195,16 +195,19 @@ interface nsIContentViewer : nsISupports
   /*
   Scrolls to a given DOM content node. 
   */
   void scrollToNode(in nsIDOMNode node);
 
   /** The amount by which to scale all text. Default is 1.0. */
   attribute float textZoom;
 
+  /** The actual text zoom in effect, as modified by the system font scale. */
+  readonly attribute float effectiveTextZoom;
+
   /** The amount by which to scale all lengths. Default is 1.0. */
   attribute float fullZoom;
 
   /**
    * The value used to override devicePixelRatio and media queries dppx.
    * Default is 0.0, that means no overriding is done (only a positive value
    * is applied).
    */
--- a/layout/base/nsDocumentViewer.cpp
+++ b/layout/base/nsDocumentViewer.cpp
@@ -3012,16 +3012,25 @@ nsDocumentViewer::GetTextZoom(float* aTe
 {
   NS_ENSURE_ARG_POINTER(aTextZoom);
   nsPresContext* pc = GetPresContext();
   *aTextZoom = pc ? pc->TextZoom() : 1.0f;
   return NS_OK;
 }
 
 NS_IMETHODIMP
+nsDocumentViewer::GetEffectiveTextZoom(float* aEffectiveTextZoom)
+{
+  NS_ENSURE_ARG_POINTER(aEffectiveTextZoom);
+  nsPresContext* pc = GetPresContext();
+  *aEffectiveTextZoom = pc ? pc->EffectiveTextZoom() : 1.0f;
+  return NS_OK;
+}
+
+NS_IMETHODIMP
 nsDocumentViewer::SetMinFontSize(int32_t aMinFontSize)
 {
   // If we don't have a document, then we need to bail.
   if (!mDocument) {
     return NS_ERROR_FAILURE;
   }
 
   if (GetIsPrintPreview()) {
--- a/toolkit/content/widgets/browser.xml
+++ b/toolkit/content/widgets/browser.xml
@@ -547,16 +547,23 @@
         <getter><![CDATA[
           return this.markupDocumentViewer.textZoom;
         ]]></getter>
         <setter><![CDATA[
           this.markupDocumentViewer.textZoom = val;
         ]]></setter>
       </property>
 
+      <property name="effectiveTextZoom"
+                readonly="true">
+        <getter><![CDATA[
+          return this.markupDocumentViewer.effectiveTextZoom;
+        ]]></getter>
+      </property>
+
       <property name="isSyntheticDocument">
         <getter><![CDATA[
           return this.contentDocument.mozSyntheticDocument;
         ]]></getter>
       </property>
 
       <property name="hasContentOpener">
         <getter><![CDATA[