Commit 5c659eb4 authored by Emilio Cobos Álvarez's avatar Emilio Cobos Álvarez
Browse files

Bug 1823764 - Use HasNonEmptyAttr to choose between XUL src and...

Bug 1823764 - Use HasNonEmptyAttr to choose between XUL src and list-style-image. r=tnikkel,layout-reviewers

This preserves the previous behavior more exactly and fixes the display
of the icons, which have src="" but expect list-style-image to take
effect.

Depends on D173265

Differential Revision: https://phabricator.services.mozilla.com/D173266
parent 3fd4d5f9
Loading
Loading
Loading
Loading
+5 −5
Original line number Diff line number Diff line
@@ -458,7 +458,7 @@ 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) {
    if (!mContent->AsElement()->HasAttr(nsGkAtoms::src) && aOldStyle &&
    if (!mContent->AsElement()->HasNonEmptyAttr(nsGkAtoms::src) && aOldStyle &&
        aOldStyle->StyleList()->mListStyleImage !=
            StyleList()->mListStyleImage) {
      UpdateXULImage();
@@ -519,7 +519,7 @@ const StyleImage* nsImageFrame::GetImageFromStyle() const {
      MOZ_ASSERT(mContent->IsHTMLElement(nsGkAtoms::mozgeneratedcontentimage));
      return &StyleList()->mListStyleImage;
    case Kind::XULImage:
      MOZ_ASSERT(!mContent->AsElement()->HasAttr(nsGkAtoms::src));
      MOZ_ASSERT(!mContent->AsElement()->HasNonEmptyAttr(nsGkAtoms::src));
      return &StyleList()->mListStyleImage;
    case Kind::ContentProperty:
    case Kind::ContentPropertyAtIndex: {
@@ -562,7 +562,7 @@ void nsImageFrame::UpdateXULImage() {

  nsAutoString src;
  nsPresContext* pc = PresContext();
  if (mContent->AsElement()->GetAttr(nsGkAtoms::src, src)) {
  if (mContent->AsElement()->GetAttr(nsGkAtoms::src, src) && !src.IsEmpty()) {
    nsContentPolicyType contentPolicyType;
    nsCOMPtr<nsIPrincipal> triggeringPrincipal;
    uint64_t requestContextID = 0;
@@ -749,7 +749,7 @@ static IntrinsicSize ComputeIntrinsicSize(imgIContainer* aImage,
    }
    if (aKind == nsImageFrame::Kind::ImageLoadingContent ||
        (aKind == nsImageFrame::Kind::XULImage &&
         aFrame.GetContent()->AsElement()->HasAttr(nsGkAtoms::src))) {
         aFrame.GetContent()->AsElement()->HasNonEmptyAttr(nsGkAtoms::src))) {
      ScaleIntrinsicSizeForDensity(aImage, *aFrame.GetContent(), intrinsicSize);
    } else {
      ScaleIntrinsicSizeForDensity(intrinsicSize,
@@ -2539,7 +2539,7 @@ nsImageMap* nsImageFrame::GetImageMap() {
}

bool nsImageFrame::IsServerImageMap() {
  return mContent->AsElement()->HasAttr(kNameSpaceID_None, nsGkAtoms::ismap);
  return mContent->AsElement()->HasAttr(nsGkAtoms::ismap);
}

CSSIntPoint nsImageFrame::TranslateEventCoords(const nsPoint& aPoint) {
+1 −0
Original line number Diff line number Diff line
@@ -94,6 +94,7 @@ div div { background: blue; display: inline; float: left; }
      src="image4x3.png" style="box-sizing: border-box; width: 112px; height: 88px; padding: 8px;"/><html:img
      src="image4x3.png" style="box-sizing: border-box; width: 96px; height: 76px; padding: 8px;"/><html:img
      src="image4x3.png" style="box-sizing: border-box; width: 112px; height: 88px; padding: 8px;"/><html:img
      src="image4x3.png" style="border: 1px solid blue"/><html:img
      width="0" height="0" style="border: 1px solid green" /><html:img
      width="0" height="0" style="border: 1px solid green" /><html:span style="display: inline-block; -moz-default-appearance: checkbox; appearance: auto" />
</html:div>
+1 −0
Original line number Diff line number Diff line
@@ -90,6 +90,7 @@
  <image src="image4x3.png" style="min-height: 88px; 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="" style="list-style-image: url(image4x3.png); border: 1px solid blue"/>
  <image id="dyn-1" src="image4x3.png" style="border: 1px solid green"/>
  <image id="dyn-2" style="list-style-image: url(image4x3.png); border: 1px solid green"/>
  <image style="-moz-default-appearance: checkbox; appearance: auto"/>