Move some history specific HistoryItem code to WebHistoryItem
authorandersca@apple.com <andersca@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 18 Oct 2016 20:22:58 +0000 (20:22 +0000)
committerandersca@apple.com <andersca@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 18 Oct 2016 20:22:58 +0000 (20:22 +0000)
https://bugs.webkit.org/show_bug.cgi?id=163567

Reviewed by Tim Horton.

Source/WebCore:

* history/HistoryItem.cpp:
(WebCore::HistoryItem::addRedirectURL): Deleted.
(WebCore::HistoryItem::redirectURLs): Deleted.
(WebCore::HistoryItem::setRedirectURLs): Deleted.
* history/HistoryItem.h:

Source/WebKit/mac:

* History/HistoryPropertyList.mm:
(HistoryPropertyListWriter::writeHistoryItem):
* History/WebHistory.mm:
(-[WebHistory _visitedURL:withTitle:method:wasFailure:]):
* History/WebHistoryItem.mm:
(-[WebHistoryItem initFromDictionaryRepresentation:]):
* History/WebHistoryItemInternal.h:
* WebCoreSupport/WebFrameLoaderClient.mm:
(addRedirectURL):
(WebFrameLoaderClient::updateGlobalHistoryRedirectLinks):

Source/WebKit/win:

Remove these, they aren't used.

* WebCoreSupport/WebFrameLoaderClient.cpp:
(WebFrameLoaderClient::updateGlobalHistoryRedirectLinks):
* WebHistory.cpp:
(WebHistory::visitedURL):
* WebHistoryItem.cpp:
(WebHistoryItem::initFromDictionaryRepresentation):
(WebHistoryItem::dictionaryRepresentation):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@207482 268f45cc-cd09-0410-ab3c-d52691b4dbfc

13 files changed:
Source/WebCore/ChangeLog
Source/WebCore/history/HistoryItem.cpp
Source/WebCore/history/HistoryItem.h
Source/WebKit/mac/ChangeLog
Source/WebKit/mac/History/HistoryPropertyList.mm
Source/WebKit/mac/History/WebHistory.mm
Source/WebKit/mac/History/WebHistoryItem.mm
Source/WebKit/mac/History/WebHistoryItemInternal.h
Source/WebKit/mac/WebCoreSupport/WebFrameLoaderClient.mm
Source/WebKit/win/ChangeLog
Source/WebKit/win/WebCoreSupport/WebFrameLoaderClient.cpp
Source/WebKit/win/WebHistory.cpp
Source/WebKit/win/WebHistoryItem.cpp

index bf53d64..4b2bddf 100644 (file)
@@ -1,3 +1,16 @@
+2016-10-17  Anders Carlsson  <andersca@apple.com>
+
+        Move some history specific HistoryItem code to WebHistoryItem
+        https://bugs.webkit.org/show_bug.cgi?id=163567
+
+        Reviewed by Tim Horton.
+
+        * history/HistoryItem.cpp:
+        (WebCore::HistoryItem::addRedirectURL): Deleted.
+        (WebCore::HistoryItem::redirectURLs): Deleted.
+        (WebCore::HistoryItem::setRedirectURLs): Deleted.
+        * history/HistoryItem.h:
+
 2016-10-18  Dave Hyatt  <hyatt@apple.com>
 
         [CSS Parser] Get all the properties turned on
index 6a8993e..9118f8a 100644 (file)
@@ -479,27 +479,6 @@ bool HistoryItem::isCurrentDocument(Document& document) const
     return equalIgnoringFragmentIdentifier(url(), document.url());
 }
 
