Issue #1620 - Use Intrinsic Aspect Ratio for Images

https://bugzilla.mozilla.org/show_bug.cgi?id=1547231
https://bugzilla.mozilla.org/show_bug.cgi?id=1559094
https://bugzilla.mozilla.org/show_bug.cgi?id=1633434
https://bugzilla.mozilla.org/show_bug.cgi?id=1565690
https://bugzilla.mozilla.org/show_bug.cgi?id=1602047

Make use of Aspect Ratios in Image frames before Images are loaded.
- Check for width and height HTML properties and create a ratio with them.
- Overwrite HTML size values with actual image dimensions on load.
- Collapse any frames with srcless images.

Comments:
dom/html/nsGenericHTMLElement.cpp:1483
layout/generic/nsImageFrame.cpp:289
This commit is contained in:
Andy 2020-08-04 13:54:01 -07:00 committed by Roy Tam
commit be1f68f39e
17 changed files with 381 additions and 143 deletions

View file

@ -273,21 +273,19 @@ private:
void GetDocumentCharacterSet(nsACString& aCharset) const;
bool ShouldDisplaySelection();
// Whether the image frame should use the mapped aspect ratio from width=""
// and height="".
bool ShouldUseMappedAspectRatio() const;
/**
* Recalculate mIntrinsicSize from the image.
*
* @return whether aImage's size did _not_
* match our previous intrinsic size.
*/
bool UpdateIntrinsicSize(imgIContainer* aImage);
bool UpdateIntrinsicSize();
/**
* Recalculate mIntrinsicRatio from the image.
*
* @return whether aImage's ratio did _not_
* match our previous intrinsic ratio.
*/
bool UpdateIntrinsicRatio(imgIContainer* aImage);
bool UpdateIntrinsicRatio();
/**
* This function calculates the transform for converting between
@ -307,6 +305,12 @@ private:
*/
bool IsPendingLoad(imgIRequest* aRequest) const;
/**
* Updates mImage based on the current image request (cannot be null), and the
* image passed in (can be null), and invalidate layout and paint as needed.
*/
void UpdateImage(imgIRequest* aRequest, imgIContainer* aImage);
/**
* Function to convert a dirty rect in the source image to a dirty
* rect for the image frame.