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

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

Issue 19555002: Translate viewport related meta tags into @viewport descriptors as suggested by the CSS Device Adap… (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 7 years, 5 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 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
80 #include "WebPagePopupImpl.h" 80 #include "WebPagePopupImpl.h"
81 #include "WebPlugin.h" 81 #include "WebPlugin.h"
82 #include "WebPluginAction.h" 82 #include "WebPluginAction.h"
83 #include "WebPluginContainerImpl.h" 83 #include "WebPluginContainerImpl.h"
84 #include "WebPopupMenuImpl.h" 84 #include "WebPopupMenuImpl.h"
85 #include "WebRange.h" 85 #include "WebRange.h"
86 #include "WebSettingsImpl.h" 86 #include "WebSettingsImpl.h"
87 #include "WebTextInputInfo.h" 87 #include "WebTextInputInfo.h"
88 #include "WebViewClient.h" 88 #include "WebViewClient.h"
89 #include "core/accessibility/AXObjectCache.h" 89 #include "core/accessibility/AXObjectCache.h"
90 #include "core/css/StyleSheetContents.h"
90 #include "core/css/resolver/StyleResolver.h" 91 #include "core/css/resolver/StyleResolver.h"
91 #include "core/dom/Document.h" 92 #include "core/dom/Document.h"
92 #include "core/dom/DocumentMarkerController.h" 93 #include "core/dom/DocumentMarkerController.h"
93 #include "core/dom/FullscreenController.h" 94 #include "core/dom/FullscreenController.h"
94 #include "core/dom/KeyboardEvent.h" 95 #include "core/dom/KeyboardEvent.h"
95 #include "core/dom/NodeRenderStyle.h" 96 #include "core/dom/NodeRenderStyle.h"
96 #include "core/dom/Text.h" 97 #include "core/dom/Text.h"
97 #include "core/dom/WheelEvent.h" 98 #include "core/dom/WheelEvent.h"
98 #include "core/editing/Editor.h" 99 #include "core/editing/Editor.h"
99 #include "core/editing/FrameSelection.h" 100 #include "core/editing/FrameSelection.h"
(...skipping 2860 matching lines...) Expand 10 before | Expand all | Expand 10 after
2960 m_shouldAutoResize = false; 2961 m_shouldAutoResize = false;
2961 configureAutoResizeMode(); 2962 configureAutoResizeMode();
2962 } 2963 }
2963 2964
2964 void WebViewImpl::setUserAgentPageScaleConstraints(PageScaleConstraints newConst raints) 2965 void WebViewImpl::setUserAgentPageScaleConstraints(PageScaleConstraints newConst raints)
2965 { 2966 {
2966 if (newConstraints == m_pageScaleConstraintsSet.userAgentConstraints()) 2967 if (newConstraints == m_pageScaleConstraintsSet.userAgentConstraints())
2967 return; 2968 return;
2968 2969
2969 m_pageScaleConstraintsSet.setUserAgentConstraints(newConstraints); 2970 m_pageScaleConstraintsSet.setUserAgentConstraints(newConstraints);
2971 m_pageScaleConstraintsSet.setNeedsReset(true);
2972
2973 Vector<String> whitelist;
2974 Document* document = m_page->mainFrame()->document();
2975 whitelist.append(document->url());
2976
2977 StringBuilder builder;
2978
2979 builder.append("@viewport{");
2980
2981 if (newConstraints.initialScale > 0) {
2982 builder.appendLiteral("zoom:");
2983 builder.append(String::number(newConstraints.initialScale));
2984 builder.appendLiteral("!important;");
2985 }
2986
2987 if (newConstraints.minimumScale > 0) {
2988 builder.appendLiteral("min-zoom:");
2989 builder.append(String::number(newConstraints.minimumScale));
2990 builder.appendLiteral("!important;");
2991 }
2992
2993 if (newConstraints.maximumScale > 0) {
2994 builder.appendLiteral("max-zoom:");
2995 builder.append(String::number(newConstraints.maximumScale));
2996 builder.appendLiteral("!important;");
2997 }
2998
2999 builder.append("}");
3000
3001 removeAllUserContent();
3002 addUserStyleSheet(builder.toString(), whitelist, UserContentInjectInAllFrame s, UserStyleInjectInExistingDocuments);
2970 3003
2971 if (!mainFrameImpl() || !mainFrameImpl()->frameView()) 3004 if (!mainFrameImpl() || !mainFrameImpl()->frameView())
2972 return; 3005 return;
2973 3006
2974 mainFrameImpl()->frameView()->setNeedsLayout(); 3007 mainFrameImpl()->frameView()->setNeedsLayout();
2975 } 3008 }
2976 3009
2977 void WebViewImpl::setInitialPageScaleOverride(float initialPageScaleFactorOverri de) 3010 void WebViewImpl::setInitialPageScaleOverride(float initialPageScaleFactorOverri de)
2978 { 3011 {
2979 PageScaleConstraints constraints = m_pageScaleConstraintsSet.userAgentConstr aints(); 3012 PageScaleConstraints constraints = m_pageScaleConstraintsSet.userAgentConstr aints();
2980 constraints.initialScale = initialPageScaleFactorOverride; 3013 constraints.initialScale = initialPageScaleFactorOverride;
2981
2982 if (constraints == m_pageScaleConstraintsSet.userAgentConstraints())
2983 return;
2984
2985 m_pageScaleConstraintsSet.setNeedsReset(true);
2986 setUserAgentPageScaleConstraints(constraints); 3014 setUserAgentPageScaleConstraints(constraints);
2987 } 3015 }
2988 3016
2989 void WebViewImpl::setPageScaleFactorLimits(float minPageScale, float maxPageScal e) 3017 void WebViewImpl::setPageScaleFactorLimits(float minPageScale, float maxPageScal e)
2990 { 3018 {
2991 PageScaleConstraints constraints = m_pageScaleConstraintsSet.userAgentConstr aints(); 3019 PageScaleConstraints constraints = m_pageScaleConstraintsSet.userAgentConstr aints();
2992 constraints.minimumScale = minPageScale; 3020 constraints.minimumScale = minPageScale;
2993 constraints.maximumScale = maxPageScale; 3021 constraints.maximumScale = maxPageScale;
2994 setUserAgentPageScaleConstraints(constraints); 3022 setUserAgentPageScaleConstraints(constraints);
2995 } 3023 }
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
3036 // isn't set at the end of a layout. 3064 // isn't set at the end of a layout.
3037 if (view->needsLayout()) 3065 if (view->needsLayout())
3038 view->layout(); 3066 view->layout();
3039 } 3067 }
3040 3068
3041 void WebViewImpl::updatePageDefinedPageScaleConstraints(const ViewportArguments& arguments) 3069 void WebViewImpl::updatePageDefinedPageScaleConstraints(const ViewportArguments& arguments)
3042 { 3070 {
3043 if (!settings()->viewportEnabled() || !isFixedLayoutModeEnabled() || !page() || !m_size.width || !m_size.height) 3071 if (!settings()->viewportEnabled() || !isFixedLayoutModeEnabled() || !page() || !m_size.width || !m_size.height)
3044 return; 3072 return;
3045 3073
3046 m_pageScaleConstraintsSet.updatePageDefinedConstraints(arguments, m_size, pa ge()->settings()->layoutFallbackWidth()); 3074 m_pageScaleConstraintsSet.updatePageDefinedConstraints(arguments, m_size);
3047 3075
3048 if (settingsImpl()->supportDeprecatedTargetDensityDPI()) 3076 if (settingsImpl()->supportDeprecatedTargetDensityDPI())
3049 m_pageScaleConstraintsSet.adjustPageDefinedConstraintsForAndroidWebView( arguments, m_size, page()->settings()->layoutFallbackWidth(), deviceScaleFactor( ), page()->settings()->useWideViewport(), page()->settings()->loadWithOverviewMo de()); 3077 m_pageScaleConstraintsSet.adjustPageDefinedConstraintsForAndroidWebView( arguments, m_size, page()->settings()->layoutFallbackWidth(), deviceScaleFactor( ), page()->settings()->useWideViewport(), page()->settings()->loadWithOverviewMo de());
3050 3078
3051 WebSize layoutSize = flooredIntSize(m_pageScaleConstraintsSet.pageDefinedCon straints().layoutSize); 3079 WebSize layoutSize = flooredIntSize(m_pageScaleConstraintsSet.pageDefinedCon straints().layoutSize);
3052 3080
3053 if (page()->settings() && page()->settings()->textAutosizingEnabled() && pag e()->mainFrame() 3081 if (page()->settings() && page()->settings()->textAutosizingEnabled() && pag e()->mainFrame()
3054 && layoutSize.width != fixedLayoutSize().width) 3082 && layoutSize.width != fixedLayoutSize().width)
3055 page()->mainFrame()->document()->textAutosizer()->recalculateMultipl iers(); 3083 page()->mainFrame()->document()->textAutosizer()->recalculateMultipl iers();
3056 3084
(...skipping 1077 matching lines...) Expand 10 before | Expand all | Expand 10 after
4134 const WebMouseEvent& mouseEvent = static_cast<const WebMouseEvent&>(event); 4162 const WebMouseEvent& mouseEvent = static_cast<const WebMouseEvent&>(event);
4135 4163
4136 if (page()) 4164 if (page())
4137 page()->pointerLockController()->dispatchLockedMouseEvent( 4165 page()->pointerLockController()->dispatchLockedMouseEvent(
4138 PlatformMouseEventBuilder(mainFrameImpl()->frameView(), mouseEvent), 4166 PlatformMouseEventBuilder(mainFrameImpl()->frameView(), mouseEvent),
4139 eventType); 4167 eventType);
4140 } 4168 }
4141 4169
4142 bool WebViewImpl::shouldDisableDesktopWorkarounds() 4170 bool WebViewImpl::shouldDisableDesktopWorkarounds()
4143 { 4171 {
4144 ViewportArguments arguments = mainFrameImpl()->frame()->document()->viewport Arguments(); 4172 Document* document = mainFrameImpl()->frame()->document();
4145 return arguments.width == ViewportArguments::ValueDeviceWidth || !arguments. userZoom 4173 return document->styleResolver()->viewportStyleResolver()->shouldDisableDesk topWorkarounds();
4146 || (arguments.minZoom == arguments.maxZoom && arguments.minZoom != Viewp ortArguments::ValueAuto);
4147 } 4174 }
4148 4175
4149 } // namespace WebKit 4176 } // namespace WebKit
OLDNEW
« Source/core/testing/Internals.cpp ('K') | « Source/core/testing/Internals.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698