Commit 9acd8521 authored by Robert Longson's avatar Robert Longson
Browse files

Bug 1814398 - SVGImageElement should not derive from SVGGeometryElement r=emilio

parent 63b60265
Loading
Loading
Loading
Loading
+0 −12
Original line number Diff line number Diff line
@@ -281,18 +281,6 @@ SVGImageElement::IsAttributeMapped(const nsAtom* name) const {
         SVGImageElementBase::IsAttributeMapped(name);
}

//----------------------------------------------------------------------
// SVGGeometryElement methods

already_AddRefed<Path> SVGImageElement::BuildPath(PathBuilder* aBuilder) {
  // To get bound, the faster method GetGeometryBounds() should already return
  // success. For render and hittest, SVGImageFrame should have its own
  // implementation that doesn't need to build path for an image.
  MOZ_ASSERT_UNREACHABLE(
      "There is no reason to call BuildPath for SVGImageElement");
  return nullptr;
}

//----------------------------------------------------------------------
// SVGElement methods

+2 −15
Original line number Diff line number Diff line
@@ -12,6 +12,7 @@
#include "mozilla/dom/SVGAnimatedString.h"
#include "mozilla/dom/SVGGeometryElement.h"
#include "mozilla/dom/SVGAnimatedPreserveAspectRatio.h"
#include "mozilla/gfx/2D.h"

nsresult NS_NewSVGImageElement(
    nsIContent** aResult, already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo);
@@ -22,7 +23,7 @@ class SVGImageFrame;
namespace dom {
class DOMSVGAnimatedPreserveAspectRatio;

using SVGImageElementBase = SVGGeometryElement;
using SVGImageElementBase = SVGGraphicsElement;

class SVGImageElement final : public SVGImageElementBase,
                              public nsImageLoadingContent {
@@ -57,10 +58,6 @@ class SVGImageElement final : public SVGImageElementBase,
  void AfterSetAttr(int32_t aNamespaceID, nsAtom* aName,
                    const nsAttrValue* aValue, const nsAttrValue* aOldValue,
                    nsIPrincipal* aSubjectPrincipal, bool aNotify) override;
  // <image> is not really an SVGGeometryElement, we should not treat it as
  // such. Ideally we'd not derive SVGImageElement from SVGGeometryElement at
  // all.
  bool IsSVGGeometryElement() const final { return false; }

  nsresult BindToTree(BindContext&, nsINode& aParent) override;
  void UnbindFromTree(bool aNullParent) override;
@@ -71,16 +68,6 @@ class SVGImageElement final : public SVGImageElementBase,

  NS_IMETHOD_(bool) IsAttributeMapped(const nsAtom* name) const override;

  // SVGGeometryElement methods:
  bool GetGeometryBounds(
      Rect* aBounds, const StrokeOptions& aStrokeOptions,
      const Matrix& aToBoundsSpace,
      const Matrix* aToNonScalingStrokeSpace = nullptr) override {
    *aBounds = GeometryBounds(aToBoundsSpace);
    return true;
  }
  already_AddRefed<Path> BuildPath(PathBuilder* aBuilder) override;

  // SVGSVGElement methods:
  bool HasValidDimensions() const override;

+12 −0
Original line number Diff line number Diff line
@@ -12,6 +12,7 @@
#include "mozilla/ProfilerLabels.h"
#include "mozilla/StaticPrefs_gfx.h"
#include "mozilla/SVGGeometryFrame.h"
#include "mozilla/SVGImageFrame.h"
#include "mozilla/UniquePtr.h"
#include "mozilla/gfx/2D.h"
#include "mozilla/gfx/Logging.h"
@@ -1215,6 +1216,17 @@ static ItemActivity IsItemProbablyActive(
    }
    case DisplayItemType::TYPE_SVG_GEOMETRY: {
      auto* svgItem = static_cast<DisplaySVGGeometry*>(aItem);
      if (StaticPrefs::gfx_webrender_svg_shapes() && aUniformlyScaled &&
          svgItem->ShouldBeActive(aBuilder, aResources, aSc, aManager,
                                  aDisplayListBuilder)) {
        return AssessBounds(aSc, aDisplayListBuilder, aItem,
                            aHasActivePrecedingSibling);
      }

      return ItemActivity::No;
    }
    case DisplayItemType::TYPE_SVG_IMAGE: {
      auto* svgItem = static_cast<DisplaySVGImage*>(aItem);
      if (StaticPrefs::gfx_webrender_svg_images() && aUniformlyScaled &&
          svgItem->ShouldBeActive(aBuilder, aResources, aSc, aManager,
                                  aDisplayListBuilder)) {
+1 −0
Original line number Diff line number Diff line
@@ -75,6 +75,7 @@ DECLARE_DISPLAY_ITEM_TYPE(SUBDOCUMENT,
DECLARE_DISPLAY_ITEM_TYPE(STICKY_POSITION,
                          TYPE_RENDERS_NO_IMAGES | TYPE_IS_CONTAINER)
DECLARE_DISPLAY_ITEM_TYPE(SVG_GEOMETRY, TYPE_IS_CONTENTFUL)
DECLARE_DISPLAY_ITEM_TYPE(SVG_IMAGE, TYPE_IS_CONTENTFUL)
DECLARE_DISPLAY_ITEM_TYPE(SVG_TEXT, TYPE_IS_CONTENTFUL)
DECLARE_DISPLAY_ITEM_TYPE(SVG_WRAPPER, TYPE_IS_CONTAINER)
DECLARE_DISPLAY_ITEM_TYPE(TABLE_BACKGROUND_COLOR, TYPE_RENDERS_NO_IMAGES)
+1 −1
Original line number Diff line number Diff line
@@ -123,7 +123,7 @@ fuzzy(0-1,0-600) == anim-feGaussianBlur-01.svg lime.svg
# animate some <angle> attributes:
== anim-marker-orient-01.svg lime.svg
# The test fails intermittently if this pref is enabled, see bug 1768650.
pref(gfx.webrender.svg-images,false) == anim-marker-orient-02.svg lime.svg
pref(gfx.webrender.svg-shapes,false) == anim-marker-orient-02.svg lime.svg

#animate points list:
== anim-polygon-points-01.svg anim-polygon-points-01-ref.svg
Loading