зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1817071 - Remove -moz-image-region support from layout. r=layout-reviewers,tnikkel
There are no users of non-auto values, so we can just simplify some code and remove the property. Differential Revision: https://phabricator.services.mozilla.com/D170010
This commit is contained in:
Родитель
1bdd81f84a
Коммит
5f6910e75e
|
@ -310,7 +310,6 @@ exports.ANIMATION_TYPE_FOR_LONGHANDS = [
|
||||||
"font-stretch",
|
"font-stretch",
|
||||||
"font-variation-settings",
|
"font-variation-settings",
|
||||||
"font-weight",
|
"font-weight",
|
||||||
"-moz-image-region",
|
|
||||||
"mask-position-x",
|
"mask-position-x",
|
||||||
"mask-position-y",
|
"mask-position-y",
|
||||||
"mask-size",
|
"mask-size",
|
||||||
|
|
|
@ -782,22 +782,6 @@ exports.CSS_PROPERTIES = {
|
||||||
"unset"
|
"unset"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"-moz-image-region": {
|
|
||||||
"isInherited": true,
|
|
||||||
"subproperties": [
|
|
||||||
"-moz-image-region"
|
|
||||||
],
|
|
||||||
"supports": [],
|
|
||||||
"values": [
|
|
||||||
"auto",
|
|
||||||
"inherit",
|
|
||||||
"initial",
|
|
||||||
"rect",
|
|
||||||
"revert",
|
|
||||||
"revert-layer",
|
|
||||||
"unset"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"-moz-margin-end": {
|
"-moz-margin-end": {
|
||||||
"isInherited": false,
|
"isInherited": false,
|
||||||
"subproperties": [
|
"subproperties": [
|
||||||
|
@ -3142,7 +3126,6 @@ exports.CSS_PROPERTIES = {
|
||||||
"list-style-type",
|
"list-style-type",
|
||||||
"list-style-image",
|
"list-style-image",
|
||||||
"quotes",
|
"quotes",
|
||||||
"-moz-image-region",
|
|
||||||
"margin-top",
|
"margin-top",
|
||||||
"margin-right",
|
"margin-right",
|
||||||
"margin-bottom",
|
"margin-bottom",
|
||||||
|
|
|
@ -6424,8 +6424,7 @@ ImgDrawResult nsLayoutUtils::DrawSingleImage(
|
||||||
gfxContext& aContext, nsPresContext* aPresContext, imgIContainer* aImage,
|
gfxContext& aContext, nsPresContext* aPresContext, imgIContainer* aImage,
|
||||||
SamplingFilter aSamplingFilter, const nsRect& aDest, const nsRect& aDirty,
|
SamplingFilter aSamplingFilter, const nsRect& aDest, const nsRect& aDirty,
|
||||||
const SVGImageContext& aSVGContext, uint32_t aImageFlags,
|
const SVGImageContext& aSVGContext, uint32_t aImageFlags,
|
||||||
const nsPoint* aAnchorPoint, const nsRect* aSourceArea) {
|
const nsPoint* aAnchorPoint) {
|
||||||
nscoord appUnitsPerCSSPixel = AppUnitsPerCSSPixel();
|
|
||||||
// NOTE(emilio): We can hardcode resolution to 1 here, since we're interested
|
// NOTE(emilio): We can hardcode resolution to 1 here, since we're interested
|
||||||
// in the actual image pixels, for snapping purposes, not on the adjusted
|
// in the actual image pixels, for snapping purposes, not on the adjusted
|
||||||
// size.
|
// size.
|
||||||
|
@ -6437,35 +6436,18 @@ ImgDrawResult nsLayoutUtils::DrawSingleImage(
|
||||||
return ImgDrawResult::SUCCESS; // no point in drawing a zero size image
|
return ImgDrawResult::SUCCESS; // no point in drawing a zero size image
|
||||||
}
|
}
|
||||||
|
|
||||||
nsSize imageSize(CSSPixel::ToAppUnits(pixelImageSize));
|
const nsSize imageSize(CSSPixel::ToAppUnits(pixelImageSize));
|
||||||
nsRect source;
|
const nsRect source(nsPoint(), imageSize);
|
||||||
nsCOMPtr<imgIContainer> image;
|
const nsRect dest = GetWholeImageDestination(imageSize, source, aDest);
|
||||||
if (aSourceArea) {
|
|
||||||
source = *aSourceArea;
|
|
||||||
nsIntRect subRect(source.x, source.y, source.width, source.height);
|
|
||||||
subRect.ScaleInverseRoundOut(appUnitsPerCSSPixel);
|
|
||||||
image = ImageOps::Clip(aImage, subRect);
|
|
||||||
|
|
||||||
nsRect imageRect;
|
|
||||||
imageRect.SizeTo(imageSize);
|
|
||||||
nsRect clippedSource = imageRect.Intersect(source);
|
|
||||||
|
|
||||||
source -= clippedSource.TopLeft();
|
|
||||||
imageSize = clippedSource.Size();
|
|
||||||
} else {
|
|
||||||
source.SizeTo(imageSize);
|
|
||||||
image = aImage;
|
|
||||||
}
|
|
||||||
|
|
||||||
nsRect dest = GetWholeImageDestination(imageSize, source, aDest);
|
|
||||||
|
|
||||||
// Ensure that only a single image tile is drawn. If aSourceArea extends
|
// Ensure that only a single image tile is drawn. If aSourceArea extends
|
||||||
// outside the image bounds, we want to honor the aSourceArea-to-aDest
|
// outside the image bounds, we want to honor the aSourceArea-to-aDest
|
||||||
// transform but we don't want to actually tile the image.
|
// transform but we don't want to actually tile the image.
|
||||||
nsRect fill;
|
nsRect fill;
|
||||||
fill.IntersectRect(aDest, dest);
|
fill.IntersectRect(aDest, dest);
|
||||||
return DrawImageInternal(aContext, aPresContext, image, aSamplingFilter, dest,
|
return DrawImageInternal(aContext, aPresContext, aImage, aSamplingFilter,
|
||||||
fill, aAnchorPoint ? *aAnchorPoint : fill.TopLeft(),
|
dest, fill,
|
||||||
|
aAnchorPoint ? *aAnchorPoint : fill.TopLeft(),
|
||||||
aDirty, aSVGContext, aImageFlags);
|
aDirty, aSVGContext, aImageFlags);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1951,17 +1951,12 @@ class nsLayoutUtils {
|
||||||
* variety.
|
* variety.
|
||||||
* @param aAnchor If non-null, a point which we will ensure
|
* @param aAnchor If non-null, a point which we will ensure
|
||||||
* is pixel-aligned in the output.
|
* is pixel-aligned in the output.
|
||||||
* @param aSourceArea If non-null, this area is extracted from
|
|
||||||
* the image and drawn in aDest. It's
|
|
||||||
* in appunits. For best results it should
|
|
||||||
* be aligned with image pixels.
|
|
||||||
*/
|
*/
|
||||||
static ImgDrawResult DrawSingleImage(
|
static ImgDrawResult DrawSingleImage(
|
||||||
gfxContext& aContext, nsPresContext* aPresContext, imgIContainer* aImage,
|
gfxContext& aContext, nsPresContext* aPresContext, imgIContainer* aImage,
|
||||||
SamplingFilter aSamplingFilter, const nsRect& aDest, const nsRect& aDirty,
|
SamplingFilter aSamplingFilter, const nsRect& aDest, const nsRect& aDirty,
|
||||||
const mozilla::SVGImageContext& aSVGContext, uint32_t aImageFlags,
|
const mozilla::SVGImageContext& aSVGContext, uint32_t aImageFlags,
|
||||||
const nsPoint* aAnchorPoint = nullptr,
|
const nsPoint* aAnchorPoint = nullptr);
|
||||||
const nsRect* aSourceArea = nullptr);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Given an imgIContainer, this method attempts to obtain an intrinsic
|
* Given an imgIContainer, this method attempts to obtain an intrinsic
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
<?xml version="1.0"?>
|
<?xml version="1.0"?>
|
||||||
<window xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
|
<window xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
|
||||||
<vbox style="height:204px; border:2px solid blue;" flex="0">
|
<vbox style="border:2px solid blue;" flex="0">
|
||||||
<image style="list-style-image: url(mozilla-banner.gif);"/>
|
<image style="list-style-image: url(mozilla-banner.gif);"/>
|
||||||
</vbox>
|
</vbox>
|
||||||
<vbox/>
|
<vbox/>
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
<?xml version="1.0"?>
|
<?xml version="1.0"?>
|
||||||
<window xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
|
<window xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
|
||||||
<image style="border:2px solid blue; list-style-image: url(mozilla-banner.gif); -moz-image-region: rect(0 600px 200px 0);"/>
|
<image style="border:2px solid blue; list-style-image: url(mozilla-banner.gif);"/>
|
||||||
</window>
|
</window>
|
||||||
|
|
|
@ -1203,7 +1203,7 @@ fuzzy(0-1,0-34360) == 461512-1.html 461512-1-ref.html
|
||||||
== 462844-3.html 462844-ref.html
|
== 462844-3.html 462844-ref.html
|
||||||
== 462844-4.html 462844-ref.html
|
== 462844-4.html 462844-ref.html
|
||||||
== 463204-1.html 463204-1-ref.html
|
== 463204-1.html 463204-1-ref.html
|
||||||
fuzzy-if(!useDrawSnapshot,16-16,3345-4100) == chrome://reftest/content/bugs/463217-1.xhtml chrome://reftest/content/bugs/463217-1-ref.xhtml
|
== chrome://reftest/content/bugs/463217-1.xhtml chrome://reftest/content/bugs/463217-1-ref.xhtml
|
||||||
== 463952-1.html 463952-1-ref.html
|
== 463952-1.html 463952-1-ref.html
|
||||||
== 464811-1.html 464811-1-ref.html
|
== 464811-1.html 464811-1-ref.html
|
||||||
== 465574-1.html 465574-1-ref.html # bug 421436
|
== 465574-1.html 465574-1-ref.html # bug 421436
|
||||||
|
|
Двоичные данные
layout/reftests/image-region/image-region-ref.png
Двоичные данные
layout/reftests/image-region/image-region-ref.png
Двоичный файл не отображается.
До Ширина: | Высота: | Размер: 174 B |
|
@ -1,14 +0,0 @@
|
||||||
<?xml version="1.0"?>
|
|
||||||
<!--
|
|
||||||
Any copyright is dedicated to the Public Domain.
|
|
||||||
http://creativecommons.org/licenses/publicdomain/
|
|
||||||
-->
|
|
||||||
<?xml-stylesheet href="image-region.css" type="text/css"?>
|
|
||||||
<window xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
|
|
||||||
id="main"
|
|
||||||
class="reftest-image-region">
|
|
||||||
<hbox id="ref">
|
|
||||||
<image id="image1" />
|
|
||||||
<hbox style="-moz-box-flex: 1000" />
|
|
||||||
</hbox>
|
|
||||||
</window>
|
|
|
@ -1,19 +0,0 @@
|
||||||
/*
|
|
||||||
Any copyright is dedicated to the Public Domain.
|
|
||||||
http://creativecommons.org/licenses/publicdomain/
|
|
||||||
*/
|
|
||||||
hbox#test > image {
|
|
||||||
list-style-image: url("image-region.png");
|
|
||||||
}
|
|
||||||
|
|
||||||
hbox#test > #image1 {
|
|
||||||
-moz-image-region: rect(1px, 19px, 9px, 1px);
|
|
||||||
}
|
|
||||||
|
|
||||||
hbox#ref > image {
|
|
||||||
list-style-image: none;
|
|
||||||
}
|
|
||||||
|
|
||||||
hbox#ref > #image1 {
|
|
||||||
list-style-image: url("image-region-ref.png");
|
|
||||||
}
|
|
Двоичные данные
layout/reftests/image-region/image-region.png
Двоичные данные
layout/reftests/image-region/image-region.png
Двоичный файл не отображается.
До Ширина: | Высота: | Размер: 189 B |
|
@ -1,14 +0,0 @@
|
||||||
<?xml version="1.0"?>
|
|
||||||
<!--
|
|
||||||
Any copyright is dedicated to the Public Domain.
|
|
||||||
http://creativecommons.org/licenses/publicdomain/
|
|
||||||
-->
|
|
||||||
<?xml-stylesheet href="image-region.css" type="text/css"?>
|
|
||||||
<window xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
|
|
||||||
id="main"
|
|
||||||
class="reftest-image-region">
|
|
||||||
<hbox id="test">
|
|
||||||
<image id="image1" />
|
|
||||||
<hbox style="-moz-box-flex: 1000" />
|
|
||||||
</hbox>
|
|
||||||
</window>
|
|
|
@ -1 +0,0 @@
|
||||||
== chrome://reftest/content/image-region/image-region.xhtml chrome://reftest/content/image-region/image-region-ref.xhtml
|
|
|
@ -243,9 +243,6 @@ include image-element/reftest.list
|
||||||
# image-rect/
|
# image-rect/
|
||||||
include image-rect/reftest.list
|
include image-rect/reftest.list
|
||||||
|
|
||||||
# image-region/
|
|
||||||
include image-region/reftest.list
|
|
||||||
|
|
||||||
# indic shaping with harfbuzz
|
# indic shaping with harfbuzz
|
||||||
include indic-shaping/reftest.list
|
include indic-shaping/reftest.list
|
||||||
|
|
||||||
|
|
|
@ -15,7 +15,6 @@ function run()
|
||||||
body { display: none } /* so we control the order of the ComputeListData calls */
|
body { display: none } /* so we control the order of the ComputeListData calls */
|
||||||
|
|
||||||
#s1, #s2, #s3 {
|
#s1, #s2, #s3 {
|
||||||
-moz-image-region: auto;
|
|
||||||
list-style-image: none;
|
list-style-image: none;
|
||||||
list-style-position: outside;
|
list-style-position: outside;
|
||||||
list-style-type: disc;
|
list-style-type: disc;
|
||||||
|
|
|
@ -601,8 +601,7 @@ nsChangeHint nsStyleOutline::CalcDifference(
|
||||||
nsStyleList::nsStyleList(const Document& aDocument)
|
nsStyleList::nsStyleList(const Document& aDocument)
|
||||||
: mListStylePosition(StyleListStylePosition::Outside),
|
: mListStylePosition(StyleListStylePosition::Outside),
|
||||||
mQuotes(StyleQuotes::Auto()),
|
mQuotes(StyleQuotes::Auto()),
|
||||||
mListStyleImage(StyleImage::None()),
|
mListStyleImage(StyleImage::None()) {
|
||||||
mImageRegion(StyleClipRectOrAuto::Auto()) {
|
|
||||||
MOZ_COUNT_CTOR(nsStyleList);
|
MOZ_COUNT_CTOR(nsStyleList);
|
||||||
MOZ_ASSERT(NS_IsMainThread());
|
MOZ_ASSERT(NS_IsMainThread());
|
||||||
|
|
||||||
|
@ -615,8 +614,7 @@ nsStyleList::nsStyleList(const nsStyleList& aSource)
|
||||||
: mListStylePosition(aSource.mListStylePosition),
|
: mListStylePosition(aSource.mListStylePosition),
|
||||||
mCounterStyle(aSource.mCounterStyle),
|
mCounterStyle(aSource.mCounterStyle),
|
||||||
mQuotes(aSource.mQuotes),
|
mQuotes(aSource.mQuotes),
|
||||||
mListStyleImage(aSource.mListStyleImage),
|
mListStyleImage(aSource.mListStyleImage) {
|
||||||
mImageRegion(aSource.mImageRegion) {
|
|
||||||
MOZ_COUNT_CTOR(nsStyleList);
|
MOZ_COUNT_CTOR(nsStyleList);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -656,14 +654,6 @@ nsChangeHint nsStyleList::CalcDifference(
|
||||||
if (mListStyleImage != aNewData.mListStyleImage) {
|
if (mListStyleImage != aNewData.mListStyleImage) {
|
||||||
return NS_STYLE_HINT_REFLOW;
|
return NS_STYLE_HINT_REFLOW;
|
||||||
}
|
}
|
||||||
if (mImageRegion != aNewData.mImageRegion) {
|
|
||||||
nsRect region = GetImageRegion();
|
|
||||||
nsRect newRegion = aNewData.GetImageRegion();
|
|
||||||
if (region.width != newRegion.width || region.height != newRegion.height) {
|
|
||||||
return NS_STYLE_HINT_REFLOW;
|
|
||||||
}
|
|
||||||
return NS_STYLE_HINT_VISUAL;
|
|
||||||
}
|
|
||||||
return hint;
|
return hint;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -708,13 +708,6 @@ struct MOZ_NEEDS_MEMMOVABLE_MEMBERS nsStyleList {
|
||||||
nsChangeHint CalcDifference(const nsStyleList& aNewData,
|
nsChangeHint CalcDifference(const nsStyleList& aNewData,
|
||||||
const nsStyleDisplay& aOldDisplay) const;
|
const nsStyleDisplay& aOldDisplay) const;
|
||||||
|
|
||||||
nsRect GetImageRegion() const {
|
|
||||||
if (!mImageRegion.IsRect()) {
|
|
||||||
return nsRect();
|
|
||||||
}
|
|
||||||
return mImageRegion.AsRect().ToLayoutRect(0);
|
|
||||||
}
|
|
||||||
|
|
||||||
already_AddRefed<nsIURI> GetListStyleImageURI() const;
|
already_AddRefed<nsIURI> GetListStyleImageURI() const;
|
||||||
|
|
||||||
mozilla::StyleListStylePosition mListStylePosition;
|
mozilla::StyleListStylePosition mListStylePosition;
|
||||||
|
@ -722,9 +715,6 @@ struct MOZ_NEEDS_MEMMOVABLE_MEMBERS nsStyleList {
|
||||||
mozilla::CounterStylePtr mCounterStyle;
|
mozilla::CounterStylePtr mCounterStyle;
|
||||||
mozilla::StyleQuotes mQuotes;
|
mozilla::StyleQuotes mQuotes;
|
||||||
mozilla::StyleImage mListStyleImage;
|
mozilla::StyleImage mListStyleImage;
|
||||||
|
|
||||||
// the rect to use within an image.
|
|
||||||
mozilla::StyleClipRectOrAuto mImageRegion;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
struct MOZ_NEEDS_MEMMOVABLE_MEMBERS nsStylePage {
|
struct MOZ_NEEDS_MEMMOVABLE_MEMBERS nsStylePage {
|
||||||
|
|
|
@ -2872,14 +2872,6 @@ var gCSSProperties = {
|
||||||
other_values: ["1"],
|
other_values: ["1"],
|
||||||
invalid_values: [],
|
invalid_values: [],
|
||||||
},
|
},
|
||||||
"-moz-image-region": {
|
|
||||||
domProp: "MozImageRegion",
|
|
||||||
inherited: true,
|
|
||||||
type: CSS_TYPE_LONGHAND,
|
|
||||||
initial_values: ["auto"],
|
|
||||||
other_values: ["rect(3px 20px 15px 4px)", "rect(17px, 21px, 33px, 2px)"],
|
|
||||||
invalid_values: ["rect(17px, 21px, 33, 2px)"],
|
|
||||||
},
|
|
||||||
"margin-inline": {
|
"margin-inline": {
|
||||||
domProp: "marginInline",
|
domProp: "marginInline",
|
||||||
inherited: false,
|
inherited: false,
|
||||||
|
|
|
@ -86,7 +86,6 @@ var supported_properties = {
|
||||||
test_length_unclamped, test_percent_unclamped ],
|
test_length_unclamped, test_percent_unclamped ],
|
||||||
"cy": [ test_length_transition, test_percent_transition,
|
"cy": [ test_length_transition, test_percent_transition,
|
||||||
test_length_unclamped, test_percent_unclamped ],
|
test_length_unclamped, test_percent_unclamped ],
|
||||||
"-moz-image-region": [ test_rect_transition ],
|
|
||||||
"background-color": [ test_color_transition,
|
"background-color": [ test_color_transition,
|
||||||
test_currentcolor_transition ],
|
test_currentcolor_transition ],
|
||||||
"background-position": [ test_background_position_transition,
|
"background-position": [ test_background_position_transition,
|
||||||
|
|
|
@ -69,7 +69,6 @@ using namespace mozilla::image;
|
||||||
using namespace mozilla::layers;
|
using namespace mozilla::layers;
|
||||||
|
|
||||||
using mozilla::dom::Document;
|
using mozilla::dom::Document;
|
||||||
using mozilla::dom::Element;
|
|
||||||
using mozilla::dom::ReferrerInfo;
|
using mozilla::dom::ReferrerInfo;
|
||||||
|
|
||||||
class nsImageBoxFrameEvent : public Runnable {
|
class nsImageBoxFrameEvent : public Runnable {
|
||||||
|
@ -347,14 +346,12 @@ ImgDrawResult nsImageBoxFrame::PaintImage(gfxContext& aRenderingContext,
|
||||||
return ImgDrawResult::TEMPORARY_ERROR;
|
return ImgDrawResult::TEMPORARY_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool hasSubRect = !mUseSrcAttr && (mSubRect.width > 0 || mSubRect.height > 0);
|
|
||||||
|
|
||||||
SVGImageContext svgContext;
|
SVGImageContext svgContext;
|
||||||
SVGImageContext::MaybeStoreContextPaint(svgContext, this, imgCon);
|
SVGImageContext::MaybeStoreContextPaint(svgContext, this, imgCon);
|
||||||
return nsLayoutUtils::DrawSingleImage(
|
return nsLayoutUtils::DrawSingleImage(
|
||||||
aRenderingContext, PresContext(), imgCon,
|
aRenderingContext, PresContext(), imgCon,
|
||||||
nsLayoutUtils::GetSamplingFilterForFrame(this), dest, dirty, svgContext,
|
nsLayoutUtils::GetSamplingFilterForFrame(this), dest, dirty, svgContext,
|
||||||
aFlags, anchorPoint.ptrOr(nullptr), hasSubRect ? &mSubRect : nullptr);
|
aFlags, anchorPoint.ptrOr(nullptr));
|
||||||
}
|
}
|
||||||
|
|
||||||
ImgDrawResult nsImageBoxFrame::CreateWebRenderCommands(
|
ImgDrawResult nsImageBoxFrame::CreateWebRenderCommands(
|
||||||
|
@ -500,13 +497,7 @@ bool nsDisplayXULImage::CreateWebRenderCommands(
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool nsImageBoxFrame::CanOptimizeToImageLayer() {
|
bool nsImageBoxFrame::CanOptimizeToImageLayer() { return true; }
|
||||||
bool hasSubRect = !mUseSrcAttr && (mSubRect.width > 0 || mSubRect.height > 0);
|
|
||||||
if (hasSubRect) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
const mozilla::StyleImage* nsImageBoxFrame::GetImageFromStyle(
|
const mozilla::StyleImage* nsImageBoxFrame::GetImageFromStyle(
|
||||||
const ComputedStyle& aStyle) const {
|
const ComputedStyle& aStyle) const {
|
||||||
|
@ -545,9 +536,6 @@ void nsImageBoxFrame::DidSetComputedStyle(ComputedStyle* aOldStyle) {
|
||||||
nsLeafBoxFrame::DidSetComputedStyle(aOldStyle);
|
nsLeafBoxFrame::DidSetComputedStyle(aOldStyle);
|
||||||
|
|
||||||
// Fetch our subrect.
|
// Fetch our subrect.
|
||||||
const nsStyleList* myList = StyleList();
|
|
||||||
mSubRect = myList->GetImageRegion(); // before |mSuppressStyleCheck| test!
|
|
||||||
|
|
||||||
if (mUseSrcAttr || mSuppressStyleCheck) {
|
if (mUseSrcAttr || mSuppressStyleCheck) {
|
||||||
return; // No more work required, since the image isn't specified by style.
|
return; // No more work required, since the image isn't specified by style.
|
||||||
}
|
}
|
||||||
|
@ -575,19 +563,14 @@ void nsImageBoxFrame::GetImageSize() {
|
||||||
* Ok return our dimensions
|
* Ok return our dimensions
|
||||||
*/
|
*/
|
||||||
nsSize nsImageBoxFrame::GetXULPrefSize(nsBoxLayoutState& aState) {
|
nsSize nsImageBoxFrame::GetXULPrefSize(nsBoxLayoutState& aState) {
|
||||||
nsSize size(0, 0);
|
nsSize size;
|
||||||
DISPLAY_PREF_SIZE(this, size);
|
DISPLAY_PREF_SIZE(this, size);
|
||||||
if (XULNeedsRecalc(mImageSize)) {
|
if (XULNeedsRecalc(mImageSize)) {
|
||||||
GetImageSize();
|
GetImageSize();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!mUseSrcAttr && (mSubRect.width > 0 || mSubRect.height > 0)) {
|
size = mImageSize;
|
||||||
size = mSubRect.Size();
|
const nsSize intrinsicSize = size;
|
||||||
} else {
|
|
||||||
size = mImageSize;
|
|
||||||
}
|
|
||||||
|
|
||||||
nsSize intrinsicSize = size;
|
|
||||||
|
|
||||||
nsMargin borderPadding(0, 0, 0, 0);
|
nsMargin borderPadding(0, 0, 0, 0);
|
||||||
GetXULBorderAndPadding(borderPadding);
|
GetXULBorderAndPadding(borderPadding);
|
||||||
|
|
|
@ -127,8 +127,6 @@ class nsImageBoxFrame final : public nsLeafBoxFrame {
|
||||||
void OnImageIsAnimated(imgIRequest* aRequest);
|
void OnImageIsAnimated(imgIRequest* aRequest);
|
||||||
void OnFrameUpdate(imgIRequest* aRequest);
|
void OnFrameUpdate(imgIRequest* aRequest);
|
||||||
|
|
||||||
nsRect mSubRect; ///< If set, indicates that only the portion of the image
|
|
||||||
///< specified by the rect should be used.
|
|
||||||
nsSize mIntrinsicSize;
|
nsSize mIntrinsicSize;
|
||||||
nsSize mImageSize;
|
nsSize mImageSize;
|
||||||
|
|
||||||
|
|
|
@ -96,20 +96,4 @@ div div { background: blue; display: inline; float: left; }
|
||||||
src="image4x3.png" style="box-sizing: border-box; width: 112px; height: 88px; padding: 8px;"/>
|
src="image4x3.png" style="box-sizing: border-box; width: 112px; height: 88px; padding: 8px;"/>
|
||||||
</html:div>
|
</html:div>
|
||||||
|
|
||||||
<html:div><html:div
|
|
||||||
style="width: 20px; height: 15px;"/><html:div
|
|
||||||
style="width: 80px; height: 60px;"/><html:div
|
|
||||||
style="width: 40px; height: 30px;"/><html:div
|
|
||||||
style="width: 10px; height: 8px;"/><html:div
|
|
||||||
style="width: 10px; height: 8px;"/>
|
|
||||||
</html:div>
|
|
||||||
|
|
||||||
<html:div><html:div style="width: 20px; height: 15px;"/></html:div>
|
|
||||||
|
|
||||||
<html:div><html:div style="width: 20px; height: 15px;"/></html:div>
|
|
||||||
|
|
||||||
<html:div><html:div style="box-sizing: border-box; width: 24px; height: 22px; border: 8px solid green;"/></html:div>
|
|
||||||
|
|
||||||
<html:div><html:div style="box-sizing: border-box; width: 24px; height: 22px; border: 8px solid green;"/></html:div>
|
|
||||||
|
|
||||||
</window>
|
</window>
|
||||||
|
|
|
@ -91,29 +91,4 @@
|
||||||
<image src="image4x3.png" style="min-width: 90px; min-height: 76px; padding: 8px;"/>
|
<image src="image4x3.png" style="min-width: 90px; min-height: 76px; padding: 8px;"/>
|
||||||
<image src="image4x3.png" style="min-width: 112px; min-height: 76px; padding: 8px;"/>
|
<image src="image4x3.png" style="min-width: 112px; min-height: 76px; padding: 8px;"/>
|
||||||
</hbox>
|
</hbox>
|
||||||
|
|
||||||
<hbox align="start">
|
|
||||||
<image style="width: auto; height: auto; list-style-image: url(image4x3.png); -moz-image-region: rect(5px, 25px, 20px, 5px);"/>
|
|
||||||
<image style="width: 80px; list-style-image: url(image4x3.png); -moz-image-region: rect(5px, 25px, 20px, 5px);"/>
|
|
||||||
<image style="height: 30px; list-style-image: url(image4x3.png); -moz-image-region: rect(5px, 25px, 20px, 5px);"/>
|
|
||||||
<image style="width: 10px; list-style-image: url(image4x3.png); -moz-image-region: rect(5px, 25px, 21px, 5px);"/>
|
|
||||||
<image style="height: 8px; list-style-image: url(image4x3.png); -moz-image-region: rect(5px, 25px, 21px, 5px);"/>
|
|
||||||
</hbox>
|
|
||||||
|
|
||||||
<hbox align="end">
|
|
||||||
<image style="max-width: 20px; list-style-image: url(image4x3.png); -moz-image-region: rect(5px, 25px, 20px, 5px);"/>
|
|
||||||
</hbox>
|
|
||||||
|
|
||||||
<hbox align="end">
|
|
||||||
<image style="max-height: 15px; list-style-image: url(image4x3.png); -moz-image-region: rect(5px, 25px, 20px, 5px);"/>
|
|
||||||
</hbox>
|
|
||||||
|
|
||||||
<hbox align="end">
|
|
||||||
<image style="width: 24px; list-style-image: url(image4x3.png); -moz-image-region: rect(5px, 25px, 20px, 5px); border: 8px solid green;"/>
|
|
||||||
</hbox>
|
|
||||||
|
|
||||||
<hbox align="end">
|
|
||||||
<image style="max-height: 22px; list-style-image: url(image4x3.png); -moz-image-region: rect(5px, 25px, 20px, 5px); border: 8px solid green;"/>
|
|
||||||
</hbox>
|
|
||||||
|
|
||||||
</window>
|
</window>
|
||||||
|
|
|
@ -1797,18 +1797,14 @@ nsITheme* nsTreeBodyFrame::GetTwistyRect(int32_t aRowIndex,
|
||||||
nsresult nsTreeBodyFrame::GetImage(int32_t aRowIndex, nsTreeColumn* aCol,
|
nsresult nsTreeBodyFrame::GetImage(int32_t aRowIndex, nsTreeColumn* aCol,
|
||||||
bool aUseContext,
|
bool aUseContext,
|
||||||
ComputedStyle* aComputedStyle,
|
ComputedStyle* aComputedStyle,
|
||||||
bool& aAllowImageRegions,
|
|
||||||
imgIContainer** aResult) {
|
imgIContainer** aResult) {
|
||||||
*aResult = nullptr;
|
*aResult = nullptr;
|
||||||
|
|
||||||
nsAutoString imageSrc;
|
nsAutoString imageSrc;
|
||||||
mView->GetImageSrc(aRowIndex, aCol, imageSrc);
|
mView->GetImageSrc(aRowIndex, aCol, imageSrc);
|
||||||
RefPtr<imgRequestProxy> styleRequest;
|
RefPtr<imgRequestProxy> styleRequest;
|
||||||
if (!aUseContext && !imageSrc.IsEmpty()) {
|
if (aUseContext || imageSrc.IsEmpty()) {
|
||||||
aAllowImageRegions = false;
|
|
||||||
} else {
|
|
||||||
// Obtain the URL from the ComputedStyle.
|
// Obtain the URL from the ComputedStyle.
|
||||||
aAllowImageRegions = true;
|
|
||||||
styleRequest =
|
styleRequest =
|
||||||
aComputedStyle->StyleList()->mListStyleImage.GetImageRequest();
|
aComputedStyle->StyleList()->mListStyleImage.GetImageRequest();
|
||||||
if (!styleRequest) return NS_OK;
|
if (!styleRequest) return NS_OK;
|
||||||
|
@ -1927,24 +1923,13 @@ nsRect nsTreeBodyFrame::GetImageSize(int32_t aRowIndex, nsTreeColumn* aCol,
|
||||||
|
|
||||||
// We have to load image even though we already have a size.
|
// We have to load image even though we already have a size.
|
||||||
// Don't change this, otherwise things start to go awry.
|
// Don't change this, otherwise things start to go awry.
|
||||||
bool useImageRegion = true;
|
|
||||||
nsCOMPtr<imgIContainer> image;
|
nsCOMPtr<imgIContainer> image;
|
||||||
GetImage(aRowIndex, aCol, aUseContext, aComputedStyle, useImageRegion,
|
GetImage(aRowIndex, aCol, aUseContext, aComputedStyle, getter_AddRefs(image));
|
||||||
getter_AddRefs(image));
|
|
||||||
|
|
||||||
const nsStylePosition* myPosition = aComputedStyle->StylePosition();
|
const nsStylePosition* myPosition = aComputedStyle->StylePosition();
|
||||||
const nsStyleList* myList = aComputedStyle->StyleList();
|
|
||||||
nsRect imageRegion = myList->GetImageRegion();
|
|
||||||
if (useImageRegion) {
|
|
||||||
r.x += imageRegion.x;
|
|
||||||
r.y += imageRegion.y;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (myPosition->mWidth.ConvertsToLength()) {
|
if (myPosition->mWidth.ConvertsToLength()) {
|
||||||
int32_t val = myPosition->mWidth.ToLength();
|
int32_t val = myPosition->mWidth.ToLength();
|
||||||
r.width += val;
|
r.width += val;
|
||||||
} else if (useImageRegion && imageRegion.width > 0) {
|
|
||||||
r.width += imageRegion.width;
|
|
||||||
} else {
|
} else {
|
||||||
needWidth = true;
|
needWidth = true;
|
||||||
}
|
}
|
||||||
|
@ -1952,10 +1937,9 @@ nsRect nsTreeBodyFrame::GetImageSize(int32_t aRowIndex, nsTreeColumn* aCol,
|
||||||
if (myPosition->mHeight.ConvertsToLength()) {
|
if (myPosition->mHeight.ConvertsToLength()) {
|
||||||
int32_t val = myPosition->mHeight.ToLength();
|
int32_t val = myPosition->mHeight.ToLength();
|
||||||
r.height += val;
|
r.height += val;
|
||||||
} else if (useImageRegion && imageRegion.height > 0)
|
} else {
|
||||||
r.height += imageRegion.height;
|
|
||||||
else
|
|
||||||
needHeight = true;
|
needHeight = true;
|
||||||
|
}
|
||||||
|
|
||||||
if (image) {
|
if (image) {
|
||||||
if (needWidth || needHeight) {
|
if (needWidth || needHeight) {
|
||||||
|
@ -1991,7 +1975,6 @@ nsRect nsTreeBodyFrame::GetImageSize(int32_t aRowIndex, nsTreeColumn* aCol,
|
||||||
// If only the destination height has been specified in CSS, the width is
|
// If only the destination height has been specified in CSS, the width is
|
||||||
// calculated to maintain the aspect ratio of the image.
|
// calculated to maintain the aspect ratio of the image.
|
||||||
nsSize nsTreeBodyFrame::GetImageDestSize(ComputedStyle* aComputedStyle,
|
nsSize nsTreeBodyFrame::GetImageDestSize(ComputedStyle* aComputedStyle,
|
||||||
bool useImageRegion,
|
|
||||||
imgIContainer* image) {
|
imgIContainer* image) {
|
||||||
nsSize size(0, 0);
|
nsSize size(0, 0);
|
||||||
|
|
||||||
|
@ -2022,24 +2005,10 @@ nsSize nsTreeBodyFrame::GetImageDestSize(ComputedStyle* aComputedStyle,
|
||||||
if (needWidth || needHeight) {
|
if (needWidth || needHeight) {
|
||||||
// We need to get the size of the image/region.
|
// We need to get the size of the image/region.
|
||||||
nsSize imageSize(0, 0);
|
nsSize imageSize(0, 0);
|
||||||
|
if (image) {
|
||||||
const nsStyleList* myList = aComputedStyle->StyleList();
|
|
||||||
nsRect imageRegion = myList->GetImageRegion();
|
|
||||||
if (useImageRegion && imageRegion.width > 0) {
|
|
||||||
// CSS has specified an image region.
|
|
||||||
// Use the width of the image region.
|
|
||||||
imageSize.width = imageRegion.width;
|
|
||||||
} else if (image) {
|
|
||||||
nscoord width;
|
nscoord width;
|
||||||
image->GetWidth(&width);
|
image->GetWidth(&width);
|
||||||
imageSize.width = nsPresContext::CSSPixelsToAppUnits(width);
|
imageSize.width = nsPresContext::CSSPixelsToAppUnits(width);
|
||||||
}
|
|
||||||
|
|
||||||
if (useImageRegion && imageRegion.height > 0) {
|
|
||||||
// CSS has specified an image region.
|
|
||||||
// Use the height of the image region.
|
|
||||||
imageSize.height = imageRegion.height;
|
|
||||||
} else if (image) {
|
|
||||||
nscoord height;
|
nscoord height;
|
||||||
image->GetHeight(&height);
|
image->GetHeight(&height);
|
||||||
imageSize.height = nsPresContext::CSSPixelsToAppUnits(height);
|
imageSize.height = nsPresContext::CSSPixelsToAppUnits(height);
|
||||||
|
@ -2079,14 +2048,7 @@ nsSize nsTreeBodyFrame::GetImageDestSize(ComputedStyle* aComputedStyle,
|
||||||
// The width and height do not reflect the destination size specified
|
// The width and height do not reflect the destination size specified
|
||||||
// in CSS.
|
// in CSS.
|
||||||
nsRect nsTreeBodyFrame::GetImageSourceRect(ComputedStyle* aComputedStyle,
|
nsRect nsTreeBodyFrame::GetImageSourceRect(ComputedStyle* aComputedStyle,
|
||||||
bool useImageRegion,
|
|
||||||
imgIContainer* image) {
|
imgIContainer* image) {
|
||||||
const nsStyleList* myList = aComputedStyle->StyleList();
|
|
||||||
// CSS has specified an image region.
|
|
||||||
if (useImageRegion && myList->mImageRegion.IsRect()) {
|
|
||||||
return myList->GetImageRegion();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!image) {
|
if (!image) {
|
||||||
return nsRect();
|
return nsRect();
|
||||||
}
|
}
|
||||||
|
@ -3158,9 +3120,7 @@ ImgDrawResult nsTreeBodyFrame::PaintTwisty(
|
||||||
|
|
||||||
// Get the image for drawing.
|
// Get the image for drawing.
|
||||||
nsCOMPtr<imgIContainer> image;
|
nsCOMPtr<imgIContainer> image;
|
||||||
bool useImageRegion = true;
|
GetImage(aRowIndex, aColumn, true, twistyContext, getter_AddRefs(image));
|
||||||
GetImage(aRowIndex, aColumn, true, twistyContext, useImageRegion,
|
|
||||||
getter_AddRefs(image));
|
|
||||||
if (image) {
|
if (image) {
|
||||||
nsPoint anchorPoint = twistyRect.TopLeft();
|
nsPoint anchorPoint = twistyRect.TopLeft();
|
||||||
|
|
||||||
|
@ -3210,13 +3170,11 @@ ImgDrawResult nsTreeBodyFrame::PaintImage(
|
||||||
imageRect.Deflate(imageMargin);
|
imageRect.Deflate(imageMargin);
|
||||||
|
|
||||||
// Get the image.
|
// Get the image.
|
||||||
bool useImageRegion = true;
|
|
||||||
nsCOMPtr<imgIContainer> image;
|
nsCOMPtr<imgIContainer> image;
|
||||||
GetImage(aRowIndex, aColumn, false, imageContext, useImageRegion,
|
GetImage(aRowIndex, aColumn, false, imageContext, getter_AddRefs(image));
|
||||||
getter_AddRefs(image));
|
|
||||||
|
|
||||||
// Get the image destination size.
|
// Get the image destination size.
|
||||||
nsSize imageDestSize = GetImageDestSize(imageContext, useImageRegion, image);
|
nsSize imageDestSize = GetImageDestSize(imageContext, image);
|
||||||
if (!imageDestSize.width || !imageDestSize.height) {
|
if (!imageDestSize.width || !imageDestSize.height) {
|
||||||
return ImgDrawResult::SUCCESS;
|
return ImgDrawResult::SUCCESS;
|
||||||
}
|
}
|
||||||
|
@ -3300,8 +3258,7 @@ ImgDrawResult nsTreeBodyFrame::PaintImage(
|
||||||
// Get the image source rectangle - the rectangle containing the part of
|
// Get the image source rectangle - the rectangle containing the part of
|
||||||
// the image that we are going to display. sourceRect will be passed as
|
// the image that we are going to display. sourceRect will be passed as
|
||||||
// the aSrcRect argument in the DrawImage method.
|
// the aSrcRect argument in the DrawImage method.
|
||||||
nsRect sourceRect =
|
nsRect sourceRect = GetImageSourceRect(imageContext, image);
|
||||||
GetImageSourceRect(imageContext, useImageRegion, image);
|
|
||||||
|
|
||||||
// Let's say that the image is 100 pixels tall and that the CSS has
|
// Let's say that the image is 100 pixels tall and that the CSS has
|
||||||
// specified that the destination height should be 50 pixels tall. Let's
|
// specified that the destination height should be 50 pixels tall. Let's
|
||||||
|
@ -3530,9 +3487,7 @@ ImgDrawResult nsTreeBodyFrame::PaintCheckbox(int32_t aRowIndex,
|
||||||
|
|
||||||
// Get the image for drawing.
|
// Get the image for drawing.
|
||||||
nsCOMPtr<imgIContainer> image;
|
nsCOMPtr<imgIContainer> image;
|
||||||
bool useImageRegion = true;
|
GetImage(aRowIndex, aColumn, true, checkboxContext, getter_AddRefs(image));
|
||||||
GetImage(aRowIndex, aColumn, true, checkboxContext, useImageRegion,
|
|
||||||
getter_AddRefs(image));
|
|
||||||
if (image) {
|
if (image) {
|
||||||
nsPoint pt = checkboxRect.TopLeft();
|
nsPoint pt = checkboxRect.TopLeft();
|
||||||
|
|
||||||
|
|
|
@ -307,8 +307,7 @@ class nsTreeBodyFrame final : public nsLeafBoxFrame,
|
||||||
|
|
||||||
// Fetch an image from the image cache.
|
// Fetch an image from the image cache.
|
||||||
nsresult GetImage(int32_t aRowIndex, nsTreeColumn* aCol, bool aUseContext,
|
nsresult GetImage(int32_t aRowIndex, nsTreeColumn* aCol, bool aUseContext,
|
||||||
ComputedStyle* aComputedStyle, bool& aAllowImageRegions,
|
ComputedStyle* aComputedStyle, imgIContainer** aResult);
|
||||||
imgIContainer** aResult);
|
|
||||||
|
|
||||||
// Returns the size of a given image. This size *includes* border and
|
// Returns the size of a given image. This size *includes* border and
|
||||||
// padding. It does not include margins.
|
// padding. It does not include margins.
|
||||||
|
@ -317,12 +316,10 @@ class nsTreeBodyFrame final : public nsLeafBoxFrame,
|
||||||
|
|
||||||
// Returns the destination size of the image, not including borders and
|
// Returns the destination size of the image, not including borders and
|
||||||
// padding.
|
// padding.
|
||||||
nsSize GetImageDestSize(ComputedStyle* aComputedStyle, bool useImageRegion,
|
nsSize GetImageDestSize(ComputedStyle*, imgIContainer*);
|
||||||
imgIContainer* image);
|
|
||||||
|
|
||||||
// Returns the source rectangle of the image to be displayed.
|
// Returns the source rectangle of the image to be displayed.
|
||||||
nsRect GetImageSourceRect(ComputedStyle* aComputedStyle, bool useImageRegion,
|
nsRect GetImageSourceRect(ComputedStyle*, imgIContainer*);
|
||||||
imgIContainer* image);
|
|
||||||
|
|
||||||
// Returns the height of rows in the tree.
|
// Returns the height of rows in the tree.
|
||||||
int32_t GetRowHeight();
|
int32_t GetRowHeight();
|
||||||
|
|
|
@ -73,14 +73,3 @@ ${helpers.predefined_type(
|
||||||
spec="https://drafts.csswg.org/css-content/#propdef-quotes",
|
spec="https://drafts.csswg.org/css-content/#propdef-quotes",
|
||||||
servo_restyle_damage="rebuild_and_reflow",
|
servo_restyle_damage="rebuild_and_reflow",
|
||||||
)}
|
)}
|
||||||
|
|
||||||
${helpers.predefined_type(
|
|
||||||
"-moz-image-region",
|
|
||||||
"ClipRectOrAuto",
|
|
||||||
"computed::ClipRectOrAuto::auto()",
|
|
||||||
engines="gecko",
|
|
||||||
gecko_ffi_name="mImageRegion",
|
|
||||||
animation_value_type="ComputedValue",
|
|
||||||
boxed=True,
|
|
||||||
spec="Nonstandard (https://developer.mozilla.org/en-US/docs/Web/CSS/-moz-image-region)",
|
|
||||||
)}
|
|
||||||
|
|
Загрузка…
Ссылка в новой задаче