lists.torproject.org
Sign In Sign Up
Manage this list Sign In Sign Up

Keyboard Shortcuts

Thread View

  • j: Next unread message
  • k: Previous unread message
  • j a: Jump to all threads
  • j l: Jump to MailingList overview

tbb-commits

Thread Start a new thread
Download
Threads by month
  • ----- 2025 -----
  • May
  • April
  • March
  • February
  • January
  • ----- 2024 -----
  • December
  • November
  • October
  • September
  • August
  • July
  • June
  • May
  • April
  • March
  • February
  • January
  • ----- 2023 -----
  • December
  • November
  • October
  • September
  • August
  • July
  • June
  • May
  • April
  • March
  • February
  • January
  • ----- 2022 -----
  • December
  • November
  • October
  • September
  • August
  • July
  • June
  • May
  • April
  • March
  • February
  • January
  • ----- 2021 -----
  • December
  • November
  • October
  • September
  • August
  • July
  • June
  • May
  • April
  • March
  • February
  • January
  • ----- 2020 -----
  • December
  • November
  • October
  • September
  • August
  • July
  • June
  • May
  • April
  • March
  • February
  • January
  • ----- 2019 -----
  • December
  • November
  • October
  • September
  • August
  • July
  • June
  • May
  • April
  • March
  • February
  • January
  • ----- 2018 -----
  • December
  • November
  • October
  • September
  • August
  • July
  • June
  • May
  • April
  • March
  • February
  • January
  • ----- 2017 -----
  • December
  • November
  • October
  • September
  • August
  • July
  • June
  • May
  • April
  • March
  • February
  • January
  • ----- 2016 -----
  • December
  • November
  • October
  • September
  • August
  • July
  • June
  • May
  • April
  • March
  • February
  • January
  • ----- 2015 -----
  • December
  • November
  • October
  • September
  • August
  • July
  • June
  • May
  • April
  • March
  • February
  • January
  • ----- 2014 -----
  • December
  • November
  • October
  • September
  • August
  • July
  • June
  • May
  • April
  • March
  • February
tbb-commits@lists.torproject.org

December 2024

  • 1 participants
  • 95 discussions
[Git][tpo/applications/tor-browser-build][main] Bug 41334: Add aarch64 builds to tools/signing/nightly/config.yml
by morgan (@morgan) 09 Dec '24

09 Dec '24
morgan pushed to branch main at The Tor Project / Applications / tor-browser-build Commits: b34af23e by Nicolas Vigier at 2024-12-09T15:09:45+01:00 Bug 41334: Add aarch64 builds to tools/signing/nightly/config.yml - - - - - 1 changed file: - tools/signing/nightly/config.yml Changes: ===================================== tools/signing/nightly/config.yml ===================================== @@ -8,6 +8,7 @@ torbrowser: publish_dirs: - nightly-linux-x86_64 - nightly-linux-i686 + - nightly-linux-aarch64 - nightly-windows-x86_64 - nightly-windows-i686 - nightly-macos @@ -17,6 +18,7 @@ torbrowser: mullvadbrowser: publish_dirs: - mullvadbrowser-nightly-linux-x86_64 + - mullvadbrowser-nightly-linux-aarch64 - mullvadbrowser-nightly-windows-x86_64 - mullvadbrowser-nightly-macos nss_db_dir: nssdb-mullvadbrowser-1 View it on GitLab: https://gitlab.torproject.org/tpo/applications/tor-browser-build/-/commit/b… -- View it on GitLab: https://gitlab.torproject.org/tpo/applications/tor-browser-build/-/commit/b… You're receiving this email because of your account on gitlab.torproject.org.
1 0
0 0
[Git][tpo/applications/mullvad-browser][mullvad-browser-128.5.0esr-14.0-1] 2 commits: Bug 1909625 - Ignore CSS zoom and text zoom for canvas. r=gfx-reviewers,lsalzman
by morgan (@morgan) 09 Dec '24

