Title: [219099] trunk
Revision
219099
Author
beid...@apple.com
Date
2017-07-03 15:17:01 -0700 (Mon, 03 Jul 2017)

Log Message

Switch all WebKit API related to favicons from WebIconDatabase over to new WebCore::IconLoader mechanism.
https://bugs.webkit.org/show_bug.cgi?id=174073

Reviewed by Andy Estes.

Source/WebCore:

Covered by existing API test.

* loader/DocumentLoader.cpp:
(WebCore::DocumentLoader::startIconLoading):
* loader/EmptyClients.cpp:
* loader/FrameLoaderClient.h:

Source/WebKit/mac:

WebView now keeps a direct copy of its main frame icon as a member variable.
It populates that variable by finding exactly one Favicon LinkIcon from WebCore and loading it.

This change causes a progression in KVO observation of the mainFrameIcon property as we now
have both the old icon and new icon at the time it changes.

* WebCoreSupport/WebFrameLoaderClient.h:
* WebCoreSupport/WebFrameLoaderClient.mm:
(WebFrameLoaderClient::prepareForDataSourceReplacement):
(WebFrameLoaderClient::getLoadDecisionForIcons):
(WebFrameLoaderClient::finishedLoadingIcon):
(WebFrameLoaderClient::dispatchDidReceiveIcon): Deleted.
(WebFrameLoaderClient::registerForIconNotification): Deleted.

* WebView/WebView.mm:
(+[WebView _setIconLoadingEnabled:]):
(+[WebView _isIconLoadingEnabled]):
(-[WebView mainFrameIcon]):
(-[WebView _setMainFrameIcon:]):
(-[WebView _receivedIconChangedNotification:]): Deleted.
(-[WebView _registerForIconNotification:]): Deleted.
(-[WebView _dispatchDidReceiveIconFromWebFrame:]): Deleted.
* WebView/WebViewData.h:
* WebView/WebViewInternal.h:
* WebView/WebViewPrivate.h:

Source/WebKit/win:

* WebCoreSupport/WebFrameLoaderClient.cpp:
(WebFrameLoaderClient::dispatchDidReceiveIcon): Deleted.
(WebFrameLoaderClient::registerForIconNotification): Deleted.
* WebCoreSupport/WebFrameLoaderClient.h:

Source/WebKit2:

* WebProcess/WebCoreSupport/WebFrameLoaderClient.cpp:
(WebKit::WebFrameLoaderClient::getLoadDecisionForIcons):
(WebKit::WebFrameLoaderClient::dispatchDidReceiveIcon): Deleted.
(WebKit::WebFrameLoaderClient::registerForIconNotification): Deleted.
(WebKit::WebFrameLoaderClient::getLoadDecisionForIcon): Deleted.
* WebProcess/WebCoreSupport/WebFrameLoaderClient.h:

Tools:

* DumpRenderTree/mac/TestRunnerMac.mm:
(TestRunner::setIconDatabaseEnabled): Call new SPI for this setting instead of WebIconDatabase stuff.

* TestWebKitAPI/Tests/mac/WebViewIconLoading.mm:
(-[MainFrameIconKVO observeValueForKeyPath:ofObject:change:context:]):

LayoutTests:

* http/tests/security/contentSecurityPolicy/block-favicon-expected.txt: Updated results to actually catch
  the load being blocked due to CSP.

Modified Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (219098 => 219099)


--- trunk/LayoutTests/ChangeLog	2017-07-03 21:51:01 UTC (rev 219098)
+++ trunk/LayoutTests/ChangeLog	2017-07-03 22:17:01 UTC (rev 219099)
@@ -1,3 +1,13 @@
+2017-07-03  Brady Eidson  <beid...@apple.com>
+
+        Switch all WebKit API related to favicons from WebIconDatabase over to new WebCore::IconLoader mechanism.
+        https://bugs.webkit.org/show_bug.cgi?id=174073
+
+        Reviewed by Andy Estes.
+
+        * http/tests/security/contentSecurityPolicy/block-favicon-expected.txt: Updated results to actually catch
+          the load being blocked due to CSP.
+
 2017-07-03  Matt Lewis  <jlew...@apple.com>
 
         Marked media/track/track-cues-sorted-before-dispatch.html as flaky

Modified: trunk/LayoutTests/http/tests/security/contentSecurityPolicy/block-favicon-expected.txt (219098 => 219099)


--- trunk/LayoutTests/http/tests/security/contentSecurityPolicy/block-favicon-expected.txt	2017-07-03 21:51:01 UTC (rev 219098)
+++ trunk/LayoutTests/http/tests/security/contentSecurityPolicy/block-favicon-expected.txt	2017-07-03 22:17:01 UTC (rev 219099)
@@ -1,4 +1,5 @@
 http://127.0.0.1:8000/security/contentSecurityPolicy/block-favicon.html - didFinishLoading
 http://127.0.0.1:8000/security/contentSecurityPolicy/block-favicon.html - willSendRequest <NSURLRequest URL http://127.0.0.1:8000/security/contentSecurityPolicy/block-favicon.html, main document URL http://127.0.0.1:8000/security/contentSecurityPolicy/block-favicon.html, http method GET> redirectResponse (null)
 http://127.0.0.1:8000/security/contentSecurityPolicy/block-favicon.html - didReceiveResponse <NSURLResponse http://127.0.0.1:8000/security/contentSecurityPolicy/block-favicon.html, http status code 200>
