OLD | NEW |
---|---|
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 2981 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2992 } | 2992 } |
2993 | 2993 |
2994 void WebViewImpl::setPageScaleFactorLimits(float minPageScale, float maxPageScal e) | 2994 void WebViewImpl::setPageScaleFactorLimits(float minPageScale, float maxPageScal e) |
2995 { | 2995 { |
2996 if (minPageScale == m_pageDefinedMinimumPageScaleFactor && maxPageScale == m _pageDefinedMaximumPageScaleFactor) | 2996 if (minPageScale == m_pageDefinedMinimumPageScaleFactor && maxPageScale == m _pageDefinedMaximumPageScaleFactor) |
2997 return; | 2997 return; |
2998 | 2998 |
2999 m_pageDefinedMinimumPageScaleFactor = minPageScale; | 2999 m_pageDefinedMinimumPageScaleFactor = minPageScale; |
3000 m_pageDefinedMaximumPageScaleFactor = maxPageScale; | 3000 m_pageDefinedMaximumPageScaleFactor = maxPageScale; |
3001 | 3001 |
3002 if (settings()->viewportEnabled()) { | 3002 // Obtain the latest contents size and compute the final limits. |
3003 // If we're in viewport tag mode, we need to layout to obtain the latest | 3003 FrameView* view = mainFrameImpl()->frameView(); |
3004 // contents size and compute the final limits. | 3004 if (view) |
3005 FrameView* view = mainFrameImpl()->frameView(); | 3005 view->setNeedsLayout(); |
3006 if (view) | |
3007 view->setNeedsLayout(); | |
3008 } else { | |
3009 // Otherwise just compute the limits immediately. | |
3010 computePageScaleFactorLimits(); | |
3011 } | |
3012 } | 3006 } |
3013 | 3007 |
3014 void WebViewImpl::setIgnoreViewportTagMaximumScale(bool flag) | 3008 void WebViewImpl::setIgnoreViewportTagMaximumScale(bool flag) |
3015 { | 3009 { |
3016 m_ignoreViewportTagMaximumScale = flag; | 3010 m_ignoreViewportTagMaximumScale = flag; |
3017 | 3011 |
3018 if (!page() || !page()->mainFrame()) | 3012 if (!page() || !page()->mainFrame()) |
3019 return; | 3013 return; |
3020 | 3014 |
3021 m_page->chrome()->client()->dispatchViewportPropertiesDidChange(page()->main Frame()->document()->viewportArguments()); | 3015 m_page->chrome()->client()->dispatchViewportPropertiesDidChange(page()->main Frame()->document()->viewportArguments()); |
(...skipping 634 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3656 | 3650 |
3657 if (m_shouldAutoResize && mainFrameImpl()->frame() && mainFrameImpl()->frame ()->view()) { | 3651 if (m_shouldAutoResize && mainFrameImpl()->frame() && mainFrameImpl()->frame ()->view()) { |
3658 WebSize frameSize = mainFrameImpl()->frame()->view()->frameRect().size() ; | 3652 WebSize frameSize = mainFrameImpl()->frame()->view()->frameRect().size() ; |
3659 if (frameSize != m_size) { | 3653 if (frameSize != m_size) { |
3660 m_size = frameSize; | 3654 m_size = frameSize; |
3661 m_client->didAutoResize(m_size); | 3655 m_client->didAutoResize(m_size); |
3662 sendResizeEventAndRepaint(); | 3656 sendResizeEventAndRepaint(); |
3663 } | 3657 } |
3664 } | 3658 } |
3665 | 3659 |
3666 if (settings()->viewportEnabled()) { | 3660 if (settings()->viewportEnabled() && !isPageScaleFactorSet()) { |
3667 if (!isPageScaleFactorSet()) { | 3661 // If the viewport tag failed to be processed earlier, we need |
3668 // If the viewport tag failed to be processed earlier, we need | 3662 // to recompute it now. |
3669 // to recompute it now. | 3663 ViewportArguments viewportArguments = mainFrameImpl()->frame()->document ()->viewportArguments(); |
3670 ViewportArguments viewportArguments = mainFrameImpl()->frame()->docu ment()->viewportArguments(); | 3664 m_page->chrome()->client()->dispatchViewportPropertiesDidChange(viewport Arguments); |
3671 m_page->chrome()->client()->dispatchViewportPropertiesDidChange(view portArguments); | 3665 } |
3672 } | |
3673 | 3666 |
3674 // Contents size is an input to the page scale limits, so a good time to | 3667 // Contents size is an input to the page scale limits, so a good time to |
jamesr
2013/05/03 17:55:58
do you really need to do all this work on every la
wjmaclean
2013/05/03 18:26:17
I think so ... will upload new patch shortly.
aelias_OOO_until_Jul13
2013/05/03 21:00:50
We shouldn't avoid calling this based on pageScale
| |
3675 // recalculate is after layout has occurred. | 3668 // recalculate is after layout has occurred. |
3676 computePageScaleFactorLimits(); | 3669 computePageScaleFactorLimits(); |
3677 | 3670 |
3678 // Relayout immediately to avoid violating the rule that needsLayout() | 3671 // Relayout immediately to avoid violating the rule that needsLayout() |
3679 // isn't set at the end of a layout. | 3672 // isn't set at the end of a layout. |
3680 FrameView* view = mainFrameImpl()->frameView(); | 3673 FrameView* view = mainFrameImpl()->frameView(); |
3681 if (view && view->needsLayout()) | 3674 if (view && view->needsLayout()) |
3682 view->layout(); | 3675 view->layout(); |
3683 } | |
3684 | 3676 |
3685 m_client->didUpdateLayout(); | 3677 m_client->didUpdateLayout(); |
3686 | 3678 |
3687 } | 3679 } |
3688 | 3680 |
3689 void WebViewImpl::didChangeContentsSize() | 3681 void WebViewImpl::didChangeContentsSize() |
3690 { | 3682 { |
3691 } | 3683 } |
3692 | 3684 |
3693 void WebViewImpl::deviceOrPageScaleFactorChanged() | 3685 void WebViewImpl::deviceOrPageScaleFactorChanged() |
(...skipping 516 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
4210 } | 4202 } |
4211 | 4203 |
4212 bool WebViewImpl::shouldDisableDesktopWorkarounds() | 4204 bool WebViewImpl::shouldDisableDesktopWorkarounds() |
4213 { | 4205 { |
4214 ViewportArguments arguments = mainFrameImpl()->frame()->document()->viewport Arguments(); | 4206 ViewportArguments arguments = mainFrameImpl()->frame()->document()->viewport Arguments(); |
4215 return arguments.width == ViewportArguments::ValueDeviceWidth || !arguments. userZoom | 4207 return arguments.width == ViewportArguments::ValueDeviceWidth || !arguments. userZoom |
4216 || (arguments.minZoom == arguments.maxZoom && arguments.minZoom != Viewp ortArguments::ValueAuto); | 4208 || (arguments.minZoom == arguments.maxZoom && arguments.minZoom != Viewp ortArguments::ValueAuto); |
4217 } | 4209 } |
4218 | 4210 |
4219 } // namespace WebKit | 4211 } // namespace WebKit |
OLD | NEW |