2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org)
3 * Copyright (C) 2004, 2005, 2006, 2007, 2009 Apple Inc. All rights reserved.
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.
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.
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.
22 #ifndef RenderReplaced_h
23 #define RenderReplaced_h
25 #include "core/rendering/RenderBox.h"
29 class RenderReplaced : public RenderBox {
31 RenderReplaced(Element*);
32 RenderReplaced(Element*, const LayoutSize& intrinsicSize);
33 virtual ~RenderReplaced();
35 virtual LayoutUnit computeReplacedLogicalWidth(ShouldComputePreferred = ComputeActual) const OVERRIDE;
36 virtual LayoutUnit computeReplacedLogicalHeight() const OVERRIDE;
38 bool hasReplacedLogicalHeight() const;
39 LayoutRect replacedContentRect(const LayoutSize* overriddenIntrinsicSize = 0) const;
41 virtual bool needsPreferredWidthsRecalculation() const OVERRIDE;
43 // These values are specified to be 300 and 150 pixels in the CSS 2.1 spec.
44 // http://www.w3.org/TR/CSS2/visudet.html#inline-replaced-width
45 static const int defaultWidth;
46 static const int defaultHeight;
48 virtual void paint(PaintInfo&, const LayoutPoint&) OVERRIDE;
51 virtual void willBeDestroyed() OVERRIDE;
53 virtual void layout() OVERRIDE;
55 virtual LayoutSize intrinsicSize() const OVERRIDE FINAL { return m_intrinsicSize; }
56 virtual void computeIntrinsicRatioInformation(FloatSize& intrinsicSize, double& intrinsicRatio) const OVERRIDE;
58 virtual void computeIntrinsicLogicalWidths(LayoutUnit& minLogicalWidth, LayoutUnit& maxLogicalWidth) const OVERRIDE FINAL;
60 virtual LayoutUnit intrinsicContentLogicalHeight() const { return intrinsicLogicalHeight(); }
62 virtual LayoutUnit minimumReplacedHeight() const { return LayoutUnit(); }
64 virtual void setSelectionState(SelectionState) OVERRIDE FINAL;
66 bool isSelected() const;
68 virtual void styleDidChange(StyleDifference, const RenderStyle* oldStyle) OVERRIDE;
70 void setIntrinsicSize(const LayoutSize& intrinsicSize) { m_intrinsicSize = intrinsicSize; }
71 virtual void intrinsicSizeChanged();
73 bool shouldPaint(PaintInfo&, const LayoutPoint&);
74 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).
75 virtual RenderBox* embeddedContentBox() const { return 0; }
78 virtual const char* renderName() const OVERRIDE { return "RenderReplaced"; }
80 virtual bool canHaveChildren() const OVERRIDE { return false; }
82 virtual void computePreferredLogicalWidths() OVERRIDE FINAL;
83 virtual void paintReplaced(PaintInfo&, const LayoutPoint&) { }
85 virtual LayoutRect clippedOverflowRectForPaintInvalidation(const RenderLayerModelObject* paintInvalidationContainer, const PaintInvalidationState* = 0) const OVERRIDE;
87 virtual PositionWithAffinity positionForPoint(const LayoutPoint&) OVERRIDE FINAL;
89 virtual bool canBeSelectionLeaf() const OVERRIDE { return true; }
91 virtual LayoutRect selectionRectForPaintInvalidation(const RenderLayerModelObject* paintInvalidationContainer) const OVERRIDE FINAL;
92 void computeAspectRatioInformationForRenderBox(RenderBox*, FloatSize& constrainedSize, double& intrinsicRatio) const;
94 mutable LayoutSize m_intrinsicSize;