-void HistoryItem::addRedirectURL(const String& url)
-{
-    if (!m_redirectURLs)
-        m_redirectURLs = std::make_unique<Vector<String>>();
-
-    // Our API allows us to store all the URLs in the redirect chain, but for
-    // now we only have a use for the final URL.
-    (*m_redirectURLs).resize(1);
-    (*m_redirectURLs)[0] = url;
-}
-
-Vector<String>* HistoryItem::redirectURLs() const
-{
-    return m_redirectURLs.get();
-}
-
-void HistoryItem::setRedirectURLs(std::unique_ptr<Vector<String>> redirectURLs)
-{
-    m_redirectURLs = WTFMove(redirectURLs);
-}
-
 void HistoryItem::notifyChanged()
 {
     notifyHistoryItemChanged(this);
index d2ee3bd..9b42d88 100644 (file)
@@ -148,10 +148,6 @@ public:
     bool shouldDoSameDocumentNavigationTo(HistoryItem& otherItem) const;
     bool hasSameFrames(HistoryItem& otherItem) const;
 
-    WEBCORE_EXPORT void addRedirectURL(const String&);
-    WEBCORE_EXPORT Vector<String>* redirectURLs() const;
-    WEBCORE_EXPORT void setRedirectURLs(std::unique_ptr<Vector<String>>);
-
     bool isCurrentDocument(Document&) const;
     
 #if PLATFORM(COCOA)
index f5fe0e0..42a6aa2 100644 (file)
@@ -1,3 +1,21 @@
+2016-10-17  Anders Carlsson  <andersca@apple.com>
+
+        Move some history specific HistoryItem code to WebHistoryItem
+        https://bugs.webkit.org/show_bug.cgi?id=163567
+
+        Reviewed by Tim Horton.
+
+        * History/HistoryPropertyList.mm:
+        (HistoryPropertyListWriter::writeHistoryItem):
+        * History/WebHistory.mm:
+        (-[WebHistory _visitedURL:withTitle:method:wasFailure:]):
+        * History/WebHistoryItem.mm:
+        (-[WebHistoryItem initFromDictionaryRepresentation:]):
+        * History/WebHistoryItemInternal.h:
+        * WebCoreSupport/WebFrameLoaderClient.mm:
+        (addRedirectURL):
+        (WebFrameLoaderClient::updateGlobalHistoryRedirectLinks):
+
 2016-10-18  Eric Carlson  <eric.carlson@apple.com>
 
         [MediaStream] Resolve constraints and enumerate devices in the UI process
index c3ff14d..060a3bf 100644 (file)
@@ -90,7 +90,7 @@ void HistoryPropertyListWriter::writeHistoryItem(BinaryPropertyListObjectStream&
     const String& title = item->title();
     const String& displayTitle = item->alternateTitle();
     double lastVisitedDate = webHistoryItem->_private->_lastVisitedTime;
-    Vector<String>* redirectURLs = item->redirectURLs();
+    Vector<String>* redirectURLs = webHistoryItem->_private->_redirectURLs.get();
 
     // keys
     stream.writeString(m_urlKey);
index 115d16f..7f4272d 100644 (file)
@@ -897,7 +897,7 @@ static inline WebHistoryDateKey dateKey(NSTimeInterval date)
     HistoryItem* item = core(entry);
     item->setLastVisitWasFailure(wasFailure);
 
-    item->setRedirectURLs(nullptr);
+    entry->_private->_redirectURLs = nullptr;
 
     NSArray *entries = [[NSArray alloc] initWithObjects:entry, nil];
     [self _sendNotification:WebHistoryItemsAddedNotification entries:entries];
index 8aa8fb3..3df7dfe 100644 (file)
@@ -354,7 +354,7 @@ WebHistoryItem *kit(HistoryItem* item)
             redirectURLsVector->uncheckedAppend((NSString *)redirectURL);
         }
 
-        core(_private)->setRedirectURLs(WTFMove(redirectURLsVector));
+        _private->_redirectURLs = WTFMove(redirectURLsVector);
     }
 
     NSArray *childDicts = [dict objectForKey:childrenKey];
@@ -441,12 +441,12 @@ WebHistoryItem *kit(HistoryItem* item)
     }
     if (coreItem->lastVisitWasFailure())
         [dict setObject:[NSNumber numberWithBool:YES] forKey:lastVisitWasFailureKey];
