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

Side by Side Diff: Source/web/WebViewImpl.cpp

Issue 40423003: Experimental viewport meta tag support for desktop, Blink-side. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 7 years, 2 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 /* 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 1674 matching lines...) Expand 10 before | Expand all | Expand 10 after
1685 FrameView* view = mainFrameImpl()->frameView(); 1685 FrameView* view = mainFrameImpl()->frameView();
1686 if (!view) 1686 if (!view)
1687 return; 1687 return;
1688 1688
1689 WebSize oldSize = m_size; 1689 WebSize oldSize = m_size;
1690 float oldPageScaleFactor = pageScaleFactor(); 1690 float oldPageScaleFactor = pageScaleFactor();
1691 int oldContentsWidth = contentsSize().width(); 1691 int oldContentsWidth = contentsSize().width();
1692 1692
1693 m_size = newSize; 1693 m_size = newSize;
1694 1694
1695 bool shouldAnchorAndRescaleViewport = settings()->viewportEnabled() && oldSi ze.width && oldContentsWidth && newSize.width != oldSize.width; 1695 bool shouldAnchorAndRescaleViewport =
1696 settings()->viewportEnabled() && settings()->scaleViewportOnResize()
aelias_OOO_until_Jul13 2013/10/25 04:10:08 You can delete the settings()->viewportEnabled() n
bokan 2013/10/28 22:17:52 Done.
1697 && oldSize.width && oldContentsWidth && newSize.width != oldSize.width;
1698
1696 ViewportAnchor viewportAnchor(&mainFrameImpl()->frame()->eventHandler()); 1699 ViewportAnchor viewportAnchor(&mainFrameImpl()->frame()->eventHandler());
1697 if (shouldAnchorAndRescaleViewport) { 1700 if (shouldAnchorAndRescaleViewport) {
1698 viewportAnchor.setAnchor(view->visibleContentRect(), 1701 viewportAnchor.setAnchor(view->visibleContentRect(),
1699 FloatSize(viewportAnchorXCoord, viewportAnchorY Coord)); 1702 FloatSize(viewportAnchorXCoord, viewportAnchorY Coord));
1700 } 1703 }
1701 1704
1702 updatePageDefinedViewportConstraints(mainFrameImpl()->frame()->document()->v iewportDescription()); 1705 updatePageDefinedViewportConstraints(mainFrameImpl()->frame()->document()->v iewportDescription());
1703 updateMainFrameLayoutSize(); 1706 updateMainFrameLayoutSize();
1704 1707
1705 WebDevToolsAgentPrivate* agentPrivate = devToolsAgentPrivate(); 1708 WebDevToolsAgentPrivate* agentPrivate = devToolsAgentPrivate();
1706 if (agentPrivate) 1709 if (agentPrivate)
1707 agentPrivate->webViewResized(newSize); 1710 agentPrivate->webViewResized(newSize);
1708 WebFrameImpl* webFrame = mainFrameImpl(); 1711 WebFrameImpl* webFrame = mainFrameImpl();
1709 if (webFrame->frameView()) { 1712 if (webFrame->frameView()) {
1710 webFrame->frameView()->resize(m_size); 1713 webFrame->frameView()->resize(m_size);
1711 if (m_pinchViewports) 1714 if (m_pinchViewports)
1712 m_pinchViewports->setViewportSize(m_size); 1715 m_pinchViewports->setViewportSize(m_size);
1713 } 1716 }
1714 1717
1715 if (settings()->viewportEnabled() && !m_fixedLayoutSizeLock) { 1718 if (settings()->viewportEnabled() && !m_fixedLayoutSizeLock) {
1716 // Relayout immediately to recalculate the minimum scale limit. 1719 // Relayout immediately to recalculate the minimum scale limit.
1717 if (view->needsLayout()) 1720 if (view->needsLayout())
1718 view->layout(); 1721 view->layout();
aelias_OOO_until_Jul13 2013/10/25 04:10:08 Hmm, this should a no-op after the fixed layout ch
bokan 2013/10/25 17:19:38 Sorry, you did mention it in that review, but I re
aelias_OOO_until_Jul13 2013/10/25 23:15:02 OK, that's fine, my fault for not remembering that
1719 1722
1720 if (shouldAnchorAndRescaleViewport) { 1723 if (shouldAnchorAndRescaleViewport) {
1721 float viewportWidthRatio = static_cast<float>(newSize.width) / oldSi ze.width; 1724 float viewportWidthRatio = static_cast<float>(newSize.width) / oldSi ze.width;
1722 float contentsWidthRatio = static_cast<float>(contentsSize().width() ) / oldContentsWidth; 1725 float contentsWidthRatio = static_cast<float>(contentsSize().width() ) / oldContentsWidth;
1723 float scaleMultiplier = viewportWidthRatio / contentsWidthRatio; 1726 float scaleMultiplier = viewportWidthRatio / contentsWidthRatio;
1724 1727
1725 IntSize viewportSize = view->visibleContentRect().size(); 1728 IntSize viewportSize = view->visibleContentRect().size();
1726 if (scaleMultiplier != 1) { 1729 if (scaleMultiplier != 1) {
1727 float newPageScaleFactor = oldPageScaleFactor * scaleMultiplier; 1730 float newPageScaleFactor = oldPageScaleFactor * scaleMultiplier;
1728 viewportSize.scale(pageScaleFactor() / newPageScaleFactor); 1731 viewportSize.scale(pageScaleFactor() / newPageScaleFactor);
(...skipping 2379 matching lines...) Expand 10 before | Expand all | Expand 10 after
4108 const PageScaleConstraints& constraints = m_pageScaleConstraintsSet.pageDefi nedConstraints(); 4111 const PageScaleConstraints& constraints = m_pageScaleConstraintsSet.pageDefi nedConstraints();
4109 4112
4110 if (!mainFrameImpl() || !mainFrameImpl()->frameView()) 4113 if (!mainFrameImpl() || !mainFrameImpl()->frameView())
4111 return false; 4114 return false;
4112 4115
4113 return mainFrameImpl()->frameView()->layoutSize().width() == m_size.width 4116 return mainFrameImpl()->frameView()->layoutSize().width() == m_size.width
4114 || (constraints.minimumScale == constraints.maximumScale && constraints. minimumScale != -1); 4117 || (constraints.minimumScale == constraints.maximumScale && constraints. minimumScale != -1);
4115 } 4118 }
4116 4119
4117 } // namespace WebKit 4120 } // namespace WebKit
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698