1 | /* |
2 | * Copyright (C) 1999 Lars Knoll (knoll@kde.org) |
3 | * (C) 1999 Antti Koivisto (koivisto@kde.org) |
4 | * Copyright (C) 2003, 2006, 2007, 2009 Apple Inc. All rights reserved. |
5 | * Copyright (C) 2010, 2012 Google Inc. All rights reserved. |
6 | * |
7 | * This library is free software; you can redistribute it and/or |
8 | * modify it under the terms of the GNU Library General Public |
9 | * License as published by the Free Software Foundation; either |
10 | * version 2 of the License, or (at your option) any later version. |
11 | * |
12 | * This library is distributed in the hope that it will be useful, |
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
15 | * Library General Public License for more details. |
16 | * |
17 | * You should have received a copy of the GNU Library General Public License |
18 | * along with this library; see the file COPYING.LIB. If not, write to |
19 | * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
20 | * Boston, MA 02110-1301, USA. |
21 | */ |
22 | |
23 | #pragma once |
24 | |
25 | #include "RenderElement.h" |
26 | |
27 | namespace WebCore { |
28 | |
29 | class KeyframeList; |
30 | class RenderLayer; |
31 | |
32 | struct RepaintLayoutRects { |
33 | LayoutRect m_repaintRect; // This rect is clipped by enclosing objects (e.g., overflow:hidden). |
34 | LayoutRect m_outlineBox; // This rect is unclipped. |
35 | |
36 | RepaintLayoutRects(const RenderLayerModelObject& renderer, const RenderLayerModelObject* repaintContainer, const RenderGeometryMap* = nullptr); |
37 | RepaintLayoutRects() { }; |
38 | }; |
39 | |
40 | class RenderLayerModelObject : public RenderElement { |
41 | WTF_MAKE_ISO_ALLOCATED(RenderLayerModelObject); |
42 | public: |
43 | virtual ~RenderLayerModelObject(); |
44 | |
45 | void destroyLayer(); |
46 | |
47 | bool hasSelfPaintingLayer() const; |
48 | RenderLayer* layer() const { return m_layer.get(); } |
49 | |
50 | void styleWillChange(StyleDifference, const RenderStyle& newStyle) override; |
51 | void styleDidChange(StyleDifference, const RenderStyle* oldStyle) override; |
52 | virtual void updateFromStyle() { } |
53 | |
54 | virtual bool requiresLayer() const = 0; |
55 | |
56 | // Returns true if the background is painted opaque in the given rect. |
57 | // The query rect is given in local coordinate system. |
58 | virtual bool backgroundIsKnownToBeOpaqueInRect(const LayoutRect&) const { return false; } |
59 | |
60 | virtual bool isScrollableOrRubberbandableBox() const { return false; } |
61 | |
62 | bool shouldPlaceBlockDirectionScrollbarOnLeft() const; |
63 | |
64 | void computeRepaintLayoutRects(const RenderLayerModelObject* repaintContainer, const RenderGeometryMap* = nullptr); |
65 | |
66 | RepaintLayoutRects repaintLayoutRects() const; |
67 | |
68 | bool hasRepaintLayoutRects() const; |
69 | void setRepaintLayoutRects(const RepaintLayoutRects&); |
70 | void clearRepaintLayoutRects(); |
71 | |
72 | bool startTransition(double timeOffset, CSSPropertyID, const RenderStyle* fromStyle, const RenderStyle* toStyle) override; |
73 | void transitionPaused(double timeOffset, CSSPropertyID) override; |
74 | void transitionFinished(CSSPropertyID) override; |
75 | |
76 | bool startAnimation(double timeOffset, const Animation&, const KeyframeList&) override; |
77 | void animationPaused(double timeOffset, const String& name) override; |
78 | void animationSeeked(double timeOffset, const String& name) override; |
79 | void animationFinished(const String& name) override; |
80 | |
81 | void suspendAnimations(MonotonicTime = MonotonicTime()) override; |
82 | |
83 | protected: |
84 | RenderLayerModelObject(Element&, RenderStyle&&, BaseTypeFlags); |
85 | RenderLayerModelObject(Document&, RenderStyle&&, BaseTypeFlags); |
86 | |
87 | void createLayer(); |
88 | void willBeDestroyed() override; |
89 | |
90 | private: |
91 | std::unique_ptr<RenderLayer> m_layer; |
92 | |
93 | // Used to store state between styleWillChange and styleDidChange |
94 | static bool s_wasFloating; |
95 | static bool s_hadLayer; |
96 | static bool s_hadTransform; |
97 | static bool s_layerWasSelfPainting; |
98 | }; |
99 | |
100 | } // namespace WebCore |
101 | |
102 | SPECIALIZE_TYPE_TRAITS_RENDER_OBJECT(RenderLayerModelObject, isRenderLayerModelObject()) |
103 | |