Title: [146597] trunk/Source/WebKit
Revision
146597
Author
[email protected]
Date
2013-03-22 06:18:22 -0700 (Fri, 22 Mar 2013)

Log Message

[BlackBerry] Add custom BackForwardList client implementation
https://bugs.webkit.org/show_bug.cgi?id=113024

Patch by Carlos Garcia Campos <[email protected]> on 2013-03-22
Reviewed by Rob Buis.

PR 310030
Internally reviewed by Joe Mason.

Source/WebKit:

* PlatformBlackBerry.cmake: Add new files to compilation.

Source/WebKit/blackberry:

Adds a new class BackForwardListBlackBerry that implements
BackForwardList client and wraps the BackForwardListImpl including
the BlackBerry specific changes to notify the API layer when the
BackForwardList changes.

* Api/WebPage.cpp:
(BlackBerry::WebKit::WebPagePrivate::init): Create a
BackForwardListBlackBerry.
(BlackBerry::WebKit::WebPage::getBackForwardList): Use
BackForwardListBlackBerry instead of BackForwardListImpl.
(BlackBerry::WebKit::WebPage::clearBackForwardList): Ditto.
* WebCoreSupport/BackForwardListBlackBerry.cpp: Added.
(WebCore):
(WebCore::BackForwardListBlackBerry::BackForwardListBlackBerry):
(WebCore::BackForwardListBlackBerry::~BackForwardListBlackBerry):
(WebCore::BackForwardListBlackBerry::current):
(WebCore::BackForwardListBlackBerry::notifyBackForwardListChanged):
(WebCore::BackForwardListBlackBerry::addItem):
(WebCore::BackForwardListBlackBerry::goToItem):
(WebCore::BackForwardListBlackBerry::itemAtIndex):
(WebCore::BackForwardListBlackBerry::backListCount):
(WebCore::BackForwardListBlackBerry::forwardListCount):
(WebCore::BackForwardListBlackBerry::isActive):
(WebCore::BackForwardListBlackBerry::close):
(WebCore::BackForwardListBlackBerry::clear):
(WebCore::BackForwardListBlackBerry::entries):
(WebCore::BackForwardListBlackBerry::currentItem):
* WebCoreSupport/BackForwardListBlackBerry.h: Added.
(WebKit):
(WebCore):
(BackForwardListBlackBerry):
(WebCore::BackForwardListBlackBerry::create):
* WebCoreSupport/FrameLoaderClientBlackBerry.cpp:
* WebCoreSupport/FrameLoaderClientBlackBerry.h:
(FrameLoaderClientBlackBerry):

Modified Paths

Added Paths

Diff

Modified: trunk/Source/WebKit/ChangeLog (146596 => 146597)


--- trunk/Source/WebKit/ChangeLog	2013-03-22 12:32:41 UTC (rev 146596)
+++ trunk/Source/WebKit/ChangeLog	2013-03-22 13:18:22 UTC (rev 146597)
@@ -1,3 +1,15 @@
+2013-03-22  Carlos Garcia Campos  <[email protected]>
+
+        [BlackBerry] Add custom BackForwardList client implementation
+        https://bugs.webkit.org/show_bug.cgi?id=113024
+
+        Reviewed by Rob Buis.
+
+        PR 310030
+        Internally reviewed by Joe Mason.
+
+        * PlatformBlackBerry.cmake: Add new files to compilation.
+
 2013-03-21  Roger Fong  <[email protected]>
 
         Unreviewed. Move common props files for VS2010 solution to WebKitLibraries folder and update all projects accordingly.

Modified: trunk/Source/WebKit/PlatformBlackBerry.cmake (146596 => 146597)


--- trunk/Source/WebKit/PlatformBlackBerry.cmake	2013-03-22 12:32:41 UTC (rev 146596)
+++ trunk/Source/WebKit/PlatformBlackBerry.cmake	2013-03-22 13:18:22 UTC (rev 146597)
@@ -97,6 +97,7 @@
     blackberry/Api/WebViewportArguments.cpp
     blackberry/Api/_javascript_Variant.cpp
     blackberry/WebCoreSupport/AutofillManager.cpp
