Title: [209613] trunk/Source/WebCore
Revision
209613
Author
beid...@apple.com
Date
2016-12-09 10:21:30 -0800 (Fri, 09 Dec 2016)

Log Message

LinkIconCollector refactoring.
https://bugs.webkit.org/show_bug.cgi?id=165657

Reviewed by Dean Jackson.

No new tests (Refactor, no behavior change)

* WebCore.xcodeproj/project.pbxproj:

* html/LinkIconCollector.cpp:
(WebCore::iconSize):
(WebCore::compareIcons):
* html/LinkIconCollector.h:

* platform/LinkIcon.h: Move outside of LinkIconCollector for future expandability.

Modified Paths

Added Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (209612 => 209613)


--- trunk/Source/WebCore/ChangeLog	2016-12-09 18:12:31 UTC (rev 209612)
+++ trunk/Source/WebCore/ChangeLog	2016-12-09 18:21:30 UTC (rev 209613)
@@ -1,3 +1,21 @@
+2016-12-09  Brady Eidson  <beid...@apple.com>
+
+        LinkIconCollector refactoring.
+        https://bugs.webkit.org/show_bug.cgi?id=165657
+
+        Reviewed by Dean Jackson.
+
+        No new tests (Refactor, no behavior change)
+
+        * WebCore.xcodeproj/project.pbxproj:
+
+        * html/LinkIconCollector.cpp:
+        (WebCore::iconSize):
+        (WebCore::compareIcons):
+        * html/LinkIconCollector.h:
+
+        * platform/LinkIcon.h: Move outside of LinkIconCollector for future expandability.
+
 2016-12-09  Ryan Haddad  <ryanhad...@apple.com>
 
         Unreviewed, rolling out r209574.

Modified: trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj (209612 => 209613)


--- trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj	2016-12-09 18:12:31 UTC (rev 209612)
+++ trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj	2016-12-09 18:21:30 UTC (rev 209613)
@@ -2050,6 +2050,7 @@
 		514129981C6976900059E714 /* IDBRequestCompletionEvent.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 514129961C6976150059E714 /* IDBRequestCompletionEvent.cpp */; };
 		514129991C6976900059E714 /* IDBRequestCompletionEvent.h in Headers */ = {isa = PBXBuildFile; fileRef = 514129971C6976150059E714 /* IDBRequestCompletionEvent.h */; };
 		5141299B1C6C16740059E714 /* JSIDBIndexCustom.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 5141299A1C6C166D0059E714 /* JSIDBIndexCustom.cpp */; };
+		5143B2631DDD15200014FAC6 /* LinkIcon.h in Headers */ = {isa = PBXBuildFile; fileRef = 5143B2621DDD14900014FAC6 /* LinkIcon.h */; settings = {ATTRIBUTES = (Private, ); }; };
 		5145B1091BC48E2E00E86219 /* IDBResourceIdentifier.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 5145B1071BC4890B00E86219 /* IDBResourceIdentifier.cpp */; };
 		5145B10A1BC48E2E00E86219 /* IDBResourceIdentifier.h in Headers */ = {isa = PBXBuildFile; fileRef = 5145B1081BC4890B00E86219 /* IDBResourceIdentifier.h */; settings = {ATTRIBUTES = (Private, ); }; };
 		5148453E1BB9D07E006A72ED /* IDBError.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 5148453C1BB9D076006A72ED /* IDBError.cpp */; };
@@ -9271,6 +9272,7 @@
 		514129961C6976150059E714 /* IDBRequestCompletionEvent.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = IDBRequestCompletionEvent.cpp; sourceTree = "<group>"; };
 		514129971C6976150059E714 /* IDBRequestCompletionEvent.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = IDBRequestCompletionEvent.h; sourceTree = "<group>"; };
 		5141299A1C6C166D0059E714 /* JSIDBIndexCustom.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSIDBIndexCustom.cpp; sourceTree = "<group>"; };
+		5143B2621DDD14900014FAC6 /* LinkIcon.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = LinkIcon.h; sourceTree = "<group>"; };
 		5145B1071BC4890B00E86219 /* IDBResourceIdentifier.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = IDBResourceIdentifier.cpp; sourceTree = "<group>"; };
 		5145B1081BC4890B00E86219 /* IDBResourceIdentifier.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = IDBResourceIdentifier.h; sourceTree = "<group>"; };
 		5148453C1BB9D076006A72ED /* IDBError.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = IDBError.cpp; sourceTree = "<group>"; };
@@ -22535,6 +22537,7 @@
 				BCFF64900EAD15C200C1D6F7 /* LengthSize.h */,
 				A7AD2F850EC89D07008AB002 /* LinkHash.cpp */,
 				A7AD2F860EC89D07008AB002 /* LinkHash.h */,