09 Dec '24
morgan pushed to branch mullvad-browser-128.5.0esr-14.0-1 at The Tor Project / Applications / Mullvad Browser Commits: 6aa85a0c by Emilio Cobos Álvarez at 2024-12-09T16:57:01+00:00 Bug 1909625 - Ignore CSS zoom and text zoom for canvas. r=gfx-reviewers,lsalzman The spec doesn't mention anything about applying them, and other browsers don't, so let's just be consistent... Differential Revision: https://phabricator.services.mozilla.com/D221709 - - - - - fcbe39a9 by Emilio Cobos Álvarez at 2024-12-09T16:57:01+00:00 Bug 1918454 - Prevent divide by zero when inverting effective zoom. r=firefox-style-system-reviewers,layout-reviewers,boris See comment. Differential Revision: https://phabricator.services.mozilla.com/D222090 - - - - - 9 changed files: - dom/canvas/CanvasRenderingContext2D.cpp - servo/components/style/properties/cascade.rs - servo/components/style/properties/properties.mako.rs - servo/components/style/values/computed/box.rs - servo/components/style/values/specified/length.rs - servo/ports/geckolib/glue.rs - + testing/web-platform/tests/css/css-viewport/zoom/canvas-ref.html - + testing/web-platform/tests/css/css-viewport/zoom/canvas.html - + testing/web-platform/tests/css/css-viewport/zoom/textarea-very-small-zoom-crash.html Changes: ===================================== dom/canvas/CanvasRenderingContext2D.cpp ===================================== @@ -6,6 +6,7 @@ #include "CanvasRenderingContext2D.h" #include "mozilla/gfx/Helpers.h" +#include "nsCSSValue.h" #include "nsXULElement.h" #include "nsMathUtils.h" @@ -2585,14 +2586,8 @@ static already_AddRefed<StyleLockedDeclarationBlock> CreateDeclarationForServo( return nullptr; } - // From canvas spec, force to set line-height property to 'normal' font - // property. if (aProperty == eCSSProperty_font) { - const nsCString normalString = "normal"_ns; - Servo_DeclarationBlock_SetPropertyById( - servoDeclarations, eCSSProperty_line_height, &normalString, false, - env.mUrlExtraData, StyleParsingMode::DEFAULT, env.mCompatMode, - env.mLoader, env.mRuleType, {}); + Servo_DeclarationBlock_SanitizeForCanvas(servoDeclarations); } return servoDeclarations.forget(); @@ -2657,12 +2652,9 @@ static already_AddRefed<const ComputedStyle> GetFontStyleForServo( // The font-size component must be converted to CSS px for reserialization, // so we update the declarations with the value from the computed style. if (!sc->StyleFont()->mFont.family.is_system_font) { - nsAutoCString computedFontSize; - sc->GetComputedPropertyValue(eCSSProperty_font_size, computedFontSize); - Servo_DeclarationBlock_SetPropertyById( - declarations, eCSSProperty_font_size, &computedFontSize, false, nullptr, - StyleParsingMode::DEFAULT, eCompatibility_FullStandards, nullptr, - StyleCssRuleType::Style, {}); + float px = sc->StyleFont()->mFont.size.ToCSSPixels(); + Servo_DeclarationBlock_SetLengthValue(declarations, eCSSProperty_font_size, + px, eCSSUnit_Pixel); } // The font getter is required to be reserialized based on what we ===================================== servo/components/style/properties/cascade.rs ===================================== @@ -1247,7 +1247,7 @@ impl<'b> Cascade<'b> { ); debug_assert!( !text_scale.text_zoom_enabled(), - "We only ever disable text zoom (in svg:text), never enable it" + "We only ever disable text zoom never enable it" ); let device = builder.device; builder.mutate_font().unzoom_fonts(device); @@ -1257,9 +1257,8 @@ impl<'b> Cascade<'b> { debug_assert!(self.seen.contains(LonghandId::Zoom)); // NOTE(emilio): Intentionally not using the effective zoom here, since all the inherited // zooms are already applied. - let zoom = builder.get_box().clone_zoom(); let old_size = builder.get_font().clone_font_size(); - let new_size = old_size.zoom(zoom); + let new_size = old_size.zoom(builder.resolved_specified_zoom()); if old_size == new_size { return; } ===================================== servo/components/style/properties/properties.mako.rs ===================================== @@ -2711,6 +2711,19 @@ impl<'a> StyleBuilder<'a> { self.get_box().clone_zoom() } + /// The zoom we need to apply for this element, without including ancestor effective zooms. + pub fn resolved_specified_zoom(&self) -> computed::Zoom { + let zoom = self.specified_zoom(); + if zoom.is_document() { + // If our inherited effective zoom has derived to zero, there's not much we can do. + // This value is not exposed to content anyways (it's used for scrollbars and to avoid + // zoom affecting canvas). + self.inherited_effective_zoom().inverted().unwrap_or(computed::Zoom::ONE) + } else { + zoom + } + } + /// Inherited zoom. pub fn inherited_effective_zoom(&self) -> computed::Zoom { self.inherited_style.effective_zoom @@ -2747,7 +2760,7 @@ impl<'a> StyleBuilder<'a> { let lh = device.calc_line_height(&font, writing_mode, None); if line_height_base == LineHeightBase::InheritedStyle { // Apply our own zoom if our style source is the parent style. - computed::NonNegativeLength::new(self.get_box().clone_zoom().zoom(lh.px())) + computed::NonNegativeLength::new(self.resolved_specified_zoom().zoom(lh.px())) } else { lh } ===================================== servo/components/style/values/computed/box.rs ===================================== @@ -357,6 +357,21 @@ impl Zoom { self == Self::ONE } + /// Returns whether we're the `document` keyword. + #[inline] + pub fn is_document(self) -> bool { + self == Self::DOCUMENT + } + + /// Returns the inverse of our value. + #[inline] + pub fn inverted(&self) -> Option<Self> { + if self.0.value == 0 { + return None; + } + Some(Self(Self::ONE.0 / self.0)) + } + /// Returns the value as a float. #[inline] pub fn value(&self) -> f32 { ===================================== servo/components/style/values/specified/length.rs ===================================== @@ -103,7 +103,7 @@ impl FontBaseSize { Self::InheritedStyle => { // If we're using the size from our inherited style, we still need to apply our // own zoom. - let zoom = style.get_box().clone_zoom(); + let zoom = style.resolved_specified_zoom(); style.get_parent_font().clone_font_size().zoom(zoom) }, } ===================================== servo/ports/geckolib/glue.rs ===================================== @@ -4972,6 +4972,21 @@ 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] pub unsafe extern "C" fn Servo_DeclarationBlock_SetProperty( declarations: &LockedDeclarationBlock, ===================================== testing/web-platform/tests/css/css-viewport/zoom/canvas-ref.html ===================================== @@ -0,0 +1,15 @@ +<!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> ===================================== testing/web-platform/tests/css/css-viewport/zoom/canvas.html ===================================== @@ -0,0 +1,20 @@ +<!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> ===================================== testing/web-platform/tests/css/css-viewport/zoom/textarea-very-small-zoom-crash.html ===================================== @@ -0,0 +1,6 @@ +<style> +*:nth-of-type(1) { + zoom: 5%; +} +</style> +<textarea> View it on GitLab: https://gitlab.torproject.org/tpo/applications/mullvad-browser/-/compare/53… -- View it on GitLab: https://gitlab.torproject.org/tpo/applications/mullvad-browser/-/compare/53… You're receiving this email because of your account on gitlab.torproject.org.
1 0
0 0
[Git][tpo/applications/tor-browser][base-browser-128.5.0esr-14.0-1] 2 commits: Bug 1909625 - Ignore CSS zoom and text zoom for canvas. r=gfx-reviewers,lsalzman
by morgan (@morgan) 09 Dec '24

