Reviewed by Maciej
Icon loads now take place in WebCore
* WebCore.xcodeproj/project.pbxproj:
* bridge/BrowserExtension.h:
* bridge/mac/BrowserExtensionMac.h:
* bridge/mac/BrowserExtensionMac.mm:
- Moved enforcement of a Mozilla Favicon extension elsewhere
* bridge/mac/FrameMac.h:
* bridge/mac/FrameMac.mm:
(WebCore::FrameMac::originalRequestURL):
- Added accessor to "original request URL"
* bridge/mac/WebCoreFrameBridge.h:
- Removed methods to set the iconURL as all loading is now done in WebCore
- Added call throughs to notify WebKit an Icon is done loading, and a to get the original request URL
* html/HTMLLinkElement.cpp:
(WebCore::HTMLLinkElement::process):
- Moved enforcement of a Mozilla Favicon extension elsewhere
* loader/icon/IconDatabase.cpp:
(WebCore::IconDatabase::setIconURLForPageURL):
- Changed an ASSERT to correctly handle a sketchy (invalid) situation
* loader/icon/IconLoader.h: Added.
* loader/icon/IconLoader.cpp: Added.
(IconLoader::IconLoader):
(IconLoader::createForFrame):
- Static factory method with a private constructor to enforce
"you MUST have a Frame to create an IconLoader" semantics
(IconLoader::~IconLoader):
(IconLoader::startLoading):
(IconLoader::stopLoading):
(IconLoader::receivedData):
- ResourceLoaderClient delegate
(IconLoader::receivedAllData):
- Ditto
* loader/mac/IconLoaderMac.mm: Added.
(IconLoader::receivedResponse):
(IconLoader::notifyIconChanged):
- For now, these are platform specific methods
- One to get the HTTP response code of an icon load
- The other to call through to the app when the icon has changed (loaded)
* page/Frame.h:
* page/Frame.cpp:
(WebCore::Frame::iconURL):
(WebCore::Frame::setIconURL):
- Frame objects now have an inherent icon URL and a way to calculate/access it
(WebCore::Frame::endIfNotLoading):
- This is where we actually kick off the IconLoader
(WebCore::Frame::stop):
- Added call to stop loading the icon
* page/FramePrivate.h:
(WebCore::FramePrivate::FramePrivate):
(WebCore::FramePrivate::~FramePrivate):
- Added the icon URL as a private member
- Added the IconLoader as a private member, and clean it up on deletion
* platform/mac/ResourceLoaderMac.mm:
(WebCore::ResourceLoader::start): Added a valuable ASSERT
WebKit:
Reviewed by Maciej
Add infrastructure to support icon loads taking place in WebCore
Will remove WebKit icon loaders in a later patch
* WebCoreSupport/WebFrameBridge.m:
(-[WebFrameBridge notifyIconChanged:]):
(-[WebFrameBridge originalRequestURL]):
- Nuked two old, obsolete methods
- Added bridge for notifying of an icon change
- Added bridge for getting the "original request URL" which is still needed
until that info is available in the WebCore loaders
* WebView/WebDataSource.m:
(-[WebDataSource _loadIcon]):
- Empty body just for now, as it still gets called - next patch will prune all the old impl out
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@16360
268f45cc-cd09-0410-ab3c-
d52691b4dbfc
+2006-09-13 Brady Eidson <beidson@apple.com>
+
+ Reviewed by Maciej
+
+ Icon loads now take place in WebCore
+
+ * WebCore.xcodeproj/project.pbxproj:
+ * bridge/BrowserExtension.h:
+ * bridge/mac/BrowserExtensionMac.h:
+ * bridge/mac/BrowserExtensionMac.mm:
+ - Moved enforcement of a Mozilla Favicon extension elsewhere
+
+ * bridge/mac/FrameMac.h:
+ * bridge/mac/FrameMac.mm:
+ (WebCore::FrameMac::originalRequestURL):
+ - Added accessor to "original request URL"
+
+ * bridge/mac/WebCoreFrameBridge.h:
+ - Removed methods to set the iconURL as all loading is now done in WebCore
+ - Added call throughs to notify WebKit an Icon is done loading, and a to get the original request URL
+
+ * html/HTMLLinkElement.cpp:
+ (WebCore::HTMLLinkElement::process):
+ - Moved enforcement of a Mozilla Favicon extension elsewhere
+
+ * loader/icon/IconDatabase.cpp:
+ (WebCore::IconDatabase::setIconURLForPageURL):
+ - Changed an ASSERT to correctly handle a sketchy (invalid) situation
+
+ * loader/icon/IconLoader.h: Added.
+ * loader/icon/IconLoader.cpp: Added.
+ (IconLoader::IconLoader):
+ (IconLoader::createForFrame):
+ - Static factory method with a private constructor to enforce
+ "you MUST have a Frame to create an IconLoader" semantics
+ (IconLoader::~IconLoader):
+ (IconLoader::startLoading):
+ (IconLoader::stopLoading):
+ (IconLoader::receivedData):
+ - ResourceLoaderClient delegate
+ (IconLoader::receivedAllData):
+ - Ditto
+
+ * loader/mac/IconLoaderMac.mm: Added.
+ (IconLoader::receivedResponse):
+ (IconLoader::notifyIconChanged):
+ - For now, these are platform specific methods
+ - One to get the HTTP response code of an icon load
+ - The other to call through to the app when the icon has changed (loaded)
+
+ * page/Frame.h:
+ * page/Frame.cpp:
+ (WebCore::Frame::iconURL):
+ (WebCore::Frame::setIconURL):
+ - Frame objects now have an inherent icon URL and a way to calculate/access it
+ (WebCore::Frame::endIfNotLoading):
+ - This is where we actually kick off the IconLoader
+ (WebCore::Frame::stop):
+ - Added call to stop loading the icon
+
+ * page/FramePrivate.h:
+ (WebCore::FramePrivate::FramePrivate):
+ (WebCore::FramePrivate::~FramePrivate):
+ - Added the icon URL as a private member
+ - Added the IconLoader as a private member, and clean it up on deletion
+
+ * platform/mac/ResourceLoaderMac.mm:
+ (WebCore::ResourceLoader::start): Added a valuable ASSERT
+
2006-09-13 David Hyatt <hyatt@apple.com>
Fix for 10841, unable to check checkboxes inside labels.
5126E6BF0A2E3B29005C29FA /* WebCoreIconDatabaseBridge.h in Headers */ = {isa = PBXBuildFile; fileRef = 5126E6BD0A2E3B29005C29FA /* WebCoreIconDatabaseBridge.h */; settings = {ATTRIBUTES = (Private, ); }; };
5126E6C00A2E3B29005C29FA /* WebCoreIconDatabaseBridge.mm in Sources */ = {isa = PBXBuildFile; fileRef = 5126E6BE0A2E3B29005C29FA /* WebCoreIconDatabaseBridge.mm */; };
51386EE70AB4F0D5004AF79E /* IntSizeHash.h in Headers */ = {isa = PBXBuildFile; fileRef = 51386EE60AB4F0D5004AF79E /* IntSizeHash.h */; };
+ 513F14530AB634C400094DDF /* IconLoader.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 513F14510AB634C400094DDF /* IconLoader.cpp */; };
+ 513F14540AB634C400094DDF /* IconLoader.h in Headers */ = {isa = PBXBuildFile; fileRef = 513F14520AB634C400094DDF /* IconLoader.h */; };
5186C0560A9C21470034FE94 /* IconDataCache.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 5186C0550A9C21470034FE94 /* IconDataCache.cpp */; };
+ 51A1D2C60AB69120000D732C /* IconLoaderMac.mm in Sources */ = {isa = PBXBuildFile; fileRef = 51A1D2C50AB69120000D732C /* IconLoaderMac.mm */; };
51D3EA160A3D24D300BADA35 /* SQLDatabase.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 51D3EA130A3D24D300BADA35 /* SQLDatabase.cpp */; };
51D3EA170A3D24D300BADA35 /* SQLDatabase.h in Headers */ = {isa = PBXBuildFile; fileRef = 51D3EA140A3D24D300BADA35 /* SQLDatabase.h */; };
51D3EA180A3D24D300BADA35 /* SQLStatement.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 51D3EA150A3D24D300BADA35 /* SQLStatement.cpp */; };
5126E6BD0A2E3B29005C29FA /* WebCoreIconDatabaseBridge.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = WebCoreIconDatabaseBridge.h; sourceTree = "<group>"; };
5126E6BE0A2E3B29005C29FA /* WebCoreIconDatabaseBridge.mm */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.objcpp; path = WebCoreIconDatabaseBridge.mm; sourceTree = "<group>"; };
51386EE60AB4F0D5004AF79E /* IntSizeHash.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = IntSizeHash.h; sourceTree = "<group>"; };
+ 513F14510AB634C400094DDF /* IconLoader.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = IconLoader.cpp; sourceTree = "<group>"; };
+ 513F14520AB634C400094DDF /* IconLoader.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = IconLoader.h; sourceTree = "<group>"; };
5150C2A10702629000AF642C /* WebDashboardRegion.h */ = {isa = PBXFileReference; fileEncoding = 30; indentWidth = 4; lastKnownFileType = sourcecode.c.h; path = WebDashboardRegion.h; sourceTree = "<group>"; tabWidth = 8; usesTabs = 0; };
5150C2A50702629800AF642C /* WebDashboardRegion.m */ = {isa = PBXFileReference; fileEncoding = 30; indentWidth = 4; lastKnownFileType = sourcecode.c.objc; path = WebDashboardRegion.m; sourceTree = "<group>"; tabWidth = 8; usesTabs = 0; };
5186C0550A9C21470034FE94 /* IconDataCache.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = IconDataCache.cpp; sourceTree = "<group>"; };
+ 51A1D2C50AB69120000D732C /* IconLoaderMac.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = IconLoaderMac.mm; sourceTree = "<group>"; };
51D3EA130A3D24D300BADA35 /* SQLDatabase.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = SQLDatabase.cpp; sourceTree = "<group>"; };
51D3EA140A3D24D300BADA35 /* SQLDatabase.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = SQLDatabase.h; sourceTree = "<group>"; };
51D3EA150A3D24D300BADA35 /* SQLStatement.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = SQLStatement.cpp; sourceTree = "<group>"; };
5186C0550A9C21470034FE94 /* IconDataCache.cpp */,
5126E6BA0A2E3B12005C29FA /* IconDatabase.h */,
5126E6B90A2E3B12005C29FA /* IconDatabase.cpp */,
+ 513F14520AB634C400094DDF /* IconLoader.h */,
+ 513F14510AB634C400094DDF /* IconLoader.cpp */,
51D3EA140A3D24D300BADA35 /* SQLDatabase.h */,
51D3EA130A3D24D300BADA35 /* SQLDatabase.cpp */,
657429150A9C2D0B00C52C97 /* SQLStatement.h */,
93A1EAA70A563508006960A0 /* ImageDocumentMac.h */,
93A1EA9F0A5634C9006960A0 /* ImageDocumentMac.mm */,
F587850302DE375901EA4122 /* LoaderFunctionsMac.mm */,
+ 51A1D2C50AB69120000D732C /* IconLoaderMac.mm */,
);
path = mac;
sourceTree = "<group>";
85E9E0A50AB3A0C700069CD0 /* DOMXPathResult.h in Headers */,
51386EE70AB4F0D5004AF79E /* IntSizeHash.h in Headers */,
06E81ED70AB5D5E900C87837 /* LocalCurrentGraphicsContext.h in Headers */,
+ 513F14540AB634C400094DDF /* IconLoader.h in Headers */,
066C772B0AB603B700238CC4 /* FileChooser.h in Headers */,
066C77310AB603FD00238CC4 /* RenderFileUploadControl.h in Headers */,
066C773C0AB6052700238CC4 /* Icon.h in Headers */,
0867D690FE84028FC02AAC07 /* Project object */ = {
isa = PBXProject;
buildConfigurationList = 149C284308902B11008A9EFC /* Build configuration list for PBXProject "WebCore" */;
- compatibilityVersion = "Xcode 2.4";
hasScannedForEncodings = 1;
knownRegions = (
English,
productRefGroup = 034768DFFF38A50411DB9C8B /* Products */;
projectDirPath = "";
projectRoot = "";
- shouldCheckCompatibility = 1;
targets = (
93F198A508245E59001E9ABC /* WebCore */,
DD041FBE09D9DDBE0010AF2A /* Derived Sources */,
85E9E0A20AB3A0C700069CD0 /* DOMXPathExpression.mm in Sources */,
85E9E0A60AB3A0C700069CD0 /* DOMXPathResult.mm in Sources */,
06E81EEC0AB5DA9700C87837 /* LocalCurrentGraphicsContext.mm in Sources */,
+ 513F14530AB634C400094DDF /* IconLoader.cpp in Sources */,
+ 51A1D2C60AB69120000D732C /* IconLoaderMac.mm in Sources */,
066C772D0AB603D200238CC4 /* FileChooserMac.mm in Sources */,
066C77300AB603FD00238CC4 /* RenderFileUploadControl.cpp in Sources */,
066C773E0AB6053F00238CC4 /* IconMac.mm in Sources */,
virtual void createNewWindow(const ResourceRequest&) = 0;
virtual void createNewWindow(const ResourceRequest&, const WindowArgs&, Frame*&) = 0;
- virtual void setIconURL(const KURL&) = 0;
- virtual void setTypedIconURL(const KURL&, const String& type) = 0;
-
virtual int getHistoryLength() = 0;
virtual void goBackOrForward(int distance) = 0;
virtual KURL historyURL(int distance) = 0;
const WindowArgs&,
Frame*& part);
- virtual void setIconURL(const KURL&);
- virtual void setTypedIconURL(const KURL&, const String& type);
-
virtual int getHistoryLength();
virtual void goBackOrForward(int distance);
virtual KURL historyURL(int distance);
END_BLOCK_OBJC_EXCEPTIONS;
}
-void BrowserExtensionMac::setIconURL(const KURL &url)
-{
- BEGIN_BLOCK_OBJC_EXCEPTIONS;
- [m_frame->bridge() setIconURL:url.getNSURL()];
- END_BLOCK_OBJC_EXCEPTIONS;
-}
-
-void BrowserExtensionMac::setTypedIconURL(const KURL &url, const String &type)
-{
- BEGIN_BLOCK_OBJC_EXCEPTIONS;
- [m_frame->bridge() setIconURL:url.getNSURL() withType:type];
- END_BLOCK_OBJC_EXCEPTIONS;
-}
-
int BrowserExtensionMac::getHistoryLength()
{
return [m_frame->bridge() historyLength];
void paintCustomHighlight(const AtomicString& type, const FloatRect& boxRect, const FloatRect& lineRect, bool text, bool line);
NSEvent* currentEvent() { return _currentEvent; }
-
+ KURL originalRequestURL() const;
+
protected:
virtual void startRedirectionTimer();
virtual void stopRedirectionTimer();
[bridge() paintCustomHighlight:type forBox:boxRect onLine:lineRect behindText:text entireLine:line];
}
+KURL FrameMac::originalRequestURL() const
+{
+ return [_bridge originalRequestURL];
+}
+
}
- (void)setTitle:(NSString *)title;
- (void)setStatusText:(NSString *)status;
-- (void)setIconURL:(NSURL *)URL;
-- (void)setIconURL:(NSURL *)URL withType:(NSString *)string;
-
- (WebCoreFrameBridge *)createChildFrameNamed:(NSString *)frameName withURL:(NSURL *)URL
referrer:(NSString *)referrer
ownerElement:(WebCoreElement *)ownerElement
- (NSURLResponse*)mainResourceURLResponse;
- (NSString*)imageTitleForFilename:(NSString*)filename size:(NSSize)size;
+- (void)notifyIconChanged:(NSURL*)iconURL;
+- (NSURL*)originalRequestURL;
@end
// This interface definition allows those who hold a WebCoreFrameBridge * to call all the methods
Frame* frame = document()->frame();
// IE extension: location of small icon for locationbar / bookmarks
- if (frame && m_isIcon && !m_url.isEmpty() && !frame->tree()->parent()) {
- if (!type.isEmpty()) // Mozilla extension to IE extension: icon specified with type
- frame->browserExtension()->setTypedIconURL(KURL(m_url.deprecatedString()), type);
- else
- frame->browserExtension()->setIconURL(KURL(m_url.deprecatedString()));
- }
+ if (frame && m_isIcon && !m_url.isEmpty() && !frame->tree()->parent())
+ frame->setIconURL(m_url, type);
// Stylesheet
// This was buggy and would incorrectly match <link rel="alternate">, which has a different specified meaning. -dwh
bool IconDatabase::setIconURLForPageURL(const String& iconURL, const String& pageURL)
{
ASSERT(!iconURL.isEmpty());
- ASSERT(!pageURL.isEmpty());
+ if (pageURL.isEmpty())
+ return false;
// If the urls already map to each other, bail.
// This happens surprisingly often, and seems to cream iBench performance
--- /dev/null
+/*
+ * Copyright (C) 2006 Apple Computer, Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "IconLoader.h"
+
+#include "dom/Document.h"
+#include "FrameMac.h"
+#include "loader/icon/IconDatabase.h"
+#include "Logging.h"
+#include "page/Frame.h"
+
+using namespace WebCore;
+
+IconLoader::IconLoader(Frame* frame)
+ : m_resourceLoader(0)
+ , m_frame(frame)
+ , m_httpStatusCode(0)
+{
+}
+
+IconLoader* IconLoader::createForFrame(Frame* frame)
+{
+ if (frame)
+ return new IconLoader(frame);
+ return 0;
+}
+
+IconLoader::~IconLoader()
+{
+ delete m_resourceLoader;
+}
+
+void IconLoader::startLoading()
+{
+ if (m_resourceLoader)
+ return;
+
+ m_httpStatusCode = 0;
+ m_resourceLoader = new ResourceLoader(this, "GET", m_frame->iconURL());
+
+ ASSERT(m_frame->document());
+ if (!m_resourceLoader->start(m_frame->document()->docLoader())) {
+ LOG_ERROR("Failed to start load for icon at url %s", m_frame->iconURL().url().ascii());
+ delete m_resourceLoader;
+ m_resourceLoader = 0;
+ return;
+ }
+}
+
+void IconLoader::stopLoading()
+{
+ delete m_resourceLoader;
+ m_resourceLoader = 0;
+ m_data.clear();
+}
+
+void IconLoader::receivedData(ResourceLoader* resourceLoader, const char* data, int size)
+{
+ ASSERT(resourceLoader = m_resourceLoader);
+ ASSERT(data);
+ ASSERT(size > -1);
+
+ for (int i=0; i<size; ++i)
+ m_data.append(data[i]);
+}
+
+void IconLoader::receivedAllData(ResourceLoader* resourceLoader)
+{
+ ASSERT(resourceLoader == m_resourceLoader);
+
+ const char* data;
+ int size;
+
+ // If we logged an HTTP response, only set the icon data if it was a valid response
+ if (m_httpStatusCode && (m_httpStatusCode < 200 || m_httpStatusCode > 299)) {
+ data = 0;
+ size = 0;
+ } else {
+ data = m_data.data();
+ size = m_data.size();
+ }
+
+ IconDatabase * iconDatabase = IconDatabase::sharedIconDatabase();
+ ASSERT(iconDatabase);
+
+ KURL iconURL(resourceLoader->url());
+
+ if (data)
+ iconDatabase->setIconDataForIconURL(data, size, iconURL.url());
+ else
+ iconDatabase->setHaveNoIconForIconURL(iconURL.url());
+
+ // We set both the original request URL and the final URL as the PageURLs as different parts
+ // of the app tend to want to retain both
+ iconDatabase->setIconURLForPageURL(iconURL.url(), m_frame->url().url());
+ FrameMac* frameMac = Mac(m_frame);
+ iconDatabase->setIconURLForPageURL(iconURL.url(), frameMac->originalRequestURL().url());
+
+ notifyIconChanged(iconURL);
+
+ // ResourceLoaders delete themselves after they deliver their last data, so we can just forget about it
+ m_resourceLoader = 0;
+ m_data.clear();
+}
+
--- /dev/null
+/*
+ * Copyright (C) 2006 Apple Computer, Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+#ifndef ICONLOADER_H_
+#define ICONLOADER_H_
+
+#include <ResourceLoader.h>
+
+namespace WebCore {
+
+class Frame;
+
+class IconLoader : public ResourceLoaderClient
+{
+public:
+ static IconLoader* createForFrame(Frame* frame);
+ ~IconLoader();
+
+ void startLoading();
+ void stopLoading();
+
+// ResourceLoaderClient delegate methods
+ virtual void receivedResponse(ResourceLoader*, PlatformResponse);
+ virtual void receivedData(ResourceLoader*, const char*, int);
+ virtual void receivedAllData(ResourceLoader*);
+private:
+ IconLoader(Frame* frame);
+
+ void notifyIconChanged(const KURL& iconURL);
+
+ ResourceLoader* m_resourceLoader;
+ Frame* m_frame;
+
+ static const int IconLoaderDefaultBuffer = 4096;
+ Vector<char, IconLoaderDefaultBuffer> m_data;
+ int m_httpStatusCode;
+}; // class Iconloader
+
+}; // namespace WebCore
+
+#endif
--- /dev/null
+/*
+ * Copyright (C) 2006 Apple Computer, Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "IconLoader.h"
+
+#include "FrameMac.h"
+#include "WebCoreFrameBridge.h"
+
+using namespace WebCore;
+
+void IconLoader::receivedResponse(ResourceLoader* resourceLoader, NSURLResponse* responsePtr)
+{
+ ASSERT(resourceLoader);
+ ASSERT(responsePtr);
+
+ id response = responsePtr;
+ if ([response isKindOfClass:[NSHTTPURLResponse class]])
+ m_httpStatusCode = [response statusCode];
+ else
+ m_httpStatusCode = 0;
+}
+
+void IconLoader::notifyIconChanged(const KURL& iconURL)
+{
+ FrameMac* frame = Mac(m_frame);
+ [frame->bridge() notifyIconChanged:iconURL.getNSURL()];
+}
+
#include "config.h"
#include "Frame.h"
+#include "FrameMac.h"
#include "FramePrivate.h"
#include "ApplyStyleCommand.h"
#include "HTMLNames.h"
#include "HTMLObjectElement.h"
#include "HTMLViewSourceDocument.h"
+#include "IconDatabase.h"
+#include "IconLoader.h"
#include "ImageDocument.h"
#include "MediaFeatureNames.h"
#include "MouseEventWithHitTestResults.h"
d = 0;
}
+KURL Frame::iconURL()
+{
+ // If this isn't a top level frame, return nothing
+ if (tree() && tree()->parent())
+ return "";
+
+ // If we have an iconURL from a Link element, return that
+ if (!d->m_iconURL.isEmpty())
+ return KURL(d->m_iconURL.deprecatedString());
+
+ // Don't return a favicon iconURL unless we're http or https
+ if (d->m_url.protocol() != "http" && d->m_url.protocol() != "https")
+ return "";
+
+ KURL url = d->m_url;
+ url.setPath("/favicon.ico");
+ return url;
+}
+
+void Frame::setIconURL(const String& url, const String& type)
+{
+ // FIXME - <rdar://problem/4727645> - At some point in the future, we might actually honor the "type"
+ if (d->m_iconURL.isEmpty())
+ d->m_iconURL = url;
+ else if (!type.isEmpty())
+ d->m_iconURL = url;
+}
+
bool Frame::didOpenURL(const KURL& url)
{
if (d->m_scheduledRedirection == locationChangeScheduledDuringLoad) {
// become true. An example is when a subframe is a pure text doc, and that subframe is the
// last one to complete.
checkCompleted();
+
+ // Don't load an icon if -
+ // 1) This is not the main frame
+ // 2) The database is disabled
+ // 3) We have no valid icon URL
+ // 4) We already have an unexpired icon
+
+ if (tree()->parent())
+ return;
+
+ // FIXME - <rdar://problem/4729797> - To honor #2, we need to add the isEnabled() flag to WebCore::IconDatabase
+
+ String url(iconURL().url());
+ if (url.isEmpty())
+ return;
+
+ IconDatabase* sharedIconDatabase = IconDatabase::sharedIconDatabase();
+ if (sharedIconDatabase->hasEntryForIconURL(url) && !sharedIconDatabase->isIconExpiredForIconURL(url))
+ return;
+
+ if (!d->m_iconLoader)
+ d->m_iconLoader = IconLoader::createForFrame(this);
+ d->m_iconLoader->startLoading();
}
void Frame::stop()
// become true. An example is when a subframe is a pure text doc, and that subframe is the
// last one to complete.
checkCompleted();
+ if (d->m_iconLoader)
+ d->m_iconLoader->stopLoading();
}
void Frame::gotoAnchor()
void didExplicitOpen();
+ KURL iconURL();
+ void setIconURL(const String& url, const String& type);
+
Page* page() const;
void pageDestroyed();
virtual void urlSelected(const DeprecatedString& url, const String& target);
virtual void urlSelected(const ResourceRequest&, const String& target);
-
// Methods with platform-specific overrides (and no base class implementation).
virtual void setTitle(const String&) = 0;
virtual void handledOnloadEvents() = 0;
void updateBaseURLForEmptyDocument();
KURL url() const;
+
void setResourceRequest(const ResourceRequest& request);
const ResourceRequest& resourceRequest() const;
#include "EditCommand.h"
#include "Frame.h"
#include "FrameTree.h"
+#include "IconLoader.h"
#include "SelectionController.h"
#include "StringHash.h"
#include "Timer.h"
class Decoder;
class UserStyleSheetLoader;
+ class IconLoader;
enum RedirectionScheduled {
noRedirectionScheduled,
, m_cancelWithLoadInProgress(false)
, m_lifeSupportTimer(thisFrame, &Frame::lifeSupportTimerFired)
, m_userStyleSheetLoader(0)
+ , m_iconLoader(0)
, m_autoscrollTimer(thisFrame, &Frame::autoscrollTimerFired)
, m_autoscrollLayer(0)
, m_paintRestriction(PaintRestrictionNone)
{
delete m_extension;
delete m_jscript;
+ delete m_iconLoader;
}
Page* m_page;
String m_referrer;
+ String m_iconURL;
+
struct SubmitForm {
const char* submitAction;
String submitUrl;
Timer<Frame> m_lifeSupportTimer;
UserStyleSheetLoader* m_userStyleSheetLoader;
+ IconLoader* m_iconLoader;
Timer<Frame> m_autoscrollTimer;
RenderLayer* m_autoscrollLayer;
bool ResourceLoader::start(DocLoader* docLoader)
{
+ ASSERT(docLoader);
+
FrameMac* frame = Mac(docLoader->frame());
if (!frame) {
delete this;
+2006-09-13 Brady Eidson <beidson@apple.com>
+
+ Reviewed by Maciej
+
+ Add infrastructure to support icon loads taking place in WebCore
+ Will remove WebKit icon loaders in a later patch
+
+ * WebCoreSupport/WebFrameBridge.m:
+ (-[WebFrameBridge notifyIconChanged:]):
+ (-[WebFrameBridge originalRequestURL]):
+ - Nuked two old, obsolete methods
+ - Added bridge for notifying of an icon change
+ - Added bridge for getting the "original request URL" which is still needed
+ until that info is available in the WebCore loaders
+
+ * WebView/WebDataSource.m:
+ (-[WebDataSource _loadIcon]):
+ - Empty body just for now, as it still gets called - next patch will prune all the old impl out
+
2006-09-13 Timothy Hatcher <timothy@apple.com>
Reviewed by Tim O.
#import "WebFormDelegate.h"
#import "WebFrameInternal.h"
#import "WebFrameLoadDelegate.h"
+#import "WebFrameLoader.h"
#import "WebFrameViewInternal.h"
#import "WebHTMLRepresentationPrivate.h"
#import "WebHTMLViewInternal.h"
#import "WebHistoryItemPrivate.h"
+#import "WebIconDatabase.h"
+#import <WebKit/WebIconDatabasePrivate.h>
#import "WebJavaPlugIn.h"
#import "WebJavaScriptTextInputPanel.h"
#import "WebKitErrorsPrivate.h"
[(WebHTMLView *)[[_frame frameView] documentView] _formControlIsResigningFirstResponder:formControl];
}
-- (void)setIconURL:(NSURL *)URL
-{
- [[self dataSource] _setIconURL:URL];
-}
-
-- (void)setIconURL:(NSURL *)URL withType:(NSString *)type
-{
- [[self dataSource] _setIconURL:URL withType:type];
-}
-
- (void)loadURL:(NSURL *)URL referrer:(NSString *)referrer reload:(BOOL)reload userGesture:(BOOL)forUser target:(NSString *)target triggeringEvent:(NSEvent *)event form:(DOMElement *)form formValues:(NSDictionary *)values
{
BOOL hideReferrer;
return [NSString stringWithFormat:UI_STRING("%@ %.0f×%.0f pixels", "window title for a standalone image (uses multiplication symbol, not x)"), filename, size.width, size.height];
}
+- (void)notifyIconChanged:(NSURL*)iconURL
+{
+ ASSERT([[WebIconDatabase sharedIconDatabase] _isEnabled]);
+ ASSERT(_frame == [[_frame webView] mainFrame]);
+
+ [[_frame webView] _willChangeValueForKey:_WebMainFrameIconKey];
+
+ NSImage *icon = [[WebIconDatabase sharedIconDatabase] iconForURL:[[[[_frame _frameLoader] activeDataSource] _URL] _web_originalDataAsString] withSize:WebIconSmallSize];
+
+ [[[_frame webView] _frameLoadDelegateForwarder] webView:[_frame webView]
+ didReceiveIcon:icon
+ forFrame:_frame];
+
+ [[_frame webView] _didChangeValueForKey:_WebMainFrameIconKey];
+}
+
+- (NSURL*)originalRequestURL
+{
+ return [[[[_frame _frameLoader] activeDataSource] initialRequest] URL];
+}
+
@end
- (void)_loadIcon
{
- // Don't load an icon if 1) this is not the main frame 2) we ended in error
- // 3) they aren't saved by the DB
- if ([self webFrame] != [[self _webView] mainFrame] || _private->mainDocumentError || ![[WebIconDatabase sharedIconDatabase] _isEnabled])
- return;
-
- if (!_private->iconURL) {
- // No icon URL from the LINK tag so try the server's root.
- // This is only really a feature of http or https, so don't try this with other protocols.
- NSString *scheme = [[self _URL] scheme];
- if([scheme isEqualToString:@"http"] || [scheme isEqualToString:@"https"]){
- _private->iconURL = [[[NSURL _web_URLWithDataAsString:@"/favicon.ico"
- relativeToURL:[self _URL]] absoluteURL] retain];
- }
- }
-
- if (_private->iconURL != nil) {
- // If we have the icon already, we'll still see if we're manually reloading or if the icon is expired
- // If so, kick off a reload of the icon
- // If we don't have the icon already, kick off the initial load
- if ([[WebIconDatabase sharedIconDatabase] _hasEntryForIconURL:[_private->iconURL _web_originalDataAsString]]) {
- [[_private->webFrame _frameLoader] _updateIconDatabaseWithURL:_private->iconURL];
- if ([[self webFrame] _loadType] == WebFrameLoadTypeReload || [[WebIconDatabase sharedIconDatabase] isIconExpiredForIconURL:[_private->iconURL _web_originalDataAsString]])
- [[WebIconDatabase sharedIconDatabase] loadIconFromURL:[_private->iconURL _web_originalDataAsString]];
- else
- [[_private->webFrame _frameLoader] _notifyIconChanged:_private->iconURL];
- } else {
- NSMutableURLRequest *request = [[NSMutableURLRequest alloc] initWithURL:_private->iconURL];
- [[self webFrame] _addExtraFieldsToRequest:request mainResource:YES alwaysFromRequest:NO];
- [[_private->webFrame _frameLoader] loadIconWithRequest:request];
- [request release];
- }
- }
}
- (NSError *)_cancelledError