Skip to content

Commit f7a791e

Browse files
committed
Merge autoland to mozilla-central. a=merge
2 parents 0e79668 + 01ba78d commit f7a791e

File tree

7,224 files changed

+17047
-12299
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

7,224 files changed

+17047
-12299
lines changed

browser/components/places/tests/browser/browser.ini

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ skip-if = os == "linux" && (tsan || asan) # Bug 1714384
7777
skip-if = os == "linux" && (tsan || asan) # Bug 1714384
7878
[browser_controller_onDrop_tagFolder.js]
7979
[browser_controller_onDrop.js]
80-
skip-if = os == "linux" && (tsan || asan) # Bug 1714384
80+
skip-if = os == "linux" && debug # Bug 1714384
8181
[browser_copy_query_without_tree.js]
8282
skip-if = os == "linux" && (tsan || asan) # Bug 1714384
8383
[browser_cutting_bookmarks.js]

browser/themes/shared/preferences/preferences.inc.css

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1208,6 +1208,11 @@ richlistitem .text-link:hover {
12081208
line-height: 1.4em;
12091209
}
12101210

1211+
#moreFromMozillaCategory:not([hidden]) {
1212+
display: flex;
1213+
flex-direction: column;
1214+
}
1215+
12111216
#moreFromMozillaCategory .mozilla-product-item {
12121217
margin-top: 30px;
12131218
}

devtools/client/debugger/src/components/shared/ResultList.css

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,10 +46,6 @@
4646
color: white;
4747
}
4848

49-
.theme-dark .result-list.small li.selected {
50-
background-color: var(--theme-body-background);
51-
}
52-
5349
.theme-dark .result-list li:hover {
5450
background: var(--grey-70);
5551
}

gfx/wr/webrender/src/glyph_rasterizer/mod.rs

Lines changed: 115 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -604,8 +604,8 @@ impl FontInstance {
604604
}
605605

