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

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

Issue 23441020: Make it possibe to lock the fixedLayoutSize (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: add one more test Created 7 years, 3 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 1651 matching lines...) Expand 10 before | Expand all | Expand 10 after
1662 // Set the fixed layout size from the viewport constraints before resizing. 1662 // Set the fixed layout size from the viewport constraints before resizing.
1663 updatePageDefinedPageScaleConstraints(mainFrameImpl()->frame()->document()-> viewportArguments()); 1663 updatePageDefinedPageScaleConstraints(mainFrameImpl()->frame()->document()-> viewportArguments());
1664 1664
1665 WebDevToolsAgentPrivate* agentPrivate = devToolsAgentPrivate(); 1665 WebDevToolsAgentPrivate* agentPrivate = devToolsAgentPrivate();
1666 if (agentPrivate) 1666 if (agentPrivate)
1667 agentPrivate->webViewResized(newSize); 1667 agentPrivate->webViewResized(newSize);
1668 if (!agentPrivate || !agentPrivate->metricsOverridden()) { 1668 if (!agentPrivate || !agentPrivate->metricsOverridden()) {
1669 WebFrameImpl* webFrame = mainFrameImpl(); 1669 WebFrameImpl* webFrame = mainFrameImpl();
1670 if (webFrame->frameView()) { 1670 if (webFrame->frameView()) {
1671 webFrame->frameView()->resize(m_size); 1671 webFrame->frameView()->resize(m_size);
1672
aelias_OOO_until_Jul13 2013/09/06 23:11:18 nit: unnecessary newline diff
mkosiba (inactive) 2013/09/10 09:11:31 Done.
1672 if (m_pinchViewports) 1673 if (m_pinchViewports)
1673 m_pinchViewports->setViewportSize(m_size); 1674 m_pinchViewports->setViewportSize(m_size);
1674 } 1675 }
1675 } 1676 }
1676 1677
1677 if (settings()->viewportEnabled()) { 1678 if (settings()->viewportEnabled()) {
1678 // Relayout immediately to recalculate the minimum scale limit. 1679 // Relayout immediately to recalculate the minimum scale limit.
1679 if (view->needsLayout()) 1680 if (view->needsLayout())
1680 view->layout(); 1681 view->layout();
1681 1682
1682 if (shouldAnchorAndRescaleViewport) { 1683 if (shouldAnchorAndRescaleViewport) {
1683 float viewportWidthRatio = static_cast<float>(newSize.width) / oldSi ze.width; 1684 float viewportWidthRatio = static_cast<float>(newSize.width) / oldSi ze.width;
1684 float contentsWidthRatio = static_cast<float>(contentsSize().width() ) / oldContentsWidth; 1685 float contentsWidthRatio = static_cast<float>(contentsSize().width() ) / oldContentsWidth;
1685 float scaleMultiplier = viewportWidthRatio / contentsWidthRatio; 1686 float scaleMultiplier = viewportWidthRatio / contentsWidthRatio;
1686 1687
1687 IntSize viewportSize = view->visibleContentRect().size(); 1688 IntSize viewportSize = view->visibleContentRect().size();
1688 if (scaleMultiplier != 1) { 1689 if (scaleMultiplier != 1 && !fixedLayoutSizeLock()) {
aelias_OOO_until_Jul13 2013/09/06 23:11:18 I don't think you want the else clause of this cod
mkosiba (inactive) 2013/09/10 09:11:31 Done.
1689 float newPageScaleFactor = oldPageScaleFactor * scaleMultiplier; 1690 float newPageScaleFactor = oldPageScaleFactor * scaleMultiplier;
1690 viewportSize.scale(pageScaleFactor() / newPageScaleFactor); 1691 viewportSize.scale(pageScaleFactor() / newPageScaleFactor);
1691 IntPoint scrollOffsetAtNewScale = viewportAnchor.computeOrigin(v iewportSize); 1692 IntPoint scrollOffsetAtNewScale = viewportAnchor.computeOrigin(v iewportSize);
1692 setPageScaleFactor(newPageScaleFactor, scrollOffsetAtNewScale); 1693 setPageScaleFactor(newPageScaleFactor, scrollOffsetAtNewScale);
1693 } else { 1694 } else {
1694 IntPoint scrollOffsetAtNewScale = clampOffsetAtScale(viewportAnc hor.computeOrigin(viewportSize), pageScaleFactor()); 1695 IntPoint scrollOffsetAtNewScale = clampOffsetAtScale(viewportAnc hor.computeOrigin(viewportSize), pageScaleFactor());
1695 updateMainFrameScrollPosition(scrollOffsetAtNewScale, false); 1696 updateMainFrameScrollPosition(scrollOffsetAtNewScale, false);
1696 } 1697 }
1697 } 1698 }
1698 } 1699 }
(...skipping 1259 matching lines...) Expand 10 before | Expand all | Expand 10 after
2958 2959
2959 void WebViewImpl::refreshPageScaleFactorAfterLayout() 2960 void WebViewImpl::refreshPageScaleFactorAfterLayout()
2960 { 2961 {
2961 if (!mainFrame() || !page() || !page()->mainFrame() || !page()->mainFrame()- >view()) 2962 if (!mainFrame() || !page() || !page()->mainFrame() || !page()->mainFrame()- >view())
2962 return; 2963 return;
2963 FrameView* view = page()->mainFrame()->view(); 2964 FrameView* view = page()->mainFrame()->view();
2964 2965
2965 updatePageDefinedPageScaleConstraints(mainFrameImpl()->frame()->document()-> viewportArguments()); 2966 updatePageDefinedPageScaleConstraints(mainFrameImpl()->frame()->document()-> viewportArguments());
2966 m_pageScaleConstraintsSet.computeFinalConstraints(); 2967 m_pageScaleConstraintsSet.computeFinalConstraints();
2967 2968
2968 if (settings()->viewportEnabled()) { 2969 if (settings()->viewportEnabled() && !fixedLayoutSizeLock()) {
2969 int verticalScrollbarWidth = 0; 2970 int verticalScrollbarWidth = 0;
2970 if (view->verticalScrollbar() && !view->verticalScrollbar()->isOverlaySc rollbar()) 2971 if (view->verticalScrollbar() && !view->verticalScrollbar()->isOverlaySc rollbar())
2971 verticalScrollbarWidth = view->verticalScrollbar()->width(); 2972 verticalScrollbarWidth = view->verticalScrollbar()->width();
2972 m_pageScaleConstraintsSet.adjustFinalConstraintsToContentsSize(m_size, c ontentsSize(), verticalScrollbarWidth); 2973 m_pageScaleConstraintsSet.adjustFinalConstraintsToContentsSize(m_size, c ontentsSize(), verticalScrollbarWidth);
2973 } 2974 }
2974 2975
2975 float newPageScaleFactor = pageScaleFactor(); 2976 float newPageScaleFactor = pageScaleFactor();
2976 if (m_pageScaleConstraintsSet.needsReset() && m_pageScaleConstraintsSet.fina lConstraints().initialScale != -1) { 2977 if (m_pageScaleConstraintsSet.needsReset() && m_pageScaleConstraintsSet.fina lConstraints().initialScale != -1) {
2977 newPageScaleFactor = m_pageScaleConstraintsSet.finalConstraints().initia lScale; 2978 newPageScaleFactor = m_pageScaleConstraintsSet.finalConstraints().initia lScale;
2978 m_pageScaleConstraintsSet.setNeedsReset(false); 2979 m_pageScaleConstraintsSet.setNeedsReset(false);
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
3083 3084
3084 Frame* frame = page()->mainFrame(); 3085 Frame* frame = page()->mainFrame();
3085 if (!frame || !frame->view()) 3086 if (!frame || !frame->view())
3086 return WebSize(); 3087 return WebSize();
3087 3088
3088 return frame->view()->fixedLayoutSize(); 3089 return frame->view()->fixedLayoutSize();
3089 } 3090 }
3090 3091
3091 void WebViewImpl::setFixedLayoutSize(const WebSize& layoutSize) 3092 void WebViewImpl::setFixedLayoutSize(const WebSize& layoutSize)
3092 { 3093 {
3094 if (fixedLayoutSizeLock())
3095 return;
3096
3093 if (!page()) 3097 if (!page())
3094 return; 3098 return;
3095 3099
3096 Frame* frame = page()->mainFrame(); 3100 Frame* frame = page()->mainFrame();
3097 if (!frame || !frame->view()) 3101 if (!frame || !frame->view())
3098 return; 3102 return;
3099 3103
3100 frame->view()->setFixedLayoutSize(layoutSize); 3104 frame->view()->setFixedLayoutSize(layoutSize);
3101 } 3105 }
3102 3106
3107 void WebViewImpl::setFixedLayoutSizeLock(bool enable)
3108 {
3109 Frame* frame = page()->mainFrame();
3110 if (!frame || !frame->view())
3111 return;
3112 frame->view()->setFixedLayoutSizeLock(enable);
3113 }
3114
3115 bool WebViewImpl::fixedLayoutSizeLock() const
3116 {
3117 Frame* frame = page()->mainFrame();
3118 if (!frame || !frame->view())
3119 return false;
3120 return frame->view()->fixedLayoutSizeLock();
3121 }
3122
3103 void WebViewImpl::performMediaPlayerAction(const WebMediaPlayerAction& action, 3123 void WebViewImpl::performMediaPlayerAction(const WebMediaPlayerAction& action,
3104 const WebPoint& location) 3124 const WebPoint& location)
3105 { 3125 {
3106 HitTestResult result = hitTestResultForWindowPos(location); 3126 HitTestResult result = hitTestResultForWindowPos(location);
3107 RefPtr<Node> node = result.innerNonSharedNode(); 3127 RefPtr<Node> node = result.innerNonSharedNode();
3108 if (!isHTMLVideoElement(node.get()) && !node->hasTagName(HTMLNames::audioTag )) 3128 if (!isHTMLVideoElement(node.get()) && !node->hasTagName(HTMLNames::audioTag ))
3109 return; 3129 return;
3110 3130
3111 RefPtr<HTMLMediaElement> mediaElement = 3131 RefPtr<HTMLMediaElement> mediaElement =
3112 static_pointer_cast<HTMLMediaElement>(node); 3132 static_pointer_cast<HTMLMediaElement>(node);
(...skipping 992 matching lines...) Expand 10 before | Expand all | Expand 10 after
4105 } 4125 }
4106 4126
4107 bool WebViewImpl::shouldDisableDesktopWorkarounds() 4127 bool WebViewImpl::shouldDisableDesktopWorkarounds()
4108 { 4128 {
4109 ViewportArguments arguments = mainFrameImpl()->frame()->document()->viewport Arguments(); 4129 ViewportArguments arguments = mainFrameImpl()->frame()->document()->viewport Arguments();
4110 return arguments.width == ViewportArguments::ValueDeviceWidth || !arguments. userZoom 4130 return arguments.width == ViewportArguments::ValueDeviceWidth || !arguments. userZoom
4111 || (arguments.minZoom == arguments.maxZoom && arguments.minZoom != Viewp ortArguments::ValueAuto); 4131 || (arguments.minZoom == arguments.maxZoom && arguments.minZoom != Viewp ortArguments::ValueAuto);
4112 } 4132 }
4113 4133
4114 } // namespace WebKit 4134 } // namespace WebKit
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698