+CONSOLE MESSAGE: Refused to load http://127.0.0.1:8000/misc/resources/favicon.ico because it does not appear in the img-src directive of the Content Security Policy.
 

Modified: trunk/Source/WebCore/ChangeLog (219098 => 219099)


--- trunk/Source/WebCore/ChangeLog	2017-07-03 21:51:01 UTC (rev 219098)
+++ trunk/Source/WebCore/ChangeLog	2017-07-03 22:17:01 UTC (rev 219099)
@@ -1,3 +1,17 @@
+2017-07-03  Brady Eidson  <beid...@apple.com>
+
+        Switch all WebKit API related to favicons from WebIconDatabase over to new WebCore::IconLoader mechanism.
+        https://bugs.webkit.org/show_bug.cgi?id=174073
+
+        Reviewed by Andy Estes.
+
+        Covered by existing API test.
+
+        * loader/DocumentLoader.cpp:
+        (WebCore::DocumentLoader::startIconLoading):
+        * loader/EmptyClients.cpp:
+        * loader/FrameLoaderClient.h:
+
 2017-07-03  Sam Weinig  <s...@webkit.org>
 
         [WebIDL] Remove more unnecessary uses of the preprocessor in idl files

Modified: trunk/Source/WebCore/loader/DocumentLoader.cpp (219098 => 219099)


--- trunk/Source/WebCore/loader/DocumentLoader.cpp	2017-07-03 21:51:01 UTC (rev 219098)
+++ trunk/Source/WebCore/loader/DocumentLoader.cpp	2017-07-03 22:17:01 UTC (rev 219099)
@@ -1673,10 +1673,14 @@
     if (!hasFavicon)
         icons.append({ m_frame->document()->completeURL(ASCIILiteral("/favicon.ico")), LinkIconType::Favicon, String(), std::nullopt });
 
+    Vector<std::pair<WebCore::LinkIcon&, uint64_t>> iconDecisions;
+    iconDecisions.reserveInitialCapacity(icons.size());
     for (auto& icon : icons) {
         auto result = m_iconsPendingLoadDecision.add(nextIconCallbackID++, icon);
-        m_frame->loader().client().getLoadDecisionForIcon(icon, result.iterator->key);
+        iconDecisions.uncheckedAppend({ icon, result.iterator->key });
     }
+
+    m_frame->loader().client().getLoadDecisionForIcons(iconDecisions);
 }
 
 void DocumentLoader::didGetLoadDecisionForIcon(bool decision, uint64_t loadIdentifier, uint64_t newCallbackID)

Modified: trunk/Source/WebCore/loader/EmptyClients.cpp (219098 => 219099)


--- trunk/Source/WebCore/loader/EmptyClients.cpp	2017-07-03 21:51:01 UTC (rev 219098)
+++ trunk/Source/WebCore/loader/EmptyClients.cpp	2017-07-03 22:17:01 UTC (rev 219099)
@@ -325,7 +325,6 @@
     void dispatchDidReplaceStateWithinPage() final { }
     void dispatchDidPopStateWithinPage() final { }
     void dispatchWillClose() final { }
-    void dispatchDidReceiveIcon() final { }
     void dispatchDidStartProvisionalLoad() final { }
     void dispatchDidReceiveTitle(const StringWithDirection&) final { }
     void dispatchDidCommitLoad(std::optional<HasInsecureContent>) final { }
@@ -429,8 +428,6 @@
     void redirectDataToPlugin(Widget&) final { }
     void dispatchDidClearWindowObjectInWorld(DOMWrapperWorld&) final { }
 
-    void registerForIconNotification(bool) final { }
-
 #if PLATFORM(COCOA)
     RemoteAXObjectRef accessibilityRemoteObject() final { return nullptr; }
     NSCachedURLResponse *willCacheResponse(DocumentLoader*, unsigned long, NSCachedURLResponse *response) const final { return response; }

Modified: trunk/Source/WebCore/loader/FrameLoaderClient.h (219098 => 219099)


--- trunk/Source/WebCore/loader/FrameLoaderClient.h	2017-07-03 21:51:01 UTC (rev 219098)
+++ trunk/Source/WebCore/loader/FrameLoaderClient.h	2017-07-03 22:17:01 UTC (rev 219099)
@@ -158,7 +158,7 @@
     virtual void dispatchDidReplaceStateWithinPage() = 0;
     virtual void dispatchDidPopStateWithinPage() = 0;
     virtual void dispatchWillClose() = 0;
-    virtual void dispatchDidReceiveIcon() = 0;
+    virtual void dispatchDidReceiveIcon() { }
     virtual void dispatchDidStartProvisionalLoad() = 0;
     virtual void dispatchDidReceiveTitle(const StringWithDirection&) = 0;
     virtual void dispatchDidCommitLoad(std::optional<HasInsecureContent>) = 0;
@@ -286,7 +286,7 @@
 
     virtual void dispatchDidClearWindowObjectInWorld(DOMWrapperWorld&) = 0;
 
