Abstract GoogleURLTracker & google_util Profile dependencies
[chromium-blink-merge.git] / ppapi / shared_impl / ppb_view_shared.cc
blobfc19a461f16a207c00768765fe4490ff5d7f187f
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"
7 namespace {
9 bool IsRectNonempty(const PP_Rect& rect) {
10 return rect.size.width > 0 && rect.size.height > 0;
13 } // namespace
15 namespace ppapi {
17 ViewData::ViewData() {
18 // Assume POD.
19 memset(this, 0, sizeof(ViewData));
21 device_scale = 1.0f;
22 css_scale = 1.0f;
25 ViewData::~ViewData() {}
27 bool ViewData::Equals(const ViewData& other) const {
28 return rect.point.x == other.rect.point.x &&
29 rect.point.y == other.rect.point.y &&
30 rect.size.width == other.rect.size.width &&
31 rect.size.height == other.rect.size.height &&
32 is_fullscreen == other.is_fullscreen &&
33 is_page_visible == other.is_page_visible &&
34 clip_rect.point.x == other.clip_rect.point.x &&
35 clip_rect.point.y == other.clip_rect.point.y &&
36 clip_rect.size.width == other.clip_rect.size.width &&
37 clip_rect.size.height == other.clip_rect.size.height &&
38 device_scale == other.device_scale && css_scale == other.css_scale;
41 PPB_View_Shared::PPB_View_Shared(ResourceObjectType type,
42 PP_Instance instance,
43 const ViewData& data)
44 : Resource(type, instance), data_(data) {}
46 PPB_View_Shared::~PPB_View_Shared() {}
48 thunk::PPB_View_API* PPB_View_Shared::AsPPB_View_API() { return this; }
50 const ViewData& PPB_View_Shared::GetData() const { return data_; }
52 PP_Bool PPB_View_Shared::GetRect(PP_Rect* viewport) const {
53 if (!viewport)
54 return PP_FALSE;
55 *viewport = data_.rect;
56 return PP_TRUE;
59 PP_Bool PPB_View_Shared::IsFullscreen() const {
60 return PP_FromBool(data_.is_fullscreen);
63 PP_Bool PPB_View_Shared::IsVisible() const {
64 return PP_FromBool(data_.is_page_visible && IsRectNonempty(data_.clip_rect));
67 PP_Bool PPB_View_Shared::IsPageVisible() const {
68 return PP_FromBool(data_.is_page_visible);
71 PP_Bool PPB_View_Shared::GetClipRect(PP_Rect* clip) const {
72 if (!clip)
73 return PP_FALSE;
74 *clip = data_.clip_rect;
75 return PP_TRUE;
78 float PPB_View_Shared::GetDeviceScale() const { return data_.device_scale; }
80 float PPB_View_Shared::GetCSSScale() const { return data_.css_scale; }
82 } // namespace ppapi