Changeset 183015 in webkit


Ignore:
Timestamp:
Apr 20, 2015 9:49:43 AM (9 years ago)
Author:
peavo@outlook.com
Message:

Favicons are not always loaded.
https://bugs.webkit.org/show_bug.cgi?id=143880

Reviewed by Darin Adler.

Source/WebCore:

If the favicon link element(s) in the document does not have a mime type,
the favicon is loaded from the domain root (/favicon.ico). If no favicon
exists at this location, the favicon loading will fail. This can be solved
by not demanding that the link element has a mime type.

Test: fast/dom/icon-url-without-mimetype.html

  • loader/icon/IconController.cpp:

(WebCore::iconFromLinkElements): Return the chosen icon URL instead of a vector of URLs.
(WebCore::IconController::url):
(WebCore::iconsFromLinkElements): Deleted.

LayoutTests:

Added new test for icon link elements without mime type.

  • fast/dom/icon-url-without-mimetype-expected.txt: Added.
  • fast/dom/icon-url-without-mimetype.html: Added.
Location:
trunk
Files:
2 added
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r183014 r183015  
     12015-04-20  Per Arne Vollan  <peavo@outlook.com>
     2
     3        Favicons are not always loaded.
     4        https://bugs.webkit.org/show_bug.cgi?id=143880
     5
     6        Reviewed by Darin Adler.
     7
     8        Added new test for icon link elements without mime type.
     9
     10        * fast/dom/icon-url-without-mimetype-expected.txt: Added.
     11        * fast/dom/icon-url-without-mimetype.html: Added.
     12
    1132015-04-20  Alexey Proskuryakov  <ap@apple.com>
    214
  • trunk/Source/WebCore/ChangeLog

    r183012 r183015  
     12015-04-20  Per Arne Vollan  <peavo@outlook.com>
     2
     3        Favicons are not always loaded.
     4        https://bugs.webkit.org/show_bug.cgi?id=143880
     5
     6        Reviewed by Darin Adler.
     7
     8        If the favicon link element(s) in the document does not have a mime type,
     9        the favicon is loaded from the domain root (/favicon.ico). If no favicon
     10        exists at this location, the favicon loading will fail. This can be solved
     11        by not demanding that the link element has a mime type.
     12
     13        Test: fast/dom/icon-url-without-mimetype.html
     14
     15        * loader/icon/IconController.cpp:
     16        (WebCore::iconFromLinkElements): Return the chosen icon URL instead of a vector of URLs.
     17        (WebCore::IconController::url):
     18        (WebCore::iconsFromLinkElements): Deleted.
     19
    1202015-04-20  Martin Robinson  <mrobinson@igalia.com>
    221
  • trunk/Source/WebCore/loader/icon/IconController.cpp

    r182352 r183015  
    5353namespace WebCore {
    5454
    55 enum class LinkElementSelector { All, WithMIMEType };
    56 
    5755IconController::IconController(Frame& frame)
    5856    : m_frame(frame)
     
    6462}
    6563
    66 // FIXME: Given how this is used, there's no real need to use a vector here.
    67 // Should straighten this out and tighten up the code.
    68 static Vector<URL> iconsFromLinkElements(Frame& frame, LinkElementSelector selector)
    69 {
    70     Vector<URL> result;
     64static URL iconFromLinkElements(Frame& frame)
     65{
     66    // This function returns the first icon with a mime type.
     67    // If no icon with mime type exists, the last icon is returned.
     68    // It may make more sense to always return the last icon,
     69    // but this implementation is consistent with previous behavior.
     70
     71    URL result;
    7172
    7273    auto* document = frame.document();
     
    8384        if (linkElement.href().isEmpty())
    8485            continue;
    85         if (selector == LinkElementSelector::WithMIMEType && linkElement.type().isEmpty())
    86             continue;
    87         result.append(linkElement.href());
    88     }
    89 
    90     // Put last icon seen at the front. This helps us implement a rule that says that icons seen later should take precedence.
    91     result.reverse();
     86        result = linkElement.href();
     87        if (!linkElement.type().isEmpty())
     88            break;
     89    }
    9290
    9391    return result;
     
    9997        return URL();
    10098
    101     // FIXME: This implements a rule that says "first icon seen with a MIME type wins".
    102     // But that is not consistent with the comment in iconsFromLinkElements that says
    103     // that icons seen *later* should take precedence.
    104     URL icon;
    105     for (auto& candidate : iconsFromLinkElements(m_frame, LinkElementSelector::WithMIMEType))
    106         icon = candidate;
     99    auto icon = iconFromLinkElements(m_frame);
    107100    if (!icon.isEmpty())
    108101        return icon;
     
    116109        return icon;
    117110    }
    118 
    119     for (auto& candidate : iconsFromLinkElements(m_frame, LinkElementSelector::All))
    120         return candidate;
    121111
    122112    return URL();
Note: See TracChangeset for help on using the changeset viewer.