-    virtual void registerForIconNotification(bool listen = true) = 0;
+    virtual void registerForIconNotification() { }
 
 #if PLATFORM(COCOA)
     // Allow an accessibility object to retrieve a Frame parent if there's no PlatformWidget.
@@ -354,7 +354,7 @@
     virtual void didRestoreScrollPosition() { }
 
     virtual bool useIconLoadingClient() { return false; }
-    virtual void getLoadDecisionForIcon(const LinkIcon&, uint64_t) { }
+    virtual void getLoadDecisionForIcons(const Vector<std::pair<WebCore::LinkIcon&, uint64_t>>&) { }
     virtual void finishedLoadingIcon(uint64_t, SharedBuffer*) { }
 };
 

Modified: trunk/Source/WebKit/mac/ChangeLog (219098 => 219099)


--- trunk/Source/WebKit/mac/ChangeLog	2017-07-03 21:51:01 UTC (rev 219098)
+++ trunk/Source/WebKit/mac/ChangeLog	2017-07-03 22:17:01 UTC (rev 219099)
@@ -1,3 +1,36 @@
+2017-07-03  Brady Eidson  <beid...@apple.com>
+
+        Switch all WebKit API related to favicons from WebIconDatabase over to new WebCore::IconLoader mechanism.
+        https://bugs.webkit.org/show_bug.cgi?id=174073
+
+        Reviewed by Andy Estes.
+
+        WebView now keeps a direct copy of its main frame icon as a member variable.
+        It populates that variable by finding exactly one Favicon LinkIcon from WebCore and loading it.
+        
+        This change causes a progression in KVO observation of the mainFrameIcon property as we now
+        have both the old icon and new icon at the time it changes.
+
+        * WebCoreSupport/WebFrameLoaderClient.h:
+        * WebCoreSupport/WebFrameLoaderClient.mm:
+        (WebFrameLoaderClient::prepareForDataSourceReplacement):
+        (WebFrameLoaderClient::getLoadDecisionForIcons):
+        (WebFrameLoaderClient::finishedLoadingIcon):
+        (WebFrameLoaderClient::dispatchDidReceiveIcon): Deleted.
+        (WebFrameLoaderClient::registerForIconNotification): Deleted.
+
+        * WebView/WebView.mm:
+        (+[WebView _setIconLoadingEnabled:]):
+        (+[WebView _isIconLoadingEnabled]):
+        (-[WebView mainFrameIcon]):
+        (-[WebView _setMainFrameIcon:]):
+        (-[WebView _receivedIconChangedNotification:]): Deleted.
+        (-[WebView _registerForIconNotification:]): Deleted.
+        (-[WebView _dispatchDidReceiveIconFromWebFrame:]): Deleted.
+        * WebView/WebViewData.h:
+        * WebView/WebViewInternal.h:
+        * WebView/WebViewPrivate.h:
+
 2017-07-03  Sam Weinig  <s...@webkit.org>
 
         [WebIDL] Remove more unnecessary uses of the preprocessor in idl files

Modified: trunk/Source/WebKit/mac/WebCoreSupport/WebFrameLoaderClient.h (219098 => 219099)


--- trunk/Source/WebKit/mac/WebCoreSupport/WebFrameLoaderClient.h	2017-07-03 21:51:01 UTC (rev 219098)
+++ trunk/Source/WebKit/mac/WebCoreSupport/WebFrameLoaderClient.h	2017-07-03 22:17:01 UTC (rev 219099)
@@ -106,7 +106,6 @@
     void dispatchDidPopStateWithinPage() final;
     
     void dispatchWillClose() final;
-    void dispatchDidReceiveIcon() final;
     void dispatchDidStartProvisionalLoad() final;
     void dispatchDidReceiveTitle(const WebCore::StringWithDirection&) final;
     void dispatchDidCommitLoad(std::optional<WebCore::HasInsecureContent>) final;
@@ -221,8 +220,6 @@
     
     void dispatchDidClearWindowObjectInWorld(WebCore::DOMWrapperWorld&) final;
 
-    void registerForIconNotification(bool listen) final;
-
 #if PLATFORM(IOS)
     bool shouldLoadMediaElementURL(const WebCore::URL&) const final;
 #endif
@@ -253,6 +250,12 @@
 
     void prefetchDNS(const String&) final;
 
+    bool useIconLoadingClient() final { return true; }
+    void getLoadDecisionForIcons(const Vector<std::pair<WebCore::LinkIcon&, uint64_t>>&) final;
+    void finishedLoadingIcon(uint64_t, WebCore::SharedBuffer*) final;
+
+    uint64_t m_activeIconLoadCallbackID { 0 };
+
     RetainPtr<WebFrame> m_webFrame;
 
     RetainPtr<WebFramePolicyListener> m_policyListener;

Modified: trunk/Source/WebKit/mac/WebCoreSupport/WebFrameLoaderClient.mm (219098 => 219099)


--- trunk/Source/WebKit/mac/WebCoreSupport/WebFrameLoaderClient.mm	2017-07-03 21:51:01 UTC (rev 219098)
+++ trunk/Source/WebKit/mac/WebCoreSupport/WebFrameLoaderClient.mm	2017-07-03 22:17:01 UTC (rev 219099)
@@ -76,6 +76,7 @@
 #import <WebCore/AuthenticationCF.h>
 #import <WebCore/AuthenticationMac.h>
 #import <WebCore/BackForwardController.h>