09 Dec '24
morgan pushed to branch base-browser-128.5.0esr-14.0-1 at The Tor Project / Applications / Tor Browser Commits: 665e7cdd by Emilio Cobos Álvarez at 2024-12-09T16:54:02+00:00 Bug 1909625 - Ignore CSS zoom and text zoom for canvas. r=gfx-reviewers,lsalzman The spec doesn't mention anything about applying them, and other browsers don't, so let's just be consistent... Differential Revision: https://phabricator.services.mozilla.com/D221709 - - - - - d7a304c0 by Emilio Cobos Álvarez at 2024-12-09T16:54:02+00:00 Bug 1918454 - Prevent divide by zero when inverting effective zoom. r=firefox-style-system-reviewers,layout-reviewers,boris See comment. Differential Revision: https://phabricator.services.mozilla.com/D222090 - - - - - 9 changed files: - dom/canvas/CanvasRenderingContext2D.cpp - servo/components/style/properties/cascade.rs - servo/components/style/properties/properties.mako.rs - servo/components/style/values/computed/box.rs - servo/components/style/values/specified/length.rs - servo/ports/geckolib/glue.rs - + testing/web-platform/tests/css/css-viewport/zoom/canvas-ref.html - + testing/web-platform/tests/css/css-viewport/zoom/canvas.html - + testing/web-platform/tests/css/css-viewport/zoom/textarea-very-small-zoom-crash.html Changes: ===================================== dom/canvas/CanvasRenderingContext2D.cpp ===================================== @@ -6,6 +6,7 @@ #include "CanvasRenderingContext2D.h" #include "mozilla/gfx/Helpers.h" +#include "nsCSSValue.h" #include "nsXULElement.h" #include "nsMathUtils.h" @@ -2585,14 +2586,8 @@ static already_AddRefed<StyleLockedDeclarationBlock> CreateDeclarationForServo( return nullptr; } - // From canvas spec, force to set line-height property to 'normal' font - // property. if (aProperty == eCSSProperty_font) { - const nsCString normalString = "normal"_ns; - Servo_DeclarationBlock_SetPropertyById( - servoDeclarations, eCSSProperty_line_height, &normalString, false, - env.mUrlExtraData, StyleParsingMode::DEFAULT, env.mCompatMode, - env.mLoader, env.mRuleType, {}); + Servo_DeclarationBlock_SanitizeForCanvas(servoDeclarations); } return servoDeclarations.forget(); @@ -2657,12 +2652,9 @@ static already_AddRefed<const ComputedStyle> GetFontStyleForServo( // The font-size component must be converted to CSS px for reserialization, // so we update the declarations with the value from the computed style. if (!sc->StyleFont()->mFont.family.is_system_font) { - nsAutoCString computedFontSize; - sc->GetComputedPropertyValue(eCSSProperty_font_size, computedFontSize); - Servo_DeclarationBlock_SetPropertyById( - declarations, eCSSProperty_font_size, &computedFontSize, false, nullptr, - StyleParsingMode::DEFAULT, eCompatibility_FullStandards, nullptr, - StyleCssRuleType::Style, {}); + float px = sc->StyleFont()->mFont.size.ToCSSPixels(); + Servo_DeclarationBlock_SetLengthValue(declarations, eCSSProperty_font_size, + px, eCSSUnit_Pixel); } // The font getter is required to be reserialized based on what we ===================================== servo/components/style/properties/cascade.rs ===================================== @@ -1247,7 +1247,7 @@ impl<'b> Cascade<'b> { ); debug_assert!( !text_scale.text_zoom_enabled(), - "We only ever disable text zoom (in svg:text), never enable it" + "We only ever disable text zoom never enable it" ); let device = builder.device; builder.mutate_font().unzoom_fonts(device); @@ -1257,9 +1257,8 @@ impl<'b> Cascade<'b> { debug_assert!(self.seen.contains(LonghandId::Zoom)); // NOTE(emilio): Intentionally not using the effective zoom here, since all the inherited // zooms are already applied. - let zoom = builder.get_box().clone_zoom(); let old_size = builder.get_font().clone_font_size(); - let new_size = old_size.zoom(zoom); + let new_size = old_size.zoom(builder.resolved_specified_zoom()); if old_size == new_size { return; } ===================================== servo/components/style/properties/properties.mako.rs ===================================== @@ -2711,6 +2711,19 @@ impl<'a> StyleBuilder<'a> { self.get_box().clone_zoom() } + /// The zoom we need to apply for this element, without including ancestor effective zooms. + pub fn resolved_specified_zoom(&self) -> computed::Zoom { + let zoom = self.specified_zoom(); + if zoom.is_document() { + // If our inherited effective zoom has derived to zero, there's not much we can do. + // This value is not exposed to content anyways (it's used for scrollbars and to avoid + // zoom affecting canvas). + self.inherited_effective_zoom().inverted().unwrap_or(computed::Zoom::ONE) + } else { + zoom + } + } + /// Inherited zoom. pub fn inherited_effective_zoom(&self) -> computed::Zoom { self.inherited_style.effective_zoom @@ -2747,7 +2760,7 @@ impl<'a> StyleBuilder<'a> { let lh = device.calc_line_height(&font, writing_mode, None); if line_height_base == LineHeightBase::InheritedStyle { // Apply our own zoom if our style source is the parent style. - computed::NonNegativeLength::new(self.get_box().clone_zoom().zoom(lh.px())) + computed::NonNegativeLength::new(self.resolved_specified_zoom().zoom(lh.px())) } else { lh } ===================================== servo/components/style/values/computed/box.rs ===================================== @@ -357,6 +357,21 @@ impl Zoom { self == Self::ONE } + /// Returns whether we're the `document` keyword. + #[inline] + pub fn is_document(self) -> bool { + self == Self::DOCUMENT + } + + /// Returns the inverse of our value. + #[inline] + pub fn inverted(&self) -> Option<Self> { + if self.0.value == 0 { + return None; + } + Some(Self(Self::ONE.0 / self.0)) + } + /// Returns the value as a float. #[inline] pub fn value(&self) -> f32 { ===================================== servo/components/style/values/specified/length.rs ===================================== @@ -103,7 +103,7 @@ impl FontBaseSize { Self::InheritedStyle => { // If we're using the size from our inherited style, we still need to apply our // own zoom. - let zoom = style.get_box().clone_zoom(); + let zoom = style.resolved_specified_zoom(); style.get_parent_font().clone_font_size().zoom(zoom) }, } ===================================== servo/ports/geckolib/glue.rs ===================================== @@ -4972,6 +4972,21 @@ 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] pub unsafe extern "C" fn Servo_DeclarationBlock_SetProperty( declarations: &LockedDeclarationBlock, ===================================== testing/web-platform/tests/css/css-viewport/zoom/canvas-ref.html ===================================== @@ -0,0 +1,15 @@ +<!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> ===================================== testing/web-platform/tests/css/css-viewport/zoom/canvas.html ===================================== @@ -0,0 +1,20 @@ +<!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> ===================================== testing/web-platform/tests/css/css-viewport/zoom/textarea-very-small-zoom-crash.html ===================================== @@ -0,0 +1,6 @@ +<style> +*:nth-of-type(1) { + zoom: 5%; +} +</style> +<textarea> View it on GitLab: https://gitlab.torproject.org/tpo/applications/tor-browser/-/compare/f230a2… -- View it on GitLab: https://gitlab.torproject.org/tpo/applications/tor-browser/-/compare/f230a2… You're receiving this email because of your account on gitlab.torproject.org.
1 0
0 0
[Git][tpo/applications/mullvad-browser][mullvad-browser-128.5.0esr-14.5-1] 2 commits: Bug 1909625 - Ignore CSS zoom and text zoom for canvas. r=gfx-reviewers,lsalzman
by morgan (@morgan) 09 Dec '24

