1 | /* |
2 | * Copyright (C) 2012 Apple Inc. All rights reserved. |
3 | * |
4 | * Redistribution and use in source and binary forms, with or without |
5 | * modification, are permitted provided that the following conditions |
6 | * are met: |
7 | * 1. Redistributions of source code must retain the above copyright |
8 | * notice, this list of conditions and the following disclaimer. |
9 | * 2. Redistributions in binary form must reproduce the above copyright |
10 | * notice, this list of conditions and the following disclaimer in the |
11 | * documentation and/or other materials provided with the distribution. |
12 | * |
13 | * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' |
14 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, |
15 | * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR |
16 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS |
17 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
18 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
19 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
20 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
21 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
22 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF |
23 | * THE POSSIBILITY OF SUCH DAMAGE. |
24 | */ |
25 | |
26 | #include "config.h" |
27 | #include "WKRenderLayer.h" |
28 | |
29 | #include "APIArray.h" |
30 | #include "WKAPICast.h" |
31 | #include "WebRenderLayer.h" |
32 | |
33 | WKTypeID WKRenderLayerGetTypeID() |
34 | { |
35 | return WebKit::toAPI(WebKit::WebRenderLayer::APIType); |
36 | } |
37 | |
38 | WKRenderObjectRef WKRenderLayerGetRenderer(WKRenderLayerRef renderLayerRef) |
39 | { |
40 | return toAPI(WebKit::toImpl(renderLayerRef)->renderer()); |
41 | } |
42 | |
43 | WKStringRef WKRenderLayerCopyRendererName(WKRenderLayerRef renderLayerRef) |
44 | { |
45 | return WebKit::toCopiedAPI(WebKit::toImpl(renderLayerRef)->renderer()->name()); |
46 | } |
47 | |
48 | WKStringRef WKRenderLayerCopyElementTagName(WKRenderLayerRef renderLayerRef) |
49 | { |
50 | WebKit::WebRenderLayer* renderLayer = WebKit::toImpl(renderLayerRef); |
51 | if (!renderLayer->renderer()->elementTagName().isNull()) |
52 | return WebKit::toCopiedAPI(renderLayer->renderer()->elementTagName()); |
53 | |
54 | return nullptr; |
55 | } |
56 | |
57 | WKStringRef WKRenderLayerCopyElementID(WKRenderLayerRef renderLayerRef) |
58 | { |
59 | WebKit::WebRenderLayer* renderLayer = WebKit::toImpl(renderLayerRef); |
60 | if (!renderLayer->renderer()->elementID().isNull()) |
61 | return WebKit::toCopiedAPI(renderLayer->renderer()->elementID()); |
62 | |
63 | return nullptr; |
64 | } |
65 | |
66 | WKArrayRef WKRenderLayerGetElementClassNames(WKRenderLayerRef renderLayerRef) |
67 | { |
68 | return WebKit::toAPI(WebKit::toImpl(renderLayerRef)->renderer()->elementClassNames()); |
69 | } |
70 | |
71 | WKRect WKRenderLayerGetAbsoluteBounds(WKRenderLayerRef renderLayerRef) |
72 | { |
73 | WebCore::IntRect bounds = WebKit::toImpl(renderLayerRef)->absoluteBoundingBox(); |
74 | return WKRectMake(bounds.x(), bounds.y(), bounds.width(), bounds.height()); |
75 | } |
76 | |
77 | bool WKRenderLayerIsClipping(WKRenderLayerRef renderLayerRef) |
78 | { |
79 | return WebKit::toImpl(renderLayerRef)->isClipping(); |
80 | } |
81 | |
82 | bool WKRenderLayerIsClipped(WKRenderLayerRef renderLayerRef) |
83 | { |
84 | return WebKit::toImpl(renderLayerRef)->isClipped(); |
85 | } |
86 | |
87 | bool WKRenderLayerIsReflection(WKRenderLayerRef renderLayerRef) |
88 | { |
89 | return WebKit::toImpl(renderLayerRef)->isReflection(); |
90 | } |
91 | |
92 | WKCompositingLayerType WKRenderLayerGetCompositingLayerType(WKRenderLayerRef renderLayerRef) |
93 | { |
94 | switch (WebKit::toImpl(renderLayerRef)->compositingLayerType()) { |
95 | case WebKit::WebRenderLayer::None: |
96 | return kWKCompositingLayerTypeNone; |
97 | case WebKit::WebRenderLayer::Normal: |
98 | return kWKCompositingLayerTypeNormal; |
99 | case WebKit::WebRenderLayer::Tiled: |
100 | return kWKCompositingLayerTypeTiled; |
101 | case WebKit::WebRenderLayer::Media: |
102 | return kWKCompositingLayerTypeMedia; |
103 | case WebKit::WebRenderLayer::Container: |
104 | return kWKCompositingLayerTypeContainer; |
105 | } |
106 | |
107 | ASSERT_NOT_REACHED(); |
108 | return kWKCompositingLayerTypeNone; |
109 | } |
110 | |
111 | WK_EXPORT double WKRenderLayerGetBackingStoreMemoryEstimate(WKRenderLayerRef renderLayerRef) |
112 | { |
113 | return WebKit::toImpl(renderLayerRef)->backingStoreMemoryEstimate(); |
114 | } |
115 | |
116 | WKArrayRef WKRenderLayerGetNegativeZOrderList(WKRenderLayerRef renderLayerRef) |
117 | { |
118 | return WebKit::toAPI(WebKit::toImpl(renderLayerRef)->negativeZOrderList()); |
119 | } |
120 | |
121 | WKArrayRef WKRenderLayerGetNormalFlowList(WKRenderLayerRef renderLayerRef) |
122 | { |
123 | return WebKit::toAPI(WebKit::toImpl(renderLayerRef)->normalFlowList()); |
124 | } |
125 | |
126 | WKArrayRef WKRenderLayerGetPositiveZOrderList(WKRenderLayerRef renderLayerRef) |
127 | { |
128 | return WebKit::toAPI(WebKit::toImpl(renderLayerRef)->positiveZOrderList()); |
129 | } |
130 | |
131 | WKRenderLayerRef WKRenderLayerGetFrameContentsLayer(WKRenderLayerRef renderLayerRef) |
132 | { |
133 | return WebKit::toAPI(WebKit::toImpl(renderLayerRef)->frameContentsLayer()); |
134 | } |
135 | |