Bug 1785635 Add flag to enforce from-image orientation for createImageBitmap r=emilio

New flag added to nsLayoutUtils to ensure any exif specified orientation
is applied to surfaces obtained from HTMLImage elements irrespective of the
presence of the element in the DOM. For use in createImageBitmap where from-image is
the required behaviour.

Differential Revision: https://phabricator.services.mozilla.com/D168356
This commit is contained in:
Angus Sawyer 2023-01-31 16:04:17 +00:00
Родитель a8e5bce81b
Коммит 843eab98fc
4 изменённых файлов: 6 добавлений и 9 удалений

Просмотреть файл

@ -582,7 +582,8 @@ static already_AddRefed<SourceSurface> GetSurfaceFromElement(
nsIGlobalObject* aGlobal, ElementType& aElement, bool* aWriteOnly,
const ImageBitmapOptions& aOptions, gfxAlphaType* aAlphaType,
ErrorResult& aRv) {
uint32_t flags = nsLayoutUtils::SFE_WANT_FIRST_FRAME_IF_IMAGE;
uint32_t flags = nsLayoutUtils::SFE_WANT_FIRST_FRAME_IF_IMAGE |
nsLayoutUtils::SFE_ORIENTATION_FROM_IMAGE;
// by default surfaces have premultiplied alpha
// attempt to get non premultiplied if required

Просмотреть файл

@ -7219,7 +7219,8 @@ SurfaceFromElementResult nsLayoutUtils::SurfaceFromElement(
// Ensure that the image is oriented the same way as it's displayed
// if the image request is of the same origin.
auto orientation =
content->GetPrimaryFrame()
content->GetPrimaryFrame() &&
!(aSurfaceFlags & SFE_ORIENTATION_FROM_IMAGE)
? content->GetPrimaryFrame()->StyleVisibility()->UsedImageOrientation(
imgRequest)
: nsStyleVisibility::UsedImageOrientation(

Просмотреть файл

@ -2194,6 +2194,8 @@ class nsLayoutUtils {
* The surface might be different for, e.g., a EXIF-scaled raster image, if
* we don't rescale during decode. */
SFE_EXACT_SIZE_SURFACE = 1 << 6,
/* Use orientation from image */
SFE_ORIENTATION_FROM_IMAGE = 1 << 7
};
// This function can be called on any thread.

Просмотреть файл

@ -1,7 +0,0 @@
[imagebitmap-replication-exif-orientation.html]
[ImageBitmap from file with EXIF rotation, loaded via <img> in DOM, imageOrientation = none]
expected:
if (os == "linux") and not debug and fission and (processor == "x86_64"): [FAIL, PASS]
if (os == "linux") and not debug and not fission: [FAIL, PASS]
if (os == "mac") and debug: [FAIL, PASS]
[PASS, FAIL]