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 -----
  • July
  • June
  • 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

  • 18606 discussions
[Git][tpo/applications/mullvad-browser][mullvad-browser-128.5.0esr-14.5-1] Bug 1935621 - Fix virtual environment sysconfig path calculation...
by Pier Angelo Vendrame (@pierov) 10 Dec '24

10 Dec '24
Pier Angelo Vendrame pushed to branch mullvad-browser-128.5.0esr-14.5-1 at The Tor Project / Applications / Mullvad Browser Commits: 83f707a1 by Filipe Laíns at 2024-12-10T10:23:46+01:00 Bug 1935621 - Fix virtual environment sysconfig path calculation r=firefox-build-system-reviewers,ahochheiden Signed-off-by: Filipe Laíns <lains(a)riseup.net> Signed-off-by: Filipe Laíns <lains(a)riseup.net> Signed-off-by: Filipe Laíns <lains(a)riseup.net> Differential Revision: https://phabricator.services.mozilla.com/D231480 - - - - - 1 changed file: - python/mach/mach/site.py Changes: ===================================== python/mach/mach/site.py ===================================== @@ -17,6 +17,7 @@ import subprocess import sys import sysconfig import tempfile +import warnings from contextlib import contextmanager from pathlib import Path from typing import Callable, Optional @@ -817,33 +818,75 @@ class PythonVirtualenv: """Calculates paths of interest for general python virtual environments""" def __init__(self, prefix): - if _is_windows: - self.bin_path = os.path.join(prefix, "Scripts") - self.python_path = os.path.join(self.bin_path, "python.exe") - else: - self.bin_path = os.path.join(prefix, "bin") - self.python_path = os.path.join(self.bin_path, "python") self.prefix = os.path.realpath(prefix) + self.paths = self._get_sysconfig_paths(self.prefix) - @functools.lru_cache(maxsize=None) - def resolve_sysconfig_packages_path(self, sysconfig_path): - # macOS uses a different default sysconfig scheme based on whether it's using the - # system Python or running in a virtualenv. - # Manually define the scheme (following the implementation in - # "sysconfig._get_default_scheme()") so that we're always following the - # code path for a virtualenv directory structure. - if os.name == "posix": - scheme = "posix_prefix" - else: - scheme = os.name + # Name of the Python executable to use in virtual environments. + # An executable with the same name as sys.executable might not exist in + # virtual environments. An executable with 'python' as the steam — + # without version numbers or ABI flags — will always be present in + # virtual environments, so we use that. + python_exe_name = "python" + sysconfig.get_config_var("EXE") + + self.bin_path = self.paths["scripts"] + self.python_path = os.path.join(self.bin_path, python_exe_name) - sysconfig_paths = sysconfig.get_paths(scheme) - data_path = Path(sysconfig_paths["data"]) - path = Path(sysconfig_paths[sysconfig_path]) - relative_path = path.relative_to(data_path) + @staticmethod + def _get_sysconfig_paths(prefix): + """Calculate the sysconfig paths of a virtual environment in the given prefix. - # Path to virtualenv's "site-packages" directory for provided sysconfig path - return os.path.normpath(os.path.normcase(Path(self.prefix) / relative_path)) + The virtual environment MUST be using the same Python distribution as us. + """ + # Determine the sysconfig scheme used in virtual environments + if "venv" in sysconfig.get_scheme_names(): + # A 'venv' scheme was added in Python 3.11 to allow users to + # calculate the paths for a virtual environment, since the default + # scheme may not always be the same as used on virtual environments. + # Some common examples are the system Python distributed by macOS, + # Debian, and Fedora. + # For more information, see https://github.com/python/cpython/issues/89576 + venv_scheme = "venv" + elif os.name == "nt": + # We know that before the 'venv' scheme was added, on Windows, + # the 'nt' scheme was used in virtual environments. + venv_scheme = "nt" + elif os.name == "posix": + # We know that before the 'venv' scheme was added, on POSIX, + # the 'posix_prefix' scheme was used in virtual environments. + venv_scheme = "posix_prefix" + else: + # This should never happen with upstream Python, as the 'venv' + # scheme should always be available on >=3.11, and no other + # platforms are supported by the upstream on older Python versions. + # + # Since the 'venv' scheme isn't available, and we have no knowledge + # of this platform/distribution, fallback to the default scheme. + # + # Hitting this will likely be the result of running a custom Python + # distribution targetting a platform that is not supported by the + # upstream. + # In this case, unless the Python vendor patched the Python + # distribution in such a way as the default scheme may not always be + # the same scheme, using the default scheme should be correct. + # If the vendor did patch Python as such, to work around this issue, + # I would recommend them to define a 'venv' scheme that matches + # the layout used on virtual environments in their Python distribution. + # (rec. signed Filipe Laíns — upstream sysconfig maintainer) + venv_scheme = sysconfig.get_default_scheme() + warnings.warn( + f"Unknown platform '{os.name}', using the default install scheme '{venv_scheme}'. " + "If this is incorrect, please ask your Python vendor to add a 'venv' sysconfig scheme " + "(see https://github.com/python/cpython/issues/89576, or check the code comment).", + stacklevel=2, + ) + # Build the sysconfig config_vars dictionary for the virtual environment. + venv_vars = sysconfig.get_config_vars().copy() + venv_vars["base"] = venv_vars["platbase"] = prefix + # Get sysconfig paths for the virtual environment. + return sysconfig.get_paths(venv_scheme, vars=venv_vars) + + def resolve_sysconfig_packages_path(self, sysconfig_path): + return self.paths[sysconfig_path] def site_packages_dirs(self): dirs = [] View it on GitLab: https://gitlab.torproject.org/tpo/applications/mullvad-browser/-/commit/83f… -- View it on GitLab: https://gitlab.torproject.org/tpo/applications/mullvad-browser/-/commit/83f… 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] Bug 1935621 - Fix virtual environment sysconfig path calculation...
by Pier Angelo Vendrame (@pierov) 10 Dec '24

