Changeset 163319 in webkit


Ignore:
Timestamp:
Feb 3, 2014 12:26:09 PM (10 years ago)
Author:
akling@apple.com
Message:

CTTE: RenderSVGGradientStop always has a SVGStopElement.
<https://webkit.org/b/128107>

RenderSVGGradientStop is never anonymous and always has a
corresponding SVGStopElement. Codify this by adding an element()
overload that returns an SVGStopElement&.

Also added missing overrides and made most functions private.

Reviewed by Darin Adler.

  • rendering/svg/RenderSVGGradientStop.cpp:

(WebCore::RenderSVGGradientStop::styleDidChange):
(WebCore::RenderSVGGradientStop::gradientElement):

  • rendering/svg/RenderSVGGradientStop.h:
  • rendering/svg/SVGRenderTreeAsText.cpp:

(WebCore::writeSVGGradientStop):

Location:
trunk/Source/WebCore
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r163318 r163319  
     12014-02-03  Andreas Kling  <akling@apple.com>
     2
     3        CTTE: RenderSVGGradientStop always has a SVGStopElement.
     4        <https://webkit.org/b/128107>
     5
     6        RenderSVGGradientStop is never anonymous and always has a
     7        corresponding SVGStopElement. Codify this by adding an element()
     8        overload that returns an SVGStopElement&.
     9
     10        Also added missing overrides and made most functions private.
     11
     12        Reviewed by Darin Adler.
     13
     14        * rendering/svg/RenderSVGGradientStop.cpp:
     15        (WebCore::RenderSVGGradientStop::styleDidChange):
     16        (WebCore::RenderSVGGradientStop::gradientElement):
     17        * rendering/svg/RenderSVGGradientStop.h:
     18        * rendering/svg/SVGRenderTreeAsText.cpp:
     19        (WebCore::writeSVGGradientStop):
     20
    1212014-02-03  David Kilzer  <ddkilzer@apple.com>
    222
  • trunk/Source/WebCore/rendering/svg/RenderSVGGradientStop.cpp

    r163283 r163319  
    5151    // <stop> elements should only be allowed to make renderers under gradient elements
    5252    // but I can imagine a few cases we might not be catching, so let's not crash if our parent isn't a gradient.
    53     SVGGradientElement* gradient = gradientElement();
     53    const auto* gradient = gradientElement();
    5454    if (!gradient)
    5555        return;
     
    6868}
    6969
    70 SVGGradientElement* RenderSVGGradientStop::gradientElement() const
     70SVGGradientElement* RenderSVGGradientStop::gradientElement()
    7171{
    72     ContainerNode* parentNode = element()->parentNode();
    73     if (parentNode->hasTagName(linearGradientTag) || parentNode->hasTagName(radialGradientTag))
    74         return toSVGGradientElement(parentNode);
    75     return 0;
     72    if (element().parentElement() && isSVGGradientElement(*element().parentElement()))
     73        return &toSVGGradientElement(*element().parentElement());
     74    return nullptr;
    7675}
    7776
  • trunk/Source/WebCore/rendering/svg/RenderSVGGradientStop.h

    r162158 r163319  
    22 * Copyright (C) 2007 Eric Seidel <eric@webkit.org>
    33 * Copyright (C) 2009 Google, Inc.
     4 * Copyright (C) 2014 Apple Inc. All rights reserved.
    45 *
    56 * This library is free software; you can redistribute it and/or
     
    2425#if ENABLE(SVG)
    2526#include "RenderElement.h"
     27#include "SVGStopElement.h"
    2628
    2729namespace WebCore {
    2830   
    2931class SVGGradientElement;
    30 class SVGStopElement;
    3132
    3233// This class exists mostly so we can hear about gradient stop style changes
     
    3637    virtual ~RenderSVGGradientStop();
    3738
    38     virtual bool isSVGGradientStop() const { return true; }
    39     virtual const char* renderName() const { return "RenderSVGGradientStop"; }
     39    SVGStopElement& element() const { return toSVGStopElement(RenderObject::nodeForNonAnonymous()); }
    4040
    41     virtual void layout();
     41private:
     42    virtual void styleDidChange(StyleDifference, const RenderStyle* oldStyle) override;
    4243
    43     // This overrides are needed to prevent ASSERTs on <svg><stop /></svg>
     44    virtual void layout() override;
     45
     46    // These overrides are needed to prevent ASSERTs on <svg><stop /></svg>
    4447    // RenderObject's default implementations ASSERT_NOT_REACHED()
    4548    // https://bugs.webkit.org/show_bug.cgi?id=20400
    4649    virtual LayoutRect clippedOverflowRectForRepaint(const RenderLayerModelObject*) const override { return LayoutRect(); }
    47     virtual FloatRect objectBoundingBox() const { return FloatRect(); }
    48     virtual FloatRect strokeBoundingBox() const { return FloatRect(); }
    49     virtual FloatRect repaintRectInLocalCoordinates() const { return FloatRect(); }
     50    virtual FloatRect objectBoundingBox() const override { return FloatRect(); }
     51    virtual FloatRect strokeBoundingBox() const override { return FloatRect(); }
     52    virtual FloatRect repaintRectInLocalCoordinates() const override { return FloatRect(); }
    5053    virtual bool nodeAtFloatPoint(const HitTestRequest&, HitTestResult&, const FloatPoint&, HitTestAction) override { return false; }
    5154
    52 protected:
    53     virtual void styleDidChange(StyleDifference, const RenderStyle* oldStyle);
     55    virtual bool isSVGGradientStop() const override { return true; }
     56    virtual const char* renderName() const override { return "RenderSVGGradientStop"; }
    5457
    55 private:
    5658    virtual bool canHaveChildren() const override { return false; }
    57     virtual void paint(PaintInfo&, const LayoutPoint&) override final { }
     59    virtual void paint(PaintInfo&, const LayoutPoint&) override { }
    5860
    59     SVGGradientElement* gradientElement() const;
     61    SVGGradientElement* gradientElement();
    6062};
    6163
  • trunk/Source/WebCore/rendering/svg/SVGRenderTreeAsText.cpp

    r163316 r163319  
    609609    writeStandardPrefix(ts, stop, indent);
    610610
    611     SVGStopElement* stopElement = toSVGStopElement(toSVGElement(stop.element()));
    612     ASSERT(stopElement);
    613 
    614     ts << " [offset=" << stopElement->offset() << "] [color=" << stopElement->stopColorIncludingOpacity() << "]\n";
     611    ts << " [offset=" << stop.element().offset() << "] [color=" << stop.element().stopColorIncludingOpacity() << "]\n";
    615612}
    616613
Note: See TracChangeset for help on using the changeset viewer.