1/*
2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org)
3 * Copyright (C) 2004, 2005, 2006, 2007, 2009 Apple Inc. All rights reserved.
4 *
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Library General Public
7 * License as published by the Free Software Foundation; either
8 * version 2 of the License, or (at your option) any later version.
9 *
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13 * Library General Public License for more details.
14 *
15 * You should have received a copy of the GNU Library General Public License
16 * along with this library; see the file COPYING.LIB.  If not, write to
17 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
18 * Boston, MA 02110-1301, USA.
19 *
20 */
21
22#ifndef RenderReplaced_h
23#define RenderReplaced_h
24
25#include "RenderBox.h"
26
27namespace WebCore {
28
29class RenderReplaced : public RenderBox {
30public:
31    RenderReplaced(Element*);
32    RenderReplaced(Element*, const LayoutSize& intrinsicSize);
33    virtual ~RenderReplaced();
34
35    virtual LayoutUnit computeReplacedLogicalWidth(ShouldComputePreferred  = ComputeActual) const OVERRIDE;
36    virtual LayoutUnit computeReplacedLogicalHeight() const;
37
38    bool hasReplacedLogicalWidth() const;
39    bool hasReplacedLogicalHeight() const;
40
41protected:
42    virtual void willBeDestroyed();
43
44    virtual void layout();
45
46    virtual LayoutSize intrinsicSize() const OVERRIDE { return m_intrinsicSize; }
47    virtual void computeIntrinsicRatioInformation(FloatSize& intrinsicSize, double& intrinsicRatio, bool& isPercentageIntrinsicSize) const;
48
49    virtual void computeIntrinsicLogicalWidths(LayoutUnit& minLogicalWidth, LayoutUnit& maxLogicalWidth) const OVERRIDE;
50
51    virtual LayoutUnit minimumReplacedHeight() const { return LayoutUnit(); }
52
53    virtual void setSelectionState(SelectionState);
54
55    bool isSelected() const;
56
57    virtual void styleDidChange(StyleDifference, const RenderStyle* oldStyle);
58
59    void setIntrinsicSize(const LayoutSize& intrinsicSize) { m_intrinsicSize = intrinsicSize; }
60    virtual void intrinsicSizeChanged();
61    virtual bool hasRelativeIntrinsicLogicalWidth() const { return false; }
62
63    virtual void paint(PaintInfo&, const LayoutPoint&);
64    bool shouldPaint(PaintInfo&, const LayoutPoint&);
65    LayoutRect localSelectionRect(bool checkWhetherSelected = true) const; // This is in local coordinates, but it's a physical rect (so the top left corner is physical top left).
66
67private:
68    virtual RenderBox* embeddedContentBox() const { return 0; }
69    virtual const char* renderName() const { return "RenderReplaced"; }
70
71    virtual bool canHaveChildren() const { return false; }
72
73    virtual void computePreferredLogicalWidths();
74    virtual void paintReplaced(PaintInfo&, const LayoutPoint&) { }
75
76    virtual LayoutRect clippedOverflowRectForRepaint(const RenderLayerModelObject* repaintContainer) const OVERRIDE;
77
78    virtual VisiblePosition positionForPoint(const LayoutPoint&);
79
80    virtual bool canBeSelectionLeaf() const { return true; }
81
82    virtual LayoutRect selectionRectForRepaint(const RenderLayerModelObject* repaintContainer, bool clipToVisibleContent = true) OVERRIDE;
83    void computeAspectRatioInformationForRenderBox(RenderBox*, FloatSize& constrainedSize, double& intrinsicRatio, bool& isPercentageIntrinsicSize) const;
84
85    mutable LayoutSize m_intrinsicSize;
86};
87
88}
89
90#endif
91