-    if (Vector<String>* redirectURLs = coreItem->redirectURLs()) {
+    if (Vector<String>* redirectURLs = _private->_redirectURLs.get()) {
         size_t size = redirectURLs->size();
         ASSERT(size);
         NSMutableArray *result = [[NSMutableArray alloc] initWithCapacity:size];
         for (size_t i = 0; i < size; ++i)
-            [result addObject:(NSString*)redirectURLs->at(i)];
+            [result addObject:(NSString *)redirectURLs->at(i)];
         [dict setObject:result forKey:redirectURLsKey];
         [result release];
     }
@@ -554,7 +554,7 @@ WebHistoryItem *kit(HistoryItem* item)
 
 - (NSArray *)_redirectURLs
 {
-    Vector<String>* redirectURLs = core(_private)->redirectURLs();
+    Vector<String>* redirectURLs = _private->_redirectURLs.get();
     if (!redirectURLs)
         return nil;
 
index fd089f2..0e20e7a 100644 (file)
@@ -29,6 +29,8 @@
 #import "WebBackForwardList.h"
 #import "WebHistoryItemPrivate.h"
 #import <wtf/RefPtr.h>
+#import <wtf/Vector.h>
+#import <wtf/text/WTFString.h>
 
 namespace WebCore {
     class HistoryItem;
@@ -61,5 +63,6 @@ extern void WKNotifyHistoryItemChanged(WebCore::HistoryItem*);
     RefPtr<WebCore::HistoryItem> _historyItem;
 
     NSTimeInterval _lastVisitedTime;
+    std::unique_ptr<Vector<String>> _redirectURLs;
 }
 @end
index 8211d36..8be873b 100644 (file)
@@ -1040,6 +1040,17 @@ void WebFrameLoaderClient::updateGlobalHistory()
     [[WebHistory optionalSharedHistory] _visitedURL:loader->urlForHistory() withTitle:loader->title().string() method:loader->originalRequestCopy().httpMethod() wasFailure:loader->urlForHistoryReflectsFailure()];
 }
 
+static void addRedirectURL(WebHistoryItem *item, const String& url)
+{
+    if (!item->_private->_redirectURLs)
+        item->_private->_redirectURLs = std::make_unique<Vector<String>>();
+
+    // Our API allows us to store all the URLs in the redirect chain, but for
+    // now we only have a use for the final URL.
+    item->_private->_redirectURLs->resize(1);
+    item->_private->_redirectURLs->at(0) = url;
+}
+
 void WebFrameLoaderClient::updateGlobalHistoryRedirectLinks()
 {
     WebView* view = getWebView(m_webFrame.get());
@@ -1055,7 +1066,7 @@ void WebFrameLoaderClient::updateGlobalHistoryRedirectLinks()
                     m_webFrame->_private->url.get(), loader->clientRedirectDestinationForHistory(), m_webFrame.get());
             }
         } else if (WebHistoryItem *item = [[WebHistory optionalSharedHistory] _itemForURLString:loader->clientRedirectSourceForHistory()])
-            core(item)->addRedirectURL(loader->clientRedirectDestinationForHistory());
+            addRedirectURL(item, loader->clientRedirectDestinationForHistory());
     }
 
     if (!loader->serverRedirectSourceForHistory().isNull()) {
@@ -1065,7 +1076,7 @@ void WebFrameLoaderClient::updateGlobalHistoryRedirectLinks()
                     loader->serverRedirectSourceForHistory(), loader->serverRedirectDestinationForHistory(), m_webFrame.get());
             }
         } else if (WebHistoryItem *item = [[WebHistory optionalSharedHistory] _itemForURLString:loader->serverRedirectSourceForHistory()])
-            core(item)->addRedirectURL(loader->serverRedirectDestinationForHistory());
+            addRedirectURL(item, loader->serverRedirectDestinationForHistory());
     }
 }
 
index 2da63d3..e1fa9a1 100644 (file)
@@ -1,3 +1,20 @@
+2016-10-18  Anders Carlsson  <andersca@apple.com>
+
+        Move some history specific HistoryItem code to WebHistoryItem
+        https://bugs.webkit.org/show_bug.cgi?id=163567
+
+        Reviewed by Tim Horton.
+
+        Remove these, they aren't used.
+
+        * WebCoreSupport/WebFrameLoaderClient.cpp:
+        (WebFrameLoaderClient::updateGlobalHistoryRedirectLinks):
+        * WebHistory.cpp:
+        (WebHistory::visitedURL):
+        * WebHistoryItem.cpp:
+        (WebHistoryItem::initFromDictionaryRepresentation):
+        (WebHistoryItem::dictionaryRepresentation):
+
 2016-10-16  Darin Adler  <darin@apple.com>
 
         Move CSS classes from ExceptionCode to Exception
