Home | History | Annotate | Download | only in platform
      1 /*
      2  * Copyright (c) 2008, 2009, Google Inc. All rights reserved.
      3  *
      4  * Redistribution and use in source and binary forms, with or without
      5  * modification, are permitted provided that the following conditions are
      6  * met:
      7  *
      8  *     * Redistributions of source code must retain the above copyright
      9  * notice, this list of conditions and the following disclaimer.
     10  *     * Redistributions in binary form must reproduce the above
     11  * copyright notice, this list of conditions and the following disclaimer
     12  * in the documentation and/or other materials provided with the
     13  * distribution.
     14  *     * Neither the name of Google Inc. nor the names of its
     15  * contributors may be used to endorse or promote products derived from
     16  * this software without specific prior written permission.
     17  *
     18  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
     19  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
     20  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
     21  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
     22  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
     23  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
     24  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
     25  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
     26  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
     27  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
     28  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
     29  */
     30 
     31 #include "config.h"
     32 #include "platform/PlatformScreen.h"
     33 
     34 #include "platform/HostWindow.h"
     35 #include "platform/Widget.h"
     36 #include "public/platform/Platform.h"
     37 #include "public/platform/WebScreenInfo.h"
     38 
     39 namespace WebCore {
     40 
     41 static HostWindow* toHostWindow(Widget* widget)
     42 {
     43     if (!widget)
     44         return 0;
     45     Widget* root = widget->root();
     46     if (!root)
     47         return 0;
     48     return root->hostWindow();
     49 }
     50 
     51 int screenDepth(Widget* widget)
     52 {
     53     HostWindow* hostWindow = toHostWindow(widget);
     54     if (!hostWindow)
     55         return 0;
     56     return hostWindow->screenInfo().depth;
     57 }
     58 
     59 int screenDepthPerComponent(Widget* widget)
     60 {
     61     HostWindow* hostWindow = toHostWindow(widget);
     62     if (!hostWindow)
     63         return 0;
     64     return hostWindow->screenInfo().depthPerComponent;
     65 }
     66 
     67 bool screenIsMonochrome(Widget* widget)
     68 {
     69     HostWindow* hostWindow = toHostWindow(widget);
     70     if (!hostWindow)
     71         return false;
     72     return hostWindow->screenInfo().isMonochrome;
     73 }
     74 
     75 FloatRect screenRect(Widget* widget)
     76 {
     77     HostWindow* hostWindow = toHostWindow(widget);
     78     if (!hostWindow)
     79         return FloatRect();
     80     return IntRect(hostWindow->screenInfo().rect);
     81 }
     82 
     83 FloatRect screenAvailableRect(Widget* widget)
     84 {
     85     HostWindow* hostWindow = toHostWindow(widget);
     86     if (!hostWindow)
     87         return FloatRect();
     88     return IntRect(hostWindow->screenInfo().availableRect);
     89 }
     90 
     91 uint16_t screenOrientationAngle(Widget* widget)
     92 {
     93     HostWindow* hostWindow = toHostWindow(widget);
     94     if (!hostWindow)
     95         return 0;
     96     return hostWindow->screenInfo().orientationAngle;
     97 }
     98 
     99 blink::WebScreenOrientationType screenOrientationType(Widget* widget)
    100 {
    101     HostWindow* hostWindow = toHostWindow(widget);
    102     if (!hostWindow)
    103         return blink::WebScreenOrientationUndefined;
    104     return hostWindow->screenInfo().orientationType;
    105 }
    106 
    107 void screenColorProfile(ColorProfile& toProfile)
    108 {
    109     blink::WebVector<char> profile;
    110     blink::Platform::current()->screenColorProfile(&profile);
    111     toProfile.append(profile.data(), profile.size());
    112 }
    113 
    114 } // namespace WebCore
    115