зеркало из https://github.com/mozilla/gecko-dev.git
servo: Merge #18658 - stylo: Handle quirks mode on font base sizes (from canaltinova:font-size-quirk); r=Manishearth
We should use different font size mapping for quirks mode. --- - [X] `./mach build -d` does not report any errors - [X] `./mach test-tidy` does not report any errors - [X] These changes fix [Bug 1401322](https://bugzilla.mozilla.org/show_bug.cgi?id=1401322) Source-Repo: https://github.com/servo/servo Source-Revision: 01adcf69d794b09396ea469a4fe2ca3324ef9306 --HG-- extra : subtree_source : https%3A//hg.mozilla.org/projects/converted-servo-linear extra : subtree_revision : 0bdfb999b3ae85a3b3223b77a682a3166cf96bcf
This commit is contained in:
Родитель
13aa1f3a82
Коммит
e70135310c
|
@ -168,6 +168,7 @@ impl ToComputedValue for KeywordSize {
|
|||
type ComputedValue = NonNegativeLength;
|
||||
#[inline]
|
||||
fn to_computed_value(&self, cx: &Context) -> NonNegativeLength {
|
||||
use context::QuirksMode;
|
||||
use values::specified::length::au_to_int_px;
|
||||
// Data from nsRuleNode.cpp in Gecko
|
||||
// Mapping from base size and HTML size to pixels
|
||||
|
@ -188,9 +189,29 @@ impl ToComputedValue for KeywordSize {
|
|||
[9, 10, 13, 16, 18, 24, 32, 48]
|
||||
];
|
||||
|
||||
static FONT_SIZE_FACTORS: [i32; 8] = [60, 75, 89, 100, 120, 150, 200, 300];
|
||||
// Data from nsRuleNode.cpp in Gecko
|
||||
// (https://dxr.mozilla.org/mozilla-central/rev/35fbf14b9/layout/style/nsRuleNode.cpp#3303)
|
||||
//
|
||||
// This table gives us compatibility with WinNav4 for the default fonts only.
|
||||
// In WinNav4, the default fonts were:
|
||||
//
|
||||
// Times/12pt == Times/16px at 96ppi
|
||||
// Courier/10pt == Courier/13px at 96ppi
|
||||
//
|
||||
// xxs xs s m l xl xxl -
|
||||
// - 1 2 3 4 5 6 7
|
||||
static QUIRKS_FONT_SIZE_MAPPING: [[i32; 8]; 8] = [
|
||||
[9, 9, 9, 9, 11, 14, 18, 28],
|
||||
[9, 9, 9, 10, 12, 15, 20, 31],
|
||||
[9, 9, 9, 11, 13, 17, 22, 34],
|
||||
[9, 9, 10, 12, 14, 18, 24, 37],
|
||||
[9, 9, 10, 13, 16, 20, 26, 40],
|
||||
[9, 9, 11, 14, 17, 21, 28, 42],
|
||||
[9, 10, 12, 15, 17, 23, 30, 45],
|
||||
[9, 10, 13, 16, 18, 24, 32, 48]
|
||||
];
|
||||
|
||||
// XXXManishearth handle quirks mode (bug 1401322)
|
||||
static FONT_SIZE_FACTORS: [i32; 8] = [60, 75, 89, 100, 120, 150, 200, 300];
|
||||
|
||||
let ref gecko_font = cx.style().get_font().gecko();
|
||||
let base_size = unsafe { Atom::with(gecko_font.mLanguage.mRawPtr, |atom| {
|
||||
|
@ -200,7 +221,12 @@ impl ToComputedValue for KeywordSize {
|
|||
let base_size_px = au_to_int_px(base_size as f32);
|
||||
let html_size = self.html_size() as usize;
|
||||
if base_size_px >= 9 && base_size_px <= 16 {
|
||||
Au::from_px(FONT_SIZE_MAPPING[(base_size_px - 9) as usize][html_size]).into()
|
||||
let mapping = if cx.quirks_mode == QuirksMode::Quirks {
|
||||
QUIRKS_FONT_SIZE_MAPPING
|
||||
} else {
|
||||
FONT_SIZE_MAPPING
|
||||
};
|
||||
Au::from_px(mapping[(base_size_px - 9) as usize][html_size]).into()
|
||||
} else {
|
||||
Au(FONT_SIZE_FACTORS[html_size] * base_size / 100).into()
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче