1/*
2 * Copyright (C) 2007 Eric Seidel <eric@webkit.org>
3 * Copyright (C) 2009 Google, Inc.
4 * Copyright (C) 2014 Apple Inc. All rights reserved.
5 *
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Library General Public
8 * License as published by the Free Software Foundation; either
9 * version 2 of the License, or (at your option) any later version.
10 *
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Library General Public License for more details.
15 *
16 * You should have received a copy of the GNU Library General Public License
17 * along with this library; see the file COPYING.LIB. If not, write to
18 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
19 * Boston, MA 02110-1301, USA.
20 */
21
22#pragma once
23
24#include "RenderElement.h"
25#include "SVGStopElement.h"
26
27namespace WebCore {
28
29class SVGGradientElement;
30
31// This class exists mostly so we can hear about gradient stop style changes
32class RenderSVGGradientStop final : public RenderElement {
33 WTF_MAKE_ISO_ALLOCATED(RenderSVGGradientStop);
34public:
35 RenderSVGGradientStop(SVGStopElement&, RenderStyle&&);
36 virtual ~RenderSVGGradientStop();
37
38 SVGStopElement& element() const { return downcast<SVGStopElement>(RenderObject::nodeForNonAnonymous()); }
39
40private:
41 void styleDidChange(StyleDifference, const RenderStyle* oldStyle) override;
42
43 void layout() override;
44
45 // These overrides are needed to prevent ASSERTs on <svg><stop /></svg>
46 // RenderObject's default implementations ASSERT_NOT_REACHED()
47 // https://bugs.webkit.org/show_bug.cgi?id=20400
48 LayoutRect clippedOverflowRectForRepaint(const RenderLayerModelObject*) const override { return LayoutRect(); }
49 FloatRect objectBoundingBox() const override { return FloatRect(); }
50 FloatRect strokeBoundingBox() const override { return FloatRect(); }
51 FloatRect repaintRectInLocalCoordinates() const override { return FloatRect(); }
52 bool nodeAtFloatPoint(const HitTestRequest&, HitTestResult&, const FloatPoint&, HitTestAction) override { return false; }
53
54 bool isSVGGradientStop() const override { return true; }
55 const char* renderName() const override { return "RenderSVGGradientStop"; }
56
57 bool canHaveChildren() const override { return false; }
58 void paint(PaintInfo&, const LayoutPoint&) override { }
59
60 SVGGradientElement* gradientElement();
61};
62
63} // namespace WebCore
64
65SPECIALIZE_TYPE_TRAITS_RENDER_OBJECT(RenderSVGGradientStop, isSVGGradientStop())
66