haikuwebkit/Source/WebCore/html/LinkIconCollector.h

50 lines
1.7 KiB
C
Raw Permalink Normal View History

Add injected bundle SPI for getting favicon and touch icon URLs https://bugs.webkit.org/show_bug.cgi?id=157435 Reviewed by Darin Adler. Source/WebCore: * CMakeLists.txt: Add new files. * WebCore.xcodeproj/project.pbxproj: Add new files. * html/HTMLLinkElement.cpp: (WebCore::HTMLLinkElement::iconType): * html/HTMLLinkElement.h: Rename LinkRelAttribute::IconType to LinkIconType. * html/LinkIconCollector.cpp: Added. (WebCore::iconSize): New helper function that returns the icon size for an icon. (WebCore::compareIcons): Icon comparison function, to be used by for sorting. (LinkIconCollector::iconsOfTypes): Gather the right icons, sort them (descending by size) and return them. * html/LinkIconCollector.h: Added. * html/LinkIconType.h: Move icon type declarations here and arrange them so we can use them in an OptionSet. * html/LinkRelAttribute.cpp: (WebCore::LinkRelAttribute::LinkRelAttribute): * html/LinkRelAttribute.h: * loader/icon/IconController.cpp: (WebCore::iconFromLinkElements): Rename IconType to LinkIconType. Source/WebKit2: * WebProcess/InjectedBundle/API/Cocoa/WKWebProcessPlugInFrame.h: * WebProcess/InjectedBundle/API/Cocoa/WKWebProcessPlugInFrame.mm: (collectIcons): New helper function that calls into the WebCore LinkCollector. (-[WKWebProcessPlugInFrame appleTouchIconURLs]): Call collectIcons. (-[WKWebProcessPlugInFrame faviconURLs]): Ditto. Canonical link: https://commits.webkit.org/175622@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@200591 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2016-05-09 20:41:31 +00:00
/*
* Copyright (C) 2016 Apple 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 INC. AND ITS CONTRIBUTORS ``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 INC. OR ITS 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.
*/
#pragma once
#include "LinkIcon.h"
Add injected bundle SPI for getting favicon and touch icon URLs https://bugs.webkit.org/show_bug.cgi?id=157435 Reviewed by Darin Adler. Source/WebCore: * CMakeLists.txt: Add new files. * WebCore.xcodeproj/project.pbxproj: Add new files. * html/HTMLLinkElement.cpp: (WebCore::HTMLLinkElement::iconType): * html/HTMLLinkElement.h: Rename LinkRelAttribute::IconType to LinkIconType. * html/LinkIconCollector.cpp: Added. (WebCore::iconSize): New helper function that returns the icon size for an icon. (WebCore::compareIcons): Icon comparison function, to be used by for sorting. (LinkIconCollector::iconsOfTypes): Gather the right icons, sort them (descending by size) and return them. * html/LinkIconCollector.h: Added. * html/LinkIconType.h: Move icon type declarations here and arrange them so we can use them in an OptionSet. * html/LinkRelAttribute.cpp: (WebCore::LinkRelAttribute::LinkRelAttribute): * html/LinkRelAttribute.h: * loader/icon/IconController.cpp: (WebCore::iconFromLinkElements): Rename IconType to LinkIconType. Source/WebKit2: * WebProcess/InjectedBundle/API/Cocoa/WKWebProcessPlugInFrame.h: * WebProcess/InjectedBundle/API/Cocoa/WKWebProcessPlugInFrame.mm: (collectIcons): New helper function that calls into the WebCore LinkCollector. (-[WKWebProcessPlugInFrame appleTouchIconURLs]): Call collectIcons. (-[WKWebProcessPlugInFrame faviconURLs]): Ditto. Canonical link: https://commits.webkit.org/175622@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@200591 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2016-05-09 20:41:31 +00:00
#include <wtf/OptionSet.h>
namespace WebCore {
class Document;
enum class LinkIconType : uint8_t;
Add injected bundle SPI for getting favicon and touch icon URLs https://bugs.webkit.org/show_bug.cgi?id=157435 Reviewed by Darin Adler. Source/WebCore: * CMakeLists.txt: Add new files. * WebCore.xcodeproj/project.pbxproj: Add new files. * html/HTMLLinkElement.cpp: (WebCore::HTMLLinkElement::iconType): * html/HTMLLinkElement.h: Rename LinkRelAttribute::IconType to LinkIconType. * html/LinkIconCollector.cpp: Added. (WebCore::iconSize): New helper function that returns the icon size for an icon. (WebCore::compareIcons): Icon comparison function, to be used by for sorting. (LinkIconCollector::iconsOfTypes): Gather the right icons, sort them (descending by size) and return them. * html/LinkIconCollector.h: Added. * html/LinkIconType.h: Move icon type declarations here and arrange them so we can use them in an OptionSet. * html/LinkRelAttribute.cpp: (WebCore::LinkRelAttribute::LinkRelAttribute): * html/LinkRelAttribute.h: * loader/icon/IconController.cpp: (WebCore::iconFromLinkElements): Rename IconType to LinkIconType. Source/WebKit2: * WebProcess/InjectedBundle/API/Cocoa/WKWebProcessPlugInFrame.h: * WebProcess/InjectedBundle/API/Cocoa/WKWebProcessPlugInFrame.mm: (collectIcons): New helper function that calls into the WebCore LinkCollector. (-[WKWebProcessPlugInFrame appleTouchIconURLs]): Call collectIcons. (-[WKWebProcessPlugInFrame faviconURLs]): Ditto. Canonical link: https://commits.webkit.org/175622@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@200591 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2016-05-09 20:41:31 +00:00
class LinkIconCollector {
public:
explicit LinkIconCollector(Document& document)
: m_document(document)
{
}
WEBCORE_EXPORT Vector<LinkIcon> iconsOfTypes(OptionSet<LinkIconType>);
Add injected bundle SPI for getting favicon and touch icon URLs https://bugs.webkit.org/show_bug.cgi?id=157435 Reviewed by Darin Adler. Source/WebCore: * CMakeLists.txt: Add new files. * WebCore.xcodeproj/project.pbxproj: Add new files. * html/HTMLLinkElement.cpp: (WebCore::HTMLLinkElement::iconType): * html/HTMLLinkElement.h: Rename LinkRelAttribute::IconType to LinkIconType. * html/LinkIconCollector.cpp: Added. (WebCore::iconSize): New helper function that returns the icon size for an icon. (WebCore::compareIcons): Icon comparison function, to be used by for sorting. (LinkIconCollector::iconsOfTypes): Gather the right icons, sort them (descending by size) and return them. * html/LinkIconCollector.h: Added. * html/LinkIconType.h: Move icon type declarations here and arrange them so we can use them in an OptionSet. * html/LinkRelAttribute.cpp: (WebCore::LinkRelAttribute::LinkRelAttribute): * html/LinkRelAttribute.h: * loader/icon/IconController.cpp: (WebCore::iconFromLinkElements): Rename IconType to LinkIconType. Source/WebKit2: * WebProcess/InjectedBundle/API/Cocoa/WKWebProcessPlugInFrame.h: * WebProcess/InjectedBundle/API/Cocoa/WKWebProcessPlugInFrame.mm: (collectIcons): New helper function that calls into the WebCore LinkCollector. (-[WKWebProcessPlugInFrame appleTouchIconURLs]): Call collectIcons. (-[WKWebProcessPlugInFrame faviconURLs]): Ditto. Canonical link: https://commits.webkit.org/175622@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@200591 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2016-05-09 20:41:31 +00:00
private:
Document& m_document;
};
}