09 Dec '24
morgan pushed to branch mullvad-browser-128.5.0esr-14.5-1 at The Tor Project / Applications / Mullvad Browser Commits: 223b5884 by Emilio Cobos Álvarez at 2024-12-09T16:51:30+00:00 Bug 1909625 - Ignore CSS zoom and text zoom for canvas. r=gfx-reviewers,lsalzman The spec doesn't mention anything about applying them, and other browsers don't, so let's just be consistent... Differential Revision: https://phabricator.services.mozilla.com/D221709 - - - - - 1593887c by Emilio Cobos Álvarez at 2024-12-09T16:51:31+00:00 Bug 1918454 - Prevent divide by zero when inverting effective zoom. r=firefox-style-system-reviewers,layout-reviewers,boris See comment. Differential Revision: https://phabricator.services.mozilla.com/D222090 - - - - - 9 changed files: - dom/canvas/CanvasRenderingContext2D.cpp - servo/components/style/properties/cascade.rs - servo/components/style/properties/properties.mako.rs - servo/components/style/values/computed/box.rs - servo/components/style/values/specified/length.rs - servo/ports/geckolib/glue.rs - + testing/web-platform/tests/css/css-viewport/zoom/canvas-ref.html - + testing/web-platform/tests/css/css-viewport/zoom/canvas.html - + testing/web-platform/tests/css/css-viewport/zoom/textarea-very-small-zoom-crash.html Changes: ===================================== dom/canvas/CanvasRenderingContext2D.cpp ===================================== @@ -6,6 +6,7 @@ #include "CanvasRenderingContext2D.h" #include "mozilla/gfx/Helpers.h" +#include "nsCSSValue.h" #include "nsXULElement.h" #include "nsMathUtils.h" @@ -2585,14 +2586,8 @@ static already_AddRefed<StyleLockedDeclarationBlock> CreateDeclarationForServo( return nullptr; } - // From canvas spec, force to set line-height property to 'normal' font - // property. if (aProperty == eCSSProperty_font) { - const nsCString normalString = "normal"_ns; - Servo_DeclarationBlock_SetPropertyById( - servoDeclarations, eCSSProperty_line_height, &normalString, false, - env.mUrlExtraData, StyleParsingMode::DEFAULT, env.mCompatMode, - env.mLoader, env.mRuleType, {}); + Servo_DeclarationBlock_SanitizeForCanvas(servoDeclarations); } return servoDeclarations.forget(); @@ -2657,12 +2652,9 @@ static already_AddRefed<const ComputedStyle> GetFontStyleForServo( // The font-size component must be converted to CSS px for reserialization, // so we update the declarations with the value from the computed style. if (!sc->StyleFont()->mFont.family.is_system_font) { - nsAutoCString computedFontSize; - sc->GetComputedPropertyValue(eCSSProperty_font_size, computedFontSize); - Servo_DeclarationBlock_SetPropertyById( - declarations, eCSSProperty_font_size, &computedFontSize, false, nullptr, - StyleParsingMode::DEFAULT, eCompatibility_FullStandards, nullptr, - StyleCssRuleType::Style, {}); + float px = sc->StyleFont()->mFont.size.ToCSSPixels(); + Servo_DeclarationBlock_SetLengthValue(declarations, eCSSProperty_font_size, + px, eCSSUnit_Pixel); } // The font getter is required to be reserialized based on what we ===================================== servo/components/style/properties/cascade.rs ===================================== @@ -1247,7 +1247,7 @@ impl<'b> Cascade<'b> { ); debug_assert!( !text_scale.text_zoom_enabled(), - "We only ever disable text zoom (in svg:text), never enable it" + "We only ever disable text zoom never enable it" ); let device = builder.device; builder.mutate_font().unzoom_fonts(device); @@ -1257,9 +1257,8 @@ impl<'b> Cascade<'b> { debug_assert!(self.seen.contains(LonghandId::Zoom)); // NOTE(emilio): Intentionally not using the effective zoom here, since all the inherited // zooms are already applied. - let zoom = builder.get_box().clone_zoom(); let old_size = builder.get_font().clone_font_size(); - let new_size = old_size.zoom(zoom); + let new_size = old_size.zoom(builder.resolved_specified_zoom()); if old_size == new_size { return; } ===================================== servo/components/style/properties/properties.mako.rs ===================================== @@ -2711,6 +2711,19 @@ impl<'a> StyleBuilder<'a> { self.get_box().clone_zoom() } + /// The zoom we need to apply for this element, without including ancestor effective zooms. + pub fn resolved_specified_zoom(&self) -> computed::Zoom { + let zoom = self.specified_zoom(); + if zoom.is_document() { + // If our inherited effective zoom has derived to zero, there's not much we can do. + // This value is not exposed to content anyways (it's used for scrollbars and to avoid + // zoom affecting canvas). + self.inherited_effective_zoom().inverted().unwrap_or(computed::Zoom::ONE) + } else { + zoom + } + } + /// Inherited zoom. pub fn inherited_effective_zoom(&self) -> computed::Zoom { self.inherited_style.effective_zoom @@ -2747,7 +2760,7 @@ impl<'a> StyleBuilder<'a> { let lh = device.calc_line_height(&font, writing_mode, None); if line_height_base == LineHeightBase::InheritedStyle { // Apply our own zoom if our style source is the parent style. - computed::NonNegativeLength::new(self.get_box().clone_zoom().zoom(lh.px())) + computed::NonNegativeLength::new(self.resolved_specified_zoom().zoom(lh.px())) } else { lh } ===================================== servo/components/style/values/computed/box.rs ===================================== @@ -357,6 +357,21 @@ impl Zoom { self == Self::ONE } + /// Returns whether we're the `document` keyword. + #[inline] + pub fn is_document(self) -> bool { + self == Self::DOCUMENT + } + + /// Returns the inverse of our value. + #[inline] + pub fn inverted(&self) -> Option<Self> { + if self.0.value == 0 { + return None; + } + Some(Self(Self::ONE.0 / self.0)) + } + /// Returns the value as a float. #[inline] pub fn value(&self) -> f32 { ===================================== servo/components/style/values/specified/length.rs ===================================== @@ -103,7 +103,7 @@ impl FontBaseSize { Self::InheritedStyle => { // If we're using the size from our inherited style, we still need to apply our // own zoom. - let zoom = style.get_box().clone_zoom(); + let zoom = style.resolved_specified_zoom(); style.get_parent_font().clone_font_size().zoom(zoom) }, } ===================================== servo/ports/geckolib/glue.rs ===================================== @@ -4972,6 +4972,21 @@ 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] pub unsafe extern "C" fn Servo_DeclarationBlock_SetProperty( declarations: &LockedDeclarationBlock, ===================================== testing/web-platform/tests/css/css-viewport/zoom/canvas-ref.html ===================================== @@ -0,0 +1,15 @@ +<!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> ===================================== testing/web-platform/tests/css/css-viewport/zoom/canvas.html ===================================== @@ -0,0 +1,20 @@ +<!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> ===================================== testing/web-platform/tests/css/css-viewport/zoom/textarea-very-small-zoom-crash.html ===================================== @@ -0,0 +1,6 @@ +<style> +*:nth-of-type(1) { + zoom: 5%; +} +</style> +<textarea> View it on GitLab: https://gitlab.torproject.org/tpo/applications/mullvad-browser/-/compare/5f… -- View it on GitLab: https://gitlab.torproject.org/tpo/applications/mullvad-browser/-/compare/5f… You're receiving this email because of your account on gitlab.torproject.org.
1 0
0 0
[Git][tpo/applications/tor-browser][tor-browser-128.5.0esr-14.0-1] 2 commits: Bug 1909625 - Ignore CSS zoom and text zoom for canvas. r=gfx-reviewers,lsalzman
by morgan (@morgan) 09 Dec '24

