Bug 1818432 - Provide intrinsic size from theme for xul images that are themed but don't have any images. r=tnikkel,layout-reviewers
This restores previous behavior of <xul:image>. Differential Revision: https://phabricator.services.mozilla.com/D170743
This commit is contained in:
@@ -475,10 +475,17 @@ void nsImageFrame::DidSetComputedStyle(ComputedStyle* aOldStyle) {
|
||||
//
|
||||
// TODO(emilio): We might want to do the same for regular list-style-image or
|
||||
// even simple content: url() changes.
|
||||
if (mKind == Kind::XULImage &&
|
||||
!mContent->AsElement()->HasAttr(nsGkAtoms::src) && aOldStyle &&
|
||||
aOldStyle->StyleList()->mListStyleImage != StyleList()->mListStyleImage) {
|
||||
UpdateXULImage();
|
||||
if (mKind == Kind::XULImage) {
|
||||
if (!mContent->AsElement()->HasAttr(nsGkAtoms::src) && aOldStyle &&
|
||||
aOldStyle->StyleList()->mListStyleImage !=
|
||||
StyleList()->mListStyleImage) {
|
||||
UpdateXULImage();
|
||||
}
|
||||
if (!mOwnedRequest && aOldStyle &&
|
||||
aOldStyle->StyleDisplay()->EffectiveAppearance() !=
|
||||
StyleDisplay()->EffectiveAppearance()) {
|
||||
UpdateIntrinsicSize();
|
||||
}
|
||||
}
|
||||
|
||||
// We need to update our orientation either if we had no ComputedStyle before
|
||||
@@ -778,6 +785,17 @@ static IntrinsicSize ComputeIntrinsicSize(imgIContainer* aImage,
|
||||
IntrinsicSize(defaultLength, defaultLength), aFrame);
|
||||
}
|
||||
|
||||
if (aKind == nsImageFrame::Kind::XULImage && aFrame.IsThemed()) {
|
||||
nsPresContext* pc = aFrame.PresContext();
|
||||
// FIXME: const_cast here is a bit evil but IsThemed and so does the same.
|
||||
const auto widgetSize = pc->Theme()->GetMinimumWidgetSize(
|
||||
pc, const_cast<nsImageFrame*>(&aFrame),
|
||||
aFrame.StyleDisplay()->EffectiveAppearance());
|
||||
const IntrinsicSize intrinsicSize(
|
||||
LayoutDeviceIntSize::ToAppUnits(widgetSize, pc->AppUnitsPerDevPixel()));
|
||||
return containAxes.ContainIntrinsicSize(intrinsicSize, aFrame);
|
||||
}
|
||||
|
||||
if (aFrame.ShouldShowBrokenImageIcon()) {
|
||||
nscoord edgeLengthToUse = nsPresContext::CSSPixelsToAppUnits(
|
||||
ICON_SIZE + (2 * (ICON_PADDING + ALT_BORDER_WIDTH)));
|
||||
|
||||
Reference in New Issue
Block a user