| 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 28 matching lines...) Expand all Loading... |
| 39 | 39 |
| 40 namespace blink { | 40 namespace blink { |
| 41 | 41 |
| 42 Screen::Screen(LocalFrame* frame) | 42 Screen::Screen(LocalFrame* frame) |
| 43 : DOMWindowProperty(frame) | 43 : DOMWindowProperty(frame) |
| 44 { | 44 { |
| 45 } | 45 } |
| 46 | 46 |
| 47 int Screen::height() const | 47 int Screen::height() const |
| 48 { | 48 { |
| 49 if (!m_frame) | 49 if (!frame()) |
| 50 return 0; | 50 return 0; |
| 51 FrameHost* host = m_frame->host(); | 51 FrameHost* host = frame()->host(); |
| 52 if (!host) | 52 if (!host) |
| 53 return 0; | 53 return 0; |
| 54 if (host->settings().reportScreenSizeInPhysicalPixelsQuirk()) { | 54 if (host->settings().reportScreenSizeInPhysicalPixelsQuirk()) { |
| 55 WebScreenInfo screenInfo = host->chromeClient().screenInfo(); | 55 WebScreenInfo screenInfo = host->chromeClient().screenInfo(); |
| 56 return lroundf(screenInfo.rect.height * screenInfo.deviceScaleFactor); | 56 return lroundf(screenInfo.rect.height * screenInfo.deviceScaleFactor); |
| 57 } | 57 } |
| 58 return host->chromeClient().screenInfo().rect.height; | 58 return host->chromeClient().screenInfo().rect.height; |
| 59 } | 59 } |
| 60 | 60 |
| 61 int Screen::width() const | 61 int Screen::width() const |
| 62 { | 62 { |
| 63 if (!m_frame) | 63 if (!frame()) |
| 64 return 0; | 64 return 0; |
| 65 FrameHost* host = m_frame->host(); | 65 FrameHost* host = frame()->host(); |
| 66 if (!host) | 66 if (!host) |
| 67 return 0; | 67 return 0; |
| 68 if (host->settings().reportScreenSizeInPhysicalPixelsQuirk()) { | 68 if (host->settings().reportScreenSizeInPhysicalPixelsQuirk()) { |
| 69 WebScreenInfo screenInfo = host->chromeClient().screenInfo(); | 69 WebScreenInfo screenInfo = host->chromeClient().screenInfo(); |
| 70 return lroundf(screenInfo.rect.width * screenInfo.deviceScaleFactor); | 70 return lroundf(screenInfo.rect.width * screenInfo.deviceScaleFactor); |
| 71 } | 71 } |
| 72 return host->chromeClient().screenInfo().rect.width; | 72 return host->chromeClient().screenInfo().rect.width; |
| 73 } | 73 } |
| 74 | 74 |
| 75 unsigned Screen::colorDepth() const | 75 unsigned Screen::colorDepth() const |
| 76 { | 76 { |
| 77 if (!m_frame || !m_frame->host()) | 77 if (!frame() || !frame()->host()) |
| 78 return 0; | 78 return 0; |
| 79 return static_cast<unsigned>(m_frame->host()->chromeClient().screenInfo().de
pth); | 79 return static_cast<unsigned>(frame()->host()->chromeClient().screenInfo().de
pth); |
| 80 } | 80 } |
| 81 | 81 |
| 82 unsigned Screen::pixelDepth() const | 82 unsigned Screen::pixelDepth() const |
| 83 { | 83 { |
| 84 if (!m_frame) | 84 if (!frame()) |
| 85 return 0; | 85 return 0; |
| 86 return static_cast<unsigned>(m_frame->host()->chromeClient().screenInfo().de
pth); | 86 return static_cast<unsigned>(frame()->host()->chromeClient().screenInfo().de
pth); |
| 87 } | 87 } |
| 88 | 88 |
| 89 int Screen::availLeft() const | 89 int Screen::availLeft() const |
| 90 { | 90 { |
| 91 if (!m_frame) | 91 if (!frame()) |
| 92 return 0; | 92 return 0; |
| 93 FrameHost* host = m_frame->host(); | 93 FrameHost* host = frame()->host(); |
| 94 if (!host) | 94 if (!host) |
| 95 return 0; | 95 return 0; |
| 96 if (host->settings().reportScreenSizeInPhysicalPixelsQuirk()) { | 96 if (host->settings().reportScreenSizeInPhysicalPixelsQuirk()) { |
| 97 WebScreenInfo screenInfo = host->chromeClient().screenInfo(); | 97 WebScreenInfo screenInfo = host->chromeClient().screenInfo(); |
| 98 return lroundf(screenInfo.availableRect.x * screenInfo.deviceScaleFactor
); | 98 return lroundf(screenInfo.availableRect.x * screenInfo.deviceScaleFactor
); |
| 99 } | 99 } |
| 100 return static_cast<int>(host->chromeClient().screenInfo().availableRect.x); | 100 return static_cast<int>(host->chromeClient().screenInfo().availableRect.x); |
| 101 } | 101 } |
| 102 | 102 |
| 103 int Screen::availTop() const | 103 int Screen::availTop() const |
| 104 { | 104 { |
| 105 if (!m_frame) | 105 if (!frame()) |
| 106 return 0; | 106 return 0; |
| 107 FrameHost* host = m_frame->host(); | 107 FrameHost* host = frame()->host(); |
| 108 if (!host) | 108 if (!host) |
| 109 return 0; | 109 return 0; |
| 110 if (host->settings().reportScreenSizeInPhysicalPixelsQuirk()) { | 110 if (host->settings().reportScreenSizeInPhysicalPixelsQuirk()) { |
| 111 WebScreenInfo screenInfo = host->chromeClient().screenInfo(); | 111 WebScreenInfo screenInfo = host->chromeClient().screenInfo(); |
| 112 return lroundf(screenInfo.availableRect.y * screenInfo.deviceScaleFactor
); | 112 return lroundf(screenInfo.availableRect.y * screenInfo.deviceScaleFactor
); |
| 113 } | 113 } |
| 114 return static_cast<int>(host->chromeClient().screenInfo().availableRect.y); | 114 return static_cast<int>(host->chromeClient().screenInfo().availableRect.y); |
| 115 } | 115 } |
| 116 | 116 |
| 117 int Screen::availHeight() const | 117 int Screen::availHeight() const |
| 118 { | 118 { |
| 119 if (!m_frame) | 119 if (!frame()) |
| 120 return 0; | 120 return 0; |
| 121 FrameHost* host = m_frame->host(); | 121 FrameHost* host = frame()->host(); |
| 122 if (!host) | 122 if (!host) |
| 123 return 0; | 123 return 0; |
| 124 if (host->settings().reportScreenSizeInPhysicalPixelsQuirk()) { | 124 if (host->settings().reportScreenSizeInPhysicalPixelsQuirk()) { |
| 125 WebScreenInfo screenInfo = host->chromeClient().screenInfo(); | 125 WebScreenInfo screenInfo = host->chromeClient().screenInfo(); |
| 126 return lroundf(screenInfo.availableRect.height * screenInfo.deviceScaleF
actor); | 126 return lroundf(screenInfo.availableRect.height * screenInfo.deviceScaleF
actor); |
| 127 } | 127 } |
| 128 return host->chromeClient().screenInfo().availableRect.height; | 128 return host->chromeClient().screenInfo().availableRect.height; |
| 129 } | 129 } |
| 130 | 130 |
| 131 int Screen::availWidth() const | 131 int Screen::availWidth() const |
| 132 { | 132 { |
| 133 if (!m_frame) | 133 if (!frame()) |
| 134 return 0; | 134 return 0; |
| 135 FrameHost* host = m_frame->host(); | 135 FrameHost* host = frame()->host(); |
| 136 if (!host) | 136 if (!host) |
| 137 return 0; | 137 return 0; |
| 138 if (host->settings().reportScreenSizeInPhysicalPixelsQuirk()) { | 138 if (host->settings().reportScreenSizeInPhysicalPixelsQuirk()) { |
| 139 WebScreenInfo screenInfo = host->chromeClient().screenInfo(); | 139 WebScreenInfo screenInfo = host->chromeClient().screenInfo(); |
| 140 return lroundf(screenInfo.availableRect.width * screenInfo.deviceScaleFa
ctor); | 140 return lroundf(screenInfo.availableRect.width * screenInfo.deviceScaleFa
ctor); |
| 141 } | 141 } |
| 142 return host->chromeClient().screenInfo().availableRect.width; | 142 return host->chromeClient().screenInfo().availableRect.width; |
| 143 } | 143 } |
| 144 | 144 |
| 145 DEFINE_TRACE(Screen) | 145 DEFINE_TRACE(Screen) |
| 146 { | 146 { |
| 147 DOMWindowProperty::trace(visitor); | 147 DOMWindowProperty::trace(visitor); |
| 148 Supplementable<Screen>::trace(visitor); | 148 Supplementable<Screen>::trace(visitor); |
| 149 } | 149 } |
| 150 | 150 |
| 151 } // namespace blink | 151 } // namespace blink |
| OLD | NEW |