Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 /* | 1 /* |
| 2 * Copyright (C) 2011, 2012 Google Inc. All rights reserved. | 2 * Copyright (C) 2011, 2012 Google 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 are | 5 * modification, are permitted provided that the following conditions are |
| 6 * met: | 6 * met: |
| 7 * | 7 * |
| 8 * * Redistributions of source code must retain the above copyright | 8 * * 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 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
| (...skipping 2126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2137 eventType, static_cast<const WebMouseEvent&>(inputEvent).clickCount) ; | 2137 eventType, static_cast<const WebMouseEvent&>(inputEvent).clickCount) ; |
| 2138 return true; | 2138 return true; |
| 2139 } | 2139 } |
| 2140 | 2140 |
| 2141 // FIXME: This should take in the intended frame, not the local frame root. | 2141 // FIXME: This should take in the intended frame, not the local frame root. |
| 2142 if (PageWidgetDelegate::handleInputEvent(*this, inputEvent, localFrameRootTe mporary()->frame())) | 2142 if (PageWidgetDelegate::handleInputEvent(*this, inputEvent, localFrameRootTe mporary()->frame())) |
| 2143 return true; | 2143 return true; |
| 2144 | 2144 |
| 2145 // Unhandled touchpad gesture pinch events synthesize mouse wheel events. | 2145 // Unhandled touchpad gesture pinch events synthesize mouse wheel events. |
| 2146 if (inputEvent.type == WebInputEvent::GesturePinchUpdate) { | 2146 if (inputEvent.type == WebInputEvent::GesturePinchUpdate) { |
| 2147 if (handleSyntheticWheelFromTouchpadPinchEvent(static_cast<const WebGest ureEvent&>(inputEvent))) | 2147 const WebGestureEvent& pinchEvent = static_cast<const WebGestureEvent&>( inputEvent); |
| 2148 // First, synthesize a Windows-like wheel event to send to any handlers that may exist. | |
| 2149 if (handleSyntheticWheelFromTouchpadPinchEvent(pinchEvent)) | |
| 2148 return true; | 2150 return true; |
| 2151 | |
| 2152 // If the event remains unhandled, use it pinch the viewport. | |
| 2153 const float magnifyDelta = pinchEvent.data.pinchUpdate.scale; | |
| 2154 const float oldPageScale = pageScaleFactor(); | |
| 2155 setPageScaleFactor(oldPageScale * magnifyDelta); | |
|
aelias_OOO_until_Jul13
2015/01/30 21:21:40
Please avoid this call to setPageScaleFactor, sinc
ccameron
2015/02/02 23:59:07
Done.
| |
| 2156 const float newPageScale = pageScaleFactor(); | |
| 2157 | |
| 2158 // Keep the center-of-pinch anchor specified by (x, y) in a stable | |
| 2159 // position over the course of the magnify. | |
| 2160 const FloatPoint anchor(pinchEvent.x, pinchEvent.y); | |
| 2161 FloatPoint anchorAtOldScale = anchor.scaledBy(1.f / oldPageScale); | |
| 2162 FloatPoint anchorAtNewScale = anchor.scaledBy(1.f / newPageScale); | |
| 2163 FloatSize anchorDelta = anchorAtOldScale - anchorAtNewScale; | |
| 2164 page()->frameHost().pinchViewport().move(FloatPoint(anchorDelta.width(), anchorDelta.height())); | |
| 2165 | |
| 2166 // TODO(ccameron): Always return that the event was handled. Once the pi nch-zoom content scale | |
| 2167 // handlers have been remove from content, this function may return fals e if the page scale does | |
| 2168 // not change. | |
| 2169 return true; | |
| 2149 } | 2170 } |
| 2150 | 2171 |
| 2151 return false; | 2172 return false; |
| 2152 } | 2173 } |
| 2153 | 2174 |
| 2154 void WebViewImpl::setCursorVisibilityState(bool isVisible) | 2175 void WebViewImpl::setCursorVisibilityState(bool isVisible) |
| 2155 { | 2176 { |
| 2156 if (m_page) | 2177 if (m_page) |
| 2157 m_page->setIsCursorVisible(isVisible); | 2178 m_page->setIsCursorVisible(isVisible); |
| 2158 } | 2179 } |
| (...skipping 2451 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 4610 return mainFrameImpl()->frameView()->layoutSize().width() == m_size.width | 4631 return mainFrameImpl()->frameView()->layoutSize().width() == m_size.width |
| 4611 || (constraints.minimumScale == constraints.maximumScale && constraints. minimumScale != -1); | 4632 || (constraints.minimumScale == constraints.maximumScale && constraints. minimumScale != -1); |
| 4612 } | 4633 } |
| 4613 | 4634 |
| 4614 void WebViewImpl::forceNextWebGLContextCreationToFail() | 4635 void WebViewImpl::forceNextWebGLContextCreationToFail() |
| 4615 { | 4636 { |
| 4616 WebGLRenderingContext::forceNextWebGLContextCreationToFail(); | 4637 WebGLRenderingContext::forceNextWebGLContextCreationToFail(); |
| 4617 } | 4638 } |
| 4618 | 4639 |
| 4619 } // namespace blink | 4640 } // namespace blink |
| OLD | NEW |