index 2a35ecb..7427e0c 100644 (file)
@@ -740,13 +740,6 @@ void WebFrameLoaderClient::updateGlobalHistoryRedirectLinks()
             BString sourceURL(loader->clientRedirectSourceForHistory());
             BString destURL(loader->clientRedirectDestinationForHistory());
             historyDelegate->didPerformClientRedirectFromURL(webView, sourceURL, destURL, m_webFrame);
-        } else {
-            if (history) {
-                if (COMPtr<IWebHistoryItem> iWebHistoryItem = history->itemForURLString(loader->clientRedirectSourceForHistory())) {
-                    COMPtr<WebHistoryItem> webHistoryItem(Query, iWebHistoryItem);
-                    webHistoryItem->historyItem()->addRedirectURL(loader->clientRedirectDestinationForHistory());
-                }
-            }
         }
     }
 
@@ -755,13 +748,6 @@ void WebFrameLoaderClient::updateGlobalHistoryRedirectLinks()
             BString sourceURL(loader->serverRedirectSourceForHistory());
             BString destURL(loader->serverRedirectDestinationForHistory());
             historyDelegate->didPerformServerRedirectFromURL(webView, sourceURL, destURL, m_webFrame);
-        } else {
-            if (history) {
-                if (COMPtr<IWebHistoryItem> iWebHistoryItem = history->itemForURLString(loader->serverRedirectSourceForHistory())) {
-                    COMPtr<WebHistoryItem> webHistoryItem(Query, iWebHistoryItem);
-                    webHistoryItem->historyItem()->addRedirectURL(loader->serverRedirectDestinationForHistory());
-                }
-            }
         }
     }
 }
index 02e2bfc..aae99eb 100644 (file)
@@ -522,7 +522,6 @@ void WebHistory::visitedURL(const URL& url, const String& title, const String& h
     entryPrivate->setLastVisitWasFailure(wasFailure);
 
     COMPtr<WebHistoryItem> item(Query, entry);
-    item->historyItem()->setRedirectURLs(nullptr);
 
     COMPtr<IPropertyBag> userInfo = createUserInfoFromHistoryItem(
         getNotificationString(kWebHistoryItemsAddedNotification), entry);
index 5fcd866..65d0047 100644 (file)
@@ -124,9 +124,6 @@ HRESULT WebHistoryItem::initFromDictionaryRepresentation(_In_opt_ void* dictiona
     if (lastVisitWasFailure)
         m_historyItem->setLastVisitWasFailure(true);
 
-    if (redirectURLsVector.get())
-        m_historyItem->setRedirectURLs(WTFMove(redirectURLsVector));
-
     return S_OK;
 }
 
@@ -156,22 +153,6 @@ HRESULT WebHistoryItem::dictionaryRepresentation(__deref_out_opt void** dictiona
         ++keyCount;
     }
 
-    if (Vector<String>* redirectURLs = m_historyItem->redirectURLs()) {
-        size_t size = redirectURLs->size();
-        ASSERT(size);
-        CFStringRef* items = new CFStringRef[size];
-        for (size_t i = 0; i < size; ++i)
-            items[i] = redirectURLs->at(i).createCFString().leakRef();
-        CFArrayRef result = CFArrayCreate(0, (const void**)items, size, &kCFTypeArrayCallBacks);
-        for (size_t i = 0; i < size; ++i)
-            CFRelease(items[i]);
-        delete[] items;
-
-        keys[keyCount] = redirectURLsKey;
-        values[keyCount] = result;
-        ++keyCount;
-    }
-
     *dictionaryRef = CFDictionaryCreate(0, keys, values, keyCount, &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks);
     
     for (int i = 0; i < keyCount; ++i)