+				5143B2621DDD14900014FAC6 /* LinkIcon.h */,
 				C046E1AB1208A9FE00BA2CF7 /* LocalizedStrings.cpp */,
 				935207BD09BD410A00F2038D /* LocalizedStrings.h */,
 				A8239DFE09B3CF8A00B60641 /* Logging.cpp */,
@@ -27757,6 +27760,7 @@
 				B22279F40D00BF220071B782 /* SVGFEMergeElement.h in Headers */,
 				B22279F70D00BF220071B782 /* SVGFEMergeNodeElement.h in Headers */,
 				84224194107E78A700766A87 /* SVGFEMorphologyElement.h in Headers */,
+				5143B2631DDD15200014FAC6 /* LinkIcon.h in Headers */,
 				B22279FA0D00BF220071B782 /* SVGFEOffsetElement.h in Headers */,
 				B22279FD0D00BF220071B782 /* SVGFEPointLightElement.h in Headers */,
 				B2227A000D00BF220071B782 /* SVGFESpecularLightingElement.h in Headers */,

Modified: trunk/Source/WebCore/html/LinkIconCollector.cpp (209612 => 209613)


--- trunk/Source/WebCore/html/LinkIconCollector.cpp	2016-12-09 18:12:31 UTC (rev 209612)
+++ trunk/Source/WebCore/html/LinkIconCollector.cpp	2016-12-09 18:21:30 UTC (rev 209613)
@@ -36,7 +36,7 @@
 
 const unsigned defaultTouchIconWidth = 60;
 
-static unsigned iconSize(const LinkIconCollector::Icon& icon)
+static unsigned iconSize(const LinkIcon& icon)
 {
     if (icon.size)
         return *icon.size;
@@ -47,7 +47,7 @@
     return 0;
 }
 
-static int compareIcons(const LinkIconCollector::Icon& a, const LinkIconCollector::Icon& b)
+static int compareIcons(const LinkIcon& a, const LinkIcon& b)
 {
     // Apple Touch icons always come first.
     if (a.type == LinkIconType::Favicon && b.type != LinkIconType::Favicon)
@@ -72,13 +72,13 @@
     return 0;
 }
 
-auto LinkIconCollector::iconsOfTypes(OptionSet<LinkIconType> iconTypes) -> Vector<Icon>
+auto LinkIconCollector::iconsOfTypes(OptionSet<LinkIconType> iconTypes) -> Vector<LinkIcon>
 {
     auto* head = m_document.head();
     if (!head)
         return { };
 
-    Vector<Icon> icons;
+    Vector<LinkIcon> icons;
 
     for (auto& linkElement : childrenOfType<HTMLLinkElement>(*head)) {
         if (!linkElement.iconType())
@@ -104,7 +104,7 @@
                 iconSize = size;
         }
 
-        icons.append({ url, iconType, iconSize });
+        icons.append({ url, iconType, linkElement.type(), iconSize });
     }
 
     std::sort(icons.begin(), icons.end(), [](auto& a, auto& b) {

Modified: trunk/Source/WebCore/html/LinkIconCollector.h (209612 => 209613)


--- trunk/Source/WebCore/html/LinkIconCollector.h	2016-12-09 18:12:31 UTC (rev 209612)
+++ trunk/Source/WebCore/html/LinkIconCollector.h	2016-12-09 18:21:30 UTC (rev 209613)
@@ -25,9 +25,8 @@
 
 #pragma once
 
-#include "URL.h"
+#include "LinkIcon.h"
 #include <wtf/OptionSet.h>
-#include <wtf/Optional.h>
 
 namespace WebCore {
 
@@ -41,15 +40,8 @@
     {
     }
 
-    struct Icon {
-        URL url;
+    WEBCORE_EXPORT Vector<LinkIcon> iconsOfTypes(OptionSet<LinkIconType>);
 
-        LinkIconType type;
-        std::optional<unsigned> size;
-    };
-
-    WEBCORE_EXPORT Vector<Icon> iconsOfTypes(OptionSet<LinkIconType>);
-
 private:
     Document& m_document;
 };

Copied: trunk/Source/WebCore/platform/LinkIcon.h (from rev 209612, trunk/Source/WebCore/html/LinkIconCollector.h) (0 => 209613)


--- trunk/Source/WebCore/platform/LinkIcon.h	                        (rev 0)
+++ trunk/Source/WebCore/platform/LinkIcon.h	2016-12-09 18:21:30 UTC (rev 209613)
@@ -0,0 +1,42 @@
+/*
+ * 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 "LinkIconType.h"
+#include "URL.h"
+#include <wtf/Optional.h>
+#include <wtf/text/WTFString.h>
+
+namespace WebCore {
+
+struct LinkIcon {
+    URL url;
+    LinkIconType type;
+    String mimeType;
+    std::optional<unsigned> size;
+};
+
+} // namespace WebCore
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to