012d754e095eba4cb4cdb78a93b5fd498278afbf
[platform/framework/web/crosswalk.git] / src / third_party / WebKit / Source / core / rendering / RenderReplaced.h
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 "core/rendering/RenderBox.h"
26
27 namespace WebCore {
28
29 class RenderReplaced : public RenderBox {
30 public:
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 OVERRIDE;
37
38     bool hasReplacedLogicalWidth() const;
39     bool hasReplacedLogicalHeight() const;
40     LayoutRect replacedContentRect(const LayoutSize* overriddenIntrinsicSize = 0) const;
41
42     virtual bool needsPreferredWidthsRecalculation() const OVERRIDE;
43
44 protected:
45     virtual void willBeDestroyed() OVERRIDE;
46
47     virtual void layout() OVERRIDE;
48
49     virtual LayoutSize intrinsicSize() const OVERRIDE FINAL { return m_intrinsicSize; }
50     virtual void computeIntrinsicRatioInformation(FloatSize& intrinsicSize, double& intrinsicRatio, bool& isPercentageIntrinsicSize) const OVERRIDE;
51
52     virtual void computeIntrinsicLogicalWidths(LayoutUnit& minLogicalWidth, LayoutUnit& maxLogicalWidth) const OVERRIDE FINAL;
53
54     virtual LayoutUnit minimumReplacedHeight() const { return LayoutUnit(); }
55
56     virtual void setSelectionState(SelectionState) OVERRIDE FINAL;
57
58     bool isSelected() const;
59
60     virtual void styleDidChange(StyleDifference, const RenderStyle* oldStyle) OVERRIDE;
61
62     void setIntrinsicSize(const LayoutSize& intrinsicSize) { m_intrinsicSize = intrinsicSize; }
63     virtual void intrinsicSizeChanged();
64     virtual bool hasRelativeIntrinsicLogicalWidth() const { return false; }
65
66     virtual void paint(PaintInfo&, const LayoutPoint&) OVERRIDE;
67     bool shouldPaint(PaintInfo&, const LayoutPoint&);
68     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).
69
70 private:
71     virtual RenderBox* embeddedContentBox() const { return 0; }
72     virtual const char* renderName() const OVERRIDE { return "RenderReplaced"; }
73
74     virtual bool canHaveChildren() const OVERRIDE { return false; }
75
76     virtual void computePreferredLogicalWidths() OVERRIDE FINAL;
77     virtual void paintReplaced(PaintInfo&, const LayoutPoint&) { }
78
79     virtual LayoutRect clippedOverflowRectForRepaint(const RenderLayerModelObject* repaintContainer) const OVERRIDE;
80
81     virtual PositionWithAffinity positionForPoint(const LayoutPoint&) OVERRIDE FINAL;
82
83     virtual bool canBeSelectionLeaf() const OVERRIDE { return true; }
84
85     virtual LayoutRect selectionRectForRepaint(const RenderLayerModelObject* repaintContainer, bool clipToVisibleContent = true) OVERRIDE FINAL;
86     void computeAspectRatioInformationForRenderBox(RenderBox*, FloatSize& constrainedSize, double& intrinsicRatio, bool& isPercentageIntrinsicSize) const;
87
88     mutable LayoutSize m_intrinsicSize;
89 };
90
91 }
92
93 #endif