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/shared_impl/ppb_view_shared.h"
9 bool IsRectNonempty(const PP_Rect
& rect
) {
10 return rect
.size
.width
> 0 && rect
.size
.height
> 0;
17 ViewData::ViewData() {
19 memset(this, 0, sizeof(ViewData
));
25 ViewData::~ViewData() {
28 bool ViewData::Equals(const ViewData
& other
) const {
29 return rect
.point
.x
== other
.rect
.point
.x
&&
30 rect
.point
.y
== other
.rect
.point
.y
&&
31 rect
.size
.width
== other
.rect
.size
.width
&&
32 rect
.size
.height
== other
.rect
.size
.height
&&
33 is_fullscreen
== other
.is_fullscreen
&&
34 is_page_visible
== other
.is_page_visible
&&
35 clip_rect
.point
.x
== other
.clip_rect
.point
.x
&&
36 clip_rect
.point
.y
== other
.clip_rect
.point
.y
&&
37 clip_rect
.size
.width
== other
.clip_rect
.size
.width
&&
38 clip_rect
.size
.height
== other
.clip_rect
.size
.height
&&
39 device_scale
== other
.device_scale
&&
40 css_scale
== other
.css_scale
;
43 PPB_View_Shared::PPB_View_Shared(ResourceObjectType type
,
46 : Resource(type
, instance
),
50 PPB_View_Shared::~PPB_View_Shared() {
53 thunk::PPB_View_API
* PPB_View_Shared::AsPPB_View_API() {
57 const ViewData
& PPB_View_Shared::GetData() const {
61 PP_Bool
PPB_View_Shared::GetRect(PP_Rect
* viewport
) const {
64 *viewport
= data_
.rect
;
68 PP_Bool
PPB_View_Shared::IsFullscreen() const {
69 return PP_FromBool(data_
.is_fullscreen
);
72 PP_Bool
PPB_View_Shared::IsVisible() const {
73 return PP_FromBool(data_
.is_page_visible
&& IsRectNonempty(data_
.clip_rect
));
76 PP_Bool
PPB_View_Shared::IsPageVisible() const {
77 return PP_FromBool(data_
.is_page_visible
);
80 PP_Bool
PPB_View_Shared::GetClipRect(PP_Rect
* clip
) const {
83 *clip
= data_
.clip_rect
;
87 float PPB_View_Shared::GetDeviceScale() const {
88 return data_
.device_scale
;
91 float PPB_View_Shared::GetCSSScale() const {
92 return data_
.css_scale
;