| 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 #include "core/platform/graphics/FloatRect.h" | 39 #include "core/platform/graphics/FloatRect.h" |
| 40 | 40 |
| 41 namespace WebCore { | 41 namespace WebCore { |
| 42 | 42 |
| 43 Screen::Screen(Frame* frame) | 43 Screen::Screen(Frame* frame) |
| 44 : DOMWindowProperty(frame) | 44 : DOMWindowProperty(frame) |
| 45 { | 45 { |
| 46 ScriptWrappable::init(this); | 46 ScriptWrappable::init(this); |
| 47 } | 47 } |
| 48 | 48 |
| 49 unsigned Screen::horizontalDPI() const | |
| 50 { | |
| 51 if (!m_frame) | |
| 52 return 0; | |
| 53 | |
| 54 // Used by the testing system, can be set from internals. | |
| 55 IntSize override = m_frame->page()->settings()->resolutionOverride(); | |
| 56 if (!override.isEmpty()) | |
| 57 return override.width(); | |
| 58 | |
| 59 // The DPI is defined as dots per CSS inch and thus not device inch. | |
| 60 return m_frame->page()->deviceScaleFactor() * 96; | |
| 61 } | |
| 62 | |
| 63 unsigned Screen::verticalDPI() const | |
| 64 { | |
| 65 // The DPI is defined as dots per CSS inch and thus not device inch. | |
| 66 if (!m_frame) | |
| 67 return 0; | |
| 68 | |
| 69 // Used by the testing system, can be set from internals. | |
| 70 IntSize override = m_frame->page()->settings()->resolutionOverride(); | |
| 71 if (!override.isEmpty()) | |
| 72 return override.height(); | |
| 73 | |
| 74 // The DPI is defined as dots per CSS inch and thus not device inch. | |
| 75 return m_frame->page()->deviceScaleFactor() * 96; | |
| 76 } | |
| 77 | |
| 78 unsigned Screen::height() const | 49 unsigned Screen::height() const |
| 79 { | 50 { |
| 80 if (!m_frame) | 51 if (!m_frame) |
| 81 return 0; | 52 return 0; |
| 82 long height = static_cast<long>(screenRect(m_frame->view()).height()); | 53 long height = static_cast<long>(screenRect(m_frame->view()).height()); |
| 83 InspectorInstrumentation::applyScreenHeightOverride(m_frame, &height); | 54 InspectorInstrumentation::applyScreenHeightOverride(m_frame, &height); |
| 84 return static_cast<unsigned>(height); | 55 return static_cast<unsigned>(height); |
| 85 } | 56 } |
| 86 | 57 |
| 87 unsigned Screen::width() const | 58 unsigned Screen::width() const |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 129 } | 100 } |
| 130 | 101 |
| 131 unsigned Screen::availWidth() const | 102 unsigned Screen::availWidth() const |
| 132 { | 103 { |
| 133 if (!m_frame) | 104 if (!m_frame) |
| 134 return 0; | 105 return 0; |
| 135 return static_cast<unsigned>(screenAvailableRect(m_frame->view()).width()); | 106 return static_cast<unsigned>(screenAvailableRect(m_frame->view()).width()); |
| 136 } | 107 } |
| 137 | 108 |
| 138 } // namespace WebCore | 109 } // namespace WebCore |
| OLD | NEW |