<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[202656] trunk/Source/WebCore</title>
</head>
<body>
<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; }
#msg dl a { font-weight: bold}
#msg dl a:link { color:#fc3; }
#msg dl a:active { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://trac.webkit.org/projects/webkit/changeset/202656">202656</a></dd>
<dt>Author</dt> <dd>antti@apple.com</dd>
<dt>Date</dt> <dd>2016-06-29 16:01:42 -0700 (Wed, 29 Jun 2016)</dd>
</dl>
<h3>Log Message</h3>
<pre>Factor pending CSS resources into a struct
https://bugs.webkit.org/show_bug.cgi?id=159268
Reviewed by Andreas Kling.
To fix resource loading related re-entrancy issues in StyleResolver we should move the triggering of
resource loads outside the style resolver. The first step for that is to capture pending resources to a struct.
* CMakeLists.txt:
* WebCore.xcodeproj/project.pbxproj:
* css/CSSCursorImageValue.cpp:
(WebCore::CSSCursorImageValue::cachedImage):
(WebCore::CSSCursorImageValue::cachedOrPendingImage):
* css/CSSCursorImageValue.h:
* css/CSSGradientValue.cpp:
(WebCore::GradientStop::GradientStop):
(WebCore::CSSGradientValue::gradientWithStylesResolved):
* css/CSSGradientValue.h:
(WebCore::CSSGradientValue::loadSubimages):
(WebCore::CSSGradientValue::CSSGradientValue):
* css/CSSImageSetValue.cpp:
(WebCore::CSSImageSetValue::cachedImageSet):
(WebCore::CSSImageSetValue::cachedOrPendingImageSet):
* css/CSSImageSetValue.h:
* css/StyleResolver.cpp:
(WebCore::StyleResolver::State::clear):
(WebCore::StyleResolver::State::setParentStyle):
(WebCore::StyleResolver::State::ensurePendingResources):
(WebCore::isAtShadowBoundary):
(WebCore::StyleResolver::cachedOrPendingFromValue):
(WebCore::StyleResolver::generatedOrPendingFromValue):
(WebCore::StyleResolver::setOrPendingFromValue):
(WebCore::StyleResolver::cursorOrPendingFromValue):
(WebCore::filterOperationForType):
(WebCore::StyleResolver::createFilterOperations):
(WebCore::StyleResolver::loadPendingResources):
(WebCore::StyleResolver::MatchedProperties::MatchedProperties):
(WebCore::StyleResolver::loadPendingSVGDocuments): Deleted.
(WebCore::StyleResolver::loadPendingImage): Deleted.
(WebCore::StyleResolver::loadPendingShapeImage): Deleted.
(WebCore::StyleResolver::loadPendingImages): Deleted.
* css/StyleResolver.h:
(WebCore::StyleResolver::rootElementStyle):
(WebCore::StyleResolver::element):
(WebCore::StyleResolver::document):
(WebCore::StyleResolver::documentSettings):
(WebCore::StyleResolver::State::setApplyPropertyToVisitedLinkStyle):
(WebCore::StyleResolver::State::applyPropertyToRegularStyle):
(WebCore::StyleResolver::State::applyPropertyToVisitedLinkStyle):
(WebCore::StyleResolver::State::setFontDirty):
(WebCore::StyleResolver::State::fontDirty):
(WebCore::StyleResolver::State::useSVGZoomRules):
(WebCore::StyleResolver::State::takePendingResources):
(WebCore::StyleResolver::State::cssToLengthConversionData):
(WebCore::StyleResolver::State::cascadeLevel):
(WebCore::StyleResolver::State::setCascadeLevel):
(WebCore::StyleResolver::state):
(WebCore::StyleResolver::State::pendingImageProperties): Deleted.
(WebCore::StyleResolver::State::filtersWithPendingSVGDocuments): Deleted.
* style/StylePendingResources.cpp: Added.
(WebCore::Style::loadPendingImage):
(WebCore::Style::loadPendingImages):
(WebCore::Style::loadPendingSVGFilters):
(WebCore::Style::loadPendingResources):
Move the functions for triggering the resource loads from StyleResolver.
* style/StylePendingResources.h: Added.
Add struct for pending resources.</pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkSourceWebCoreCMakeListstxt">trunk/Source/WebCore/CMakeLists.txt</a></li>
<li><a href="#trunkSourceWebCoreChangeLog">trunk/Source/WebCore/ChangeLog</a></li>
<li><a href="#trunkSourceWebCoreWebCorexcodeprojprojectpbxproj">trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj</a></li>
<li><a href="#trunkSourceWebCorecssCSSCursorImageValuecpp">trunk/Source/WebCore/css/CSSCursorImageValue.cpp</a></li>
<li><a href="#trunkSourceWebCorecssCSSCursorImageValueh">trunk/Source/WebCore/css/CSSCursorImageValue.h</a></li>
<li><a href="#trunkSourceWebCorecssCSSGradientValuecpp">trunk/Source/WebCore/css/CSSGradientValue.cpp</a></li>
<li><a href="#trunkSourceWebCorecssCSSGradientValueh">trunk/Source/WebCore/css/CSSGradientValue.h</a></li>
<li><a href="#trunkSourceWebCorecssCSSImageSetValuecpp">trunk/Source/WebCore/css/CSSImageSetValue.cpp</a></li>
<li><a href="#trunkSourceWebCorecssCSSImageSetValueh">trunk/Source/WebCore/css/CSSImageSetValue.h</a></li>
<li><a href="#trunkSourceWebCorecssStyleResolvercpp">trunk/Source/WebCore/css/StyleResolver.cpp</a></li>
<li><a href="#trunkSourceWebCorecssStyleResolverh">trunk/Source/WebCore/css/StyleResolver.h</a></li>
</ul>
<h3>Added Paths</h3>
<ul>
<li><a href="#trunkSourceWebCorestyleStylePendingResourcescpp">trunk/Source/WebCore/style/StylePendingResources.cpp</a></li>
<li><a href="#trunkSourceWebCorestyleStylePendingResourcesh">trunk/Source/WebCore/style/StylePendingResources.h</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkSourceWebCoreCMakeListstxt"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/CMakeLists.txt (202655 => 202656)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/CMakeLists.txt        2016-06-29 22:41:15 UTC (rev 202655)
+++ trunk/Source/WebCore/CMakeLists.txt        2016-06-29 23:01:42 UTC (rev 202656)
</span><span class="lines">@@ -2649,6 +2649,7 @@
</span><span class="cx"> style/RenderTreeUpdater.cpp
</span><span class="cx"> style/StyleChange.cpp
</span><span class="cx"> style/StyleFontSizeFunctions.cpp
</span><ins>+ style/StylePendingResources.cpp
</ins><span class="cx"> style/StyleRelations.cpp
</span><span class="cx"> style/StyleResolveForDocument.cpp
</span><span class="cx"> style/StyleSharingResolver.cpp
</span></span></pre></div>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (202655 => 202656)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog        2016-06-29 22:41:15 UTC (rev 202655)
+++ trunk/Source/WebCore/ChangeLog        2016-06-29 23:01:42 UTC (rev 202656)
</span><span class="lines">@@ -1,3 +1,76 @@
</span><ins>+2016-06-29 Antti Koivisto <antti@apple.com>
+
+ Factor pending CSS resources into a struct
+ https://bugs.webkit.org/show_bug.cgi?id=159268
+
+ Reviewed by Andreas Kling.
+
+ To fix resource loading related re-entrancy issues in StyleResolver we should move the triggering of
+ resource loads outside the style resolver. The first step for that is to capture pending resources to a struct.
+
+ * CMakeLists.txt:
+ * WebCore.xcodeproj/project.pbxproj:
+ * css/CSSCursorImageValue.cpp:
+ (WebCore::CSSCursorImageValue::cachedImage):
+ (WebCore::CSSCursorImageValue::cachedOrPendingImage):
+ * css/CSSCursorImageValue.h:
+ * css/CSSGradientValue.cpp:
+ (WebCore::GradientStop::GradientStop):
+ (WebCore::CSSGradientValue::gradientWithStylesResolved):
+ * css/CSSGradientValue.h:
+ (WebCore::CSSGradientValue::loadSubimages):
+ (WebCore::CSSGradientValue::CSSGradientValue):
+ * css/CSSImageSetValue.cpp:
+ (WebCore::CSSImageSetValue::cachedImageSet):
+ (WebCore::CSSImageSetValue::cachedOrPendingImageSet):
+ * css/CSSImageSetValue.h:
+ * css/StyleResolver.cpp:
+ (WebCore::StyleResolver::State::clear):
+ (WebCore::StyleResolver::State::setParentStyle):
+ (WebCore::StyleResolver::State::ensurePendingResources):
+ (WebCore::isAtShadowBoundary):
+ (WebCore::StyleResolver::cachedOrPendingFromValue):
+ (WebCore::StyleResolver::generatedOrPendingFromValue):
+ (WebCore::StyleResolver::setOrPendingFromValue):
+ (WebCore::StyleResolver::cursorOrPendingFromValue):
+ (WebCore::filterOperationForType):
+ (WebCore::StyleResolver::createFilterOperations):
+ (WebCore::StyleResolver::loadPendingResources):
+ (WebCore::StyleResolver::MatchedProperties::MatchedProperties):
+ (WebCore::StyleResolver::loadPendingSVGDocuments): Deleted.
+ (WebCore::StyleResolver::loadPendingImage): Deleted.
+ (WebCore::StyleResolver::loadPendingShapeImage): Deleted.
+ (WebCore::StyleResolver::loadPendingImages): Deleted.
+ * css/StyleResolver.h:
+ (WebCore::StyleResolver::rootElementStyle):
+ (WebCore::StyleResolver::element):
+ (WebCore::StyleResolver::document):
+ (WebCore::StyleResolver::documentSettings):
+ (WebCore::StyleResolver::State::setApplyPropertyToVisitedLinkStyle):
+ (WebCore::StyleResolver::State::applyPropertyToRegularStyle):
+ (WebCore::StyleResolver::State::applyPropertyToVisitedLinkStyle):
+ (WebCore::StyleResolver::State::setFontDirty):
+ (WebCore::StyleResolver::State::fontDirty):
+ (WebCore::StyleResolver::State::useSVGZoomRules):
+ (WebCore::StyleResolver::State::takePendingResources):
+ (WebCore::StyleResolver::State::cssToLengthConversionData):
+ (WebCore::StyleResolver::State::cascadeLevel):
+ (WebCore::StyleResolver::State::setCascadeLevel):
+ (WebCore::StyleResolver::state):
+ (WebCore::StyleResolver::State::pendingImageProperties): Deleted.
+ (WebCore::StyleResolver::State::filtersWithPendingSVGDocuments): Deleted.
+ * style/StylePendingResources.cpp: Added.
+ (WebCore::Style::loadPendingImage):
+ (WebCore::Style::loadPendingImages):
+ (WebCore::Style::loadPendingSVGFilters):
+ (WebCore::Style::loadPendingResources):
+
+ Move the functions for triggering the resource loads from StyleResolver.
+
+ * style/StylePendingResources.h: Added.
+
+ Add struct for pending resources.
+
</ins><span class="cx"> 2016-06-29 Anders Carlsson <andersca@apple.com>
</span><span class="cx">
</span><span class="cx"> Add "type" and "paymentPass" properties in PaymentMethod
</span></span></pre></div>
<a id="trunkSourceWebCoreWebCorexcodeprojprojectpbxproj"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj (202655 => 202656)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj        2016-06-29 22:41:15 UTC (rev 202655)
+++ trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj        2016-06-29 23:01:42 UTC (rev 202656)
</span><span class="lines">@@ -6781,6 +6781,8 @@
</span><span class="cx">                 E4D58EBB17B8F12800CBDCA8 /* ElementTraversal.h in Headers */ = {isa = PBXBuildFile; fileRef = E4D58EBA17B8F12800CBDCA8 /* ElementTraversal.h */; settings = {ATTRIBUTES = (Private, ); }; };
</span><span class="cx">                 E4D988B417BFD1F60084FB88 /* TextNodeTraversal.h in Headers */ = {isa = PBXBuildFile; fileRef = E4D988B317BFD1F60084FB88 /* TextNodeTraversal.h */; };
</span><span class="cx">                 E4D988B617BFEB210084FB88 /* TextNodeTraversal.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E4D988B517BFEB210084FB88 /* TextNodeTraversal.cpp */; };
</span><ins>+                E4DACE6A1D12E10B0075980F /* StylePendingResources.h in Headers */ = {isa = PBXBuildFile; fileRef = E4DACE691D12E10B0075980F /* StylePendingResources.h */; };
+                E4DACE6C1D12E1160075980F /* StylePendingResources.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E4DACE6B1D12E1160075980F /* StylePendingResources.cpp */; };
</ins><span class="cx">                 E4DEAA1717A93DC3000E0430 /* StyleTreeResolver.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E4DEAA1517A93DC3000E0430 /* StyleTreeResolver.cpp */; };
</span><span class="cx">                 E4DEAA1817A93DC3000E0430 /* StyleTreeResolver.h in Headers */ = {isa = PBXBuildFile; fileRef = E4DEAA1617A93DC3000E0430 /* StyleTreeResolver.h */; settings = {ATTRIBUTES = (Private, ); }; };
</span><span class="cx">                 E4E39AFB1330EFA8003AB274 /* LegacyTileLayerPool.h in Headers */ = {isa = PBXBuildFile; fileRef = E4E39AFA1330EFA8003AB274 /* LegacyTileLayerPool.h */; };
</span><span class="lines">@@ -14931,6 +14933,8 @@
</span><span class="cx">                 E4D58EBA17B8F12800CBDCA8 /* ElementTraversal.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ElementTraversal.h; sourceTree = "<group>"; };
</span><span class="cx">                 E4D988B317BFD1F60084FB88 /* TextNodeTraversal.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TextNodeTraversal.h; sourceTree = "<group>"; };
</span><span class="cx">                 E4D988B517BFEB210084FB88 /* TextNodeTraversal.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = TextNodeTraversal.cpp; sourceTree = "<group>"; };
</span><ins>+                E4DACE691D12E10B0075980F /* StylePendingResources.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = StylePendingResources.h; sourceTree = "<group>"; };
+                E4DACE6B1D12E1160075980F /* StylePendingResources.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = StylePendingResources.cpp; sourceTree = "<group>"; };
</ins><span class="cx">                 E4DEAA1517A93DC3000E0430 /* StyleTreeResolver.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = StyleTreeResolver.cpp; sourceTree = "<group>"; };
</span><span class="cx">                 E4DEAA1617A93DC3000E0430 /* StyleTreeResolver.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = StyleTreeResolver.h; sourceTree = "<group>"; };
</span><span class="cx">                 E4E39AFA1330EFA8003AB274 /* LegacyTileLayerPool.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = LegacyTileLayerPool.h; sourceTree = "<group>"; };
</span><span class="lines">@@ -23845,6 +23849,8 @@
</span><span class="cx">                                 E401E0A31C3C0B8300F34D10 /* StyleChange.h */,
</span><span class="cx">                                 E4D58EB617B4ED8900CBDCA8 /* StyleFontSizeFunctions.cpp */,
</span><span class="cx">                                 E4D58EB717B4ED8900CBDCA8 /* StyleFontSizeFunctions.h */,
</span><ins>+                                E4DACE6B1D12E1160075980F /* StylePendingResources.cpp */,
+                                E4DACE691D12E10B0075980F /* StylePendingResources.h */,
</ins><span class="cx">                                 E461802E1C8DD4D20026C02C /* StyleRelations.cpp */,
</span><span class="cx">                                 E461802C1C8DD2900026C02C /* StyleRelations.h */,
</span><span class="cx">                                 E4D58EB217B4DBDC00CBDCA8 /* StyleResolveForDocument.cpp */,
</span><span class="lines">@@ -25641,6 +25647,7 @@
</span><span class="cx">                                 E1C416120F6562FD0092D2FB /* CrossOriginAccessControl.h in Headers */,
</span><span class="cx">                                 41ABE67B1D0580DB006D862D /* CrossOriginPreflightChecker.h in Headers */,
</span><span class="cx">                                 E1C415DA0F655D6F0092D2FB /* CrossOriginPreflightResultCache.h in Headers */,
</span><ins>+                                E4DACE6A1D12E10B0075980F /* StylePendingResources.h in Headers */,
</ins><span class="cx">                                 E169803D1133542D00894115 /* CRuntimeObject.h in Headers */,
</span><span class="cx">                                 975CA28B130365F800E99AD9 /* Crypto.h in Headers */,
</span><span class="cx">                                 E172AF6E180F24C600FBADB9 /* CryptoAlgorithm.h in Headers */,
</span><span class="lines">@@ -30862,6 +30869,7 @@
</span><span class="cx">                                 E1284BB210449FFA00EAEB52 /* JSPageTransitionEvent.cpp in Sources */,
</span><span class="cx">                                 FDA15EB112B03EE1003A583A /* JSPannerNode.cpp in Sources */,
</span><span class="cx">                                 FD8AA63E169514A700D2EA68 /* JSPannerNodeCustom.cpp in Sources */,
</span><ins>+                                E4DACE6C1D12E1160075980F /* StylePendingResources.cpp in Sources */,
</ins><span class="cx">                                 E51A81DF17298D7700BFCA61 /* JSPerformance.cpp in Sources */,
</span><span class="cx">                                 CB38FD511CCF938900592A3F /* JSPerformanceEntry.cpp in Sources */,
</span><span class="cx">                                 CB38FD571CD21E2A00592A3F /* JSPerformanceEntryCustom.cpp in Sources */,
</span></span></pre></div>
<a id="trunkSourceWebCorecssCSSCursorImageValuecpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/css/CSSCursorImageValue.cpp (202655 => 202656)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/css/CSSCursorImageValue.cpp        2016-06-29 22:41:15 UTC (rev 202655)
+++ trunk/Source/WebCore/css/CSSCursorImageValue.cpp        2016-06-29 23:01:42 UTC (rev 202656)
</span><span class="lines">@@ -150,7 +150,7 @@
</span><span class="cx"> return nullptr;
</span><span class="cx"> }
</span><span class="cx">
</span><del>-StyleImage* CSSCursorImageValue::cachedOrPendingImage(Document& document)
</del><ins>+StyleImage* CSSCursorImageValue::cachedOrPendingImage(const Document& document)
</ins><span class="cx"> {
</span><span class="cx"> #if ENABLE(CSS_IMAGE_SET)
</span><span class="cx"> // Need to delegate completely so that changes in device scale factor can be handled appropriately.
</span></span></pre></div>
<a id="trunkSourceWebCorecssCSSCursorImageValueh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/css/CSSCursorImageValue.h (202655 => 202656)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/css/CSSCursorImageValue.h        2016-06-29 22:41:15 UTC (rev 202655)
+++ trunk/Source/WebCore/css/CSSCursorImageValue.h        2016-06-29 23:01:42 UTC (rev 202656)
</span><span class="lines">@@ -54,7 +54,7 @@
</span><span class="cx">
</span><span class="cx"> SVGCursorElement* updateCursorElement(const Document&);
</span><span class="cx"> StyleImage* cachedImage(CachedResourceLoader&, const ResourceLoaderOptions&);
</span><del>- StyleImage* cachedOrPendingImage(Document&);
</del><ins>+ StyleImage* cachedOrPendingImage(const Document&);
</ins><span class="cx">
</span><span class="cx"> void removeReferencedElement(SVGElement*);
</span><span class="cx">
</span></span></pre></div>
<a id="trunkSourceWebCorecssCSSGradientValuecpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/css/CSSGradientValue.cpp (202655 => 202656)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/css/CSSGradientValue.cpp        2016-06-29 22:41:15 UTC (rev 202655)
+++ trunk/Source/WebCore/css/CSSGradientValue.cpp        2016-06-29 23:01:42 UTC (rev 202656)
</span><span class="lines">@@ -104,7 +104,7 @@
</span><span class="cx"> { }
</span><span class="cx"> };
</span><span class="cx">
</span><del>-RefPtr<CSSGradientValue> CSSGradientValue::gradientWithStylesResolved(StyleResolver* styleResolver)
</del><ins>+RefPtr<CSSGradientValue> CSSGradientValue::gradientWithStylesResolved(const StyleResolver* styleResolver)
</ins><span class="cx"> {
</span><span class="cx"> bool derived = false;
</span><span class="cx"> for (auto& stop : m_stops) {
</span></span></pre></div>
<a id="trunkSourceWebCorecssCSSGradientValueh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/css/CSSGradientValue.h (202655 => 202656)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/css/CSSGradientValue.h        2016-06-29 22:41:15 UTC (rev 202655)
+++ trunk/Source/WebCore/css/CSSGradientValue.h        2016-06-29 23:01:42 UTC (rev 202656)
</span><span class="lines">@@ -85,7 +85,7 @@
</span><span class="cx"> bool knownToBeOpaque(const RenderElement*) const;
</span><span class="cx">
</span><span class="cx"> void loadSubimages(CachedResourceLoader&, const ResourceLoaderOptions&) { }
</span><del>- RefPtr<CSSGradientValue> gradientWithStylesResolved(StyleResolver*);
</del><ins>+ RefPtr<CSSGradientValue> gradientWithStylesResolved(const StyleResolver*);
</ins><span class="cx">
</span><span class="cx"> protected:
</span><span class="cx"> CSSGradientValue(ClassType classType, CSSGradientRepeat repeat, CSSGradientType gradientType)
</span></span></pre></div>
<a id="trunkSourceWebCorecssCSSImageSetValuecpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/css/CSSImageSetValue.cpp (202655 => 202656)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/css/CSSImageSetValue.cpp        2016-06-29 22:41:15 UTC (rev 202655)
+++ trunk/Source/WebCore/css/CSSImageSetValue.cpp        2016-06-29 23:01:42 UTC (rev 202656)
</span><span class="lines">@@ -130,7 +130,7 @@
</span><span class="cx"> return is<StyleCachedImageSet>(m_imageSet.get()) ? downcast<StyleCachedImageSet>(m_imageSet.get()) : nullptr;
</span><span class="cx"> }
</span><span class="cx">
</span><del>-StyleImage* CSSImageSetValue::cachedOrPendingImageSet(Document& document)
</del><ins>+StyleImage* CSSImageSetValue::cachedOrPendingImageSet(const Document& document)
</ins><span class="cx"> {
</span><span class="cx"> if (!m_imageSet)
</span><span class="cx"> m_imageSet = StylePendingImage::create(this);
</span></span></pre></div>
<a id="trunkSourceWebCorecssCSSImageSetValueh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/css/CSSImageSetValue.h (202655 => 202656)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/css/CSSImageSetValue.h        2016-06-29 22:41:15 UTC (rev 202655)
+++ trunk/Source/WebCore/css/CSSImageSetValue.h        2016-06-29 23:01:42 UTC (rev 202656)
</span><span class="lines">@@ -50,7 +50,7 @@
</span><span class="cx"> StyleCachedImageSet* cachedImageSet(CachedResourceLoader&, const ResourceLoaderOptions&);
</span><span class="cx">
</span><span class="cx"> // Returns a StyleCachedImageSet if the best fit image has been cached already, otherwise a StylePendingImage.
</span><del>- StyleImage* cachedOrPendingImageSet(Document&);
</del><ins>+ StyleImage* cachedOrPendingImageSet(const Document&);
</ins><span class="cx">
</span><span class="cx"> String customCSSText() const;
</span><span class="cx">
</span></span></pre></div>
<a id="trunkSourceWebCorecssStyleResolvercpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/css/StyleResolver.cpp (202655 => 202656)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/css/StyleResolver.cpp        2016-06-29 22:41:15 UTC (rev 202655)
+++ trunk/Source/WebCore/css/StyleResolver.cpp        2016-06-29 23:01:42 UTC (rev 202656)
</span><span class="lines">@@ -194,8 +194,7 @@
</span><span class="cx"> m_parentStyle = nullptr;
</span><span class="cx"> m_ownedParentStyle = nullptr;
</span><span class="cx"> m_regionForStyling = nullptr;
</span><del>- m_pendingImageProperties.clear();
- m_filtersWithPendingSVGDocuments.clear();
</del><ins>+ m_pendingResources = nullptr;
</ins><span class="cx"> m_cssToLengthConversionData = CSSToLengthConversionData();
</span><span class="cx"> }
</span><span class="cx">
</span><span class="lines">@@ -384,6 +383,13 @@
</span><span class="cx"> m_parentStyle = m_ownedParentStyle.get();
</span><span class="cx"> }
</span><span class="cx">
</span><ins>+Style::PendingResources& StyleResolver::State::ensurePendingResources()
+{
+ if (!m_pendingResources)
+ m_pendingResources = std::make_unique<Style::PendingResources>();
+ return *m_pendingResources;
+}
+
</ins><span class="cx"> static inline bool isAtShadowBoundary(const Element& element)
</span><span class="cx"> {
</span><span class="cx"> auto* parentNode = element.parentNode();
</span><span class="lines">@@ -1725,7 +1731,7 @@
</span><span class="cx"> {
</span><span class="cx"> Ref<StyleImage> image = value.cachedOrPendingImage();
</span><span class="cx"> if (image->isPendingImage())
</span><del>- m_state.pendingImageProperties().set(property, &value);
</del><ins>+ m_state.ensurePendingResources().pendingImages.set(property, &value);
</ins><span class="cx"> return image;
</span><span class="cx"> }
</span><span class="cx">
</span><span class="lines">@@ -1737,7 +1743,7 @@
</span><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> if (value.isPending()) {
</span><del>- m_state.pendingImageProperties().set(property, &value);
</del><ins>+ m_state.ensurePendingResources().pendingImages.set(property, &value);
</ins><span class="cx"> return StylePendingImage::create(&value);
</span><span class="cx"> }
</span><span class="cx"> return StyleGeneratedImage::create(value);
</span><span class="lines">@@ -1748,7 +1754,7 @@
</span><span class="cx"> {
</span><span class="cx"> RefPtr<StyleImage> image = value.cachedOrPendingImageSet(document());
</span><span class="cx"> if (image && image->isPendingImage())
</span><del>- m_state.pendingImageProperties().set(property, &value);
</del><ins>+ m_state.ensurePendingResources().pendingImages.set(property, &value);
</ins><span class="cx"> return image;
</span><span class="cx"> }
</span><span class="cx"> #endif
</span><span class="lines">@@ -1757,7 +1763,7 @@
</span><span class="cx"> {
</span><span class="cx"> RefPtr<StyleImage> image = value.cachedOrPendingImage(document());
</span><span class="cx"> if (image && image->isPendingImage())
</span><del>- m_state.pendingImageProperties().set(property, &value);
</del><ins>+ m_state.ensurePendingResources().pendingImages.set(property, &value);
</ins><span class="cx"> return image;
</span><span class="cx"> }
</span><span class="cx">
</span><span class="lines">@@ -1960,28 +1966,6 @@
</span><span class="cx"> return FilterOperation::NONE;
</span><span class="cx"> }
</span><span class="cx">
</span><del>-void StyleResolver::loadPendingSVGDocuments()
-{
- State& state = m_state;
-
- // Crash reports indicate that we've seen calls to this function when our
- // style is NULL. We don't know exactly why this happens. Our guess is
- // reentering styleForElement().
- ASSERT(state.style());
- if (!state.style() || !state.style()->hasFilter() || state.filtersWithPendingSVGDocuments().isEmpty())
- return;
-
- ResourceLoaderOptions options = CachedResourceLoader::defaultCachedResourceOptions();
- options.setContentSecurityPolicyImposition(m_state.element() && m_state.element()->isInUserAgentShadowTree() ? ContentSecurityPolicyImposition::SkipPolicyCheck : ContentSecurityPolicyImposition::DoPolicyCheck);
-
- CachedResourceLoader& cachedResourceLoader = state.document().cachedResourceLoader();
-
- for (auto& filterOperation : state.filtersWithPendingSVGDocuments())
- filterOperation->getOrCreateCachedSVGDocumentReference()->load(cachedResourceLoader, options);
-
- state.filtersWithPendingSVGDocuments().clear();
-}
-
</del><span class="cx"> bool StyleResolver::createFilterOperations(const CSSValue& inValue, FilterOperations& outOperations)
</span><span class="cx"> {
</span><span class="cx"> State& state = m_state;
</span><span class="lines">@@ -2018,7 +2002,7 @@
</span><span class="cx">
</span><span class="cx"> RefPtr<ReferenceFilterOperation> operation = ReferenceFilterOperation::create(cssUrl, url.fragmentIdentifier());
</span><span class="cx"> if (SVGURIReference::isExternalURIReference(cssUrl, m_state.document()))
</span><del>- state.filtersWithPendingSVGDocuments().append(operation);
</del><ins>+ state.ensurePendingResources().pendingSVGFilters.append(operation);
</ins><span class="cx">
</span><span class="cx"> operations.operations().append(operation);
</span><span class="cx"> continue;
</span><span class="lines">@@ -2118,177 +2102,17 @@
</span><span class="cx"> return true;
</span><span class="cx"> }
</span><span class="cx">
</span><del>-RefPtr<StyleImage> StyleResolver::loadPendingImage(const StylePendingImage& pendingImage, const ResourceLoaderOptions& options)
-{
- if (auto imageValue = pendingImage.cssImageValue())
- return imageValue->cachedImage(m_state.document().cachedResourceLoader(), options);
-
- if (auto imageGeneratorValue = pendingImage.cssImageGeneratorValue()) {
- imageGeneratorValue->loadSubimages(m_state.document().cachedResourceLoader(), options);
- return StyleGeneratedImage::create(*imageGeneratorValue);
- }
-
- if (auto cursorImageValue = pendingImage.cssCursorImageValue())
- return cursorImageValue->cachedImage(m_state.document().cachedResourceLoader(), options);
-
-#if ENABLE(CSS_IMAGE_SET)
- if (auto imageSetValue = pendingImage.cssImageSetValue())
- return imageSetValue->cachedImageSet(m_state.document().cachedResourceLoader(), options);
-#endif
-
- return nullptr;
-}
-
-RefPtr<StyleImage> StyleResolver::loadPendingImage(const StylePendingImage& pendingImage)
-{
- ResourceLoaderOptions options = CachedResourceLoader::defaultCachedResourceOptions();
- options.setContentSecurityPolicyImposition(m_state.element() && m_state.element()->isInUserAgentShadowTree() ? ContentSecurityPolicyImposition::SkipPolicyCheck : ContentSecurityPolicyImposition::DoPolicyCheck);
- return loadPendingImage(pendingImage, options);
-}
-
-#if ENABLE(CSS_SHAPES)
-void StyleResolver::loadPendingShapeImage(ShapeValue* shapeValue)
-{
- if (!shapeValue)
- return;
-
- StyleImage* image = shapeValue->image();
- if (!is<StylePendingImage>(image))
- return;
-
- auto& pendingImage = downcast<StylePendingImage>(*image);
-
- ResourceLoaderOptions options = CachedResourceLoader::defaultCachedResourceOptions();
- options.setRequestOriginPolicy(PotentiallyCrossOriginEnabled);
- options.setAllowCredentials(DoNotAllowStoredCredentials);
- options.setContentSecurityPolicyImposition(m_state.element() && m_state.element()->isInUserAgentShadowTree() ? ContentSecurityPolicyImposition::SkipPolicyCheck : ContentSecurityPolicyImposition::DoPolicyCheck);
-
- shapeValue->setImage(loadPendingImage(pendingImage, options));
-}
-#endif
-
-void StyleResolver::loadPendingImages()
-{
- RELEASE_ASSERT(!m_inLoadPendingImages);
- TemporaryChange<bool> changeInLoadPendingImages(m_inLoadPendingImages, true);
-
- if (m_state.pendingImageProperties().isEmpty())
- return;
-
- auto end = m_state.pendingImageProperties().end().keys();
- for (auto it = m_state.pendingImageProperties().begin().keys(); it != end; ++it) {
- CSSPropertyID currentProperty = *it;
-
- switch (currentProperty) {
- case CSSPropertyBackgroundImage: {
- for (FillLayer* backgroundLayer = &m_state.style()->ensureBackgroundLayers(); backgroundLayer; backgroundLayer = backgroundLayer->next()) {
- auto* styleImage = backgroundLayer->image();
- if (is<StylePendingImage>(styleImage))
- backgroundLayer->setImage(loadPendingImage(downcast<StylePendingImage>(*styleImage)));
- }
- break;
- }
- case CSSPropertyContent: {
- for (ContentData* contentData = const_cast<ContentData*>(m_state.style()->contentData()); contentData; contentData = contentData->next()) {
- if (is<ImageContentData>(*contentData)) {
- auto& styleImage = downcast<ImageContentData>(*contentData).image();
- if (is<StylePendingImage>(styleImage)) {
- if (auto loadedImage = loadPendingImage(downcast<StylePendingImage>(styleImage)))
- downcast<ImageContentData>(*contentData).setImage(WTFMove(loadedImage));
- }
- }
- }
- break;
- }
- case CSSPropertyCursor: {
- if (CursorList* cursorList = m_state.style()->cursors()) {
- for (size_t i = 0; i < cursorList->size(); ++i) {
- CursorData& currentCursor = cursorList->at(i);
- auto* styleImage = currentCursor.image();
- if (is<StylePendingImage>(styleImage))
- currentCursor.setImage(loadPendingImage(downcast<StylePendingImage>(*styleImage)));
- }
- }
- break;
- }
- case CSSPropertyListStyleImage: {
- auto* styleImage = m_state.style()->listStyleImage();
- if (is<StylePendingImage>(styleImage))
- m_state.style()->setListStyleImage(loadPendingImage(downcast<StylePendingImage>(*styleImage)));
- break;
- }
- case CSSPropertyBorderImageSource: {
- auto* styleImage = m_state.style()->borderImageSource();
- if (is<StylePendingImage>(styleImage))
- m_state.style()->setBorderImageSource(loadPendingImage(downcast<StylePendingImage>(*styleImage)));
- break;
- }
- case CSSPropertyWebkitBoxReflect: {
- if (StyleReflection* reflection = m_state.style()->boxReflect()) {
- const NinePieceImage& maskImage = reflection->mask();
- auto* styleImage = maskImage.image();
- if (is<StylePendingImage>(styleImage)) {
- auto loadedImage = loadPendingImage(downcast<StylePendingImage>(*styleImage));
- reflection->setMask(NinePieceImage(WTFMove(loadedImage), maskImage.imageSlices(), maskImage.fill(), maskImage.borderSlices(), maskImage.outset(), maskImage.horizontalRule(), maskImage.verticalRule()));
- }
- }
- break;
- }
- case CSSPropertyWebkitMaskBoxImageSource: {
- auto* styleImage = m_state.style()->maskBoxImageSource();
- if (is<StylePendingImage>(styleImage))
- m_state.style()->setMaskBoxImageSource(loadPendingImage(downcast<StylePendingImage>(*styleImage)));
- break;
- }
- case CSSPropertyWebkitMaskImage: {
- for (FillLayer* maskLayer = &m_state.style()->ensureMaskLayers(); maskLayer; maskLayer = maskLayer->next()) {
- auto* styleImage = maskLayer->image();
- if (is<StylePendingImage>(styleImage))
- maskLayer->setImage(loadPendingImage(downcast<StylePendingImage>(*styleImage)));
- }
- break;
- }
-#if ENABLE(CSS_SHAPES)
- case CSSPropertyWebkitShapeOutside:
- loadPendingShapeImage(m_state.style()->shapeOutside());
- break;
-#endif
- default:
- ASSERT_NOT_REACHED();
- }
- }
-
- m_state.pendingImageProperties().clear();
-}
-
-#ifndef NDEBUG
-static bool inLoadPendingResources = false;
-#endif
-
</del><span class="cx"> void StyleResolver::loadPendingResources()
</span><span class="cx"> {
</span><del>- // We've seen crashes in all three of the functions below. Some of them
- // indicate that style() is NULL. This NULL check will cut down on total
- // crashes, while the ASSERT will help us find the cause in debug builds.
</del><span class="cx"> ASSERT(style());
</span><span class="cx"> if (!style())
</span><span class="cx"> return;
</span><span class="cx">
</span><del>-#ifndef NDEBUG
- // Re-entering this function will probably mean trouble. Catch it in debug builds.
- ASSERT(!inLoadPendingResources);
- inLoadPendingResources = true;
-#endif
</del><ins>+ RELEASE_ASSERT(!m_inLoadPendingImages);
+ TemporaryChange<bool> changeInLoadPendingImages(m_inLoadPendingImages, true);
</ins><span class="cx">
</span><del>- // Start loading images referenced by this style.
- loadPendingImages();
-
- // Start loading the SVG Documents referenced by this style.
- loadPendingSVGDocuments();
-
-#ifndef NDEBUG
- inLoadPendingResources = false;
-#endif
</del><ins>+ if (auto pendingResources = state().takePendingResources())
+ Style::loadPendingResources(*pendingResources, document(), *style(), m_state.element());
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> inline StyleResolver::MatchedProperties::MatchedProperties()
</span></span></pre></div>
<a id="trunkSourceWebCorecssStyleResolverh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/css/StyleResolver.h (202655 => 202656)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/css/StyleResolver.h        2016-06-29 22:41:15 UTC (rev 202655)
+++ trunk/Source/WebCore/css/StyleResolver.h        2016-06-29 23:01:42 UTC (rev 202656)
</span><span class="lines">@@ -30,6 +30,7 @@
</span><span class="cx"> #include "RuleFeature.h"
</span><span class="cx"> #include "RuleSet.h"
</span><span class="cx"> #include "SelectorChecker.h"
</span><ins>+#include "StylePendingResources.h"
</ins><span class="cx"> #include <bitset>
</span><span class="cx"> #include <memory>
</span><span class="cx"> #include <wtf/HashMap.h>
</span><span class="lines">@@ -148,6 +149,7 @@
</span><span class="cx"> const RenderStyle* rootElementStyle() const { return m_state.rootElementStyle(); }
</span><span class="cx"> const Element* element() { return m_state.element(); }
</span><span class="cx"> Document& document() { return m_document; }
</span><ins>+ const Document& document() const { return m_document; }
</ins><span class="cx"> Settings* documentSettings() { return m_document.settings(); }
</span><span class="cx">
</span><span class="cx"> void appendAuthorStyleSheets(const Vector<RefPtr<CSSStyleSheet>>&);
</span><span class="lines">@@ -381,9 +383,6 @@
</span><span class="cx"> void setApplyPropertyToVisitedLinkStyle(bool isApply) { m_applyPropertyToVisitedLinkStyle = isApply; }
</span><span class="cx"> bool applyPropertyToRegularStyle() const { return m_applyPropertyToRegularStyle; }
</span><span class="cx"> bool applyPropertyToVisitedLinkStyle() const { return m_applyPropertyToVisitedLinkStyle; }
</span><del>- PendingImagePropertyMap& pendingImageProperties() { return m_pendingImageProperties; }
-
- Vector<RefPtr<ReferenceFilterOperation>>& filtersWithPendingSVGDocuments() { return m_filtersWithPendingSVGDocuments; }
</del><span class="cx">
</span><span class="cx"> void setFontDirty(bool isDirty) { m_fontDirty = isDirty; }
</span><span class="cx"> bool fontDirty() const { return m_fontDirty; }
</span><span class="lines">@@ -406,8 +405,11 @@
</span><span class="cx">
</span><span class="cx"> bool useSVGZoomRules() const { return m_element && m_element->isSVGElement(); }
</span><span class="cx">
</span><del>- CSSToLengthConversionData cssToLengthConversionData() const { return m_cssToLengthConversionData; }
</del><ins>+ Style::PendingResources& ensurePendingResources();
+ std::unique_ptr<Style::PendingResources> takePendingResources() { return WTFMove(m_pendingResources); }
</ins><span class="cx">
</span><ins>+ const CSSToLengthConversionData& cssToLengthConversionData() const { return m_cssToLengthConversionData; }
+
</ins><span class="cx"> CascadeLevel cascadeLevel() const { return m_cascadeLevel; }
</span><span class="cx"> void setCascadeLevel(CascadeLevel level) { m_cascadeLevel = level; }
</span><span class="cx">
</span><span class="lines">@@ -442,8 +444,7 @@
</span><span class="cx"> FillLayer m_backgroundData { BackgroundFillLayer };
</span><span class="cx"> Color m_backgroundColor;
</span><span class="cx">
</span><del>- PendingImagePropertyMap m_pendingImageProperties;
- Vector<RefPtr<ReferenceFilterOperation>> m_filtersWithPendingSVGDocuments;
</del><ins>+ std::unique_ptr<Style::PendingResources> m_pendingResources;
</ins><span class="cx"> CSSToLengthConversionData m_cssToLengthConversionData;
</span><span class="cx">
</span><span class="cx"> CascadeLevel m_cascadeLevel { UserAgentLevel };
</span><span class="lines">@@ -454,6 +455,7 @@
</span><span class="cx"> };
</span><span class="cx">
</span><span class="cx"> State& state() { return m_state; }
</span><ins>+ const State& state() const { return m_state; }
</ins><span class="cx">
</span><span class="cx"> RefPtr<StyleImage> styleImage(CSSPropertyID, CSSValue&);
</span><span class="cx"> Ref<StyleImage> cachedOrPendingFromValue(CSSPropertyID, CSSImageValue&);
</span><span class="lines">@@ -489,12 +491,7 @@
</span><span class="cx">
</span><span class="cx"> void applySVGProperty(CSSPropertyID, CSSValue*);
</span><span class="cx">
</span><del>- RefPtr<StyleImage> loadPendingImage(const StylePendingImage&, const ResourceLoaderOptions&);
- RefPtr<StyleImage> loadPendingImage(const StylePendingImage&);
</del><span class="cx"> void loadPendingImages();
</span><del>-#if ENABLE(CSS_SHAPES)
- void loadPendingShapeImage(ShapeValue*);
-#endif
</del><span class="cx">
</span><span class="cx"> static unsigned computeMatchedPropertiesHash(const MatchedProperties*, unsigned size);
</span><span class="cx"> struct MatchedPropertiesCacheItem {
</span></span></pre></div>
<a id="trunkSourceWebCorestyleStylePendingResourcescpp"></a>
<div class="addfile"><h4>Added: trunk/Source/WebCore/style/StylePendingResources.cpp (0 => 202656)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/style/StylePendingResources.cpp         (rev 0)
+++ trunk/Source/WebCore/style/StylePendingResources.cpp        2016-06-29 23:01:42 UTC (rev 202656)
</span><span class="lines">@@ -0,0 +1,187 @@
</span><ins>+/*
+ * 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.
+ */
+
+#include "config.h"
+#include "StylePendingResources.h"
+
+#include "CachedResourceLoader.h"
+#include "CachedSVGDocumentReference.h"
+#include "ContentData.h"
+#include "CursorData.h"
+#include "CursorList.h"
+#include "Document.h"
+#include "RenderStyle.h"
+#include "SVGURIReference.h"
+#include "StyleCachedImage.h"
+#include "StyleCachedImageSet.h"
+#include "StyleGeneratedImage.h"
+#include "StylePendingImage.h"
+#include "TransformFunctions.h"
+
+namespace WebCore {
+namespace Style {
+
+enum class LoadPolicy { Normal, ShapeOutside };
+static RefPtr<StyleImage> loadPendingImage(Document& document, const StyleImage& image, const Element* element, LoadPolicy loadPolicy = LoadPolicy::Normal)
+{
+ auto& pendingImage = downcast<StylePendingImage>(image);
+ ResourceLoaderOptions options = CachedResourceLoader::defaultCachedResourceOptions();
+ options.setContentSecurityPolicyImposition(element && element->isInUserAgentShadowTree() ? ContentSecurityPolicyImposition::SkipPolicyCheck : ContentSecurityPolicyImposition::DoPolicyCheck);
+
+ // FIXME: Why does shape-outside have different policy than other properties?
+ if (loadPolicy == LoadPolicy::ShapeOutside) {
+ options.setRequestOriginPolicy(PotentiallyCrossOriginEnabled);
+ options.setAllowCredentials(DoNotAllowStoredCredentials);
+ }
+
+ if (auto imageValue = pendingImage.cssImageValue())
+ return imageValue->cachedImage(document.cachedResourceLoader(), options);
+
+ if (auto imageGeneratorValue = pendingImage.cssImageGeneratorValue()) {
+ imageGeneratorValue->loadSubimages(document.cachedResourceLoader(), options);
+ return StyleGeneratedImage::create(*imageGeneratorValue);
+ }
+
+ if (auto cursorImageValue = pendingImage.cssCursorImageValue())
+ return cursorImageValue->cachedImage(document.cachedResourceLoader(), options);
+
+#if ENABLE(CSS_IMAGE_SET)
+ if (auto imageSetValue = pendingImage.cssImageSetValue())
+ return imageSetValue->cachedImageSet(document.cachedResourceLoader(), options);
+#endif
+
+ return nullptr;
+}
+
+static void loadPendingImages(const PendingResources& pendingResources, Document& document, RenderStyle& style, const Element* element)
+{
+ for (auto currentProperty : pendingResources.pendingImages.keys()) {
+ switch (currentProperty) {
+ case CSSPropertyBackgroundImage: {
+ for (FillLayer* backgroundLayer = &style.ensureBackgroundLayers(); backgroundLayer; backgroundLayer = backgroundLayer->next()) {
+ auto* styleImage = backgroundLayer->image();
+ if (is<StylePendingImage>(styleImage))
+ backgroundLayer->setImage(loadPendingImage(document, *styleImage, element));
+ }
+ break;
+ }
+ case CSSPropertyContent: {
+ for (ContentData* contentData = const_cast<ContentData*>(style.contentData()); contentData; contentData = contentData->next()) {
+ if (is<ImageContentData>(*contentData)) {
+ auto& styleImage = downcast<ImageContentData>(*contentData).image();
+ if (is<StylePendingImage>(styleImage)) {
+ if (auto loadedImage = loadPendingImage(document, styleImage, element))
+ downcast<ImageContentData>(*contentData).setImage(WTFMove(loadedImage));
+ }
+ }
+ }
+ break;
+ }
+ case CSSPropertyCursor: {
+ if (CursorList* cursorList = style.cursors()) {
+ for (size_t i = 0; i < cursorList->size(); ++i) {
+ CursorData& currentCursor = cursorList->at(i);
+ auto* styleImage = currentCursor.image();
+ if (is<StylePendingImage>(styleImage))
+ currentCursor.setImage(loadPendingImage(document, *styleImage, element));
+ }
+ }
+ break;
+ }
+ case CSSPropertyListStyleImage: {
+ auto* styleImage = style.listStyleImage();
+ if (is<StylePendingImage>(styleImage))
+ style.setListStyleImage(loadPendingImage(document, *styleImage, element));
+ break;
+ }
+ case CSSPropertyBorderImageSource: {
+ auto* styleImage = style.borderImageSource();
+ if (is<StylePendingImage>(styleImage))
+ style.setBorderImageSource(loadPendingImage(document, *styleImage, element));
+ break;
+ }
+ case CSSPropertyWebkitBoxReflect: {
+ if (StyleReflection* reflection = style.boxReflect()) {
+ const NinePieceImage& maskImage = reflection->mask();
+ auto* styleImage = maskImage.image();
+ if (is<StylePendingImage>(styleImage)) {
+ auto loadedImage = loadPendingImage(document, *styleImage, element);
+ reflection->setMask(NinePieceImage(WTFMove(loadedImage), maskImage.imageSlices(), maskImage.fill(), maskImage.borderSlices(), maskImage.outset(), maskImage.horizontalRule(), maskImage.verticalRule()));
+ }
+ }
+ break;
+ }
+ case CSSPropertyWebkitMaskBoxImageSource: {
+ auto* styleImage = style.maskBoxImageSource();
+ if (is<StylePendingImage>(styleImage))
+ style.setMaskBoxImageSource(loadPendingImage(document, *styleImage, element));
+ break;
+ }
+ case CSSPropertyWebkitMaskImage: {
+ for (FillLayer* maskLayer = &style.ensureMaskLayers(); maskLayer; maskLayer = maskLayer->next()) {
+ auto* styleImage = maskLayer->image();
+ if (is<StylePendingImage>(styleImage))
+ maskLayer->setImage(loadPendingImage(document, *styleImage, element));
+ }
+ break;
+ }
+#if ENABLE(CSS_SHAPES)
+ case CSSPropertyWebkitShapeOutside: {
+ if (!style.shapeOutside())
+ return;
+
+ StyleImage* image = style.shapeOutside()->image();
+ if (is<StylePendingImage>(image))
+ style.shapeOutside()->setImage(loadPendingImage(document, *image, element, LoadPolicy::ShapeOutside));
+
+ break;
+ }
+#endif
+ default:
+ ASSERT_NOT_REACHED();
+ }
+ }
+}
+
+static void loadPendingSVGFilters(const PendingResources& pendingResources, Document& document, const Element* element)
+{
+ if (pendingResources.pendingSVGFilters.isEmpty())
+ return;
+
+ ResourceLoaderOptions options = CachedResourceLoader::defaultCachedResourceOptions();
+ options.setContentSecurityPolicyImposition(element && element->isInUserAgentShadowTree() ? ContentSecurityPolicyImposition::SkipPolicyCheck : ContentSecurityPolicyImposition::DoPolicyCheck);
+
+ for (auto& filterOperation : pendingResources.pendingSVGFilters)
+ filterOperation->getOrCreateCachedSVGDocumentReference()->load(document.cachedResourceLoader(), options);
+}
+
+void loadPendingResources(const PendingResources& pendingResources, Document& document, RenderStyle& style, const Element* element)
+{
+ loadPendingImages(pendingResources, document, style, element);
+ loadPendingSVGFilters(pendingResources, document, element);
+}
+
+}
+}
</ins></span></pre></div>
<a id="trunkSourceWebCorestyleStylePendingResourcesh"></a>
<div class="addfile"><h4>Added: trunk/Source/WebCore/style/StylePendingResources.h (0 => 202656)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/style/StylePendingResources.h         (rev 0)
+++ trunk/Source/WebCore/style/StylePendingResources.h        2016-06-29 23:01:42 UTC (rev 202656)
</span><span class="lines">@@ -0,0 +1,51 @@
</span><ins>+/*
+ * 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 "CSSPropertyNames.h"
+#include "FilterOperations.h"
+#include <wtf/HashMap.h>
+
+namespace WebCore {
+
+class CSSValue;
+class Document;
+class Element;
+class RenderStyle;
+
+namespace Style {
+
+struct PendingResources {
+ WTF_MAKE_FAST_ALLOCATED;
+public:
+ HashMap<CSSPropertyID, RefPtr<CSSValue>> pendingImages;
+ Vector<RefPtr<ReferenceFilterOperation>> pendingSVGFilters;
+};
+
+void loadPendingResources(const PendingResources&, Document&, RenderStyle&, const Element*);
+
+}
+}
</ins></span></pre>
</div>
</div>
</body>
</html>