⚠ Archived content — this site is no longer maintained.   Current WebKit documentation is at docs.webkit.org.

Changeset 291730 in webkit


Ignore:
Timestamp:
Mar 22, 2022, 5:58:41 PM (5 years ago)
Author:
Chris Dumez
Message:

Add URL::stringWithoutFragmentIdentifier() overload which returns a String instead of a StringView
​https://bugs.webkit.org/show_bug.cgi?id=238221

Reviewed by Geoffrey Garen.

Source/WebCore:

  • page/History.cpp:

(WebCore::History::stateObjectAdded):

  • platform/network/BlobRegistryImpl.cpp:

(WebCore::BlobRegistryImpl::getBlobDataFromURL const):
(WebCore::BlobRegistryImpl::registerBlobURLHandle):
(WebCore::BlobRegistryImpl::unregisterBlobURLHandle):
(WebCore::blobURLWithoutFragment): Deleted.

Source/WTF:

  • wtf/URL.cpp:

(WTF::URL::viewWithoutQueryOrFragmentIdentifier const):
(WTF::URL::viewWithoutFragmentIdentifier const):
(WTF::URL::stringWithoutFragmentIdentifier const):
(WTF::equalIgnoringFragmentIdentifier):
(WTF::URL::stringWithoutQueryOrFragmentIdentifier const): Deleted.

  • wtf/URL.h:
Location:
trunk/Source
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WTF/ChangeLog

    r291630 r291730  
     12022-03-22  Chris Dumez  <cdumez@apple.com>
     2
     3        Add URL::stringWithoutFragmentIdentifier() overload which returns a String instead of a StringView
     4        https://bugs.webkit.org/show_bug.cgi?id=238221
     5
     6        Reviewed by Geoffrey Garen.
     7
     8        * wtf/URL.cpp:
     9        (WTF::URL::viewWithoutQueryOrFragmentIdentifier const):
     10        (WTF::URL::viewWithoutFragmentIdentifier const):
     11        (WTF::URL::stringWithoutFragmentIdentifier const):
     12        (WTF::equalIgnoringFragmentIdentifier):
     13        (WTF::URL::stringWithoutQueryOrFragmentIdentifier const): Deleted.
     14        * wtf/URL.h:
     15
    1162022-03-22  Per Arne Vollan  <pvollan@apple.com>
    217
  • trunk/Source/WTF/wtf/URL.cpp

    r290846 r291730  
    709709}
    710710
    711 StringView URL::stringWithoutQueryOrFragmentIdentifier() const
     711StringView URL::viewWithoutQueryOrFragmentIdentifier() const
    712712{
    713713    if (!m_isValid)
    … …  
    717717}
    718718
    719 StringView URL::stringWithoutFragmentIdentifier() const
     719StringView URL::viewWithoutFragmentIdentifier() const
    720720{
    721721    if (!m_isValid)
    … …  
    725725}
    726726
     727String URL::stringWithoutFragmentIdentifier() const
     728{
     729    if (!m_isValid)
     730        return m_string;
     731
     732    return m_string.left(m_queryEnd);
     733}
     734
    727735bool equalIgnoringFragmentIdentifier(const URL& a, const URL& b)
    728736{
    729     return a.stringWithoutFragmentIdentifier() == b.stringWithoutFragmentIdentifier();
     737    return a.viewWithoutFragmentIdentifier() == b.viewWithoutFragmentIdentifier();
    730738}
    731739
  • trunk/Source/WTF/wtf/URL.h

    r290350 r291730  
    118118    WTF_EXPORT_PRIVATE StringView queryWithLeadingQuestionMark() const;
    119119    WTF_EXPORT_PRIVATE StringView fragmentIdentifierWithLeadingNumberSign() const;
    120     WTF_EXPORT_PRIVATE StringView stringWithoutQueryOrFragmentIdentifier() const;
    121     WTF_EXPORT_PRIVATE StringView stringWithoutFragmentIdentifier() const;
     120    WTF_EXPORT_PRIVATE StringView viewWithoutQueryOrFragmentIdentifier() const;
     121    WTF_EXPORT_PRIVATE StringView viewWithoutFragmentIdentifier() const;
     122    WTF_EXPORT_PRIVATE String stringWithoutFragmentIdentifier() const;
    122123
    123124    WTF_EXPORT_PRIVATE String protocolHostAndPort() const;
  • trunk/Source/WebCore/ChangeLog

    r291726 r291730  
     12022-03-22  Chris Dumez  <cdumez@apple.com>
     2
     3        Add URL::stringWithoutFragmentIdentifier() overload which returns a String instead of a StringView
     4        https://bugs.webkit.org/show_bug.cgi?id=238221
     5
     6        Reviewed by Geoffrey Garen.
     7
     8        * page/History.cpp:
     9        (WebCore::History::stateObjectAdded):
     10        * platform/network/BlobRegistryImpl.cpp:
     11        (WebCore::BlobRegistryImpl::getBlobDataFromURL const):
     12        (WebCore::BlobRegistryImpl::registerBlobURLHandle):
     13        (WebCore::BlobRegistryImpl::unregisterBlobURLHandle):
     14        (WebCore::blobURLWithoutFragment): Deleted.
     15
    1162022-03-22  Sihui Liu  <sihui_liu@apple.com>
    217
  • trunk/Source/WebCore/page/History.cpp

    r290566 r291730  
    209209    // See https://bugs.webkit.org/show_bug.cgi?id=183028 for the compatibility concerns.
    210210    bool allowSandboxException = (documentSecurityOrigin.isLocal() || documentSecurityOrigin.isUnique())
    211         && documentURL.stringWithoutQueryOrFragmentIdentifier() == fullURL.stringWithoutQueryOrFragmentIdentifier();
     211        && documentURL.viewWithoutQueryOrFragmentIdentifier() == fullURL.viewWithoutQueryOrFragmentIdentifier();
    212212
    213213    if (!allowSandboxException && !documentSecurityOrigin.canRequest(fullURL) && (fullURL.path() != documentURL.path() || fullURL.query() != documentURL.query()))
  • trunk/Source/WebCore/platform/network/BlobRegistryImpl.cpp

    r291689 r291730  
    5151namespace WebCore {
    5252
    53 static String blobURLWithoutFragment(const URL& url)
    54 {
    55     return url.hasFragmentIdentifier() ? url.stringWithoutFragmentIdentifier().toString() : url.string();
    56 }
    57 
    5853BlobRegistryImpl::~BlobRegistryImpl() = default;
    5954
    … …  
    236231    ASSERT(isMainThread());
    237232    if (url.hasFragmentIdentifier())
    238         return m_blobs.get(url.stringWithoutFragmentIdentifier().toStringWithoutCopying());
     233        return m_blobs.get(url.viewWithoutFragmentIdentifier().toStringWithoutCopying());
    239234    return m_blobs.get(url.string());
    240235}
    … …  
    381376void BlobRegistryImpl::registerBlobURLHandle(const URL& url)
    382377{
    383     auto urlKey = blobURLWithoutFragment(url);
     378    auto urlKey = url.stringWithoutFragmentIdentifier();
    384379    if (m_blobs.contains(urlKey))
    385380        m_blobReferences.add(urlKey);
    … …  
    388383void BlobRegistryImpl::unregisterBlobURLHandle(const URL& url)
    389384{
    390     auto urlKey = blobURLWithoutFragment(url);
     385    auto urlKey = url.stringWithoutFragmentIdentifier();
    391386    if (m_blobReferences.remove(urlKey))
    392387        m_blobs.remove(urlKey);
Note: See TracChangeset for help on using the changeset viewer.