09 Dec '24
morgan pushed to branch tor-browser-128.5.0esr-14.0-1 at The Tor Project / Applications / Tor Browser Commits: 09a1810a by Emilio Cobos Álvarez at 2024-12-09T16:52:44+00:00 Bug 1909625 - Ignore CSS zoom and text zoom for canvas. r=gfx-reviewers,lsalzman The spec doesn't mention anything about applying them, and other browsers don't, so let's just be consistent... Differential Revision: https://phabricator.services.mozilla.com/D221709 - - - - - 314fdd34 by Emilio Cobos Álvarez at 2024-12-09T16:52:45+00:00 Bug 1918454 - Prevent divide by zero when inverting effective zoom. r=firefox-style-system-reviewers,layout-reviewers,boris See comment. Differential Revision: https://phabricator.services.mozilla.com/D222090 - - - - - 9 changed files: - dom/canvas/CanvasRenderingContext2D.cpp - servo/components/style/properties/cascade.rs - servo/components/style/properties/properties.mako.rs - servo/components/style/values/computed/box.rs - servo/components/style/values/specified/length.rs - servo/ports/geckolib/glue.rs - + testing/web-platform/tests/css/css-viewport/zoom/canvas-ref.html - + testing/web-platform/tests/css/css-viewport/zoom/canvas.html - + testing/web-platform/tests/css/css-viewport/zoom/textarea-very-small-zoom-crash.html Changes: ===================================== dom/canvas/CanvasRenderingContext2D.cpp ===================================== @@ -6,6 +6,7 @@ #include "CanvasRenderingContext2D.h" #include "mozilla/gfx/Helpers.h" +#include "nsCSSValue.h" #include "nsXULElement.h" #include "nsMathUtils.h" @@ -2585,14 +2586,8 @@ static already_AddRefed<StyleLockedDeclarationBlock> CreateDeclarationForServo( return nullptr; } - // From canvas spec, force to set line-height property to 'normal' font - // property. if (aProperty == eCSSProperty_font) { - const nsCString normalString = "normal"_ns; - Servo_DeclarationBlock_SetPropertyById( - servoDeclarations, eCSSProperty_line_height, &normalString, false, - env.mUrlExtraData, StyleParsingMode::DEFAULT, env.mCompatMode, - env.mLoader, env.mRuleType, {}); + Servo_DeclarationBlock_SanitizeForCanvas(servoDeclarations); } return servoDeclarations.forget(); @@ -2657,12 +2652,9 @@ static already_AddRefed<const ComputedStyle> GetFontStyleForServo( // The font-size component must be converted to CSS px for reserialization, // so we update the declarations with the value from the computed style. if (!sc->StyleFont()->mFont.family.is_system_font) { - nsAutoCString computedFontSize; - sc->GetComputedPropertyValue(eCSSProperty_font_size, computedFontSize); - Servo_DeclarationBlock_SetPropertyById( - declarations, eCSSProperty_font_size, &computedFontSize, false, nullptr, - StyleParsingMode::DEFAULT, eCompatibility_FullStandards, nullptr, - StyleCssRuleType::Style, {}); + float px = sc->StyleFont()->mFont.size.ToCSSPixels(); + Servo_DeclarationBlock_SetLengthValue(declarations, eCSSProperty_font_size, + px, eCSSUnit_Pixel); } // The font getter is required to be reserialized based on what we ===================================== servo/components/style/properties/cascade.rs ===================================== @@ -1247,7 +1247,7 @@ impl<'b> Cascade<'b> { ); debug_assert!( !text_scale.text_zoom_enabled(), - "We only ever disable text zoom (in svg:text), never enable it" + "We only ever disable text zoom never enable it" ); let device = builder.device; builder.mutate_font().unzoom_fonts(device); @@ -1257,9 +1257,8 @@ impl<'b> Cascade<'b> { debug_assert!(self.seen.contains(LonghandId::Zoom)); // NOTE(emilio): Intentionally not using the effective zoom here, since all the inherited // zooms are already applied. - let zoom = builder.get_box().clone_zoom(); let old_size = builder.get_font().clone_font_size(); - let new_size = old_size.zoom(zoom); + let new_size = old_size.zoom(builder.resolved_specified_zoom()); if old_size == new_size { return; } ===================================== servo/components/style/properties/properties.mako.rs ===================================== @@ -2711,6 +2711,19 @@ impl<'a> StyleBuilder<'a> { self.get_box().clone_zoom() } + /// The zoom we need to apply for this element, without including ancestor effective zooms. + pub fn resolved_specified_zoom(&self) -> computed::Zoom { + let zoom = self.specified_zoom(); + if zoom.is_document() { + // If our inherited effective zoom has derived to zero, there's not much we can do. + // This value is not exposed to content anyways (it's used for scrollbars and to avoid + // zoom affecting canvas). + self.inherited_effective_zoom().inverted().unwrap_or(computed::Zoom::ONE) + } else { + zoom + } + } + /// Inherited zoom. pub fn inherited_effective_zoom(&self) -> computed::Zoom { self.inherited_style.effective_zoom @@ -2747,7 +2760,7 @@ impl<'a> StyleBuilder<'a> { let lh = device.calc_line_height(&font, writing_mode, None); if line_height_base == LineHeightBase::InheritedStyle { // Apply our own zoom if our style source is the parent style. - computed::NonNegativeLength::new(self.get_box().clone_zoom().zoom(lh.px())) + computed::NonNegativeLength::new(self.resolved_specified_zoom().zoom(lh.px())) } else { lh } ===================================== servo/components/style/values/computed/box.rs ===================================== @@ -357,6 +357,21 @@ impl Zoom { self == Self::ONE } + /// Returns whether we're the `document` keyword. + #[inline] + pub fn is_document(self) -> bool { + self == Self::DOCUMENT + } + + /// Returns the inverse of our value. + #[inline] + pub fn inverted(&self) -> Option<Self> { + if self.0.value == 0 { + return None; + } + Some(Self(Self::ONE.0 / self.0)) + } + /// Returns the value as a float. #[inline] pub fn value(&self) -> f32 { ===================================== servo/components/style/values/specified/length.rs ===================================== @@ -103,7 +103,7 @@ impl FontBaseSize { Self::InheritedStyle => { // If we're using the size from our inherited style, we still need to apply our // own zoom. - let zoom = style.get_box().clone_zoom(); + let zoom = style.resolved_specified_zoom(); style.get_parent_font().clone_font_size().zoom(zoom) }, } ===================================== servo/ports/geckolib/glue.rs ===================================== @@ -4972,6 +4972,21 @@ 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] pub unsafe extern "C" fn Servo_DeclarationBlock_SetProperty( declarations: &LockedDeclarationBlock, ===================================== testing/web-platform/tests/css/css-viewport/zoom/canvas-ref.html ===================================== @@ -0,0 +1,15 @@ +<!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> ===================================== testing/web-platform/tests/css/css-viewport/zoom/canvas.html ===================================== @@ -0,0 +1,20 @@ +<!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> ===================================== testing/web-platform/tests/css/css-viewport/zoom/textarea-very-small-zoom-crash.html ===================================== @@ -0,0 +1,6 @@ +<style> +*:nth-of-type(1) { + zoom: 5%; +} +</style> +<textarea> View it on GitLab: https://gitlab.torproject.org/tpo/applications/tor-browser/-/compare/174d3f… -- View it on GitLab: https://gitlab.torproject.org/tpo/applications/tor-browser/-/compare/174d3f… You're receiving this email because of your account on gitlab.torproject.org.
1 0
0 0
[Git][tpo/applications/tor-browser][base-browser-128.5.0esr-14.5-1] 2 commits: Bug 1909625 - Ignore CSS zoom and text zoom for canvas. r=gfx-reviewers,lsalzman
by morgan (@morgan) 09 Dec '24