+#import <WebCore/BitmapImage.h>
 #import <WebCore/CachedFrame.h>
 #import <WebCore/Chrome.h>
 #import <WebCore/DNS.h>
@@ -655,15 +656,6 @@
 #endif
 }
 
-void WebFrameLoaderClient::dispatchDidReceiveIcon()
-{
-#if ENABLE(ICONDATABASE)
-    WebView *webView = getWebView(m_webFrame.get());   
-    ASSERT(m_webFrame == [webView mainFrame]);
-    [webView _dispatchDidReceiveIconFromWebFrame:m_webFrame.get()];
-#endif
-}
-
 void WebFrameLoaderClient::dispatchDidStartProvisionalLoad()
 {
     ASSERT(!m_webFrame->_private->provisionalURL);
@@ -1314,6 +1306,8 @@
 
 void WebFrameLoaderClient::prepareForDataSourceReplacement()
 {
+    m_activeIconLoadCallbackID = 0;
+
     if (![m_webFrame.get() _dataSource]) {
         ASSERT(!core(m_webFrame.get())->tree().childCount());
         return;
@@ -2202,13 +2196,6 @@
     }
 }
 
-void WebFrameLoaderClient::registerForIconNotification(bool listen)
-{
-#if ENABLE(ICONDATABASE)
-    [[m_webFrame.get() webView] _registerForIconNotification:listen];
-#endif
-}
-
 Ref<FrameNetworkingContext> WebFrameLoaderClient::createNetworkingContext()
 {
     return WebFrameNetworkingContext::create(core(m_webFrame.get()));
@@ -2289,6 +2276,68 @@
     WebCore::prefetchDNS(hostname);
 }
 
+void WebFrameLoaderClient::getLoadDecisionForIcons(const Vector<std::pair<WebCore::LinkIcon&, uint64_t>>& icons)
+{
+    auto* frame = core(m_webFrame.get());
+    DocumentLoader* documentLoader = frame->loader().documentLoader();
+    ASSERT(documentLoader);
+
+    bool disallowedDueToImageLoadSettings = false;
+    if (!frame->settings().loadsImagesAutomatically() && !frame->settings().loadsSiteIconsIgnoringImageLoadingSetting())
+        disallowedDueToImageLoadSettings = true;
+
+    if (disallowedDueToImageLoadSettings || !frame->isMainFrame() || !documentLoader->url().protocolIsInHTTPFamily() || ![WebView _isIconLoadingEnabled]) {
+        for (auto& icon : icons)
+            documentLoader->didGetLoadDecisionForIcon(false, icon.second, 0);
+
+        return;
+    }
+
+    ASSERT(!m_activeIconLoadCallbackID);
+
+#if !PLATFORM(IOS)
+    // WebKit 1, which only supports one icon per page URL, traditionally has preferred the last icon in case of multiple icons listed.
+    // To preserve that behavior we walk the list backwards.
+    for (auto icon = icons.rbegin(); icon != icons.rend(); ++icon) {
+        if (icon->first.type != LinkIconType::Favicon || m_activeIconLoadCallbackID) {
+            documentLoader->didGetLoadDecisionForIcon(false, icon->second, 0);
+            continue;
+        }
+
+        m_activeIconLoadCallbackID = 1;
+        documentLoader->didGetLoadDecisionForIcon(true, icon->second, m_activeIconLoadCallbackID);
+    }
+#else
+    // No WebCore icon loading on iOS
+    for (auto& icon : icons)
+        documentLoader->didGetLoadDecisionForIcon(false, icon.second, 0);
+#endif
+}
+
+void WebFrameLoaderClient::finishedLoadingIcon(uint64_t callbackID, SharedBuffer* iconData)
+{
+#if !PLATFORM(IOS)
+    ASSERT(m_activeIconLoadCallbackID);
+    ASSERT(callbackID = m_activeIconLoadCallbackID);
+    m_activeIconLoadCallbackID = 0;
+
+    WebView *webView = getWebView(m_webFrame.get());
+    if (!webView)
+        return;
+
+    auto image = BitmapImage::create();
+    if (image->setData(iconData, true) < EncodedDataStatus::SizeAvailable)
+        return;
+
+    NSImage *icon = webGetNSImage(image.ptr(), NSMakeSize(16, 16));
+    if (icon)
+        [webView _setMainFrameIcon:icon];
+#else
+    UNUSED_PARAM(callbackID);
+    UNUSED_PARAM(iconData);
+#endif
+}
+
 @implementation WebFramePolicyListener
 
 + (void)initialize

Modified: trunk/Source/WebKit/mac/WebView/WebView.mm (219098 => 219099)


--- trunk/Source/WebKit/mac/WebView/WebView.mm	2017-07-03 21:51:01 UTC (rev 219098)
+++ trunk/Source/WebKit/mac/WebView/WebView.mm	2017-07-03 22:17:01 UTC (rev 219099)
@@ -800,6 +800,7 @@
 @end
 
 static BOOL continuousSpellCheckingEnabled;
+static BOOL iconLoadingEnabled = YES;
 #if !PLATFORM(IOS)
 static BOOL grammarCheckingEnabled;
 static BOOL automaticQuoteSubstitutionEnabled;
@@ -2411,6 +2412,16 @@
     return newWindowWebView;
 }
 
