Backed out changeset dfb3a55370d3 (bug 1909625) for causing mochitest failures on test_canvas_font_setter.html. CLOSED TREE

This commit is contained in:
Tamas Szentpeteri
2024-09-11 00:12:59 +03:00
parent 29258bedd7
commit 194f7a44ac
4 changed files with 7 additions and 51 deletions

View File

@@ -2602,8 +2602,14 @@ static already_AddRefed<StyleLockedDeclarationBlock> CreateDeclarationForServo(
return nullptr; return nullptr;
} }
// From canvas spec, force to set line-height property to 'normal' font
// property.
if (aProperty == eCSSProperty_font) { if (aProperty == eCSSProperty_font) {
Servo_DeclarationBlock_SanitizeForCanvas(servoDeclarations); const nsCString normalString = "normal"_ns;
Servo_DeclarationBlock_SetPropertyById(
servoDeclarations, eCSSProperty_line_height, &normalString, false,
env.mUrlExtraData, StyleParsingMode::DEFAULT, env.mCompatMode,
env.mLoader, env.mRuleType, {});
} }
return servoDeclarations.forget(); return servoDeclarations.forget();

View File

@@ -5053,21 +5053,6 @@ fn set_property(
) )
} }
#[no_mangle]
pub unsafe extern "C" fn Servo_DeclarationBlock_SanitizeForCanvas(
declarations: &LockedDeclarationBlock,
) {
use style::properties::PropertyDeclaration;
use style::values::specified::{LineHeight, XTextScale, Zoom};
// From canvas spec, force to set line-height property to 'normal' font property.
// Also, for compat, disable text scaling and CSS zoom.
write_locked_arc(declarations, |decls: &mut PropertyDeclarationBlock| {
decls.push(PropertyDeclaration::LineHeight(LineHeight::Normal), Importance::Normal);
decls.push(PropertyDeclaration::Zoom(Zoom::Document), Importance::Normal);
decls.push(PropertyDeclaration::XTextScale(XTextScale::None), Importance::Normal);
});
}
#[no_mangle] #[no_mangle]
pub unsafe extern "C" fn Servo_DeclarationBlock_SetProperty( pub unsafe extern "C" fn Servo_DeclarationBlock_SetProperty(
declarations: &LockedDeclarationBlock, declarations: &LockedDeclarationBlock,

View File

@@ -1,15 +0,0 @@
<!DOCTYPE html>
<style>
canvas {
width: 600px;
height: 200px;
}
</style>
<script>
document.addEventListener("DOMContentLoaded", () => {
const ctx = document.getElementById("canvas").getContext("2d");
ctx.font = "48px serif";
ctx.fillText(ctx.font, 10, 50);
});
</script>
<canvas id="canvas" width="300" height="100"></canvas>

View File

@@ -1,20 +0,0 @@
<!DOCTYPE html>
<link rel="help" href="https://bugzilla.mozilla.org/show_bug.cgi?id=1909625">
<link rel="help" href="https://html.spec.whatwg.org/#dom-context-2d-font">
<link rel="author" href="mailto:emilio@crisal.io" title="Emilio Cobos Álvarez">
<link rel="author" href="https://mozilla.org" title="Mozilla">
<link rel="match" href="canvas-ref.html">
<title>zoom is ignored for canvas</title>
<style>
canvas {
zoom: 2;
}
</style>
<script>
document.addEventListener("DOMContentLoaded", () => {
const ctx = document.getElementById("canvas").getContext("2d");
ctx.font = "48px serif";
ctx.fillText(ctx.font, 10, 50);
});
</script>
<canvas id="canvas" width="300" height="100"></canvas>