| 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 13 matching lines...) Expand all Loading... |
| 24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | 24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
| 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
| 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 29 */ | 29 */ |
| 30 | 30 |
| 31 #include "config.h" | 31 #include "config.h" |
| 32 #include "WebViewImpl.h" | 32 #include "WebViewImpl.h" |
| 33 | 33 |
| 34 #include "public/platform/Platform.h" | |
| 35 #include "public/platform/WebDragData.h" | |
| 36 #include "public/platform/WebFloatPoint.h" | |
| 37 #include "public/platform/WebGestureCurve.h" | |
| 38 #include "public/platform/WebImage.h" | |
| 39 #include "public/platform/WebLayer.h" | |
| 40 #include "public/platform/WebLayerTreeView.h" | |
| 41 #include "public/platform/WebPoint.h" | |
| 42 #include "public/platform/WebRect.h" | |
| 43 #include "public/platform/WebString.h" | |
| 44 #include "public/platform/WebVector.h" | |
| 45 #include "wtf/CurrentTime.h" | |
| 46 #include "wtf/MainThread.h" | |
| 47 #include "wtf/RefPtr.h" | |
| 48 #include "wtf/TemporaryChange.h" | |
| 49 #include "wtf/Uint8ClampedArray.h" | |
| 50 #include "AutofillPopupMenuClient.h" | 34 #include "AutofillPopupMenuClient.h" |
| 51 #include "CSSValueKeywords.h" | 35 #include "CSSValueKeywords.h" |
| 52 #include "CompositionUnderlineVectorBuilder.h" | 36 #include "CompositionUnderlineVectorBuilder.h" |
| 53 #include "ContextFeaturesClientImpl.h" | 37 #include "ContextFeaturesClientImpl.h" |
| 54 #include "DeviceOrientationClientProxy.h" | 38 #include "DeviceOrientationClientProxy.h" |
| 55 #include "FullscreenController.h" | 39 #include "FullscreenController.h" |
| 56 #include "GeolocationClientProxy.h" | 40 #include "GeolocationClientProxy.h" |
| 57 #include "GraphicsLayerFactoryChromium.h" | 41 #include "GraphicsLayerFactoryChromium.h" |
| 58 #include "HTMLNames.h" | 42 #include "HTMLNames.h" |
| 59 #include "LinkHighlight.h" | 43 #include "LinkHighlight.h" |
| (...skipping 24 matching lines...) Expand all Loading... |
| 84 #include "WebPlugin.h" | 68 #include "WebPlugin.h" |
| 85 #include "WebPluginAction.h" | 69 #include "WebPluginAction.h" |
| 86 #include "WebPluginContainerImpl.h" | 70 #include "WebPluginContainerImpl.h" |
| 87 #include "WebPopupMenuImpl.h" | 71 #include "WebPopupMenuImpl.h" |
| 88 #include "WebRange.h" | 72 #include "WebRange.h" |
| 89 #include "WebSettingsImpl.h" | 73 #include "WebSettingsImpl.h" |
| 90 #include "WebTextInputInfo.h" | 74 #include "WebTextInputInfo.h" |
| 91 #include "WebViewClient.h" | 75 #include "WebViewClient.h" |
| 92 #include "WebWindowFeatures.h" | 76 #include "WebWindowFeatures.h" |
| 93 #include "core/accessibility/AXObjectCache.h" | 77 #include "core/accessibility/AXObjectCache.h" |
| 78 #include "core/css/StyleSheetContents.h" |
| 94 #include "core/css/resolver/StyleResolver.h" | 79 #include "core/css/resolver/StyleResolver.h" |
| 80 #include "core/css/resolver/ViewportStyleResolver.h" |
| 95 #include "core/dom/Document.h" | 81 #include "core/dom/Document.h" |
| 96 #include "core/dom/DocumentMarkerController.h" | 82 #include "core/dom/DocumentMarkerController.h" |
| 97 #include "core/dom/KeyboardEvent.h" | 83 #include "core/dom/KeyboardEvent.h" |
| 98 #include "core/dom/NodeRenderStyle.h" | 84 #include "core/dom/NodeRenderStyle.h" |
| 99 #include "core/dom/Text.h" | 85 #include "core/dom/Text.h" |
| 100 #include "core/dom/WheelEvent.h" | 86 #include "core/dom/WheelEvent.h" |
| 101 #include "core/editing/Editor.h" | 87 #include "core/editing/Editor.h" |
| 102 #include "core/editing/FrameSelection.h" | 88 #include "core/editing/FrameSelection.h" |
| 103 #include "core/editing/InputMethodController.h" | 89 #include "core/editing/InputMethodController.h" |
| 104 #include "core/editing/TextIterator.h" | 90 #include "core/editing/TextIterator.h" |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 151 #include "core/platform/graphics/GraphicsContext.h" | 137 #include "core/platform/graphics/GraphicsContext.h" |
| 152 #include "core/platform/graphics/GraphicsContext3D.h" | 138 #include "core/platform/graphics/GraphicsContext3D.h" |
| 153 #include "core/platform/graphics/Image.h" | 139 #include "core/platform/graphics/Image.h" |
| 154 #include "core/platform/graphics/ImageBuffer.h" | 140 #include "core/platform/graphics/ImageBuffer.h" |
| 155 #include "core/platform/graphics/chromium/LayerPainterChromium.h" | 141 #include "core/platform/graphics/chromium/LayerPainterChromium.h" |
| 156 #include "core/platform/graphics/gpu/SharedGraphicsContext3D.h" | 142 #include "core/platform/graphics/gpu/SharedGraphicsContext3D.h" |
| 157 #include "core/rendering/RenderView.h" | 143 #include "core/rendering/RenderView.h" |
| 158 #include "core/rendering/RenderWidget.h" | 144 #include "core/rendering/RenderWidget.h" |
| 159 #include "core/rendering/TextAutosizer.h" | 145 #include "core/rendering/TextAutosizer.h" |
| 160 #include "modules/geolocation/GeolocationController.h" | 146 #include "modules/geolocation/GeolocationController.h" |
| 147 #include "painting/ContinuousPainter.h" |
| 148 #include "public/platform/Platform.h" |
| 149 #include "public/platform/WebDragData.h" |
| 150 #include "public/platform/WebFloatPoint.h" |
| 151 #include "public/platform/WebGestureCurve.h" |
| 152 #include "public/platform/WebImage.h" |
| 153 #include "public/platform/WebLayer.h" |
| 154 #include "public/platform/WebLayerTreeView.h" |
| 155 #include "public/platform/WebPoint.h" |
| 156 #include "public/platform/WebRect.h" |
| 157 #include "public/platform/WebString.h" |
| 158 #include "public/platform/WebVector.h" |
| 161 #include "weborigin/SchemeRegistry.h" | 159 #include "weborigin/SchemeRegistry.h" |
| 162 #include "weborigin/SecurityOrigin.h" | 160 #include "weborigin/SecurityOrigin.h" |
| 163 #include "weborigin/SecurityPolicy.h" | 161 #include "weborigin/SecurityPolicy.h" |
| 164 #include "painting/ContinuousPainter.h" | 162 #include "wtf/CurrentTime.h" |
| 163 #include "wtf/MainThread.h" |
| 164 #include "wtf/RefPtr.h" |
| 165 #include "wtf/TemporaryChange.h" |
| 166 #include "wtf/Uint8ClampedArray.h" |
| 167 #include "wtf/text/StringBuilder.h" |
| 165 | 168 |
| 166 #if ENABLE(DEFAULT_RENDER_THEME) | 169 #if ENABLE(DEFAULT_RENDER_THEME) |
| 167 #include "core/platform/chromium/PlatformThemeChromiumDefault.h" | 170 #include "core/platform/chromium/PlatformThemeChromiumDefault.h" |
| 168 #include "core/rendering/RenderThemeChromiumDefault.h" | 171 #include "core/rendering/RenderThemeChromiumDefault.h" |
| 169 #endif | 172 #endif |
| 170 | 173 |
| 171 #if OS(WINDOWS) | 174 #if OS(WINDOWS) |
| 172 #if !ENABLE(DEFAULT_RENDER_THEME) | 175 #if !ENABLE(DEFAULT_RENDER_THEME) |
| 173 #include "core/rendering/RenderThemeChromiumWin.h" | 176 #include "core/rendering/RenderThemeChromiumWin.h" |
| 174 #endif | 177 #endif |
| (...skipping 2732 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2907 m_shouldAutoResize = false; | 2910 m_shouldAutoResize = false; |
| 2908 configureAutoResizeMode(); | 2911 configureAutoResizeMode(); |
| 2909 } | 2912 } |
| 2910 | 2913 |
| 2911 void WebViewImpl::setUserAgentPageScaleConstraints(PageScaleConstraints newConst
raints) | 2914 void WebViewImpl::setUserAgentPageScaleConstraints(PageScaleConstraints newConst
raints) |
| 2912 { | 2915 { |
| 2913 if (newConstraints == m_pageScaleConstraintsSet.userAgentConstraints()) | 2916 if (newConstraints == m_pageScaleConstraintsSet.userAgentConstraints()) |
| 2914 return; | 2917 return; |
| 2915 | 2918 |
| 2916 m_pageScaleConstraintsSet.setUserAgentConstraints(newConstraints); | 2919 m_pageScaleConstraintsSet.setUserAgentConstraints(newConstraints); |
| 2920 m_pageScaleConstraintsSet.setNeedsReset(true); |
| 2921 |
| 2922 Vector<String> whitelist; |
| 2923 Document* document = m_page->mainFrame()->document(); |
| 2924 whitelist.append(document->url()); |
| 2925 |
| 2926 StringBuilder builder; |
| 2927 |
| 2928 builder.append("@viewport{"); |
| 2929 |
| 2930 if (newConstraints.initialScale > 0) { |
| 2931 builder.appendLiteral("zoom:"); |
| 2932 builder.append(String::number(newConstraints.initialScale)); |
| 2933 builder.appendLiteral("!important;"); |
| 2934 } |
| 2935 |
| 2936 if (newConstraints.minimumScale > 0) { |
| 2937 builder.appendLiteral("min-zoom:"); |
| 2938 builder.append(String::number(newConstraints.minimumScale)); |
| 2939 builder.appendLiteral("!important;"); |
| 2940 } |
| 2941 |
| 2942 if (newConstraints.maximumScale > 0) { |
| 2943 builder.appendLiteral("max-zoom:"); |
| 2944 builder.append(String::number(newConstraints.maximumScale)); |
| 2945 builder.appendLiteral("!important;"); |
| 2946 } |
| 2947 |
| 2948 builder.append("}"); |
| 2949 |
| 2950 removeAllUserContent(); |
| 2951 addUserStyleSheet(builder.toString(), whitelist, UserContentInjectInAllFrame
s, UserStyleInjectInExistingDocuments); |
| 2917 | 2952 |
| 2918 if (!mainFrameImpl() || !mainFrameImpl()->frameView()) | 2953 if (!mainFrameImpl() || !mainFrameImpl()->frameView()) |
| 2919 return; | 2954 return; |
| 2920 | 2955 |
| 2921 mainFrameImpl()->frameView()->setNeedsLayout(); | 2956 mainFrameImpl()->frameView()->setNeedsLayout(); |
| 2922 } | 2957 } |
| 2923 | 2958 |
| 2924 void WebViewImpl::setInitialPageScaleOverride(float initialPageScaleFactorOverri
de) | 2959 void WebViewImpl::setInitialPageScaleOverride(float initialPageScaleFactorOverri
de) |
| 2925 { | 2960 { |
| 2926 PageScaleConstraints constraints = m_pageScaleConstraintsSet.userAgentConstr
aints(); | 2961 PageScaleConstraints constraints = m_pageScaleConstraintsSet.userAgentConstr
aints(); |
| 2927 constraints.initialScale = initialPageScaleFactorOverride; | 2962 constraints.initialScale = initialPageScaleFactorOverride; |
| 2928 | |
| 2929 if (constraints == m_pageScaleConstraintsSet.userAgentConstraints()) | |
| 2930 return; | |
| 2931 | |
| 2932 m_pageScaleConstraintsSet.setNeedsReset(true); | |
| 2933 setUserAgentPageScaleConstraints(constraints); | 2963 setUserAgentPageScaleConstraints(constraints); |
| 2934 } | 2964 } |
| 2935 | 2965 |
| 2936 void WebViewImpl::setPageScaleFactorLimits(float minPageScale, float maxPageScal
e) | 2966 void WebViewImpl::setPageScaleFactorLimits(float minPageScale, float maxPageScal
e) |
| 2937 { | 2967 { |
| 2938 PageScaleConstraints constraints = m_pageScaleConstraintsSet.userAgentConstr
aints(); | 2968 PageScaleConstraints constraints = m_pageScaleConstraintsSet.userAgentConstr
aints(); |
| 2939 constraints.minimumScale = minPageScale; | 2969 constraints.minimumScale = minPageScale; |
| 2940 constraints.maximumScale = maxPageScale; | 2970 constraints.maximumScale = maxPageScale; |
| 2941 setUserAgentPageScaleConstraints(constraints); | 2971 setUserAgentPageScaleConstraints(constraints); |
| 2942 } | 2972 } |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2983 // isn't set at the end of a layout. | 3013 // isn't set at the end of a layout. |
| 2984 if (view->needsLayout()) | 3014 if (view->needsLayout()) |
| 2985 view->layout(); | 3015 view->layout(); |
| 2986 } | 3016 } |
| 2987 | 3017 |
| 2988 void WebViewImpl::updatePageDefinedPageScaleConstraints(const ViewportArguments&
arguments) | 3018 void WebViewImpl::updatePageDefinedPageScaleConstraints(const ViewportArguments&
arguments) |
| 2989 { | 3019 { |
| 2990 if (!settings()->viewportEnabled() || !isFixedLayoutModeEnabled() || !page()
|| !m_size.width || !m_size.height) | 3020 if (!settings()->viewportEnabled() || !isFixedLayoutModeEnabled() || !page()
|| !m_size.width || !m_size.height) |
| 2991 return; | 3021 return; |
| 2992 | 3022 |
| 2993 m_pageScaleConstraintsSet.updatePageDefinedConstraints(arguments, m_size, pa
ge()->settings().layoutFallbackWidth()); | 3023 m_pageScaleConstraintsSet.updatePageDefinedConstraints(arguments, m_size); |
| 2994 | 3024 |
| 2995 if (settingsImpl()->supportDeprecatedTargetDensityDPI()) | 3025 if (settingsImpl()->supportDeprecatedTargetDensityDPI()) |
| 2996 m_pageScaleConstraintsSet.adjustPageDefinedConstraintsForAndroidWebView(
arguments, m_size, page()->settings().layoutFallbackWidth(), deviceScaleFactor()
, page()->settings().useWideViewport(), page()->settings().loadWithOverviewMode(
)); | 3026 m_pageScaleConstraintsSet.adjustPageDefinedConstraintsForAndroidWebView(
arguments, m_size, page()->settings().layoutFallbackWidth(), deviceScaleFactor()
, page()->settings().useWideViewport(), page()->settings().loadWithOverviewMode(
)); |
| 2997 | 3027 |
| 2998 WebSize layoutSize = flooredIntSize(m_pageScaleConstraintsSet.pageDefinedCon
straints().layoutSize); | 3028 WebSize layoutSize = flooredIntSize(m_pageScaleConstraintsSet.pageDefinedCon
straints().layoutSize); |
| 2999 | 3029 |
| 3000 if (page()->settings().textAutosizingEnabled() && page()->mainFrame() && lay
outSize.width != fixedLayoutSize().width) | 3030 if (page()->settings().textAutosizingEnabled() && page()->mainFrame() && lay
outSize.width != fixedLayoutSize().width) |
| 3001 page()->mainFrame()->document()->textAutosizer()->recalculateMultipliers
(); | 3031 page()->mainFrame()->document()->textAutosizer()->recalculateMultipliers
(); |
| 3002 | 3032 |
| 3003 setFixedLayoutSize(layoutSize); | 3033 setFixedLayoutSize(layoutSize); |
| (...skipping 1098 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4102 const WebMouseEvent& mouseEvent = static_cast<const WebMouseEvent&>(event); | 4132 const WebMouseEvent& mouseEvent = static_cast<const WebMouseEvent&>(event); |
| 4103 | 4133 |
| 4104 if (page()) | 4134 if (page()) |
| 4105 page()->pointerLockController().dispatchLockedMouseEvent( | 4135 page()->pointerLockController().dispatchLockedMouseEvent( |
| 4106 PlatformMouseEventBuilder(mainFrameImpl()->frameView(), mouseEvent), | 4136 PlatformMouseEventBuilder(mainFrameImpl()->frameView(), mouseEvent), |
| 4107 eventType); | 4137 eventType); |
| 4108 } | 4138 } |
| 4109 | 4139 |
| 4110 bool WebViewImpl::shouldDisableDesktopWorkarounds() | 4140 bool WebViewImpl::shouldDisableDesktopWorkarounds() |
| 4111 { | 4141 { |
| 4112 ViewportArguments arguments = mainFrameImpl()->frame()->document()->viewport
Arguments(); | 4142 Document* document = mainFrameImpl()->frame()->document(); |
| 4113 return arguments.width == ViewportArguments::ValueDeviceWidth || !arguments.
userZoom | 4143 return document->styleResolver()->viewportStyleResolver()->shouldDisableDesk
topWorkarounds(); |
| 4114 || (arguments.minZoom == arguments.maxZoom && arguments.minZoom != Viewp
ortArguments::ValueAuto); | |
| 4115 } | 4144 } |
| 4116 | 4145 |
| 4117 } // namespace WebKit | 4146 } // namespace WebKit |
| OLD | NEW |