servo: Merge #16724 - style: Re-enable font metrics querying for ch and ex units in Stylo traversal (from heycam:reenable-metrics); r=bholley
authorCameron McCormack <cam@mcc.id.au>
Thu, 04 May 2017 03:46:28 -0500
changeset 356476 366d1dc1f33e55c6b4c93c1ef0ebe4834c3c9df6
parent 356475 579a36c00c58d6175932905a8f4c2260ad2c1989
child 356477 8f8cb62a874903f66603da14326bfc52326c30f9
push id31767
push usercbook@mozilla.com
push dateFri, 05 May 2017 13:15:58 +0000
treeherdermozilla-central@8872ad4d52b6 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbholley
milestone55.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
servo: Merge #16724 - style: Re-enable font metrics querying for ch and ex units in Stylo traversal (from heycam:reenable-metrics); r=bholley From https://bugzilla.mozilla.org/show_bug.cgi?id=1356103. Source-Repo: https://github.com/servo/servo Source-Revision: ca277aabe6c32f025da585b909b308336181d6e2
servo/components/style/gecko/wrapper.rs
--- a/servo/components/style/gecko/wrapper.rs
+++ b/servo/components/style/gecko/wrapper.rs
@@ -17,17 +17,17 @@
 use app_units::Au;
 use atomic_refcell::AtomicRefCell;
 use context::{QuirksMode, SharedStyleContext, UpdateAnimationsTasks};
 use data::ElementData;
 use dom::{self, AnimationRules, DescendantsBit, LayoutIterator, NodeInfo, TElement, TNode, UnsafeNode};
 use dom::{OpaqueNode, PresentationalHintsSynthetizer};
 use element_state::ElementState;
 use error_reporting::RustLogReporter;
-use font_metrics::{FontMetricsProvider, FontMetricsQueryResult};
+use font_metrics::{FontMetrics, FontMetricsProvider, FontMetricsQueryResult};
 use gecko::global_style_data::GLOBAL_STYLE_DATA;
 use gecko::selector_parser::{SelectorImpl, NonTSPseudoClass, PseudoElement};
 use gecko::snapshot_helpers;
 use gecko_bindings::bindings;
 use gecko_bindings::bindings::{Gecko_DropStyleChildrenIterator, Gecko_MaybeCreateStyleChildrenIterator};
 use gecko_bindings::bindings::{Gecko_ElementState, Gecko_GetLastChild, Gecko_GetNextStyleChild};
 use gecko_bindings::bindings::{Gecko_IsRootElement, Gecko_MatchesElement, Gecko_Namespace};
 use gecko_bindings::bindings::{Gecko_SetNodeFlags, Gecko_UnsetNodeFlags};
@@ -471,35 +471,32 @@ impl FontMetricsProvider for GeckoFontMe
         }
         let sizes = unsafe {
             Gecko_GetBaseSize(font_name.as_ptr())
         };
         cache.push((font_name.clone(), sizes));
         sizes.size_for_generic(font_family)
     }
 
-    fn query(&self, _font: &Font, _font_size: Au, _wm: WritingMode,
-             _in_media_query: bool, _device: &Device) -> FontMetricsQueryResult {
-        // Disabled until we can make font metrics thread safe (bug 1356105)
-        //
-        // use gecko_bindings::bindings::Gecko_GetFontMetrics;
-        // let gecko_metrics = unsafe {
-        //     Gecko_GetFontMetrics(&*device.pres_context,
-        //                          wm.is_vertical() && !wm.is_sideways(),
-        //                          font.gecko(),
-        //                          font_size.0,
-        //                          // we don't use the user font set in a media query
-        //                          !in_media_query)
-        // };
-        // let metrics = FontMetrics {
-        //     x_height: Au(gecko_metrics.mXSize),
-        //     zero_advance_measure: Au(gecko_metrics.mChSize),
-        // };
-        // FontMetricsQueryResult::Available(metrics)
-        FontMetricsQueryResult::NotAvailable
+    fn query(&self, font: &Font, font_size: Au, wm: WritingMode,
+             in_media_query: bool, device: &Device) -> FontMetricsQueryResult {
+        use gecko_bindings::bindings::Gecko_GetFontMetrics;
+        let gecko_metrics = unsafe {
+            Gecko_GetFontMetrics(&*device.pres_context,
+                                 wm.is_vertical() && !wm.is_sideways(),
+                                 font.gecko(),
+                                 font_size.0,
+                                 // we don't use the user font set in a media query
+                                 !in_media_query)
+        };
+        let metrics = FontMetrics {
+            x_height: Au(gecko_metrics.mXSize),
+            zero_advance_measure: Au(gecko_metrics.mChSize),
+        };
+        FontMetricsQueryResult::Available(metrics)
     }
 }
 
 impl structs::FontSizePrefs {
     fn size_for_generic(&self, font_family: u8) -> Au {
         Au(match font_family {
             structs::kPresContext_DefaultVariableFont_ID => self.mDefaultVariableSize,
             structs::kPresContext_DefaultFixedFont_ID => self.mDefaultFixedSize,