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

  • 1 participants
  • 18563 discussions
[Git][tpo/applications/tor-browser][tor-browser-128.5.0esr-14.5-1] dropme! Add verification statement for BrowserStack support
by morgan (@morgan) 10 Dec '24

10 Dec '24
morgan pushed to branch tor-browser-128.5.0esr-14.5-1 at The Tor Project / Applications / Tor Browser Commits: 20762d49 by Morgan at 2024-12-10T12:49:42+00:00 dropme! Add verification statement for BrowserStack support - - - - - 1 changed file: - README.md Changes: ===================================== README.md ===================================== @@ -4,3 +4,6 @@ See the following wiki links for more information: + [Repository Overview](https://gitlab.torproject.org/tpo/applications/team/-/wikis/Devel… + [Contributing](https://gitlab.torproject.org/tpo/applications/team/-/wikis/D… + +This project is tested with [BrowserStack](https://www.browserstack.com/). +w \ No newline at end of file View it on GitLab: https://gitlab.torproject.org/tpo/applications/tor-browser/-/commit/20762d4… -- View it on GitLab: https://gitlab.torproject.org/tpo/applications/tor-browser/-/commit/20762d4… 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 1935621 - Fix virtual environment sysconfig path calculation...
by Pier Angelo Vendrame (@pierov) 10 Dec '24

10 Dec '24
Pier Angelo Vendrame pushed to branch base-browser-128.5.0esr-14.5-1 at The Tor Project / Applications / Tor Browser Commits: 73a4e6ad by Filipe Laíns at 2024-12-10T10:24:41+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/73a4e6a… -- View it on GitLab: https://gitlab.torproject.org/tpo/applications/tor-browser/-/commit/73a4e6a… 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] 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
  • ← Newer
  • 1
  • ...
  • 101
  • 102
  • 103
  • 104
  • 105
  • 106
  • 107
  • ...
  • 1857
  • Older →

HyperKitty Powered by HyperKitty version 1.3.12.