10 Dec '24
Pier Angelo Vendrame pushed to branch tor-browser-128.5.0esr-14.5-1 at The Tor Project / Applications / Tor Browser Commits: ee315187 by Filipe Laíns at 2024-12-10T10:00:43+01:00 Bug 1935621 - Fix virtual environment sysconfig path calculation r=firefox-build-system-reviewers,ahochheiden Signed-off-by: Filipe Laíns <lains(a)riseup.net> Signed-off-by: Filipe Laíns <lains(a)riseup.net> Signed-off-by: Filipe Laíns <lains(a)riseup.net> Differential Revision: https://phabricator.services.mozilla.com/D231480 - - - - - 1 changed file: - python/mach/mach/site.py Changes: ===================================== python/mach/mach/site.py ===================================== @@ -17,6 +17,7 @@ import subprocess import sys import sysconfig import tempfile +import warnings from contextlib import contextmanager from pathlib import Path from typing import Callable, Optional @@ -817,33 +818,75 @@ class PythonVirtualenv: """Calculates paths of interest for general python virtual environments""" def __init__(self, prefix): - if _is_windows: - self.bin_path = os.path.join(prefix, "Scripts") - self.python_path = os.path.join(self.bin_path, "python.exe") - else: - self.bin_path = os.path.join(prefix, "bin") - self.python_path = os.path.join(self.bin_path, "python") self.prefix = os.path.realpath(prefix) + self.paths = self._get_sysconfig_paths(self.prefix) - @functools.lru_cache(maxsize=None) - def resolve_sysconfig_packages_path(self, sysconfig_path): - # macOS uses a different default sysconfig scheme based on whether it's using the - # system Python or running in a virtualenv. - # Manually define the scheme (following the implementation in - # "sysconfig._get_default_scheme()") so that we're always following the - # code path for a virtualenv directory structure. - if os.name == "posix": - scheme = "posix_prefix" - else: - scheme = os.name + # Name of the Python executable to use in virtual environments. + # An executable with the same name as sys.executable might not exist in + # virtual environments. An executable with 'python' as the steam — + # without version numbers or ABI flags — will always be present in + # virtual environments, so we use that. + python_exe_name = "python" + sysconfig.get_config_var("EXE") + + self.bin_path = self.paths["scripts"] + self.python_path = os.path.join(self.bin_path, python_exe_name) - sysconfig_paths = sysconfig.get_paths(scheme) - data_path = Path(sysconfig_paths["data"]) - path = Path(sysconfig_paths[sysconfig_path]) - relative_path = path.relative_to(data_path) + @staticmethod + def _get_sysconfig_paths(prefix): + """Calculate the sysconfig paths of a virtual environment in the given prefix. - # Path to virtualenv's "site-packages" directory for provided sysconfig path - return os.path.normpath(os.path.normcase(Path(self.prefix) / relative_path)) + The virtual environment MUST be using the same Python distribution as us. + """ + # Determine the sysconfig scheme used in virtual environments + if "venv" in sysconfig.get_scheme_names(): + # A 'venv' scheme was added in Python 3.11 to allow users to + # calculate the paths for a virtual environment, since the default + # scheme may not always be the same as used on virtual environments. + # Some common examples are the system Python distributed by macOS, + # Debian, and Fedora. + # For more information, see https://github.com/python/cpython/issues/89576 + venv_scheme = "venv" + elif os.name == "nt": + # We know that before the 'venv' scheme was added, on Windows, + # the 'nt' scheme was used in virtual environments. + venv_scheme = "nt" + elif os.name == "posix": + # We know that before the 'venv' scheme was added, on POSIX, + # the 'posix_prefix' scheme was used in virtual environments. + venv_scheme = "posix_prefix" + else: + # This should never happen with upstream Python, as the 'venv' + # scheme should always be available on >=3.11, and no other + # platforms are supported by the upstream on older Python versions. + # + # Since the 'venv' scheme isn't available, and we have no knowledge + # of this platform/distribution, fallback to the default scheme. + # + # Hitting this will likely be the result of running a custom Python + # distribution targetting a platform that is not supported by the + # upstream. + # In this case, unless the Python vendor patched the Python + # distribution in such a way as the default scheme may not always be + # the same scheme, using the default scheme should be correct. + # If the vendor did patch Python as such, to work around this issue, + # I would recommend them to define a 'venv' scheme that matches + # the layout used on virtual environments in their Python distribution. + # (rec. signed Filipe Laíns — upstream sysconfig maintainer) + venv_scheme = sysconfig.get_default_scheme() + warnings.warn( + f"Unknown platform '{os.name}', using the default install scheme '{venv_scheme}'. " + "If this is incorrect, please ask your Python vendor to add a 'venv' sysconfig scheme " + "(see https://github.com/python/cpython/issues/89576, or check the code comment).", + stacklevel=2, + ) + # Build the sysconfig config_vars dictionary for the virtual environment. + venv_vars = sysconfig.get_config_vars().copy() + venv_vars["base"] = venv_vars["platbase"] = prefix + # Get sysconfig paths for the virtual environment. + return sysconfig.get_paths(venv_scheme, vars=venv_vars) + + def resolve_sysconfig_packages_path(self, sysconfig_path): + return self.paths[sysconfig_path] def site_packages_dirs(self): dirs = [] View it on GitLab: https://gitlab.torproject.org/tpo/applications/tor-browser/-/commit/ee31518… -- View it on GitLab: https://gitlab.torproject.org/tpo/applications/tor-browser/-/commit/ee31518… You're receiving this email because of your account on gitlab.torproject.org.
1 0
0 0
[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
[Git][tpo/applications/tor-browser][tor-browser-128.5.0esr-14.5-1] fixup! Bug 40597: Implement TorSettings module
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: 4cccc26d by Morgan at 2024-12-04T22:11:01+00:00 fixup! Bug 40597: Implement TorSettings module - Bug 41333: Update STUN servers in Snowflake builtin bridges - Also remove webtunnel and add to lyrebird - - - - - 1 changed file: - toolkit/content/pt_config.json Changes: ===================================== toolkit/content/pt_config.json ===================================== @@ -2,9 +2,8 @@ "_comment": "Used for dev build, replaced for release builds in tor-browser-build. This file is copied from tor-browser-build 0554d981:projects/tor-expert-bundle/pt_config.json", "recommendedDefault" : "obfs4", "pluggableTransports" : { - "lyrebird" : "ClientTransportPlugin meek_lite,obfs2,obfs3,obfs4,scramblesuit exec ${pt_path}lyrebird${pt_extension}", + "lyrebird" : "ClientTransportPlugin meek_lite,obfs2,obfs3,obfs4,scramblesuit,webtunnel exec ${pt_path}lyrebird${pt_extension}", "snowflake" : "ClientTransportPlugin snowflake exec ${pt_path}snowflake-client${pt_extension}", - "webtunnel" : "ClientTransportPlugin webtunnel exec ${pt_path}webtunnel-client${pt_extension}", "conjure" : "ClientTransportPlugin conjure exec ${pt_path}conjure-client${pt_extension} -registerURL https://registration.refraction.network/api" }, "bridges" : { @@ -25,8 +24,8 @@ "obfs4 51.222.13.177:80 5EDAC3B810E12B01F6FD8050D2FD3E277B289A08 cert=2uplIpLQ0q9+0qMFrK5pkaYRDOe460LL9WHBvatgkuRr/SL31wBOEupaMMJ6koRE6Ld0ew iat-mode=0" ], "snowflake" : [ - "snowflake 192.0.2.3:80 2B280B23E1107BB62ABFC40DDCC8824814F80A72 fingerprint=2B280B23E1107BB62ABFC40DDCC8824814F80A72 url=https://1098762253.rsc.cdn77.org/ fronts=www.cdn77.com,www.phpmyadmin.net ice=stun:stun.l.google.com:19302,stun:stun.antisip.com:3478,stun:stun.bluesip.net:3478,stun:stun.dus.net:3478,stun:stun.epygi.com:3478,stun:stun.sonetel.com:3478,stun:stun.uls.co.za:3478,stun:stun.voipgate.com:3478,stun:stun.voys.nl:3478 utls-imitate=hellorandomizedalpn", - "snowflake 192.0.2.4:80 8838024498816A039FCBBAB14E6F40A0843051FA fingerprint=8838024498816A039FCBBAB14E6F40A0843051FA url=https://1098762253.rsc.cdn77.org/ fronts=www.cdn77.com,www.phpmyadmin.net ice=stun:stun.l.google.com:19302,stun:stun.antisip.com:3478,stun:stun.bluesip.net:3478,stun:stun.dus.net:3478,stun:stun.epygi.com:3478,stun:stun.sonetel.net:3478,stun:stun.uls.co.za:3478,stun:stun.voipgate.com:3478,stun:stun.voys.nl:3478 utls-imitate=hellorandomizedalpn" + "snowflake 192.0.2.3:80 2B280B23E1107BB62ABFC40DDCC8824814F80A72 fingerprint=2B280B23E1107BB62ABFC40DDCC8824814F80A72 url=https://1098762253.rsc.cdn77.org/ fronts=www.cdn77.com,www.phpmyadmin.net ice=stun:stun.antisip.com:3478,stun:stun.epygi.com:3478,stun:stun.uls.co.za:3478,stun:stun.voipgate.com:3478,stun:stun.mixvoip.com:3478,stun:stun.nextcloud.com:3478,stun:stun.bethesda.net:3478,stun:stun.nextcloud.com:443 utls-imitate=hellorandomizedalpn", + "snowflake 192.0.2.4:80 8838024498816A039FCBBAB14E6F40A0843051FA fingerprint=8838024498816A039FCBBAB14E6F40A0843051FA url=https://1098762253.rsc.cdn77.org/ fronts=www.cdn77.com,www.phpmyadmin.net ice=stun:stun.antisip.com:3478,stun:stun.epygi.com:3478,stun:stun.uls.co.za:3478,stun:stun.voipgate.com:3478,stun:stun.mixvoip.com:3478,stun:stun.nextcloud.com:3478,stun:stun.bethesda.net:3478,stun:stun.nextcloud.com:443 utls-imitate=hellorandomizedalpn" ] } } View it on GitLab: https://gitlab.torproject.org/tpo/applications/tor-browser/-/commit/4cccc26… -- View it on GitLab: https://gitlab.torproject.org/tpo/applications/tor-browser/-/commit/4cccc26… You're receiving this email because of your account on gitlab.torproject.org.
1 0
0 0
[Git][tpo/applications/tor-browser-build][main] Bug 41331: Add linux-aarch64 build target to update_responses_config.yml
by morgan (@morgan) 04 Dec '24

