| 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" | |
| 39 #include "platform/PlatformScreen.h" | 38 #include "platform/PlatformScreen.h" |
| 40 | 39 |
| 41 namespace blink { | 40 namespace blink { |
| 42 | 41 |
| 43 Screen::Screen(LocalFrame* frame) | 42 Screen::Screen(LocalFrame* frame) |
| 44 : DOMWindowProperty(frame) | 43 : DOMWindowProperty(frame) |
| 45 { | 44 { |
| 46 } | 45 } |
| 47 | 46 |
| 48 unsigned Screen::height() const | 47 unsigned Screen::height() const |
| (...skipping 28 matching lines...) Expand all Loading... |
| 77 if (!m_frame) | 76 if (!m_frame) |
| 78 return 0; | 77 return 0; |
| 79 return static_cast<unsigned>(screenDepth(m_frame->view())); | 78 return static_cast<unsigned>(screenDepth(m_frame->view())); |
| 80 } | 79 } |
| 81 | 80 |
| 82 int Screen::availLeft() const | 81 int Screen::availLeft() const |
| 83 { | 82 { |
| 84 if (!m_frame) | 83 if (!m_frame) |
| 85 return 0; | 84 return 0; |
| 86 FrameHost* host = m_frame->host(); | 85 FrameHost* host = m_frame->host(); |
| 87 if (!host) | 86 if (host && host->settings().reportScreenSizeInPhysicalPixelsQuirk()) |
| 88 return 0; | 87 return lroundf(screenAvailableRect(m_frame->view()).x() * host->deviceSc
aleFactor()); |
| 89 if (host->settings().reportScreenSizeInPhysicalPixelsQuirk()) | 88 return static_cast<int>(screenAvailableRect(m_frame->view()).x()); |
| 90 return lroundf(screenAvailableRect(host->chrome()).x() * host->deviceSca
leFactor()); | |
| 91 return static_cast<int>(screenAvailableRect(host->chrome()).x()); | |
| 92 } | 89 } |
| 93 | 90 |
| 94 int Screen::availTop() const | 91 int Screen::availTop() const |
| 95 { | 92 { |
| 96 if (!m_frame) | 93 if (!m_frame) |
| 97 return 0; | 94 return 0; |
| 98 FrameHost* host = m_frame->host(); | 95 FrameHost* host = m_frame->host(); |
| 99 if (!host) | 96 if (host && host->settings().reportScreenSizeInPhysicalPixelsQuirk()) |
| 100 return 0; | 97 return lroundf(screenAvailableRect(m_frame->view()).y() * host->deviceSc
aleFactor()); |
| 101 if (host->settings().reportScreenSizeInPhysicalPixelsQuirk()) | 98 return static_cast<int>(screenAvailableRect(m_frame->view()).y()); |
| 102 return lroundf(screenAvailableRect(host->chrome()).y() * host->deviceSca
leFactor()); | |
| 103 return static_cast<int>(screenAvailableRect(host->chrome()).y()); | |
| 104 } | 99 } |
| 105 | 100 |
| 106 unsigned Screen::availHeight() const | 101 unsigned Screen::availHeight() const |
| 107 { | 102 { |
| 108 if (!m_frame) | 103 if (!m_frame) |
| 109 return 0; | 104 return 0; |
| 110 FrameHost* host = m_frame->host(); | 105 FrameHost* host = m_frame->host(); |
| 111 if (!host) | 106 if (host && host->settings().reportScreenSizeInPhysicalPixelsQuirk()) |
| 112 return 0; | 107 return lroundf(screenAvailableRect(m_frame->view()).height() * host->dev
iceScaleFactor()); |
| 113 if (host->settings().reportScreenSizeInPhysicalPixelsQuirk()) | 108 return static_cast<unsigned>(screenAvailableRect(m_frame->view()).height()); |
| 114 return lroundf(screenAvailableRect(host->chrome()).height() * host->devi
ceScaleFactor()); | |
| 115 return static_cast<unsigned>(screenAvailableRect(host->chrome()).height()); | |
| 116 } | 109 } |
| 117 | 110 |
| 118 unsigned Screen::availWidth() const | 111 unsigned Screen::availWidth() const |
| 119 { | 112 { |
| 120 if (!m_frame) | 113 if (!m_frame) |
| 121 return 0; | 114 return 0; |
| 122 FrameHost* host = m_frame->host(); | 115 FrameHost* host = m_frame->host(); |
| 123 if (!host) | 116 if (host && host->settings().reportScreenSizeInPhysicalPixelsQuirk()) |
| 124 return 0; | 117 return lroundf(screenAvailableRect(m_frame->view()).width() * host->devi
ceScaleFactor()); |
| 125 if (host->settings().reportScreenSizeInPhysicalPixelsQuirk()) | 118 return static_cast<unsigned>(screenAvailableRect(m_frame->view()).width()); |
| 126 return lroundf(screenAvailableRect(host->chrome()).width() * host->devic
eScaleFactor()); | |
| 127 return static_cast<unsigned>(screenAvailableRect(host->chrome()).width()); | |
| 128 } | 119 } |
| 129 | 120 |
| 130 DEFINE_TRACE(Screen) | 121 DEFINE_TRACE(Screen) |
| 131 { | 122 { |
| 132 HeapSupplementable<Screen>::trace(visitor); | 123 HeapSupplementable<Screen>::trace(visitor); |
| 133 DOMWindowProperty::trace(visitor); | 124 DOMWindowProperty::trace(visitor); |
| 134 } | 125 } |
| 135 | 126 |
| 136 } // namespace blink | 127 } // namespace blink |
| OLD | NEW |