WebKit Bugzilla
Attachment 347878 Details for
Bug 188870
: HTML{Image, Link, Script}Element::crossOrigin() should return an AtomicString
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
Patch
bug-188870-20180822170918.patch (text/plain), 9.74 KB, created by
Daniel Bates
on 2018-08-22 17:09:18 PDT
(
hide
)
Description:
Patch
Filename:
MIME Type:
Creator:
Daniel Bates
Created:
2018-08-22 17:09:18 PDT
Size:
9.74 KB
patch
obsolete
>Subversion Revision: 235181 >diff --git a/Source/WebCore/ChangeLog b/Source/WebCore/ChangeLog >index 60c71cb0c7de2025e4972de8dadccfa20be57f6e..9bb2f679318956483a969cfb524c62e017e67954 100644 >--- a/Source/WebCore/ChangeLog >+++ b/Source/WebCore/ChangeLog >@@ -1,3 +1,38 @@ >+2018-08-22 Daniel Bates <dabates@apple.com> >+ >+ HTML{Image, Link, Script}Element::crossOrigin() should return an AtomicString >+ https://bugs.webkit.org/show_bug.cgi?id=188870 >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ Have HTML{Image, Link, Script}Element::crossOrigin() return a const AtomicString& >+ instead of a String to avoid unncessary ref-count churn as well as the need for >+ a caller to perform string comparisons against the return value to handle the >+ different CORS settings values. >+ >+ This patch just changes the return type and renames the conversion function from >+ parseCORSSettingsAttribute() to toValidCrossOriginValue() to better describe its purpose. >+ A subsequent patch will audit call sites and remove unnecessary string comparisions >+ and remove any unncessary AtomicString to String conversions. >+ >+ * html/HTMLImageElement.cpp: >+ (WebCore::HTMLImageElement::crossOrigin const): Substitute toValidCrossOriginValue() >+ for parseCORSSettingsAttribute(). >+ * html/HTMLImageElement.h: >+ * html/HTMLLinkElement.cpp: >+ (WebCore::HTMLLinkElement::crossOrigin const): Ditto. >+ * html/HTMLLinkElement.h: >+ * html/HTMLMediaElement.cpp: >+ (WebCore::HTMLMediaElement::crossOrigin const): Ditto. >+ * html/HTMLMediaElement.h: >+ * html/HTMLScriptElement.cpp: >+ (WebCore::HTMLScriptElement::crossOrigin const): Ditto. >+ * html/HTMLScriptElement.h: >+ * html/parser/HTMLParserIdioms.cpp: >+ (WebCore::toValidCrossOriginValue): Added. >+ (WebCore::parseCORSSettingsAttribute): Deleted. >+ * html/parser/HTMLParserIdioms.h: >+ > 2018-08-22 Zalan Bujtas <zalan@apple.com> > > [LFC][Floating] Move files to a dedicated directory. >diff --git a/Source/WebCore/html/HTMLImageElement.cpp b/Source/WebCore/html/HTMLImageElement.cpp >index ed6cbd2524d9ebf4bcec9d92afea87bad0642ae4..7dcf14765794ffe6d0009697e70051311cecfe22 100644 >--- a/Source/WebCore/html/HTMLImageElement.cpp >+++ b/Source/WebCore/html/HTMLImageElement.cpp >@@ -598,9 +598,9 @@ void HTMLImageElement::setCrossOrigin(const AtomicString& value) > setAttributeWithoutSynchronization(crossoriginAttr, value); > } > >-String HTMLImageElement::crossOrigin() const >+const AtomicString& HTMLImageElement::crossOrigin() const > { >- return parseCORSSettingsAttribute(attributeWithoutSynchronization(crossoriginAttr)); >+ return toValidCrossOriginValue(attributeWithoutSynchronization(crossoriginAttr)); > } > > #if ENABLE(SERVICE_CONTROLS) >diff --git a/Source/WebCore/html/HTMLImageElement.h b/Source/WebCore/html/HTMLImageElement.h >index 848edea5f2fce073271e47af242b25cae2771530..2808276e81705d82d4bce35ccb5365f8c8745153 100644 >--- a/Source/WebCore/html/HTMLImageElement.h >+++ b/Source/WebCore/html/HTMLImageElement.h >@@ -74,7 +74,7 @@ public: > void setSrc(const String&); > > WEBCORE_EXPORT void setCrossOrigin(const AtomicString&); >- WEBCORE_EXPORT String crossOrigin() const; >+ WEBCORE_EXPORT const AtomicString& crossOrigin() const; > > WEBCORE_EXPORT void setWidth(unsigned); > >diff --git a/Source/WebCore/html/HTMLLinkElement.cpp b/Source/WebCore/html/HTMLLinkElement.cpp >index ba52d29371b3d86ef0d7c75bddfcd5db6da669ad..156e5b2b1043531261095f3e69aa5dfddec78ec4 100644 >--- a/Source/WebCore/html/HTMLLinkElement.cpp >+++ b/Source/WebCore/html/HTMLLinkElement.cpp >@@ -220,9 +220,9 @@ void HTMLLinkElement::setCrossOrigin(const AtomicString& value) > setAttributeWithoutSynchronization(crossoriginAttr, value); > } > >-String HTMLLinkElement::crossOrigin() const >+const AtomicString& HTMLLinkElement::crossOrigin() const > { >- return parseCORSSettingsAttribute(attributeWithoutSynchronization(crossoriginAttr)); >+ return toValidCrossOriginValue(attributeWithoutSynchronization(crossoriginAttr)); > } > > void HTMLLinkElement::setAs(const AtomicString& value) >diff --git a/Source/WebCore/html/HTMLLinkElement.h b/Source/WebCore/html/HTMLLinkElement.h >index 510f4cfb636d9da11e258f9ee3a42fed6efd36cd..551ae72dd1d4fa3cebbce814b7338964e51cea56 100644 >--- a/Source/WebCore/html/HTMLLinkElement.h >+++ b/Source/WebCore/html/HTMLLinkElement.h >@@ -66,7 +66,7 @@ public: > DOMTokenList& sizes(); > > WEBCORE_EXPORT void setCrossOrigin(const AtomicString&); >- WEBCORE_EXPORT String crossOrigin() const; >+ WEBCORE_EXPORT const AtomicString& crossOrigin() const; > WEBCORE_EXPORT void setAs(const AtomicString&); > WEBCORE_EXPORT String as() const; > >diff --git a/Source/WebCore/html/HTMLMediaElement.cpp b/Source/WebCore/html/HTMLMediaElement.cpp >index 3588a72aac73c29990231ca981eb0776e2317d3a..7b320c67f5ade1f9458dcba501987eb9a8b25718 100644 >--- a/Source/WebCore/html/HTMLMediaElement.cpp >+++ b/Source/WebCore/html/HTMLMediaElement.cpp >@@ -1210,9 +1210,9 @@ void HTMLMediaElement::setCrossOrigin(const AtomicString& value) > setAttributeWithoutSynchronization(crossoriginAttr, value); > } > >-String HTMLMediaElement::crossOrigin() const >+const AtomicString& HTMLMediaElement::crossOrigin() const > { >- return parseCORSSettingsAttribute(attributeWithoutSynchronization(crossoriginAttr)); >+ return toValidCrossOriginValue(attributeWithoutSynchronization(crossoriginAttr)); > } > > HTMLMediaElement::NetworkState HTMLMediaElement::networkState() const >diff --git a/Source/WebCore/html/HTMLMediaElement.h b/Source/WebCore/html/HTMLMediaElement.h >index a78ecfd3196b9fdeabc510277fca764ee3dd6a72..ff7d30190b7ab5a81be0d34442a94d3df207786f 100644 >--- a/Source/WebCore/html/HTMLMediaElement.h >+++ b/Source/WebCore/html/HTMLMediaElement.h >@@ -211,7 +211,7 @@ public: > void setSrcObject(MediaProvider&&); > > WEBCORE_EXPORT void setCrossOrigin(const AtomicString&); >- WEBCORE_EXPORT String crossOrigin() const; >+ WEBCORE_EXPORT const AtomicString& crossOrigin() const; > > // network state > using HTMLMediaElementEnums::NetworkState; >diff --git a/Source/WebCore/html/HTMLScriptElement.cpp b/Source/WebCore/html/HTMLScriptElement.cpp >index 60610984024c18dcceeb02a78c380d946feeaa74..7fc2f3745512f96fb32100b4562027739928684b 100644 >--- a/Source/WebCore/html/HTMLScriptElement.cpp >+++ b/Source/WebCore/html/HTMLScriptElement.cpp >@@ -104,9 +104,9 @@ void HTMLScriptElement::setCrossOrigin(const AtomicString& value) > setAttributeWithoutSynchronization(crossoriginAttr, value); > } > >-String HTMLScriptElement::crossOrigin() const >+const AtomicString& HTMLScriptElement::crossOrigin() const > { >- return parseCORSSettingsAttribute(attributeWithoutSynchronization(crossoriginAttr)); >+ return toValidCrossOriginValue(attributeWithoutSynchronization(crossoriginAttr)); > } > > URL HTMLScriptElement::src() const >diff --git a/Source/WebCore/html/HTMLScriptElement.h b/Source/WebCore/html/HTMLScriptElement.h >index bd1e3ed2f25ede6d92398715d7914793fde0f516..9b118dc0bc790ac5183444c3e7f12a9461224418 100644 >--- a/Source/WebCore/html/HTMLScriptElement.h >+++ b/Source/WebCore/html/HTMLScriptElement.h >@@ -42,7 +42,7 @@ public: > WEBCORE_EXPORT bool async() const; > > WEBCORE_EXPORT void setCrossOrigin(const AtomicString&); >- WEBCORE_EXPORT String crossOrigin() const; >+ WEBCORE_EXPORT const AtomicString& crossOrigin() const; > > using HTMLElement::ref; > using HTMLElement::deref; >diff --git a/Source/WebCore/html/parser/HTMLParserIdioms.cpp b/Source/WebCore/html/parser/HTMLParserIdioms.cpp >index 674debc698db9b7002eb4052335b9e6db81b64a3..67a7582e2e18c886d1fd2662c44d45fa87f4bca4 100644 >--- a/Source/WebCore/html/parser/HTMLParserIdioms.cpp >+++ b/Source/WebCore/html/parser/HTMLParserIdioms.cpp >@@ -344,13 +344,15 @@ bool threadSafeMatch(const QualifiedName& a, const QualifiedName& b) > return threadSafeEqual(*a.localName().impl(), *b.localName().impl()); > } > >-String parseCORSSettingsAttribute(const AtomicString& value) >+const AtomicString& toValidCrossOriginValue(const AtomicString& value) > { >+ static NeverDestroyed<AtomicString> useCredentialsValue { "use-credentials", AtomicString::ConstructFromLiteral }; >+ static NeverDestroyed<AtomicString> anonymousValue { "anonymous", AtomicString::ConstructFromLiteral }; > if (value.isNull()) >- return String(); >- if (equalIgnoringASCIICase(value, "use-credentials")) >- return "use-credentials"_s; >- return "anonymous"_s; >+ return nullAtom(); >+ if (equalIgnoringASCIICase(value, useCredentialsValue)) >+ return useCredentialsValue; >+ return anonymousValue; > } > > // https://html.spec.whatwg.org/multipage/semantics.html#attr-meta-http-equiv-refresh >diff --git a/Source/WebCore/html/parser/HTMLParserIdioms.h b/Source/WebCore/html/parser/HTMLParserIdioms.h >index dcccc269945564bf1ebfc3d151f8b1de0c60d757..ff78f0d38d12d9484428c207aad1cbdb5359c45b 100644 >--- a/Source/WebCore/html/parser/HTMLParserIdioms.h >+++ b/Source/WebCore/html/parser/HTMLParserIdioms.h >@@ -82,13 +82,13 @@ Vector<double> parseHTMLListOfOfFloatingPointNumberValues(StringView); > // https://html.spec.whatwg.org/multipage/semantics.html#attr-meta-http-equiv-refresh > bool parseMetaHTTPEquivRefresh(const StringView&, double& delay, String& url); > >-// https://html.spec.whatwg.org/multipage/infrastructure.html#cors-settings-attribute >-String parseCORSSettingsAttribute(const AtomicString&); >- > bool threadSafeMatch(const QualifiedName&, const QualifiedName&); > > AtomicString parseHTMLHashNameReference(StringView); > >+// https://html.spec.whatwg.org/multipage/urls-and-fetching.html#cors-settings-attributes >+const AtomicString& toValidCrossOriginValue(const AtomicString&); >+ > // Inline implementations of some of the functions declared above. > > template<typename CharacterType> inline bool isHTMLSpace(CharacterType character)
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Formatted Diff
|
Diff
Attachments on
bug 188870
: 347878