+    blackberry/WebCoreSupport/BackForwardListBlackBerry.cpp
     blackberry/WebCoreSupport/CacheClientBlackBerry.cpp
     blackberry/WebCoreSupport/ChromeClientBlackBerry.cpp
     blackberry/WebCoreSupport/ClientExtension.cpp

Modified: trunk/Source/WebKit/blackberry/Api/WebPage.cpp (146596 => 146597)


--- trunk/Source/WebKit/blackberry/Api/WebPage.cpp	2013-03-22 12:32:41 UTC (rev 146596)
+++ trunk/Source/WebKit/blackberry/Api/WebPage.cpp	2013-03-22 13:18:22 UTC (rev 146597)
@@ -24,7 +24,7 @@
 #include "AuthenticationChallengeManager.h"
 #include "AutofillManager.h"
 #include "BackForwardController.h"
-#include "BackForwardListImpl.h"
+#include "BackForwardListBlackBerry.h"
 #include "BackingStoreClient.h"
 #include "BackingStore_p.h"
 #if ENABLE(BATTERY_STATUS)
@@ -535,6 +535,7 @@
     pageClients.editorClient = editorClient;
     pageClients.dragClient = dragClient;
     pageClients.inspectorClient = m_inspectorClient;
+    pageClients.backForwardClient = BackForwardListBlackBerry::create(this);
 
     m_page = new Page(pageClients);
 #if !defined(PUBLIC_BUILD) || !PUBLIC_BUILD
