| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "webkit/plugins/ppapi/ppapi_plugin_instance.h" | 5 #include "webkit/plugins/ppapi/ppapi_plugin_instance.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/debug/trace_event.h" | 8 #include "base/debug/trace_event.h" |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "base/memory/linked_ptr.h" | 10 #include "base/memory/linked_ptr.h" |
| (...skipping 1828 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1839 uint32_t event_classes) { | 1839 uint32_t event_classes) { |
| 1840 input_event_mask_ &= ~(event_classes); | 1840 input_event_mask_ &= ~(event_classes); |
| 1841 filtered_input_event_mask_ &= ~(event_classes); | 1841 filtered_input_event_mask_ &= ~(event_classes); |
| 1842 } | 1842 } |
| 1843 | 1843 |
| 1844 void PluginInstance::ZoomChanged(PP_Instance instance, double factor) { | 1844 void PluginInstance::ZoomChanged(PP_Instance instance, double factor) { |
| 1845 // We only want to tell the page to change its zoom if the whole page is the | 1845 // We only want to tell the page to change its zoom if the whole page is the |
| 1846 // plugin. If we're in an iframe, then don't do anything. | 1846 // plugin. If we're in an iframe, then don't do anything. |
| 1847 if (!IsFullPagePlugin()) | 1847 if (!IsFullPagePlugin()) |
| 1848 return; | 1848 return; |
| 1849 | 1849 container()->zoomLevelChanged(WebView::zoomFactorToZoomLevel(factor)); |
| 1850 double zoom_level = WebView::zoomFactorToZoomLevel(factor); | |
| 1851 // The conversino from zoom level to factor, and back, can introduce rounding | |
| 1852 // errors. i.e. WebKit originally tells us 3.0, but by the time we tell the | |
| 1853 // plugin and it tells us back, the level becomes 3.000000000004. Need to | |
| 1854 // round or else otherwise if the user zooms out, it will go to 3.0 instead of | |
| 1855 // 2.0. | |
| 1856 int rounded = | |
| 1857 static_cast<int>(zoom_level + (zoom_level > 0 ? 0.001 : -0.001)); | |
| 1858 if (abs(rounded - zoom_level) < 0.001) | |
| 1859 zoom_level = rounded; | |
| 1860 container()->zoomLevelChanged(zoom_level); | |
| 1861 } | 1850 } |
| 1862 | 1851 |
| 1863 void PluginInstance::ZoomLimitsChanged(PP_Instance instance, | 1852 void PluginInstance::ZoomLimitsChanged(PP_Instance instance, |
| 1864 double minimum_factor, | 1853 double minimum_factor, |
| 1865 double maximium_factor) { | 1854 double maximium_factor) { |
| 1866 if (minimum_factor > maximium_factor) { | 1855 if (minimum_factor > maximium_factor) { |
| 1867 NOTREACHED(); | 1856 NOTREACHED(); |
| 1868 return; | 1857 return; |
| 1869 } | 1858 } |
| 1870 delegate()->ZoomLimitsChanged(minimum_factor, maximium_factor); | 1859 delegate()->ZoomLimitsChanged(minimum_factor, maximium_factor); |
| (...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2025 screen_size_for_fullscreen_ = gfx::Size(); | 2014 screen_size_for_fullscreen_ = gfx::Size(); |
| 2026 WebElement element = container_->element(); | 2015 WebElement element = container_->element(); |
| 2027 element.setAttribute(WebString::fromUTF8(kWidth), width_before_fullscreen_); | 2016 element.setAttribute(WebString::fromUTF8(kWidth), width_before_fullscreen_); |
| 2028 element.setAttribute(WebString::fromUTF8(kHeight), height_before_fullscreen_); | 2017 element.setAttribute(WebString::fromUTF8(kHeight), height_before_fullscreen_); |
| 2029 element.setAttribute(WebString::fromUTF8(kBorder), border_before_fullscreen_); | 2018 element.setAttribute(WebString::fromUTF8(kBorder), border_before_fullscreen_); |
| 2030 element.setAttribute(WebString::fromUTF8(kStyle), style_before_fullscreen_); | 2019 element.setAttribute(WebString::fromUTF8(kStyle), style_before_fullscreen_); |
| 2031 } | 2020 } |
| 2032 | 2021 |
| 2033 } // namespace ppapi | 2022 } // namespace ppapi |
| 2034 } // namespace webkit | 2023 } // namespace webkit |
| OLD | NEW |