| 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 | #pragma once |
| 23 | |
| 24 | #include "RenderBox.h" |
| 25 | |
| 26 | namespace WebCore { |
| 27 | |
| 28 | class RenderReplaced : public RenderBox { |
| 29 | WTF_MAKE_ISO_ALLOCATED(RenderReplaced); |
| 30 | public: |
| 31 | virtual ~RenderReplaced(); |
| 32 | |
| 33 | LayoutUnit computeReplacedLogicalWidth(ShouldComputePreferred = ComputeActual) const override; |
| 34 | LayoutUnit computeReplacedLogicalHeight(Optional<LayoutUnit> estimatedUsedWidth = WTF::nullopt) const override; |
| 35 | |
| 36 | LayoutRect replacedContentRect(const LayoutSize& intrinsicSize) const; |
| 37 | LayoutRect replacedContentRect() const { return replacedContentRect(intrinsicSize()); } |
| 38 | |
| 39 | bool hasReplacedLogicalWidth() const; |
| 40 | bool hasReplacedLogicalHeight() const; |
| 41 | bool setNeedsLayoutIfNeededAfterIntrinsicSizeChange(); |
| 42 | |
| 43 | LayoutSize intrinsicSize() const final { return m_intrinsicSize; } |
| 44 | |
| 45 | protected: |
| 46 | RenderReplaced(Element&, RenderStyle&&); |
| 47 | RenderReplaced(Element&, RenderStyle&&, const LayoutSize& intrinsicSize); |
| 48 | RenderReplaced(Document&, RenderStyle&&, const LayoutSize& intrinsicSize); |
| 49 | |
| 50 | void layout() override; |
| 51 | |
| 52 | void computeIntrinsicRatioInformation(FloatSize& intrinsicSize, double& intrinsicRatio) const override; |
| 53 | |
| 54 | void computeIntrinsicLogicalWidths(LayoutUnit& minLogicalWidth, LayoutUnit& maxLogicalWidth) const final; |
| 55 | |
| 56 | virtual LayoutUnit minimumReplacedHeight() const { return 0_lu; } |
| 57 | |
| 58 | void setSelectionState(SelectionState) override; |
| 59 | |
| 60 | bool isSelected() const; |
| 61 | |
| 62 | void styleDidChange(StyleDifference, const RenderStyle* oldStyle) override; |
| 63 | |
| 64 | void setIntrinsicSize(const LayoutSize& intrinsicSize) { m_intrinsicSize = intrinsicSize; } |
| 65 | virtual void intrinsicSizeChanged(); |
| 66 | virtual bool hasRelativeIntrinsicLogicalWidth() const { return false; } |
| 67 | |
| 68 | void paint(PaintInfo&, const LayoutPoint&) override; |
| 69 | bool shouldPaint(PaintInfo&, const LayoutPoint&); |
| 70 | 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). |
| 71 | |
| 72 | void willBeDestroyed() override; |
| 73 | |
| 74 | private: |
| 75 | LayoutUnit computeConstrainedLogicalWidth(ShouldComputePreferred) const; |
| 76 | |
| 77 | virtual RenderBox* embeddedContentBox() const { return 0; } |
| 78 | const char* renderName() const override { return "RenderReplaced" ; } |
| 79 | |
| 80 | bool canHaveChildren() const override { return false; } |
| 81 | |
| 82 | void computePreferredLogicalWidths() final; |
| 83 | virtual void paintReplaced(PaintInfo&, const LayoutPoint&) { } |
| 84 | |
| 85 | LayoutRect clippedOverflowRectForRepaint(const RenderLayerModelObject* repaintContainer) const override; |
| 86 | |
| 87 | VisiblePosition positionForPoint(const LayoutPoint&, const RenderFragmentContainer*) final; |
| 88 | |
| 89 | bool canBeSelectionLeaf() const override { return true; } |
| 90 | |
| 91 | LayoutRect selectionRectForRepaint(const RenderLayerModelObject* repaintContainer, bool clipToVisibleContent = true) final; |
| 92 | void computeAspectRatioInformationForRenderBox(RenderBox*, FloatSize& constrainedSize, double& intrinsicRatio) const; |
| 93 | |
| 94 | virtual bool shouldDrawSelectionTint() const; |
| 95 | |
| 96 | mutable LayoutSize m_intrinsicSize; |
| 97 | }; |
| 98 | |
| 99 | } // namespace WebCore |
| 100 | |
| 101 | SPECIALIZE_TYPE_TRAITS_RENDER_OBJECT(RenderReplaced, isRenderReplaced()) |
| 102 | |