Skip to content
Snippets Groups Projects
Commit 01f1d420 authored by Emilio Cobos Álvarez's avatar Emilio Cobos Álvarez Committed by Beatriz Rizental
Browse files

Bug 1918454 - Prevent divide by zero when inverting effective zoom....

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
parent f3be63f2
No related branches found
No related tags found
1 merge request!1527Bug 43808: Rebase 128.10.1 onto 128.11
......@@ -2715,7 +2715,10 @@ impl<'a> StyleBuilder<'a> {
pub fn resolved_specified_zoom(&self) -> computed::Zoom {
let zoom = self.specified_zoom();
if zoom.is_document() {
self.inherited_effective_zoom().inverted()
// 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
}
......
......@@ -365,8 +365,11 @@ impl Zoom {
/// Returns the inverse of our value.
#[inline]
pub fn inverted(&self) -> Self {
Self(Self::ONE.0 / self.0)
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.
......
<style>
*:nth-of-type(1) {
zoom: 5%;
}
</style>
<textarea>
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment