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

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

Issue 15927026: Enabled using viewport on desktop browsers behind experimental flag (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 7 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 /* 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 1581 matching lines...) Expand 10 before | Expand all | Expand 10 after
1592 FrameView* view = mainFrameImpl()->frameView(); 1592 FrameView* view = mainFrameImpl()->frameView();
1593 if (!view) 1593 if (!view)
1594 return; 1594 return;
1595 1595
1596 WebSize oldSize = m_size; 1596 WebSize oldSize = m_size;
1597 float oldPageScaleFactor = pageScaleFactor(); 1597 float oldPageScaleFactor = pageScaleFactor();
1598 int oldContentsWidth = contentsSize().width(); 1598 int oldContentsWidth = contentsSize().width();
1599 1599
1600 m_size = newSize; 1600 m_size = newSize;
1601 1601
1602 bool shouldAnchorAndRescaleViewport = settings()->viewportEnabled() && oldSi ze.width && oldContentsWidth; 1602 bool shouldAnchorAndRescaleViewport = settings()->viewportEnabled()
1603 && settings()->deviceSupportsRotation() && oldSize.width && oldContentsW idth;
Rick Byers 2013/06/04 00:25:30 Note that ChromeOS does support rotation (Ctrl-Shi
bokan 2013/06/04 18:52:16 Ah, resizableWindow makes more sense then - I'll c
Rick Byers 2013/06/05 15:04:08 Right.
1604
1603 ViewportAnchor viewportAnchor(mainFrameImpl()->frame()->eventHandler()); 1605 ViewportAnchor viewportAnchor(mainFrameImpl()->frame()->eventHandler());
1604 if (shouldAnchorAndRescaleViewport) { 1606 if (shouldAnchorAndRescaleViewport) {
1605 viewportAnchor.setAnchor(view->visibleContentRect(), 1607 viewportAnchor.setAnchor(view->visibleContentRect(),
1606 FloatSize(viewportAnchorXCoord, viewportAnchorY Coord)); 1608 FloatSize(viewportAnchorXCoord, viewportAnchorY Coord));
1607 } 1609 }
1608 1610
1609 // Set the fixed layout size from the viewport constraints before resizing. 1611 // Set the fixed layout size from the viewport constraints before resizing.
1610 updatePageDefinedPageScaleConstraints(mainFrameImpl()->frame()->document()-> viewportArguments()); 1612 updatePageDefinedPageScaleConstraints(mainFrameImpl()->frame()->document()-> viewportArguments());
1611 1613
1614 if (settings()->desktopViewportEnabled() && mainFrameImpl()->frame()->docume nt()->viewportArguments().width == ViewportArguments::ValueAuto)
1615 setFixedLayoutSize(newSize);
Rick Byers 2013/06/04 00:25:30 Shouldn't we also be updating the size on resize u
Rick Byers 2013/06/04 00:25:30 Shouldn't we also do this in the ValueDeviceWidth
bokan 2013/06/04 18:52:16 That happens in the method call above, along with
bokan 2013/06/04 18:52:16 Agreed, and I originally had everything behind vie
Rick Byers 2013/06/05 15:04:08 I think this logic belongs inside of updatePageDef
Rick Byers 2013/06/05 15:04:08 You should be able to build content shell easily e
bokan 2013/06/06 19:43:47 Done.
1616
1612 WebDevToolsAgentPrivate* agentPrivate = devToolsAgentPrivate(); 1617 WebDevToolsAgentPrivate* agentPrivate = devToolsAgentPrivate();
1613 if (agentPrivate) 1618 if (agentPrivate)
1614 agentPrivate->webViewResized(newSize); 1619 agentPrivate->webViewResized(newSize);
1615 if (!agentPrivate || !agentPrivate->metricsOverridden()) { 1620 if (!agentPrivate || !agentPrivate->metricsOverridden()) {
1616 WebFrameImpl* webFrame = mainFrameImpl(); 1621 WebFrameImpl* webFrame = mainFrameImpl();
1617 if (webFrame->frameView()) 1622 if (webFrame->frameView())
1618 webFrame->frameView()->resize(m_size); 1623 webFrame->frameView()->resize(m_size);
1619 } 1624 }
1620 1625
1621 if (settings()->viewportEnabled()) { 1626 if (settings()->viewportEnabled()) {
(...skipping 1373 matching lines...) Expand 10 before | Expand all | Expand 10 after
2995 // isn't set at the end of a layout. 3000 // isn't set at the end of a layout.
2996 if (view->needsLayout()) 3001 if (view->needsLayout())
2997 view->layout(); 3002 view->layout();
2998 } 3003 }
2999 3004
3000 void WebViewImpl::updatePageDefinedPageScaleConstraints(const ViewportArguments& arguments) 3005 void WebViewImpl::updatePageDefinedPageScaleConstraints(const ViewportArguments& arguments)
3001 { 3006 {
3002 if (!settings()->viewportEnabled() || !isFixedLayoutModeEnabled() || !page() || !m_size.width || !m_size.height) 3007 if (!settings()->viewportEnabled() || !isFixedLayoutModeEnabled() || !page() || !m_size.width || !m_size.height)
3003 return; 3008 return;
3004 3009
3005 m_pageScaleConstraintsSet.updatePageDefinedConstraints(arguments, m_size, pa ge()->settings()->layoutFallbackWidth()); 3010 m_pageScaleConstraintsSet.updatePageDefinedConstraints(arguments, m_size, se ttings()->desktopViewportEnabled() ? 0 : page()->settings()->layoutFallbackWidth ());
Rick Byers 2013/06/04 00:25:30 Rather than change the code here, can't we change
bokan 2013/06/04 18:52:16 Actually, I already set fallback width to 0 if the
3006 3011
3007 if (settingsImpl()->supportDeprecatedTargetDensityDPI()) 3012 if (settingsImpl()->supportDeprecatedTargetDensityDPI())
3008 m_pageScaleConstraintsSet.adjustPageDefinedConstraintsForAndroidWebView( arguments, m_size, page()->settings()->layoutFallbackWidth(), deviceScaleFactor( ), page()->settings()->useWideViewport(), page()->settings()->loadWithOverviewMo de()); 3013 m_pageScaleConstraintsSet.adjustPageDefinedConstraintsForAndroidWebView( arguments, m_size, page()->settings()->layoutFallbackWidth(), deviceScaleFactor( ), page()->settings()->useWideViewport(), page()->settings()->loadWithOverviewMo de());
3009 3014
3010 WebSize layoutSize = flooredIntSize(m_pageScaleConstraintsSet.pageDefinedCon straints().layoutSize); 3015 WebSize layoutSize = flooredIntSize(m_pageScaleConstraintsSet.pageDefinedCon straints().layoutSize);
3011 3016
3012 if (page()->settings() && page()->settings()->textAutosizingEnabled() && pag e()->mainFrame() 3017 if (page()->settings() && page()->settings()->textAutosizingEnabled() && pag e()->mainFrame()
3013 && layoutSize.width != fixedLayoutSize().width) 3018 && layoutSize.width != fixedLayoutSize().width)
3014 page()->mainFrame()->document()->textAutosizer()->recalculateMultipl iers(); 3019 page()->mainFrame()->document()->textAutosizer()->recalculateMultipl iers();
3015 3020
(...skipping 566 matching lines...) Expand 10 before | Expand all | Expand 10 after
3582 { 3587 {
3583 if (isNewNavigation) 3588 if (isNewNavigation)
3584 *isNewNavigation = m_observedNewNavigation; 3589 *isNewNavigation = m_observedNewNavigation;
3585 3590
3586 #ifndef NDEBUG 3591 #ifndef NDEBUG
3587 ASSERT(!m_observedNewNavigation 3592 ASSERT(!m_observedNewNavigation
3588 || m_page->mainFrame()->loader()->documentLoader() == m_newNavigationLoa der); 3593 || m_page->mainFrame()->loader()->documentLoader() == m_newNavigationLoa der);
3589 m_newNavigationLoader = 0; 3594 m_newNavigationLoader = 0;
3590 #endif 3595 #endif
3591 m_observedNewNavigation = false; 3596 m_observedNewNavigation = false;
3592 if (*isNewNavigation && !isNavigationWithinPage) 3597 if ((*isNewNavigation && !isNavigationWithinPage) || settings()->desktopView portEnabled())
Rick Byers 2013/06/04 00:25:30 Why is this different for android/desktop?
bokan 2013/06/04 18:52:16 So I'm not sure why, but sometimes when I'd reload
Rick Byers 2013/06/05 15:04:08 Ok. I'm OK with a temporary hack (eg. relying on
3593 m_pageScaleConstraintsSet.setNeedsReset(true); 3598 m_pageScaleConstraintsSet.setNeedsReset(true);
3594 3599
3595 // Make sure link highlight from previous page is cleared. 3600 // Make sure link highlight from previous page is cleared.
3596 m_linkHighlight.clear(); 3601 m_linkHighlight.clear();
3597 m_gestureAnimation.clear(); 3602 m_gestureAnimation.clear();
3598 if (m_layerTreeView) 3603 if (m_layerTreeView)
3599 m_layerTreeView->didStopFlinging(); 3604 m_layerTreeView->didStopFlinging();
3600 resetSavedScrollAndScaleState(); 3605 resetSavedScrollAndScaleState();
3601 } 3606 }
3602 3607
(...skipping 479 matching lines...) Expand 10 before | Expand all | Expand 10 after
4082 } 4087 }
4083 4088
4084 bool WebViewImpl::shouldDisableDesktopWorkarounds() 4089 bool WebViewImpl::shouldDisableDesktopWorkarounds()
4085 { 4090 {
4086 ViewportArguments arguments = mainFrameImpl()->frame()->document()->viewport Arguments(); 4091 ViewportArguments arguments = mainFrameImpl()->frame()->document()->viewport Arguments();
4087 return arguments.width == ViewportArguments::ValueDeviceWidth || !arguments. userZoom 4092 return arguments.width == ViewportArguments::ValueDeviceWidth || !arguments. userZoom
4088 || (arguments.minZoom == arguments.maxZoom && arguments.minZoom != Viewp ortArguments::ValueAuto); 4093 || (arguments.minZoom == arguments.maxZoom && arguments.minZoom != Viewp ortArguments::ValueAuto);
4089 } 4094 }
4090 4095
4091 } // namespace WebKit 4096 } // namespace WebKit
OLDNEW
« Source/WebKit/chromium/public/WebSettings.h ('K') | « Source/WebKit/chromium/src/WebSettingsImpl.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698