09 Dec '24
morgan pushed to branch base-browser-128.5.0esr-14.5-1 at The Tor Project / Applications / Tor Browser Commits: f533badc by Emilio Cobos Álvarez at 2024-12-09T16:47:26+00:00 Bug 1909625 - Ignore CSS zoom and text zoom for canvas. r=gfx-reviewers,lsalzman The spec doesn't mention anything about applying them, and other browsers don't, so let's just be consistent... Differential Revision: https://phabricator.services.mozilla.com/D221709 - - - - - 7c1ff710 by Emilio Cobos Álvarez at 2024-12-09T16:47:26+00:00 Bug 1918454 - Prevent divide by zero when inverting effective zoom. r=firefox-style-system-reviewers,layout-reviewers,boris See comment. Differential Revision: https://phabricator.services.mozilla.com/D222090 - - - - - 9 changed files: - dom/canvas/CanvasRenderingContext2D.cpp - servo/components/style/properties/cascade.rs - servo/components/style/properties/properties.mako.rs - servo/components/style/values/computed/box.rs - servo/components/style/values/specified/length.rs - servo/ports/geckolib/glue.rs - + testing/web-platform/tests/css/css-viewport/zoom/canvas-ref.html - + testing/web-platform/tests/css/css-viewport/zoom/canvas.html - + testing/web-platform/tests/css/css-viewport/zoom/textarea-very-small-zoom-crash.html Changes: ===================================== dom/canvas/CanvasRenderingContext2D.cpp ===================================== @@ -6,6 +6,7 @@ #include "CanvasRenderingContext2D.h" #include "mozilla/gfx/Helpers.h" +#include "nsCSSValue.h" #include "nsXULElement.h" #include "nsMathUtils.h" @@ -2585,14 +2586,8 @@ static already_AddRefed<StyleLockedDeclarationBlock> CreateDeclarationForServo( return nullptr; } - // From canvas spec, force to set line-height property to 'normal' font - // property. if (aProperty == eCSSProperty_font) { - const nsCString normalString = "normal"_ns; - Servo_DeclarationBlock_SetPropertyById( - servoDeclarations, eCSSProperty_line_height, &normalString, false, - env.mUrlExtraData, StyleParsingMode::DEFAULT, env.mCompatMode, - env.mLoader, env.mRuleType, {}); + Servo_DeclarationBlock_SanitizeForCanvas(servoDeclarations); } return servoDeclarations.forget(); @@ -2657,12 +2652,9 @@ static already_AddRefed<const ComputedStyle> GetFontStyleForServo( // The font-size component must be converted to CSS px for reserialization, // so we update the declarations with the value from the computed style. if (!sc->StyleFont()->mFont.family.is_system_font) { - nsAutoCString computedFontSize; - sc->GetComputedPropertyValue(eCSSProperty_font_size, computedFontSize); - Servo_DeclarationBlock_SetPropertyById( - declarations, eCSSProperty_font_size, &computedFontSize, false, nullptr, - StyleParsingMode::DEFAULT, eCompatibility_FullStandards, nullptr, - StyleCssRuleType::Style, {}); + float px = sc->StyleFont()->mFont.size.ToCSSPixels(); + Servo_DeclarationBlock_SetLengthValue(declarations, eCSSProperty_font_size, + px, eCSSUnit_Pixel); } // The font getter is required to be reserialized based on what we ===================================== servo/components/style/properties/cascade.rs ===================================== @@ -1247,7 +1247,7 @@ impl<'b> Cascade<'b> { ); debug_assert!( !text_scale.text_zoom_enabled(), - "We only ever disable text zoom (in svg:text), never enable it" + "We only ever disable text zoom never enable it" ); let device = builder.device; builder.mutate_font().unzoom_fonts(device); @@ -1257,9 +1257,8 @@ impl<'b> Cascade<'b> { debug_assert!(self.seen.contains(LonghandId::Zoom)); // NOTE(emilio): Intentionally not using the effective zoom here, since all the inherited // zooms are already applied. - let zoom = builder.get_box().clone_zoom(); let old_size = builder.get_font().clone_font_size(); - let new_size = old_size.zoom(zoom); + let new_size = old_size.zoom(builder.resolved_specified_zoom()); if old_size == new_size { return; } ===================================== servo/components/style/properties/properties.mako.rs ===================================== @@ -2711,6 +2711,19 @@ impl<'a> StyleBuilder<'a> { self.get_box().clone_zoom() } + /// The zoom we need to apply for this element, without including ancestor effective zooms. + pub fn resolved_specified_zoom(&self) -> computed::Zoom { + let zoom = self.specified_zoom(); + if zoom.is_document() { + // If our inherited effective zoom has derived to zero, there's not much we can do. + // This value is not exposed to content anyways (it's used for scrollbars and to avoid + // zoom affecting canvas). + self.inherited_effective_zoom().inverted().unwrap_or(computed::Zoom::ONE) + } else { + zoom + } + } + /// Inherited zoom. pub fn inherited_effective_zoom(&self) -> computed::Zoom { self.inherited_style.effective_zoom @@ -2747,7 +2760,7 @@ impl<'a> StyleBuilder<'a> { let lh = device.calc_line_height(&font, writing_mode, None); if line_height_base == LineHeightBase::InheritedStyle { // Apply our own zoom if our style source is the parent style. - computed::NonNegativeLength::new(self.get_box().clone_zoom().zoom(lh.px())) + computed::NonNegativeLength::new(self.resolved_specified_zoom().zoom(lh.px())) } else { lh } ===================================== servo/components/style/values/computed/box.rs ===================================== @@ -357,6 +357,21 @@ impl Zoom { self == Self::ONE } + /// Returns whether we're the `document` keyword. + #[inline] + pub fn is_document(self) -> bool { + self == Self::DOCUMENT + } + + /// Returns the inverse of our value. + #[inline] + pub fn inverted(&self) -> Option<Self> { + if self.0.value == 0 { + return None; + } + Some(Self(Self::ONE.0 / self.0)) + } + /// Returns the value as a float. #[inline] pub fn value(&self) -> f32 { ===================================== servo/components/style/values/specified/length.rs ===================================== @@ -103,7 +103,7 @@ impl FontBaseSize { Self::InheritedStyle => { // If we're using the size from our inherited style, we still need to apply our // own zoom. - let zoom = style.get_box().clone_zoom(); + let zoom = style.resolved_specified_zoom(); style.get_parent_font().clone_font_size().zoom(zoom) }, } ===================================== servo/ports/geckolib/glue.rs ===================================== @@ -4972,6 +4972,21 @@ 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] pub unsafe extern "C" fn Servo_DeclarationBlock_SetProperty( declarations: &LockedDeclarationBlock, ===================================== testing/web-platform/tests/css/css-viewport/zoom/canvas-ref.html ===================================== @@ -0,0 +1,15 @@ +<!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> ===================================== testing/web-platform/tests/css/css-viewport/zoom/canvas.html ===================================== @@ -0,0 +1,20 @@ +<!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> ===================================== testing/web-platform/tests/css/css-viewport/zoom/textarea-very-small-zoom-crash.html ===================================== @@ -0,0 +1,6 @@ +<style> +*:nth-of-type(1) { + zoom: 5%; +} +</style> +<textarea> View it on GitLab: https://gitlab.torproject.org/tpo/applications/tor-browser/-/compare/47f389… -- View it on GitLab: https://gitlab.torproject.org/tpo/applications/tor-browser/-/compare/47f389… You're receiving this email because of your account on gitlab.torproject.org.
1 0
0 0
[Git][tpo/applications/tor-browser][tor-browser-128.5.0esr-14.5-1] 2 commits: Bug 1909625 - Ignore CSS zoom and text zoom for canvas. r=gfx-reviewers,lsalzman
by morgan (@morgan) 09 Dec '24

