1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include "ppapi/cpp/view.h"
7 #include "ppapi/c/ppb_view.h"
8 #include "ppapi/cpp/module_impl.h"
14 template <> const char* interface_name
<PPB_View_1_0
>() {
15 return PPB_VIEW_INTERFACE_1_0
;
18 template <> const char* interface_name
<PPB_View_1_1
>() {
19 return PPB_VIEW_INTERFACE_1_1
;
22 template <> const char* interface_name
<PPB_View_1_2
>() {
23 return PPB_VIEW_INTERFACE_1_2
;
28 View::View() : Resource() {
31 View::View(PP_Resource view_resource
) : Resource(view_resource
) {
34 Rect
View::GetRect() const {
36 if (has_interface
<PPB_View_1_2
>()) {
37 if (PP_ToBool(get_interface
<PPB_View_1_2
>()->GetRect(pp_resource(), &out
)))
39 } else if (has_interface
<PPB_View_1_1
>()) {
40 if (PP_ToBool(get_interface
<PPB_View_1_1
>()->GetRect(pp_resource(), &out
)))
42 } else if (has_interface
<PPB_View_1_0
>()) {
43 if (PP_ToBool(get_interface
<PPB_View_1_0
>()->GetRect(pp_resource(), &out
)))
49 bool View::IsFullscreen() const {
50 if (has_interface
<PPB_View_1_2
>()) {
51 return PP_ToBool(get_interface
<PPB_View_1_2
>()->IsFullscreen(
53 } else if (has_interface
<PPB_View_1_1
>()) {
54 return PP_ToBool(get_interface
<PPB_View_1_1
>()->IsFullscreen(
56 } else if (has_interface
<PPB_View_1_0
>()) {
57 return PP_ToBool(get_interface
<PPB_View_1_0
>()->IsFullscreen(
63 bool View::IsVisible() const {
64 if (has_interface
<PPB_View_1_2
>())
65 return PP_ToBool(get_interface
<PPB_View_1_2
>()->IsVisible(pp_resource()));
66 else if (has_interface
<PPB_View_1_1
>())
67 return PP_ToBool(get_interface
<PPB_View_1_1
>()->IsVisible(pp_resource()));
68 else if (has_interface
<PPB_View_1_0
>())
69 return PP_ToBool(get_interface
<PPB_View_1_0
>()->IsVisible(pp_resource()));
73 bool View::IsPageVisible() const {
74 if (has_interface
<PPB_View_1_2
>()) {
75 return PP_ToBool(get_interface
<PPB_View_1_2
>()->IsPageVisible(
77 } else if (has_interface
<PPB_View_1_1
>()) {
78 return PP_ToBool(get_interface
<PPB_View_1_1
>()->IsPageVisible(
80 } else if (has_interface
<PPB_View_1_0
>()) {
81 return PP_ToBool(get_interface
<PPB_View_1_0
>()->IsPageVisible(
87 Rect
View::GetClipRect() const {
89 if (has_interface
<PPB_View_1_2
>()) {
90 if (PP_ToBool(get_interface
<PPB_View_1_2
>()->GetClipRect(pp_resource(),
93 } else if (has_interface
<PPB_View_1_1
>()) {
94 if (PP_ToBool(get_interface
<PPB_View_1_1
>()->GetClipRect(pp_resource(),
97 } else if (has_interface
<PPB_View_1_0
>()) {
98 if (PP_ToBool(get_interface
<PPB_View_1_0
>()->GetClipRect(pp_resource(),
105 float View::GetDeviceScale() const {
106 if (has_interface
<PPB_View_1_2
>())
107 return get_interface
<PPB_View_1_2
>()->GetDeviceScale(pp_resource());
108 else if (has_interface
<PPB_View_1_1
>())
109 return get_interface
<PPB_View_1_1
>()->GetDeviceScale(pp_resource());
113 float View::GetCSSScale() const {
114 if (has_interface
<PPB_View_1_2
>())
115 return get_interface
<PPB_View_1_2
>()->GetCSSScale(pp_resource());
116 else if (has_interface
<PPB_View_1_1
>())
117 return get_interface
<PPB_View_1_1
>()->GetCSSScale(pp_resource());
121 Point
View::GetScrollOffset() const {
123 if (has_interface
<PPB_View_1_2
>()) {
124 if (PP_ToBool(get_interface
<PPB_View_1_2
>()->GetScrollOffset(pp_resource(),