Bug 1056479 p4 - fix accessibility api for font-weight. r=jfkthame
☠☠ backed out by 6127b1d28cb5 ☠ ☠
authorJohn Daggett <jdaggett@mozilla.com>
Tue, 12 May 2015 14:51:17 +0900
changeset 243459 93bd67204fac4d9a157f02d2aa53a2dd14577795
parent 243458 5260b93eb0b9b8c61bdb39a3c75f174e735f3876
child 243460 0933391809c952884b1d65b0b7bcd2044a2ea7c8
push id28738
push usercbook@mozilla.com
push dateTue, 12 May 2015 14:11:31 +0000
treeherdermozilla-central@bedce1b405a3 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjfkthame
bugs1056479
milestone40.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 1056479 p4 - fix accessibility api for font-weight. r=jfkthame
accessible/base/TextAttrs.cpp
--- a/accessible/base/TextAttrs.cpp
+++ b/accessible/base/TextAttrs.cpp
@@ -13,16 +13,20 @@
 #include "gfxFont.h"
 #include "nsFontMetrics.h"
 #include "nsLayoutUtils.h"
 #include "nsContainerFrame.h"
 #include "HyperTextAccessible.h"
 #include "mozilla/AppUnits.h"
 #include "mozilla/gfx/2D.h"
 
+#if defined(MOZ_WIDGET_GTK)
+#include "gfxPlatformGtk.h" // xxx - for UseFcFontList
+#endif
+
 using namespace mozilla;
 using namespace mozilla::a11y;
 
 ////////////////////////////////////////////////////////////////////////////////
 // TextAttrsMgr
 ////////////////////////////////////////////////////////////////////////////////
 
 void
@@ -623,31 +627,40 @@ TextAttrsMgr::FontWeightTextAttr::
   // When there doesn't exist a bold font in the family and so the rendering of
   // a non-bold font face is changed so that the user sees what looks like a
   // bold font, i.e. synthetic bolding is used. IsSyntheticBold method is only
   // needed on Mac, but it is "safe" to use on all platforms.  (For non-Mac
   // platforms it always return false.)
   if (font->IsSyntheticBold())
     return 700;
 
-#if defined(MOZ_WIDGET_GTK) || defined(MOZ_WIDGET_QT)
-  // On Linux, font->GetStyle()->weight will give the absolute weight requested
-  // of the font face. The Linux code uses the gfxFontEntry constructor which
-  // doesn't initialize the weight field.
-  return font->GetStyle()->weight;
-#else
-  // On Windows, font->GetStyle()->weight will give the same weight as
-  // fontEntry->Weight(), the weight of the first font in the font group, which
-  // may not be the weight of the font face used to render the characters.
-  // On Mac, font->GetStyle()->weight will just give the same number as
-  // getComputedStyle(). fontEntry->Weight() will give the weight of the font
-  // face used.
-  gfxFontEntry *fontEntry = font->GetFontEntry();
-  return fontEntry->Weight();
+  bool useFontEntryWeight = true;
+
+  // Under Linux, when gfxPangoFontGroup code is used,
+  // font->GetStyle()->weight will give the absolute weight requested of the
+  // font face. The gfxPangoFontGroup code uses the gfxFontEntry constructor
+  // which doesn't initialize the weight field.
+#if defined(MOZ_WIDGET_QT)
+  useFontEntryWeight = false;
+#elif defined(MOZ_WIDGET_GTK)
+  useFontEntryWeight = gfxPlatformGtk::UseFcFontList();
 #endif
+
+  if (useFontEntryWeight) {
+    // On Windows, font->GetStyle()->weight will give the same weight as
+    // fontEntry->Weight(), the weight of the first font in the font group,
+    // which may not be the weight of the font face used to render the
+    // characters. On Mac, font->GetStyle()->weight will just give the same
+    // number as getComputedStyle(). fontEntry->Weight() will give the weight
+    // of the font face used.
+    gfxFontEntry *fontEntry = font->GetFontEntry();
+    return fontEntry->Weight();
+  } else {
+    return font->GetStyle()->weight;
+  }
 }
 
 ////////////////////////////////////////////////////////////////////////////////
 // AutoGeneratedTextAttr
 ////////////////////////////////////////////////////////////////////////////////
 TextAttrsMgr::AutoGeneratedTextAttr::
   AutoGeneratedTextAttr(HyperTextAccessible* aHyperTextAcc,
                         Accessible* aAccessible) :