Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(165)

Side by Side Diff: ppapi/cpp/view.cc

Issue 329033003: Add GetScrollOffset function to PPB_View (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « ppapi/cpp/view.h ('k') | ppapi/native_client/src/untrusted/pnacl_irt_shim/pnacl_shim.c » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "ppapi/cpp/view.h" 5 #include "ppapi/cpp/view.h"
6 6
7 #include "ppapi/c/ppb_view.h" 7 #include "ppapi/c/ppb_view.h"
8 #include "ppapi/cpp/module_impl.h" 8 #include "ppapi/cpp/module_impl.h"
9 9
10 namespace pp { 10 namespace pp {
11 11
12 namespace { 12 namespace {
13 13
14 template <> const char* interface_name<PPB_View_1_0>() { 14 template <> const char* interface_name<PPB_View_1_0>() {
15 return PPB_VIEW_INTERFACE_1_0; 15 return PPB_VIEW_INTERFACE_1_0;
16 } 16 }
17 17
18 template <> const char* interface_name<PPB_View_1_1>() { 18 template <> const char* interface_name<PPB_View_1_1>() {
19 return PPB_VIEW_INTERFACE_1_1; 19 return PPB_VIEW_INTERFACE_1_1;
20 } 20 }
21 21
22 template <> const char* interface_name<PPB_View_1_2>() {
23 return PPB_VIEW_INTERFACE_1_2;
24 }
25
22 } // namespace 26 } // namespace
23 27
24 View::View() : Resource() { 28 View::View() : Resource() {
25 } 29 }
26 30
27 View::View(PP_Resource view_resource) : Resource(view_resource) { 31 View::View(PP_Resource view_resource) : Resource(view_resource) {
28 } 32 }
29 33
30 Rect View::GetRect() const { 34 Rect View::GetRect() const {
31 PP_Rect out; 35 PP_Rect out;
32 if (has_interface<PPB_View_1_1>()) { 36 if (has_interface<PPB_View_1_2>()) {
37 if (PP_ToBool(get_interface<PPB_View_1_2>()->GetRect(pp_resource(), &out)))
38 return Rect(out);
39 } else if (has_interface<PPB_View_1_1>()) {
33 if (PP_ToBool(get_interface<PPB_View_1_1>()->GetRect(pp_resource(), &out))) 40 if (PP_ToBool(get_interface<PPB_View_1_1>()->GetRect(pp_resource(), &out)))
34 return Rect(out); 41 return Rect(out);
35 } else if (has_interface<PPB_View_1_0>()) { 42 } else if (has_interface<PPB_View_1_0>()) {
36 if (PP_ToBool(get_interface<PPB_View_1_0>()->GetRect(pp_resource(), &out))) 43 if (PP_ToBool(get_interface<PPB_View_1_0>()->GetRect(pp_resource(), &out)))
37 return Rect(out); 44 return Rect(out);
38 } 45 }
39 return Rect(); 46 return Rect();
40 } 47 }
41 48
42 bool View::IsFullscreen() const { 49 bool View::IsFullscreen() const {
43 if (has_interface<PPB_View_1_1>()) { 50 if (has_interface<PPB_View_1_2>()) {
51 return PP_ToBool(get_interface<PPB_View_1_2>()->IsFullscreen(
52 pp_resource()));
53 } else if (has_interface<PPB_View_1_1>()) {
44 return PP_ToBool(get_interface<PPB_View_1_1>()->IsFullscreen( 54 return PP_ToBool(get_interface<PPB_View_1_1>()->IsFullscreen(
45 pp_resource())); 55 pp_resource()));
46 } else if (has_interface<PPB_View_1_0>()) { 56 } else if (has_interface<PPB_View_1_0>()) {
47 return PP_ToBool(get_interface<PPB_View_1_0>()->IsFullscreen( 57 return PP_ToBool(get_interface<PPB_View_1_0>()->IsFullscreen(
48 pp_resource())); 58 pp_resource()));
49 } 59 }
50 return false; 60 return false;
51 } 61 }
52 62
53 bool View::IsVisible() const { 63 bool View::IsVisible() const {
54 if (has_interface<PPB_View_1_1>()) 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>())
55 return PP_ToBool(get_interface<PPB_View_1_1>()->IsVisible(pp_resource())); 67 return PP_ToBool(get_interface<PPB_View_1_1>()->IsVisible(pp_resource()));
56 else if (has_interface<PPB_View_1_0>()) 68 else if (has_interface<PPB_View_1_0>())
57 return PP_ToBool(get_interface<PPB_View_1_0>()->IsVisible(pp_resource())); 69 return PP_ToBool(get_interface<PPB_View_1_0>()->IsVisible(pp_resource()));
58 return false; 70 return false;
59 } 71 }
60 72
61 bool View::IsPageVisible() const { 73 bool View::IsPageVisible() const {
62 if (has_interface<PPB_View_1_1>()) { 74 if (has_interface<PPB_View_1_2>()) {
75 return PP_ToBool(get_interface<PPB_View_1_2>()->IsPageVisible(
76 pp_resource()));
77 } else if (has_interface<PPB_View_1_1>()) {
63 return PP_ToBool(get_interface<PPB_View_1_1>()->IsPageVisible( 78 return PP_ToBool(get_interface<PPB_View_1_1>()->IsPageVisible(
64 pp_resource())); 79 pp_resource()));
65 } else if (has_interface<PPB_View_1_0>()) { 80 } else if (has_interface<PPB_View_1_0>()) {
66 return PP_ToBool(get_interface<PPB_View_1_0>()->IsPageVisible( 81 return PP_ToBool(get_interface<PPB_View_1_0>()->IsPageVisible(
67 pp_resource())); 82 pp_resource()));
68 } 83 }
69 return true; 84 return true;
70 } 85 }
71 86
72 Rect View::GetClipRect() const { 87 Rect View::GetClipRect() const {
73 PP_Rect out; 88 PP_Rect out;
74 if (has_interface<PPB_View_1_1>()) { 89 if (has_interface<PPB_View_1_2>()) {
90 if (PP_ToBool(get_interface<PPB_View_1_2>()->GetClipRect(pp_resource(),
91 &out)))
92 return Rect(out);
93 } else if (has_interface<PPB_View_1_1>()) {
75 if (PP_ToBool(get_interface<PPB_View_1_1>()->GetClipRect(pp_resource(), 94 if (PP_ToBool(get_interface<PPB_View_1_1>()->GetClipRect(pp_resource(),
76 &out))) 95 &out)))
77 return Rect(out); 96 return Rect(out);
78 } else if (has_interface<PPB_View_1_0>()) { 97 } else if (has_interface<PPB_View_1_0>()) {
79 if (PP_ToBool(get_interface<PPB_View_1_0>()->GetClipRect(pp_resource(), 98 if (PP_ToBool(get_interface<PPB_View_1_0>()->GetClipRect(pp_resource(),
80 &out))) 99 &out)))
81 return Rect(out); 100 return Rect(out);
82 } 101 }
83 return Rect(); 102 return Rect();
84 } 103 }
85 104
86 float View::GetDeviceScale() const { 105 float View::GetDeviceScale() const {
87 if (has_interface<PPB_View_1_1>()) 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>())
88 return get_interface<PPB_View_1_1>()->GetDeviceScale(pp_resource()); 109 return get_interface<PPB_View_1_1>()->GetDeviceScale(pp_resource());
89 return 1.0f; 110 return 1.0f;
90 } 111 }
91 112
92 float View::GetCSSScale() const { 113 float View::GetCSSScale() const {
93 if (has_interface<PPB_View_1_1>()) 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>())
94 return get_interface<PPB_View_1_1>()->GetCSSScale(pp_resource()); 117 return get_interface<PPB_View_1_1>()->GetCSSScale(pp_resource());
95 return 1.0f; 118 return 1.0f;
96 } 119 }
97 120
121 Point View::GetScrollOffset() const {
122 PP_Point out;
123 if (has_interface<PPB_View_1_2>()) {
124 if (PP_ToBool(get_interface<PPB_View_1_2>()->GetScrollOffset(pp_resource(),
125 &out))) {
126 return Point(out);
127 }
128 }
129 return Point();
130 }
131
98 } // namespace pp 132 } // namespace pp
OLDNEW
« no previous file with comments | « ppapi/cpp/view.h ('k') | ppapi/native_client/src/untrusted/pnacl_irt_shim/pnacl_shim.c » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698