diff options
Diffstat (limited to 'Source/WebKit2/UIProcess')
12 files changed, 292 insertions, 63 deletions
diff --git a/Source/WebKit2/UIProcess/API/gtk/WebKitPermissionRequest.cpp b/Source/WebKit2/UIProcess/API/gtk/WebKitPermissionRequest.cpp new file mode 100644 index 000000000..92235cef1 --- /dev/null +++ b/Source/WebKit2/UIProcess/API/gtk/WebKitPermissionRequest.cpp @@ -0,0 +1,72 @@ +/* + * Copyright (C) 2012 Igalia S.L. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public License + * along with this library; see the file COPYING.LIB. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + */ + +#include "config.h" +#include "WebKitPermissionRequest.h" + +/** + * SECTION: WebKitPermissionRequest + * @Short_description: A permission request + * @Title: WebKitPermissionRequest + * @See_also: #WebKitWebView + * + * There are situations where an embedder would need to ask the user + * for permission to do certain types of operations, such as switching + * to fullscreen mode or reporting the user's location through the + * standard Geolocation API. In those cases, WebKit will emit a + * #WebKitWebView::permission-request signal with a + * #WebKitPermissionRequest object attached to it. + */ + +typedef WebKitPermissionRequestIface WebKitPermissionRequestInterface; +G_DEFINE_INTERFACE(WebKitPermissionRequest, webkit_permission_request, G_TYPE_OBJECT) + +static void webkit_permission_request_default_init(WebKitPermissionRequestIface*) +{ +} + +/** + * webkit_permission_request_allow: + * @request: a #WebKitPermissionRequest + * + * Allow the action which triggered this request. + */ +void webkit_permission_request_allow(WebKitPermissionRequest* request) +{ + g_return_if_fail(WEBKIT_IS_PERMISSION_REQUEST(request)); + + WebKitPermissionRequestIface* iface = WEBKIT_PERMISSION_REQUEST_GET_IFACE(request); + if (iface->allow) + iface->allow(request); +} + +/** + * webkit_permission_request_deny: + * @request: a #WebKitPermissionRequest + * + * Deny the action which triggered this request. + */ +void webkit_permission_request_deny(WebKitPermissionRequest* request) +{ + g_return_if_fail(WEBKIT_IS_PERMISSION_REQUEST(request)); + + WebKitPermissionRequestIface* iface = WEBKIT_PERMISSION_REQUEST_GET_IFACE(request); + if (iface->deny) + iface->deny(request); +} diff --git a/Source/WebKit2/UIProcess/API/gtk/WebKitPermissionRequest.h b/Source/WebKit2/UIProcess/API/gtk/WebKitPermissionRequest.h new file mode 100644 index 000000000..a62f1f1a5 --- /dev/null +++ b/Source/WebKit2/UIProcess/API/gtk/WebKitPermissionRequest.h @@ -0,0 +1,58 @@ +/* + * Copyright (C) 2012 Igalia S.L. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public License + * along with this library; see the file COPYING.LIB. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + */ + +#if !defined(__WEBKIT2_H_INSIDE__) && !defined(WEBKIT2_COMPILATION) +#error "Only <webkit2/webkit2.h> can be included directly." +#endif + +#ifndef WebKitPermissionRequest_h +#define WebKitPermissionRequest_h + +#include <glib-object.h> +#include <webkit2/WebKitDefines.h> + +G_BEGIN_DECLS + +#define WEBKIT_TYPE_PERMISSION_REQUEST (webkit_permission_request_get_type()) +#define WEBKIT_PERMISSION_REQUEST(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), WEBKIT_TYPE_PERMISSION_REQUEST, WebKitPermissionRequest)) +#define WEBKIT_IS_PERMISSION_REQUEST(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), WEBKIT_TYPE_PERMISSION_REQUEST)) +#define WEBKIT_PERMISSION_REQUEST_GET_IFACE(obj) (G_TYPE_INSTANCE_GET_INTERFACE((obj), WEBKIT_TYPE_PERMISSION_REQUEST, WebKitPermissionRequestIface)) + +typedef struct _WebKitPermissionRequest WebKitPermissionRequest; +typedef struct _WebKitPermissionRequestIface WebKitPermissionRequestIface; + +struct _WebKitPermissionRequestIface { + GTypeInterface parent_interface; + + void (* allow) (WebKitPermissionRequest *request); + void (* deny) (WebKitPermissionRequest *request); +}; + +WEBKIT_API GType +webkit_permission_request_get_type (void); + +WEBKIT_API void +webkit_permission_request_allow (WebKitPermissionRequest *request); + +WEBKIT_API void +webkit_permission_request_deny (WebKitPermissionRequest *request); + +G_END_DECLS + +#endif diff --git a/Source/WebKit2/UIProcess/API/gtk/WebKitWebView.cpp b/Source/WebKit2/UIProcess/API/gtk/WebKitWebView.cpp index 65dab6ec2..77ef6c1de 100644 --- a/Source/WebKit2/UIProcess/API/gtk/WebKitWebView.cpp +++ b/Source/WebKit2/UIProcess/API/gtk/WebKitWebView.cpp @@ -65,6 +65,7 @@ enum { SCRIPT_DIALOG, DECIDE_POLICY, + PERMISSION_REQUEST, MOUSE_TARGET_CHANGED, @@ -195,6 +196,12 @@ static gboolean webkitWebViewDecidePolicy(WebKitWebView*, WebKitPolicyDecision* return TRUE; } +static gboolean webkitWebViewPermissionRequest(WebKitWebView*, WebKitPermissionRequest* request) +{ + webkit_permission_request_deny(request); + return TRUE; +} + static void zoomTextOnlyChanged(WebKitSettings* settings, GParamSpec*, WebKitWebView* webView) { WKPageRef wkPage = toAPI(webkitWebViewBaseGetPage(WEBKIT_WEB_VIEW_BASE(webView))); @@ -361,6 +368,7 @@ static void webkit_web_view_class_init(WebKitWebViewClass* webViewClass) webViewClass->create = webkitWebViewCreate; webViewClass->script_dialog = webkitWebViewScriptDialog; webViewClass->decide_policy = webkitWebViewDecidePolicy; + webViewClass->permission_request = webkitWebViewPermissionRequest; webViewClass->run_file_chooser = webkitWebViewRunFileChooser; g_type_class_add_private(webViewClass, sizeof(WebKitWebViewPrivate)); @@ -687,6 +695,70 @@ static void webkit_web_view_class_init(WebKitWebViewClass* webViewClass) WEBKIT_TYPE_POLICY_DECISION_TYPE); /** + * WebKitWebView::permission-request: + * @web_view: the #WebKitWebView on which the signal is emitted + * @request: the #WebKitPermissionRequest + * + * This signal is emitted when WebKit is requesting the client to + * decide about a permission request, such as allowing the browser + * to switch to fullscreen mode, sharing its location or similar + * operations. + * + * A possible way to use this signal could be through a dialog + * allowing the user decide what to do with the request: + * + * <informalexample><programlisting> + * static gboolean permission_request_cb (WebKitWebView *web_view, + * WebKitPermissionRequest *request, + * GtkWindow *parent_window) + * { + * GtkWidget *dialog = gtk_message_dialog_new (parent_window, + * GTK_DIALOG_MODAL, + * GTK_MESSAGE_QUESTION, + * GTK_BUTTONS_YES_NO, + * "Allow Permission Request?"); + * gtk_widget_show (dialog); + * gint result = gtk_dialog_run (GTK_DIALOG (dialog)); + * + * switch (result) { + * case GTK_RESPONSE_YES: + * webkit_permission_request_allow (request); + * break; + * default: + * webkit_permission_request_deny (request); + * break; + * } + * gtk_widget_destroy (dialog); + * + * return TRUE; + * } + * </programlisting></informalexample> + * + * It is possible to handle permission requests asynchronously, by + * simply calling g_object_ref() on the @request argument and + * returning %TRUE to block the default signal handler. If the + * last reference is removed on a #WebKitPermissionRequest and the + * request has not been handled, webkit_permission_request_deny() + * will be the default action. + * + * By default, if the signal is not handled, + * webkit_permission_request_deny() will be called over the + * #WebKitPermissionRequest. + * + * Returns: %TRUE to stop other handlers from being invoked for the event. + * %FALSE to propagate the event further. + * + */ + signals[PERMISSION_REQUEST] = + g_signal_new("permission-request", + G_TYPE_FROM_CLASS(webViewClass), + G_SIGNAL_RUN_LAST, + G_STRUCT_OFFSET(WebKitWebViewClass, permission_request), + g_signal_accumulator_true_handled, 0 /* accumulator data */, + webkit_marshal_BOOLEAN__OBJECT, + G_TYPE_BOOLEAN, 1, /* number of parameters */ + WEBKIT_TYPE_PERMISSION_REQUEST); + /** * WebKitWebView::mouse-target-changed: * @web_view: the #WebKitWebView on which the signal is emitted * @hit_test_result: a #WebKitHitTestResult @@ -971,6 +1043,12 @@ void webkitWebViewMakePolicyDecision(WebKitWebView* webView, WebKitPolicyDecisio g_signal_emit(webView, signals[DECIDE_POLICY], 0, decision, type, &returnValue); } +void webkitWebViewMakePermissionRequest(WebKitWebView* webView, WebKitPermissionRequest* request) +{ + gboolean returnValue; + g_signal_emit(webView, signals[PERMISSION_REQUEST], 0, request, &returnValue); +} + void webkitWebViewMouseTargetChanged(WebKitWebView* webView, WKHitTestResultRef wkHitTestResult, unsigned modifiers) { WebKitWebViewPrivate* priv = webView->priv; diff --git a/Source/WebKit2/UIProcess/API/gtk/WebKitWebView.h b/Source/WebKit2/UIProcess/API/gtk/WebKitWebView.h index 4f5fe1869..7f9fb9e36 100644 --- a/Source/WebKit2/UIProcess/API/gtk/WebKitWebView.h +++ b/Source/WebKit2/UIProcess/API/gtk/WebKitWebView.h @@ -35,6 +35,7 @@ #include <webkit2/WebKitFindController.h> #include <webkit2/WebKitHitTestResult.h> #include <webkit2/WebKitJavascriptResult.h> +#include <webkit2/WebKitPermissionRequest.h> #include <webkit2/WebKitPolicyDecision.h> #include <webkit2/WebKitScriptDialog.h> #include <webkit2/WebKitSettings.h> @@ -143,6 +144,8 @@ struct _WebKitWebViewClass { gboolean (* decide_policy) (WebKitWebView *web_view, WebKitPolicyDecision *decision, WebKitPolicyDecisionType type); + gboolean (* permission_request) (WebKitWebView *web_view, + WebKitPermissionRequest *permission_request); void (* mouse_target_changed) (WebKitWebView *web_view, WebKitHitTestResult *hit_test_result, guint modifiers); diff --git a/Source/WebKit2/UIProcess/API/gtk/WebKitWebViewPrivate.h b/Source/WebKit2/UIProcess/API/gtk/WebKitWebViewPrivate.h index 717d2c344..6ab374551 100644 --- a/Source/WebKit2/UIProcess/API/gtk/WebKitWebViewPrivate.h +++ b/Source/WebKit2/UIProcess/API/gtk/WebKitWebViewPrivate.h @@ -42,6 +42,7 @@ void webkitWebViewClosePage(WebKitWebView*); void webkitWebViewRunJavaScriptAlert(WebKitWebView*, const CString& message); bool webkitWebViewRunJavaScriptConfirm(WebKitWebView*, const CString& message); WKStringRef webkitWebViewRunJavaScriptPrompt(WebKitWebView*, const CString& message, const CString& defaultText); +void webkitWebViewMakePermissionRequest(WebKitWebView*, WebKitPermissionRequest*); void webkitWebViewMakePolicyDecision(WebKitWebView*, WebKitPolicyDecisionType, WebKitPolicyDecision*); void webkitWebViewMouseTargetChanged(WebKitWebView*, WKHitTestResultRef, unsigned modifiers); void webkitWebViewPrintFrame(WebKitWebView*, WKFrameRef); diff --git a/Source/WebKit2/UIProcess/API/gtk/docs/webkit2gtk-docs.sgml b/Source/WebKit2/UIProcess/API/gtk/docs/webkit2gtk-docs.sgml index b6b9aa0b1..90005acb2 100644 --- a/Source/WebKit2/UIProcess/API/gtk/docs/webkit2gtk-docs.sgml +++ b/Source/WebKit2/UIProcess/API/gtk/docs/webkit2gtk-docs.sgml @@ -21,6 +21,7 @@ <xi:include href="xml/WebKitURIResponse.xml"/> <xi:include href="xml/WebKitWindowProperties.xml"/> <xi:include href="xml/WebKitDownload.xml"/> + <xi:include href="xml/WebKitPermissionRequest.xml"/> <xi:include href="xml/WebKitPolicyDecision.xml"/> <xi:include href="xml/WebKitNavigationPolicyDecision.xml"/> <xi:include href="xml/WebKitResponsePolicyDecision.xml"/> diff --git a/Source/WebKit2/UIProcess/API/gtk/docs/webkit2gtk-sections.txt b/Source/WebKit2/UIProcess/API/gtk/docs/webkit2gtk-sections.txt index 05bdeeb51..4251cc4a6 100644 --- a/Source/WebKit2/UIProcess/API/gtk/docs/webkit2gtk-sections.txt +++ b/Source/WebKit2/UIProcess/API/gtk/docs/webkit2gtk-sections.txt @@ -368,6 +368,23 @@ webkit_download_get_type </SECTION> <SECTION> +<FILE>WebKitPermissionRequest</FILE> +WebKitPermissionRequest +webkit_permission_request_allow +webkit_permission_request_deny + +<SUBSECTION Standard> +WebKitPermissionRequestIface +WEBKIT_TYPE_PERMISSION_REQUEST +WEBKIT_PERMISSION_REQUEST +WEBKIT_IS_PERMISSION_REQUEST +WEBKIT_PERMISSION_REQUEST_GET_IFACE + +<SUBSECTION Private> +webkit_permission_request_get_type +</SECTION> + +<SECTION> <FILE>WebKitPolicyDecision</FILE> WebKitPolicyDecision webkit_policy_decision_download diff --git a/Source/WebKit2/UIProcess/API/gtk/webkit2.h b/Source/WebKit2/UIProcess/API/gtk/webkit2.h index 23dbd9903..b58210a80 100644 --- a/Source/WebKit2/UIProcess/API/gtk/webkit2.h +++ b/Source/WebKit2/UIProcess/API/gtk/webkit2.h @@ -36,6 +36,7 @@ #include <webkit2/WebKitHitTestResult.h> #include <webkit2/WebKitJavascriptResult.h> #include <webkit2/WebKitMimeInfo.h> +#include <webkit2/WebKitPermissionRequest.h> #include <webkit2/WebKitPlugin.h> #include <webkit2/WebKitPrintOperation.h> #include <webkit2/WebKitScriptDialog.h> diff --git a/Source/WebKit2/UIProcess/WebBackForwardList.cpp b/Source/WebKit2/UIProcess/WebBackForwardList.cpp index 9ffc9a2c9..4a81a8765 100644 --- a/Source/WebKit2/UIProcess/WebBackForwardList.cpp +++ b/Source/WebKit2/UIProcess/WebBackForwardList.cpp @@ -34,10 +34,9 @@ static const unsigned DefaultCapacity = 100; WebBackForwardList::WebBackForwardList(WebPageProxy* page) : m_page(page) - , m_current(NoCurrentItemIndex) + , m_hasCurrentIndex(false) + , m_currentIndex(0) , m_capacity(DefaultCapacity) - , m_closed(true) - , m_enabled(true) { ASSERT(m_page); } @@ -59,16 +58,16 @@ void WebBackForwardList::pageClosed() void WebBackForwardList::addItem(WebBackForwardListItem* newItem) { - ASSERT(m_current == NoCurrentItemIndex || m_current < m_entries.size()); + ASSERT(!m_hasCurrentIndex || m_currentIndex < m_entries.size()); - if (!m_capacity || !m_enabled || !newItem || !m_page) + if (!m_capacity || !newItem || !m_page) return; Vector<RefPtr<APIObject> > removedItems; - if (m_current != NoCurrentItemIndex) { + if (m_hasCurrentIndex) { // Toss everything in the forward list. - unsigned targetSize = m_current + 1; + unsigned targetSize = m_currentIndex + 1; removedItems.reserveCapacity(m_entries.size() - targetSize); while (m_entries.size() > targetSize) { m_page->backForwardRemovedItem(m_entries.last()->itemID()); @@ -78,11 +77,14 @@ void WebBackForwardList::addItem(WebBackForwardListItem* newItem) // Toss the first item if the list is getting too big, as long as we're not using it // (or even if we are, if we only want 1 entry). - if (m_entries.size() == m_capacity && (m_current || m_capacity == 1)) { + if (m_entries.size() == m_capacity && (m_currentIndex || m_capacity == 1)) { m_page->backForwardRemovedItem(m_entries[0]->itemID()); removedItems.append(m_entries[0].release()); m_entries.remove(0); - m_current--; + if (m_entries.isEmpty()) + m_hasCurrentIndex = false; + else + m_currentIndex--; } } else { // If we have no current item index, we should have no other entries before adding this new item. @@ -94,23 +96,24 @@ void WebBackForwardList::addItem(WebBackForwardListItem* newItem) m_entries.clear(); } - if (m_current == NoCurrentItemIndex) - m_current = 0; - else - m_current++; + if (!m_hasCurrentIndex) { + m_currentIndex = 0; + m_hasCurrentIndex = true; + } else + m_currentIndex++; // m_current never be pointing more than 1 past the end of the entries Vector. // If it is, something has gone wrong and we should not try to insert the new item. - ASSERT(m_current <= m_entries.size()); - if (m_current <= m_entries.size()) - m_entries.insert(m_current, newItem); + ASSERT(m_currentIndex <= m_entries.size()); + if (m_currentIndex <= m_entries.size()) + m_entries.insert(m_currentIndex, newItem); m_page->didChangeBackForwardList(newItem, &removedItems); } void WebBackForwardList::goToItem(WebBackForwardListItem* item) { - ASSERT(m_current == NoCurrentItemIndex || m_current < m_entries.size()); + ASSERT(!m_hasCurrentIndex || m_currentIndex < m_entries.size()); if (!m_entries.size() || !item) return; @@ -121,7 +124,7 @@ void WebBackForwardList::goToItem(WebBackForwardListItem* item) break; } if (index < m_entries.size()) { - m_current = index; + m_currentIndex = index; if (m_page) m_page->didChangeBackForwardList(0, 0); } @@ -129,36 +132,30 @@ void WebBackForwardList::goToItem(WebBackForwardListItem* item) WebBackForwardListItem* WebBackForwardList::currentItem() { - ASSERT(m_current == NoCurrentItemIndex || m_current < m_entries.size()); + ASSERT(!m_hasCurrentIndex || m_currentIndex < m_entries.size()); - if (m_current != NoCurrentItemIndex) - return m_entries[m_current].get(); - return 0; + return m_hasCurrentIndex ? m_entries[m_currentIndex].get() : 0; } WebBackForwardListItem* WebBackForwardList::backItem() { - ASSERT(m_current == NoCurrentItemIndex || m_current < m_entries.size()); + ASSERT(!m_hasCurrentIndex || m_currentIndex < m_entries.size()); - if (m_current && m_current != NoCurrentItemIndex) - return m_entries[m_current - 1].get(); - return 0; + return m_hasCurrentIndex && m_currentIndex ? m_entries[m_currentIndex - 1].get() : 0; } WebBackForwardListItem* WebBackForwardList::forwardItem() { - ASSERT(m_current == NoCurrentItemIndex || m_current < m_entries.size()); + ASSERT(!m_hasCurrentIndex || m_currentIndex < m_entries.size()); - if (m_entries.size() && m_current < m_entries.size() - 1) - return m_entries[m_current + 1].get(); - return 0; + return m_hasCurrentIndex && m_entries.size() && m_currentIndex < m_entries.size() - 1 ? m_entries[m_currentIndex + 1].get() : 0; } WebBackForwardListItem* WebBackForwardList::itemAtIndex(int index) { - ASSERT(m_current == NoCurrentItemIndex || m_current < m_entries.size()); + ASSERT(!m_hasCurrentIndex || m_currentIndex < m_entries.size()); - if (m_current == NoCurrentItemIndex) + if (!m_hasCurrentIndex) return 0; // Do range checks without doing math on index to avoid overflow. @@ -168,26 +165,26 @@ WebBackForwardListItem* WebBackForwardList::itemAtIndex(int index) if (index > forwardListCount()) return 0; - return m_entries[index + m_current].get(); + return m_entries[index + m_currentIndex].get(); } int WebBackForwardList::backListCount() { - ASSERT(m_current == NoCurrentItemIndex || m_current < m_entries.size()); + ASSERT(!m_hasCurrentIndex || m_currentIndex < m_entries.size()); - return m_current == NoCurrentItemIndex ? 0 : m_current; + return !m_hasCurrentIndex ? 0 : m_currentIndex; } int WebBackForwardList::forwardListCount() { - ASSERT(m_current == NoCurrentItemIndex || m_current < m_entries.size()); + ASSERT(!m_hasCurrentIndex || m_currentIndex < m_entries.size()); - return m_current == NoCurrentItemIndex ? 0 : static_cast<int>(m_entries.size()) - (m_current + 1); + return !m_hasCurrentIndex ? 0 : static_cast<int>(m_entries.size()) - (m_currentIndex + 1); } PassRefPtr<ImmutableArray> WebBackForwardList::backListAsImmutableArrayWithLimit(unsigned limit) { - ASSERT(m_current == NoCurrentItemIndex || m_current < m_entries.size()); + ASSERT(!m_hasCurrentIndex || m_currentIndex < m_entries.size()); unsigned backListSize = static_cast<unsigned>(backListCount()); unsigned size = std::min(backListSize, limit); @@ -206,7 +203,7 @@ PassRefPtr<ImmutableArray> WebBackForwardList::backListAsImmutableArrayWithLimit PassRefPtr<ImmutableArray> WebBackForwardList::forwardListAsImmutableArrayWithLimit(unsigned limit) { - ASSERT(m_current == NoCurrentItemIndex || m_current < m_entries.size()); + ASSERT(!m_hasCurrentIndex || m_currentIndex < m_entries.size()); unsigned size = std::min(static_cast<unsigned>(forwardListCount()), limit); if (!size) @@ -215,9 +212,9 @@ PassRefPtr<ImmutableArray> WebBackForwardList::forwardListAsImmutableArrayWithLi Vector<RefPtr<APIObject> > vector; vector.reserveInitialCapacity(size); - unsigned last = m_current + size; + unsigned last = m_currentIndex + size; ASSERT(last < m_entries.size()); - for (unsigned i = m_current + 1; i <= last; ++i) + for (unsigned i = m_currentIndex + 1; i <= last; ++i) vector.uncheckedAppend(m_entries[i].get()); return ImmutableArray::adopt(vector); @@ -225,7 +222,7 @@ PassRefPtr<ImmutableArray> WebBackForwardList::forwardListAsImmutableArrayWithLi void WebBackForwardList::clear() { - ASSERT(m_current == NoCurrentItemIndex || m_current < m_entries.size()); + ASSERT(!m_hasCurrentIndex || m_currentIndex < m_entries.size()); size_t size = m_entries.size(); if (size <= 1) @@ -243,18 +240,18 @@ void WebBackForwardList::clear() Vector<RefPtr<APIObject> > removedItems; removedItems.reserveCapacity(m_entries.size() - 1); for (size_t i = 0; i < m_entries.size(); ++i) { - if (i != m_current) + if (i != m_currentIndex) removedItems.append(m_entries[i].release()); } - m_current = 0; + m_currentIndex = 0; if (currentItem) { m_entries.shrink(1); m_entries[0] = currentItem.release(); } else { m_entries.clear(); - m_current = NoCurrentItemIndex; + m_hasCurrentIndex = false; } if (m_page) diff --git a/Source/WebKit2/UIProcess/WebBackForwardList.h b/Source/WebKit2/UIProcess/WebBackForwardList.h index ead0fca06..97bd2a32f 100644 --- a/Source/WebKit2/UIProcess/WebBackForwardList.h +++ b/Source/WebKit2/UIProcess/WebBackForwardList.h @@ -70,7 +70,7 @@ public: const BackForwardListItemVector& entries() const { return m_entries; } - uint32_t currentIndex() { return m_current; } + uint32_t currentIndex() { return m_currentIndex; } int backListCount(); int forwardListCount(); @@ -83,18 +83,16 @@ public: #endif private: - static const unsigned NoCurrentItemIndex = UINT_MAX; - WebBackForwardList(WebPageProxy*); virtual Type type() const { return APIType; } WebPageProxy* m_page; BackForwardListItemVector m_entries; - uint32_t m_current; - uint32_t m_capacity; - bool m_closed; - bool m_enabled; + + bool m_hasCurrentIndex; + unsigned m_currentIndex; + unsigned m_capacity; }; } // namespace WebKit diff --git a/Source/WebKit2/UIProcess/WebPageProxy.cpp b/Source/WebKit2/UIProcess/WebPageProxy.cpp index 930e79598..2b538e5d8 100644 --- a/Source/WebKit2/UIProcess/WebPageProxy.cpp +++ b/Source/WebKit2/UIProcess/WebPageProxy.cpp @@ -164,7 +164,11 @@ WebPageProxy::WebPageProxy(PageClient* pageClient, PassRefPtr<WebProcessProxy> p , m_pageScaleFactor(1) , m_intrinsicDeviceScaleFactor(1) , m_customDeviceScaleFactor(0) +#if HAVE(LAYER_HOSTING_IN_WINDOW_SERVER) + , m_layerHostingMode(LayerHostingModeInWindowServer) +#else , m_layerHostingMode(LayerHostingModeDefault) +#endif , m_drawsBackground(true) , m_drawsTransparentBackground(false) , m_areMemoryCacheClientCallsEnabled(true) diff --git a/Source/WebKit2/UIProcess/cf/WebBackForwardListCF.cpp b/Source/WebKit2/UIProcess/cf/WebBackForwardListCF.cpp index f5ec6a312..b4885220f 100644 --- a/Source/WebKit2/UIProcess/cf/WebBackForwardListCF.cpp +++ b/Source/WebKit2/UIProcess/cf/WebBackForwardListCF.cpp @@ -53,12 +53,12 @@ DEFINE_STATIC_GETTER(CFStringRef, SessionHistoryEntryDataKey, (CFSTR("SessionHis CFDictionaryRef WebBackForwardList::createCFDictionaryRepresentation(WebPageProxy::WebPageProxySessionStateFilterCallback filter, void* context) const { - ASSERT(m_current == NoCurrentItemIndex || m_current < m_entries.size()); + ASSERT(!m_hasCurrentIndex || m_currentIndex < m_entries.size()); RetainPtr<CFMutableArrayRef> entries(AdoptCF, CFArrayCreateMutable(0, m_entries.size(), &kCFTypeArrayCallBacks)); // We may need to update the current index to account for entries that are filtered by the callback. - CFIndex currentIndex = m_current; + CFIndex currentIndex = m_currentIndex; for (size_t i = 0; i < m_entries.size(); ++i) { // If we somehow ended up with a null entry then we should consider the data invalid and not save session history at all. @@ -67,7 +67,7 @@ CFDictionaryRef WebBackForwardList::createCFDictionaryRepresentation(WebPageProx return 0; if (filter && !filter(toAPI(m_page), WKPageGetSessionHistoryURLValueType(), toURLRef(m_entries[i]->originalURL().impl()), context)) { - if (i <= static_cast<size_t>(m_current)) + if (i <= static_cast<size_t>(m_currentIndex)) currentIndex--; continue; } @@ -89,12 +89,12 @@ CFDictionaryRef WebBackForwardList::createCFDictionaryRepresentation(WebPageProx // If all items before and including the current item were filtered then currentIndex will be -1. // Assuming we didn't start out with NoCurrentItemIndex, we should store "current" to point at the first item. - if (currentIndex == -1 && m_current != NoCurrentItemIndex && CFArrayGetCount(entries.get())) + if (currentIndex == -1 && m_hasCurrentIndex && CFArrayGetCount(entries.get())) currentIndex = 0; // FIXME: We're relying on currentIndex == -1 to mean the exact same thing as NoCurrentItemIndex (UINT_MAX) in unsigned form. // That seems implicit and fragile and we should find a better way of representing the NoCurrentItemIndex case. - if (m_current == NoCurrentItemIndex || !CFArrayGetCount(entries.get())) + if (!m_hasCurrentIndex || !CFArrayGetCount(entries.get())) currentIndex = -1; RetainPtr<CFNumberRef> currentIndexNumber(AdoptCF, CFNumberCreate(0, kCFNumberCFIndexType, ¤tIndex)); @@ -138,9 +138,10 @@ bool WebBackForwardList::restoreFromCFDictionaryRepresentation(CFDictionaryRef d // FIXME: We're relying on currentIndex == -1 to mean the exact same thing as NoCurrentItemIndex (UINT_MAX) in unsigned form. // That seems implicit and fragile and we should find a better way of representing the NoCurrentItemIndex case. - uint32_t currentIndex = currentCFIndex == -1 ? NoCurrentItemIndex : static_cast<uint32_t>(currentCFIndex); + bool hasCurrentIndex = currentCFIndex > -1; + unsigned currentIndex = hasCurrentIndex ? static_cast<unsigned>(currentCFIndex) : 0; - if (currentIndex == NoCurrentItemIndex && size) { + if (!hasCurrentIndex && size) { LOG(SessionState, "WebBackForwardList dictionary representation says there is no current item index, but there is a list of %ld entries - this is bogus", size); return false; } @@ -182,10 +183,8 @@ bool WebBackForwardList::restoreFromCFDictionaryRepresentation(CFDictionaryRef d } m_entries = newEntries; - m_current = currentIndex; - // Perform a sanity check: in case we're out of range, we reset. - if (m_current != NoCurrentItemIndex && m_current >= newEntries.size()) - m_current = NoCurrentItemIndex; + m_hasCurrentIndex = hasCurrentIndex; + m_currentIndex = currentIndex; return true; } |