https://bugs.webkit.org/show_bug.cgi?id=83771
Reviewed by Simon Hausmann.
Instead of computing the viewport attributes on both sides,
we now do everything on the web process side, and just send
over the computed result.
* Scripts/webkit2/messages.py:
(struct_or_class):
(headers_for_type):
* Shared/WebCoreArgumentCoders.cpp:
(CoreIPC::::encode):
(CoreIPC::::decode):
* Shared/WebCoreArgumentCoders.h:
(WebCore):
* UIProcess/API/efl/PageClientImpl.cpp:
(WebKit::PageClientImpl::didChangeViewportProperties):
* UIProcess/API/efl/PageClientImpl.h:
(PageClientImpl):
* UIProcess/API/gtk/PageClientImpl.cpp:
(WebKit::PageClientImpl::didChangeViewportProperties):
* UIProcess/API/gtk/PageClientImpl.h:
(PageClientImpl):
* UIProcess/API/mac/PageClientImpl.h:
(PageClientImpl):
* UIProcess/API/mac/PageClientImpl.mm:
(WebKit::PageClientImpl::didChangeViewportProperties):
* UIProcess/API/qt/qquickwebview.cpp:
(QQuickWebViewPrivate::didRelaunchProcess):
(QQuickWebViewFlickablePrivate::didChangeViewportProperties):
(QQuickWebViewFlickablePrivate::updateViewportSize):
* UIProcess/API/qt/qquickwebview_p_p.h:
(QQuickWebViewPrivate::didChangeViewportProperties):
(QQuickWebViewPrivate):
(QQuickWebViewFlickablePrivate):
* UIProcess/PageClient.h:
(WebCore):
(PageClient):
* UIProcess/WebPageProxy.cpp:
(WebKit::WebPageProxy::didChangeViewportProperties):
* UIProcess/WebPageProxy.h:
(WebCore):
(WebPageProxy):
* UIProcess/WebPageProxy.messages.in:
* UIProcess/qt/QtPageClient.cpp:
(QtPageClient::didChangeViewportProperties):
* UIProcess/qt/QtPageClient.h:
(QtPageClient):
* UIProcess/win/WebView.cpp:
(WebKit::WebView::didChangeViewportProperties):
* UIProcess/win/WebView.h:
(WebView):
* WebProcess/WebCoreSupport/WebChromeClient.cpp:
(WebKit::WebChromeClient::dispatchViewportPropertiesDidChange):
(WebKit):
* WebProcess/WebPage/WebPage.cpp:
(WebKit::WebPage::sendViewportAttributesChanged):
(WebKit):
(WebKit::WebPage::setViewportSize):
* WebProcess/WebPage/WebPage.h:
(WebPage):
git-svn-id: http://svn.webkit.org/repository/webkit/trunk@113974
268f45cc-cd09-0410-ab3c-
d52691b4dbfc
+2012-04-12 Kenneth Rohde Christiansen <kenneth@webkit.org>
+
+ Move viewport meta handling to the web process side
+ https://bugs.webkit.org/show_bug.cgi?id=83771
+
+ Reviewed by Simon Hausmann.
+
+ Instead of computing the viewport attributes on both sides,
+ we now do everything on the web process side, and just send
+ over the computed result.
+
+ * Scripts/webkit2/messages.py:
+ (struct_or_class):
+ (headers_for_type):
+ * Shared/WebCoreArgumentCoders.cpp:
+ (CoreIPC::::encode):
+ (CoreIPC::::decode):
+ * Shared/WebCoreArgumentCoders.h:
+ (WebCore):
+ * UIProcess/API/efl/PageClientImpl.cpp:
+ (WebKit::PageClientImpl::didChangeViewportProperties):
+ * UIProcess/API/efl/PageClientImpl.h:
+ (PageClientImpl):
+ * UIProcess/API/gtk/PageClientImpl.cpp:
+ (WebKit::PageClientImpl::didChangeViewportProperties):
+ * UIProcess/API/gtk/PageClientImpl.h:
+ (PageClientImpl):
+ * UIProcess/API/mac/PageClientImpl.h:
+ (PageClientImpl):
+ * UIProcess/API/mac/PageClientImpl.mm:
+ (WebKit::PageClientImpl::didChangeViewportProperties):
+ * UIProcess/API/qt/qquickwebview.cpp:
+ (QQuickWebViewPrivate::didRelaunchProcess):
+ (QQuickWebViewFlickablePrivate::didChangeViewportProperties):
+ (QQuickWebViewFlickablePrivate::updateViewportSize):
+ * UIProcess/API/qt/qquickwebview_p_p.h:
+ (QQuickWebViewPrivate::didChangeViewportProperties):
+ (QQuickWebViewPrivate):
+ (QQuickWebViewFlickablePrivate):
+ * UIProcess/PageClient.h:
+ (WebCore):
+ (PageClient):
+ * UIProcess/WebPageProxy.cpp:
+ (WebKit::WebPageProxy::didChangeViewportProperties):
+ * UIProcess/WebPageProxy.h:
+ (WebCore):
+ (WebPageProxy):
+ * UIProcess/WebPageProxy.messages.in:
+ * UIProcess/qt/QtPageClient.cpp:
+ (QtPageClient::didChangeViewportProperties):
+ * UIProcess/qt/QtPageClient.h:
+ (QtPageClient):
+ * UIProcess/win/WebView.cpp:
+ (WebKit::WebView::didChangeViewportProperties):
+ * UIProcess/win/WebView.h:
+ (WebView):
+ * WebProcess/WebCoreSupport/WebChromeClient.cpp:
+ (WebKit::WebChromeClient::dispatchViewportPropertiesDidChange):
+ (WebKit):
+ * WebProcess/WebPage/WebPage.cpp:
+ (WebKit::WebPage::sendViewportAttributesChanged):
+ (WebKit):
+ (WebKit::WebPage::setViewportSize):
+ * WebProcess/WebPage/WebPage.h:
+ (WebPage):
+
2012-04-12 Zalan Bujtas <zbujtas@gmail.com>
[Qt][WK2] Zoom gesture with double tap crashes on iframe when main frame has scroll offset.
'WebCore::TransformOperation',
'WebCore::TransformOperations',
'WebCore::TranslateTransformOperation',
- 'WebCore::ViewportArguments',
+ 'WebCore::ViewportAttributes',
'WebCore::WindowFeatures',
'WebKit::AttributedString',
'WebKit::ContextMenuState',
'WebCore::FileChooserSettings': ['<WebCore/FileChooser.h>'],
'WebCore::PluginInfo': ['<WebCore/PluginData.h>'],
'WebCore::TextCheckingResult': ['<WebCore/TextCheckerClient.h>'],
+ 'WebCore::ViewportAttributes': ['<WebCore/ViewportArguments.h>'],
'WebKit::InjectedBundleUserMessageEncoder': [],
'WebKit::WebContextUserMessageEncoder': [],
'WebKit::WebGestureEvent': ['"WebEvent.h"'],
return SimpleArgumentCoder<IntSize>::decode(decoder, intSize);
}
-
-void ArgumentCoder<ViewportArguments>::encode(ArgumentEncoder* encoder, const ViewportArguments& viewportArguments)
+void ArgumentCoder<ViewportAttributes>::encode(ArgumentEncoder* encoder, const ViewportAttributes& viewportAttributes)
{
- SimpleArgumentCoder<ViewportArguments>::encode(encoder, viewportArguments);
+ SimpleArgumentCoder<ViewportAttributes>::encode(encoder, viewportAttributes);
}
-bool ArgumentCoder<ViewportArguments>::decode(ArgumentDecoder* decoder, ViewportArguments& viewportArguments)
+bool ArgumentCoder<ViewportAttributes>::decode(ArgumentDecoder* decoder, ViewportAttributes& viewportAttributes)
{
- return SimpleArgumentCoder<ViewportArguments>::decode(decoder, viewportArguments);
+ return SimpleArgumentCoder<ViewportAttributes>::decode(decoder, viewportAttributes);
}
void ArgumentCoder<MimeClassInfo>::encode(ArgumentEncoder* encoder, const MimeClassInfo& mimeClassInfo)
struct MimeClassInfo;
struct PluginInfo;
struct TextCheckingResult;
- struct ViewportArguments;
+ struct ViewportAttributes;
struct WindowFeatures;
}
static bool decode(ArgumentDecoder*, WebCore::IntSize&);
};
-template<> struct ArgumentCoder<WebCore::ViewportArguments> {
- static void encode(ArgumentEncoder*, const WebCore::ViewportArguments&);
- static bool decode(ArgumentDecoder*, WebCore::ViewportArguments&);
+template<> struct ArgumentCoder<WebCore::ViewportAttributes> {
+ static void encode(ArgumentEncoder*, const WebCore::ViewportAttributes&);
+ static bool decode(ArgumentDecoder*, WebCore::ViewportAttributes&);
};
template<> struct ArgumentCoder<WebCore::MimeClassInfo> {
notImplemented();
}
-void PageClientImpl::didChangeViewportProperties(const WebCore::ViewportArguments&)
+void PageClientImpl::didChangeViewportProperties(const WebCore::ViewportAttribues&)
{
notImplemented();
}
virtual void setCursor(const WebCore::Cursor&);
virtual void setCursorHiddenUntilMouseMoves(bool);
- virtual void didChangeViewportProperties(const WebCore::ViewportArguments&);
+ virtual void didChangeViewportProperties(const WebCore::ViewportAttributes&);
virtual void registerEditCommand(PassRefPtr<WebEditCommandProxy>, WebPageProxy::UndoOrRedo);
virtual void clearAllEditCommands();
notImplemented();
}
-void PageClientImpl::didChangeViewportProperties(const WebCore::ViewportArguments&)
+void PageClientImpl::didChangeViewportProperties(const WebCore::ViewportAttributes&)
{
notImplemented();
}
virtual void toolTipChanged(const WTF::String&, const WTF::String&);
virtual void setCursor(const WebCore::Cursor&);
virtual void setCursorHiddenUntilMouseMoves(bool);
- virtual void didChangeViewportProperties(const WebCore::ViewportArguments&);
+ virtual void didChangeViewportProperties(const WebCore::ViewportAttributes&);
virtual void registerEditCommand(PassRefPtr<WebEditCommandProxy>, WebPageProxy::UndoOrRedo);
virtual void clearAllEditCommands();
virtual bool canUndoRedo(WebPageProxy::UndoOrRedo);
virtual void toolTipChanged(const String& oldToolTip, const String& newToolTip);
virtual void setCursor(const WebCore::Cursor&);
virtual void setCursorHiddenUntilMouseMoves(bool);
- virtual void didChangeViewportProperties(const WebCore::ViewportArguments&);
+ virtual void didChangeViewportProperties(const WebCore::ViewportAttributes&);
virtual void registerEditCommand(PassRefPtr<WebEditCommandProxy>, WebPageProxy::UndoOrRedo);
virtual void clearAllEditCommands();
[NSCursor setHiddenUntilMouseMoves:hiddenUntilMouseMoves];
}
-void PageClientImpl::didChangeViewportProperties(const WebCore::ViewportArguments&)
+void PageClientImpl::didChangeViewportProperties(const WebCore::ViewportAttributes&)
{
}
void QQuickWebViewPrivate::didRelaunchProcess()
{
- Q_Q(QQuickWebView);
-
qWarning("WARNING: The web process has been successfully restarted.");
- webPageProxy->setViewportSize(q->boundingRect().size().toSize());
webPageProxy->drawingArea()->setSize(viewSize(), IntSize());
+ updateViewportSize();
}
PassOwnPtr<DrawingAreaProxy> QQuickWebViewPrivate::createDrawingAreaProxy()
{
}
-void QQuickWebViewFlickablePrivate::didChangeViewportProperties(const WebCore::ViewportArguments& args)
+void QQuickWebViewFlickablePrivate::didChangeViewportProperties(const WebCore::ViewportAttributes& attributes)
{
- viewportArguments = args;
+ Q_Q(QQuickWebView);
+
+ QSize viewportSize = q->boundingRect().size().toSize();
+
+ // FIXME: Revise these when implementing fit-to-width.
+ WebCore::ViewportAttributes attr = attributes;
+ WebCore::restrictMinimumScaleFactorToViewportSize(attr, viewportSize);
+ WebCore::restrictScaleFactorToInitialScaleIfNotUserScalable(attr);
+
+ QtViewportInteractionEngine::Constraints newConstraints;
+ newConstraints.initialScale = attr.initialScale;
+ newConstraints.minimumScale = attr.minimumScale;
+ newConstraints.maximumScale = attr.maximumScale;
+ newConstraints.devicePixelRatio = attr.devicePixelRatio;
+ newConstraints.isUserScalable = !!attr.userScalable;
+ newConstraints.layoutSize = attr.layoutSize;
+
+ q->experimental()->viewportInfo()->didUpdateViewportConstraints();
// FIXME: If suspended we should do this on resume.
- interactionEngine->applyConstraints(computeViewportConstraints());
+ interactionEngine->applyConstraints(newConstraints);
}
void QQuickWebViewFlickablePrivate::updateViewportSize()
if (viewportSize.isEmpty() || !interactionEngine)
return;
+ WebPreferences* wkPrefs = webPageProxy->pageGroup()->preferences();
+
+ // FIXME: Remove later; Hardcode a value for now to make sure the DPI adjustment is being tested.
+ wkPrefs->setDeviceDPI(160);
+
+ wkPrefs->setDeviceWidth(viewportSize.width());
+ wkPrefs->setDeviceHeight(viewportSize.height());
+
// Let the WebProcess know about the new viewport size, so that
// it can resize the content accordingly.
webPageProxy->setViewportSize(viewportSize);
- interactionEngine->applyConstraints(computeViewportConstraints());
_q_contentViewportChanged(QPointF());
}
q->experimental()->viewportInfo()->didUpdateContentsSize();
}
-QtViewportInteractionEngine::Constraints QQuickWebViewFlickablePrivate::computeViewportConstraints()
-{
- Q_Q(QQuickWebView);
-
- QtViewportInteractionEngine::Constraints newConstraints;
- QSize availableSize = q->boundingRect().size().toSize();
-
- // Return default values for zero sized viewport.
- if (availableSize.isEmpty())
- return newConstraints;
-
- WebPreferences* wkPrefs = webPageProxy->pageGroup()->preferences();
-
- // FIXME: Remove later; Hardcode a value for now to make sure the DPI adjustment is being tested.
- wkPrefs->setDeviceDPI(160);
-
- wkPrefs->setDeviceWidth(availableSize.width());
- wkPrefs->setDeviceHeight(availableSize.height());
-
- int minimumLayoutFallbackWidth = qMax<int>(wkPrefs->layoutFallbackWidth(), availableSize.width());
-
- WebCore::ViewportAttributes attr = WebCore::computeViewportAttributes(viewportArguments, minimumLayoutFallbackWidth, wkPrefs->deviceWidth(), wkPrefs->deviceHeight(), wkPrefs->deviceDPI(), availableSize);
- WebCore::restrictMinimumScaleFactorToViewportSize(attr, availableSize);
- WebCore::restrictScaleFactorToInitialScaleIfNotUserScalable(attr);
-
- newConstraints.initialScale = attr.initialScale;
- newConstraints.minimumScale = attr.minimumScale;
- newConstraints.maximumScale = attr.maximumScale;
- newConstraints.devicePixelRatio = attr.devicePixelRatio;
- newConstraints.isUserScalable = !!attr.userScalable;
- newConstraints.layoutSize = attr.layoutSize;
-
- q->experimental()->viewportInfo()->didUpdateViewportConstraints();
-
- return newConstraints;
-}
-
/*!
\qmlsignal WebView::onNavigationRequested(request)
virtual void onComponentComplete();
virtual void loadDidCommit() { }
virtual void didFinishFirstNonEmptyLayout() { }
- virtual void didChangeViewportProperties(const WebCore::ViewportArguments& args) { }
+ virtual void didChangeViewportProperties(const WebCore::ViewportAttributes& attr) { }
void didChangeLoadingState(QWebLoadRequest* loadRequest);
void didChangeBackForwardList();
QDeclarativeComponent* filePicker;
QDeclarativeComponent* databaseQuotaDialog;
- WebCore::ViewportArguments viewportArguments;
-
bool m_useDefaultContentItemSize;
bool m_navigatorQtObjectEnabled;
bool m_renderToOffscreenBuffer;
virtual void onComponentComplete();
virtual void loadDidCommit();
virtual void didFinishFirstNonEmptyLayout();
- virtual void didChangeViewportProperties(const WebCore::ViewportArguments& args);
+ virtual void didChangeViewportProperties(const WebCore::ViewportAttributes&);
virtual QtViewportInteractionEngine* viewportInteractionEngine() { return interactionEngine.data(); }
virtual void updateViewportSize();
virtual void pageDidRequestScroll(const QPoint& pos);
virtual void didChangeContentsSize(const QSize& newSize);
- QtViewportInteractionEngine::Constraints computeViewportConstraints();
-
private:
QScopedPointer<QtViewportInteractionEngine> interactionEngine;
bool pageIsSuspended;
namespace WebCore {
class Cursor;
- struct ViewportArguments;
+ struct ViewportAttributes;
}
namespace WebKit {
virtual void setCursor(const WebCore::Cursor&) = 0;
virtual void setCursorHiddenUntilMouseMoves(bool) = 0;
- virtual void didChangeViewportProperties(const WebCore::ViewportArguments&) = 0;
+ virtual void didChangeViewportProperties(const WebCore::ViewportAttributes&) = 0;
virtual void registerEditCommand(PassRefPtr<WebEditCommandProxy>, WebPageProxy::UndoOrRedo) = 0;
virtual void clearAllEditCommands() = 0;
}
#endif
-void WebPageProxy::didChangeViewportProperties(const ViewportArguments& args)
+void WebPageProxy::didChangeViewportProperties(const ViewportAttributes& attr)
{
- m_pageClient->didChangeViewportProperties(args);
+ m_pageClient->didChangeViewportProperties(attr);
}
void WebPageProxy::pageDidScroll()
class ProtectionSpace;
struct FileChooserSettings;
struct TextCheckingResult;
- struct ViewportArguments;
+ struct ViewportAttributes;
struct WindowFeatures;
}
void screenToWindow(const WebCore::IntPoint& screenPoint, WebCore::IntPoint& windowPoint);
void windowToScreen(const WebCore::IntRect& viewRect, WebCore::IntRect& result);
void runBeforeUnloadConfirmPanel(const String& message, uint64_t frameID, bool& shouldClose);
- void didChangeViewportProperties(const WebCore::ViewportArguments&);
+ void didChangeViewportProperties(const WebCore::ViewportAttributes&);
void pageDidScroll();
void runOpenPanel(uint64_t frameID, const WebCore::FileChooserSettings&);
void printFrame(uint64_t frameID);
ShouldInterruptJavaScript() -> (bool shouldInterupt)
MouseDidMoveOverElement(WebKit::WebHitTestResult::Data hitTestResultData, uint32_t modifiers, WebKit::InjectedBundleUserMessageEncoder userData);
MissingPluginButtonClicked(WTF::String mimeType, WTF::String url, WTF::String pluginsPageURL)
- DidChangeViewportProperties(WebCore::ViewportArguments arguments)
+ DidChangeViewportProperties(WebCore::ViewportAttributes attributes)
DidReceiveEvent(uint32_t type, bool handled)
StopResponsivenessTimer()
SetCursor(WebCore::Cursor cursor)
QQuickWebViewPrivate::get(m_webView)->didChangeContentsSize(newSize);
}
-void QtPageClient::didChangeViewportProperties(const WebCore::ViewportArguments& args)
+void QtPageClient::didChangeViewportProperties(const WebCore::ViewportAttributes& attr)
{
- QQuickWebViewPrivate::get(m_webView)->didChangeViewportProperties(args);
+ QQuickWebViewPrivate::get(m_webView)->didChangeViewportProperties(attr);
}
void QtPageClient::startDrag(const WebCore::DragData& dragData, PassRefPtr<ShareableBitmap> dragImage)
virtual void didReceiveMessageFromNavigatorQtObject(const String&);
virtual void pageDidRequestScroll(const WebCore::IntPoint&);
virtual void didChangeContentsSize(const WebCore::IntSize&);
- virtual void didChangeViewportProperties(const WebCore::ViewportArguments&);
+ virtual void didChangeViewportProperties(const WebCore::ViewportAttributes&);
virtual void processDidCrash();
virtual void didRelaunchProcess();
virtual PassOwnPtr<DrawingAreaProxy> createDrawingAreaProxy();
m_nextResizeScrollOffset = scrollOffset;
}
-void WebView::didChangeViewportProperties(const WebCore::ViewportArguments&)
+void WebView::didChangeViewportProperties(const WebCore::ViewportAttributes&)
{
}
virtual void toolTipChanged(const WTF::String&, const WTF::String&);
virtual void setCursor(const WebCore::Cursor&);
virtual void setCursorHiddenUntilMouseMoves(bool);
- virtual void didChangeViewportProperties(const WebCore::ViewportArguments&);
+ virtual void didChangeViewportProperties(const WebCore::ViewportAttributes&);
virtual void registerEditCommand(PassRefPtr<WebEditCommandProxy>, WebPageProxy::UndoOrRedo);
virtual void clearAllEditCommands();
virtual bool canUndoRedo(WebPageProxy::UndoOrRedo);
}
#endif
-void WebChromeClient::dispatchViewportPropertiesDidChange(const ViewportArguments& args) const
+void WebChromeClient::dispatchViewportPropertiesDidChange(const ViewportArguments&) const
{
- m_page->send(Messages::WebPageProxy::DidChangeViewportProperties(args));
-
#if USE(TILED_BACKING_STORE)
- // When viewport properties change, recalculate and set the new recommended layout size in case of fixed layout rendering.
- // Viewport properties have no impact on zero sized fixed viewports.
- if (m_page->useFixedLayout() && !m_page->viewportSize().isEmpty()) {
- Settings* settings = m_page->corePage()->settings();
-
- int minimumLayoutFallbackWidth = std::max(settings->layoutFallbackWidth(), m_page->viewportSize().width());
+ if (!m_page->useFixedLayout())
+ return;
- IntSize targetLayoutSize = computeViewportAttributes(m_page->corePage()->viewportArguments(),
- minimumLayoutFallbackWidth, settings->deviceWidth(), settings->deviceHeight(),
- settings->deviceDPI(), m_page->viewportSize()).layoutSize;
- m_page->setResizesToContentsUsingLayoutSize(targetLayoutSize);
- }
+ m_page->sendViewportAttributesChanged();
#endif
}
-
+
void WebChromeClient::notifyScrollerThumbIsVisibleInRect(const IntRect& scrollerThumb)
{
m_page->send(Messages::WebPageProxy::NotifyScrollerThumbIsVisibleInRect(scrollerThumb));
view->setNeedsLayout();
}
-void WebPage::setViewportSize(const IntSize& size)
+void WebPage::sendViewportAttributesChanged()
{
ASSERT(m_useFixedLayout);
- if (m_viewportSize == size)
+ // Viewport properties have no impact on zero sized fixed viewports.
+ if (m_viewportSize.isEmpty())
return;
- m_viewportSize = size;
-
// Recalculate the recommended layout size, when the available size (device pixel) changes.
Settings* settings = m_page->settings();
- int minimumLayoutFallbackWidth = std::max(settings->layoutFallbackWidth(), size.width());
+ int minimumLayoutFallbackWidth = std::max(settings->layoutFallbackWidth(), m_viewportSize.width());
+
+ ViewportAttributes attr = computeViewportAttributes(m_page->viewportArguments(), minimumLayoutFallbackWidth, settings->deviceWidth(), settings->deviceHeight(), settings->deviceDPI(), m_viewportSize);
+
+ setResizesToContentsUsingLayoutSize(attr.layoutSize);
+ send(Messages::WebPageProxy::DidChangeViewportProperties(attr));
+}
+
+void WebPage::setViewportSize(const IntSize& size)
+{
+ ASSERT(m_useFixedLayout);
+
+ if (m_viewportSize == size)
+ return;
+
+ m_viewportSize = size;
- IntSize targetLayoutSize = computeViewportAttributes(m_page->viewportArguments(), minimumLayoutFallbackWidth, settings->deviceWidth(), settings->deviceHeight(), settings->deviceDPI(), size).layoutSize;
- setResizesToContentsUsingLayoutSize(targetLayoutSize);
+ sendViewportAttributesChanged();
}
#endif
void setFixedVisibleContentRect(const WebCore::IntRect&);
void setResizesToContentsUsingLayoutSize(const WebCore::IntSize&);
void resizeToContentsIfNeeded();
+ void sendViewportAttributesChanged();
void setViewportSize(const WebCore::IntSize&);
WebCore::IntSize viewportSize() const { return m_viewportSize; }
#endif