From 8524974786d5a4d28c2e4e0061353365beb26395 Mon Sep 17 00:00:00 2001 From: Cameron Kaiser Date: Wed, 30 Aug 2017 21:38:14 -0700 Subject: [PATCH] #431: M1377257 M1372602 --- gfx/cairo/cairo/src/cairo-rename.h | 1 + gfx/cairo/cairo/src/cairo-scaled-font.c | 20 ++++++++++++++++++++ gfx/cairo/cairo/src/cairo.h | 3 +++ gfx/cairo/cairo/src/cairoint.h | 1 + gfx/thebes/gfxContext.cpp | 5 +---- widget/cocoa/nsChildView.h | 2 +- widget/cocoa/nsChildView.mm | 6 +++--- 7 files changed, 30 insertions(+), 8 deletions(-) diff --git a/gfx/cairo/cairo/src/cairo-rename.h b/gfx/cairo/cairo/src/cairo-rename.h index db20352ea6..0228596c3d 100644 --- a/gfx/cairo/cairo/src/cairo-rename.h +++ b/gfx/cairo/cairo/src/cairo-rename.h @@ -267,6 +267,7 @@ #define cairo_scaled_font_get_font_face _moz_cairo_scaled_font_get_font_face #define cairo_scaled_font_get_font_matrix _moz_cairo_scaled_font_get_font_matrix #define cairo_scaled_font_get_font_options _moz_cairo_scaled_font_get_font_options +#define cairo_scaled_font_get_hint_metrics _moz_cairo_scaled_font_get_hint_metrics #define cairo_scaled_font_get_reference_count _moz_cairo_scaled_font_get_reference_count #define cairo_scaled_font_get_scale_matrix _moz_cairo_scaled_font_get_scale_matrix #define cairo_scaled_font_get_type _moz_cairo_scaled_font_get_type diff --git a/gfx/cairo/cairo/src/cairo-scaled-font.c b/gfx/cairo/cairo/src/cairo-scaled-font.c index 0a2730f66a..b4151890b0 100644 --- a/gfx/cairo/cairo/src/cairo-scaled-font.c +++ b/gfx/cairo/cairo/src/cairo-scaled-font.c @@ -2986,3 +2986,23 @@ cairo_scaled_font_get_font_options (cairo_scaled_font_t *scaled_font, _cairo_font_options_init_copy (options, &scaled_font->options); } slim_hidden_def (cairo_scaled_font_get_font_options); + +/** + * cairo_scaled_font_get_hint_metrics: + * @scaled_font: a #cairo_scaled_font_t + * + * Mozilla extension since the required malloc/free to use + * cairo_scaled_font_get_font_options() above is too slow. + **/ +cairo_public cairo_hint_metrics_t +cairo_scaled_font_get_hint_metrics (cairo_scaled_font_t *scaled_font) +{ + cairo_font_options_t options; + if (scaled_font->status) { + _cairo_font_options_init_default (&options); + } else { + _cairo_font_options_init_copy (&options, &scaled_font->options); + } + return options.hint_metrics; +} +slim_hidden_def (cairo_scaled_font_get_hint_metrics); diff --git a/gfx/cairo/cairo/src/cairo.h b/gfx/cairo/cairo/src/cairo.h index 52d062352a..95a97d8331 100644 --- a/gfx/cairo/cairo/src/cairo.h +++ b/gfx/cairo/cairo/src/cairo.h @@ -1498,6 +1498,9 @@ cairo_public void cairo_scaled_font_get_font_options (cairo_scaled_font_t *scaled_font, cairo_font_options_t *options); +/* mozilla extension, see https://bugzilla.mozilla.org/show_bug.cgi?id=1377257 */ +cairo_public cairo_hint_metrics_t +cairo_scaled_font_get_hint_metrics (cairo_scaled_font_t *scaled_font); /* Toy fonts */ diff --git a/gfx/cairo/cairo/src/cairoint.h b/gfx/cairo/cairo/src/cairoint.h index be78d6d89d..82431274d5 100644 --- a/gfx/cairo/cairo/src/cairoint.h +++ b/gfx/cairo/cairo/src/cairoint.h @@ -2473,6 +2473,7 @@ slim_hidden_proto (cairo_scaled_font_get_ctm); slim_hidden_proto (cairo_scaled_font_get_font_face); slim_hidden_proto (cairo_scaled_font_get_font_matrix); slim_hidden_proto (cairo_scaled_font_get_font_options); +slim_hidden_proto (cairo_scaled_font_get_hint_metrics); slim_hidden_proto (cairo_scaled_font_glyph_extents); slim_hidden_proto_no_warn (cairo_scaled_font_reference); slim_hidden_proto (cairo_scaled_font_status); diff --git a/gfx/thebes/gfxContext.cpp b/gfx/thebes/gfxContext.cpp index c8abfdf760..72a72a1c32 100644 --- a/gfx/thebes/gfxContext.cpp +++ b/gfx/thebes/gfxContext.cpp @@ -1326,11 +1326,8 @@ gfxContext::GetRoundOffsetsToPixels(bool *aRoundX, bool *aRoundY) } // Sometimes hint metrics gets set for us, most notably for printing. - cairo_font_options_t *font_options = cairo_font_options_create(); - cairo_scaled_font_get_font_options(scaled_font, font_options); cairo_hint_metrics_t hint_metrics = - cairo_font_options_get_hint_metrics(font_options); - cairo_font_options_destroy(font_options); + cairo_scaled_font_get_hint_metrics(scaled_font); switch (hint_metrics) { case CAIRO_HINT_METRICS_OFF: diff --git a/widget/cocoa/nsChildView.h b/widget/cocoa/nsChildView.h index fb12ad1638..189564b167 100644 --- a/widget/cocoa/nsChildView.h +++ b/widget/cocoa/nsChildView.h @@ -588,7 +588,7 @@ class nsChildView : public nsBaseWidget NSView* GetEditorView(); #endif - nsCocoaWindow* GetXULWindowWidget(); + nsCocoaWindow* GetXULWindowWidget() const; NS_IMETHOD ReparentNativeWidget(nsIWidget* aNewParent) override; diff --git a/widget/cocoa/nsChildView.mm b/widget/cocoa/nsChildView.mm index 666fae0070..459d0b1aad 100644 --- a/widget/cocoa/nsChildView.mm +++ b/widget/cocoa/nsChildView.mm @@ -906,7 +906,7 @@ virtual void BindAndDrawQuad(ShaderProgramOGL *aProg, } nsCocoaWindow* -nsChildView::GetXULWindowWidget() +nsChildView::GetXULWindowWidget() const { id windowDelegate = [[mView window] delegate]; if (windowDelegate && [windowDelegate isKindOfClass:[WindowDelegate class]]) { @@ -1033,8 +1033,8 @@ static void PrintViewHierarchy(NSView *view) { NS_OBJC_BEGIN_TRY_ABORT_BLOCK_RETURN; - if (!mVisible) { - return mVisible; + if (MOZ_UNLIKELY(!mVisible || !GetXULWindowWidget()->IsVisible())) { + return false; } // mVisible does not accurately reflect the state of a hidden tabbed view