04 Dec '24
morgan pushed to branch main at The Tor Project / Applications / tor-browser-build Commits: f96868f8 by Nicolas Vigier at 2024-12-04T20:43:56+00:00 Bug 41331: Add linux-aarch64 build target to update_responses_config.yml - - - - - 2 changed files: - projects/release/update_responses_config.yml - tools/signing/nightly/update-responses-base-config.yml Changes: ===================================== projects/release/update_responses_config.yml ===================================== @@ -16,6 +16,7 @@ download: mars_url: 'https://cdn.mullvad.net/browser' [% END -%] build_targets: + linux-aarch64: Linux_aarch64-gcc3 linux-i686: Linux_x86-gcc3 linux-x86_64: Linux_x86_64-gcc3 windows-i686: ===================================== tools/signing/nightly/update-responses-base-config.yml ===================================== @@ -2,6 +2,7 @@ download: mars_url: https://nightlies.tbb.torproject.org/nightly-updates build_targets: + linux-aarch64: Linux_aarch64-gcc3 linux-i686: Linux_x86-gcc3 linux-x86_64: Linux_x86_64-gcc3 windows-i686: View it on GitLab: https://gitlab.torproject.org/tpo/applications/tor-browser-build/-/commit/f… -- View it on GitLab: https://gitlab.torproject.org/tpo/applications/tor-browser-build/-/commit/f… 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: 938f751c by clairehurst at 2024-12-04T11:50:34-07:00 fixup! [android] Add Tor integration and UI - - - - - 9 changed files: - mobile/android/fenix/app/src/main/java/org/mozilla/fenix/HomeActivity.kt - mobile/android/fenix/app/src/main/java/org/mozilla/fenix/home/HomeFragment.kt - mobile/android/fenix/app/src/main/java/org/mozilla/fenix/settings/SettingsFragment.kt - mobile/android/fenix/app/src/main/java/org/mozilla/fenix/tor/TorConnectionAssistFragment.kt - mobile/android/fenix/app/src/main/java/org/mozilla/fenix/tor/TorConnectionAssistViewModel.kt - mobile/android/fenix/app/src/main/java/org/mozilla/fenix/tor/TorControllerGV.kt - mobile/android/fenix/app/src/main/res/layout/fenix_snackbar.xml - mobile/android/fenix/app/src/main/res/navigation/nav_graph.xml - mobile/android/fenix/app/src/main/res/values/torbrowser_strings.xml Changes: ===================================== mobile/android/fenix/app/src/main/java/org/mozilla/fenix/HomeActivity.kt ===================================== @@ -25,6 +25,7 @@ import android.view.MotionEvent import android.view.View import android.view.ViewConfiguration import android.view.WindowManager.LayoutParams.FLAG_SECURE +import androidx.activity.viewModels import androidx.annotation.CallSuper import androidx.annotation.IdRes import androidx.annotation.RequiresApi @@ -32,7 +33,6 @@ import androidx.annotation.VisibleForTesting import androidx.appcompat.app.ActionBar import androidx.appcompat.widget.Toolbar import androidx.core.splashscreen.SplashScreen.Companion.installSplashScreen -import androidx.core.content.ContentProviderCompat.requireContext import androidx.lifecycle.lifecycleScope import androidx.navigation.NavController import androidx.navigation.fragment.NavHostFragment @@ -151,10 +151,10 @@ import org.mozilla.fenix.utils.Settings import java.lang.ref.WeakReference import java.util.Locale -import androidx.navigation.fragment.findNavController import mozilla.components.browser.engine.gecko.GeckoEngine -import mozilla.components.browser.state.selector.findCustomTab +import org.mozilla.fenix.components.FenixSnackbar import org.mozilla.fenix.home.HomeFragment +import org.mozilla.fenix.tor.TorConnectionAssistViewModel import org.mozilla.geckoview.TorIntegrationAndroid /** @@ -238,6 +238,8 @@ open class HomeActivity : LocaleAwareAppCompatActivity(), NavHostActivity, TorIn private var dialog: RedirectDialogFragment? = null + private val torConnectionAssistViewModel: TorConnectionAssistViewModel by viewModels() + @Suppress("ComplexMethod") final override fun onCreate(savedInstanceState: Bundle?) { // DO NOT MOVE ANYTHING ABOVE THIS getProfilerTime CALL. @@ -1115,6 +1117,25 @@ open class HomeActivity : LocaleAwareAppCompatActivity(), NavHostActivity, TorIn historyMetadata: HistoryMetadataKey? = null, additionalHeaders: Map<String, String>? = null, ) { + if (!components.torController.isBootstrapped && !searchTermOrURL.startsWith("about:")) { + FenixSnackbar.make( + view = binding.root, + isDisplayedWithBrowserToolbar = true, + ) + .setText(getString(R.string.connection_assist_connect_to_tor_before_opening_links)) + .setAction(getString(R.string.connection_assist_connect_to_tor_before_opening_links_confirmation)) { + torConnectionAssistViewModel.handleConnect(searchTermOrURL) + if (navHost.navController.previousBackStackEntry?.destination?.id == R.id.torConnectionAssistFragment) { + supportFragmentManager.popBackStack() + } else { + navHost.navController.navigate( + TorConnectionAssistFragmentDirections.actionConnectToTorBeforeOpeningLinks() + ) + } + } + .show() + return + } openToBrowser(from, customTabSessionId) load( searchTermOrURL = searchTermOrURL, @@ -1434,8 +1455,10 @@ open class HomeActivity : LocaleAwareAppCompatActivity(), NavHostActivity, TorIn override fun onBootstrapStateChange(state: String) = Unit override fun onBootstrapProgress(progress: Double, hasWarnings: Boolean) = Unit override fun onBootstrapComplete() { - components.useCases.tabsUseCases.removeAllTabs() - navHost.navController.navigate(NavGraphDirections.actionStartupHome()) + if (settings().useHtmlConnectionUi) { + components.useCases.tabsUseCases.removeAllTabs() + navHost.navController.navigate(NavGraphDirections.actionStartupHome()) + } } override fun onBootstrapError(code: String?, message: String?, phase: String?, reason: String?) = Unit } ===================================== mobile/android/fenix/app/src/main/java/org/mozilla/fenix/home/HomeFragment.kt ===================================== @@ -160,6 +160,7 @@ import org.mozilla.fenix.tabstray.TabsTrayAccessPoint import org.mozilla.fenix.theme.FirefoxTheme import org.mozilla.fenix.tor.TorBootstrapFragmentDirections import org.mozilla.fenix.tor.TorBootstrapStatus +import org.mozilla.fenix.tor.TorConnectionAssistViewModel import org.mozilla.fenix.utils.Settings.Companion.TOP_SITES_PROVIDER_MAX_THRESHOLD import org.mozilla.fenix.utils.allowUndo import org.mozilla.fenix.wallpapers.Wallpaper @@ -179,6 +180,7 @@ class HomeFragment : Fragment(), UserInteractionHandler { private val binding get() = _binding!! private val homeViewModel: HomeScreenViewModel by activityViewModels() + private val torConnectionAssistViewModel: TorConnectionAssistViewModel by activityViewModels() private val snackbarAnchorView: View? get() = when (requireContext().settings().toolbarPosition) { @@ -899,6 +901,17 @@ class HomeFragment : Fragment(), UserInteractionHandler { view = view, ) + torConnectionAssistViewModel.urlToLoadAfterConnecting.also { + if(!it.isNullOrBlank()){ + (requireActivity() as HomeActivity).openToBrowserAndLoad( + searchTermOrURL = it, + newTab = true, + from = BrowserDirection.FromHome, + ) + torConnectionAssistViewModel.urlToLoadAfterConnecting = null // Only load this url once + } + } + // DO NOT MOVE ANYTHING BELOW THIS addMarker CALL! requireComponents.core.engine.profiler?.addMarker( MarkersFragmentLifecycleCallbacks.MARKER_NAME, ===================================== mobile/android/fenix/app/src/main/java/org/mozilla/fenix/settings/SettingsFragment.kt ===================================== @@ -25,6 +25,7 @@ import androidx.lifecycle.Observer import androidx.lifecycle.lifecycleScope import androidx.navigation.NavDirections import androidx.navigation.findNavController +import androidx.navigation.fragment.findNavController import androidx.navigation.fragment.navArgs import androidx.preference.Preference import androidx.preference.PreferenceFragmentCompat @@ -40,6 +41,7 @@ import mozilla.components.concept.sync.OAuthAccount import mozilla.components.concept.sync.Profile import mozilla.components.feature.addons.ui.AddonFilePicker import mozilla.components.service.glean.private.NoExtras +import mozilla.components.support.base.feature.UserInteractionHandler import mozilla.components.support.ktx.android.view.showKeyboard import mozilla.components.ui.widgets.withCenterAlignedButtons import org.mozilla.fenix.BrowserDirection @@ -77,7 +79,7 @@ import kotlin.system.exitProcess import org.mozilla.fenix.GleanMetrics.Settings as SettingsMetrics @Suppress("LargeClass", "TooManyFunctions") -class SettingsFragment : PreferenceFragmentCompat() { +class SettingsFragment : PreferenceFragmentCompat(), UserInteractionHandler { private val args by navArgs<SettingsFragmentArgs>() private lateinit var accountUiView: AccountUiView @@ -883,4 +885,18 @@ class SettingsFragment : PreferenceFragmentCompat() { private const val FXA_SYNC_OVERRIDE_EXIT_DELAY = 2000L private const val AMO_COLLECTION_OVERRIDE_EXIT_DELAY = 3000L } + + override fun onBackPressed(): Boolean { + // If tor is already bootstrapped, skip going back to [TorConnectionAssistFragment] and instead go directly to [HomeFragment] + if (requireComponents.torController.isBootstrapped) { + val navController = findNavController() + if (navController.previousBackStackEntry?.destination?.id == R.id.torConnectionAssistFragment) { + navController.navigate( + SettingsFragmentDirections.actionGlobalHomeFragment(), + ) + return true + } + } + return false + } } ===================================== mobile/android/fenix/app/src/main/java/org/mozilla/fenix/tor/TorConnectionAssistFragment.kt ===================================== @@ -19,7 +19,7 @@ import android.view.View import android.view.ViewGroup import androidx.appcompat.content.res.AppCompatResources import androidx.fragment.app.Fragment -import androidx.fragment.app.viewModels +import androidx.fragment.app.activityViewModels import androidx.lifecycle.Lifecycle import androidx.lifecycle.lifecycleScope import androidx.lifecycle.repeatOnLifecycle @@ -34,7 +34,7 @@ import org.mozilla.fenix.ext.hideToolbar class TorConnectionAssistFragment : Fragment(), UserInteractionHandler { private val TAG = "TorConnectionAssistFrag" - private val viewModel: TorConnectionAssistViewModel by viewModels() + private val viewModel: TorConnectionAssistViewModel by activityViewModels() private var _binding: FragmentTorConnectionAssistBinding? = null private val binding get() = _binding!! @@ -46,6 +46,11 @@ class TorConnectionAssistFragment : Fragment(), UserInteractionHandler { _binding = FragmentTorConnectionAssistBinding.inflate( inflater, container, false, ) + viewLifecycleOwner.lifecycleScope.launch { + repeatOnLifecycle(Lifecycle.State.STARTED) { + viewModel.collectLastKnownStatus() + } + } viewLifecycleOwner.lifecycleScope.launch { repeatOnLifecycle(Lifecycle.State.STARTED) { @@ -62,7 +67,6 @@ class TorConnectionAssistFragment : Fragment(), UserInteractionHandler { override fun onResume() { super.onResume() hideToolbar() - viewModel.handleTorConnectStateToScreen() // Covers the case where the app is backgrounded when the bootstrap finishes } override fun onViewCreated(view: View, savedInstanceState: Bundle?) { @@ -71,11 +75,7 @@ class TorConnectionAssistFragment : Fragment(), UserInteractionHandler { viewModel.progress().observe( viewLifecycleOwner, ) { progress -> - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) { - binding.torBootstrapProgressBar.setProgress(progress, true) - } else { - binding.torBootstrapProgressBar.progress = progress - } + setProgressBarCompat(progress) } viewModel.quickstartToggle().observe( @@ -95,6 +95,14 @@ class TorConnectionAssistFragment : Fragment(), UserInteractionHandler { } + private fun setProgressBarCompat(progress: Int) { + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) { + binding.torBootstrapProgressBar.setProgress(progress, true) + } else { + binding.torBootstrapProgressBar.progress = progress + } + } + private fun showScreen(screen: ConnectAssistUiState) { setProgressBar(screen) setSettingsButton(screen) @@ -269,7 +277,7 @@ class TorConnectionAssistFragment : Fragment(), UserInteractionHandler { private fun openHome() { Log.d(TAG, "openHome()") - findNavController().navigate(TorConnectionAssistFragmentDirections.actionStartupHome()) + viewModel.openHome(findNavController()) } private fun openSettings(preferenceToScrollTo: String? = null) { ===================================== mobile/android/fenix/app/src/main/java/org/mozilla/fenix/tor/TorConnectionAssistViewModel.kt ===================================== @@ -10,6 +10,7 @@ import androidx.lifecycle.AndroidViewModel import androidx.lifecycle.LifecycleCoroutineScope import androidx.lifecycle.LiveData import androidx.lifecycle.MutableLiveData +import androidx.navigation.NavController import kotlinx.coroutines.flow.MutableStateFlow import kotlinx.coroutines.flow.StateFlow import org.mozilla.fenix.ext.components @@ -44,20 +45,25 @@ class TorConnectionAssistViewModel( } init { - Log.d(TAG, "initiating TorConnectionAssistViewModel") + Log.d(TAG, "initiating TorConnectionAssistViewModel $this") _torController.registerTorListener(this) - handleTorConnectStateToScreen() // should cover the case of when we have an onBootStrapStateChange() event before this is initialized, which lead to being stuck on the splash screen } - private fun handleConnect( + var urlToLoadAfterConnecting: String? = null + + fun handleConnect( + urlToLoadAfterConnecting: String? = null, withDebugLogging: Boolean = false, lifecycleScope: LifecycleCoroutineScope? = null, ) { - Log.d(TAG, "handleConnect initiatingTorBootstrap with lifecycleScope = $lifecycleScope") - _torController.initiateTorBootstrap( - withDebugLogging = withDebugLogging, - lifecycleScope = lifecycleScope, - ) + this.urlToLoadAfterConnecting = urlToLoadAfterConnecting + if (_torController.lastKnownStatus.value.isOff()) { + Log.d(TAG, "handleConnect() triggered, initiatingTorBootstrap") + _torController.initiateTorBootstrap( + withDebugLogging = withDebugLogging, + lifecycleScope = lifecycleScope, + ) + } } fun handleQuickstartChecked(checked: Boolean) { @@ -96,18 +102,19 @@ class TorConnectionAssistViewModel( _progress.value = progress.toInt() } - handleTorConnectStateToScreen() } - fun handleTorConnectStateToScreen() { - when (_torController.lastKnownStatus) { - TorConnectState.Initial -> _torConnectScreen.value = ConnectAssistUiState.Splash - TorConnectState.Configuring -> handleConfiguring() - TorConnectState.AutoBootstrapping -> handleBootstrap() - TorConnectState.Bootstrapping -> handleBootstrap() - TorConnectState.Bootstrapped -> _shouldOpenHome.value = true - TorConnectState.Disabled -> _shouldOpenHome.value = true - TorConnectState.Error -> handleError() + suspend fun collectLastKnownStatus() { + _torController.lastKnownStatus.collect { + when (it) { + TorConnectState.Initial -> _torConnectScreen.value = ConnectAssistUiState.Splash + TorConnectState.Configuring -> handleConfiguring() + TorConnectState.AutoBootstrapping -> handleBootstrap() + TorConnectState.Bootstrapping -> handleBootstrap() + TorConnectState.Bootstrapped -> _shouldOpenHome.value = true + TorConnectState.Disabled -> _shouldOpenHome.value = true + TorConnectState.Error -> handleError() + } } } @@ -254,4 +261,10 @@ class TorConnectionAssistViewModel( } return true } + + fun openHome(navController: NavController) { + navController.navigate( + TorConnectionAssistFragmentDirections.actionHome(), + ) + } } ===================================== mobile/android/fenix/app/src/main/java/org/mozilla/fenix/tor/TorControllerGV.kt ===================================== @@ -4,6 +4,8 @@ package org.mozilla.fenix.tor import android.content.Context import android.util.Log import androidx.lifecycle.LifecycleCoroutineScope +import kotlinx.coroutines.flow.MutableStateFlow +import kotlinx.coroutines.flow.StateFlow import mozilla.components.browser.engine.gecko.GeckoEngine import org.mozilla.fenix.ext.components import org.mozilla.geckoview.TorIntegrationAndroid @@ -54,20 +56,22 @@ class TorControllerGV( private var torListeners = mutableListOf<TorEvents>() private var torLogListeners = mutableListOf<TorLogs>() - internal var lastKnownStatus = TorConnectState.Initial + private val _lastKnownStatus = MutableStateFlow(TorConnectState.Initial) + internal val lastKnownStatus: StateFlow<TorConnectState> = _lastKnownStatus + internal var lastKnownError: TorError? = null private var wasTorBootstrapped = false private var isTorRestarting = false private var isTorBootstrapped = false - get() = ((lastKnownStatus.isStarted()) && wasTorBootstrapped) + get() = ((_lastKnownStatus.value.isStarted()) && wasTorBootstrapped) private val entries = mutableListOf<Pair<String?, String?>>() override val logEntries get() = entries - override val isStarting get() = lastKnownStatus.isStarting() + override val isStarting get() = _lastKnownStatus.value.isStarting() override val isRestarting get() = isTorRestarting override val isBootstrapped get() = isTorBootstrapped - override val isConnected get() = (lastKnownStatus.isStarted() && !isTorRestarting) + override val isConnected get() = (_lastKnownStatus.value.isStarted() && !isTorRestarting) override var quickstart: Boolean get() { @@ -267,13 +271,13 @@ class TorControllerGV( } override fun setTorStopped() { - lastKnownStatus = TorConnectState.Configuring + _lastKnownStatus.value = TorConnectState.Configuring onTorStatusUpdate(null, lastKnownStatus.toString(), 0.0) onTorStopped() } override fun restartTor() { - if (!lastKnownStatus.isStarted() && wasTorBootstrapped) { + if (!_lastKnownStatus.value.isStarted() && wasTorBootstrapped) { // If we aren't started, but we were previously bootstrapped, // then we handle a "restart" request as a "start" restart initiateTorBootstrap() @@ -321,42 +325,22 @@ class TorControllerGV( } } - if (lastKnownStatus.isOff() && newState.isStarting()) { + if (_lastKnownStatus.value.isOff() && newState.isStarting()) { isTorRestarting = false } - lastKnownStatus = newState + _lastKnownStatus.value = newState onTorStatusUpdate(null, newStateVal, null) } // TorEventsBootstrapStateChangeListener override fun onBootstrapProgress(progress: Double, hasWarnings: Boolean) { - Log.d(TAG, "onBootstrapProgress($progress, $hasWarnings)") - // TODO: onBootstrapProgress should only be used to change the shown - // bootstrap percentage or a Tor log option during a "Bootstrapping" - // stage. - // The progress value should not be used to change the `lastKnownStatus` - // value or determine if a bootstrap has started or completed. The - // TorConnectStage should be used instead. - if (progress == 100.0) { - lastKnownStatus = TorConnectState.Bootstrapped - wasTorBootstrapped = true - onTorConnected() - } else if (lastKnownStatus == TorConnectState.Bootstrapping) { - onTorConnecting() - } - onTorStatusUpdate("", lastKnownStatus.toTorStatus().status, progress) + Log.d(TAG, "onBootstrapProgress(progress = $progress, hasWarnings = $hasWarnings)") + onTorStatusUpdate("", _lastKnownStatus.value.toTorStatus().status, progress) } // TorEventsBootstrapStateChangeListener - override fun onBootstrapComplete() { - // TODO: There should be no need to respond to the BootstrapComplete - // event if we are already handling TorConnectStage.Bootstrapped. - // In particular, `lastKnownStatus` and onTorConnected should be set in - // response to a change in TorConnectStage instead. - lastKnownStatus = TorConnectState.Bootstrapped - this.onTorConnected() - } + override fun onBootstrapComplete() = Unit // TorEventsBootstrapStateChangeListener override fun onBootstrapError(code: String?, message: String?, phase: String?, reason: String?) { ===================================== mobile/android/fenix/app/src/main/res/layout/fenix_snackbar.xml ===================================== @@ -21,6 +21,12 @@ android:paddingStart="16dp" android:paddingEnd="16dp"> + <!-- + TextView below changed as part of tor-browser#43229 to match the designs + https://www.figma.com/design/vXrWeiV2IlKx5IIZVLtxBX/Android-Components?node… screenshot shown here + Line spacing eyeballed from screenshot here + https://gitlab.torproject.org/tpo/applications/tor-browser/-/merge_requests… + --> <TextView android:id="@+id/snackbar_text" android:layout_width="0dp" @@ -29,8 +35,9 @@ android:letterSpacing="0.05" android:minHeight="46dp" android:maxLines="2" - android:paddingTop="8dp" - android:paddingBottom="8dp" + android:paddingTop="12dp" + android:paddingBottom="12dp" + android:lineSpacingExtra="8sp" android:textAlignment="textStart" android:textColor="@color/photonWhite" android:textSize="18sp" ===================================== mobile/android/fenix/app/src/main/res/navigation/nav_graph.xml ===================================== @@ -27,6 +27,12 @@ app:popUpTo="@id/startupFragment" app:popUpToInclusive="true" /> + <action + android:id="@+id/action_connect_to_tor_before_opening_links" + app:destination="@+id/torConnectionAssistFragment" + app:popUpTo="@id/torConnectionAssistFragment" + app:popUpToInclusive="true"/> + <action android:id="@+id/action_global_home" app:destination="@id/homeFragment" @@ -264,7 +270,7 @@ <fragment android:id="@+id/torConnectionAssistFragment" android:name="org.mozilla.fenix.tor.TorConnectionAssistFragment" - tools:layout="@layout/fragment_home"> + tools:layout="@layout/fragment_tor_connection_assist"> <action android:id="@+id/action_home" app:destination="@id/homeFragment" ===================================== mobile/android/fenix/app/src/main/res/values/torbrowser_strings.xml ===================================== @@ -149,4 +149,31 @@ <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/938f751… -- View it on GitLab: https://gitlab.torproject.org/tpo/applications/tor-browser/-/commit/938f751… You're receiving this email because of your account on gitlab.torproject.org.
1 0
0 0
[Git][tpo/applications/tor-browser-build][maint-13.5] Update STUN servers in Snowflake builtin bridges
by morgan (@morgan) 04 Dec '24