++ (void)_setIconLoadingEnabled:(BOOL)enabled
+{
+    iconLoadingEnabled = enabled;
+}
+
++ (BOOL)_isIconLoadingEnabled
+{
+    return iconLoadingEnabled;
+}
+
 - (WebInspector *)inspector
 {
     if (!_private->inspector)
@@ -6987,8 +6998,27 @@
 {
     WebCoreThreadViolationCheckRoundThree();
 
-    return [[WebIconDatabase sharedIconDatabase] iconForURL:[[[[self mainFrame] _dataSource] _URL] _web_originalDataAsString] withSize:WebIconSmallSize];
+    if (auto *icon = _private->_mainFrameIcon.get())
+        return icon;
+    
+    return [[WebIconDatabase sharedIconDatabase] defaultIconWithSize:WebIconSmallSize];
 }
+
+- (void)_setMainFrameIcon:(NSImage *)icon
+{
+    if (_private->_mainFrameIcon.get() == icon)
+        return;
+
+    [self _willChangeValueForKey:_WebMainFrameIconKey];
+
+    _private->_mainFrameIcon = icon;
+
+    WebFrameLoadDelegateImplementationCache* cache = &_private->frameLoadDelegateImplementations;
+    if (icon && cache->didReceiveIconForFrameFunc)
+        CallFrameLoadDelegate(cache->didReceiveIconForFrameFunc, self, @selector(webView:didReceiveIcon:forFrame:), icon, [self mainFrame]);
+
+    [self _didChangeValueForKey:_WebMainFrameIconKey];
+}
 #else
 - (NSURL *)mainFrameIconURL
 {
@@ -8969,49 +8999,6 @@
     return _private->becomingFirstResponderFromOutside;
 }
 
-#if ENABLE(ICONDATABASE)
-- (void)_receivedIconChangedNotification:(NSNotification *)notification
-{
-    // Get the URL for this notification
-    NSDictionary *userInfo = [notification userInfo];
-    ASSERT([userInfo isKindOfClass:[NSDictionary class]]);
-    NSString *urlString = [userInfo objectForKey:WebIconNotificationUserInfoURLKey];
-    ASSERT([urlString isKindOfClass:[NSString class]]);
-    
-    // If that URL matches the current main frame, dispatch the delegate call, which will also unregister
-    // us for this notification
-    if ([[self mainFrameURL] isEqualTo:urlString])
-        [self _dispatchDidReceiveIconFromWebFrame:[self mainFrame]];
-}
-
-- (void)_registerForIconNotification:(BOOL)listen
-{
-    if (listen)
-        [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(_receivedIconChangedNotification:) name:WebIconDatabaseDidAddIconNotification object:nil];        
-    else
-        [[NSNotificationCenter defaultCenter] removeObserver:self name:WebIconDatabaseDidAddIconNotification object:nil];
-}
-
-- (void)_dispatchDidReceiveIconFromWebFrame:(WebFrame *)webFrame
-{
-    // FIXME: This willChangeValueForKey call is too late, because the icon has already changed by now.
-    [self _willChangeValueForKey:_WebMainFrameIconKey];
-    
-    // Since we definitely have an icon and are about to send out the delegate call for that, this WebView doesn't need to listen for the general
-    // notification any longer
-    [self _registerForIconNotification:NO];
-
-    WebFrameLoadDelegateImplementationCache* cache = &_private->frameLoadDelegateImplementations;
-    if (cache->didReceiveIconForFrameFunc) {
-        Image* image = iconDatabase().synchronousIconForPageURL(core(webFrame)->document()->url().string(), IntSize(16, 16));
-        if (NSImage *icon = webGetNSImage(image, NSMakeSize(16, 16)))
-            CallFrameLoadDelegate(cache->didReceiveIconForFrameFunc, self, @selector(webView:didReceiveIcon:forFrame:), icon, webFrame);
-    }
-
-    [self _didChangeValueForKey:_WebMainFrameIconKey];
-}
-#endif // ENABLE(ICONDATABASE)
-
 - (void)_addObject:(id)object forIdentifier:(unsigned long)identifier
 {
     ASSERT(!_private->identifierMap.contains(identifier));

Modified: trunk/Source/WebKit/mac/WebView/WebViewData.h (219098 => 219099)


--- trunk/Source/WebKit/mac/WebView/WebViewData.h	2017-07-03 21:51:01 UTC (rev 219098)
+++ trunk/Source/WebKit/mac/WebView/WebViewData.h	2017-07-03 22:17:01 UTC (rev 219099)
@@ -328,6 +328,7 @@
 
 #if !PLATFORM(IOS)
     NSPasteboard *insertionPasteboard;
+    RetainPtr<NSImage> _mainFrameIcon;
 #endif
             
     NSSize lastLayoutSize;

Modified: trunk/Source/WebKit/mac/WebView/WebViewInternal.h (219098 => 219099)


--- trunk/Source/WebKit/mac/WebView/WebViewInternal.h	2017-07-03 21:51:01 UTC (rev 219098)
+++ trunk/Source/WebKit/mac/WebView/WebViewInternal.h	2017-07-03 22:17:01 UTC (rev 219099)
@@ -126,11 +126,6 @@
 
 - (BOOL)_becomingFirstResponderFromOutside;
 
-#if ENABLE(ICONDATABASE)
-- (void)_registerForIconNotification:(BOOL)listen;
-- (void)_dispatchDidReceiveIconFromWebFrame:(WebFrame *)webFrame;
-#endif
-
 - (BOOL)_needsOneShotDrawingSynchronization;
 - (void)_setNeedsOneShotDrawingSynchronization:(BOOL)needsSynchronization;
 - (void)_scheduleCompositingLayerFlush;
@@ -326,4 +321,7 @@
 - (void)showFormValidationMessage:(NSString *)message withAnchorRect:(NSRect)anchorRect;
 - (void)hideFormValidationMessage;
 
+#if !PLATFORM(IOS)
+- (void)_setMainFrameIcon:(NSImage *)icon;
+#endif
 @end

Modified: trunk/Source/WebKit/mac/WebView/WebViewPrivate.h (219098 => 219099)


--- trunk/Source/WebKit/mac/WebView/WebViewPrivate.h	2017-07-03 21:51:01 UTC (rev 219098)
+++ trunk/Source/WebKit/mac/WebView/WebViewPrivate.h	2017-07-03 22:17:01 UTC (rev 219099)
@@ -320,6 +320,9 @@
 
 @interface WebView (WebPrivate)
 
++ (void)_setIconLoadingEnabled:(BOOL)enabled;
++ (BOOL)_isIconLoadingEnabled;
+
 - (WebInspector *)inspector;
 
 #if ENABLE_REMOTE_INSPECTOR

Modified: trunk/Source/WebKit/win/ChangeLog (219098 => 219099)


--- trunk/Source/WebKit/win/ChangeLog	2017-07-03 21:51:01 UTC (rev 219098)
+++ trunk/Source/WebKit/win/ChangeLog	2017-07-03 22:17:01 UTC (rev 219099)
@@ -1,3 +1,15 @@
+2017-07-03  Brady Eidson  <beid...@apple.com>
+
+        Switch all WebKit API related to favicons from WebIconDatabase over to new WebCore::IconLoader mechanism.
+        https://bugs.webkit.org/show_bug.cgi?id=174073
+
+        Reviewed by Andy Estes.
+
+        * WebCoreSupport/WebFrameLoaderClient.cpp:
+        (WebFrameLoaderClient::dispatchDidReceiveIcon): Deleted.
+        (WebFrameLoaderClient::registerForIconNotification): Deleted.
+        * WebCoreSupport/WebFrameLoaderClient.h:
+
 2017-07-01  Ryosuke Niwa  <rn...@webkit.org>
 
         Frame.h doesn't need to include FrameLoader.h, IntRect.h, and NavigationScheduler.h

Modified: trunk/Source/WebKit/win/WebCoreSupport/WebFrameLoaderClient.cpp (219098 => 219099)


--- trunk/Source/WebKit/win/WebCoreSupport/WebFrameLoaderClient.cpp	2017-07-03 21:51:01 UTC (rev 219098)
+++ trunk/Source/WebKit/win/WebCoreSupport/WebFrameLoaderClient.cpp	2017-07-03 22:17:01 UTC (rev 219099)
@@ -403,11 +403,6 @@
         frameLoadDelegate->willCloseFrame(webView, m_webFrame);
 }
 
-void WebFrameLoaderClient::dispatchDidReceiveIcon()
-{
-    m_webFrame->webView()->dispatchDidReceiveIconFromWebFrame(m_webFrame);
-}
-
 void WebFrameLoaderClient::dispatchDidStartProvisionalLoad()
 {
     WebView* webView = m_webFrame->webView();
@@ -1249,11 +1244,6 @@
         frameLoadDelegate->windowScriptObjectAvailable(webView, context, windowObject);
 }
 
-void WebFrameLoaderClient::registerForIconNotification(bool listen)
-{
-    m_webFrame->webView()->registerForIconNotification(listen);
-}
-
 Ref<FrameNetworkingContext> WebFrameLoaderClient::createNetworkingContext()
 {
     return WebFrameNetworkingContext::create(core(m_webFrame));

Modified: trunk/Source/WebKit/win/WebCoreSupport/WebFrameLoaderClient.h (219098 => 219099)


--- trunk/Source/WebKit/win/WebCoreSupport/WebFrameLoaderClient.h	2017-07-03 21:51:01 UTC (rev 219098)
+++ trunk/Source/WebKit/win/WebCoreSupport/WebFrameLoaderClient.h	2017-07-03 22:17:01 UTC (rev 219099)
@@ -87,7 +87,6 @@
     void dispatchDidReplaceStateWithinPage() override;
     void dispatchDidPopStateWithinPage() override;
     void dispatchWillClose() override;
-    void dispatchDidReceiveIcon() override;
     void dispatchDidStartProvisionalLoad() override;
     void dispatchDidReceiveTitle(const WebCore::StringWithDirection&) override;
     void dispatchDidCommitLoad(std::optional<WebCore::HasInsecureContent>) override;
@@ -198,8 +197,6 @@
     COMPtr<WebFramePolicyListener> setUpPolicyListener(WebCore::FramePolicyFunction&&);
     void receivedPolicyDecision(WebCore::PolicyAction);
 
-    void registerForIconNotification(bool listen) override;
-
     bool shouldAlwaysUsePluginDocument(const WTF::String& mimeType) const override;
 
     void prefetchDNS(const String&) override;

Modified: trunk/Source/WebKit2/ChangeLog (219098 => 219099)


--- trunk/Source/WebKit2/ChangeLog	2017-07-03 21:51:01 UTC (rev 219098)
+++ trunk/Source/WebKit2/ChangeLog	2017-07-03 22:17:01 UTC (rev 219099)
@@ -1,3 +1,17 @@
+2017-07-03  Brady Eidson  <beid...@apple.com>
+
+        Switch all WebKit API related to favicons from WebIconDatabase over to new WebCore::IconLoader mechanism.
+        https://bugs.webkit.org/show_bug.cgi?id=174073
+
+        Reviewed by Andy Estes.
+
+        * WebProcess/WebCoreSupport/WebFrameLoaderClient.cpp:
+        (WebKit::WebFrameLoaderClient::getLoadDecisionForIcons):
+        (WebKit::WebFrameLoaderClient::dispatchDidReceiveIcon): Deleted.
+        (WebKit::WebFrameLoaderClient::registerForIconNotification): Deleted.
+        (WebKit::WebFrameLoaderClient::getLoadDecisionForIcon): Deleted.
+        * WebProcess/WebCoreSupport/WebFrameLoaderClient.h:
+
 2017-07-03  Sam Weinig  <s...@webkit.org>
 
         [WebIDL] Remove more unnecessary uses of the preprocessor in idl files

Modified: trunk/Source/WebKit2/WebProcess/WebCoreSupport/WebFrameLoaderClient.cpp (219098 => 219099)


--- trunk/Source/WebKit2/WebProcess/WebCoreSupport/WebFrameLoaderClient.cpp	2017-07-03 21:51:01 UTC (rev 219098)
+++ trunk/Source/WebKit2/WebProcess/WebCoreSupport/WebFrameLoaderClient.cpp	2017-07-03 22:17:01 UTC (rev 219099)
@@ -402,11 +402,6 @@
     notImplemented();
 }
 
-void WebFrameLoaderClient::dispatchDidReceiveIcon()
-{
-    WebProcess::singleton().parentProcessConnection()->send(Messages::WebIconDatabase::DidReceiveIconForPageURL(m_frame->url()), 0);
-}
-
 void WebFrameLoaderClient::dispatchDidStartProvisionalLoad()
 {
     WebPage* webPage = m_frame->page();
@@ -1666,11 +1661,6 @@
     webPage->injectedBundleLoaderClient().willDestroyGlobalObjectForDOMWindowExtension(*webPage, extension);
 }
 
-void WebFrameLoaderClient::registerForIconNotification(bool /*listen*/)
-{
-    notImplemented();
-}
-
 #if PLATFORM(COCOA)
     
 RemoteAXObjectRef WebFrameLoaderClient::accessibilityRemoteObject() 
@@ -1794,10 +1784,14 @@
     return m_useIconLoadingClient;
 }
 
