Bug 655877 - Part 31d: Hook SVG text scaling into CSS text frames. r=roc
authorCameron McCormack <cam@mcc.id.au>
Mon, 11 Feb 2013 17:22:17 +1100
changeset 121492 0e81334f73d1137a7d412e5216d80888ba42d03f
parent 121491 53005a0154076fbad15da799ebaafb6f1f5bc5ca
child 121493 9bc717b46687dec44940b912c56b757eb2a5d11e
push id24291
push userryanvm@gmail.com
push dateMon, 11 Feb 2013 19:12:51 +0000
treeherdermozilla-central@93ba23f414ff [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersroc
bugs655877
milestone21.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 655877 - Part 31d: Hook SVG text scaling into CSS text frames. r=roc
layout/base/nsLayoutUtils.cpp
--- a/layout/base/nsLayoutUtils.cpp
+++ b/layout/base/nsLayoutUtils.cpp
@@ -72,16 +72,17 @@
 #include "nsDataHashtable.h"
 #include "nsTextFrame.h"
 #include "nsFontFaceList.h"
 #include "nsFontInflationData.h"
 #include "nsSVGUtils.h"
 #include "nsSVGIntegrationUtils.h"
 #include "nsSVGForeignObjectFrame.h"
 #include "nsSVGOuterSVGFrame.h"
+#include "nsSVGTextFrame2.h"
 #include "nsStyleStructInlines.h"
 
 #include "mozilla/dom/PBrowserChild.h"
 #include "mozilla/dom/TabChild.h"
 #include "mozilla/Preferences.h"
 
 #ifdef MOZ_XUL
 #include "nsXULPopupManager.h"
@@ -5285,18 +5286,28 @@ nsLayoutUtils::InflationMinFontSizeFor(c
   NS_ABORT_IF_FALSE(false, "root should always be container");
 
   return 0;
 }
 
 float
 nsLayoutUtils::FontSizeInflationFor(const nsIFrame *aFrame)
 {
+  if (aFrame->IsSVGText()) {
+    const nsIFrame* container = aFrame;
+    while (container->GetType() != nsGkAtoms::svgTextFrame2) {
+      container = container->GetParent();
+    }
+    NS_ASSERTION(container, "expected to find an ancestor nsSVGTextFrame2");
+    return
+      static_cast<const nsSVGTextFrame2*>(container)->GetFontSizeScaleFactor();
+  }
+
   if (!FontSizeInflationEnabled(aFrame->PresContext())) {
-    return 1.0;
+    return 1.0f;
   }
 
   return FontSizeInflationInner(aFrame, InflationMinFontSizeFor(aFrame));
 }
 
 /* static */ bool
 nsLayoutUtils::FontSizeInflationEnabled(nsPresContext *aPresContext)
 {