04 Dec '24
morgan pushed to branch maint-13.5 at The Tor Project / Applications / tor-browser-build Commits: 7934e0fb by Cecylia Bocovich at 2024-12-04T19:55:42+00:00 Update STUN servers in Snowflake builtin bridges This removes STUN servers that are unreliable or no longer support NAT behaviour discovery, and adds a few new servers. - - - - - 1 changed file: - projects/tor-expert-bundle/pt_config.json Changes: ===================================== projects/tor-expert-bundle/pt_config.json ===================================== @@ -23,8 +23,8 @@ "obfs4 51.222.13.177:80 5EDAC3B810E12B01F6FD8050D2FD3E277B289A08 cert=2uplIpLQ0q9+0qMFrK5pkaYRDOe460LL9WHBvatgkuRr/SL31wBOEupaMMJ6koRE6Ld0ew iat-mode=0" ], "snowflake" : [ - "snowflake 192.0.2.3:80 2B280B23E1107BB62ABFC40DDCC8824814F80A72 fingerprint=2B280B23E1107BB62ABFC40DDCC8824814F80A72 url=https://1098762253.rsc.cdn77.org/ fronts=www.cdn77.com,www.phpmyadmin.net ice=stun:stun.l.google.com:19302,stun:stun.antisip.com:3478,stun:stun.bluesip.net:3478,stun:stun.dus.net:3478,stun:stun.epygi.com:3478,stun:stun.sonetel.com:3478,stun:stun.uls.co.za:3478,stun:stun.voipgate.com:3478,stun:stun.voys.nl:3478 utls-imitate=hellorandomizedalpn", - "snowflake 192.0.2.4:80 8838024498816A039FCBBAB14E6F40A0843051FA fingerprint=8838024498816A039FCBBAB14E6F40A0843051FA url=https://1098762253.rsc.cdn77.org/ fronts=www.cdn77.com,www.phpmyadmin.net ice=stun:stun.l.google.com:19302,stun:stun.antisip.com:3478,stun:stun.bluesip.net:3478,stun:stun.dus.net:3478,stun:stun.epygi.com:3478,stun:stun.sonetel.net:3478,stun:stun.uls.co.za:3478,stun:stun.voipgate.com:3478,stun:stun.voys.nl:3478 utls-imitate=hellorandomizedalpn" + "snowflake 192.0.2.3:80 2B280B23E1107BB62ABFC40DDCC8824814F80A72 fingerprint=2B280B23E1107BB62ABFC40DDCC8824814F80A72 url=https://1098762253.rsc.cdn77.org/ fronts=www.cdn77.com,www.phpmyadmin.net ice=stun:stun.antisip.com:3478,stun:stun.epygi.com:3478,stun:stun.uls.co.za:3478,stun:stun.voipgate.com:3478,stun:stun.mixvoip.com:3478,stun:stun.nextcloud.com:3478,stun:stun.bethesda.net:3478,stun:stun.nextcloud.com:443 utls-imitate=hellorandomizedalpn", + "snowflake 192.0.2.4:80 8838024498816A039FCBBAB14E6F40A0843051FA fingerprint=8838024498816A039FCBBAB14E6F40A0843051FA url=https://1098762253.rsc.cdn77.org/ fronts=www.cdn77.com,www.phpmyadmin.net ice=stun:stun.antisip.com:3478,stun:stun.epygi.com:3478,stun:stun.uls.co.za:3478,stun:stun.voipgate.com:3478,stun:stun.mixvoip.com:3478,stun:stun.nextcloud.com:3478,stun:stun.bethesda.net:3478,stun:stun.nextcloud.com:443 utls-imitate=hellorandomizedalpn" ] } } View it on GitLab: https://gitlab.torproject.org/tpo/applications/tor-browser-build/-/commit/7… -- View it on GitLab: https://gitlab.torproject.org/tpo/applications/tor-browser-build/-/commit/7… You're receiving this email because of your account on gitlab.torproject.org.
1 0
0 0
[Git][tpo/applications/tor-browser-build][maint-14.0] Update STUN servers in Snowflake builtin bridges
by morgan (@morgan) 04 Dec '24