-void WebFrameLoaderClient::getLoadDecisionForIcon(const LinkIcon& icon, uint64_t callbackID)
+void WebFrameLoaderClient::getLoadDecisionForIcons(const Vector<std::pair<WebCore::LinkIcon&, uint64_t>>& icons)
 {
-    if (WebPage* webPage { m_frame->page() })
-        webPage->send(Messages::WebPageProxy::GetLoadDecisionForIcon(icon, CallbackID::fromInteger(callbackID)));
+    auto* webPage = m_frame->page();
+    if (!webPage)
+        return;
+
+    for (auto& icon : icons)
+        webPage->send(Messages::WebPageProxy::GetLoadDecisionForIcon(icon.first, CallbackID::fromInteger(icon.second)));
 }
 
 void WebFrameLoaderClient::finishedLoadingIcon(uint64_t callbackIdentifier, SharedBuffer* data)

Modified: trunk/Source/WebKit2/WebProcess/WebCoreSupport/WebFrameLoaderClient.h (219098 => 219099)


--- trunk/Source/WebKit2/WebProcess/WebCoreSupport/WebFrameLoaderClient.h	2017-07-03 21:51:01 UTC (rev 219098)
+++ trunk/Source/WebKit2/WebProcess/WebCoreSupport/WebFrameLoaderClient.h	2017-07-03 22:17:01 UTC (rev 219099)
@@ -96,7 +96,6 @@
     void dispatchDidReplaceStateWithinPage() final;
     void dispatchDidPopStateWithinPage() final;
     void dispatchWillClose() final;
