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

Side by Side Diff: Source/WebKit/chromium/src/WebViewImpl.cpp

Issue 13854008: Unguard VIEWPORT (always enabled) (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Repatch to ToT Created 7 years, 7 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 | Annotate | Revision Log
OLDNEW
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 1629 matching lines...) Expand 10 before | Expand all | Expand 10 after
1640 FrameView* view = mainFrameImpl()->frameView(); 1640 FrameView* view = mainFrameImpl()->frameView();
1641 if (!view) 1641 if (!view)
1642 return; 1642 return;
1643 1643
1644 WebSize oldSize = m_size; 1644 WebSize oldSize = m_size;
1645 float oldPageScaleFactor = pageScaleFactor(); 1645 float oldPageScaleFactor = pageScaleFactor();
1646 int oldContentsWidth = contentsSize().width(); 1646 int oldContentsWidth = contentsSize().width();
1647 1647
1648 m_size = newSize; 1648 m_size = newSize;
1649 1649
1650 #if ENABLE(VIEWPORT)
1651 bool shouldAnchorAndRescaleViewport = settings()->viewportEnabled() && oldSi ze.width && oldContentsWidth; 1650 bool shouldAnchorAndRescaleViewport = settings()->viewportEnabled() && oldSi ze.width && oldContentsWidth;
1652 ViewportAnchor viewportAnchor(mainFrameImpl()->frame()->eventHandler()); 1651 ViewportAnchor viewportAnchor(mainFrameImpl()->frame()->eventHandler());
1653 if (shouldAnchorAndRescaleViewport) { 1652 if (shouldAnchorAndRescaleViewport) {
1654 viewportAnchor.setAnchor(view->visibleContentRect(), 1653 viewportAnchor.setAnchor(view->visibleContentRect(),
1655 FloatSize(viewportAnchorXCoord, viewportAnchorY Coord)); 1654 FloatSize(viewportAnchorXCoord, viewportAnchorY Coord));
1656 } 1655 }
1657 1656
1658 ViewportArguments viewportArguments = mainFrameImpl()->frame()->document()-> viewportArguments(); 1657 ViewportArguments viewportArguments = mainFrameImpl()->frame()->document()-> viewportArguments();
1659 m_page->chrome()->client()->dispatchViewportPropertiesDidChange(viewportArgu ments); 1658 m_page->chrome()->client()->dispatchViewportPropertiesDidChange(viewportArgu ments);
1660 #endif
1661 1659
1662 WebDevToolsAgentPrivate* agentPrivate = devToolsAgentPrivate(); 1660 WebDevToolsAgentPrivate* agentPrivate = devToolsAgentPrivate();
1663 if (agentPrivate) 1661 if (agentPrivate)
1664 agentPrivate->webViewResized(newSize); 1662 agentPrivate->webViewResized(newSize);
1665 if (!agentPrivate || !agentPrivate->metricsOverridden()) { 1663 if (!agentPrivate || !agentPrivate->metricsOverridden()) {
1666 WebFrameImpl* webFrame = mainFrameImpl(); 1664 WebFrameImpl* webFrame = mainFrameImpl();
1667 if (webFrame->frameView()) 1665 if (webFrame->frameView())
1668 webFrame->frameView()->resize(m_size); 1666 webFrame->frameView()->resize(m_size);
1669 } 1667 }
1670 1668
1671 #if ENABLE(VIEWPORT)
1672 if (settings()->viewportEnabled()) { 1669 if (settings()->viewportEnabled()) {
1673 // Relayout immediately to recalculate the minimum scale limit. 1670 // Relayout immediately to recalculate the minimum scale limit.
1674 if (view->needsLayout()) 1671 if (view->needsLayout())
1675 view->layout(); 1672 view->layout();
1676 1673
1677 if (shouldAnchorAndRescaleViewport) { 1674 if (shouldAnchorAndRescaleViewport) {
1678 float viewportWidthRatio = static_cast<float>(newSize.width) / oldSi ze.width; 1675 float viewportWidthRatio = static_cast<float>(newSize.width) / oldSi ze.width;
1679 float contentsWidthRatio = static_cast<float>(contentsSize().width() ) / oldContentsWidth; 1676 float contentsWidthRatio = static_cast<float>(contentsSize().width() ) / oldContentsWidth;
1680 float scaleMultiplier = viewportWidthRatio / contentsWidthRatio; 1677 float scaleMultiplier = viewportWidthRatio / contentsWidthRatio;
1681 1678
1682 IntSize viewportSize = view->visibleContentRect().size(); 1679 IntSize viewportSize = view->visibleContentRect().size();
1683 if (scaleMultiplier != 1) { 1680 if (scaleMultiplier != 1) {
1684 float newPageScaleFactor = oldPageScaleFactor * scaleMultiplier; 1681 float newPageScaleFactor = oldPageScaleFactor * scaleMultiplier;
1685 viewportSize.scale(pageScaleFactor() / newPageScaleFactor); 1682 viewportSize.scale(pageScaleFactor() / newPageScaleFactor);
1686 IntPoint scrollOffsetAtNewScale = viewportAnchor.computeOrigin(v iewportSize); 1683 IntPoint scrollOffsetAtNewScale = viewportAnchor.computeOrigin(v iewportSize);
1687 setPageScaleFactor(newPageScaleFactor, scrollOffsetAtNewScale); 1684 setPageScaleFactor(newPageScaleFactor, scrollOffsetAtNewScale);
1688 } else { 1685 } else {
1689 IntPoint scrollOffsetAtNewScale = clampOffsetAtScale(viewportAnc hor.computeOrigin(viewportSize), pageScaleFactor()); 1686 IntPoint scrollOffsetAtNewScale = clampOffsetAtScale(viewportAnc hor.computeOrigin(viewportSize), pageScaleFactor());
1690 updateMainFrameScrollPosition(scrollOffsetAtNewScale, false); 1687 updateMainFrameScrollPosition(scrollOffsetAtNewScale, false);
1691 } 1688 }
1692 } 1689 }
1693 } 1690 }
1694 #endif
1695 1691
1696 sendResizeEventAndRepaint(); 1692 sendResizeEventAndRepaint();
1697 } 1693 }
1698 1694
1699 void WebViewImpl::willEndLiveResize() 1695 void WebViewImpl::willEndLiveResize()
1700 { 1696 {
1701 if (mainFrameImpl() && mainFrameImpl()->frameView()) 1697 if (mainFrameImpl() && mainFrameImpl()->frameView())
1702 mainFrameImpl()->frameView()->willEndLiveResize(); 1698 mainFrameImpl()->frameView()->willEndLiveResize();
1703 1699
1704 Frame* frame = mainFrameImpl()->frame(); 1700 Frame* frame = mainFrameImpl()->frame();
(...skipping 2508 matching lines...) Expand 10 before | Expand all | Expand 10 after
4213 } 4209 }
4214 4210
4215 bool WebViewImpl::shouldDisableDesktopWorkarounds() 4211 bool WebViewImpl::shouldDisableDesktopWorkarounds()
4216 { 4212 {
4217 ViewportArguments arguments = mainFrameImpl()->frame()->document()->viewport Arguments(); 4213 ViewportArguments arguments = mainFrameImpl()->frame()->document()->viewport Arguments();
4218 return arguments.width == ViewportArguments::ValueDeviceWidth || !arguments. userZoom 4214 return arguments.width == ViewportArguments::ValueDeviceWidth || !arguments. userZoom
4219 || (arguments.minZoom == arguments.maxZoom && arguments.minZoom != Viewp ortArguments::ValueAuto); 4215 || (arguments.minZoom == arguments.maxZoom && arguments.minZoom != Viewp ortArguments::ValueAuto);
4220 } 4216 }
4221 4217
4222 } // namespace WebKit 4218 } // namespace WebKit
OLDNEW
« no previous file with comments | « Source/WebKit/chromium/src/ViewportAnchor.cpp ('k') | Source/WebKit/chromium/tests/WebFrameTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698