04 Dec '24
morgan pushed to branch maint-14.0 at The Tor Project / Applications / tor-browser-build Commits: 81a1dab9 by Cecylia Bocovich at 2024-12-04T19:55:25+00:00 Update STUN servers in Snowflake builtin bridges This removes STUN servers that are unreliable or no longer support NAT behaviour discovery, and adds a few new servers. - - - - - 1 changed file: - projects/tor-expert-bundle/pt_config.json Changes: ===================================== projects/tor-expert-bundle/pt_config.json ===================================== @@ -23,8 +23,8 @@ "obfs4 51.222.13.177:80 5EDAC3B810E12B01F6FD8050D2FD3E277B289A08 cert=2uplIpLQ0q9+0qMFrK5pkaYRDOe460LL9WHBvatgkuRr/SL31wBOEupaMMJ6koRE6Ld0ew iat-mode=0" ], "snowflake" : [ - "snowflake 192.0.2.3:80 2B280B23E1107BB62ABFC40DDCC8824814F80A72 fingerprint=2B280B23E1107BB62ABFC40DDCC8824814F80A72 url=https://1098762253.rsc.cdn77.org/ fronts=www.cdn77.com,www.phpmyadmin.net ice=stun:stun.l.google.com:19302,stun:stun.antisip.com:3478,stun:stun.bluesip.net:3478,stun:stun.dus.net:3478,stun:stun.epygi.com:3478,stun:stun.sonetel.com:3478,stun:stun.uls.co.za:3478,stun:stun.voipgate.com:3478,stun:stun.voys.nl:3478 utls-imitate=hellorandomizedalpn", - "snowflake 192.0.2.4:80 8838024498816A039FCBBAB14E6F40A0843051FA fingerprint=8838024498816A039FCBBAB14E6F40A0843051FA url=https://1098762253.rsc.cdn77.org/ fronts=www.cdn77.com,www.phpmyadmin.net ice=stun:stun.l.google.com:19302,stun:stun.antisip.com:3478,stun:stun.bluesip.net:3478,stun:stun.dus.net:3478,stun:stun.epygi.com:3478,stun:stun.sonetel.net:3478,stun:stun.uls.co.za:3478,stun:stun.voipgate.com:3478,stun:stun.voys.nl:3478 utls-imitate=hellorandomizedalpn" + "snowflake 192.0.2.3:80 2B280B23E1107BB62ABFC40DDCC8824814F80A72 fingerprint=2B280B23E1107BB62ABFC40DDCC8824814F80A72 url=https://1098762253.rsc.cdn77.org/ fronts=www.cdn77.com,www.phpmyadmin.net ice=stun:stun.antisip.com:3478,stun:stun.epygi.com:3478,stun:stun.uls.co.za:3478,stun:stun.voipgate.com:3478,stun:stun.mixvoip.com:3478,stun:stun.nextcloud.com:3478,stun:stun.bethesda.net:3478,stun:stun.nextcloud.com:443 utls-imitate=hellorandomizedalpn", + "snowflake 192.0.2.4:80 8838024498816A039FCBBAB14E6F40A0843051FA fingerprint=8838024498816A039FCBBAB14E6F40A0843051FA url=https://1098762253.rsc.cdn77.org/ fronts=www.cdn77.com,www.phpmyadmin.net ice=stun:stun.antisip.com:3478,stun:stun.epygi.com:3478,stun:stun.uls.co.za:3478,stun:stun.voipgate.com:3478,stun:stun.mixvoip.com:3478,stun:stun.nextcloud.com:3478,stun:stun.bethesda.net:3478,stun:stun.nextcloud.com:443 utls-imitate=hellorandomizedalpn" ] } } View it on GitLab: https://gitlab.torproject.org/tpo/applications/tor-browser-build/-/commit/8… -- View it on GitLab: https://gitlab.torproject.org/tpo/applications/tor-browser-build/-/commit/8… You're receiving this email because of your account on gitlab.torproject.org.
1 0
0 0
[Git][tpo/applications/tor-browser-build][main] Update STUN servers in Snowflake builtin bridges
by morgan (@morgan) 04 Dec '24