@@ -4841,7 +4842,7 @@
 // will be used by the client as an opaque reference to identify the item.
 void WebPage::getBackForwardList(SharedArray<BackForwardEntry>& result) const
 {
-    HistoryItemVector entries = static_cast<BackForwardListImpl*>(d->m_page->backForward()->client())->entries();
+    HistoryItemVector entries = static_cast<BackForwardListBlackBerry*>(d->m_page->backForward()->client())->entries();
     result.reset(new BackForwardEntry[entries.size()], entries.size());
 
     for (unsigned i = 0; i < entries.size(); ++i) {
@@ -4927,12 +4928,11 @@
 
 void WebPage::clearBackForwardList(bool keepCurrentPage) const
 {
-    BackForwardListImpl* backForwardList = static_cast<BackForwardListImpl*>(d->m_page->backForward()->client());
+    BackForwardListBlackBerry* backForwardList = static_cast<BackForwardListBlackBerry*>(d->m_page->backForward()->client());
     RefPtr<HistoryItem> currentItem = backForwardList->currentItem();
-    while (!backForwardList->entries().isEmpty())
-        backForwardList->removeItem(backForwardList->entries().last().get());
+    backForwardList->clear();
     if (keepCurrentPage)
-        backForwardList->addItem(currentItem);
+        d->m_page->backForward()->client()->addItem(currentItem);
 }
 
 bool WebPage::isEnableLocalAccessToAllCookies() const

Modified: trunk/Source/WebKit/blackberry/ChangeLog (146596 => 146597)


--- trunk/Source/WebKit/blackberry/ChangeLog	2013-03-22 12:32:41 UTC (rev 146596)
+++ trunk/Source/WebKit/blackberry/ChangeLog	2013-03-22 13:18:22 UTC (rev 146597)
@@ -1,3 +1,49 @@
+2013-03-22  Carlos Garcia Campos  <[email protected]>
+
+        [BlackBerry] Add custom BackForwardList client implementation
+        https://bugs.webkit.org/show_bug.cgi?id=113024
+
+        Reviewed by Rob Buis.
+
+        PR 310030
+        Internally reviewed by Joe Mason.
+
+        Adds a new class BackForwardListBlackBerry that implements
+        BackForwardList client and wraps the BackForwardListImpl including
+        the BlackBerry specific changes to notify the API layer when the
+        BackForwardList changes.
+
+        * Api/WebPage.cpp:
+        (BlackBerry::WebKit::WebPagePrivate::init): Create a
+        BackForwardListBlackBerry.
+        (BlackBerry::WebKit::WebPage::getBackForwardList): Use
+        BackForwardListBlackBerry instead of BackForwardListImpl.
+        (BlackBerry::WebKit::WebPage::clearBackForwardList): Ditto.
+        * WebCoreSupport/BackForwardListBlackBerry.cpp: Added.
+        (WebCore):
+        (WebCore::BackForwardListBlackBerry::BackForwardListBlackBerry):
+        (WebCore::BackForwardListBlackBerry::~BackForwardListBlackBerry):
+        (WebCore::BackForwardListBlackBerry::current):
+        (WebCore::BackForwardListBlackBerry::notifyBackForwardListChanged):
+        (WebCore::BackForwardListBlackBerry::addItem):
+        (WebCore::BackForwardListBlackBerry::goToItem):
+        (WebCore::BackForwardListBlackBerry::itemAtIndex):
+        (WebCore::BackForwardListBlackBerry::backListCount):
+        (WebCore::BackForwardListBlackBerry::forwardListCount):
+        (WebCore::BackForwardListBlackBerry::isActive):
+        (WebCore::BackForwardListBlackBerry::close):
+        (WebCore::BackForwardListBlackBerry::clear):
+        (WebCore::BackForwardListBlackBerry::entries):
+        (WebCore::BackForwardListBlackBerry::currentItem):
+        * WebCoreSupport/BackForwardListBlackBerry.h: Added.
+        (WebKit):
+        (WebCore):
+        (BackForwardListBlackBerry):
+        (WebCore::BackForwardListBlackBerry::create):
+        * WebCoreSupport/FrameLoaderClientBlackBerry.cpp:
+        * WebCoreSupport/FrameLoaderClientBlackBerry.h:
+        (FrameLoaderClientBlackBerry):
+
 2013-03-21  Iris Wu  <[email protected]>
 
         [BlackBerry] Last paragraph can't be selected by touch hold selection if there is no new line after it in subframe.

Added: trunk/Source/WebKit/blackberry/WebCoreSupport/BackForwardListBlackBerry.cpp (0 => 146597)


--- trunk/Source/WebKit/blackberry/WebCoreSupport/BackForwardListBlackBerry.cpp	                        (rev 0)
+++ trunk/Source/WebKit/blackberry/WebCoreSupport/BackForwardListBlackBerry.cpp	2013-03-22 13:18:22 UTC (rev 146597)
@@ -0,0 +1,120 @@
+/*
+ * Copyright (C) 2013 Research In Motion Limited. All rights reserved.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
+ */
+
+#include "config.h"
+#include "BackForwardListBlackBerry.h"
+
+#include "HistoryItem.h"
+#include "WebPage_p.h"
+
+using namespace BlackBerry::WebKit;
+
+namespace WebCore {
+
+BackForwardListBlackBerry::BackForwardListBlackBerry(WebPagePrivate* pagePrivate)
+    : m_impl(BackForwardListImpl::create(pagePrivate->m_page))
+    , m_webPagePrivate(pagePrivate)
+{
+}
+
+BackForwardListBlackBerry::~BackForwardListBlackBerry()
+{
+}
+
+int BackForwardListBlackBerry::current()
+{
+    return m_impl->backListCount();
+}
+
+void BackForwardListBlackBerry::notifyBackForwardListChanged()
+{
+    m_webPagePrivate->m_client->resetBackForwardList(m_impl->entries().size(), current());
+}
+
+void BackForwardListBlackBerry::addItem(PassRefPtr<HistoryItem> prpItem)
+{
+    if (!isActive())
+        return;
+
+    m_impl->addItem(prpItem);
+    notifyBackForwardListChanged();
+}
+
+void BackForwardListBlackBerry::goToItem(HistoryItem* item)
+{
+    if (!m_impl->entries().size() || !item)
+        return;
+
+    int oldIndex = current();
+    m_impl->goToItem(item);
+    if (oldIndex != current())
+        notifyBackForwardListChanged();
+    else {
+        // FIXME: this might not be needed anymore. See PR 310030.
+        // Since the recent pages dialog is in another process, it's possible for
+        // the user to choose an entry after it's been removed from the underlying
+        // BackForwardList (for example, if the current page is in the middle of
+        // the stack and it sets document.location with a timer, clearing the
+        // forward list, while the user has the recent pages dialog open). In this
+        // case the best thing to do is re-add the item at the end of the stack.
+        addItem(item);
+    }
+}
+
+HistoryItem* BackForwardListBlackBerry::itemAtIndex(int index)
+{
+    return m_impl->itemAtIndex(index);
+}
+
+int BackForwardListBlackBerry::backListCount()
+{
+    return m_impl->backListCount();
+}
+
+int BackForwardListBlackBerry::forwardListCount()
+{
+    return m_impl->forwardListCount();
+}
+
+bool BackForwardListBlackBerry::isActive()
+{
+    return m_impl->enabled() && m_impl->capacity();
+}
+
+void BackForwardListBlackBerry::close()
+{
+    return m_impl->close();
+}
+
+void BackForwardListBlackBerry::clear()
+{
+    while (!m_impl->entries().isEmpty())
+        m_impl->removeItem(m_impl->entries().last().get());
+}
+
+HistoryItemVector& BackForwardListBlackBerry::entries()
+{
+    return m_impl->entries();
+}
+
+HistoryItem* BackForwardListBlackBerry::currentItem()
+{
+    return m_impl->currentItem();
+}
+
+}; // namespace WebCore

Added: trunk/Source/WebKit/blackberry/WebCoreSupport/BackForwardListBlackBerry.h (0 => 146597)


--- trunk/Source/WebKit/blackberry/WebCoreSupport/BackForwardListBlackBerry.h	                        (rev 0)
+++ trunk/Source/WebKit/blackberry/WebCoreSupport/BackForwardListBlackBerry.h	2013-03-22 13:18:22 UTC (rev 146597)
@@ -0,0 +1,64 @@
+/*
+ * Copyright (C) 2013 Research In Motion Limited. All rights reserved.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
+ */
+
+#ifndef BackForwardListBlackBerry_h
+#define BackForwardListBlackBerry_h
+
+#include "BackForwardListImpl.h"
+
+namespace BlackBerry {
+namespace WebKit {
+class WebPagePrivate;
+}
+}
+
+namespace WebCore {
+
+class BackForwardListBlackBerry : public WebCore::BackForwardList {
+public:
+    static PassRefPtr<BackForwardListBlackBerry> create(BlackBerry::WebKit::WebPagePrivate* pagePrivate)
+    {
+        return adoptRef(new BackForwardListBlackBerry(pagePrivate));
+    }
+    virtual ~BackForwardListBlackBerry();
+
+    void clear();
+    HistoryItemVector& entries();
+    HistoryItem* currentItem();
+
+private:
+    explicit BackForwardListBlackBerry(BlackBerry::WebKit::WebPagePrivate*);
+
+    virtual void addItem(PassRefPtr<WebCore::HistoryItem>);
+    virtual void goToItem(WebCore::HistoryItem*);
+    virtual WebCore::HistoryItem* itemAtIndex(int);
+    virtual int backListCount();
+    virtual int forwardListCount();
+    virtual bool isActive();
+    virtual void close();
+
+    int current();
+    void notifyBackForwardListChanged();
+
+    RefPtr<BackForwardListImpl> m_impl;
+    BlackBerry::WebKit::WebPagePrivate* m_webPagePrivate;
+};
+
+} // namespace WebCore
+
+#endif // BackForwardListBlackBerry_h

Modified: trunk/Source/WebKit/blackberry/WebCoreSupport/FrameLoaderClientBlackBerry.cpp (146596 => 146597)


--- trunk/Source/WebKit/blackberry/WebCoreSupport/FrameLoaderClientBlackBerry.cpp	2013-03-22 12:32:41 UTC (rev 146596)
+++ trunk/Source/WebKit/blackberry/WebCoreSupport/FrameLoaderClientBlackBerry.cpp	2013-03-22 13:18:22 UTC (rev 146597)
@@ -22,7 +22,6 @@
 #include "AboutData.h"
 #include "AutofillManager.h"
 #include "BackForwardController.h"
-#include "BackForwardListImpl.h"
 #include "BackingStoreClient.h"
 #include "BackingStore_p.h"
 #include "Chrome.h"
@@ -128,22 +127,6 @@
     return m_webPagePrivate->m_webSettings->areCookiesEnabled();
 }
 
-void FrameLoaderClientBlackBerry::dispatchDidAddBackForwardItem(HistoryItem* item) const
-{
-    // Inform the client that the back/forward list has changed.
-    invalidateBackForwardList();
-}
-
-void FrameLoaderClientBlackBerry::dispatchDidRemoveBackForwardItem(HistoryItem* item) const
-{
-    invalidateBackForwardList();
-}
-
-void FrameLoaderClientBlackBerry::dispatchDidChangeBackForwardIndex() const
-{
-    invalidateBackForwardList();
-}
-
 void FrameLoaderClientBlackBerry::dispatchDidChangeLocationWithinPage()
 {
     if (!isMainFrame())
@@ -960,21 +943,6 @@
     return true;
 }
 
-void FrameLoaderClientBlackBerry::invalidateBackForwardList() const
-{
-    notifyBackForwardListChanged();
-}
-
-void FrameLoaderClientBlackBerry::notifyBackForwardListChanged() const
-{
-    BackForwardListImpl* backForwardList = static_cast<BackForwardListImpl*>(m_webPagePrivate->m_page->backForward()->client());
-    ASSERT(backForwardList);
-
-    unsigned listSize = backForwardList->entries().size();
-    unsigned currentIndex = backForwardList->backListCount();
-    m_webPagePrivate->m_client->resetBackForwardList(listSize, currentIndex);
-}
-
 Frame* FrameLoaderClientBlackBerry::dispatchCreatePage(const NavigationAction& navigation)
 {
     WebPage* webPage = m_webPagePrivate->m_client->createWindow(0, 0, -1, -1, WebPageClient::FlagWindowDefault, navigation.url().string(), BlackBerry::Platform::String::emptyString());

Modified: trunk/Source/WebKit/blackberry/WebCoreSupport/FrameLoaderClientBlackBerry.h (146596 => 146597)


--- trunk/Source/WebKit/blackberry/WebCoreSupport/FrameLoaderClientBlackBerry.h	2013-03-22 12:32:41 UTC (rev 146596)
+++ trunk/Source/WebKit/blackberry/WebCoreSupport/FrameLoaderClientBlackBerry.h	2013-03-22 13:18:22 UTC (rev 146597)
@@ -108,9 +108,6 @@
     virtual void updateGlobalHistoryRedirectLinks() { notImplemented(); }
     virtual bool shouldGoToHistoryItem(HistoryItem*) const;
     virtual bool shouldStopLoadingForHistoryItem(HistoryItem*) const;
-    virtual void dispatchDidAddBackForwardItem(HistoryItem*) const;
-    virtual void dispatchDidRemoveBackForwardItem(HistoryItem*) const;
-    virtual void dispatchDidChangeBackForwardIndex() const;
     virtual void dispatchWillUpdateApplicationCache(const ResourceRequest&);
     virtual void dispatchDidLoadFromApplicationCache(const ResourceRequest&);
     virtual void didDisplayInsecureContent() { notImplemented(); }
@@ -187,9 +184,6 @@
     void didFinishOrFailLoading(const ResourceError&);
     bool isMainFrame() const;
 
-    void invalidateBackForwardList() const;
-    void notifyBackForwardListChanged() const;
-
     PolicyAction decidePolicyForExternalLoad(const ResourceRequest &, bool isFragmentScroll);
     void delayPolicyCheckUntilFragmentExists(const String& fragment, FramePolicyFunction);
 
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to