Commit 6234013d authored by Robert Longson's avatar Robert Longson
Browse files

Bug 1185271 - SVG pattern with userSpaceOnUse units does not scale correctly for text r=emilio

parent 2d6051aa
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -189,6 +189,7 @@ float SVGAnimatedLength::GetPixelsPerUnit(SVGViewportElement* aCtx,
float SVGAnimatedLength::GetPixelsPerUnit(nsIFrame* aFrame,
                                          uint8_t aUnitType) const {
  nsIContent* content = aFrame->GetContent();
  MOZ_ASSERT(!content->IsText(), "Not expecting text content");
  if (content->IsSVGElement()) {
    return GetPixelsPerUnit(
        SVGElementMetrics(static_cast<SVGElement*>(content)), aUnitType);
+1 −1
Original line number Diff line number Diff line
@@ -237,7 +237,7 @@ already_AddRefed<gfxPattern> SVGGradientFrame::GetPaintServerPattern(
    // Set mSource for this consumer.
    // If this gradient is applied to text, our caller will be the glyph, which
    // is not an element, so we need to get the parent
    mSource = aSource->GetContent()->IsText() ? aSource->GetParent() : aSource;
    mSource = aSource->IsTextFrame() ? aSource->GetParent() : aSource;
  }

  AutoTArray<nsIFrame*, 8> stopFrames;
+1 −1
Original line number Diff line number Diff line
@@ -1566,7 +1566,7 @@ SVGPaintServerFrame* SVGObserverUtils::GetAndObservePaintServer(
  // least look up past a text frame, and if the text frame's parent is the
  // anonymous block frame, then we look up to its parent (the SVGTextFrame).
  nsIFrame* paintedFrame = aPaintedFrame;
  if (paintedFrame->GetContent()->IsText()) {
  if (paintedFrame->IsInSVGTextSubtree()) {
    paintedFrame = paintedFrame->GetParent();
    nsIFrame* grandparent = paintedFrame->GetParent();
    if (grandparent && grandparent->IsSVGTextFrame()) {
+7 −1
Original line number Diff line number Diff line
@@ -595,6 +595,9 @@ gfxRect SVGPatternFrame::GetPatternRect(uint16_t aPatternUnits,
    width = SVGUtils::ObjectSpace(aTargetBBox, tmpWidth);
    height = SVGUtils::ObjectSpace(aTargetBBox, tmpHeight);
  } else {
    if (aTarget->IsTextFrame()) {
      aTarget = aTarget->GetParent();
    }
    float scale = MaxExpansion(aTargetCTM);
    x = SVGUtils::UserSpace(aTarget, tmpX) * scale;
    y = SVGUtils::UserSpace(aTarget, tmpY) * scale;
@@ -611,8 +614,11 @@ gfxMatrix SVGPatternFrame::ConstructCTM(const SVGAnimatedViewBox& aViewBox,
                                        const gfxRect& callerBBox,
                                        const Matrix& callerCTM,
                                        nsIFrame* aTarget) {
  SVGViewportElement* ctx = nullptr;
  if (aTarget->IsTextFrame()) {
    aTarget = aTarget->GetParent();
  }
  nsIContent* targetContent = aTarget->GetContent();
  SVGViewportElement* ctx = nullptr;
  gfxFloat scaleX, scaleY;

  // The objectBoundingBox conversion must be handled in the CTM:
+1 −0
Original line number Diff line number Diff line
@@ -268,6 +268,7 @@ float SVGUtils::UserSpace(SVGElement* aSVGElement,

float SVGUtils::UserSpace(nsIFrame* aNonSVGContext,
                          const SVGAnimatedLength* aLength) {
  MOZ_ASSERT(!aNonSVGContext->IsTextFrame(), "Not expecting text content");
  return aLength->GetAnimValue(aNonSVGContext);
}

Loading