04 Dec '24
morgan pushed to branch main at The Tor Project / Applications / tor-browser-build Commits: f60ea24e by Cecylia Bocovich at 2024-12-04T19:53:35+00:00 Update STUN servers in Snowflake builtin bridges This removes STUN servers that are unreliable or no longer support NAT behaviour discovery, and adds a few new servers. - - - - - 1 changed file: - projects/tor-expert-bundle/pt_config.json Changes: ===================================== projects/tor-expert-bundle/pt_config.json ===================================== @@ -23,8 +23,8 @@ "obfs4 51.222.13.177:80 5EDAC3B810E12B01F6FD8050D2FD3E277B289A08 cert=2uplIpLQ0q9+0qMFrK5pkaYRDOe460LL9WHBvatgkuRr/SL31wBOEupaMMJ6koRE6Ld0ew iat-mode=0" ], "snowflake" : [ - "snowflake 192.0.2.3:80 2B280B23E1107BB62ABFC40DDCC8824814F80A72 fingerprint=2B280B23E1107BB62ABFC40DDCC8824814F80A72 url=https://1098762253.rsc.cdn77.org/ fronts=www.cdn77.com,www.phpmyadmin.net ice=stun:stun.l.google.com:19302,stun:stun.antisip.com:3478,stun:stun.bluesip.net:3478,stun:stun.dus.net:3478,stun:stun.epygi.com:3478,stun:stun.sonetel.com:3478,stun:stun.uls.co.za:3478,stun:stun.voipgate.com:3478,stun:stun.voys.nl:3478 utls-imitate=hellorandomizedalpn", - "snowflake 192.0.2.4:80 8838024498816A039FCBBAB14E6F40A0843051FA fingerprint=8838024498816A039FCBBAB14E6F40A0843051FA url=https://1098762253.rsc.cdn77.org/ fronts=www.cdn77.com,www.phpmyadmin.net ice=stun:stun.l.google.com:19302,stun:stun.antisip.com:3478,stun:stun.bluesip.net:3478,stun:stun.dus.net:3478,stun:stun.epygi.com:3478,stun:stun.sonetel.net:3478,stun:stun.uls.co.za:3478,stun:stun.voipgate.com:3478,stun:stun.voys.nl:3478 utls-imitate=hellorandomizedalpn" + "snowflake 192.0.2.3:80 2B280B23E1107BB62ABFC40DDCC8824814F80A72 fingerprint=2B280B23E1107BB62ABFC40DDCC8824814F80A72 url=https://1098762253.rsc.cdn77.org/ fronts=www.cdn77.com,www.phpmyadmin.net ice=stun:stun.antisip.com:3478,stun:stun.epygi.com:3478,stun:stun.uls.co.za:3478,stun:stun.voipgate.com:3478,stun:stun.mixvoip.com:3478,stun:stun.nextcloud.com:3478,stun:stun.bethesda.net:3478,stun:stun.nextcloud.com:443 utls-imitate=hellorandomizedalpn", + "snowflake 192.0.2.4:80 8838024498816A039FCBBAB14E6F40A0843051FA fingerprint=8838024498816A039FCBBAB14E6F40A0843051FA url=https://1098762253.rsc.cdn77.org/ fronts=www.cdn77.com,www.phpmyadmin.net ice=stun:stun.antisip.com:3478,stun:stun.epygi.com:3478,stun:stun.uls.co.za:3478,stun:stun.voipgate.com:3478,stun:stun.mixvoip.com:3478,stun:stun.nextcloud.com:3478,stun:stun.bethesda.net:3478,stun:stun.nextcloud.com:443 utls-imitate=hellorandomizedalpn" ] } } View it on GitLab: https://gitlab.torproject.org/tpo/applications/tor-browser-build/-/commit/f… -- View it on GitLab: https://gitlab.torproject.org/tpo/applications/tor-browser-build/-/commit/f… You're receiving this email because of your account on gitlab.torproject.org.
1 0
0 0
[Git][tpo/applications/tor-browser-build][main] Bug 41331: Make update_responses find linux-aarch64 mar-tools
by boklm (@boklm) 04 Dec '24

