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

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: dont need to disable content rects scaling? 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
« no previous file with comments | « Source/web/WebViewImpl.h ('k') | Source/web/tests/WebFrameTest.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 361 matching lines...) Expand 10 before | Expand all | Expand 10 after
372 , m_autofillClient(0) 372 , m_autofillClient(0)
373 , m_permissionClient(0) 373 , m_permissionClient(0)
374 , m_spellCheckClient(0) 374 , m_spellCheckClient(0)
375 , m_passwordGeneratorClient(0) 375 , m_passwordGeneratorClient(0)
376 , m_chromeClientImpl(this) 376 , m_chromeClientImpl(this)
377 , m_contextMenuClientImpl(this) 377 , m_contextMenuClientImpl(this)
378 , m_dragClientImpl(this) 378 , m_dragClientImpl(this)
379 , m_editorClientImpl(this) 379 , m_editorClientImpl(this)
380 , m_inspectorClientImpl(this) 380 , m_inspectorClientImpl(this)
381 , m_backForwardClientImpl(this) 381 , m_backForwardClientImpl(this)
382 , m_fixedLayoutSizeLock(false)
382 , m_shouldAutoResize(false) 383 , m_shouldAutoResize(false)
383 , m_observedNewNavigation(false) 384 , m_observedNewNavigation(false)
384 #ifndef NDEBUG 385 #ifndef NDEBUG
385 , m_newNavigationLoader(0) 386 , m_newNavigationLoader(0)
386 #endif 387 #endif
387 , m_zoomLevel(0) 388 , m_zoomLevel(0)
388 , m_minimumZoomLevel(zoomFactorToZoomLevel(minTextSizeMultiplier)) 389 , m_minimumZoomLevel(zoomFactorToZoomLevel(minTextSizeMultiplier))
389 , m_maximumZoomLevel(zoomFactorToZoomLevel(maxTextSizeMultiplier)) 390 , m_maximumZoomLevel(zoomFactorToZoomLevel(maxTextSizeMultiplier))
390 , m_savedPageScaleFactor(0) 391 , m_savedPageScaleFactor(0)
391 , m_doubleTapZoomPageScaleFactor(0) 392 , m_doubleTapZoomPageScaleFactor(0)
(...skipping 1274 matching lines...) Expand 10 before | Expand all | Expand 10 after
1666 agentPrivate->webViewResized(newSize); 1667 agentPrivate->webViewResized(newSize);
1667 if (!agentPrivate || !agentPrivate->metricsOverridden()) { 1668 if (!agentPrivate || !agentPrivate->metricsOverridden()) {
1668 WebFrameImpl* webFrame = mainFrameImpl(); 1669 WebFrameImpl* webFrame = mainFrameImpl();
1669 if (webFrame->frameView()) { 1670 if (webFrame->frameView()) {
1670 webFrame->frameView()->resize(m_size); 1671 webFrame->frameView()->resize(m_size);
1671 if (m_pinchViewports) 1672 if (m_pinchViewports)
1672 m_pinchViewports->setViewportSize(m_size); 1673 m_pinchViewports->setViewportSize(m_size);
1673 } 1674 }
1674 } 1675 }
1675 1676
1676 if (settings()->viewportEnabled()) { 1677 if (settings()->viewportEnabled() && !m_fixedLayoutSizeLock) {
1677 // Relayout immediately to recalculate the minimum scale limit. 1678 // Relayout immediately to recalculate the minimum scale limit.
1678 if (view->needsLayout()) 1679 if (view->needsLayout())
1679 view->layout(); 1680 view->layout();
1680 1681
1681 if (shouldAnchorAndRescaleViewport) { 1682 if (shouldAnchorAndRescaleViewport) {
1682 float viewportWidthRatio = static_cast<float>(newSize.width) / oldSi ze.width; 1683 float viewportWidthRatio = static_cast<float>(newSize.width) / oldSi ze.width;
1683 float contentsWidthRatio = static_cast<float>(contentsSize().width() ) / oldContentsWidth; 1684 float contentsWidthRatio = static_cast<float>(contentsSize().width() ) / oldContentsWidth;
1684 float scaleMultiplier = viewportWidthRatio / contentsWidthRatio; 1685 float scaleMultiplier = viewportWidthRatio / contentsWidthRatio;
1685 1686
1686 IntSize viewportSize = view->visibleContentRect().size(); 1687 IntSize viewportSize = view->visibleContentRect().size();
(...skipping 1270 matching lines...) Expand 10 before | Expand all | Expand 10 after
2957 2958
2958 void WebViewImpl::refreshPageScaleFactorAfterLayout() 2959 void WebViewImpl::refreshPageScaleFactorAfterLayout()
2959 { 2960 {
2960 if (!mainFrame() || !page() || !page()->mainFrame() || !page()->mainFrame()- >view()) 2961 if (!mainFrame() || !page() || !page()->mainFrame() || !page()->mainFrame()- >view())
2961 return; 2962 return;
2962 FrameView* view = page()->mainFrame()->view(); 2963 FrameView* view = page()->mainFrame()->view();
2963 2964
2964 updatePageDefinedPageScaleConstraints(mainFrameImpl()->frame()->document()-> viewportArguments()); 2965 updatePageDefinedPageScaleConstraints(mainFrameImpl()->frame()->document()-> viewportArguments());
2965 m_pageScaleConstraintsSet.computeFinalConstraints(); 2966 m_pageScaleConstraintsSet.computeFinalConstraints();
2966 2967
2967 if (settings()->viewportEnabled()) { 2968 if (settings()->viewportEnabled() && !m_fixedLayoutSizeLock) {
2968 int verticalScrollbarWidth = 0; 2969 int verticalScrollbarWidth = 0;
2969 if (view->verticalScrollbar() && !view->verticalScrollbar()->isOverlaySc rollbar()) 2970 if (view->verticalScrollbar() && !view->verticalScrollbar()->isOverlaySc rollbar())
2970 verticalScrollbarWidth = view->verticalScrollbar()->width(); 2971 verticalScrollbarWidth = view->verticalScrollbar()->width();
2971 m_pageScaleConstraintsSet.adjustFinalConstraintsToContentsSize(m_size, c ontentsSize(), verticalScrollbarWidth); 2972 m_pageScaleConstraintsSet.adjustFinalConstraintsToContentsSize(m_size, c ontentsSize(), verticalScrollbarWidth);
2972 } 2973 }
2973 2974
2974 float newPageScaleFactor = pageScaleFactor(); 2975 float newPageScaleFactor = pageScaleFactor();
2975 if (m_pageScaleConstraintsSet.needsReset() && m_pageScaleConstraintsSet.fina lConstraints().initialScale != -1) { 2976 if (m_pageScaleConstraintsSet.needsReset() && m_pageScaleConstraintsSet.fina lConstraints().initialScale != -1) {
2976 newPageScaleFactor = m_pageScaleConstraintsSet.finalConstraints().initia lScale; 2977 newPageScaleFactor = m_pageScaleConstraintsSet.finalConstraints().initia lScale;
2977 m_pageScaleConstraintsSet.setNeedsReset(false); 2978 m_pageScaleConstraintsSet.setNeedsReset(false);
(...skipping 21 matching lines...) Expand all
2999 adjustedArguments.minHeight = adjustedArguments.maxHeight; 3000 adjustedArguments.minHeight = adjustedArguments.maxHeight;
3000 } 3001 }
3001 m_pageScaleConstraintsSet.updatePageDefinedConstraints(adjustedArguments, m_ size); 3002 m_pageScaleConstraintsSet.updatePageDefinedConstraints(adjustedArguments, m_ size);
3002 m_pageScaleConstraintsSet.adjustForAndroidWebViewQuirks(adjustedArguments, m _size, page()->settings().layoutFallbackWidth(), deviceScaleFactor(), settingsIm pl()->supportDeprecatedTargetDensityDPI(), page()->settings().wideViewportQuirkE nabled(), page()->settings().useWideViewport(), page()->settings().loadWithOverv iewMode()); 3003 m_pageScaleConstraintsSet.adjustForAndroidWebViewQuirks(adjustedArguments, m _size, page()->settings().layoutFallbackWidth(), deviceScaleFactor(), settingsIm pl()->supportDeprecatedTargetDensityDPI(), page()->settings().wideViewportQuirkE nabled(), page()->settings().useWideViewport(), page()->settings().loadWithOverv iewMode());
3003 3004
3004 WebSize layoutSize = flooredIntSize(m_pageScaleConstraintsSet.pageDefinedCon straints().layoutSize); 3005 WebSize layoutSize = flooredIntSize(m_pageScaleConstraintsSet.pageDefinedCon straints().layoutSize);
3005 3006
3006 if (page()->settings().textAutosizingEnabled() && page()->mainFrame() && lay outSize.width != fixedLayoutSize().width) 3007 if (page()->settings().textAutosizingEnabled() && page()->mainFrame() && lay outSize.width != fixedLayoutSize().width)
3007 page()->mainFrame()->document()->textAutosizer()->recalculateMultipliers (); 3008 page()->mainFrame()->document()->textAutosizer()->recalculateMultipliers ();
3008 3009
3009 setFixedLayoutSize(layoutSize); 3010 if (page()->mainFrame() && page()->mainFrame()->view() && !m_fixedLayoutSize Lock)
3011 page()->mainFrame()->view()->setFixedLayoutSize(layoutSize);
3010 } 3012 }
3011 3013
3012 IntSize WebViewImpl::contentsSize() const 3014 IntSize WebViewImpl::contentsSize() const
3013 { 3015 {
3014 RenderView* root = page()->mainFrame()->contentRenderer(); 3016 RenderView* root = page()->mainFrame()->contentRenderer();
3015 if (!root) 3017 if (!root)
3016 return IntSize(); 3018 return IntSize();
3017 return root->documentRect().size(); 3019 return root->documentRect().size();
3018 } 3020 }
3019 3021
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
3088 3090
3089 return frame->view()->fixedLayoutSize(); 3091 return frame->view()->fixedLayoutSize();
3090 } 3092 }
3091 3093
3092 void WebViewImpl::setFixedLayoutSize(const WebSize& layoutSize) 3094 void WebViewImpl::setFixedLayoutSize(const WebSize& layoutSize)
3093 { 3095 {
3094 if (!page()) 3096 if (!page())
3095 return; 3097 return;
3096 3098
3097 Frame* frame = page()->mainFrame(); 3099 Frame* frame = page()->mainFrame();
3098 if (!frame || !frame->view()) 3100 if (!frame)
3099 return; 3101 return;
3100 3102
3101 frame->view()->setFixedLayoutSize(layoutSize); 3103 FrameView* view = frame->view();
3104 if (!view)
3105 return;
3106
3107 m_fixedLayoutSizeLock = layoutSize.width || layoutSize.height;
3108
3109 if (m_fixedLayoutSizeLock)
3110 view->setFixedLayoutSize(layoutSize);
3111 else
3112 view->setFixedLayoutSize(flooredIntSize(m_pageScaleConstraintsSet.pageDe finedConstraints().layoutSize));
3102 } 3113 }
3103 3114
3104 void WebViewImpl::performMediaPlayerAction(const WebMediaPlayerAction& action, 3115 void WebViewImpl::performMediaPlayerAction(const WebMediaPlayerAction& action,
3105 const WebPoint& location) 3116 const WebPoint& location)
3106 { 3117 {
3107 HitTestResult result = hitTestResultForWindowPos(location); 3118 HitTestResult result = hitTestResultForWindowPos(location);
3108 RefPtr<Node> node = result.innerNonSharedNode(); 3119 RefPtr<Node> node = result.innerNonSharedNode();
3109 if (!isHTMLVideoElement(node.get()) && !node->hasTagName(HTMLNames::audioTag )) 3120 if (!isHTMLVideoElement(node.get()) && !node->hasTagName(HTMLNames::audioTag ))
3110 return; 3121 return;
3111 3122
(...skipping 1001 matching lines...) Expand 10 before | Expand all | Expand 10 after
4113 // the initial viewport width. 4124 // the initial viewport width.
4114 // 2. The author has disabled viewport zoom. 4125 // 2. The author has disabled viewport zoom.
4115 4126
4116 const PageScaleConstraints& constraints = m_pageScaleConstraintsSet.pageDefi nedConstraints(); 4127 const PageScaleConstraints& constraints = m_pageScaleConstraintsSet.pageDefi nedConstraints();
4117 4128
4118 return fixedLayoutSize().width == m_size.width 4129 return fixedLayoutSize().width == m_size.width
4119 || (constraints.minimumScale == constraints.maximumScale && constraints. minimumScale != -1); 4130 || (constraints.minimumScale == constraints.maximumScale && constraints. minimumScale != -1);
4120 } 4131 }
4121 4132
4122 } // namespace WebKit 4133 } // namespace WebKit
OLDNEW
« no previous file with comments | « Source/web/WebViewImpl.h ('k') | Source/web/tests/WebFrameTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698