Bug 1056479 p4 - fix accessibility api for font-weight. r=jfkthame

This commit is contained in:
John Daggett 2015-05-12 14:51:17 +09:00
parent 7154781e42
commit 95ca0097bc

View File

@ -18,6 +18,10 @@
#include "mozilla/AppUnits.h" #include "mozilla/AppUnits.h"
#include "mozilla/gfx/2D.h" #include "mozilla/gfx/2D.h"
#if defined(MOZ_WIDGET_GTK)
#include "gfxPlatformGtk.h" // xxx - for UseFcFontList
#endif
using namespace mozilla; using namespace mozilla;
using namespace mozilla::a11y; using namespace mozilla::a11y;
@ -628,21 +632,30 @@ TextAttrsMgr::FontWeightTextAttr::
if (font->IsSyntheticBold()) if (font->IsSyntheticBold())
return 700; return 700;
#if defined(MOZ_WIDGET_GTK) || defined(MOZ_WIDGET_QT) bool useFontEntryWeight = true;
// On Linux, font->GetStyle()->weight will give the absolute weight requested
// of the font face. The Linux code uses the gfxFontEntry constructor which // Under Linux, when gfxPangoFontGroup code is used,
// doesn't initialize the weight field. // font->GetStyle()->weight will give the absolute weight requested of the
return font->GetStyle()->weight; // font face. The gfxPangoFontGroup code uses the gfxFontEntry constructor
#else // which doesn't initialize the weight field.
// On Windows, font->GetStyle()->weight will give the same weight as #if defined(MOZ_WIDGET_QT)
// fontEntry->Weight(), the weight of the first font in the font group, which useFontEntryWeight = false;
// may not be the weight of the font face used to render the characters. #elif defined(MOZ_WIDGET_GTK)
// On Mac, font->GetStyle()->weight will just give the same number as useFontEntryWeight = gfxPlatformGtk::UseFcFontList();
// getComputedStyle(). fontEntry->Weight() will give the weight of the font
// face used.
gfxFontEntry *fontEntry = font->GetFontEntry();
return fontEntry->Weight();
#endif #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;
}
} }
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////