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 "GeolocationClientProxy.h" | 39 #include "GeolocationClientProxy.h" |
56 #include "GraphicsLayerFactoryChromium.h" | 40 #include "GraphicsLayerFactoryChromium.h" |
57 #include "HTMLNames.h" | 41 #include "HTMLNames.h" |
58 #include "LinkHighlight.h" | 42 #include "LinkHighlight.h" |
59 #include "PageWidgetDelegate.h" | 43 #include "PageWidgetDelegate.h" |
(...skipping 20 matching lines...) Expand all Loading... |
80 #include "WebPagePopupImpl.h" | 64 #include "WebPagePopupImpl.h" |
81 #include "WebPlugin.h" | 65 #include "WebPlugin.h" |
82 #include "WebPluginAction.h" | 66 #include "WebPluginAction.h" |
83 #include "WebPluginContainerImpl.h" | 67 #include "WebPluginContainerImpl.h" |
84 #include "WebPopupMenuImpl.h" | 68 #include "WebPopupMenuImpl.h" |
85 #include "WebRange.h" | 69 #include "WebRange.h" |
86 #include "WebSettingsImpl.h" | 70 #include "WebSettingsImpl.h" |
87 #include "WebTextInputInfo.h" | 71 #include "WebTextInputInfo.h" |
88 #include "WebViewClient.h" | 72 #include "WebViewClient.h" |
89 #include "core/accessibility/AXObjectCache.h" | 73 #include "core/accessibility/AXObjectCache.h" |
| 74 #include "core/css/StyleSheetContents.h" |
90 #include "core/css/resolver/StyleResolver.h" | 75 #include "core/css/resolver/StyleResolver.h" |
| 76 #include "core/css/resolver/ViewportStyleResolver.h" |
91 #include "core/dom/Document.h" | 77 #include "core/dom/Document.h" |
92 #include "core/dom/DocumentMarkerController.h" | 78 #include "core/dom/DocumentMarkerController.h" |
93 #include "core/dom/FullscreenController.h" | 79 #include "core/dom/FullscreenController.h" |
94 #include "core/dom/KeyboardEvent.h" | 80 #include "core/dom/KeyboardEvent.h" |
95 #include "core/dom/NodeRenderStyle.h" | 81 #include "core/dom/NodeRenderStyle.h" |
96 #include "core/dom/Text.h" | 82 #include "core/dom/Text.h" |
97 #include "core/dom/WheelEvent.h" | 83 #include "core/dom/WheelEvent.h" |
98 #include "core/editing/Editor.h" | 84 #include "core/editing/Editor.h" |
99 #include "core/editing/FrameSelection.h" | 85 #include "core/editing/FrameSelection.h" |
100 #include "core/editing/TextIterator.h" | 86 #include "core/editing/TextIterator.h" |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
147 #include "core/platform/graphics/GraphicsContext3D.h" | 133 #include "core/platform/graphics/GraphicsContext3D.h" |
148 #include "core/platform/graphics/Image.h" | 134 #include "core/platform/graphics/Image.h" |
149 #include "core/platform/graphics/ImageBuffer.h" | 135 #include "core/platform/graphics/ImageBuffer.h" |
150 #include "core/platform/graphics/chromium/LayerPainterChromium.h" | 136 #include "core/platform/graphics/chromium/LayerPainterChromium.h" |
151 #include "core/platform/graphics/gpu/SharedGraphicsContext3D.h" | 137 #include "core/platform/graphics/gpu/SharedGraphicsContext3D.h" |
152 #include "core/platform/network/ResourceHandle.h" | 138 #include "core/platform/network/ResourceHandle.h" |
153 #include "core/rendering/RenderView.h" | 139 #include "core/rendering/RenderView.h" |
154 #include "core/rendering/RenderWidget.h" | 140 #include "core/rendering/RenderWidget.h" |
155 #include "core/rendering/TextAutosizer.h" | 141 #include "core/rendering/TextAutosizer.h" |
156 #include "modules/geolocation/GeolocationController.h" | 142 #include "modules/geolocation/GeolocationController.h" |
| 143 #include "painting/ContinuousPainter.h" |
| 144 #include "public/platform/Platform.h" |
| 145 #include "public/platform/WebDragData.h" |
| 146 #include "public/platform/WebFloatPoint.h" |
| 147 #include "public/platform/WebGestureCurve.h" |
| 148 #include "public/platform/WebImage.h" |
| 149 #include "public/platform/WebLayer.h" |
| 150 #include "public/platform/WebLayerTreeView.h" |
| 151 #include "public/platform/WebPoint.h" |
| 152 #include "public/platform/WebRect.h" |
| 153 #include "public/platform/WebString.h" |
| 154 #include "public/platform/WebVector.h" |
157 #include "weborigin/SchemeRegistry.h" | 155 #include "weborigin/SchemeRegistry.h" |
158 #include "weborigin/SecurityOrigin.h" | 156 #include "weborigin/SecurityOrigin.h" |
159 #include "weborigin/SecurityPolicy.h" | 157 #include "weborigin/SecurityPolicy.h" |
160 #include "painting/ContinuousPainter.h" | 158 #include "wtf/CurrentTime.h" |
| 159 #include "wtf/MainThread.h" |
| 160 #include "wtf/RefPtr.h" |
| 161 #include "wtf/TemporaryChange.h" |
| 162 #include "wtf/Uint8ClampedArray.h" |
| 163 #include "wtf/text/StringBuilder.h" |
161 | 164 |
162 #if ENABLE(DEFAULT_RENDER_THEME) | 165 #if ENABLE(DEFAULT_RENDER_THEME) |
163 #include "core/platform/chromium/PlatformThemeChromiumDefault.h" | 166 #include "core/platform/chromium/PlatformThemeChromiumDefault.h" |
164 #include "core/rendering/RenderThemeChromiumDefault.h" | 167 #include "core/rendering/RenderThemeChromiumDefault.h" |
165 #endif | 168 #endif |
166 | 169 |
167 #if OS(WINDOWS) | 170 #if OS(WINDOWS) |
168 #if !ENABLE(DEFAULT_RENDER_THEME) | 171 #if !ENABLE(DEFAULT_RENDER_THEME) |
169 #include "core/rendering/RenderThemeChromiumWin.h" | 172 #include "core/rendering/RenderThemeChromiumWin.h" |
170 #endif | 173 #endif |
(...skipping 2789 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2960 m_shouldAutoResize = false; | 2963 m_shouldAutoResize = false; |
2961 configureAutoResizeMode(); | 2964 configureAutoResizeMode(); |
2962 } | 2965 } |
2963 | 2966 |
2964 void WebViewImpl::setUserAgentPageScaleConstraints(PageScaleConstraints newConst
raints) | 2967 void WebViewImpl::setUserAgentPageScaleConstraints(PageScaleConstraints newConst
raints) |
2965 { | 2968 { |
2966 if (newConstraints == m_pageScaleConstraintsSet.userAgentConstraints()) | 2969 if (newConstraints == m_pageScaleConstraintsSet.userAgentConstraints()) |
2967 return; | 2970 return; |
2968 | 2971 |
2969 m_pageScaleConstraintsSet.setUserAgentConstraints(newConstraints); | 2972 m_pageScaleConstraintsSet.setUserAgentConstraints(newConstraints); |
| 2973 m_pageScaleConstraintsSet.setNeedsReset(true); |
| 2974 |
| 2975 Vector<String> whitelist; |
| 2976 Document* document = m_page->mainFrame()->document(); |
| 2977 whitelist.append(document->url()); |
| 2978 |
| 2979 StringBuilder builder; |
| 2980 |
| 2981 builder.append("@viewport{"); |
| 2982 |
| 2983 if (newConstraints.initialScale > 0) { |
| 2984 builder.appendLiteral("zoom:"); |
| 2985 builder.append(String::number(newConstraints.initialScale)); |
| 2986 builder.appendLiteral("!important;"); |
| 2987 } |
| 2988 |
| 2989 if (newConstraints.minimumScale > 0) { |
| 2990 builder.appendLiteral("min-zoom:"); |
| 2991 builder.append(String::number(newConstraints.minimumScale)); |
| 2992 builder.appendLiteral("!important;"); |
| 2993 } |
| 2994 |
| 2995 if (newConstraints.maximumScale > 0) { |
| 2996 builder.appendLiteral("max-zoom:"); |
| 2997 builder.append(String::number(newConstraints.maximumScale)); |
| 2998 builder.appendLiteral("!important;"); |
| 2999 } |
| 3000 |
| 3001 builder.append("}"); |
| 3002 |
| 3003 removeAllUserContent(); |
| 3004 addUserStyleSheet(builder.toString(), whitelist, UserContentInjectInAllFrame
s, UserStyleInjectInExistingDocuments); |
2970 | 3005 |
2971 if (!mainFrameImpl() || !mainFrameImpl()->frameView()) | 3006 if (!mainFrameImpl() || !mainFrameImpl()->frameView()) |
2972 return; | 3007 return; |
2973 | 3008 |
2974 mainFrameImpl()->frameView()->setNeedsLayout(); | 3009 mainFrameImpl()->frameView()->setNeedsLayout(); |
2975 } | 3010 } |
2976 | 3011 |
2977 void WebViewImpl::setInitialPageScaleOverride(float initialPageScaleFactorOverri
de) | 3012 void WebViewImpl::setInitialPageScaleOverride(float initialPageScaleFactorOverri
de) |
2978 { | 3013 { |
2979 PageScaleConstraints constraints = m_pageScaleConstraintsSet.userAgentConstr
aints(); | 3014 PageScaleConstraints constraints = m_pageScaleConstraintsSet.userAgentConstr
aints(); |
2980 constraints.initialScale = initialPageScaleFactorOverride; | 3015 constraints.initialScale = initialPageScaleFactorOverride; |
2981 | |
2982 if (constraints == m_pageScaleConstraintsSet.userAgentConstraints()) | |
2983 return; | |
2984 | |
2985 m_pageScaleConstraintsSet.setNeedsReset(true); | |
2986 setUserAgentPageScaleConstraints(constraints); | 3016 setUserAgentPageScaleConstraints(constraints); |
2987 } | 3017 } |
2988 | 3018 |
2989 void WebViewImpl::setPageScaleFactorLimits(float minPageScale, float maxPageScal
e) | 3019 void WebViewImpl::setPageScaleFactorLimits(float minPageScale, float maxPageScal
e) |
2990 { | 3020 { |
2991 PageScaleConstraints constraints = m_pageScaleConstraintsSet.userAgentConstr
aints(); | 3021 PageScaleConstraints constraints = m_pageScaleConstraintsSet.userAgentConstr
aints(); |
2992 constraints.minimumScale = minPageScale; | 3022 constraints.minimumScale = minPageScale; |
2993 constraints.maximumScale = maxPageScale; | 3023 constraints.maximumScale = maxPageScale; |
2994 setUserAgentPageScaleConstraints(constraints); | 3024 setUserAgentPageScaleConstraints(constraints); |
2995 } | 3025 } |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3036 // isn't set at the end of a layout. | 3066 // isn't set at the end of a layout. |
3037 if (view->needsLayout()) | 3067 if (view->needsLayout()) |
3038 view->layout(); | 3068 view->layout(); |
3039 } | 3069 } |
3040 | 3070 |
3041 void WebViewImpl::updatePageDefinedPageScaleConstraints(const ViewportArguments&
arguments) | 3071 void WebViewImpl::updatePageDefinedPageScaleConstraints(const ViewportArguments&
arguments) |
3042 { | 3072 { |
3043 if (!settings()->viewportEnabled() || !isFixedLayoutModeEnabled() || !page()
|| !m_size.width || !m_size.height) | 3073 if (!settings()->viewportEnabled() || !isFixedLayoutModeEnabled() || !page()
|| !m_size.width || !m_size.height) |
3044 return; | 3074 return; |
3045 | 3075 |
3046 m_pageScaleConstraintsSet.updatePageDefinedConstraints(arguments, m_size, pa
ge()->settings()->layoutFallbackWidth()); | 3076 m_pageScaleConstraintsSet.updatePageDefinedConstraints(arguments, m_size); |
3047 | 3077 |
3048 if (settingsImpl()->supportDeprecatedTargetDensityDPI()) | 3078 if (settingsImpl()->supportDeprecatedTargetDensityDPI()) |
3049 m_pageScaleConstraintsSet.adjustPageDefinedConstraintsForAndroidWebView(
arguments, m_size, page()->settings()->layoutFallbackWidth(), deviceScaleFactor(
), page()->settings()->useWideViewport(), page()->settings()->loadWithOverviewMo
de()); | 3079 m_pageScaleConstraintsSet.adjustPageDefinedConstraintsForAndroidWebView(
arguments, m_size, page()->settings()->layoutFallbackWidth(), deviceScaleFactor(
), page()->settings()->useWideViewport(), page()->settings()->loadWithOverviewMo
de()); |
3050 | 3080 |
3051 WebSize layoutSize = flooredIntSize(m_pageScaleConstraintsSet.pageDefinedCon
straints().layoutSize); | 3081 WebSize layoutSize = flooredIntSize(m_pageScaleConstraintsSet.pageDefinedCon
straints().layoutSize); |
3052 | 3082 |
3053 if (page()->settings() && page()->settings()->textAutosizingEnabled() && pag
e()->mainFrame() | 3083 if (page()->settings() && page()->settings()->textAutosizingEnabled() && pag
e()->mainFrame() |
3054 && layoutSize.width != fixedLayoutSize().width) | 3084 && layoutSize.width != fixedLayoutSize().width) |
3055 page()->mainFrame()->document()->textAutosizer()->recalculateMultipl
iers(); | 3085 page()->mainFrame()->document()->textAutosizer()->recalculateMultipl
iers(); |
3056 | 3086 |
(...skipping 1079 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4136 const WebMouseEvent& mouseEvent = static_cast<const WebMouseEvent&>(event); | 4166 const WebMouseEvent& mouseEvent = static_cast<const WebMouseEvent&>(event); |
4137 | 4167 |
4138 if (page()) | 4168 if (page()) |
4139 page()->pointerLockController()->dispatchLockedMouseEvent( | 4169 page()->pointerLockController()->dispatchLockedMouseEvent( |
4140 PlatformMouseEventBuilder(mainFrameImpl()->frameView(), mouseEvent), | 4170 PlatformMouseEventBuilder(mainFrameImpl()->frameView(), mouseEvent), |
4141 eventType); | 4171 eventType); |
4142 } | 4172 } |
4143 | 4173 |
4144 bool WebViewImpl::shouldDisableDesktopWorkarounds() | 4174 bool WebViewImpl::shouldDisableDesktopWorkarounds() |
4145 { | 4175 { |
4146 ViewportArguments arguments = mainFrameImpl()->frame()->document()->viewport
Arguments(); | 4176 Document* document = mainFrameImpl()->frame()->document(); |
4147 return arguments.width == ViewportArguments::ValueDeviceWidth || !arguments.
userZoom | 4177 return document->styleResolver()->viewportStyleResolver()->shouldDisableDesk
topWorkarounds(); |
4148 || (arguments.minZoom == arguments.maxZoom && arguments.minZoom != Viewp
ortArguments::ValueAuto); | |
4149 } | 4178 } |
4150 | 4179 |
4151 } // namespace WebKit | 4180 } // namespace WebKit |
OLD | NEW |