mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-24 13:21:05 +00:00
Backed out 2 changesets (bug 1655598) for causing Bug 1792435. a=backout
Backed out changeset 9eb3b3e7295b (bug 1655598) Backed out changeset 052c6f05c623 (bug 1655598)
This commit is contained in:
parent
4e978b56b5
commit
d45dd05bf4
@ -384,7 +384,8 @@ void DragDataProducer::CreateLinkText(const nsAString& inURL,
|
||||
|
||||
nsresult DragDataProducer::GetImageData(imgIContainer* aImage,
|
||||
imgIRequest* aRequest) {
|
||||
nsCOMPtr<nsIURI> imgUri = aRequest->GetURI();
|
||||
nsCOMPtr<nsIURI> imgUri;
|
||||
aRequest->GetURI(getter_AddRefs(imgUri));
|
||||
|
||||
nsCOMPtr<nsIURL> imgUrl(do_QueryInterface(imgUri));
|
||||
if (imgUrl) {
|
||||
|
@ -4127,9 +4127,8 @@ static CursorImage ComputeCustomCursor(nsPresContext* aPresContext,
|
||||
if (!container) {
|
||||
continue;
|
||||
}
|
||||
StyleImageOrientation orientation =
|
||||
aFrame.StyleVisibility()->UsedImageOrientation(req);
|
||||
container = nsLayoutUtils::OrientImage(container, orientation);
|
||||
container = nsLayoutUtils::OrientImage(
|
||||
container, aFrame.StyleVisibility()->mImageOrientation);
|
||||
Maybe<gfx::Point> specifiedHotspot =
|
||||
image.has_hotspot ? Some(gfx::Point{image.hotspot_x, image.hotspot_y})
|
||||
: Nothing();
|
||||
|
@ -35,12 +35,6 @@ interface imgIRequest : nsIRequest
|
||||
*/
|
||||
[infallible] readonly attribute unsigned long providerId;
|
||||
|
||||
/**
|
||||
* The principal for the document that loaded this image. Used when trying to
|
||||
* validate a CORS image load.
|
||||
*/
|
||||
[infallible] readonly attribute nsIPrincipal triggeringPrincipal;
|
||||
|
||||
/**
|
||||
* Bits set in the return value from imageStatus
|
||||
* @name statusflags
|
||||
@ -95,7 +89,7 @@ interface imgIRequest : nsIRequest
|
||||
* actual URI for the image (e.g. if HTTP redirects happened during the
|
||||
* load).
|
||||
*/
|
||||
[infallible] readonly attribute nsIURI URI;
|
||||
readonly attribute nsIURI URI;
|
||||
|
||||
/**
|
||||
* The URI of the resource we ended up loading after all redirects, etc.
|
||||
|
@ -176,11 +176,6 @@ bool imgRequest::CanReuseWithoutValidation(dom::Document* aDoc) const {
|
||||
|
||||
void imgRequest::ClearLoader() { mLoader = nullptr; }
|
||||
|
||||
already_AddRefed<nsIPrincipal> imgRequest::GetTriggeringPrincipal() const {
|
||||
nsCOMPtr<nsIPrincipal> principal = mTriggeringPrincipal;
|
||||
return principal.forget();
|
||||
}
|
||||
|
||||
already_AddRefed<ProgressTracker> imgRequest::GetProgressTracker() const {
|
||||
MutexAutoLock lock(mMutex);
|
||||
|
||||
|
@ -118,7 +118,10 @@ class imgRequest final : public nsIStreamListener,
|
||||
|
||||
// The principal for the document that loaded this image. Used when trying to
|
||||
// validate a CORS image load.
|
||||
already_AddRefed<nsIPrincipal> GetTriggeringPrincipal() const;
|
||||
already_AddRefed<nsIPrincipal> GetTriggeringPrincipal() const {
|
||||
nsCOMPtr<nsIPrincipal> principal = mTriggeringPrincipal;
|
||||
return principal.forget();
|
||||
}
|
||||
|
||||
// Return the ProgressTracker associated with this imgRequest. It may live
|
||||
// in |mProgressTracker| or in |mImage.mProgressTracker|, depending on whether
|
||||
|
@ -233,15 +233,6 @@ nsresult imgRequestProxy::ChangeOwner(imgRequest* aNewOwner) {
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP imgRequestProxy::GetTriggeringPrincipal(
|
||||
nsIPrincipal** aTriggeringPrincipal) {
|
||||
MOZ_ASSERT(GetOwner());
|
||||
nsCOMPtr<nsIPrincipal> triggeringPrincipal =
|
||||
GetOwner()->GetTriggeringPrincipal();
|
||||
triggeringPrincipal.forget(aTriggeringPrincipal);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
void imgRequestProxy::MarkValidating() {
|
||||
MOZ_ASSERT(GetValidator());
|
||||
mValidating = true;
|
||||
|
@ -7231,14 +7231,11 @@ SurfaceFromElementResult nsLayoutUtils::SurfaceFromElement(
|
||||
|
||||
nsCOMPtr<nsIContent> content = do_QueryInterface(aElement);
|
||||
|
||||
// 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()->StyleVisibility()->UsedImageOrientation(
|
||||
imgRequest)
|
||||
: nsStyleVisibility::UsedImageOrientation(
|
||||
imgRequest, StyleImageOrientation::FromImage);
|
||||
// Ensure that the image is oriented the same way as it's displayed.
|
||||
auto orientation = StyleImageOrientation::FromImage;
|
||||
if (nsIFrame* f = content->GetPrimaryFrame()) {
|
||||
orientation = f->StyleVisibility()->mImageOrientation;
|
||||
}
|
||||
imgContainer = OrientImage(imgContainer, orientation);
|
||||
|
||||
const bool noRasterize = aSurfaceFlags & SFE_NO_RASTERIZING_VECTORS;
|
||||
|
@ -1527,7 +1527,8 @@ void nsRefreshDriver::AddImageRequest(imgIRequest* aRequest) {
|
||||
EnsureTimerStarted();
|
||||
|
||||
if (profiler_thread_is_being_profiled_for_markers()) {
|
||||
nsCOMPtr<nsIURI> uri = aRequest->GetURI();
|
||||
nsCOMPtr<nsIURI> uri;
|
||||
aRequest->GetURI(getter_AddRefs(uri));
|
||||
nsAutoCString uristr;
|
||||
uri->GetAsciiSpec(uristr);
|
||||
|
||||
@ -1551,7 +1552,8 @@ void nsRefreshDriver::RemoveImageRequest(imgIRequest* aRequest) {
|
||||
}
|
||||
|
||||
if (removed && profiler_thread_is_being_profiled_for_markers()) {
|
||||
nsCOMPtr<nsIURI> uri = aRequest->GetURI();
|
||||
nsCOMPtr<nsIURI> uri;
|
||||
aRequest->GetURI(getter_AddRefs(uri));
|
||||
nsAutoCString uristr;
|
||||
uri->GetAsciiSpec(uristr);
|
||||
|
||||
|
@ -424,23 +424,15 @@ void nsImageFrame::DidSetComputedStyle(ComputedStyle* aOldStyle) {
|
||||
UpdateIntrinsicSize();
|
||||
}
|
||||
|
||||
nsCOMPtr<imgIRequest> currentRequest = GetCurrentRequest();
|
||||
|
||||
bool shouldUpdateOrientation = false;
|
||||
auto newOrientation = StyleVisibility()->UsedImageOrientation(currentRequest);
|
||||
auto newOrientation = StyleVisibility()->mImageOrientation;
|
||||
|
||||
// We need to update our orientation either if we had no ComputedStyle before
|
||||
// because this is the first time it's been set, or if the image-orientation
|
||||
// property changed from its previous value.
|
||||
if (mImage) {
|
||||
if (aOldStyle) {
|
||||
auto oldOrientation =
|
||||
aOldStyle->StyleVisibility()->UsedImageOrientation(currentRequest);
|
||||
shouldUpdateOrientation = oldOrientation != newOrientation;
|
||||
} else {
|
||||
shouldUpdateOrientation = true;
|
||||
}
|
||||
}
|
||||
bool shouldUpdateOrientation =
|
||||
mImage &&
|
||||
(!aOldStyle ||
|
||||
aOldStyle->StyleVisibility()->mImageOrientation != newOrientation);
|
||||
|
||||
if (shouldUpdateOrientation) {
|
||||
nsCOMPtr<imgIContainer> image(mImage->Unwrap());
|
||||
@ -947,11 +939,10 @@ void nsImageFrame::OnSizeAvailable(imgIRequest* aRequest,
|
||||
|
||||
void nsImageFrame::UpdateImage(imgIRequest* aRequest, imgIContainer* aImage) {
|
||||
if (SizeIsAvailable(aRequest)) {
|
||||
StyleImageOrientation orientation =
|
||||
StyleVisibility()->UsedImageOrientation(aRequest);
|
||||
// This is valid and for the current request, so update our stored image
|
||||
// container, orienting according to our style.
|
||||
mImage = nsLayoutUtils::OrientImage(aImage, orientation);
|
||||
mImage = nsLayoutUtils::OrientImage(aImage,
|
||||
StyleVisibility()->mImageOrientation);
|
||||
MOZ_ASSERT(mImage);
|
||||
} else {
|
||||
// We no longer have a valid image, so release our stored image container.
|
||||
@ -2638,7 +2629,8 @@ void nsImageFrame::List(FILE* out, const char* aPrefix,
|
||||
|
||||
// output the img src url
|
||||
if (nsCOMPtr<imgIRequest> currentRequest = GetCurrentRequest()) {
|
||||
nsCOMPtr<nsIURI> uri = currentRequest->GetURI();
|
||||
nsCOMPtr<nsIURI> uri;
|
||||
currentRequest->GetURI(getter_AddRefs(uri));
|
||||
nsAutoCString uristr;
|
||||
uri->GetAsciiSpec(uristr);
|
||||
str += nsPrintfCString(" [src=%s]", uristr.get());
|
||||
|
@ -148,9 +148,8 @@ bool nsImageRenderer::PrepareImage() {
|
||||
}
|
||||
|
||||
if (srcImage) {
|
||||
StyleImageOrientation orientation =
|
||||
mForFrame->StyleVisibility()->UsedImageOrientation(request);
|
||||
srcImage = nsLayoutUtils::OrientImage(srcImage, orientation);
|
||||
srcImage = nsLayoutUtils::OrientImage(
|
||||
srcImage, mForFrame->StyleVisibility()->mImageOrientation);
|
||||
}
|
||||
|
||||
if (!mImage->IsRect()) {
|
||||
|
20
layout/reftests/image/image-orientation-none.html
Normal file
20
layout/reftests/image/image-orientation-none.html
Normal file
@ -0,0 +1,20 @@
|
||||
<!DOCTYPE>
|
||||
<head>
|
||||
<style>
|
||||
body {
|
||||
border: 0px;
|
||||
margin: 0px;
|
||||
padding: 0px;
|
||||
}
|
||||
img {
|
||||
border: 50px solid black;
|
||||
margin: 50px;
|
||||
padding: 50px;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<!-- This is deliberately an image with a non-neutral inherent orientation to
|
||||
ensure that the inherent orientation is irrelevant. -->
|
||||
<img src="image-exif-90-deg-flip.jpg" style="image-orientation: none;">
|
||||
</body>
|
@ -2702,7 +2702,8 @@ nsChangeHint nsStyleDisplay::CalcTransformPropertyDifference(
|
||||
//
|
||||
|
||||
nsStyleVisibility::nsStyleVisibility(const Document& aDocument)
|
||||
: mDirection(aDocument.GetBidiOptions() == IBMBIDI_TEXTDIRECTION_RTL
|
||||
: mImageOrientation(StyleImageOrientation::FromImage),
|
||||
mDirection(aDocument.GetBidiOptions() == IBMBIDI_TEXTDIRECTION_RTL
|
||||
? StyleDirection::Rtl
|
||||
: StyleDirection::Ltr),
|
||||
mVisible(StyleVisibility::Visible),
|
||||
@ -2710,20 +2711,19 @@ nsStyleVisibility::nsStyleVisibility(const Document& aDocument)
|
||||
mWritingMode(StyleWritingModeProperty::HorizontalTb),
|
||||
mTextOrientation(StyleTextOrientation::Mixed),
|
||||
mMozBoxLayout(StyleMozBoxLayout::Legacy),
|
||||
mPrintColorAdjust(StylePrintColorAdjust::Economy),
|
||||
mImageOrientation(StyleImageOrientation::FromImage) {
|
||||
mPrintColorAdjust(StylePrintColorAdjust::Economy) {
|
||||
MOZ_COUNT_CTOR(nsStyleVisibility);
|
||||
}
|
||||
|
||||
nsStyleVisibility::nsStyleVisibility(const nsStyleVisibility& aSource)
|
||||
: mDirection(aSource.mDirection),
|
||||
: mImageOrientation(aSource.mImageOrientation),
|
||||
mDirection(aSource.mDirection),
|
||||
mVisible(aSource.mVisible),
|
||||
mImageRendering(aSource.mImageRendering),
|
||||
mWritingMode(aSource.mWritingMode),
|
||||
mTextOrientation(aSource.mTextOrientation),
|
||||
mMozBoxLayout(aSource.mMozBoxLayout),
|
||||
mPrintColorAdjust(aSource.mPrintColorAdjust),
|
||||
mImageOrientation(aSource.mImageOrientation) {
|
||||
mPrintColorAdjust(aSource.mPrintColorAdjust) {
|
||||
MOZ_COUNT_CTOR(nsStyleVisibility);
|
||||
}
|
||||
|
||||
@ -2769,37 +2769,6 @@ nsChangeHint nsStyleVisibility::CalcDifference(
|
||||
return hint;
|
||||
}
|
||||
|
||||
StyleImageOrientation nsStyleVisibility::UsedImageOrientation(
|
||||
imgIRequest* aRequest) const {
|
||||
return UsedImageOrientation(aRequest, mImageOrientation);
|
||||
}
|
||||
|
||||
StyleImageOrientation nsStyleVisibility::UsedImageOrientation(
|
||||
imgIRequest* aRequest, StyleImageOrientation aOrientation) {
|
||||
if (!aRequest) {
|
||||
return aOrientation;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIPrincipal> triggeringPrincipal =
|
||||
aRequest->GetTriggeringPrincipal();
|
||||
nsCOMPtr<nsIURI> uri = aRequest->GetURI();
|
||||
|
||||
// If the request was for a blob, the request may not have a triggering
|
||||
// principal and we should use the input orientation.
|
||||
if (!triggeringPrincipal) {
|
||||
return aOrientation;
|
||||
}
|
||||
|
||||
// If the image request is a cross-origin request, do not enforce the
|
||||
// image orientation found in the style. Use the image orientation found
|
||||
// in the exif data.
|
||||
if (!triggeringPrincipal->IsSameOrigin(uri)) {
|
||||
return StyleImageOrientation::FromImage;
|
||||
}
|
||||
|
||||
return aOrientation;
|
||||
}
|
||||
|
||||
//-----------------------
|
||||
// nsStyleContent
|
||||
//
|
||||
|
@ -1100,8 +1100,19 @@ struct MOZ_NEEDS_MEMMOVABLE_MEMBERS nsStyleVisibility {
|
||||
explicit nsStyleVisibility(const mozilla::dom::Document&);
|
||||
nsStyleVisibility(const nsStyleVisibility& aVisibility);
|
||||
MOZ_COUNTED_DTOR(nsStyleVisibility)
|
||||
static constexpr bool kHasTriggerImageLoads = false;
|
||||
|
||||
nsChangeHint CalcDifference(const nsStyleVisibility& aNewData) const;
|
||||
|
||||
mozilla::StyleImageOrientation mImageOrientation;
|
||||
mozilla::StyleDirection mDirection;
|
||||
mozilla::StyleVisibility mVisible;
|
||||
mozilla::StyleImageRendering mImageRendering;
|
||||
mozilla::StyleWritingModeProperty mWritingMode;
|
||||
mozilla::StyleTextOrientation mTextOrientation;
|
||||
mozilla::StyleMozBoxLayout mMozBoxLayout;
|
||||
mozilla::StylePrintColorAdjust mPrintColorAdjust;
|
||||
|
||||
bool IsVisible() const {
|
||||
return mVisible == mozilla::StyleVisibility::Visible;
|
||||
}
|
||||
@ -1114,41 +1125,6 @@ struct MOZ_NEEDS_MEMMOVABLE_MEMBERS nsStyleVisibility {
|
||||
bool EmulateMozBoxWithFlex() const {
|
||||
return mMozBoxLayout == mozilla::StyleMozBoxLayout::Flex;
|
||||
}
|
||||
|
||||
/**
|
||||
* Given an image request, returns the orientation that should be used
|
||||
* on the image. The returned orientation may differ from the style
|
||||
* struct's orientation member value, if the image request is not of the
|
||||
* same origin.
|
||||
*
|
||||
* @param aRequest The image request used to determine if same origin.
|
||||
*/
|
||||
mozilla::StyleImageOrientation UsedImageOrientation(
|
||||
imgIRequest* aRequest) const;
|
||||
|
||||
/**
|
||||
* Given an image request and an orientation, returns the orientation
|
||||
* that should be used on the image. The returned orientation may differ
|
||||
* from the input orientation if the image request is not of the same
|
||||
* origin.
|
||||
*
|
||||
* @param aRequest The image request used to determine if same origin.
|
||||
* @param aOrientation The input orientation.
|
||||
*/
|
||||
static mozilla::StyleImageOrientation UsedImageOrientation(
|
||||
imgIRequest* aRequest, mozilla::StyleImageOrientation aOrientation);
|
||||
|
||||
static constexpr bool kHasTriggerImageLoads = false;
|
||||
mozilla::StyleDirection mDirection;
|
||||
mozilla::StyleVisibility mVisible;
|
||||
mozilla::StyleImageRendering mImageRendering;
|
||||
mozilla::StyleWritingModeProperty mWritingMode;
|
||||
mozilla::StyleTextOrientation mTextOrientation;
|
||||
mozilla::StyleMozBoxLayout mMozBoxLayout;
|
||||
mozilla::StylePrintColorAdjust mPrintColorAdjust;
|
||||
|
||||
private:
|
||||
mozilla::StyleImageOrientation mImageOrientation;
|
||||
};
|
||||
|
||||
namespace mozilla {
|
||||
|
@ -149,20 +149,9 @@ void SVGImageFrame::DidSetComputedStyle(ComputedStyle* aOldStyle) {
|
||||
return;
|
||||
}
|
||||
|
||||
nsCOMPtr<imgIRequest> currentRequest;
|
||||
nsCOMPtr<nsIImageLoadingContent> imageLoader =
|
||||
do_QueryInterface(GetContent());
|
||||
if (imageLoader) {
|
||||
imageLoader->GetRequest(nsIImageLoadingContent::CURRENT_REQUEST,
|
||||
getter_AddRefs(currentRequest));
|
||||
}
|
||||
auto newOrientation = StyleVisibility()->mImageOrientation;
|
||||
|
||||
StyleImageOrientation newOrientation =
|
||||
StyleVisibility()->UsedImageOrientation(currentRequest);
|
||||
StyleImageOrientation oldOrientation =
|
||||
aOldStyle->StyleVisibility()->UsedImageOrientation(currentRequest);
|
||||
|
||||
if (oldOrientation != newOrientation) {
|
||||
if (aOldStyle->StyleVisibility()->mImageOrientation != newOrientation) {
|
||||
nsCOMPtr<imgIContainer> image(mImageContainer->Unwrap());
|
||||
mImageContainer = nsLayoutUtils::OrientImage(image, newOrientation);
|
||||
}
|
||||
@ -863,9 +852,8 @@ void SVGImageListener::Notify(imgIRequest* aRequest, int32_t aType,
|
||||
nsCOMPtr<imgIContainer> image;
|
||||
aRequest->GetImage(getter_AddRefs(image));
|
||||
if (image) {
|
||||
StyleImageOrientation orientation =
|
||||
mFrame->StyleVisibility()->UsedImageOrientation(aRequest);
|
||||
image = nsLayoutUtils::OrientImage(image, orientation);
|
||||
image = nsLayoutUtils::OrientImage(
|
||||
image, mFrame->StyleVisibility()->mImageOrientation);
|
||||
image->SetAnimationMode(mFrame->PresContext()->ImageAnimationMode());
|
||||
mFrame->mImageContainer = std::move(image);
|
||||
}
|
||||
|
@ -0,0 +1,2 @@
|
||||
[image-orientation-none-cross-origin.html]
|
||||
expected: FAIL
|
@ -32,16 +32,5 @@
|
||||
const img = document.getElementById('corsImage')
|
||||
img.src = img.src.replace(new URL(img.src).origin, get_host_info().HTTP_REMOTE_ORIGIN)
|
||||
</script>
|
||||
<p>The image should not rotate respecting their EXIF orientation because
|
||||
image-orientation: none is specified.</p>
|
||||
<div><img id="blobImage" src="support/exif-orientation-3-lr.jpg"/></div>
|
||||
<script>
|
||||
fetch(img.src).then((resp) {
|
||||
return blob;
|
||||
}).then((blob) => {
|
||||
const img = document.getElementById('blobImage')
|
||||
img.src = blob;
|
||||
});
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
|
@ -25,9 +25,5 @@
|
||||
<p>This image should rotate respecting their EXIF orientation because
|
||||
image-orientation: none should be effectively ignored for opaque (cross-origin) images.</p>
|
||||
<div><img src="../support/exif-orientation-3-lr.jpg" style="image-orientation: from-image" /></div>
|
||||
|
||||
<p>The image should not rotate respecting their EXIF orientation because
|
||||
image-orientation: none is specified.</p>
|
||||
<div><img src="../support/exif-orientation-3-lr.jpg"/></div>
|
||||
</body>
|
||||
</html>
|
||||
|
Loading…
Reference in New Issue
Block a user