Skip to content

Commit

Permalink
Bug 1876541 - Zoom should affect intrinsic replaced element size. r=T…
Browse files Browse the repository at this point in the history
  • Loading branch information
emilio committed Feb 7, 2024
1 parent 528a714 commit b595165
Show file tree
Hide file tree
Showing 5 changed files with 42 additions and 4 deletions.
13 changes: 12 additions & 1 deletion layout/generic/nsIFrame.h
Original file line number Diff line number Diff line change
Expand Up @@ -375,6 +375,15 @@ struct IntrinsicSize {
return width && height ? Some(nsSize(*width, *height)) : Nothing();
}

void Zoom(const StyleZoom& aZoom) {
if (width) {
*width = aZoom.ZoomCoord(*width);
}
if (height) {
*height = aZoom.ZoomCoord(*height);
}
}

bool operator==(const IntrinsicSize& rhs) const {
return width == rhs.width && height == rhs.height;
}
Expand Down Expand Up @@ -4092,7 +4101,9 @@ class nsIFrame : public nsQueryFrame {
const mozilla::ContainSizeAxes& aAxes,
const mozilla::IntrinsicSize& aUncontainedSize) const {
MOZ_ASSERT(aAxes == GetContainSizeAxes());
return aAxes.ContainIntrinsicSize(aUncontainedSize, *this);
auto result = aAxes.ContainIntrinsicSize(aUncontainedSize, *this);
result.Zoom(Style()->EffectiveZoom());
return result;
}

Maybe<nscoord> ContainIntrinsicBSize(nscoord aNoneValue = 0) const {
Expand Down
14 changes: 14 additions & 0 deletions layout/style/ServoStyleConstsInlines.h
Original file line number Diff line number Diff line change
Expand Up @@ -1139,6 +1139,20 @@ inline float StyleZoom::Unzoom(float aValue) const {
return aValue / ToFloat();
}

inline nscoord StyleZoom::ZoomCoord(nscoord aValue) const {
if (*this == ONE) {
return aValue;
}
return NSToCoordRoundWithClamp(Zoom(float(aValue)));
}

inline nscoord StyleZoom::UnzoomCoord(nscoord aValue) const {
if (*this == ONE) {
return aValue;
}
return NSToCoordRoundWithClamp(Unzoom(float(aValue)));
}

} // namespace mozilla

#endif
2 changes: 2 additions & 0 deletions servo/ports/geckolib/cbindgen.toml
Original file line number Diff line number Diff line change
Expand Up @@ -978,6 +978,8 @@ renaming_overrides_prefixing = true
SERVO_FIXED_POINT_HELPERS(StyleZoom, uint16_t, StyleZOOM_FRACTION_BITS);
inline float Zoom(float) const;
inline float Unzoom(float) const;
inline nscoord ZoomCoord(nscoord) const;
inline nscoord UnzoomCoord(nscoord) const;
"""

"AnimationName" = """
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<!doctype html>
<meta charset="utf-8">
<title>Zoom affects image intrinsic sizes</title>
<link rel="author" title="Emilio Cobos Álvarez" href="mailto:[email protected]">
<link rel="author" title="Mozilla" href="https://mozilla.org">
<link rel="help" href="https://drafts.csswg.org/css-viewport/#zoom-property">
<link rel="match" href="background-image-ref.html">
<style>
img {
vertical-align: top;
zoom: .5;
}
</style>
<img src="/images/pattern.png">

0 comments on commit b595165

Please sign in to comment.