-    void dispatchDidReceiveIcon() final;
     void dispatchDidStartProvisionalLoad() final;
     void dispatchDidReceiveTitle(const WebCore::StringWithDirection&) final;
     void dispatchDidCommitLoad(std::optional<WebCore::HasInsecureContent>) final;
@@ -220,8 +219,6 @@
     void dispatchWillDisconnectDOMWindowExtensionFromGlobalObject(WebCore::DOMWindowExtension*) final;
     void dispatchDidReconnectDOMWindowExtensionToGlobalObject(WebCore::DOMWindowExtension*) final;
     void dispatchWillDestroyGlobalObjectForDOMWindowExtension(WebCore::DOMWindowExtension*) final;
-
-    void registerForIconNotification(bool listen = true) final;
     
 #if PLATFORM(COCOA)
     RemoteAXObjectRef accessibilityRemoteObject() final;
@@ -260,7 +257,7 @@
     void didRestoreScrollPosition() final;
 
     bool useIconLoadingClient() final;
-    void getLoadDecisionForIcon(const WebCore::LinkIcon&, uint64_t callbackID) final;
+    void getLoadDecisionForIcons(const Vector<std::pair<WebCore::LinkIcon&, uint64_t>>&) final;
     void finishedLoadingIcon(uint64_t callbackIdentifier, WebCore::SharedBuffer*) final;
 
     WebFrame* m_frame;

