2 * Copyright (C) 2011 Google Inc. All rights reserved.
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution.
14 * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
15 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
16 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
17 * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
18 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
19 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
20 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
21 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
23 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 #include "platform/WebColor.h"
30 #include "platform/WebCommon.h"
31 #include "platform/WebPrivatePtr.h"
34 namespace WebCore { class LayerChromium; }
43 WEBKIT_EXPORT static WebLayer create(WebLayerClient*);
46 WebLayer(const WebLayer& layer) { assign(layer); }
47 virtual ~WebLayer() { reset(); }
48 WebLayer& operator=(const WebLayer& layer)
53 bool isNull() { return m_private.isNull(); }
54 WEBKIT_EXPORT void reset();
55 WEBKIT_EXPORT void assign(const WebLayer&);
56 WEBKIT_EXPORT bool equals(const WebLayer&) const;
58 WEBKIT_EXPORT WebLayer rootLayer() const;
59 WEBKIT_EXPORT WebLayer parent() const;
60 WEBKIT_EXPORT void addChild(const WebLayer&);
61 WEBKIT_EXPORT void insertChild(const WebLayer&, size_t index);
62 WEBKIT_EXPORT void replaceChild(const WebLayer& reference, const WebLayer& newLayer);
63 WEBKIT_EXPORT void removeFromParent();
64 WEBKIT_EXPORT void removeAllChildren();
66 WEBKIT_EXPORT void setAnchorPoint(const WebFloatPoint&);
67 WEBKIT_EXPORT WebFloatPoint anchorPoint() const;
69 WEBKIT_EXPORT void setAnchorPointZ(float);
70 WEBKIT_EXPORT float anchorPointZ() const;
72 WEBKIT_EXPORT void setBounds(const WebSize&);
73 WEBKIT_EXPORT WebSize bounds() const;
75 WEBKIT_EXPORT void setMasksToBounds(bool);
76 WEBKIT_EXPORT bool masksToBounds() const;
78 WEBKIT_EXPORT void setMaskLayer(const WebLayer&);
79 WEBKIT_EXPORT WebLayer maskLayer() const;
81 WEBKIT_EXPORT void setOpacity(float);
82 WEBKIT_EXPORT float opacity() const;
84 WEBKIT_EXPORT void setOpaque(bool);
85 WEBKIT_EXPORT bool opaque() const;
87 WEBKIT_EXPORT void setPosition(const WebFloatPoint&);
88 WEBKIT_EXPORT WebFloatPoint position() const;
90 WEBKIT_EXPORT void setSublayerTransform(const SkMatrix44&);
91 WEBKIT_EXPORT SkMatrix44 sublayerTransform() const;
93 WEBKIT_EXPORT void setTransform(const SkMatrix44&);
94 WEBKIT_EXPORT SkMatrix44 transform() const;
96 WEBKIT_EXPORT void setDebugBorderColor(const WebColor&);
97 WEBKIT_EXPORT void setDebugBorderWidth(float);
99 template<typename T> T to()
102 res.WebLayer::assign(*this);
106 template<typename T> const T toConst() const
109 res.WebLayer::assign(*this);
113 #if WEBKIT_IMPLEMENTATION
114 WebLayer(const WTF::PassRefPtr<WebCore::LayerChromium>&);
115 WebLayer& operator=(const WTF::PassRefPtr<WebCore::LayerChromium>&);
116 operator WTF::PassRefPtr<WebCore::LayerChromium>() const;
117 template<typename T> T* unwrap()
119 return static_cast<T*>(m_private.get());
122 template<typename T> const T* constUnwrap() const
124 return static_cast<const T*>(m_private.get());
129 WebPrivatePtr<WebCore::LayerChromium> m_private;
132 inline bool operator==(const WebLayer& a, const WebLayer& b)
137 inline bool operator!=(const WebLayer& a, const WebLayer& b)
142 } // namespace WebKit