04 Dec '24
boklm pushed to branch main at The Tor Project / Applications / tor-browser-build Commits: 1453e769 by NoisyCoil at 2024-12-04T19:40:21+01:00 Bug 41331: Make update_responses find linux-aarch64 mar-tools - - - - - 1 changed file: - tools/update-responses/update_responses Changes: ===================================== tools/update-responses/update_responses ===================================== @@ -500,7 +500,7 @@ sub write_downloads_json { sub marzip_path { my ($config, $version) = @_; - for my $osname (qw/linux-x86_64 linux-i686 macos-x86_64 windows-x86_64 windows-i686/) { + for my $osname (qw/linux-x86_64 linux-i686 linux-aarch64 macos-x86_64 windows-x86_64 windows-i686/) { my $marzip = glob(version_dir($config, $version) . "/mar-tools-$osname-*.zip"); if ($marzip && -f $marzip) { return $marzip; View it on GitLab: https://gitlab.torproject.org/tpo/applications/tor-browser-build/-/commit/1… -- View it on GitLab: https://gitlab.torproject.org/tpo/applications/tor-browser-build/-/commit/1… 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! Bug 42305: Add script to combine translation files across versions.
by Pier Angelo Vendrame (@pierov) 04 Dec '24

04 Dec '24
Pier Angelo Vendrame pushed to branch tor-browser-128.5.0esr-14.5-1 at The Tor Project / Applications / Tor Browser Commits: 781f3a87 by Henry Wilkes at 2024-12-04T17:19:49+00:00 fixup! Bug 42305: Add script to combine translation files across versions. Bug 43337: Add option to search for translation files in only certain directories, and to specify the directory they should be placed in in the translation repository. - - - - - 174cf42e by Henry Wilkes at 2024-12-04T17:19:49+00:00 fixup! Add CI for Tor Browser Bug 43337: Add branding to translation CI. Each brand.ftl and brand.properties is identical between releases, so we only need to send `tb-release` to the translation repository. - - - - - 2 changed files: - .gitlab/ci/update-translations.yml - tools/torbrowser/l10n/combine-translation-versions.py Changes: ===================================== .gitlab/ci/update-translations.yml ===================================== @@ -20,18 +20,29 @@ combine-en-US-translations: image: python variables: PIP_CACHE_DIR: "$CI_PROJECT_DIR/.cache/pip" - TRANSLATION_FILES: ' - tor-browser:tor-browser.ftl - tor-browser:aboutTBUpdate.dtd - tor-browser:torbutton.dtd - tor-browser:onionLocation.properties - tor-browser:settings.properties - tor-browser:torbutton.properties - tor-browser:torConnect.properties - tor-browser:torlauncher.properties - base-browser:base-browser.ftl - fenix-torbrowserstringsxml:torbrowser_strings.xml - ' + TRANSLATION_FILES: '[ + { + "name": "brand.ftl", + "where": ["browser/branding/tb-release", "toolkit/torbutton"], + "branch": "tor-browser", + "directory": "branding" + }, + { + "name": "brand.properties", + "where": ["browser/branding/tb-release", "toolkit/torbutton"], + "branch": "tor-browser" + }, + { "name": "tor-browser.ftl", "branch": "tor-browser" }, + { "name": "aboutTBUpdate.dtd", "branch": "tor-browser" }, + { "name": "torbutton.dtd", "branch": "tor-browser" }, + { "name": "onionLocation.properties", "branch": "tor-browser" }, + { "name": "settings.properties", "branch": "tor-browser" }, + { "name": "torbutton.properties", "branch": "tor-browser" }, + { "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" } + ]' TRANSLATION_INCLUDE_LEGACY: "true" cache: paths: ===================================== tools/torbrowser/l10n/combine-translation-versions.py ===================================== @@ -15,7 +15,7 @@ arg_parser.add_argument( "current_branch", metavar="<current-branch>", help="branch for the newest version" ) arg_parser.add_argument( - "filenames", metavar="<filenames>", help="name of the translation files" + "files", metavar="<files>", help="JSON specifying the translation files" ) arg_parser.add_argument("outname", metavar="<json>", help="name of the json output") @@ -67,6 +67,14 @@ def git_lines(git_args: list[str]) -> list[str]: return [line for line in git_text(git_args).split("\n") if line] +class TranslationFile: + """Represents a translation file.""" + + def __init__(self, path: str, content: str) -> None: + self.path = path + self.content = content + + class BrowserBranch: """Represents a browser git branch.""" @@ -134,11 +142,27 @@ class BrowserBranch: def __gt__(self, other: "BrowserBranch") -> bool: return self._ordered > other._ordered - def get_file_content(self, filename: str) -> str | None: + def _matching_dirs(self, path: str, dir_list: list[str]) -> bool: + """Test that a path is contained in the list of dirs. + + :param path: The path to check. + :param dir_list: The list of directories to check against. + :returns: Whether the path matches. + """ + for dir_path in dir_list: + if os.path.commonpath([dir_path, path]) == dir_path: + return True + return False + + def get_file( + self, filename: str, search_dirs: list[str] | None + ) -> TranslationFile | None: """Fetch the file content for the named file in this branch. :param filename: The name of the file to fetch the content for. - :returns: The file content, or `None` if no file could be found. + :param search_dirs: The directories to restrict the search to, or None + to search for the file anywhere. + :returns: The file, or `None` if no file could be found. """ if self._file_paths is None: if not self._is_head: @@ -152,7 +176,10 @@ class BrowserBranch: ) matching = [ - path for path in self._file_paths if os.path.basename(path) == filename + path + for path in self._file_paths + if os.path.basename(path) == filename + and (search_dirs is None or self._matching_dirs(path, search_dirs)) ] if not matching: return None @@ -161,7 +188,9 @@ class BrowserBranch: path = matching[0] - return git_text(["cat-file", "blob", f"{self._ref}:{path}"]) + return TranslationFile( + path=path, content=git_text(["cat-file", "blob", f"{self._ref}:{path}"]) + ) def get_stable_branch( @@ -254,48 +283,63 @@ if os.environ.get("TRANSLATION_INCLUDE_LEGACY", "") != "true": files_list = [] -for translation_branch, name in ( - part.strip().split(":", 1) for part in args.filenames.split(" ") if part.strip() -): - current_content = current_branch.get_file_content(name) - stable_content = stable_branch.get_file_content(name) +for file_dict in json.loads(args.files): + name = file_dict["name"] + where_dirs = file_dict.get("where", None) + current_file = current_branch.get_file(name, where_dirs) + stable_file = stable_branch.get_file(name, where_dirs) - if current_content is None and stable_content is None: + if current_file is None and stable_file is None: # No file in either branch. logger.warning(f"{name} does not exist in either the current or stable branch") - elif current_content is None: + elif current_file is None: logger.warning(f"{name} deleted in the current branch") - elif stable_content is None: + elif stable_file is None: logger.warning(f"{name} does not exist in the stable branch") + elif current_file.path != stable_file.path: + logger.warning( + f"{name} has different paths in the current and stable branch. " + f"{current_file.path} : {stable_file.path}" + ) content = combine_files( name, - current_content, - stable_content, + None if current_file is None else current_file.content, + None if stable_file is None else stable_file.content, f"Will be unused in Tor Browser {current_branch.browser_version}!", ) if legacy_branch: - legacy_content = legacy_branch.get_file_content(name) - if ( - legacy_content is not None - and current_content is None - and stable_content is None - ): + 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") - elif legacy_content is None: + elif legacy_file is None: logger.warning(f"{name} does not exist in the legacy branch") + elif stable_file is not None and legacy_file.path != stable_file.path: + logger.warning( + f"{name} has different paths in the stable and legacy branch. " + f"{stable_file.path} : {legacy_file.path}" + ) + elif current_file is not None and legacy_file.path != current_file.path: + logger.warning( + f"{name} has different paths in the current and legacy branch. " + f"{current_file.path} : {legacy_file.path}" + ) + content = combine_files( name, content, - legacy_content, + legacy_file.content, f"Unused in Tor Browser {stable_branch.browser_version}!", ) files_list.append( { "name": name, - "branch": translation_branch, + # If "directory" is unspecified, we place the file directly beneath + # en-US/ in the translation repository. i.e. "". + "directory": file_dict.get("directory", ""), + "branch": file_dict["branch"], "content": content, } ) View it on GitLab: https://gitlab.torproject.org/tpo/applications/tor-browser/-/compare/d80411… -- View it on GitLab: https://gitlab.torproject.org/tpo/applications/tor-browser/-/compare/d80411… 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! Tor Browser strings
by Pier Angelo Vendrame (@pierov) 04 Dec '24

04 Dec '24
Pier Angelo Vendrame pushed to branch tor-browser-128.5.0esr-14.5-1 at The Tor Project / Applications / Tor Browser Commits: 5b8b20de by Henry Wilkes at 2024-12-04T10:18:40+00:00 fixup! Tor Browser strings Bug 43336: Move branding strings from torbutton to browser/branding. - - - - - d8041158 by Henry Wilkes at 2024-12-04T10:19:19+00:00 fixup! Add TorStrings module for localization Bug 43336: Move branding strings out of torbutton. - - - - - 10 changed files: - toolkit/torbutton/chrome/locale/en-US/branding/brand.ftl → browser/branding/tb-alpha/locales/en-US/brand.ftl - toolkit/torbutton/chrome/locale/en-US/brand.properties → browser/branding/tb-alpha/locales/en-US/brand.properties - browser/branding/tb-alpha/locales/jar.mn - + browser/branding/tb-nightly/locales/en-US/brand.ftl - + browser/branding/tb-nightly/locales/en-US/brand.properties - browser/branding/tb-nightly/locales/jar.mn - + browser/branding/tb-release/locales/en-US/brand.ftl - + browser/branding/tb-release/locales/en-US/brand.properties - browser/branding/tb-release/locales/jar.mn - toolkit/torbutton/jar.mn Changes: ===================================== toolkit/torbutton/chrome/locale/en-US/branding/brand.ftl → browser/branding/tb-alpha/locales/en-US/brand.ftl ===================================== ===================================== toolkit/torbutton/chrome/locale/en-US/brand.properties → browser/branding/tb-alpha/locales/en-US/brand.properties ===================================== ===================================== browser/branding/tb-alpha/locales/jar.mn ===================================== @@ -3,4 +3,9 @@ # License, v. 2.0. If a copy of the MPL was not distributed with this # file, You can obtain one at http://mozilla.org/MPL/2.0/. -# We provide all brand files in torbutton +[localization] @AB_CD@.jar: + branding (%*.ftl) + +@AB_CD@.jar: +% locale branding @AB_CD@ %locale/branding/ + locale/branding/brand.properties (%brand.properties) ===================================== browser/branding/tb-nightly/locales/en-US/brand.ftl ===================================== @@ -0,0 +1,14 @@ +# For Tor Browser, we use a new file (different than the brand.ftl file +# that is used by Firefox) to avoid picking up the -brand-short-name values +# that Mozilla includes in the Firefox language packs. + +-brand-shorter-name = Tor Browser +-brand-short-name = Tor Browser +-brand-full-name = Tor Browser +# This brand name can be used in messages where the product name needs to +# remain unchanged across different versions (Nightly, Beta, etc.). +-brand-product-name = Tor Browser +-vendor-short-name = Tor Project +# "Tor" is a trademark names, so should not be translated (not including the quote marks, which can be localized). +# "The Tor Project, Inc." is an organisation name. +trademarkInfo = “Tor” and the Tor logo are registered trademarks of The Tor Project, Inc. ===================================== browser/branding/tb-nightly/locales/en-US/brand.properties ===================================== @@ -0,0 +1,8 @@ +# Copyright (c) 2022, The Tor Project, Inc. +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/. + +brandShorterName=Tor Browser +brandShortName=Tor Browser +brandFullName=Tor Browser ===================================== browser/branding/tb-nightly/locales/jar.mn ===================================== @@ -3,4 +3,9 @@ # License, v. 2.0. If a copy of the MPL was not distributed with this # file, You can obtain one at http://mozilla.org/MPL/2.0/. -# We provide all brand files in torbutton +[localization] @AB_CD@.jar: + branding (%*.ftl) + +@AB_CD@.jar: +% locale branding @AB_CD@ %locale/branding/ + locale/branding/brand.properties (%brand.properties) ===================================== browser/branding/tb-release/locales/en-US/brand.ftl ===================================== @@ -0,0 +1,14 @@ +# For Tor Browser, we use a new file (different than the brand.ftl file +# that is used by Firefox) to avoid picking up the -brand-short-name values +# that Mozilla includes in the Firefox language packs. + +-brand-shorter-name = Tor Browser +-brand-short-name = Tor Browser +-brand-full-name = Tor Browser +# This brand name can be used in messages where the product name needs to +# remain unchanged across different versions (Nightly, Beta, etc.). +-brand-product-name = Tor Browser +-vendor-short-name = Tor Project +# "Tor" is a trademark names, so should not be translated (not including the quote marks, which can be localized). +# "The Tor Project, Inc." is an organisation name. +trademarkInfo = “Tor” and the Tor logo are registered trademarks of The Tor Project, Inc. ===================================== browser/branding/tb-release/locales/en-US/brand.properties ===================================== @@ -0,0 +1,8 @@ +# Copyright (c) 2022, The Tor Project, Inc. +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/. + +brandShorterName=Tor Browser +brandShortName=Tor Browser +brandFullName=Tor Browser ===================================== browser/branding/tb-release/locales/jar.mn ===================================== @@ -3,4 +3,9 @@ # License, v. 2.0. If a copy of the MPL was not distributed with this # file, You can obtain one at http://mozilla.org/MPL/2.0/. -# We provide all brand files in torbutton +[localization] @AB_CD@.jar: + branding (%*.ftl) + +@AB_CD@.jar: +% locale branding @AB_CD@ %locale/branding/ + locale/branding/brand.properties (%brand.properties) ===================================== toolkit/torbutton/jar.mn ===================================== @@ -4,8 +4,5 @@ torbutton.jar: % resource torbutton % % category l10n-registry torbutton resource://torbutton/locale/{locale}/ -# browser branding -% override chrome://branding/locale/brand.properties chrome://torbutton/locale/brand.properties - % locale torbutton en-US %locale/en-US/ locale/en-US/ (chrome/locale/en-US/*) View it on GitLab: https://gitlab.torproject.org/tpo/applications/tor-browser/-/compare/395fc1… -- View it on GitLab: https://gitlab.torproject.org/tpo/applications/tor-browser/-/compare/395fc1… You're receiving this email because of your account on gitlab.torproject.org.
1 0
0 0
[Git][tpo/applications/tor-browser-build][main] 2 commits: Bug 43336: Update handling of translation files.
by Pier Angelo Vendrame (@pierov) 04 Dec '24

04 Dec '24
Pier Angelo Vendrame pushed to branch main at The Tor Project / Applications / tor-browser-build Commits: 61b37707 by Henry Wilkes at 2024-12-03T13:51:42+00:00 Bug 43336: Update handling of translation files. We make the handling of translation files more consistent between builds. For `base-browser` files: + We no longer copy to `browser/chrome/browser/` because we no longer have .properties files in this branch. For `tor-browser` files: + We use a symbolic link to translate from ja to ja-JP-mac. + We use pushd and popd. + We only copy the .properties files to torbutton since these are the only files left in this directory. - - - - - 6cf8f931 by Henry Wilkes at 2024-12-04T15:49:59+00:00 Bug 43336: Move tor-browser branding files to branding directory. - - - - - 1 changed file: - projects/firefox/build Changes: ===================================== projects/firefox/build ===================================== @@ -114,6 +114,8 @@ export MACH_BUILD_PYTHON_NATIVE_PACKAGE_SOURCE=system # Create .mozbuild to avoid interactive prompt in configure mkdir "$HOME/.mozbuild" +branding_dir=browser/branding/[% c("var/branding_directory_prefix") %]-[% c("var/channel") %] + [% IF c("var/has_l10n") -%] supported_locales="[% tmpl(c('var/locales').join(' ')) %]" @@ -129,28 +131,30 @@ mkdir "$HOME/.mozbuild" for lang in $supported_locales; do # Fluent mv $lang/base-browser.ftl "$l10ncentral/$lang/toolkit/toolkit/global/" - # Properties (they use a different directory) - mv $lang/* "$l10ncentral/$lang/browser/chrome/browser/" done popd [% IF c("var/tor-browser") -%] - # We will have to keep the torbutton.jar until we stop using dtds, because - # if we move them to the browser locale directory, browser.xhtml is not - # loaded. tar -C "$rootdir" -xf "$rootdir/[% c('input_files_by_name/translation-tor-browser') %]" - transl_tor_browser="$rootdir/translation-tor-browser" + pushd "$rootdir/translation-tor-browser" + ln -s ja ja-JP-mac + for lang in $supported_locales; do + mv $lang/tor-browser.ftl "$l10ncentral/$lang/toolkit/toolkit/global/" + # Branding. Currently all releases use the same branding. + l10n_branding_dir="$l10ncentral/$lang/$branding_dir/" + mkdir -p "$l10n_branding_dir" + mv $lang/branding/brand.ftl "$l10n_branding_dir" + mv $lang/brand.properties "$l10n_branding_dir" + done + popd + + # torbutton properties files. + # TODO: Remove once we no longer have torbutton locale files. torbutton_locales="toolkit/torbutton/chrome/locale/" torbutton_jar="toolkit/torbutton/jar.mn" for lang in $supported_locales; do - source_lang=$lang - [% IF c("var/macos") -%] - if [ "$lang" == "ja-JP-mac" ]; then - source_lang="ja" - fi - [% END -%] - mv "$transl_tor_browser/$source_lang/tor-browser.ftl" "$l10ncentral/$lang/toolkit/toolkit/global/" - mv "$transl_tor_browser/$source_lang" "$torbutton_locales/$lang" + mkdir -p "$torbutton_locales/$lang" + mv "$rootdir/translation-tor-browser/$lang"/*.properties "$torbutton_locales/$lang/" echo "% locale torbutton $lang %locale/$lang/" >> "$torbutton_jar" echo " locale/$lang (chrome/locale/$lang/*)" >> "$torbutton_jar" done @@ -176,7 +180,7 @@ echo "Starting ./mach configure $(date)" --with-distribution-id=org.torproject \ --with-base-browser-version=[% c("var/torbrowser_version") %] \ [% IF c("var/updater_enabled") -%]--enable-update-channel=[% c("var/channel") %][% END %] \ - [% IF !c("var/base-browser") -%]--with-branding=browser/branding/[% c("var/branding_directory_prefix") %]-[% c("var/channel") %][% END %] \ + [% IF !c("var/base-browser") -%]--with-branding="$branding_dir"[% END %] \ [% IF !c("var/rlbox") -%]--without-wasm-sandboxed-libraries[% END %] echo "Starting ./mach build $(date)" View it on GitLab: https://gitlab.torproject.org/tpo/applications/tor-browser-build/-/compare/… -- View it on GitLab: https://gitlab.torproject.org/tpo/applications/tor-browser-build/-/compare/… 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] 3 commits: fixup! Bug 31740: Remove some unnecessary RemoteSettings instances
by Pier Angelo Vendrame (@pierov) 04 Dec '24

04 Dec '24
Pier Angelo Vendrame pushed to branch mullvad-browser-128.5.0esr-14.5-1 at The Tor Project / Applications / Mullvad Browser Commits: 93162bec by cypherpunks1 at 2024-12-04T10:41:13+01:00 fixup! Bug 31740: Remove some unnecessary RemoteSettings instances Bug 43334: Restore RemoteSettings dumps for devtools-compatibility-browsers and devtools-devices - - - - - cc08546c by NoisyCoil at 2024-12-04T10:41:53+01:00 fixup! Base Browser's .mozconfigs. Bug 43340: Add mozconfig-linux-aarch64-dev Copy mozconfig-linux-x86_64-dev, except that linux-aarch64 does not support the {enable,disable}-eme options - - - - - 5f129674 by Pier Angelo Vendrame at 2024-12-04T10:43:03+01:00 fixup! MB 38: Mullvad Browser configuration Bug 43340: Add mozconfig-linux-aarch64-dev - - - - - 2 changed files: - + mozconfig-linux-aarch64-dev - services/settings/dumps/main/moz.build Changes: ===================================== mozconfig-linux-aarch64-dev ===================================== @@ -0,0 +1,19 @@ +. $topsrcdir/browser/config/mozconfigs/mullvad-browser + +# This mozconfig file is not used in official builds. +# It is only intended to be used when doing incremental Linux builds +# during development. + +# Moz switched to lld for all Linux targets in Bug 1839739. +ac_add_options --enable-linker=lld + +export MOZILLA_OFFICIAL= +ac_add_options --with-branding=browser/branding/mb-nightly + +ac_add_options --enable-default-toolkit=cairo-gtk3 + +ac_add_options --disable-strip +ac_add_options --disable-install-strip + +ac_add_options --with-base-browser-version=dev-build +ac_add_options --disable-base-browser-update ===================================== services/settings/dumps/main/moz.build ===================================== @@ -14,6 +14,8 @@ if not CONFIG["MOZ_BUILD_APP"].startswith("mobile/"): FINAL_TARGET_FILES.defaults.settings.main += [ "anti-tracking-url-decoration.json", "cookie-banner-rules-list.json", + "devtools-compatibility-browsers.json", + "devtools-devices.json", "example.json", "hijack-blocklists.json", "password-rules.json", View it on GitLab: https://gitlab.torproject.org/tpo/applications/mullvad-browser/-/compare/eb… -- View it on GitLab: https://gitlab.torproject.org/tpo/applications/mullvad-browser/-/compare/eb… 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] Bug 43340: Add mozconfig-linux-aarch64-dev
by Pier Angelo Vendrame (@pierov) 04 Dec '24

04 Dec '24
Pier Angelo Vendrame pushed to branch base-browser-128.5.0esr-14.5-1 at The Tor Project / Applications / Tor Browser Commits: 47f3899c by NoisyCoil at 2024-12-04T10:40:10+01:00 Bug 43340: Add mozconfig-linux-aarch64-dev Copy mozconfig-linux-x86_64-dev, except that linux-aarch64 does not support the {enable,disable}-eme options - - - - - 1 changed file: - + mozconfig-linux-aarch64-dev Changes: ===================================== mozconfig-linux-aarch64-dev ===================================== @@ -0,0 +1,18 @@ +. $topsrcdir/browser/config/mozconfigs/base-browser + +# This mozconfig file is not used in official builds. +# It is only intended to be used when doing incremental Linux builds +# during development. + +# Moz switched to lld for all Linux targets in Bug 1839739. +ac_add_options --enable-linker=lld + +export MOZILLA_OFFICIAL= + +ac_add_options --enable-default-toolkit=cairo-gtk3 + +ac_add_options --disable-strip +ac_add_options --disable-install-strip + +ac_add_options --with-base-browser-version=dev-build +ac_add_options --disable-base-browser-update View it on GitLab: https://gitlab.torproject.org/tpo/applications/tor-browser/-/commit/47f3899… -- View it on GitLab: https://gitlab.torproject.org/tpo/applications/tor-browser/-/commit/47f3899… 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] fixup! Bug 31740: Remove some unnecessary RemoteSettings instances
by Pier Angelo Vendrame (@pierov) 04 Dec '24

04 Dec '24
Pier Angelo Vendrame pushed to branch base-browser-128.5.0esr-14.5-1 at The Tor Project / Applications / Tor Browser Commits: 857bd22e by cypherpunks1 at 2024-12-04T10:38:17+01:00 fixup! Bug 31740: Remove some unnecessary RemoteSettings instances Bug 43334: Restore RemoteSettings dumps for devtools-compatibility-browsers and devtools-devices - - - - - 1 changed file: - services/settings/dumps/main/moz.build Changes: ===================================== services/settings/dumps/main/moz.build ===================================== @@ -14,6 +14,8 @@ if not CONFIG["MOZ_BUILD_APP"].startswith("mobile/"): FINAL_TARGET_FILES.defaults.settings.main += [ "anti-tracking-url-decoration.json", "cookie-banner-rules-list.json", + "devtools-compatibility-browsers.json", + "devtools-devices.json", "example.json", "hijack-blocklists.json", "password-rules.json", View it on GitLab: https://gitlab.torproject.org/tpo/applications/tor-browser/-/commit/857bd22… -- View it on GitLab: https://gitlab.torproject.org/tpo/applications/tor-browser/-/commit/857bd22… You're receiving this email because of your account on gitlab.torproject.org.
1 0
0 0
  • ← Newer
  • 1
  • ...
  • 41
  • 42
  • 43
  • 44
  • 45
  • 46
  • 47
  • ...
  • 745
  • Older →

HyperKitty Powered by HyperKitty version 1.3.12.