Commit 013bdbce authored by Emilio Cobos Álvarez's avatar Emilio Cobos Álvarez Committed by Pier Angelo Vendrame
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 b698da4d
Loading
Loading
Loading
Loading
+4 −1
Original line number Diff line number Diff line
@@ -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
        }
+5 −2
Original line number Diff line number Diff line
@@ -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.
+6 −0
Original line number Diff line number Diff line
<style>
*:nth-of-type(1) {
  zoom: 5%;
}
</style>
<textarea>