Merge "fix: use EINA_* booleans instread of TRUE/FALSE" into tizen
[platform/framework/web/wrt.git] / src / view / webkit / view_logic_orientation_support.cpp
1 /*
2  * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
3  *
4  *    Licensed under the Apache License, Version 2.0 (the "License");
5  *    you may not use this file except in compliance with the License.
6  *    You may obtain a copy of the License at
7  *
8  *        http://www.apache.org/licenses/LICENSE-2.0
9  *
10  *    Unless required by applicable law or agreed to in writing, software
11  *    distributed under the License is distributed on an "AS IS" BASIS,
12  *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  *    See the License for the specific language governing permissions and
14  *    limitations under the License.
15  */
16 /*
17  * @file       view_logic_orientation_support.cpp
18  * @author     Jihoon Chung (jihoon.chung@samsung.com)
19  * @version    1.0
20  */
21
22  #include "view_logic_orientation_support.h"
23
24 #include <dpl/log/log.h>
25 #include <widget_data_types.h>
26
27 #include <EWebKit2.h>
28
29 namespace ViewModule {
30
31 int OrientationSupport::getWinOrientationAngle(int ewkOrientation)
32 {
33     int angle;
34     if (ewkOrientation & EWK_SCREEN_ORIENTATION_PORTRAIT_PRIMARY) {
35         angle = OrientationAngle::Window::Portrait::PRIMARY;
36     } else if (ewkOrientation & EWK_SCREEN_ORIENTATION_LANDSCAPE_PRIMARY) {
37         angle = OrientationAngle::Window::Landscape::PRIMARY;
38     } else if (ewkOrientation & EWK_SCREEN_ORIENTATION_PORTRAIT_SECONDARY) {
39         angle = OrientationAngle::Window::Portrait::SECONDARY;
40     } else if (ewkOrientation & EWK_SCREEN_ORIENTATION_LANDSCAPE_SECONDARY) {
41         angle = OrientationAngle::Window::Landscape::SECONDARY;
42     } else {
43         LogDebug("Wrong orientation value is passed");
44         Assert(false);
45     }
46     return angle;
47 }
48
49 int OrientationSupport::getW3COrientationAngle(int ewkOrientation)
50 {
51     int angle;
52     if (ewkOrientation & EWK_SCREEN_ORIENTATION_PORTRAIT_PRIMARY) {
53         angle = OrientationAngle::W3C::Portrait::PRIMARY;
54     } else if (ewkOrientation & EWK_SCREEN_ORIENTATION_LANDSCAPE_PRIMARY) {
55         angle = OrientationAngle::W3C::Landscape::PRIMARY;
56     } else if (ewkOrientation & EWK_SCREEN_ORIENTATION_PORTRAIT_SECONDARY) {
57         angle = OrientationAngle::W3C::Portrait::SECONDARY;
58     } else if (ewkOrientation & EWK_SCREEN_ORIENTATION_LANDSCAPE_SECONDARY) {
59         angle = OrientationAngle::W3C::Landscape::SECONDARY;
60     } else {
61         LogDebug("Wrong orientation value is passed");
62         Assert(false);
63     }
64     return angle;
65 }
66
67 void OrientationSupport::setEwkOrientation(Evas_Object* ewk,
68                                            int angle)
69 {
70     LogDebug("setOrientation called");
71     ewk_view_orientation_send(ewk, angle);
72 }
73 } // ViewModule