diff --git a/Source/WebCore/dom/StyledElement.cpp b/Source/WebCore/dom/StyledElement.cpp index d4d1bc6257ec..f86ac632ee91 100644 --- a/Source/WebCore/dom/StyledElement.cpp +++ b/Source/WebCore/dom/StyledElement.cpp @@ -276,6 +276,25 @@ void StyledElement::addSubresourceAttributeURLs(ListHashSet& urls) const }); } +Attribute StyledElement::replaceURLsInAttributeValue(const Attribute& attribute, const HashMap& replacementURLStrings) const +{ + if (replacementURLStrings.isEmpty()) + return attribute; + + if (attribute.name() != styleAttr) + return attribute; + + RefPtr properties = this->inlineStyle(); + if (!properties) + return attribute; + + auto mutableProperties = properties->mutableCopy(); + mutableProperties->setReplacementURLForSubresources(replacementURLStrings); + auto inlineStyleString = mutableProperties->asText(); + mutableProperties->clearReplacementURLForSubresources(); + return Attribute { styleAttr, AtomString { inlineStyleString } }; +} + const ImmutableStyleProperties* StyledElement::presentationalHintStyle() const { if (!elementData()) diff --git a/Source/WebCore/dom/StyledElement.h b/Source/WebCore/dom/StyledElement.h index bbc3fdbe73ed..095d25660a19 100644 --- a/Source/WebCore/dom/StyledElement.h +++ b/Source/WebCore/dom/StyledElement.h @@ -84,6 +84,7 @@ class StyledElement : public Element { void addPropertyToPresentationalHintStyle(MutableStyleProperties&, CSSPropertyID, const String& value); void addSubresourceAttributeURLs(ListHashSet&) const override; + Attribute replaceURLsInAttributeValue(const Attribute&, const HashMap&) const override; private: void styleAttributeChanged(const AtomString& newStyleString, AttributeModificationReason); diff --git a/Tools/TestWebKitAPI/Tests/WebKitCocoa/CreateWebArchive.mm b/Tools/TestWebKitAPI/Tests/WebKitCocoa/CreateWebArchive.mm index eb2d9d88841c..95459c74d7d8 100644 --- a/Tools/TestWebKitAPI/Tests/WebKitCocoa/CreateWebArchive.mm +++ b/Tools/TestWebKitAPI/Tests/WebKitCocoa/CreateWebArchive.mm @@ -1090,7 +1090,7 @@ function loaded() { Util::run(&saved); } -static const char* htmlDataBytesForCSS = R"TESTRESOURCE( +static const char* htmlDataBytesForStyle = R"TESTRESOURCE(