Chromium Code Reviews| OLD | NEW |
|---|---|
| 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/shared_impl/ppb_view_shared.h" | 5 #include "ppapi/shared_impl/ppb_view_shared.h" |
| 6 | 6 |
| 7 namespace { | |
| 8 bool IsRectVisible(const PP_Rect& rect) { | |
|
brettw
2013/02/12 18:48:02
Maybe IsRectNonempty would be a better name?
teravest
2013/02/12 19:01:41
Done.
| |
| 9 return rect.size.width > 0 && rect.size.height > 0; | |
| 10 } | |
| 11 } | |
|
brettw
2013/02/12 18:48:02
Style nit: needs " // namespace" and I'd put spac
teravest
2013/02/12 19:01:41
Done.
| |
| 12 | |
| 7 namespace ppapi { | 13 namespace ppapi { |
| 8 | 14 |
| 9 ViewData::ViewData() { | 15 ViewData::ViewData() { |
| 10 // Assume POD. | 16 // Assume POD. |
| 11 memset(this, 0, sizeof(ViewData)); | 17 memset(this, 0, sizeof(ViewData)); |
| 12 | 18 |
| 13 device_scale = 1.0f; | 19 device_scale = 1.0f; |
| 14 css_scale = 1.0f; | 20 css_scale = 1.0f; |
| 15 } | 21 } |
| 16 | 22 |
| (...skipping 26 matching lines...) Expand all Loading... | |
| 43 } | 49 } |
| 44 | 50 |
| 45 thunk::PPB_View_API* PPB_View_Shared::AsPPB_View_API() { | 51 thunk::PPB_View_API* PPB_View_Shared::AsPPB_View_API() { |
| 46 return this; | 52 return this; |
| 47 } | 53 } |
| 48 | 54 |
| 49 const ViewData& PPB_View_Shared::GetData() const { | 55 const ViewData& PPB_View_Shared::GetData() const { |
| 50 return data_; | 56 return data_; |
| 51 } | 57 } |
| 52 | 58 |
| 59 PP_Bool PPB_View_Shared::GetRect(PP_Rect* viewport) const { | |
| 60 if (!viewport) | |
| 61 return PP_FALSE; | |
| 62 *viewport = data_.rect; | |
| 63 return PP_TRUE; | |
| 64 } | |
| 65 | |
| 66 PP_Bool PPB_View_Shared::IsFullscreen() const { | |
| 67 return PP_FromBool(data_.is_fullscreen); | |
| 68 } | |
| 69 | |
| 70 PP_Bool PPB_View_Shared::IsVisible() const { | |
| 71 return PP_FromBool(data_.is_page_visible && IsRectVisible(data_.clip_rect)); | |
| 72 } | |
| 73 | |
| 74 PP_Bool PPB_View_Shared::IsPageVisible() const { | |
| 75 return PP_FromBool(data_.is_page_visible); | |
| 76 } | |
| 77 | |
| 78 PP_Bool PPB_View_Shared::GetClipRect(PP_Rect* clip) const { | |
| 79 if (!clip) | |
| 80 return PP_FALSE; | |
| 81 *clip = data_.clip_rect; | |
| 82 return PP_TRUE; | |
| 83 } | |
| 84 | |
| 85 float PPB_View_Shared::GetDeviceScale() const { | |
| 86 return data_.device_scale; | |
| 87 } | |
| 88 | |
| 89 float PPB_View_Shared::GetCSSScale() const { | |
| 90 return data_.css_scale; | |
| 91 } | |
| 92 | |
| 53 } // namespace ppapi | 93 } // namespace ppapi |
| OLD | NEW |