| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2007 Apple Inc. All rights reserved. | 2 * Copyright (C) 2007 Apple Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions | 5 * modification, are permitted provided that the following conditions |
| 6 * are met: | 6 * are met: |
| 7 * | 7 * |
| 8 * 1. Redistributions of source code must retain the above copyright | 8 * 1. Redistributions of source code must retain the above copyright |
| 9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
| 10 * 2. Redistributions in binary form must reproduce the above copyright | 10 * 2. Redistributions in binary form must reproduce the above copyright |
| (...skipping 17 matching lines...) Expand all Loading... |
| 28 | 28 |
| 29 | 29 |
| 30 #include "config.h" | 30 #include "config.h" |
| 31 #include "core/frame/Screen.h" | 31 #include "core/frame/Screen.h" |
| 32 | 32 |
| 33 #include "core/frame/FrameHost.h" | 33 #include "core/frame/FrameHost.h" |
| 34 #include "core/frame/FrameView.h" | 34 #include "core/frame/FrameView.h" |
| 35 #include "core/frame/LocalFrame.h" | 35 #include "core/frame/LocalFrame.h" |
| 36 #include "core/frame/Settings.h" | 36 #include "core/frame/Settings.h" |
| 37 #include "core/inspector/InspectorInstrumentation.h" | 37 #include "core/inspector/InspectorInstrumentation.h" |
| 38 #include "core/page/Chrome.h" |
| 38 #include "platform/PlatformScreen.h" | 39 #include "platform/PlatformScreen.h" |
| 39 | 40 |
| 40 namespace blink { | 41 namespace blink { |
| 41 | 42 |
| 42 Screen::Screen(LocalFrame* frame) | 43 Screen::Screen(LocalFrame* frame) |
| 43 : DOMWindowProperty(frame) | 44 : DOMWindowProperty(frame) |
| 44 { | 45 { |
| 45 } | 46 } |
| 46 | 47 |
| 47 unsigned Screen::height() const | 48 unsigned Screen::height() const |
| (...skipping 28 matching lines...) Expand all Loading... |
| 76 if (!m_frame) | 77 if (!m_frame) |
| 77 return 0; | 78 return 0; |
| 78 return static_cast<unsigned>(screenDepth(m_frame->view())); | 79 return static_cast<unsigned>(screenDepth(m_frame->view())); |
| 79 } | 80 } |
| 80 | 81 |
| 81 int Screen::availLeft() const | 82 int Screen::availLeft() const |
| 82 { | 83 { |
| 83 if (!m_frame) | 84 if (!m_frame) |
| 84 return 0; | 85 return 0; |
| 85 FrameHost* host = m_frame->host(); | 86 FrameHost* host = m_frame->host(); |
| 86 if (host && host->settings().reportScreenSizeInPhysicalPixelsQuirk()) | 87 if (!host) |
| 87 return lroundf(screenAvailableRect(m_frame->view()).x() * host->deviceSc
aleFactor()); | 88 return 0; |
| 88 return static_cast<int>(screenAvailableRect(m_frame->view()).x()); | 89 if (host->settings().reportScreenSizeInPhysicalPixelsQuirk()) |
| 90 return lroundf(screenAvailableRect(host->chrome()).x() * host->deviceSca
leFactor()); |
| 91 return static_cast<int>(screenAvailableRect(host->chrome()).x()); |
| 89 } | 92 } |
| 90 | 93 |
| 91 int Screen::availTop() const | 94 int Screen::availTop() const |
| 92 { | 95 { |
| 93 if (!m_frame) | 96 if (!m_frame) |
| 94 return 0; | 97 return 0; |
| 95 FrameHost* host = m_frame->host(); | 98 FrameHost* host = m_frame->host(); |
| 96 if (host && host->settings().reportScreenSizeInPhysicalPixelsQuirk()) | 99 if (!host) |
| 97 return lroundf(screenAvailableRect(m_frame->view()).y() * host->deviceSc
aleFactor()); | 100 return 0; |
| 98 return static_cast<int>(screenAvailableRect(m_frame->view()).y()); | 101 if (host->settings().reportScreenSizeInPhysicalPixelsQuirk()) |
| 102 return lroundf(screenAvailableRect(host->chrome()).y() * host->deviceSca
leFactor()); |
| 103 return static_cast<int>(screenAvailableRect(host->chrome()).y()); |
| 99 } | 104 } |
| 100 | 105 |
| 101 unsigned Screen::availHeight() const | 106 unsigned Screen::availHeight() const |
| 102 { | 107 { |
| 103 if (!m_frame) | 108 if (!m_frame) |
| 104 return 0; | 109 return 0; |
| 105 FrameHost* host = m_frame->host(); | 110 FrameHost* host = m_frame->host(); |
| 106 if (host && host->settings().reportScreenSizeInPhysicalPixelsQuirk()) | 111 if (!host) |
| 107 return lroundf(screenAvailableRect(m_frame->view()).height() * host->dev
iceScaleFactor()); | 112 return 0; |
| 108 return static_cast<unsigned>(screenAvailableRect(m_frame->view()).height()); | 113 if (host->settings().reportScreenSizeInPhysicalPixelsQuirk()) |
| 114 return lroundf(screenAvailableRect(host->chrome()).height() * host->devi
ceScaleFactor()); |
| 115 return static_cast<unsigned>(screenAvailableRect(host->chrome()).height()); |
| 109 } | 116 } |
| 110 | 117 |
| 111 unsigned Screen::availWidth() const | 118 unsigned Screen::availWidth() const |
| 112 { | 119 { |
| 113 if (!m_frame) | 120 if (!m_frame) |
| 114 return 0; | 121 return 0; |
| 115 FrameHost* host = m_frame->host(); | 122 FrameHost* host = m_frame->host(); |
| 116 if (host && host->settings().reportScreenSizeInPhysicalPixelsQuirk()) | 123 if (!host) |
| 117 return lroundf(screenAvailableRect(m_frame->view()).width() * host->devi
ceScaleFactor()); | 124 return 0; |
| 118 return static_cast<unsigned>(screenAvailableRect(m_frame->view()).width()); | 125 if (host->settings().reportScreenSizeInPhysicalPixelsQuirk()) |
| 126 return lroundf(screenAvailableRect(host->chrome()).width() * host->devic
eScaleFactor()); |
| 127 return static_cast<unsigned>(screenAvailableRect(host->chrome()).width()); |
| 119 } | 128 } |
| 120 | 129 |
| 121 DEFINE_TRACE(Screen) | 130 DEFINE_TRACE(Screen) |
| 122 { | 131 { |
| 123 HeapSupplementable<Screen>::trace(visitor); | 132 HeapSupplementable<Screen>::trace(visitor); |
| 124 DOMWindowProperty::trace(visitor); | 133 DOMWindowProperty::trace(visitor); |
| 125 } | 134 } |
| 126 | 135 |
| 127 } // namespace blink | 136 } // namespace blink |
| OLD | NEW |