606606
#[allow(dead_code)]
607-
pub fn get_extra_strikes(&self, x_scale: f64) -> usize {
608-
if self.flags.contains(FontInstanceFlags::SYNTHETIC_BOLD) {
607+
pub fn get_extra_strikes(&self, flags: FontInstanceFlags, x_scale: f64) -> usize {
608+
if self.flags.intersects(flags) {
609609
let mut bold_offset = self.size.to_f64_px() / 48.0;
610610
if bold_offset < 1.0 {
611611
bold_offset = 0.25 + 0.75 * bold_offset;
@@ -772,6 +772,119 @@ impl GlyphFormat {
772772
}
773773
}
774774

775+
#[allow(dead_code)]
776+
#[inline]
777+
fn blend_strike_pixel(dest: u8, src: u32, src_alpha: u32) -> u8 {
778+
// Assume premultiplied alpha such that src and dest are already multiplied
779+
// by their respective alpha values and in range 0..=255. The rounded over
780+
// blend is then (src * 255 + dest * (255 - src_alpha) + 128) / 255.
781+
// We approximate (x + 128) / 255 as (x + 128 + ((x + 128) >> 8)) >> 8.
782+
let x = src * 255 + dest as u32 * (255 - src_alpha) + 128;
783+
((x + (x >> 8)) >> 8) as u8
784+
}
785+
786+
// Blends a single strike at a given offset into a destination buffer, assuming
787+
// the destination has been allocated with enough extra space to accommodate the
788+
// offset.
789+
#[allow(dead_code)]
790+
fn blend_strike(
791+
dest_bitmap: &mut [u8],
792+
src_bitmap: &[u8],
793+
width: usize,
794+
height: usize,
795+
subpixel_mask: bool,
796+
offset: f64,
797+
) {
798+
let dest_stride = dest_bitmap.len() / height;
799+
let src_stride = width * 4;
800+
let offset_integer = offset.floor() as usize * 4;
801+
let offset_fract = (offset.fract() * 256.0) as u32;
802+
for (src_row, dest_row) in src_bitmap.chunks(src_stride).zip(dest_bitmap.chunks_mut(dest_stride)) {
803+
let mut prev_px = [0u32; 4];
804+
let dest_row_offset = &mut dest_row[offset_integer .. offset_integer + src_stride];
805+
for (src, dest) in src_row.chunks(4).zip(dest_row_offset.chunks_mut(4)) {
806+
let px = [src[0] as u32, src[1] as u32, src[2] as u32, src[3] as u32];
807+
// Blend current pixel with previous pixel based on fractional offset.
808+
let next_px = [px[0] * offset_fract,
809+
px[1] * offset_fract,
810+
px[2] * offset_fract,
811+
px[3] * offset_fract];
812+
let offset_px = [(((px[0] << 8) - next_px[0]) + prev_px[0] + 128) >> 8,
813+
(((px[1] << 8) - next_px[1]) + prev_px[1] + 128) >> 8,
814+
(((px[2] << 8) - next_px[2]) + prev_px[2] + 128) >> 8,
815+
(((px[3] << 8) - next_px[3]) + prev_px[3] + 128) >> 8];
816+
if subpixel_mask {
817+
// Subpixel masks assume each component is an independent weight.
818+
dest[0] = blend_strike_pixel(dest[0], offset_px[0], offset_px[0]);
819+
dest[1] = blend_strike_pixel(dest[1], offset_px[1], offset_px[1]);
820+
dest[2] = blend_strike_pixel(dest[2], offset_px[2], offset_px[2]);
821+
dest[3] = blend_strike_pixel(dest[3], offset_px[3], offset_px[3]);
822+
} else {
823+
// Otherwise assume we have a premultiplied alpha BGRA value.
824+
dest[0] = blend_strike_pixel(dest[0], offset_px[0], offset_px[3]);
825+
dest[1] = blend_strike_pixel(dest[1], offset_px[1], offset_px[3]);
826+
dest[2] = blend_strike_pixel(dest[2], offset_px[2], offset_px[3]);
827+
dest[3] = blend_strike_pixel(dest[3], offset_px[3], offset_px[3]);
828+
}
829+
// Save the remainder for blending onto the next pixel.
830+
prev_px = next_px;
831+
}
832+
if offset_fract > 0 {
833+
// When there is fractional offset, there will be a remaining value
834+
// from the previous pixel but no next pixel, so just use that.
835+
let dest = &mut dest_row[offset_integer + src_stride .. ];
836+
let offset_px = [(prev_px[0] + 128) >> 8,
837+
(prev_px[1] + 128) >> 8,
838+
(prev_px[2] + 128) >> 8,
839+
(prev_px[3] + 128) >> 8];
840+
if subpixel_mask {
841+
dest[0] = blend_strike_pixel(dest[0], offset_px[0], offset_px[0]);
842+
dest[1] = blend_strike_pixel(dest[1], offset_px[1], offset_px[1]);
843+
dest[2] = blend_strike_pixel(dest[2], offset_px[2], offset_px[2]);
844+
dest[3] = blend_strike_pixel(dest[3], offset_px[3], offset_px[3]);
845+
} else {
846+
dest[0] = blend_strike_pixel(dest[0], offset_px[0], offset_px[3]);
847+
dest[1] = blend_strike_pixel(dest[1], offset_px[1], offset_px[3]);
848+
dest[2] = blend_strike_pixel(dest[2], offset_px[2], offset_px[3]);
849+
dest[3] = blend_strike_pixel(dest[3], offset_px[3], offset_px[3]);
850+
}
851+
}
852+
}
853+
}
854+
855+
// Applies multistrike bold to a source bitmap. This assumes the source bitmap
856+
// is a tighly packed slice of BGRA pixel values of exactly the specified width
857+
// and height. The specified extra strikes and pixel step control where to put
858+
// each strike. The pixel step is allowed to have a fractional offset and does
859+
// not strictly need to be integer.
860+
#[allow(dead_code)]
861+
pub fn apply_multistrike_bold(
862+
src_bitmap: &[u8],
863+
width: usize,
864+
height: usize,
865+
subpixel_mask: bool,
866+
extra_strikes: usize,
867+
pixel_step: f64,
868+
) -> (Vec<u8>, usize) {
869+
let src_stride = width * 4;
870+
// The amount of extra width added to the bitmap from the extra strikes.
871+
let extra_width = (extra_strikes as f64 * pixel_step).ceil() as usize;
872+
let dest_width = width + extra_width;
873+
let dest_stride = dest_width * 4;
874+
// Zero out the initial bitmap so any extra width is cleared.
875+
let mut dest_bitmap = vec![0u8; dest_stride * height];
876+
for (src_row, dest_row) in src_bitmap.chunks(src_stride).zip(dest_bitmap.chunks_mut(dest_stride)) {
877+
// Copy the initial bitmap strike rows directly from the source.
878+
dest_row[0 .. src_stride].copy_from_slice(src_row);
879+
}
880+
// Finally blend each extra strike in turn.
881+
for i in 1 ..= extra_strikes {
882+
let offset = i as f64 * pixel_step;
883+
blend_strike(&mut dest_bitmap, src_bitmap, width, height, subpixel_mask, offset);
884+
}
885+
(dest_bitmap, dest_width)
886+
}
887+
775888
pub struct RasterizedGlyph {
776889
pub top: f32,
777890
pub left: f32,

gfx/wr/webrender/src/platform/macos/font.rs

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -507,7 +507,10 @@ impl FontContext {
507507
} else {
508508
(x_scale, y_scale / x_scale)
509509
};
510-
let extra_strikes = font.get_extra_strikes(strike_scale);
510+
let extra_strikes = font.get_extra_strikes(
511+
FontInstanceFlags::SYNTHETIC_BOLD | FontInstanceFlags::MULTISTRIKE_BOLD,
512+
strike_scale,
513+
);
511514
let metrics = get_glyph_metrics(
512515
&ct_font,
513516
transform.as_ref(),
@@ -673,8 +676,10 @@ impl FontContext {
673676
} else {
674677
(x_scale, y_scale / x_scale)
675678
};
676-
677-
let extra_strikes = font.get_extra_strikes(strike_scale);
679+
let extra_strikes = font.get_extra_strikes(
680+
FontInstanceFlags::SYNTHETIC_BOLD | FontInstanceFlags::MULTISTRIKE_BOLD,
681+
strike_scale,
682+
);
678683
let metrics = get_glyph_metrics(
679684
&ct_font,
680685
transform.as_ref(),

gfx/wr/webrender/src/platform/windows/font.rs

Lines changed: 61 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,11 @@
55
use api::{FontInstanceFlags, FontKey, FontRenderMode, FontVariation};
66
use api::{ColorU, GlyphDimensions, NativeFontHandle};
77
use dwrote;
8-
use crate::gamma_lut::ColorLut;
8+
use crate::gamma_lut::{ColorLut, GammaLut};
99
use crate::glyph_rasterizer::{FontInstance, FontTransform, GlyphKey};
10-
use crate::internal_types::{FastHashMap, FastHashSet, ResourceCacheError};
1110
use crate::glyph_rasterizer::{GlyphFormat, GlyphRasterError, GlyphRasterResult, RasterizedGlyph};
12-
use crate::gamma_lut::GammaLut;
11+
use crate::glyph_rasterizer::apply_multistrike_bold;
12+
use crate::internal_types::{FastHashMap, FastHashSet, ResourceCacheError};
1313
use std::borrow::Borrow;
1414
use std::collections::hash_map::Entry;
1515
use std::hash::{Hash, Hasher};
@@ -377,7 +377,7 @@ impl FontContext {
377377
font: &FontInstance,
378378
key: &GlyphKey,
379379
) -> Option<GlyphDimensions> {
380-
let (size, _, bitmaps, transform) = Self::get_glyph_parameters(font, key);
380+
let (size, x_scale, y_scale, bitmaps, transform) = Self::get_glyph_parameters(font, key);
381381
let (_, _, bounds) = self.create_glyph_analysis(font, key, size, transform, bitmaps).ok()?;
382382

383383
let width = (bounds.right - bounds.left) as i32;
@@ -389,6 +389,14 @@ impl FontContext {
389389
return None;
390390
}
391391

392+
let (strike_scale, pixel_step) = if bitmaps {
393+
(y_scale, 1.0)
394+
} else {
395+
(x_scale, y_scale / x_scale)
396+
};
397+
let extra_strikes = font.get_extra_strikes(FontInstanceFlags::MULTISTRIKE_BOLD, strike_scale);
398+
let extra_width = extra_strikes as f64 * pixel_step;
399+
392400
let face = self.get_font_face(font);
393401
face.get_design_glyph_metrics(&[key.index() as u16], false)
394402
.first()
@@ -401,9 +409,9 @@ impl FontContext {
401409
GlyphDimensions {
402410
left: bounds.left,
403411
top: -bounds.top,
404-
width,
412+
width: width + extra_width.ceil() as i32,
405413
height,
406-
advance,
414+
advance: advance + extra_width as f32,
407415
}
408416
})
409417
}
@@ -418,14 +426,9 @@ impl FontContext {
418426
render_mode: FontRenderMode,
419427
bitmaps: bool,
420428
subpixel_bgr: bool,
421-
texture_padding: bool,
422-
) -> Vec<u8> {
423-
let (buffer_width, buffer_height, padding) = if texture_padding {
424-
(width + 2, height + 2, 1)
425-
} else {
426-
(width, height, 0)
427-
};
428-
429+
padding: usize,
430+
) -> (Vec<u8>, bool) {
431+
let (buffer_width, buffer_height) = (width + padding * 2, height + padding * 2);
429432
let buffer_length = buffer_width * buffer_height * 4;
430433
let mut bgra_pixels: Vec<u8> = vec![0; buffer_length];
431434

@@ -445,6 +448,7 @@ impl FontContext {
445448
bgra_pixels[offset + 3] = alpha;
446449
}
447450
}
451+
(bgra_pixels, false)
448452
}
449453
(_, FontRenderMode::Subpixel, false) => {
450454
assert!(width * height * 3 == pixels.len());
@@ -464,6 +468,7 @@ impl FontContext {
464468
bgra_pixels[offset + 3] = 0xff;
465469
}
466470
}
471+
(bgra_pixels, true)
467472
}
468473
_ => {
469474
assert!(width * height * 3 == pixels.len());
@@ -481,9 +486,9 @@ impl FontContext {
481486
bgra_pixels[offset + 3] = alpha;
482487
}
483488
}
489+
(bgra_pixels, false)
484490
}
485-
};
486-
bgra_pixels
491+
}
487492
}
488493