09 Dec '24
morgan pushed to branch tor-browser-128.5.0esr-14.5-1 at The Tor Project / Applications / Tor Browser Commits: 0ee9170b by Emilio Cobos Álvarez at 2024-12-09T16:40:36+00:00 Bug 1909625 - Ignore CSS zoom and text zoom for canvas. r=gfx-reviewers,lsalzman The spec doesn't mention anything about applying them, and other browsers don't, so let's just be consistent... Differential Revision: https://phabricator.services.mozilla.com/D221709 - - - - - 8b8b4a99 by Emilio Cobos Álvarez at 2024-12-09T16:40:36+00:00 Bug 1918454 - Prevent divide by zero when inverting effective zoom. r=firefox-style-system-reviewers,layout-reviewers,boris See comment. Differential Revision: https://phabricator.services.mozilla.com/D222090 - - - - - 9 changed files: - dom/canvas/CanvasRenderingContext2D.cpp - servo/components/style/properties/cascade.rs - servo/components/style/properties/properties.mako.rs - servo/components/style/values/computed/box.rs - servo/components/style/values/specified/length.rs - servo/ports/geckolib/glue.rs - + testing/web-platform/tests/css/css-viewport/zoom/canvas-ref.html - + testing/web-platform/tests/css/css-viewport/zoom/canvas.html - + testing/web-platform/tests/css/css-viewport/zoom/textarea-very-small-zoom-crash.html Changes: ===================================== dom/canvas/CanvasRenderingContext2D.cpp ===================================== @@ -6,6 +6,7 @@ #include "CanvasRenderingContext2D.h" #include "mozilla/gfx/Helpers.h" +#include "nsCSSValue.h" #include "nsXULElement.h" #include "nsMathUtils.h" @@ -2585,14 +2586,8 @@ static already_AddRefed<StyleLockedDeclarationBlock> CreateDeclarationForServo( return nullptr; } - // From canvas spec, force to set line-height property to 'normal' font - // property. if (aProperty == eCSSProperty_font) { - const nsCString normalString = "normal"_ns; - Servo_DeclarationBlock_SetPropertyById( - servoDeclarations, eCSSProperty_line_height, &normalString, false, - env.mUrlExtraData, StyleParsingMode::DEFAULT, env.mCompatMode, - env.mLoader, env.mRuleType, {}); + Servo_DeclarationBlock_SanitizeForCanvas(servoDeclarations); } return servoDeclarations.forget(); @@ -2657,12 +2652,9 @@ static already_AddRefed<const ComputedStyle> GetFontStyleForServo( // The font-size component must be converted to CSS px for reserialization, // so we update the declarations with the value from the computed style. if (!sc->StyleFont()->mFont.family.is_system_font) { - nsAutoCString computedFontSize; - sc->GetComputedPropertyValue(eCSSProperty_font_size, computedFontSize); - Servo_DeclarationBlock_SetPropertyById( - declarations, eCSSProperty_font_size, &computedFontSize, false, nullptr, - StyleParsingMode::DEFAULT, eCompatibility_FullStandards, nullptr, - StyleCssRuleType::Style, {}); + float px = sc->StyleFont()->mFont.size.ToCSSPixels(); + Servo_DeclarationBlock_SetLengthValue(declarations, eCSSProperty_font_size, + px, eCSSUnit_Pixel); } // The font getter is required to be reserialized based on what we ===================================== servo/components/style/properties/cascade.rs ===================================== @@ -1247,7 +1247,7 @@ impl<'b> Cascade<'b> { ); debug_assert!( !text_scale.text_zoom_enabled(), - "We only ever disable text zoom (in svg:text), never enable it" + "We only ever disable text zoom never enable it" ); let device = builder.device; builder.mutate_font().unzoom_fonts(device); @@ -1257,9 +1257,8 @@ impl<'b> Cascade<'b> { debug_assert!(self.seen.contains(LonghandId::Zoom)); // NOTE(emilio): Intentionally not using the effective zoom here, since all the inherited // zooms are already applied. - let zoom = builder.get_box().clone_zoom(); let old_size = builder.get_font().clone_font_size(); - let new_size = old_size.zoom(zoom); + let new_size = old_size.zoom(builder.resolved_specified_zoom()); if old_size == new_size { return; } ===================================== servo/components/style/properties/properties.mako.rs ===================================== @@ -2711,6 +2711,19 @@ impl<'a> StyleBuilder<'a> { self.get_box().clone_zoom() } + /// The zoom we need to apply for this element, without including ancestor effective zooms. + pub fn resolved_specified_zoom(&self) -> computed::Zoom { + let zoom = self.specified_zoom(); + if zoom.is_document() { + // If our inherited effective zoom has derived to zero, there's not much we can do. + // This value is not exposed to content anyways (it's used for scrollbars and to avoid + // zoom affecting canvas). + self.inherited_effective_zoom().inverted().unwrap_or(computed::Zoom::ONE) + } else { + zoom + } + } + /// Inherited zoom. pub fn inherited_effective_zoom(&self) -> computed::Zoom { self.inherited_style.effective_zoom @@ -2747,7 +2760,7 @@ impl<'a> StyleBuilder<'a> { let lh = device.calc_line_height(&font, writing_mode, None); if line_height_base == LineHeightBase::InheritedStyle { // Apply our own zoom if our style source is the parent style. - computed::NonNegativeLength::new(self.get_box().clone_zoom().zoom(lh.px())) + computed::NonNegativeLength::new(self.resolved_specified_zoom().zoom(lh.px())) } else { lh } ===================================== servo/components/style/values/computed/box.rs ===================================== @@ -357,6 +357,21 @@ impl Zoom { self == Self::ONE } + /// Returns whether we're the `document` keyword. + #[inline] + pub fn is_document(self) -> bool { + self == Self::DOCUMENT + } + + /// Returns the inverse of our value. + #[inline] + pub fn inverted(&self) -> Option<Self> { + if self.0.value == 0 { + return None; + } + Some(Self(Self::ONE.0 / self.0)) + } + /// Returns the value as a float. #[inline] pub fn value(&self) -> f32 { ===================================== servo/components/style/values/specified/length.rs ===================================== @@ -103,7 +103,7 @@ impl FontBaseSize { Self::InheritedStyle => { // If we're using the size from our inherited style, we still need to apply our // own zoom. - let zoom = style.get_box().clone_zoom(); + let zoom = style.resolved_specified_zoom(); style.get_parent_font().clone_font_size().zoom(zoom) }, } ===================================== servo/ports/geckolib/glue.rs ===================================== @@ -4972,6 +4972,21 @@ 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] pub unsafe extern "C" fn Servo_DeclarationBlock_SetProperty( declarations: &LockedDeclarationBlock, ===================================== testing/web-platform/tests/css/css-viewport/zoom/canvas-ref.html ===================================== @@ -0,0 +1,15 @@ +<!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> ===================================== testing/web-platform/tests/css/css-viewport/zoom/canvas.html ===================================== @@ -0,0 +1,20 @@ +<!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> ===================================== testing/web-platform/tests/css/css-viewport/zoom/textarea-very-small-zoom-crash.html ===================================== @@ -0,0 +1,6 @@ +<style> +*:nth-of-type(1) { + zoom: 5%; +} +</style> +<textarea> View it on GitLab: https://gitlab.torproject.org/tpo/applications/tor-browser/-/compare/e4b644… -- View it on GitLab: https://gitlab.torproject.org/tpo/applications/tor-browser/-/compare/e4b644… You're receiving this email because of your account on gitlab.torproject.org.
1 0
0 0
[Git][tpo/applications/tor-browser][tor-browser-128.5.0esr-14.5-1] 2 commits: fixup! Add CI for Tor Browser
by Pier Angelo Vendrame (@pierov) 05 Dec '24