Modified: trunk/Tools/ChangeLog (219098 => 219099)


--- trunk/Tools/ChangeLog	2017-07-03 21:51:01 UTC (rev 219098)
+++ trunk/Tools/ChangeLog	2017-07-03 22:17:01 UTC (rev 219099)
@@ -1,3 +1,16 @@
+2017-07-03  Brady Eidson  <beid...@apple.com>
+
+        Switch all WebKit API related to favicons from WebIconDatabase over to new WebCore::IconLoader mechanism.
+        https://bugs.webkit.org/show_bug.cgi?id=174073
+
+        Reviewed by Andy Estes.
+
+        * DumpRenderTree/mac/TestRunnerMac.mm:
+        (TestRunner::setIconDatabaseEnabled): Call new SPI for this setting instead of WebIconDatabase stuff.
+
+        * TestWebKitAPI/Tests/mac/WebViewIconLoading.mm:
+        (-[MainFrameIconKVO observeValueForKeyPath:ofObject:change:context:]):
+
 2017-07-03  Matt Lewis  <jlew...@apple.com>
 
         Unreviewed, rolling out r219083.

Modified: trunk/Tools/DumpRenderTree/mac/TestRunnerMac.mm (219098 => 219099)


--- trunk/Tools/DumpRenderTree/mac/TestRunnerMac.mm	2017-07-03 21:51:01 UTC (rev 219098)
+++ trunk/Tools/DumpRenderTree/mac/TestRunnerMac.mm	2017-07-03 22:17:01 UTC (rev 219099)
@@ -465,18 +465,7 @@
 
 void TestRunner::setIconDatabaseEnabled(bool iconDatabaseEnabled)
 {
-#if ENABLE(ICONDATABASE)
-    // FIXME: Workaround <rdar://problem/6480108>
-    static WebIconDatabase *sharedWebIconDatabase = NULL;
-    if (!sharedWebIconDatabase) {
-        if (!iconDatabaseEnabled)
-            return;
-        sharedWebIconDatabase = [WebIconDatabase sharedIconDatabase];
-        if ([sharedWebIconDatabase isEnabled] == iconDatabaseEnabled)
-            return;
-    }
-    [sharedWebIconDatabase setEnabled:iconDatabaseEnabled];
-#endif
+    [WebView _setIconLoadingEnabled:iconDatabaseEnabled];
 }
 
 void TestRunner::setMainFrameIsFirstResponder(bool flag)

Modified: trunk/Tools/TestWebKitAPI/Tests/mac/WebViewIconLoading.mm (219098 => 219099)


--- trunk/Tools/TestWebKitAPI/Tests/mac/WebViewIconLoading.mm	2017-07-03 21:51:01 UTC (rev 219098)
+++ trunk/Tools/TestWebKitAPI/Tests/mac/WebViewIconLoading.mm	2017-07-03 22:17:01 UTC (rev 219099)
@@ -146,12 +146,9 @@
     ASSERT([keyPath isEqualToString:MainFrameIconKeyPath]);
     ASSERT([[object class] isEqual:[WebView class]]);
 
-    // FIXME: As mentioned in a FIXME in WebKit1 code when sending these KVO events, the old icon is already lost by the time we send the event.
-    // The below line should actually be "EXPECT_TRUE" once that bug is fixed.
-    EXPECT_FALSE([[[change objectForKey:NSKeyValueChangeOldKey] TIFFRepresentation] isEqual:[oldImage TIFFRepresentation]]);
+    EXPECT_TRUE([[[change objectForKey:NSKeyValueChangeOldKey] TIFFRepresentation] isEqual:[oldImage TIFFRepresentation]]);
     EXPECT_TRUE([[[change objectForKey:NSKeyValueChangeNewKey] TIFFRepresentation] isEqual:[expectedImage TIFFRepresentation]]);
     EXPECT_TRUE([[((WebView *)object).mainFrameIcon TIFFRepresentation] isEqual:[expectedImage TIFFRepresentation]]);
-
 }
 
 @end
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to