Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(14)

Side by Side Diff: third_party/WebKit/Source/web/DevToolsEmulator.cpp

Issue 2080623002: Revert "Remove OwnPtr from Blink." (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 "web/DevToolsEmulator.h" 5 #include "web/DevToolsEmulator.h"
6 6
7 #include "core/frame/FrameHost.h" 7 #include "core/frame/FrameHost.h"
8 #include "core/frame/FrameView.h" 8 #include "core/frame/FrameView.h"
9 #include "core/frame/Settings.h" 9 #include "core/frame/Settings.h"
10 #include "core/frame/VisualViewport.h" 10 #include "core/frame/VisualViewport.h"
11 #include "core/page/Page.h" 11 #include "core/page/Page.h"
12 #include "core/style/ComputedStyle.h" 12 #include "core/style/ComputedStyle.h"
13 #include "platform/RuntimeEnabledFeatures.h" 13 #include "platform/RuntimeEnabledFeatures.h"
14 #include "public/platform/WebLayerTreeView.h" 14 #include "public/platform/WebLayerTreeView.h"
15 #include "web/WebInputEventConversion.h" 15 #include "web/WebInputEventConversion.h"
16 #include "web/WebLocalFrameImpl.h" 16 #include "web/WebLocalFrameImpl.h"
17 #include "web/WebSettingsImpl.h" 17 #include "web/WebSettingsImpl.h"
18 #include "web/WebViewImpl.h" 18 #include "web/WebViewImpl.h"
19 #include "wtf/PtrUtil.h"
20 19
21 namespace { 20 namespace {
22 21
23 static float calculateDeviceScaleAdjustment(int width, int height, float deviceS caleFactor) 22 static float calculateDeviceScaleAdjustment(int width, int height, float deviceS caleFactor)
24 { 23 {
25 // Chromium on Android uses a device scale adjustment for fonts used in text autosizing for 24 // Chromium on Android uses a device scale adjustment for fonts used in text autosizing for
26 // improved legibility. This function computes this adjusted value for text autosizing. 25 // improved legibility. This function computes this adjusted value for text autosizing.
27 // For a description of the Android device scale adjustment algorithm, see: 26 // For a description of the Android device scale adjustment algorithm, see:
28 // chrome/browser/chrome_content_browser_client.cc, GetDeviceScaleAdjustment (...) 27 // chrome/browser/chrome_content_browser_client.cc, GetDeviceScaleAdjustment (...)
29 if (!width || !height || !deviceScaleFactor) 28 if (!width || !height || !deviceScaleFactor)
(...skipping 330 matching lines...) Expand 10 before | Expand all | Expand 10 after
360 return false; 359 return false;
361 360
362 // FIXME: This workaround is required for touch emulation on Mac, where 361 // FIXME: This workaround is required for touch emulation on Mac, where
363 // compositor-side pinch handling is not enabled. See http://crbug.com/13800 3. 362 // compositor-side pinch handling is not enabled. See http://crbug.com/13800 3.
364 bool isPinch = inputEvent.type == WebInputEvent::GesturePinchBegin || inputE vent.type == WebInputEvent::GesturePinchUpdate || inputEvent.type == WebInputEve nt::GesturePinchEnd; 363 bool isPinch = inputEvent.type == WebInputEvent::GesturePinchBegin || inputE vent.type == WebInputEvent::GesturePinchUpdate || inputEvent.type == WebInputEve nt::GesturePinchEnd;
365 if (isPinch && m_touchEventEmulationEnabled) { 364 if (isPinch && m_touchEventEmulationEnabled) {
366 FrameView* frameView = page->deprecatedLocalMainFrame()->view(); 365 FrameView* frameView = page->deprecatedLocalMainFrame()->view();
367 PlatformGestureEventBuilder gestureEvent(frameView, static_cast<const We bGestureEvent&>(inputEvent)); 366 PlatformGestureEventBuilder gestureEvent(frameView, static_cast<const We bGestureEvent&>(inputEvent));
368 float pageScaleFactor = page->pageScaleFactor(); 367 float pageScaleFactor = page->pageScaleFactor();
369 if (gestureEvent.type() == PlatformEvent::GesturePinchBegin) { 368 if (gestureEvent.type() == PlatformEvent::GesturePinchBegin) {
370 m_lastPinchAnchorCss = wrapUnique(new IntPoint(frameView->scrollPosi tion() + gestureEvent.position())); 369 m_lastPinchAnchorCss = adoptPtr(new IntPoint(frameView->scrollPositi on() + gestureEvent.position()));
371 m_lastPinchAnchorDip = wrapUnique(new IntPoint(gestureEvent.position ())); 370 m_lastPinchAnchorDip = adoptPtr(new IntPoint(gestureEvent.position() ));
372 m_lastPinchAnchorDip->scale(pageScaleFactor, pageScaleFactor); 371 m_lastPinchAnchorDip->scale(pageScaleFactor, pageScaleFactor);
373 } 372 }
374 if (gestureEvent.type() == PlatformEvent::GesturePinchUpdate && m_lastPi nchAnchorCss) { 373 if (gestureEvent.type() == PlatformEvent::GesturePinchUpdate && m_lastPi nchAnchorCss) {
375 float newPageScaleFactor = pageScaleFactor * gestureEvent.scale(); 374 float newPageScaleFactor = pageScaleFactor * gestureEvent.scale();
376 IntPoint anchorCss(*m_lastPinchAnchorDip.get()); 375 IntPoint anchorCss(*m_lastPinchAnchorDip.get());
377 anchorCss.scale(1.f / newPageScaleFactor, 1.f / newPageScaleFactor); 376 anchorCss.scale(1.f / newPageScaleFactor, 1.f / newPageScaleFactor);
378 m_webViewImpl->setPageScaleFactor(newPageScaleFactor); 377 m_webViewImpl->setPageScaleFactor(newPageScaleFactor);
379 m_webViewImpl->mainFrame()->setScrollOffset(toIntSize(*m_lastPinchAn chorCss.get() - toIntSize(anchorCss))); 378 m_webViewImpl->mainFrame()->setScrollOffset(toIntSize(*m_lastPinchAn chorCss.get() - toIntSize(anchorCss)));
380 } 379 }
381 if (gestureEvent.type() == PlatformEvent::GesturePinchEnd) { 380 if (gestureEvent.type() == PlatformEvent::GesturePinchEnd) {
382 m_lastPinchAnchorCss.reset(); 381 m_lastPinchAnchorCss.reset();
383 m_lastPinchAnchorDip.reset(); 382 m_lastPinchAnchorDip.reset();
384 } 383 }
385 return true; 384 return true;
386 } 385 }
387 386
388 return false; 387 return false;
389 } 388 }
390 389
391 } // namespace blink 390 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/web/DevToolsEmulator.h ('k') | third_party/WebKit/Source/web/ExternalPopupMenu.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698