05 Dec '24
Pier Angelo Vendrame pushed to branch tor-browser-128.5.0esr-14.5-1 at The Tor Project / Applications / Tor Browser Commits: 14a0cbe0 by Henry Wilkes at 2024-12-05T14:26:15+00:00 fixup! Add CI for Tor Browser Bug 43345: Exclude android strings from the legacy branch. - - - - - e4b64479 by Henry Wilkes at 2024-12-05T14:26:54+00:00 fixup! Bug 42305: Add script to combine translation files across versions. Bug 43345: Add an option to exclude contributions from the legacy branch for some files. - - - - - 2 changed files: - .gitlab/ci/update-translations.yml - tools/torbrowser/l10n/combine-translation-versions.py Changes: ===================================== .gitlab/ci/update-translations.yml ===================================== @@ -41,7 +41,11 @@ combine-en-US-translations: { "name": "torConnect.properties", "branch": "tor-browser" }, { "name": "torlauncher.properties", "branch": "tor-browser" }, { "name": "base-browser.ftl", "branch": "base-browser" }, - { "name": "torbrowser_strings.xml", "branch": "fenix-torbrowserstringsxml" } + { + "name": "torbrowser_strings.xml", + "branch": "fenix-torbrowserstringsxml", + "exclude-legacy": true + } ]' TRANSLATION_INCLUDE_LEGACY: "true" cache: ===================================== tools/torbrowser/l10n/combine-translation-versions.py ===================================== @@ -309,7 +309,7 @@ for file_dict in json.loads(args.files): f"Will be unused in Tor Browser {current_branch.browser_version}!", ) - if legacy_branch: + if legacy_branch and not file_dict.get("exclude-legacy", False): legacy_file = legacy_branch.get_file(name, where_dirs) if legacy_file is not None and current_file is None and stable_file is None: logger.warning(f"{name} still exists in the legacy branch") @@ -332,6 +332,8 @@ for file_dict in json.loads(args.files): legacy_file.content, f"Unused in Tor Browser {stable_branch.browser_version}!", ) + elif legacy_branch: + logger.info(f"Excluding legacy branch for {name}") files_list.append( { View it on GitLab: https://gitlab.torproject.org/tpo/applications/tor-browser/-/compare/fe2071… -- View it on GitLab: https://gitlab.torproject.org/tpo/applications/tor-browser/-/compare/fe2071… You're receiving this email because of your account on gitlab.torproject.org.
1 0
0 0
[Git][tpo/applications/tor-browser][tor-browser-128.5.0esr-14.5-1] 2 commits: fixup! [android] Add Tor integration and UI
by Pier Angelo Vendrame (@pierov) 05 Dec '24

05 Dec '24
Pier Angelo Vendrame pushed to branch tor-browser-128.5.0esr-14.5-1 at The Tor Project / Applications / Tor Browser Commits: 3e999182 by Henry Wilkes at 2024-12-05T11:19:00+00:00 fixup! [android] Add Tor integration and UI Bug 43350: Revert changes from 938f751c and ff438022, which should have targeted a different commit. - - - - - fe207126 by Henry Wilkes at 2024-12-05T11:26:30+00:00 fixup! [android] Implement Android-native Connection Assist UI Bug 43350: Remove all caps comment from android string. Also made sure comments end in a full stop. - - - - - 1 changed file: - mobile/android/fenix/app/src/main/res/values/torbrowser_strings.xml Changes: ===================================== mobile/android/fenix/app/src/main/res/values/torbrowser_strings.xml ===================================== @@ -149,9 +149,9 @@ <string name="connection_assist_final_error_troubleshoot_connection_link">troubleshooting your connection</string> <!-- Connection assist. --> <string name="connection_assist_final_error_learn_more_link">Learn more</string> - <!-- Connection assist. Description for a shown "Snackbar" (special popup notification) with an action to connect --> + <!-- Connection assist. Description for a shown "Snackbar" (special popup notification) with an action to connect. --> <string name="connection_assist_connect_to_tor_before_opening_links">Connect to Tor before opening links</string> - <!-- Connection assist. Confirmation button for a shown "Snackbar" (special popup notification) that has a previously mentioned description. Automatically shown in ALL CAPS if available, regardless of the localized string --> + <!-- Connection assist. Confirmation button for a shown "Snackbar" (special popup notification). --> <string name="connection_assist_connect_to_tor_before_opening_links_confirmation">CONNECT</string> </resources> View it on GitLab: https://gitlab.torproject.org/tpo/applications/tor-browser/-/compare/ff4380… -- View it on GitLab: https://gitlab.torproject.org/tpo/applications/tor-browser/-/compare/ff4380… You're receiving this email because of your account on gitlab.torproject.org.
1 0
0 0
[Git][tpo/applications/tor-browser][tor-browser-128.5.0esr-14.5-1] fixup! [android] Add Tor integration and UI
by morgan (@morgan) 04 Dec '24

04 Dec '24
morgan pushed to branch tor-browser-128.5.0esr-14.5-1 at The Tor Project / Applications / Tor Browser Commits: ff438022 by Morgan at 2024-12-04T22:24:32+00:00 fixup! [android] Add Tor integration and UI - revert re-add of YEC strings - - - - - 1 changed file: - mobile/android/fenix/app/src/main/res/values/torbrowser_strings.xml Changes: ===================================== mobile/android/fenix/app/src/main/res/values/torbrowser_strings.xml ===================================== @@ -149,31 +149,9 @@ <string name="connection_assist_final_error_troubleshoot_connection_link">troubleshooting your connection</string> <!-- Connection assist. --> <string name="connection_assist_final_error_learn_more_link">Learn more</string> - <!-- Connection assist. Description for a shown "Snackbar" (special popup notification) with an action to connect --> <string name="connection_assist_connect_to_tor_before_opening_links">Connect to Tor before opening links</string> <!-- Connection assist. Confirmation button for a shown "Snackbar" (special popup notification) that has a previously mentioned description. Automatically shown in ALL CAPS if available, regardless of the localized string --> <string name="connection_assist_connect_to_tor_before_opening_links_confirmation">CONNECT</string> - <!-- 2024 YEC. --> - <string name="YEC_2024_right_to_speak">You have a right to SPEAK without uninvited listeners.</string> - <!-- 2024 YEC. --> - <string name="YEC_2024_right_to_BROWSE">You have a right to BROWSE without being watched.</string> - <!-- 2024 YEC. --> - <string name="YEC_2024_right_to_SEARCH">You have a right to SEARCH without being followed.</string> - - <!-- 2024 YEC. --> - <string name="YEC_2024_donation_encouragement">Join the thousands of Tor supporters building an internet powered by privacy. Make a donation today.</string> - - <!-- 2024 YEC. --> - <string name="YEC_2024_donation_match_text">Through December 31, your gift will be matched, up to $300,000!</string> - - <!-- 2024 YEC. %1$s is the app name "Tor Browser". Since this will only ever show on release, it will always be "Tor Browser" (and not "Tor Browser Alpha" for instance) --> - <string name="YEC_2024_tor_browser_for_android_will_always_be_free_no_donation_required">%1$s for Android will always be free to use—no donation is required to use this app.</string> - - <!-- 2024 YEC. Accessible name for the "X" button. --> - <string name="YEC_2024_close">Close</string> - - <!-- 2024 YEC. --> - <string name="YEC_2024_donate_now">Donate now</string> </resources> View it on GitLab: https://gitlab.torproject.org/tpo/applications/tor-browser/-/commit/ff43802… -- View it on GitLab: https://gitlab.torproject.org/tpo/applications/tor-browser/-/commit/ff43802… You're receiving this email because of your account on gitlab.torproject.org.
1 0
0 0
  • ← Newer
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • Older →

HyperKitty Powered by HyperKitty version 1.3.12.