489494
pub fn prepare_font(font: &mut FontInstance) {
@@ -503,8 +508,9 @@ impl FontContext {
503508
}
504509
}
505510

506-
fn get_glyph_parameters(font: &FontInstance, key: &GlyphKey) -> (f32, f64, bool, Option<dwrote::DWRITE_MATRIX>) {
507-
let (_, y_scale) = font.transform.compute_scale().unwrap_or((1.0, 1.0));
511+
fn get_glyph_parameters(font: &FontInstance, key: &GlyphKey)
512+
-> (f32, f64, f64, bool, Option<dwrote::DWRITE_MATRIX>) {
513+
let (x_scale, y_scale) = font.transform.compute_scale().unwrap_or((1.0, 1.0));
508514
let scaled_size = font.size.to_f64_px() * y_scale;
509515
let bitmaps = is_bitmap_font(font);
510516
let (mut shape, (mut x_offset, mut y_offset)) = if bitmaps {
@@ -542,14 +548,14 @@ impl FontContext {
542548
} else {
543549
None
544550
};
545-
(scaled_size as f32, y_scale, bitmaps, transform)
551+
(scaled_size as f32, x_scale, y_scale, bitmaps, transform)
546552
}
547553

548554
pub fn rasterize_glyph(&mut self, font: &FontInstance, key: &GlyphKey) -> GlyphRasterResult {
549-
let (size, y_scale, bitmaps, transform) = Self::get_glyph_parameters(font, key);
555+
let (size, x_scale, y_scale, bitmaps, transform) = Self::get_glyph_parameters(font, key);
550556
let (analysis, texture_type, bounds) = self.create_glyph_analysis(font, key, size, transform, bitmaps)
551557
.or(Err(GlyphRasterError::LoadFailed))?;
552-
let width = (bounds.right - bounds.left) as i32;
558+
let mut width = (bounds.right - bounds.left) as i32;
553559
let height = (bounds.bottom - bounds.top) as i32;
554560
// Alpha texture bounds can sometimes return an empty rect
555561
// Such as for spaces
@@ -558,10 +564,37 @@ impl FontContext {
558564
}
559565

560566
let pixels = analysis.create_alpha_texture(texture_type, bounds).or(Err(GlyphRasterError::LoadFailed))?;
561-
let mut bgra_pixels = self.convert_to_bgra(&pixels, width as usize, height as usize,
562-
texture_type, font.render_mode, bitmaps,
563-
font.flags.contains(FontInstanceFlags::SUBPIXEL_BGR),
564-
font.use_texture_padding());
567+
let padding = if font.use_texture_padding() { 1 } else { 0 };
568+
let (mut bgra_pixels, is_subpixel) = self.convert_to_bgra(
569+
&pixels,
570+
width as usize,
571+
height as usize,
572+
texture_type,
573+
font.render_mode,
574+
bitmaps,
575+
font.flags.contains(FontInstanceFlags::SUBPIXEL_BGR),
576+
padding as usize,
577+
);
578+
579+
// Apply multistrike bold, if necessary, and replace the current pixels with it.
580+
let (strike_scale, pixel_step) = if bitmaps {
581+
(y_scale, 1.0)
582+
} else {
583+
(x_scale, y_scale / x_scale)
584+
};
585+
let extra_strikes = font.get_extra_strikes(FontInstanceFlags::MULTISTRIKE_BOLD, strike_scale);
586+
if extra_strikes > 0 {
587+
let (bold_pixels, bold_width) = apply_multistrike_bold(
588+
&bgra_pixels,
589+
(width + padding * 2) as usize,
590+
height as usize,
591+
is_subpixel,
592+
extra_strikes,
593+
pixel_step,
594+
);
595+
width = bold_width as i32 - padding * 2;
596+
bgra_pixels = bold_pixels;
597+
}
565598

566599
let FontInstancePlatformOptions { gamma, contrast, cleartype_level, .. } =
567600
font.platform_options.unwrap_or_default();
@@ -573,11 +606,10 @@ impl FontContext {
573606
gamma as f32 / 100.0,
574607
gamma as f32 / 100.0,
575608
));
576-
if bitmaps || texture_type == dwrote::DWRITE_TEXTURE_ALIASED_1x1 ||
577-
font.render_mode != FontRenderMode::Subpixel {
578-
gamma_lut.preblend(&mut bgra_pixels, font.color);
579-
} else {
609+
if is_subpixel {
580610
gamma_lut.preblend_scaled(&mut bgra_pixels, font.color, cleartype_level);
611+
} else {
612+
gamma_lut.preblend(&mut bgra_pixels, font.color);
581613
}
582614

583615
let format = if bitmaps {
@@ -588,7 +620,6 @@ impl FontContext {
588620
font.get_glyph_format()
589621
};
590622

591-
let padding = if font.use_texture_padding() { 1 } else { 0 };
592623
Ok(RasterizedGlyph {
593624
left: (bounds.left - padding) as f32,
594625
top: (-bounds.top + padding) as f32,

gfx/wr/webrender_api/src/font.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -359,6 +359,7 @@ bitflags! {
359359
#[derive(Deserialize, MallocSizeOf, Serialize, PeekPoke)]
360360
pub struct FontInstanceFlags: u32 {
361361
// Common flags
362+
// Use native synthetic bold, if supported.
362363
const SYNTHETIC_BOLD = 1 << 1;
363364
const EMBEDDED_BITMAPS = 1 << 2;
364365
const SUBPIXEL_BGR = 1 << 3;
@@ -367,6 +368,8 @@ bitflags! {
367368
const FLIP_Y = 1 << 6;
368369
const SUBPIXEL_POSITION = 1 << 7;
369370
const VERTICAL = 1 << 8;
371+
// Explicitly use multi-strike bold emulation.
372+
const MULTISTRIKE_BOLD = 1 << 9;
370373

371374
// Internal flags
372375
const TRANSFORM_GLYPHS = 1 << 12;

0 commit comments

Comments
 (0)