<!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>[176798] 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/176798">176798</a></dd>
<dt>Author</dt> <dd>stavila@adobe.com</dd>
<dt>Date</dt> <dd>2014-12-04 09:05:12 -0800 (Thu, 04 Dec 2014)</dd>
</dl>
<h3>Log Message</h3>
<pre>[SVG Masking] Add support for referencing <mask> elements from -webkit-mask-image
https://bugs.webkit.org/show_bug.cgi?id=139092
Reviewed by Simon Fraser.
This patch improves the -webkit-mask-image property by allowing it to reference
a <mask> element defined in an inline or external SVG document.
Up until now, each image to be used as a mask consisted of a FillLayer object
whose m_image member represented the mask. Now, in order to accomodate
<mask> elements referenced by a fragment identifier (e.g. file.svg#mask1)
a new class was created (MaskImageOperation) and added as a member of the
FillLayer. As such, from now on, all FillLayer objects used for masking will
store the masking information in this new member.
When parsing the -webkit-mask-image property (or the -webkit-mask shorthand)
a new MaskImageOperation object is created for each image. If the value represents
an external URL, a pending SVG document will be created which will be loaded
during the phase that loads the pending resources. When the download is complete,
the MaskImageOperation is notified by the CachedSVGDocument class and checks if
the received download is a valid SVG and the requested fragment identifier
actually exists and identifies a <mask> element. If it does, that element's
renderer (of type RenderSVGResourceMasker) will be used when painting the mask layers.
Otherwise, the MaskImageOperation class will use the already downloaded data
buffer to create a CachedImage from it and use that instead, basically emulating
the previous behavior, when only images were accepted. This ensures that all existing
behavior, like painting entire SVGs, painting normal images (e.g. PNG/JPG), painting
generated images (e.g. linear-gradient) works as it did before.
No new tests required, this patch doesn't change any current functionality.
It only adds support for referencing <mask> elements for the -webkit-mask-image
property. This is sub-part 1 of the bigger patch https://bugs.webkit.org/show_bug.cgi?id=129682.
* CMakeLists.txt:
* WebCore.vcxproj/WebCore.vcxproj:
* WebCore.vcxproj/WebCore.vcxproj.filters:
* WebCore.xcodeproj/project.pbxproj:
* css/CSSValue.cpp:
(WebCore::CSSValue::cssText):
(WebCore::CSSValue::destroy):
* css/CSSValue.h:
(WebCore::CSSValue::isWebKitCSSResourceValue):
* css/StyleResolver.cpp:
(WebCore::StyleResolver::State::clear):
(WebCore::StyleResolver::createMaskImageOperations):
* css/StyleResolver.h:
(WebCore::StyleResolver::State::maskImagesWithPendingSVGDocuments):
* css/WebKitCSSResourceValue.cpp: Added.
(WebCore::WebKitCSSResourceValue::WebKitCSSResourceValue):
(WebCore::WebKitCSSResourceValue::customCSSText):
(WebCore::WebKitCSSResourceValue::isCSSValueNone):
* css/WebKitCSSResourceValue.h: Added.
(WebCore::WebKitCSSResourceValue::create):
(WebCore::WebKitCSSResourceValue::innerValue):
* loader/cache/CachedResourceLoader.cpp:
(WebCore::CachedResourceLoader::addCachedResource):
* loader/cache/CachedResourceLoader.h:
* loader/cache/CachedSVGDocument.cpp:
(WebCore::CachedSVGDocument::CachedSVGDocument):
(WebCore::CachedSVGDocument::finishLoading):
* loader/cache/CachedSVGDocument.h:
* loader/cache/CachedSVGDocumentReference.cpp:
(WebCore::CachedSVGDocumentReference::CachedSVGDocumentReference):
(WebCore::CachedSVGDocumentReference::~CachedSVGDocumentReference):
(WebCore::CachedSVGDocumentReference::load):
* loader/cache/CachedSVGDocumentReference.h:
* page/FrameView.cpp:
(WebCore::FrameView::isSVGDocument):
* page/FrameView.h:
* page/Page.cpp:
(WebCore::Page::createPageFromBuffer):
* page/Page.h:
* platform/ScrollView.h:
(WebCore::ScrollView::isSVGDocument):
* platform/graphics/MaskImageOperation.cpp: Added.
(WebCore::MaskImageOperation::create):
(WebCore::MaskImageOperation::MaskImageOperation):
(WebCore::MaskImageOperation::~MaskImageOperation):
(WebCore::MaskImageOperation::isCSSValueNone):
(WebCore::MaskImageOperation::cssValue):
(WebCore::MaskImageOperation::isMaskLoaded):
(WebCore::MaskImageOperation::setRenderLayerImageClient):
(WebCore::MaskImageOperation::addRendererImageClient):
(WebCore::MaskImageOperation::removeRendererImageClient):
(WebCore::MaskImageOperation::getOrCreateCachedSVGDocumentReference):
(WebCore::MaskImageOperation::notifyFinished): This is the method that gets called when the document has finished
downloading and checks if it can find a valid <mask> element.
(WebCore::MaskImageOperation::drawMask):
(WebCore::MaskImageOperation::getSVGMasker):
* platform/graphics/MaskImageOperation.h: Added.
* rendering/RenderBoxModelObject.cpp: The BackgroundImageGeometry class was moved out of RenderBoxModelObject in
order to be used as a parameter for other methods. This was necessary to avoid having methods with very many parameters.
(WebCore::BackgroundImageGeometry::setNoRepeatX):
(WebCore::BackgroundImageGeometry::setNoRepeatY):
(WebCore::BackgroundImageGeometry::useFixedAttachment):
(WebCore::BackgroundImageGeometry::clip):
(WebCore::BackgroundImageGeometry::relativePhase):
(WebCore::RenderBoxModelObject::BackgroundImageGeometry::setNoRepeatX): Deleted.
(WebCore::RenderBoxModelObject::BackgroundImageGeometry::setNoRepeatY): Deleted.
(WebCore::RenderBoxModelObject::BackgroundImageGeometry::useFixedAttachment): Deleted.
(WebCore::RenderBoxModelObject::BackgroundImageGeometry::clip): Deleted.
(WebCore::RenderBoxModelObject::BackgroundImageGeometry::relativePhase): Deleted.
* rendering/RenderBoxModelObject.h:
(WebCore::BackgroundImageGeometry::BackgroundImageGeometry):
(WebCore::BackgroundImageGeometry::destOrigin):
(WebCore::BackgroundImageGeometry::setDestOrigin):
(WebCore::BackgroundImageGeometry::destRect):
(WebCore::BackgroundImageGeometry::setDestRect):
(WebCore::BackgroundImageGeometry::phase):
(WebCore::BackgroundImageGeometry::setPhase):
(WebCore::BackgroundImageGeometry::tileSize):
(WebCore::BackgroundImageGeometry::setTileSize):
(WebCore::BackgroundImageGeometry::spaceSize):
(WebCore::BackgroundImageGeometry::setSpaceSize):
(WebCore::BackgroundImageGeometry::setPhaseX):
(WebCore::BackgroundImageGeometry::setPhaseY):
(WebCore::BackgroundImageGeometry::setHasNonLocalGeometry):
(WebCore::BackgroundImageGeometry::hasNonLocalGeometry):
(WebCore::RenderBoxModelObject::BackgroundImageGeometry::BackgroundImageGeometry): Deleted.
(WebCore::RenderBoxModelObject::BackgroundImageGeometry::destOrigin): Deleted.
(WebCore::RenderBoxModelObject::BackgroundImageGeometry::setDestOrigin): Deleted.
(WebCore::RenderBoxModelObject::BackgroundImageGeometry::destRect): Deleted.
(WebCore::RenderBoxModelObject::BackgroundImageGeometry::setDestRect): Deleted.
(WebCore::RenderBoxModelObject::BackgroundImageGeometry::phase): Deleted.
(WebCore::RenderBoxModelObject::BackgroundImageGeometry::setPhase): Deleted.
(WebCore::RenderBoxModelObject::BackgroundImageGeometry::tileSize): Deleted.
(WebCore::RenderBoxModelObject::BackgroundImageGeometry::setTileSize): Deleted.
(WebCore::RenderBoxModelObject::BackgroundImageGeometry::spaceSize): Deleted.
(WebCore::RenderBoxModelObject::BackgroundImageGeometry::setSpaceSize): Deleted.
(WebCore::RenderBoxModelObject::BackgroundImageGeometry::setPhaseX): Deleted.
(WebCore::RenderBoxModelObject::BackgroundImageGeometry::setPhaseY): Deleted.
(WebCore::RenderBoxModelObject::BackgroundImageGeometry::setHasNonLocalGeometry): Deleted.
(WebCore::RenderBoxModelObject::BackgroundImageGeometry::hasNonLocalGeometry): Deleted.
* rendering/RenderLayer.cpp:
(WebCore::RenderLayer::RenderLayer):
(WebCore::RenderLayer::~RenderLayer):
* rendering/RenderLayer.h:
* rendering/RenderLayerMaskImageInfo.cpp: Added.
(WebCore::RenderLayer::MaskImageInfo::layerToMaskMap): Returns a static map that links MaskImageInfo objects to RenderLayers.
(WebCore::RenderLayer::MaskImageInfo::getIfExists): Returns the MaskImageInfo associated with a specific RenderLayer.
(WebCore::RenderLayer::MaskImageInfo::get): Returns the MaskImageInfo associated with a specific RenderLayer (creates it if necessary).
(WebCore::RenderLayer::MaskImageInfo::remove): Removes the MaskImageInfo associated with a specific RenderLayer.
(WebCore::RenderLayer::MaskImageInfo::MaskImageInfo):
(WebCore::RenderLayer::MaskImageInfo::~MaskImageInfo):
(WebCore::RenderLayer::MaskImageInfo::notifyFinished): Gets called when the SVG document finished loading, triggers repaint.
(WebCore::RenderLayer::MaskImageInfo::imageChanged): Gets called when the image object changed, triggers repaint.
(WebCore::RenderLayer::MaskImageInfo::updateMaskImageClients): Goes through all mask layers and sets image/SVG clients.
Updates list of internal and external SVG references.
(WebCore::RenderLayer::MaskImageInfo::removeMaskImageClients): Removes all image/SVG clients and clears lists of internal and external SVG references.
* rendering/RenderLayerMaskImageInfo.h: Added.
* rendering/RenderObject.h:
(WebCore::RenderObject::isRenderSVGResourceMasker):
* rendering/style/FillLayer.cpp:
(WebCore::FillLayer::FillLayer):
(WebCore::FillLayer::operator=):
(WebCore::FillLayer::operator==):
(WebCore::FillLayer::cullEmptyLayers):
(WebCore::FillLayer::hasNonEmptyMaskImage):
(WebCore::FillLayer::imagesAreLoaded):
* rendering/style/FillLayer.h:
(WebCore::FillLayer::maskImage):
(WebCore::FillLayer::imageOrMaskImage):
(WebCore::FillLayer::setMaskImage):
(WebCore::FillLayer::clearMaskImage):
(WebCore::FillLayer::hasMaskImage):
* rendering/svg/RenderSVGResourceMasker.cpp:
(WebCore::RenderSVGResourceMasker::applySVGMask):
(WebCore::RenderSVGResourceMasker::applyResource):
(WebCore::RenderSVGResourceMasker::drawMaskForRenderer):
* rendering/svg/RenderSVGResourceMasker.h:
* svg/SVGMaskElement.cpp:
(WebCore::SVGMaskElement::createElementRenderer):
(WebCore::SVGMaskElement::addClientRenderLayer):
(WebCore::SVGMaskElement::removeClientRenderLayer):
* svg/SVGMaskElement.h:
* svg/SVGUseElement.cpp:
(WebCore::SVGUseElement::setCachedDocument):
* svg/graphics/SVGImage.cpp:
(WebCore::SVGImage::dataChanged):</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="#trunkSourceWebCoreWebCorevcxprojWebCorevcxproj">trunk/Source/WebCore/WebCore.vcxproj/WebCore.vcxproj</a></li>
<li><a href="#trunkSourceWebCoreWebCorevcxprojWebCorevcxprojfilters">trunk/Source/WebCore/WebCore.vcxproj/WebCore.vcxproj.filters</a></li>
<li><a href="#trunkSourceWebCoreWebCorexcodeprojprojectpbxproj">trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj</a></li>
<li><a href="#trunkSourceWebCorecssCSSValuecpp">trunk/Source/WebCore/css/CSSValue.cpp</a></li>
<li><a href="#trunkSourceWebCorecssCSSValueh">trunk/Source/WebCore/css/CSSValue.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>
<li><a href="#trunkSourceWebCoreloadercacheCachedResourceLoadercpp">trunk/Source/WebCore/loader/cache/CachedResourceLoader.cpp</a></li>
<li><a href="#trunkSourceWebCoreloadercacheCachedResourceLoaderh">trunk/Source/WebCore/loader/cache/CachedResourceLoader.h</a></li>
<li><a href="#trunkSourceWebCoreloadercacheCachedSVGDocumentcpp">trunk/Source/WebCore/loader/cache/CachedSVGDocument.cpp</a></li>
<li><a href="#trunkSourceWebCoreloadercacheCachedSVGDocumenth">trunk/Source/WebCore/loader/cache/CachedSVGDocument.h</a></li>
<li><a href="#trunkSourceWebCoreloadercacheCachedSVGDocumentReferencecpp">trunk/Source/WebCore/loader/cache/CachedSVGDocumentReference.cpp</a></li>
<li><a href="#trunkSourceWebCoreloadercacheCachedSVGDocumentReferenceh">trunk/Source/WebCore/loader/cache/CachedSVGDocumentReference.h</a></li>
<li><a href="#trunkSourceWebCorepageFrameViewcpp">trunk/Source/WebCore/page/FrameView.cpp</a></li>
<li><a href="#trunkSourceWebCorepageFrameViewh">trunk/Source/WebCore/page/FrameView.h</a></li>
<li><a href="#trunkSourceWebCorepagePagecpp">trunk/Source/WebCore/page/Page.cpp</a></li>
<li><a href="#trunkSourceWebCorepagePageh">trunk/Source/WebCore/page/Page.h</a></li>
<li><a href="#trunkSourceWebCoreplatformScrollViewh">trunk/Source/WebCore/platform/ScrollView.h</a></li>
<li><a href="#trunkSourceWebCorerenderingRenderBoxModelObjectcpp">trunk/Source/WebCore/rendering/RenderBoxModelObject.cpp</a></li>
<li><a href="#trunkSourceWebCorerenderingRenderBoxModelObjecth">trunk/Source/WebCore/rendering/RenderBoxModelObject.h</a></li>
<li><a href="#trunkSourceWebCorerenderingRenderLayercpp">trunk/Source/WebCore/rendering/RenderLayer.cpp</a></li>
<li><a href="#trunkSourceWebCorerenderingRenderLayerh">trunk/Source/WebCore/rendering/RenderLayer.h</a></li>
<li><a href="#trunkSourceWebCorerenderingstyleFillLayercpp">trunk/Source/WebCore/rendering/style/FillLayer.cpp</a></li>
<li><a href="#trunkSourceWebCorerenderingstyleFillLayerh">trunk/Source/WebCore/rendering/style/FillLayer.h</a></li>
<li><a href="#trunkSourceWebCorerenderingsvgRenderSVGResourceMaskercpp">trunk/Source/WebCore/rendering/svg/RenderSVGResourceMasker.cpp</a></li>
<li><a href="#trunkSourceWebCorerenderingsvgRenderSVGResourceMaskerh">trunk/Source/WebCore/rendering/svg/RenderSVGResourceMasker.h</a></li>
<li><a href="#trunkSourceWebCoresvgSVGMaskElementcpp">trunk/Source/WebCore/svg/SVGMaskElement.cpp</a></li>
<li><a href="#trunkSourceWebCoresvgSVGMaskElementh">trunk/Source/WebCore/svg/SVGMaskElement.h</a></li>
<li><a href="#trunkSourceWebCoresvgSVGUseElementcpp">trunk/Source/WebCore/svg/SVGUseElement.cpp</a></li>
<li><a href="#trunkSourceWebCoresvggraphicsSVGImagecpp">trunk/Source/WebCore/svg/graphics/SVGImage.cpp</a></li>
</ul>
<h3>Added Paths</h3>
<ul>
<li><a href="#trunkSourceWebCorecssWebKitCSSResourceValuecpp">trunk/Source/WebCore/css/WebKitCSSResourceValue.cpp</a></li>
<li><a href="#trunkSourceWebCorecssWebKitCSSResourceValueh">trunk/Source/WebCore/css/WebKitCSSResourceValue.h</a></li>
<li><a href="#trunkSourceWebCoreplatformgraphicsMaskImageOperationcpp">trunk/Source/WebCore/platform/graphics/MaskImageOperation.cpp</a></li>
<li><a href="#trunkSourceWebCoreplatformgraphicsMaskImageOperationh">trunk/Source/WebCore/platform/graphics/MaskImageOperation.h</a></li>
<li><a href="#trunkSourceWebCorerenderingRenderLayerMaskImageInfocpp">trunk/Source/WebCore/rendering/RenderLayerMaskImageInfo.cpp</a></li>
<li><a href="#trunkSourceWebCorerenderingRenderLayerMaskImageInfoh">trunk/Source/WebCore/rendering/RenderLayerMaskImageInfo.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 (176797 => 176798)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/CMakeLists.txt        2014-12-04 16:36:02 UTC (rev 176797)
+++ trunk/Source/WebCore/CMakeLists.txt        2014-12-04 17:05:12 UTC (rev 176798)
</span><span class="lines">@@ -1289,6 +1289,7 @@
</span><span class="cx"> css/TransformFunctions.cpp
</span><span class="cx"> css/ViewportStyleResolver.cpp
</span><span class="cx"> css/WebKitCSSFilterValue.cpp
</span><ins>+ css/WebKitCSSResourceValue.cpp
</ins><span class="cx"> css/CSSKeyframeRule.cpp
</span><span class="cx"> css/CSSKeyframesRule.cpp
</span><span class="cx"> css/WebKitCSSMatrix.cpp
</span><span class="lines">@@ -2089,6 +2090,7 @@
</span><span class="cx"> platform/graphics/ISOVTTCue.cpp
</span><span class="cx"> platform/graphics/LayoutBoxExtent.cpp
</span><span class="cx"> platform/graphics/LayoutRect.cpp
</span><ins>+ platform/graphics/MaskImageOperation.cpp
</ins><span class="cx"> platform/graphics/MediaPlayer.cpp
</span><span class="cx"> platform/graphics/Path.cpp
</span><span class="cx"> platform/graphics/PathTraversalState.cpp
</span><span class="lines">@@ -2295,6 +2297,7 @@
</span><span class="cx"> rendering/RenderLayerBacking.cpp
</span><span class="cx"> rendering/RenderLayerCompositor.cpp
</span><span class="cx"> rendering/RenderLayerFilterInfo.cpp
</span><ins>+ rendering/RenderLayerMaskImageInfo.cpp
</ins><span class="cx"> rendering/RenderLayerModelObject.cpp
</span><span class="cx"> rendering/RenderLineBoxList.cpp
</span><span class="cx"> rendering/RenderLineBreak.cpp
</span></span></pre></div>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (176797 => 176798)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog        2014-12-04 16:36:02 UTC (rev 176797)
+++ trunk/Source/WebCore/ChangeLog        2014-12-04 17:05:12 UTC (rev 176798)
</span><span class="lines">@@ -1,3 +1,183 @@
</span><ins>+2014-12-04 Radu Stavila <stavila@adobe.com>
+
+ [SVG Masking] Add support for referencing <mask> elements from -webkit-mask-image
+ https://bugs.webkit.org/show_bug.cgi?id=139092
+
+ Reviewed by Simon Fraser.
+
+ This patch improves the -webkit-mask-image property by allowing it to reference
+ a <mask> element defined in an inline or external SVG document.
+ Up until now, each image to be used as a mask consisted of a FillLayer object
+ whose m_image member represented the mask. Now, in order to accomodate
+ <mask> elements referenced by a fragment identifier (e.g. file.svg#mask1)
+ a new class was created (MaskImageOperation) and added as a member of the
+ FillLayer. As such, from now on, all FillLayer objects used for masking will
+ store the masking information in this new member.
+ When parsing the -webkit-mask-image property (or the -webkit-mask shorthand)
+ a new MaskImageOperation object is created for each image. If the value represents
+ an external URL, a pending SVG document will be created which will be loaded
+ during the phase that loads the pending resources. When the download is complete,
+ the MaskImageOperation is notified by the CachedSVGDocument class and checks if
+ the received download is a valid SVG and the requested fragment identifier
+ actually exists and identifies a <mask> element. If it does, that element's
+ renderer (of type RenderSVGResourceMasker) will be used when painting the mask layers.
+ Otherwise, the MaskImageOperation class will use the already downloaded data
+ buffer to create a CachedImage from it and use that instead, basically emulating
+ the previous behavior, when only images were accepted. This ensures that all existing
+ behavior, like painting entire SVGs, painting normal images (e.g. PNG/JPG), painting
+ generated images (e.g. linear-gradient) works as it did before.
+
+ No new tests required, this patch doesn't change any current functionality.
+ It only adds support for referencing <mask> elements for the -webkit-mask-image
+ property. This is sub-part 1 of the bigger patch https://bugs.webkit.org/show_bug.cgi?id=129682.
+
+ * CMakeLists.txt:
+ * WebCore.vcxproj/WebCore.vcxproj:
+ * WebCore.vcxproj/WebCore.vcxproj.filters:
+ * WebCore.xcodeproj/project.pbxproj:
+ * css/CSSValue.cpp:
+ (WebCore::CSSValue::cssText):
+ (WebCore::CSSValue::destroy):
+ * css/CSSValue.h:
+ (WebCore::CSSValue::isWebKitCSSResourceValue):
+ * css/StyleResolver.cpp:
+ (WebCore::StyleResolver::State::clear):
+ (WebCore::StyleResolver::createMaskImageOperations):
+ * css/StyleResolver.h:
+ (WebCore::StyleResolver::State::maskImagesWithPendingSVGDocuments):
+ * css/WebKitCSSResourceValue.cpp: Added.
+ (WebCore::WebKitCSSResourceValue::WebKitCSSResourceValue):
+ (WebCore::WebKitCSSResourceValue::customCSSText):
+ (WebCore::WebKitCSSResourceValue::isCSSValueNone):
+ * css/WebKitCSSResourceValue.h: Added.
+ (WebCore::WebKitCSSResourceValue::create):
+ (WebCore::WebKitCSSResourceValue::innerValue):
+ * loader/cache/CachedResourceLoader.cpp:
+ (WebCore::CachedResourceLoader::addCachedResource):
+ * loader/cache/CachedResourceLoader.h:
+ * loader/cache/CachedSVGDocument.cpp:
+ (WebCore::CachedSVGDocument::CachedSVGDocument):
+ (WebCore::CachedSVGDocument::finishLoading):
+ * loader/cache/CachedSVGDocument.h:
+ * loader/cache/CachedSVGDocumentReference.cpp:
+ (WebCore::CachedSVGDocumentReference::CachedSVGDocumentReference):
+ (WebCore::CachedSVGDocumentReference::~CachedSVGDocumentReference):
+ (WebCore::CachedSVGDocumentReference::load):
+ * loader/cache/CachedSVGDocumentReference.h:
+ * page/FrameView.cpp:
+ (WebCore::FrameView::isSVGDocument):
+ * page/FrameView.h:
+ * page/Page.cpp:
+ (WebCore::Page::createPageFromBuffer):
+ * page/Page.h:
+ * platform/ScrollView.h:
+ (WebCore::ScrollView::isSVGDocument):
+ * platform/graphics/MaskImageOperation.cpp: Added.
+ (WebCore::MaskImageOperation::create):
+ (WebCore::MaskImageOperation::MaskImageOperation):
+ (WebCore::MaskImageOperation::~MaskImageOperation):
+ (WebCore::MaskImageOperation::isCSSValueNone):
+ (WebCore::MaskImageOperation::cssValue):
+ (WebCore::MaskImageOperation::isMaskLoaded):
+ (WebCore::MaskImageOperation::setRenderLayerImageClient):
+ (WebCore::MaskImageOperation::addRendererImageClient):
+ (WebCore::MaskImageOperation::removeRendererImageClient):
+ (WebCore::MaskImageOperation::getOrCreateCachedSVGDocumentReference):
+ (WebCore::MaskImageOperation::notifyFinished): This is the method that gets called when the document has finished
+ downloading and checks if it can find a valid <mask> element.
+ (WebCore::MaskImageOperation::drawMask):
+ (WebCore::MaskImageOperation::getSVGMasker):
+ * platform/graphics/MaskImageOperation.h: Added.
+ * rendering/RenderBoxModelObject.cpp: The BackgroundImageGeometry class was moved out of RenderBoxModelObject in
+ order to be used as a parameter for other methods. This was necessary to avoid having methods with very many parameters.
+ (WebCore::BackgroundImageGeometry::setNoRepeatX):
+ (WebCore::BackgroundImageGeometry::setNoRepeatY):
+ (WebCore::BackgroundImageGeometry::useFixedAttachment):
+ (WebCore::BackgroundImageGeometry::clip):
+ (WebCore::BackgroundImageGeometry::relativePhase):
+ (WebCore::RenderBoxModelObject::BackgroundImageGeometry::setNoRepeatX): Deleted.
+ (WebCore::RenderBoxModelObject::BackgroundImageGeometry::setNoRepeatY): Deleted.
+ (WebCore::RenderBoxModelObject::BackgroundImageGeometry::useFixedAttachment): Deleted.
+ (WebCore::RenderBoxModelObject::BackgroundImageGeometry::clip): Deleted.
+ (WebCore::RenderBoxModelObject::BackgroundImageGeometry::relativePhase): Deleted.
+ * rendering/RenderBoxModelObject.h:
+ (WebCore::BackgroundImageGeometry::BackgroundImageGeometry):
+ (WebCore::BackgroundImageGeometry::destOrigin):
+ (WebCore::BackgroundImageGeometry::setDestOrigin):
+ (WebCore::BackgroundImageGeometry::destRect):
+ (WebCore::BackgroundImageGeometry::setDestRect):
+ (WebCore::BackgroundImageGeometry::phase):
+ (WebCore::BackgroundImageGeometry::setPhase):
+ (WebCore::BackgroundImageGeometry::tileSize):
+ (WebCore::BackgroundImageGeometry::setTileSize):
+ (WebCore::BackgroundImageGeometry::spaceSize):
+ (WebCore::BackgroundImageGeometry::setSpaceSize):
+ (WebCore::BackgroundImageGeometry::setPhaseX):
+ (WebCore::BackgroundImageGeometry::setPhaseY):
+ (WebCore::BackgroundImageGeometry::setHasNonLocalGeometry):
+ (WebCore::BackgroundImageGeometry::hasNonLocalGeometry):
+ (WebCore::RenderBoxModelObject::BackgroundImageGeometry::BackgroundImageGeometry): Deleted.
+ (WebCore::RenderBoxModelObject::BackgroundImageGeometry::destOrigin): Deleted.
+ (WebCore::RenderBoxModelObject::BackgroundImageGeometry::setDestOrigin): Deleted.
+ (WebCore::RenderBoxModelObject::BackgroundImageGeometry::destRect): Deleted.
+ (WebCore::RenderBoxModelObject::BackgroundImageGeometry::setDestRect): Deleted.
+ (WebCore::RenderBoxModelObject::BackgroundImageGeometry::phase): Deleted.
+ (WebCore::RenderBoxModelObject::BackgroundImageGeometry::setPhase): Deleted.
+ (WebCore::RenderBoxModelObject::BackgroundImageGeometry::tileSize): Deleted.
+ (WebCore::RenderBoxModelObject::BackgroundImageGeometry::setTileSize): Deleted.
+ (WebCore::RenderBoxModelObject::BackgroundImageGeometry::spaceSize): Deleted.
+ (WebCore::RenderBoxModelObject::BackgroundImageGeometry::setSpaceSize): Deleted.
+ (WebCore::RenderBoxModelObject::BackgroundImageGeometry::setPhaseX): Deleted.
+ (WebCore::RenderBoxModelObject::BackgroundImageGeometry::setPhaseY): Deleted.
+ (WebCore::RenderBoxModelObject::BackgroundImageGeometry::setHasNonLocalGeometry): Deleted.
+ (WebCore::RenderBoxModelObject::BackgroundImageGeometry::hasNonLocalGeometry): Deleted.
+ * rendering/RenderLayer.cpp:
+ (WebCore::RenderLayer::RenderLayer):
+ (WebCore::RenderLayer::~RenderLayer):
+ * rendering/RenderLayer.h:
+ * rendering/RenderLayerMaskImageInfo.cpp: Added.
+ (WebCore::RenderLayer::MaskImageInfo::layerToMaskMap): Returns a static map that links MaskImageInfo objects to RenderLayers.
+ (WebCore::RenderLayer::MaskImageInfo::getIfExists): Returns the MaskImageInfo associated with a specific RenderLayer.
+ (WebCore::RenderLayer::MaskImageInfo::get): Returns the MaskImageInfo associated with a specific RenderLayer (creates it if necessary).
+ (WebCore::RenderLayer::MaskImageInfo::remove): Removes the MaskImageInfo associated with a specific RenderLayer.
+ (WebCore::RenderLayer::MaskImageInfo::MaskImageInfo):
+ (WebCore::RenderLayer::MaskImageInfo::~MaskImageInfo):
+ (WebCore::RenderLayer::MaskImageInfo::notifyFinished): Gets called when the SVG document finished loading, triggers repaint.
+ (WebCore::RenderLayer::MaskImageInfo::imageChanged): Gets called when the image object changed, triggers repaint.
+ (WebCore::RenderLayer::MaskImageInfo::updateMaskImageClients): Goes through all mask layers and sets image/SVG clients.
+ Updates list of internal and external SVG references.
+ (WebCore::RenderLayer::MaskImageInfo::removeMaskImageClients): Removes all image/SVG clients and clears lists of internal and external SVG references.
+ * rendering/RenderLayerMaskImageInfo.h: Added.
+ * rendering/RenderObject.h:
+ (WebCore::RenderObject::isRenderSVGResourceMasker):
+ * rendering/style/FillLayer.cpp:
+ (WebCore::FillLayer::FillLayer):
+ (WebCore::FillLayer::operator=):
+ (WebCore::FillLayer::operator==):
+ (WebCore::FillLayer::cullEmptyLayers):
+ (WebCore::FillLayer::hasNonEmptyMaskImage):
+ (WebCore::FillLayer::imagesAreLoaded):
+ * rendering/style/FillLayer.h:
+ (WebCore::FillLayer::maskImage):
+ (WebCore::FillLayer::imageOrMaskImage):
+ (WebCore::FillLayer::setMaskImage):
+ (WebCore::FillLayer::clearMaskImage):
+ (WebCore::FillLayer::hasMaskImage):
+ * rendering/svg/RenderSVGResourceMasker.cpp:
+ (WebCore::RenderSVGResourceMasker::applySVGMask):
+ (WebCore::RenderSVGResourceMasker::applyResource):
+ (WebCore::RenderSVGResourceMasker::drawMaskForRenderer):
+ * rendering/svg/RenderSVGResourceMasker.h:
+ * svg/SVGMaskElement.cpp:
+ (WebCore::SVGMaskElement::createElementRenderer):
+ (WebCore::SVGMaskElement::addClientRenderLayer):
+ (WebCore::SVGMaskElement::removeClientRenderLayer):
+ * svg/SVGMaskElement.h:
+ * svg/SVGUseElement.cpp:
+ (WebCore::SVGUseElement::setCachedDocument):
+ * svg/graphics/SVGImage.cpp:
+ (WebCore::SVGImage::dataChanged):
+
</ins><span class="cx"> 2014-12-04 Commit Queue <commit-queue@webkit.org>
</span><span class="cx">
</span><span class="cx"> Unreviewed, rolling out r176789.
</span></span></pre></div>
<a id="trunkSourceWebCoreWebCorevcxprojWebCorevcxproj"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/WebCore.vcxproj/WebCore.vcxproj (176797 => 176798)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/WebCore.vcxproj/WebCore.vcxproj        2014-12-04 16:36:02 UTC (rev 176797)
+++ trunk/Source/WebCore/WebCore.vcxproj/WebCore.vcxproj        2014-12-04 17:05:12 UTC (rev 176798)
</span><span class="lines">@@ -749,6 +749,7 @@
</span><span class="cx"> <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</ExcludedFromBuild>
</span><span class="cx"> <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild>
</span><span class="cx"> </ClCompile>
</span><ins>+ <ClCompile Include="..\css\WebKitCSSResourceValue.cpp" />
</ins><span class="cx"> <ClCompile Include="..\DerivedSources.cpp">
</span><span class="cx"> <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
</span><span class="cx"> </PrecompiledHeader>
</span><span class="lines">@@ -7582,6 +7583,7 @@
</span><span class="cx"> <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Production|Win32'">true</ExcludedFromBuild>
</span><span class="cx"> <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Production|x64'">true</ExcludedFromBuild>
</span><span class="cx"> </ClCompile>
</span><ins>+ <ClCompile Include="..\platform\graphics\MaskImageOperation.cpp" />
</ins><span class="cx"> <ClCompile Include="..\platform\graphics\OpenGLShims.cpp" />
</span><span class="cx"> <ClCompile Include="..\platform\graphics\opengl\Extensions3DOpenGL.cpp" />
</span><span class="cx"> <ClCompile Include="..\platform\graphics\opengl\Extensions3DOpenGLCommon.cpp" />
</span><span class="lines">@@ -7950,6 +7952,7 @@
</span><span class="cx"> <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Production|Win32'">true</ExcludedFromBuild>
</span><span class="cx"> <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Production|x64'">true</ExcludedFromBuild>
</span><span class="cx"> </ClCompile>
</span><ins>+ <ClCompile Include="..\rendering\RenderLayerMaskImageInfo.cpp" />
</ins><span class="cx"> <ClCompile Include="..\rendering\style\StyleCachedImageSet.cpp">
</span><span class="cx"> <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='DebugSuffix|Win32'">true</ExcludedFromBuild>
</span><span class="cx"> <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='DebugSuffix|x64'">true</ExcludedFromBuild>
</span><span class="lines">@@ -18851,6 +18854,7 @@
</span><span class="cx"> <ClInclude Include="$(ConfigurationBuildDir)\obj$(PlatformArchitecture)\$(ProjectName)\DerivedSources\JSVTTRegionList.h" />
</span><span class="cx"> <ClInclude Include="..\accessibility\AccessibilityNodeObject.h" />
</span><span class="cx"> <ClInclude Include="..\css\CSSImageSetValue.h" />
</span><ins>+ <ClInclude Include="..\css\WebKitCSSResourceValue.h" />
</ins><span class="cx"> <ClInclude Include="..\ForwardingHeaders\bindings\ScriptFunctionCall.h" />
</span><span class="cx"> <ClInclude Include="..\ForwardingHeaders\bindings\ScriptObject.h" />
</span><span class="cx"> <ClInclude Include="..\ForwardingHeaders\bindings\ScriptValue.h" />
</span><span class="lines">@@ -19407,6 +19411,7 @@
</span><span class="cx"> <ClInclude Include="..\platform\graphics\gstreamer\VideoSinkGStreamer.h" />
</span><span class="cx"> <ClInclude Include="..\platform\graphics\gstreamer\VideoTrackPrivateGStreamer.h" />
</span><span class="cx"> <ClInclude Include="..\platform\graphics\gstreamer\WebKitWebSourceGStreamer.h" />
</span><ins>+ <ClInclude Include="..\platform\graphics\MaskImageOperation.h" />
</ins><span class="cx"> <ClInclude Include="..\platform\graphics\MediaPlayerPrivate.h" />
</span><span class="cx"> <ClInclude Include="..\platform\graphics\OpenGLShims.h" />
</span><span class="cx"> <ClInclude Include="..\platform\graphics\opengl\Extensions3DOpenGL.h" />
</span><span class="lines">@@ -19538,6 +19543,7 @@
</span><span class="cx"> <ClInclude Include="..\platform\win\WebCoreBundleWin.h" />
</span><span class="cx"> <ClInclude Include="..\platform\win\WebCoreInstanceHandle.h" />
</span><span class="cx"> <ClInclude Include="..\rendering\HitTestLocation.h" />
</span><ins>+ <ClInclude Include="..\rendering\RenderLayerMaskImageInfo.h" />
</ins><span class="cx"> <ClInclude Include="..\rendering\style\StyleCachedImageSet.h" />
</span><span class="cx"> <ClInclude Include="..\storage\StorageStrategy.h" />
</span><span class="cx"> <ClInclude Include="..\svg\graphics\SVGImageForContainer.h" />
</span></span></pre></div>
<a id="trunkSourceWebCoreWebCorevcxprojWebCorevcxprojfilters"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/WebCore.vcxproj/WebCore.vcxproj.filters (176797 => 176798)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/WebCore.vcxproj/WebCore.vcxproj.filters        2014-12-04 16:36:02 UTC (rev 176797)
+++ trunk/Source/WebCore/WebCore.vcxproj/WebCore.vcxproj.filters        2014-12-04 17:05:12 UTC (rev 176798)
</span><span class="lines">@@ -7252,6 +7252,15 @@
</span><span class="cx"> <ClCompile Include="..\editing\win\EditorWin.cpp">
</span><span class="cx"> <Filter>editing</Filter>
</span><span class="cx"> </ClCompile>
</span><ins>+ <ClCompile Include="..\platform\graphics\MaskImageOperation.cpp">
+ <Filter>platform\graphics</Filter>
+ </ClCompile>
+ <ClCompile Include="..\rendering\RenderLayerMaskImageInfo.cpp">
+ <Filter>rendering</Filter>
+ </ClCompile>
+ <ClCompile Include="..\css\WebKitCSSResourceValue.cpp">
+ <Filter>css</Filter>
+ </ClCompile>
</ins><span class="cx"> </ItemGroup>
</span><span class="cx"> <ItemGroup>
</span><span class="cx"> <ClInclude Include="..\Modules\geolocation\Coordinates.h">
</span><span class="lines">@@ -15242,6 +15251,15 @@
</span><span class="cx"> <ClInclude Include="..\platform\graphics\avfoundation\MediaTimeAVFoundation.h">
</span><span class="cx"> <Filter>platform\graphics\avfoundation</Filter>
</span><span class="cx"> </ClInclude>
</span><ins>+ <ClInclude Include="..\platform\graphics\MaskImageOperation.h">
+ <Filter>platform\graphics</Filter>
+ </ClInclude>
+ <ClInclude Include="..\rendering\RenderLayerMaskImageInfo.h">
+ <Filter>rendering</Filter>
+ </ClInclude>
+ <ClInclude Include="..\css\WebKitCSSResourceValue.h">
+ <Filter>css</Filter>
+ </ClInclude>
</ins><span class="cx"> </ItemGroup>
</span><span class="cx"> <ItemGroup>
</span><span class="cx"> <None Include="..\css\CSSGrammar.y.in">
</span></span></pre></div>
<a id="trunkSourceWebCoreWebCorexcodeprojprojectpbxproj"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj (176797 => 176798)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj        2014-12-04 16:36:02 UTC (rev 176797)
+++ trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj        2014-12-04 17:05:12 UTC (rev 176798)
</span><span class="lines">@@ -2236,8 +2236,14 @@
</span><span class="cx">                 65FD466619B596F6001E2B4D /* WebVideoFullscreenModelVideoElement.mm in Sources */ = {isa = PBXBuildFile; fileRef = 6586FE3D19B548BD005C3C82 /* WebVideoFullscreenModelVideoElement.mm */; };
</span><span class="cx">                 65FEA86909833ADE00BED4AB /* Page.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 65FEA86809833ADE00BED4AB /* Page.cpp */; };
</span><span class="cx">                 6B3480940EEF50D400AC1B41 /* NativeImagePtr.h in Headers */ = {isa = PBXBuildFile; fileRef = 6B3480920EEF50D400AC1B41 /* NativeImagePtr.h */; settings = {ATTRIBUTES = (Private, ); }; };
</span><ins>+                6C568CB019DAFEA000430CA2 /* MaskImageOperation.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 6C568CAE19DAFEA000430CA2 /* MaskImageOperation.cpp */; };
+                6C568CB119DAFEA000430CA2 /* MaskImageOperation.h in Headers */ = {isa = PBXBuildFile; fileRef = 6C568CAF19DAFEA000430CA2 /* MaskImageOperation.h */; settings = {ATTRIBUTES = (Private, ); }; };
</ins><span class="cx">                 6C638895A96CCEE50C8C946C /* CachedResourceRequestInitiators.h in Headers */ = {isa = PBXBuildFile; fileRef = 6C638893A96CCEE50C8C946C /* CachedResourceRequestInitiators.h */; settings = {ATTRIBUTES = (Private, ); }; };
</span><span class="cx">                 6C638896A96CCEE50C8C946C /* CachedResourceRequestInitiators.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 6C638894A96CCEE50C8C946C /* CachedResourceRequestInitiators.cpp */; };
</span><ins>+                6C6CCAB019DC42B90043D5DB /* WebKitCSSResourceValue.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 6C6CCAAE19DC42B90043D5DB /* WebKitCSSResourceValue.cpp */; };
+                6C6CCAB119DC42B90043D5DB /* WebKitCSSResourceValue.h in Headers */ = {isa = PBXBuildFile; fileRef = 6C6CCAAF19DC42B90043D5DB /* WebKitCSSResourceValue.h */; };
+                6CBFE4A419EBF2D400CA2F9D /* RenderLayerMaskImageInfo.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 6CBFE4A219EBF2D400CA2F9D /* RenderLayerMaskImageInfo.cpp */; };
+                6CBFE4A519EBF2D400CA2F9D /* RenderLayerMaskImageInfo.h in Headers */ = {isa = PBXBuildFile; fileRef = 6CBFE4A319EBF2D400CA2F9D /* RenderLayerMaskImageInfo.h */; };
</ins><span class="cx">                 6CDDE8D01770BB220016E072 /* RegionOversetState.h in Headers */ = {isa = PBXBuildFile; fileRef = 6C70A81417707C49009A446E /* RegionOversetState.h */; settings = {ATTRIBUTES = (Private, ); }; };
</span><span class="cx">                 6E0E569B183BFFE600E0E8D5 /* FloatRoundedRect.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 6E0E5699183BFFE600E0E8D5 /* FloatRoundedRect.cpp */; };
</span><span class="cx">                 6E0E569C183BFFE600E0E8D5 /* FloatRoundedRect.h in Headers */ = {isa = PBXBuildFile; fileRef = 6E0E569A183BFFE600E0E8D5 /* FloatRoundedRect.h */; settings = {ATTRIBUTES = (Private, ); }; };
</span><span class="lines">@@ -9401,9 +9407,15 @@
</span><span class="cx">                 65F80697054D9F86008BF776 /* BlockExceptions.mm */ = {isa = PBXFileReference; fileEncoding = 30; indentWidth = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = BlockExceptions.mm; sourceTree = "<group>"; tabWidth = 8; usesTabs = 0; };
</span><span class="cx">                 65FEA86809833ADE00BED4AB /* Page.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = Page.cpp; sourceTree = "<group>"; };
</span><span class="cx">                 6B3480920EEF50D400AC1B41 /* NativeImagePtr.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = NativeImagePtr.h; sourceTree = "<group>"; };
</span><ins>+                6C568CAE19DAFEA000430CA2 /* MaskImageOperation.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = MaskImageOperation.cpp; sourceTree = "<group>"; };
+                6C568CAF19DAFEA000430CA2 /* MaskImageOperation.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MaskImageOperation.h; sourceTree = "<group>"; };
</ins><span class="cx">                 6C638893A96CCEE50C8C946C /* CachedResourceRequestInitiators.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = CachedResourceRequestInitiators.h; sourceTree = "<group>"; };
</span><span class="cx">                 6C638894A96CCEE50C8C946C /* CachedResourceRequestInitiators.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = CachedResourceRequestInitiators.cpp; sourceTree = "<group>"; };
</span><ins>+                6C6CCAAE19DC42B90043D5DB /* WebKitCSSResourceValue.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WebKitCSSResourceValue.cpp; sourceTree = "<group>"; };
+                6C6CCAAF19DC42B90043D5DB /* WebKitCSSResourceValue.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebKitCSSResourceValue.h; sourceTree = "<group>"; };
</ins><span class="cx">                 6C70A81417707C49009A446E /* RegionOversetState.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RegionOversetState.h; sourceTree = "<group>"; };
</span><ins>+                6CBFE4A219EBF2D400CA2F9D /* RenderLayerMaskImageInfo.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = RenderLayerMaskImageInfo.cpp; sourceTree = "<group>"; };
+                6CBFE4A319EBF2D400CA2F9D /* RenderLayerMaskImageInfo.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RenderLayerMaskImageInfo.h; sourceTree = "<group>"; };
</ins><span class="cx">                 6E0E5699183BFFE600E0E8D5 /* FloatRoundedRect.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = FloatRoundedRect.cpp; sourceTree = "<group>"; };
</span><span class="cx">                 6E0E569A183BFFE600E0E8D5 /* FloatRoundedRect.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FloatRoundedRect.h; sourceTree = "<group>"; };
</span><span class="cx">                 6E21C6BF1126338500A7BE02 /* GraphicsContext3D.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = GraphicsContext3D.cpp; sourceTree = "<group>"; };
</span><span class="lines">@@ -20588,6 +20600,8 @@
</span><span class="cx">                                 141DC04C164834B900371E5A /* LayoutRect.cpp */,
</span><span class="cx">                                 141DC04D164834B900371E5A /* LayoutRect.h */,
</span><span class="cx">                                 141DC04E164834B900371E5A /* LayoutSize.h */,
</span><ins>+                                6C568CAE19DAFEA000430CA2 /* MaskImageOperation.cpp */,
+                                6C568CAF19DAFEA000430CA2 /* MaskImageOperation.h */,
</ins><span class="cx">                                 E4B41E0C0CBF90BD00AF2ECE /* MediaPlayer.cpp */,
</span><span class="cx">                                 E4B41E0D0CBF90BD00AF2ECE /* MediaPlayer.h */,
</span><span class="cx">                                 079F5E4B0F3BEBEA005E0782 /* MediaPlayerPrivate.h */,
</span><span class="lines">@@ -22293,6 +22307,8 @@
</span><span class="cx">                                 3106036C14327D2E00ABF4BA /* WebKitCSSFilterValue.cpp */,
</span><span class="cx">                                 3106036D14327D2E00ABF4BA /* WebKitCSSFilterValue.h */,
</span><span class="cx">                                 3106036E14327D2E00ABF4BA /* WebKitCSSFilterValue.idl */,
</span><ins>+                                6C6CCAAE19DC42B90043D5DB /* WebKitCSSResourceValue.cpp */,
+                                6C6CCAAF19DC42B90043D5DB /* WebKitCSSResourceValue.h */,
</ins><span class="cx">                                 31288E6E0E3005D6003619AE /* CSSKeyframeRule.cpp */,
</span><span class="cx">                                 31288E6F0E3005D6003619AE /* CSSKeyframeRule.h */,
</span><span class="cx">                                 316FE0910E6CCD7F00BF6088 /* CSSKeyframeRule.idl */,
</span><span class="lines">@@ -22447,6 +22463,8 @@
</span><span class="cx">                                 0F580CF90F12DE9B0051D689 /* RenderLayerCompositor.h */,
</span><span class="cx">                                 50D10D971545F5760096D288 /* RenderLayerFilterInfo.cpp */,
</span><span class="cx">                                 50D10D981545F5760096D288 /* RenderLayerFilterInfo.h */,
</span><ins>+                                6CBFE4A219EBF2D400CA2F9D /* RenderLayerMaskImageInfo.cpp */,
+                                6CBFE4A319EBF2D400CA2F9D /* RenderLayerMaskImageInfo.h */,
</ins><span class="cx">                                 3C244FE5A375AC633F88BE6F /* RenderLayerModelObject.cpp */,
</span><span class="cx">                                 3C244FE4A375AC633F88BE6F /* RenderLayerModelObject.h */,
</span><span class="cx">                                 BC33FB1A0F30EE85002CDD7C /* RenderLineBoxList.cpp */,
</span><span class="lines">@@ -23430,6 +23448,7 @@
</span><span class="cx">                                 316FE1140E6E1DA700BF6088 /* AnimationController.h in Headers */,
</span><span class="cx">                                 0F15DA8A0F3AAEE70000CE47 /* AnimationControllerPrivate.h in Headers */,
</span><span class="cx">                                 49E912AD0EFAC906009D0CAF /* AnimationList.h in Headers */,
</span><ins>+                                6C568CB119DAFEA000430CA2 /* MaskImageOperation.h in Headers */,
</ins><span class="cx">                                 0F580FAF149800D400FB5BD8 /* AnimationUtilities.h in Headers */,
</span><span class="cx">                                 93309DD7099E64920056E581 /* AppendNodeCommand.h in Headers */,
</span><span class="cx">                                 1A8F6BBD0DB55CDC001DB794 /* ApplicationCache.h in Headers */,
</span><span class="lines">@@ -25442,6 +25461,7 @@
</span><span class="cx">                                 CDBEAEAD19D92B6C00BEBA88 /* MediaSelectionGroupAVFObjC.h in Headers */,
</span><span class="cx">                                 070E09191875EEFC003A1D3C /* MediaSession.h in Headers */,
</span><span class="cx">                                 07F944161864D046005D31CB /* MediaSessionManager.h in Headers */,
</span><ins>+                                6CBFE4A519EBF2D400CA2F9D /* RenderLayerMaskImageInfo.h in Headers */,
</ins><span class="cx">                                 07638A991884487200E15A1B /* MediaSessionManagerIOS.h in Headers */,
</span><span class="cx">                                 CD3A495F17A9D01B00274E42 /* MediaSource.h in Headers */,
</span><span class="cx">                                 CD641EB31818F5ED00EE4C41 /* MediaSourcePrivate.h in Headers */,
</span><span class="lines">@@ -26045,6 +26065,7 @@
</span><span class="cx">                                 CDCFABBD18C0AF78006F8450 /* SelectionSubtreeRoot.h in Headers */,
</span><span class="cx">                                 E44B4BB4141650D7002B1D8B /* SelectorChecker.h in Headers */,
</span><span class="cx">                                 432D3FE818A8658400D7DC03 /* SelectorCheckerTestFunctions.h in Headers */,
</span><ins>+                                6C6CCAB119DC42B90043D5DB /* WebKitCSSResourceValue.h in Headers */,
</ins><span class="cx">                                 26B999971804D54200D01121 /* SelectorCompiler.h in Headers */,
</span><span class="cx">                                 415071581685067300C3C7B3 /* SelectorFilter.h in Headers */,
</span><span class="cx">                                 43107BE218CC19DE00CC18E8 /* SelectorPseudoTypeMap.h in Headers */,
</span><span class="lines">@@ -27753,6 +27774,7 @@
</span><span class="cx">                                 8A195933147EA16E00D1EA61 /* DOMWebKitNamedFlow.mm in Sources */,
</span><span class="cx">                                 31C0FF4D0E4CEFDD007D6FE5 /* DOMWebKitTransitionEvent.mm in Sources */,
</span><span class="cx">                                 85C7F5E80AAFBAFB004014DD /* DOMWheelEvent.mm in Sources */,
</span><ins>+                                6C6CCAB019DC42B90043D5DB /* WebKitCSSResourceValue.cpp in Sources */,
</ins><span class="cx">                                 1403B99809EB13AF00797C7F /* DOMWindow.cpp in Sources */,
</span><span class="cx">                                 FD677738195CAF3D0072E0D3 /* DOMWindowCSS.cpp in Sources */,
</span><span class="cx">                                 517FBA1E151AB17C00B57959 /* DOMWindowExtension.cpp in Sources */,
</span><span class="lines">@@ -28979,6 +29001,7 @@
</span><span class="cx">                                 CDB859F7160D48A400E5B07F /* MediaKeyEvent.cpp in Sources */,
</span><span class="cx">                                 CDA98DD816025BEF00FEA3B1 /* MediaKeyMessageEvent.cpp in Sources */,
</span><span class="cx">                                 CD1B4A65160786AE00282DF9 /* MediaKeyNeededEvent.cpp in Sources */,
</span><ins>+                                6C568CB019DAFEA000430CA2 /* MaskImageOperation.cpp in Sources */,
</ins><span class="cx">                                 CDA98E0D1603FE4A00FEA3B1 /* MediaKeys.cpp in Sources */,
</span><span class="cx">                                 CDA98E0E1603FE5800FEA3B1 /* MediaKeySession.cpp in Sources */,
</span><span class="cx">                                 A8EA80090A19516E00A8EF5F /* MediaList.cpp in Sources */,
</span><span class="lines">@@ -29047,6 +29070,7 @@
</span><span class="cx">                                 F55B3DC51251F12D003EF269 /* MonthInputType.cpp in Sources */,
</span><span class="cx">                                 85031B450A44EFC700F992E0 /* MouseEvent.cpp in Sources */,
</span><span class="cx">                                 93EB355F09E37FD600F43799 /* MouseEventWithHitTestResults.cpp in Sources */,
</span><ins>+                                6CBFE4A419EBF2D400CA2F9D /* RenderLayerMaskImageInfo.cpp in Sources */,
</ins><span class="cx">                                 85031B470A44EFC700F992E0 /* MouseRelatedEvent.cpp in Sources */,
</span><span class="cx">                                 93309DFB099E64920056E581 /* MoveSelectionCommand.cpp in Sources */,
</span><span class="cx">                                 FDB1700514A2BAB200A2B5D9 /* MultiChannelResampler.cpp in Sources */,
</span></span></pre></div>
<a id="trunkSourceWebCorecssCSSValuecpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/css/CSSValue.cpp (176797 => 176798)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/css/CSSValue.cpp        2014-12-04 16:36:02 UTC (rev 176797)
+++ trunk/Source/WebCore/css/CSSValue.cpp        2014-12-04 17:05:12 UTC (rev 176798)
</span><span class="lines">@@ -54,6 +54,7 @@
</span><span class="cx"> #include "SVGColor.h"
</span><span class="cx"> #include "SVGPaint.h"
</span><span class="cx"> #include "WebKitCSSFilterValue.h"
</span><ins>+#include "WebKitCSSResourceValue.h"
</ins><span class="cx"> #include "WebKitCSSTransformValue.h"
</span><span class="cx">
</span><span class="cx"> #if ENABLE(CSS_GRID_LAYOUT)
</span><span class="lines">@@ -311,6 +312,8 @@
</span><span class="cx"> return downcast<SVGColor>(*this).customCSSText();
</span><span class="cx"> case SVGPaintClass:
</span><span class="cx"> return downcast<SVGPaint>(*this).customCSSText();
</span><ins>+ case WebKitCSSResourceClass:
+ return downcast<WebKitCSSResourceValue>(*this).customCSSText();
</ins><span class="cx"> }
</span><span class="cx"> ASSERT_NOT_REACHED();
</span><span class="cx"> return String();
</span><span class="lines">@@ -423,6 +426,9 @@
</span><span class="cx"> case SVGPaintClass:
</span><span class="cx"> delete downcast<SVGPaint>(this);
</span><span class="cx"> return;
</span><ins>+ case WebKitCSSResourceClass:
+ delete downcast<WebKitCSSResourceValue>(this);
+ return;
</ins><span class="cx"> }
</span><span class="cx"> ASSERT_NOT_REACHED();
</span><span class="cx"> }
</span></span></pre></div>
<a id="trunkSourceWebCorecssCSSValueh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/css/CSSValue.h (176797 => 176798)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/css/CSSValue.h        2014-12-04 16:36:02 UTC (rev 176797)
+++ trunk/Source/WebCore/css/CSSValue.h        2014-12-04 17:05:12 UTC (rev 176798)
</span><span class="lines">@@ -103,6 +103,7 @@
</span><span class="cx"> bool isSVGColor() const { return m_classType == SVGColorClass || m_classType == SVGPaintClass; }
</span><span class="cx"> bool isSVGPaint() const { return m_classType == SVGPaintClass; }
</span><span class="cx"> bool isUnicodeRangeValue() const { return m_classType == UnicodeRangeClass; }
</span><ins>+ bool isWebKitCSSResourceValue() const { return m_classType == WebKitCSSResourceClass; }
</ins><span class="cx">
</span><span class="cx"> bool isCSSOMSafe() const { return m_isCSSOMSafe; }
</span><span class="cx"> bool isSubtypeExposedToCSSOM() const
</span><span class="lines">@@ -173,6 +174,8 @@
</span><span class="cx"> #if ENABLE(CSS_GRID_LAYOUT)
</span><span class="cx"> GridLineNamesClass,
</span><span class="cx"> #endif
</span><ins>+ WebKitCSSResourceClass
+
</ins><span class="cx"> // Do not append non-list class types here.
</span><span class="cx"> };
</span><span class="cx">
</span></span></pre></div>
<a id="trunkSourceWebCorecssStyleResolvercpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/css/StyleResolver.cpp (176797 => 176798)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/css/StyleResolver.cpp        2014-12-04 16:36:02 UTC (rev 176797)
+++ trunk/Source/WebCore/css/StyleResolver.cpp        2014-12-04 17:05:12 UTC (rev 176798)
</span><span class="lines">@@ -135,6 +135,7 @@
</span><span class="cx"> #include "VisitedLinkState.h"
</span><span class="cx"> #include "WebKitCSSFilterValue.h"
</span><span class="cx"> #include "WebKitCSSRegionRule.h"
</span><ins>+#include "WebKitCSSResourceValue.h"
</ins><span class="cx"> #include "WebKitCSSTransformValue.h"
</span><span class="cx"> #include "WebKitFontFamilyNames.h"
</span><span class="cx"> #include "XMLNames.h"
</span><span class="lines">@@ -236,6 +237,7 @@
</span><span class="cx"> m_regionForStyling = nullptr;
</span><span class="cx"> m_pendingImageProperties.clear();
</span><span class="cx"> m_filtersWithPendingSVGDocuments.clear();
</span><ins>+ m_maskImagesWithPendingSVGDocuments.clear();
</ins><span class="cx"> m_cssToLengthConversionData = CSSToLengthConversionData();
</span><span class="cx"> }
</span><span class="cx">
</span><span class="lines">@@ -3459,6 +3461,51 @@
</span><span class="cx"> return true;
</span><span class="cx"> }
</span><span class="cx">
</span><ins>+bool StyleResolver::createMaskImageOperations(CSSValue* inValue, Vector<RefPtr<MaskImageOperation>>& outOperations)
+{
+ ASSERT(outOperations.isEmpty());
+ if (!inValue)
+ return false;
+
+ ASSERT(is<CSSValueList>(*inValue));
+
+ for (auto& currValue : downcast<CSSValueList>(*inValue)) {
+ if (!is<WebKitCSSResourceValue>(currValue.get()))
+ continue;
+
+ WebKitCSSResourceValue& maskImageValue = downcast<WebKitCSSResourceValue>(currValue.get());
+ RefPtr<CSSValue> maskInnerValue = maskImageValue.innerValue();
+ RefPtr<MaskImageOperation> newMaskImage;
+
+ if (is<CSSPrimitiveValue>(maskInnerValue.get())) {
+ RefPtr<CSSPrimitiveValue> primitiveValue = downcast<CSSPrimitiveValue>(maskInnerValue.get());
+ if (primitiveValue->isValueID() && primitiveValue->getValueID() == CSSValueNone)
+ newMaskImage = MaskImageOperation::create();
+ else {
+ String cssUrl = primitiveValue->getStringValue();
+ URL url = m_state.document().completeURL(cssUrl);
+
+ bool isExternalDocument = (SVGURIReference::isExternalURIReference(cssUrl, m_state.document()));
+ newMaskImage = MaskImageOperation::create(&maskImageValue, cssUrl, url.fragmentIdentifier(), isExternalDocument, m_state.document().cachedResourceLoader());
+ if (isExternalDocument)
+ m_state.maskImagesWithPendingSVGDocuments().append(newMaskImage);
+ }
+ } else {
+ RefPtr<StyleImage> image = styleImage(CSSPropertyWebkitMaskImage, *maskInnerValue);
+ if (image.get())
+ newMaskImage = MaskImageOperation::create(image);
+ }
+
+ // If we didn't get a valid value, use None so we keep the correct number and order of masks.
+ if (!newMaskImage.get())
+ newMaskImage = MaskImageOperation::create();
+
+ outOperations.append(newMaskImage);
+ }
+
+ return true;
+}
+
</ins><span class="cx"> PassRefPtr<StyleImage> StyleResolver::loadPendingImage(const StylePendingImage& pendingImage, const ResourceLoaderOptions& options)
</span><span class="cx"> {
</span><span class="cx"> if (auto imageValue = pendingImage.cssImageValue())
</span></span></pre></div>
<a id="trunkSourceWebCorecssStyleResolverh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/css/StyleResolver.h (176797 => 176798)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/css/StyleResolver.h        2014-12-04 16:36:02 UTC (rev 176797)
+++ trunk/Source/WebCore/css/StyleResolver.h        2014-12-04 17:05:12 UTC (rev 176798)
</span><span class="lines">@@ -28,6 +28,7 @@
</span><span class="cx"> #include "DocumentRuleSets.h"
</span><span class="cx"> #include "InspectorCSSOMWrappers.h"
</span><span class="cx"> #include "LinkHash.h"
</span><ins>+#include "MaskImageOperation.h"
</ins><span class="cx"> #include "MediaQueryExp.h"
</span><span class="cx"> #include "RenderStyle.h"
</span><span class="cx"> #include "RuleFeature.h"
</span><span class="lines">@@ -237,6 +238,7 @@
</span><span class="cx"> void clearCachedPropertiesAffectedByViewportUnits();
</span><span class="cx">
</span><span class="cx"> bool createFilterOperations(CSSValue* inValue, FilterOperations& outOperations);
</span><ins>+ bool createMaskImageOperations(CSSValue* inValue, Vector<RefPtr<MaskImageOperation>>& outOperations);
</ins><span class="cx"> void loadPendingSVGDocuments();
</span><span class="cx">
</span><span class="cx"> void loadPendingResources();
</span><span class="lines">@@ -380,6 +382,7 @@
</span><span class="cx"> PendingImagePropertyMap& pendingImageProperties() { return m_pendingImageProperties; }
</span><span class="cx">
</span><span class="cx"> Vector<RefPtr<ReferenceFilterOperation>>& filtersWithPendingSVGDocuments() { return m_filtersWithPendingSVGDocuments; }
</span><ins>+ Vector<RefPtr<MaskImageOperation>>& maskImagesWithPendingSVGDocuments() { return m_maskImagesWithPendingSVGDocuments; }
</ins><span class="cx">
</span><span class="cx"> void setLineHeightValue(CSSValue* value) { m_lineHeightValue = value; }
</span><span class="cx"> CSSValue* lineHeightValue() { return m_lineHeightValue; }
</span><span class="lines">@@ -428,6 +431,7 @@
</span><span class="cx"> PendingImagePropertyMap m_pendingImageProperties;
</span><span class="cx">
</span><span class="cx"> Vector<RefPtr<ReferenceFilterOperation>> m_filtersWithPendingSVGDocuments;
</span><ins>+ Vector<RefPtr<MaskImageOperation>> m_maskImagesWithPendingSVGDocuments;
</ins><span class="cx">
</span><span class="cx"> CSSValue* m_lineHeightValue;
</span><span class="cx"> bool m_fontDirty;
</span></span></pre></div>
<a id="trunkSourceWebCorecssWebKitCSSResourceValuecpp"></a>
<div class="addfile"><h4>Added: trunk/Source/WebCore/css/WebKitCSSResourceValue.cpp (0 => 176798)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/css/WebKitCSSResourceValue.cpp         (rev 0)
+++ trunk/Source/WebCore/css/WebKitCSSResourceValue.cpp        2014-12-04 17:05:12 UTC (rev 176798)
</span><span class="lines">@@ -0,0 +1,75 @@
</span><ins>+/*
+ * Copyright (C) 2014 Adobe Systems Incorporated. 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 THE COPYRIGHT HOLDER "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 THE COPYRIGHT HOLDER 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 "WebKitCSSResourceValue.h"
+
+#include "CSSParser.h"
+#include "CSSPrimitiveValue.h"
+#include "CSSValueList.h"
+#include <wtf/PassRefPtr.h>
+#include <wtf/text/StringBuilder.h>
+#include <wtf/text/WTFString.h>
+
+namespace WebCore {
+
+WebKitCSSResourceValue::WebKitCSSResourceValue(PassRefPtr<CSSValue> resourceValue)
+ : CSSValue(WebKitCSSResourceClass)
+ , m_innerValue(resourceValue)
+{
+}
+
+String WebKitCSSResourceValue::customCSSText() const
+{
+ if (isCSSValueNone())
+ return "none";
+
+ if (m_innerValue.get()) {
+ if (is<CSSPrimitiveValue>(m_innerValue.get()) && downcast<CSSPrimitiveValue>(m_innerValue.get())->isURI()) {
+ StringBuilder result;
+ result.appendLiteral("url(");
+ result.append(quoteCSSURLIfNeeded(downcast<CSSPrimitiveValue>(m_innerValue.get())->getStringValue()));
+ result.appendLiteral(")");
+ return result.toString();
+ }
+
+ return m_innerValue->cssText();
+ }
+
+ return "";
+}
+
+bool WebKitCSSResourceValue::isCSSValueNone() const
+{
+ if (is<CSSPrimitiveValue>(m_innerValue.get())) {
+ RefPtr<CSSPrimitiveValue> primitiveValue = downcast<CSSPrimitiveValue>(m_innerValue.get());
+ return (primitiveValue->isValueID() && primitiveValue->getValueID() == CSSValueNone);
+ }
+
+ return false;
+}
+
+}
</ins></span></pre></div>
<a id="trunkSourceWebCorecssWebKitCSSResourceValueh"></a>
<div class="addfile"><h4>Added: trunk/Source/WebCore/css/WebKitCSSResourceValue.h (0 => 176798)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/css/WebKitCSSResourceValue.h         (rev 0)
+++ trunk/Source/WebCore/css/WebKitCSSResourceValue.h        2014-12-04 17:05:12 UTC (rev 176798)
</span><span class="lines">@@ -0,0 +1,55 @@
</span><ins>+/*
+ * Copyright (C) 2014 Adobe Systems Incorporated. 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 THE COPYRIGHT HOLDER "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 THE COPYRIGHT HOLDER 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.
+ */
+
+#ifndef WebKitCSSResourceValue_h
+#define WebKitCSSResourceValue_h
+
+#include "CSSValue.h"
+#include <wtf/PassRefPtr.h>
+#include <wtf/RefPtr.h>
+
+namespace WebCore {
+
+class WebKitCSSResourceValue : public CSSValue {
+public:
+ static PassRef<WebKitCSSResourceValue> create(PassRefPtr<CSSValue> resourceValue)
+ {
+ return adoptRef(*new WebKitCSSResourceValue(resourceValue));
+ }
+
+ String customCSSText() const;
+ PassRefPtr<CSSValue> innerValue() { return m_innerValue; };
+ bool isCSSValueNone() const;
+private:
+ WebKitCSSResourceValue(PassRefPtr<CSSValue> resourceValue);
+ RefPtr<CSSValue> m_innerValue;
+};
+
+}
+
+SPECIALIZE_TYPE_TRAITS_CSS_VALUE(WebKitCSSResourceValue, isWebKitCSSResourceValue())
+
+#endif // WebKitCSSResourceValue_h
</ins></span></pre></div>
<a id="trunkSourceWebCoreloadercacheCachedResourceLoadercpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/loader/cache/CachedResourceLoader.cpp (176797 => 176798)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/loader/cache/CachedResourceLoader.cpp        2014-12-04 16:36:02 UTC (rev 176797)
+++ trunk/Source/WebCore/loader/cache/CachedResourceLoader.cpp        2014-12-04 17:05:12 UTC (rev 176798)
</span><span class="lines">@@ -756,6 +756,14 @@
</span><span class="cx"> m_documentResources.remove(resource->url());
</span><span class="cx"> }
</span><span class="cx">
</span><ins>+void CachedResourceLoader::addCachedResource(CachedResource* resource)
+{
+ m_documentResources.set(resource->url(), resource);
+
+ if (!memoryCache().add(resource))
+ resource->setOwningCachedResourceLoader(this);
+}
+
</ins><span class="cx"> void CachedResourceLoader::loadDone(CachedResource* resource, bool shouldPerformPostLoadActions)
</span><span class="cx"> {
</span><span class="cx"> RefPtr<DocumentLoader> protectDocumentLoader(m_documentLoader);
</span></span></pre></div>
<a id="trunkSourceWebCoreloadercacheCachedResourceLoaderh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/loader/cache/CachedResourceLoader.h (176797 => 176798)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/loader/cache/CachedResourceLoader.h        2014-12-04 16:36:02 UTC (rev 176797)
+++ trunk/Source/WebCore/loader/cache/CachedResourceLoader.h        2014-12-04 17:05:12 UTC (rev 176798)
</span><span class="lines">@@ -114,6 +114,7 @@
</span><span class="cx"> SessionID sessionID() const;
</span><span class="cx">
</span><span class="cx"> void removeCachedResource(CachedResource*) const;
</span><ins>+ void addCachedResource(CachedResource*);
</ins><span class="cx">
</span><span class="cx"> void loadDone(CachedResource*, bool shouldPerformPostLoadActions = true);
</span><span class="cx">
</span></span></pre></div>
<a id="trunkSourceWebCoreloadercacheCachedSVGDocumentcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/loader/cache/CachedSVGDocument.cpp (176797 => 176798)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/loader/cache/CachedSVGDocument.cpp        2014-12-04 16:36:02 UTC (rev 176797)
+++ trunk/Source/WebCore/loader/cache/CachedSVGDocument.cpp        2014-12-04 17:05:12 UTC (rev 176798)
</span><span class="lines">@@ -23,6 +23,13 @@
</span><span class="cx"> #include "config.h"
</span><span class="cx"> #include "CachedSVGDocument.h"
</span><span class="cx">
</span><ins>+#include "DocumentLoader.h"
+#include "EmptyClients.h"
+#include "FrameView.h"
+#include "MainFrame.h"
+#include "Page.h"
+#include "PageConfiguration.h"
+#include "Settings.h"
</ins><span class="cx"> #include "SharedBuffer.h"
</span><span class="cx">
</span><span class="cx"> namespace WebCore {
</span><span class="lines">@@ -30,6 +37,8 @@
</span><span class="cx"> CachedSVGDocument::CachedSVGDocument(const ResourceRequest& request, SessionID sessionID)
</span><span class="cx"> : CachedResource(request, SVGDocumentResource, sessionID)
</span><span class="cx"> , m_decoder(TextResourceDecoder::create("application/xml"))
</span><ins>+ , m_shouldCreateFrameForDocument(true)
+ , m_canReuseResource(true)
</ins><span class="cx"> {
</span><span class="cx"> setAccept("image/svg+xml");
</span><span class="cx"> }
</span><span class="lines">@@ -51,9 +60,17 @@
</span><span class="cx"> void CachedSVGDocument::finishLoading(SharedBuffer* data)
</span><span class="cx"> {
</span><span class="cx"> if (data) {
</span><del>- // We don't need to create a new frame because the new document belongs to the parent UseElement.
- m_document = SVGDocument::create(nullptr, response().url());
- m_document->setContent(m_decoder->decodeAndFlush(data->data(), data->size()));
</del><ins>+ // In certain situations (like the scenario when this document belongs to an UseElement) we don't need to create a frame.
+ if (m_shouldCreateFrameForDocument) {
+ PageConfiguration pageConfiguration;
+ fillWithEmptyClients(pageConfiguration);
+
+ m_page = Page::createPageFromBuffer(pageConfiguration, data, "image/svg+xml", false, true);
+ m_document = downcast<SVGDocument>(m_page->mainFrame().document());
+ } else {
+ m_document = SVGDocument::create(nullptr, response().url());
+ m_document->setContent(m_decoder->decodeAndFlush(data->data(), data->size()));
+ }
</ins><span class="cx"> }
</span><span class="cx"> CachedResource::finishLoading(data);
</span><span class="cx"> }
</span></span></pre></div>
<a id="trunkSourceWebCoreloadercacheCachedSVGDocumenth"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/loader/cache/CachedSVGDocument.h (176797 => 176798)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/loader/cache/CachedSVGDocument.h        2014-12-04 16:36:02 UTC (rev 176797)
+++ trunk/Source/WebCore/loader/cache/CachedSVGDocument.h        2014-12-04 17:05:12 UTC (rev 176798)
</span><span class="lines">@@ -36,6 +36,9 @@
</span><span class="cx"> virtual ~CachedSVGDocument();
</span><span class="cx">
</span><span class="cx"> SVGDocument* document() const { return m_document.get(); }
</span><ins>+ void setShouldCreateFrameForDocument(bool shouldCreate) { m_shouldCreateFrameForDocument = shouldCreate; }
+ virtual bool canReuse(const ResourceRequest&) const override { return m_canReuseResource; }
+ void setCanReuse(bool canReuseResource) { m_canReuseResource = canReuseResource; };
</ins><span class="cx">
</span><span class="cx"> private:
</span><span class="cx"> virtual bool mayTryReplaceEncodedData() const override { return true; }
</span><span class="lines">@@ -45,6 +48,9 @@
</span><span class="cx">
</span><span class="cx"> RefPtr<SVGDocument> m_document;
</span><span class="cx"> RefPtr<TextResourceDecoder> m_decoder;
</span><ins>+ std::unique_ptr<Page> m_page;
+ bool m_shouldCreateFrameForDocument;
+ bool m_canReuseResource;
</ins><span class="cx"> };
</span><span class="cx">
</span><span class="cx"> } // namespace WebCore
</span></span></pre></div>
<a id="trunkSourceWebCoreloadercacheCachedSVGDocumentReferencecpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/loader/cache/CachedSVGDocumentReference.cpp (176797 => 176798)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/loader/cache/CachedSVGDocumentReference.cpp        2014-12-04 16:36:02 UTC (rev 176797)
+++ trunk/Source/WebCore/loader/cache/CachedSVGDocumentReference.cpp        2014-12-04 17:05:12 UTC (rev 176798)
</span><span class="lines">@@ -34,17 +34,23 @@
</span><span class="cx">
</span><span class="cx"> namespace WebCore {
</span><span class="cx">
</span><del>-CachedSVGDocumentReference::CachedSVGDocumentReference(const String& url)
</del><ins>+CachedSVGDocumentReference::CachedSVGDocumentReference(const String& url, CachedSVGDocumentClient* additionalDocumentClient, bool canReuseResource)
</ins><span class="cx"> : m_url(url)
</span><span class="cx"> , m_document(0)
</span><span class="cx"> , m_loadRequested(false)
</span><ins>+ , m_additionalDocumentClient(additionalDocumentClient)
+ , m_canReuseResource(canReuseResource)
</ins><span class="cx"> {
</span><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> CachedSVGDocumentReference::~CachedSVGDocumentReference()
</span><span class="cx"> {
</span><del>- if (m_document)
</del><ins>+ if (m_document) {
</ins><span class="cx"> m_document->removeClient(this);
</span><ins>+
+ if (m_additionalDocumentClient)
+ m_document->removeClient(m_additionalDocumentClient);
+ }
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> void CachedSVGDocumentReference::load(CachedResourceLoader* loader)
</span><span class="lines">@@ -56,8 +62,13 @@
</span><span class="cx"> CachedResourceRequest request(ResourceRequest(loader->document()->completeURL(m_url)));
</span><span class="cx"> request.setInitiator(cachedResourceRequestInitiators().css);
</span><span class="cx"> m_document = loader->requestSVGDocument(request);
</span><del>- if (m_document)
</del><ins>+ if (m_document) {
+ m_document->setCanReuse(m_canReuseResource);
</ins><span class="cx"> m_document->addClient(this);
</span><ins>+
+ if (m_additionalDocumentClient)
+ m_document->addClient(m_additionalDocumentClient);
+ }
</ins><span class="cx">
</span><span class="cx"> m_loadRequested = true;
</span><span class="cx"> }
</span></span></pre></div>
<a id="trunkSourceWebCoreloadercacheCachedSVGDocumentReferenceh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/loader/cache/CachedSVGDocumentReference.h (176797 => 176798)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/loader/cache/CachedSVGDocumentReference.h        2014-12-04 16:36:02 UTC (rev 176797)
+++ trunk/Source/WebCore/loader/cache/CachedSVGDocumentReference.h        2014-12-04 17:05:12 UTC (rev 176798)
</span><span class="lines">@@ -37,7 +37,7 @@
</span><span class="cx">
</span><span class="cx"> class CachedSVGDocumentReference : public CachedSVGDocumentClient {
</span><span class="cx"> public:
</span><del>- CachedSVGDocumentReference(const String&);
</del><ins>+ CachedSVGDocumentReference(const String& url, CachedSVGDocumentClient* additionalDocumentClient = nullptr, bool canReuseResource = true);
</ins><span class="cx">
</span><span class="cx"> virtual ~CachedSVGDocumentReference();
</span><span class="cx">
</span><span class="lines">@@ -50,6 +50,8 @@
</span><span class="cx"> String m_url;
</span><span class="cx"> CachedResourceHandle<CachedSVGDocument> m_document;
</span><span class="cx"> bool m_loadRequested;
</span><ins>+ CachedSVGDocumentClient* m_additionalDocumentClient;
+ bool m_canReuseResource;
</ins><span class="cx"> };
</span><span class="cx">
</span><span class="cx"> };
</span></span></pre></div>
<a id="trunkSourceWebCorepageFrameViewcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/page/FrameView.cpp (176797 => 176798)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/page/FrameView.cpp        2014-12-04 16:36:02 UTC (rev 176797)
+++ trunk/Source/WebCore/page/FrameView.cpp        2014-12-04 17:05:12 UTC (rev 176798)
</span><span class="lines">@@ -4382,6 +4382,14 @@
</span><span class="cx"> return renderView->style().isFlippedBlocksWritingMode();
</span><span class="cx"> }
</span><span class="cx">
</span><ins>+bool FrameView::containsSVGDocument() const
+{
+ if (frame().document())
+ return frame().document()->isSVGDocument();
+
+ return false;
+}
+
</ins><span class="cx"> void FrameView::notifyWidgetsInAllFrames(WidgetNotification notification)
</span><span class="cx"> {
</span><span class="cx"> for (Frame* frame = m_frame.get(); frame; frame = frame->tree().traverseNext(m_frame.get())) {
</span></span></pre></div>
<a id="trunkSourceWebCorepageFrameViewh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/page/FrameView.h (176797 => 176798)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/page/FrameView.h        2014-12-04 16:36:02 UTC (rev 176797)
+++ trunk/Source/WebCore/page/FrameView.h        2014-12-04 17:05:12 UTC (rev 176798)
</span><span class="lines">@@ -526,6 +526,7 @@
</span><span class="cx">
</span><span class="cx"> virtual bool isVerticalDocument() const override;
</span><span class="cx"> virtual bool isFlippedDocument() const override;
</span><ins>+ virtual bool containsSVGDocument() const override;
</ins><span class="cx">
</span><span class="cx"> private:
</span><span class="cx"> explicit FrameView(Frame&);
</span></span></pre></div>
<a id="trunkSourceWebCorepagePagecpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/page/Page.cpp (176797 => 176798)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/page/Page.cpp        2014-12-04 16:36:02 UTC (rev 176797)
+++ trunk/Source/WebCore/page/Page.cpp        2014-12-04 17:05:12 UTC (rev 176798)
</span><span class="lines">@@ -29,6 +29,7 @@
</span><span class="cx"> #include "ClientRectList.h"
</span><span class="cx"> #include "ContextMenuClient.h"
</span><span class="cx"> #include "ContextMenuController.h"
</span><ins>+#include "DocumentLoader.h"
</ins><span class="cx"> #include "DocumentMarkerController.h"
</span><span class="cx"> #include "DocumentStyleSheetCollection.h"
</span><span class="cx"> #include "DragController.h"
</span><span class="lines">@@ -275,6 +276,33 @@
</span><span class="cx"> m_visitedLinkStore->removePage(*this);
</span><span class="cx"> }
</span><span class="cx">
</span><ins>+std::unique_ptr<Page> Page::createPageFromBuffer(PageConfiguration& pageConfiguration, const SharedBuffer* buffer, const String& mimeType, bool canHaveScrollbars, bool transparent)
+{
+ ASSERT(buffer);
+
+ std::unique_ptr<Page> newPage = std::make_unique<Page>(pageConfiguration);
+ newPage->settings().setMediaEnabled(false);
+ newPage->settings().setScriptEnabled(false);
+ newPage->settings().setPluginsEnabled(false);
+
+ Frame& frame = newPage->mainFrame();
+ frame.setView(FrameView::create(frame));
+ frame.init();
+ FrameLoader& loader = frame.loader();
+ loader.forceSandboxFlags(SandboxAll);
+
+ frame.view()->setCanHaveScrollbars(canHaveScrollbars);
+ frame.view()->setTransparent(transparent);
+
+ ASSERT(loader.activeDocumentLoader()); // DocumentLoader should have been created by frame->init().
+ loader.activeDocumentLoader()->writer().setMIMEType(mimeType);
+ loader.activeDocumentLoader()->writer().begin(URL()); // create the empty document
+ loader.activeDocumentLoader()->writer().addData(buffer->data(), buffer->size());
+ loader.activeDocumentLoader()->writer().end();
+
+ return newPage;
+}
+
</ins><span class="cx"> void Page::clearPreviousItemFromAllPages(HistoryItem* item)
</span><span class="cx"> {
</span><span class="cx"> if (!allPages)
</span></span></pre></div>
<a id="trunkSourceWebCorepagePageh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/page/Page.h (176797 => 176798)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/page/Page.h        2014-12-04 16:36:02 UTC (rev 176797)
+++ trunk/Source/WebCore/page/Page.h        2014-12-04 17:05:12 UTC (rev 176798)
</span><span class="lines">@@ -107,6 +107,7 @@
</span><span class="cx"> class VisitedLinkStore;
</span><span class="cx">
</span><span class="cx"> typedef uint64_t LinkHash;
</span><ins>+class SharedBuffer;
</ins><span class="cx">
</span><span class="cx"> enum FindDirection { FindDirectionForward, FindDirectionBackward };
</span><span class="cx">
</span><span class="lines">@@ -124,6 +125,8 @@
</span><span class="cx"> WEBCORE_EXPORT ~Page();
</span><span class="cx">
</span><span class="cx"> WEBCORE_EXPORT uint64_t renderTreeSize() const;
</span><ins>+
+ static std::unique_ptr<Page> createPageFromBuffer(PageConfiguration&, const SharedBuffer*, const String& mimeType, bool canHaveScrollbars, bool transparent);
</ins><span class="cx">
</span><span class="cx"> void setNeedsRecalcStyleInAllFrames();
</span><span class="cx">
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformScrollViewh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/ScrollView.h (176797 => 176798)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/ScrollView.h        2014-12-04 16:36:02 UTC (rev 176797)
+++ trunk/Source/WebCore/platform/ScrollView.h        2014-12-04 17:05:12 UTC (rev 176798)
</span><span class="lines">@@ -410,6 +410,7 @@
</span><span class="cx"> // Subclassed by FrameView to check the writing-mode of the document.
</span><span class="cx"> virtual bool isVerticalDocument() const { return true; }
</span><span class="cx"> virtual bool isFlippedDocument() const { return false; }
</span><ins>+ virtual bool containsSVGDocument() const { return false; }
</ins><span class="cx">
</span><span class="cx"> // Called to update the scrollbars to accurately reflect the state of the view.
</span><span class="cx"> void updateScrollbars(const IntSize& desiredOffset);
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformgraphicsMaskImageOperationcpp"></a>
<div class="addfile"><h4>Added: trunk/Source/WebCore/platform/graphics/MaskImageOperation.cpp (0 => 176798)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/graphics/MaskImageOperation.cpp         (rev 0)
+++ trunk/Source/WebCore/platform/graphics/MaskImageOperation.cpp        2014-12-04 17:05:12 UTC (rev 176798)
</span><span class="lines">@@ -0,0 +1,261 @@
</span><ins>+/*
+ * Copyright (C) 2014 Adobe Systems Incorporated. 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 THE COPYRIGHT HOLDER "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 THE COPYRIGHT HOLDER 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 "MaskImageOperation.h"
+
+#include "CachedImage.h"
+#include "CachedSVGDocument.h"
+#include "RenderBoxModelObject.h"
+#include "RenderSVGResourceMasker.h"
+#include "SVGDocument.h"
+#include "SVGMaskElement.h"
+#include "SVGSVGElement.h"
+#include "StyleCachedImage.h"
+#include "SubresourceLoader.h"
+#include "WebKitCSSResourceValue.h"
+
+namespace WebCore {
+
+PassRefPtr<MaskImageOperation> MaskImageOperation::create(PassRefPtr<WebKitCSSResourceValue> cssValue, const String& url, const String& fragment, bool isExternalDocument, PassRefPtr<CachedResourceLoader> cachedResourceLoader)
+{
+ return adoptRef(new MaskImageOperation(cssValue, url, fragment, isExternalDocument, cachedResourceLoader));
+}
+
+PassRefPtr<MaskImageOperation> MaskImageOperation::create(PassRefPtr<StyleImage> generatedImage)
+{
+ return adoptRef(new MaskImageOperation(generatedImage));
+}
+
+PassRefPtr<MaskImageOperation> MaskImageOperation::create()
+{
+ return adoptRef(new MaskImageOperation());
+}
+
+MaskImageOperation::MaskImageOperation(PassRefPtr<WebKitCSSResourceValue> cssValue, const String& url, const String& fragment, bool isExternalDocument, PassRefPtr<CachedResourceLoader> cachedResourceLoader)
+ : m_url(url)
+ , m_fragment(fragment)
+ , m_isExternalDocument(isExternalDocument)
+ , m_renderLayerImageClient(nullptr)
+ , m_cssMaskImageValue(cssValue)
+ , m_cachedResourceLoader(cachedResourceLoader)
+{
+ ASSERT(m_cssMaskImageValue.get());
+}
+
+MaskImageOperation::MaskImageOperation(PassRefPtr<StyleImage> generatedImage)
+ : m_isExternalDocument(false)
+ , m_styleImage(generatedImage)
+ , m_renderLayerImageClient(nullptr)
+{
+}
+
+MaskImageOperation::MaskImageOperation()
+ : m_isExternalDocument(false)
+ , m_renderLayerImageClient(nullptr)
+{
+ m_cssMaskImageValue = WebKitCSSResourceValue::create(CSSPrimitiveValue::createIdentifier(CSSValueNone));
+}
+
+MaskImageOperation::~MaskImageOperation()
+{
+}
+
+bool MaskImageOperation::isCSSValueNone() const
+{
+ if (image())
+ return false;
+
+ ASSERT(m_cssMaskImageValue.get());
+ return m_cssMaskImageValue->isCSSValueNone();
+}
+
+PassRefPtr<CSSValue> MaskImageOperation::cssValue()
+{
+ if (image())
+ return image()->cssValue();
+
+ if (isCSSValueNone())
+ return m_cssMaskImageValue->innerValue();
+
+ ASSERT(m_cssMaskImageValue.get());
+ return m_cssMaskImageValue.get();
+}
+
+bool MaskImageOperation::isMaskLoaded() const
+{
+ if (!m_isExternalDocument)
+ return true;
+
+ if (image())
+ return (image()->cachedImage() && image()->cachedImage()->image());
+
+ if (m_cachedSVGDocumentReference.get()) {
+ if (CachedSVGDocument* cachedSVGDocument = m_cachedSVGDocumentReference->document())
+ return (cachedSVGDocument->document() != nullptr);
+ }
+
+ return false;
+}
+
+void MaskImageOperation::setRenderLayerImageClient(CachedImageClient* client)
+{
+ if (m_renderLayerImageClient == client)
+ return;
+
+ if (CachedImage* cachedImage = (image() ? image()->cachedImage() : nullptr)) {
+ if (m_renderLayerImageClient)
+ cachedImage->removeClient(m_renderLayerImageClient);
+
+ if (client)
+ cachedImage->addClient(client);
+ }
+
+ m_renderLayerImageClient = client;
+}
+
+void MaskImageOperation::addRendererImageClient(RenderElement* client)
+{
+ ASSERT(client);
+
+ if (m_styleImage.get())
+ m_styleImage->addClient(client);
+
+ m_rendererImageClients.add(client);
+}
+
+void MaskImageOperation::removeRendererImageClient(RenderElement* client)
+{
+ ASSERT(client && m_rendererImageClients.contains(client));
+
+ if (m_styleImage.get())
+ m_styleImage->removeClient(client);
+
+ m_rendererImageClients.remove(client);
+}
+
+CachedSVGDocumentReference* MaskImageOperation::ensureCachedSVGDocumentReference()
+{
+ // If we ended up loading the data into an Image, then the SVG document was not valid.
+ if (image())
+ return nullptr;
+
+ if (!m_cachedSVGDocumentReference.get())
+ m_cachedSVGDocumentReference = std::make_unique<CachedSVGDocumentReference>(m_url, this, false);
+ return m_cachedSVGDocumentReference.get();
+}
+
+void MaskImageOperation::notifyFinished(CachedResource* resource)
+{
+ // The only one notifying us should be the SVG document we hold.
+ CachedSVGDocument* cachedSVGDocument = ensureCachedSVGDocumentReference()->document();
+ if ((CachedResource*)cachedSVGDocument != resource || !resource) {
+ ASSERT_NOT_REACHED();
+ return;
+ }
+
+ // Check if we find a valid masking element in this SVG document.
+ SVGDocument* svgDocument = cachedSVGDocument->document();
+ bool validMaskFound = false;
+ if (svgDocument && svgDocument->rootElement()) {
+ // Are we looking for a specific element in the SVG document?
+ if (fragment().length()) {
+ if (Element* maskingElement = svgDocument->rootElement()->getElementById(fragment())) {
+ if (is<SVGMaskElement>(maskingElement))
+ validMaskFound = true;
+ }
+ }
+ }
+
+ // If no valid mask was found, this is not a valid SVG document or it specified an invalid fragment identifier.
+ // Fallback to the normal way of loading the document in an Image object.
+ if (!validMaskFound) {
+ // Get the resource loader, acquire the resource buffer and load it into an image.
+ ASSERT(cachedSVGDocument->loader());
+ if (SubresourceLoader* loader = cachedSVGDocument->loader()) {
+ if (SharedBuffer* dataBuffer = loader->resourceData()) {
+ m_styleImage = StyleCachedImage::create(new CachedImage(cachedSVGDocument->resourceRequest(), cachedSVGDocument->sessionID()));
+ if (m_renderLayerImageClient)
+ m_styleImage->cachedImage()->addClient(m_renderLayerImageClient);
+ for (auto itClient : m_rendererImageClients)
+ m_styleImage->addClient(itClient.key);
+
+ m_styleImage->cachedImage()->setResponse(cachedSVGDocument->response());
+ m_styleImage->cachedImage()->finishLoading(dataBuffer);
+
+ // Let the cached resource loader of the document which requested this mask keep a handle to this
+ // cached image to ensure it only gets deleted when it should.
+ if (m_cachedResourceLoader.get())
+ m_cachedResourceLoader->addCachedResource(m_styleImage->cachedImage());
+ }
+
+ // Destroy the current SVG document as its no longer needed
+ m_cachedSVGDocumentReference = nullptr;
+ }
+ }
+}
+
+bool MaskImageOperation::drawMask(RenderElement& renderer, BackgroundImageGeometry& geometry, GraphicsContext* context, CompositeOperator compositeOp)
+{
+ // This method only handles custom masks.
+ if (image())
+ return false;
+
+ if (RenderSVGResourceMasker* svgMasker = getSVGMasker(renderer)) {
+ svgMasker->drawMaskForRenderer(renderer, geometry, context, compositeOp);
+ return true;
+ }
+
+ return false;
+}
+
+RenderSVGResourceMasker* MaskImageOperation::getSVGMasker(RenderElement& renderer)
+{
+ if (image())
+ return nullptr;
+
+ // Identify the element referenced by the fragmentId.
+ CachedSVGDocumentReference* svgDocumentReference = cachedSVGDocumentReference();
+ Element* elementForMasking = nullptr;
+ RenderObject* svgResourceForMasking = nullptr;
+ if (svgDocumentReference && svgDocumentReference->document()) {
+ SVGDocument* svgDocument = svgDocumentReference->document()->document();
+ if (svgDocument && svgDocument->rootElement())
+ elementForMasking = svgDocument->rootElement()->getElementById(fragment());
+ } else
+ elementForMasking = renderer.document().getElementById(fragment());
+
+ if (elementForMasking)
+ svgResourceForMasking = elementForMasking->renderer();
+
+ // Check if it's the correct type
+ if (svgResourceForMasking && svgResourceForMasking->isSVGResourceContainer() && downcast<RenderSVGResourceContainer>(svgResourceForMasking)->resourceType() == MaskerResourceType)
+ return static_cast<RenderSVGResourceMasker*>(svgResourceForMasking);
+
+ return nullptr;
+}
+
+} // namespace WebCore
</ins></span></pre></div>
<a id="trunkSourceWebCoreplatformgraphicsMaskImageOperationh"></a>
<div class="addfile"><h4>Added: trunk/Source/WebCore/platform/graphics/MaskImageOperation.h (0 => 176798)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/graphics/MaskImageOperation.h         (rev 0)
+++ trunk/Source/WebCore/platform/graphics/MaskImageOperation.h        2014-12-04 17:05:12 UTC (rev 176798)
</span><span class="lines">@@ -0,0 +1,97 @@
</span><ins>+/*
+ * Copyright (C) 2014 Adobe Systems Incorporated. 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 THE COPYRIGHT HOLDER "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 THE COPYRIGHT HOLDER 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.
+ */
+
+#ifndef MaskImageOperation_h
+#define MaskImageOperation_h
+
+#include "CachedResourceLoader.h"
+#include "CachedSVGDocumentClient.h"
+#include "CachedSVGDocumentReference.h"
+#include "Color.h"
+#include "Image.h"
+#include "LayoutSize.h"
+#include "Length.h"
+#include "StyleImage.h"
+#include <wtf/HashCountedSet.h>
+#include <wtf/OwnPtr.h>
+#include <wtf/PassOwnPtr.h>
+#include <wtf/RefCounted.h>
+#include <wtf/text/WTFString.h>
+
+namespace WebCore {
+
+class BackgroundImageGeometry;
+class CachedImageClient;
+class RenderSVGResourceMasker;
+class WebKitCSSResourceValue;
+
+class MaskImageOperation final : public RefCounted<MaskImageOperation>, public CachedSVGDocumentClient {
+public:
+ static PassRefPtr<MaskImageOperation> create(PassRefPtr<WebKitCSSResourceValue> cssValue, const String& url, const String& fragment, bool isExternalDocument, PassRefPtr<CachedResourceLoader>);
+ static PassRefPtr<MaskImageOperation> create(PassRefPtr<StyleImage> generatedImage);
+ static PassRefPtr<MaskImageOperation> create();
+
+ PassRefPtr<CSSValue> cssValue();
+
+ virtual ~MaskImageOperation();
+
+ const String& url() const { return m_url; }
+ const String& fragment() const { return m_fragment; }
+ StyleImage* image() const { return m_styleImage.get(); }
+ void setImage(PassRefPtr<StyleImage> image) { m_styleImage = image; }
+ void setRenderLayerImageClient(CachedImageClient*);
+ void addRendererImageClient(RenderElement*);
+ void removeRendererImageClient(RenderElement*);
+ bool isMaskLoaded() const;
+ bool drawMask(RenderElement& renderer, BackgroundImageGeometry&, GraphicsContext*, CompositeOperator);
+ bool isCSSValueNone() const;
+
+ CachedSVGDocumentReference* cachedSVGDocumentReference() const { return m_cachedSVGDocumentReference.get(); }
+ CachedSVGDocumentReference* ensureCachedSVGDocumentReference();
+
+ virtual void notifyFinished(CachedResource*) override;
+
+private:
+ MaskImageOperation(PassRefPtr<WebKitCSSResourceValue> cssValue, const String& url, const String& fragment, bool isExternalDocument, PassRefPtr<CachedResourceLoader>);
+ MaskImageOperation(PassRefPtr<StyleImage> generatedImage);
+ MaskImageOperation();
+
+ RenderSVGResourceMasker* getSVGMasker(RenderElement& renderer);
+
+ String m_url;
+ String m_fragment;
+ bool m_isExternalDocument;
+ std::unique_ptr<CachedSVGDocumentReference> m_cachedSVGDocumentReference;
+ RefPtr<StyleImage> m_styleImage;
+ CachedImageClient* m_renderLayerImageClient;
+ HashCountedSet<RenderElement*> m_rendererImageClients;
+ RefPtr<WebKitCSSResourceValue> m_cssMaskImageValue;
+ RefPtr<CachedResourceLoader> m_cachedResourceLoader;
+};
+
+} // namespace WebCore
+
+#endif // MaskImageOperation_h
</ins></span></pre></div>
<a id="trunkSourceWebCorerenderingRenderBoxModelObjectcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/rendering/RenderBoxModelObject.cpp (176797 => 176798)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/rendering/RenderBoxModelObject.cpp        2014-12-04 16:36:02 UTC (rev 176797)
+++ trunk/Source/WebCore/rendering/RenderBoxModelObject.cpp        2014-12-04 17:05:12 UTC (rev 176798)
</span><span class="lines">@@ -1017,31 +1017,31 @@
</span><span class="cx"> return LayoutSize();
</span><span class="cx"> }
</span><span class="cx">
</span><del>-void RenderBoxModelObject::BackgroundImageGeometry::setNoRepeatX(LayoutUnit xOffset)
</del><ins>+void BackgroundImageGeometry::setNoRepeatX(LayoutUnit xOffset)
</ins><span class="cx"> {
</span><span class="cx"> m_destRect.move(std::max<LayoutUnit>(xOffset, 0), 0);
</span><span class="cx"> m_phase.setX(-std::min<LayoutUnit>(xOffset, 0));
</span><span class="cx"> m_destRect.setWidth(m_tileSize.width() + std::min<float>(xOffset, 0));
</span><span class="cx"> }
</span><del>-void RenderBoxModelObject::BackgroundImageGeometry::setNoRepeatY(LayoutUnit yOffset)
</del><ins>+void BackgroundImageGeometry::setNoRepeatY(LayoutUnit yOffset)
</ins><span class="cx"> {
</span><span class="cx"> m_destRect.move(0, std::max<LayoutUnit>(yOffset, 0));
</span><span class="cx"> m_phase.setY(-std::min<LayoutUnit>(yOffset, 0));
</span><span class="cx"> m_destRect.setHeight(m_tileSize.height() + std::min<float>(yOffset, 0));
</span><span class="cx"> }
</span><span class="cx">
</span><del>-void RenderBoxModelObject::BackgroundImageGeometry::useFixedAttachment(const LayoutPoint& attachmentPoint)
</del><ins>+void BackgroundImageGeometry::useFixedAttachment(const LayoutPoint& attachmentPoint)
</ins><span class="cx"> {
</span><span class="cx"> FloatPoint alignedPoint = attachmentPoint;
</span><span class="cx"> m_phase.move(std::max<LayoutUnit>(alignedPoint.x() - m_destRect.x(), 0), std::max<LayoutUnit>(alignedPoint.y() - m_destRect.y(), 0));
</span><span class="cx"> }
</span><span class="cx">
</span><del>-void RenderBoxModelObject::BackgroundImageGeometry::clip(const LayoutRect& clipRect)
</del><ins>+void BackgroundImageGeometry::clip(const LayoutRect& clipRect)
</ins><span class="cx"> {
</span><span class="cx"> m_destRect.intersect(clipRect);
</span><span class="cx"> }
</span><span class="cx">
</span><del>-LayoutPoint RenderBoxModelObject::BackgroundImageGeometry::relativePhase() const
</del><ins>+LayoutPoint BackgroundImageGeometry::relativePhase() const
</ins><span class="cx"> {
</span><span class="cx"> LayoutPoint phase = m_phase;
</span><span class="cx"> phase += m_destRect.location() - m_destOrigin;
</span></span></pre></div>
<a id="trunkSourceWebCorerenderingRenderBoxModelObjecth"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/rendering/RenderBoxModelObject.h (176797 => 176798)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/rendering/RenderBoxModelObject.h        2014-12-04 16:36:02 UTC (rev 176797)
+++ trunk/Source/WebCore/rendering/RenderBoxModelObject.h        2014-12-04 17:05:12 UTC (rev 176798)
</span><span class="lines">@@ -65,6 +65,52 @@
</span><span class="cx"> class RenderTextFragment;
</span><span class="cx"> class StickyPositionViewportConstraints;
</span><span class="cx">
</span><ins>+class BackgroundImageGeometry {
+public:
+ BackgroundImageGeometry()
+ : m_hasNonLocalGeometry(false)
+ { }
+
+ LayoutPoint destOrigin() const { return m_destOrigin; }
+ void setDestOrigin(const LayoutPoint& destOrigin) { m_destOrigin = destOrigin; }
+
+ LayoutRect destRect() const { return m_destRect; }
+ void setDestRect(const LayoutRect& destRect) { m_destRect = destRect; }
+
+ // Returns the phase relative to the destination rectangle.
+ LayoutPoint relativePhase() const;
+
+ LayoutPoint phase() const { return m_phase; }
+ void setPhase(const LayoutPoint& phase) { m_phase = phase; }
+
+ LayoutSize tileSize() const { return m_tileSize; }
+ void setTileSize(const LayoutSize& tileSize) { m_tileSize = tileSize; }
+
+ LayoutSize spaceSize() const { return m_space; }
+ void setSpaceSize(const LayoutSize& space) { m_space = space; }
+
+ void setPhaseX(LayoutUnit x) { m_phase.setX(x); }
+ void setPhaseY(LayoutUnit y) { m_phase.setY(y); }
+
+ void setNoRepeatX(LayoutUnit xOffset);
+ void setNoRepeatY(LayoutUnit yOffset);
+
+ void useFixedAttachment(const LayoutPoint& attachmentPoint);
+
+ void clip(const LayoutRect&);
+
+ void setHasNonLocalGeometry(bool hasNonLocalGeometry = true) { m_hasNonLocalGeometry = hasNonLocalGeometry; }
+ bool hasNonLocalGeometry() const { return m_hasNonLocalGeometry; }
+
+private:
+ LayoutRect m_destRect;
+ LayoutPoint m_destOrigin;
+ LayoutPoint m_phase;
+ LayoutSize m_tileSize;
+ LayoutSize m_space;
+ bool m_hasNonLocalGeometry; // Has background-attachment: fixed. Implies that we can't always cheaply compute destRect.
+};
+
</ins><span class="cx"> // This class is the base for all objects that adhere to the CSS box model as described
</span><span class="cx"> // at http://www.w3.org/TR/CSS21/box.html
</span><span class="cx">
</span><span class="lines">@@ -210,51 +256,6 @@
</span><span class="cx">
</span><span class="cx"> virtual void willBeDestroyed() override;
</span><span class="cx">
</span><del>- class BackgroundImageGeometry {
- public:
- BackgroundImageGeometry()
- : m_hasNonLocalGeometry(false)
- { }
- LayoutPoint destOrigin() const { return m_destOrigin; }
- void setDestOrigin(const LayoutPoint& destOrigin) { m_destOrigin = destOrigin; }
-
- LayoutRect destRect() const { return m_destRect; }
- void setDestRect(const LayoutRect& destRect) { m_destRect = destRect; }
-
- // Returns the phase relative to the destination rectangle.
- LayoutPoint relativePhase() const;
-
- LayoutPoint phase() const { return m_phase; }
- void setPhase(const LayoutPoint& phase) { m_phase = phase; }
-
- LayoutSize tileSize() const { return m_tileSize; }
- void setTileSize(const LayoutSize& tileSize) { m_tileSize = tileSize; }
-
- LayoutSize spaceSize() const { return m_space; }
- void setSpaceSize(const LayoutSize& space) { m_space = space; }
-
- void setPhaseX(LayoutUnit x) { m_phase.setX(x); }
- void setPhaseY(LayoutUnit y) { m_phase.setY(y); }
-
- void setNoRepeatX(LayoutUnit xOffset);
- void setNoRepeatY(LayoutUnit yOffset);
-
- void useFixedAttachment(const LayoutPoint& attachmentPoint);
-
- void clip(const LayoutRect&);
-
- void setHasNonLocalGeometry(bool hasNonLocalGeometry = true) { m_hasNonLocalGeometry = hasNonLocalGeometry; }
- bool hasNonLocalGeometry() const { return m_hasNonLocalGeometry; }
-
- private:
- LayoutRect m_destRect;
- LayoutPoint m_destOrigin;
- LayoutPoint m_phase;
- LayoutSize m_tileSize;
- LayoutSize m_space;
- bool m_hasNonLocalGeometry; // Has background-attachment: fixed. Implies that we can't always cheaply compute destRect.
- };
-
</del><span class="cx"> LayoutPoint adjustedPositionRelativeToOffsetParent(const LayoutPoint&) const;
</span><span class="cx">
</span><span class="cx"> bool hasBoxDecorationStyle() const;
</span></span></pre></div>
<a id="trunkSourceWebCorerenderingRenderLayercpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/rendering/RenderLayer.cpp (176797 => 176798)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/rendering/RenderLayer.cpp        2014-12-04 16:36:02 UTC (rev 176797)
+++ trunk/Source/WebCore/rendering/RenderLayer.cpp        2014-12-04 17:05:12 UTC (rev 176798)
</span><span class="lines">@@ -88,6 +88,7 @@
</span><span class="cx"> #include "RenderLayerBacking.h"
</span><span class="cx"> #include "RenderLayerCompositor.h"
</span><span class="cx"> #include "RenderLayerFilterInfo.h"
</span><ins>+#include "RenderLayerMaskImageInfo.h"
</ins><span class="cx"> #include "RenderMarquee.h"
</span><span class="cx"> #include "RenderMultiColumnFlowThread.h"
</span><span class="cx"> #include "RenderNamedFlowFragment.h"
</span><span class="lines">@@ -189,6 +190,7 @@
</span><span class="cx"> , m_layerListMutationAllowed(true)
</span><span class="cx"> #endif
</span><span class="cx"> , m_hasFilterInfo(false)
</span><ins>+ , m_hasMaskImageInfo(false)
</ins><span class="cx"> #if ENABLE(CSS_COMPOSITING)
</span><span class="cx"> , m_blendMode(BlendModeNormal)
</span><span class="cx"> , m_hasNotIsolatedCompositedBlendingDescendants(false)
</span><span class="lines">@@ -255,6 +257,7 @@
</span><span class="cx"> removeReflection();
</span><span class="cx">
</span><span class="cx"> FilterInfo::remove(*this);
</span><ins>+ MaskImageInfo::remove(*this);
</ins><span class="cx">
</span><span class="cx"> // Child layers will be deleted by their corresponding render objects, so
</span><span class="cx"> // we don't need to delete them ourselves.
</span></span></pre></div>
<a id="trunkSourceWebCorerenderingRenderLayerh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/rendering/RenderLayer.h (176797 => 176798)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/rendering/RenderLayer.h        2014-12-04 16:36:02 UTC (rev 176797)
+++ trunk/Source/WebCore/rendering/RenderLayer.h        2014-12-04 17:05:12 UTC (rev 176798)
</span><span class="lines">@@ -1266,6 +1266,7 @@
</span><span class="cx"> #endif
</span><span class="cx">
</span><span class="cx"> bool m_hasFilterInfo : 1;
</span><ins>+ unsigned m_hasMaskImageInfo : 1;
</ins><span class="cx">
</span><span class="cx"> #if ENABLE(CSS_COMPOSITING)
</span><span class="cx"> unsigned m_blendMode : 5;
</span><span class="lines">@@ -1342,6 +1343,7 @@
</span><span class="cx"> std::unique_ptr<RenderLayerBacking> m_backing;
</span><span class="cx">
</span><span class="cx"> class FilterInfo;
</span><ins>+ class MaskImageInfo;
</ins><span class="cx"> };
</span><span class="cx">
</span><span class="cx"> inline void RenderLayer::clearZOrderLists()
</span></span></pre></div>
<a id="trunkSourceWebCorerenderingRenderLayerMaskImageInfocpp"></a>
<div class="addfile"><h4>Added: trunk/Source/WebCore/rendering/RenderLayerMaskImageInfo.cpp (0 => 176798)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/rendering/RenderLayerMaskImageInfo.cpp         (rev 0)
+++ trunk/Source/WebCore/rendering/RenderLayerMaskImageInfo.cpp        2014-12-04 17:05:12 UTC (rev 176798)
</span><span class="lines">@@ -0,0 +1,141 @@
</span><ins>+/*
+ * Copyright (C) 2014 Adobe Systems Incorporated. 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 THE COPYRIGHT HOLDER "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 THE COPYRIGHT HOLDER 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 "RenderLayerMaskImageInfo.h"
+
+#include "CachedSVGDocument.h"
+#include "CachedSVGDocumentReference.h"
+#include "RenderSVGResourceContainer.h"
+#include "SVGElement.h"
+#include "SVGMaskElement.h"
+#include <wtf/NeverDestroyed.h>
+
+namespace WebCore {
+
+HashMap<const RenderLayer*, std::unique_ptr<RenderLayer::MaskImageInfo>>& RenderLayer::MaskImageInfo::layerToMaskMap()
+{
+ static NeverDestroyed<HashMap<const RenderLayer*, std::unique_ptr<MaskImageInfo>>> layerToMaskMap;
+ return layerToMaskMap;
+}
+
+RenderLayer::MaskImageInfo* RenderLayer::MaskImageInfo::getIfExists(const RenderLayer& layer)
+{
+ ASSERT(layer.m_hasMaskImageInfo == layerToMaskMap().contains(&layer));
+ return layer.m_hasMaskImageInfo ? layerToMaskMap().get(&layer) : 0;
+}
+
+RenderLayer::MaskImageInfo& RenderLayer::MaskImageInfo::get(RenderLayer& layer)
+{
+ ASSERT(layer.m_hasMaskImageInfo == layerToMaskMap().contains(&layer));
+
+ auto& info = layerToMaskMap().add(&layer, nullptr).iterator->value;
+ if (!info) {
+ info = std::make_unique<MaskImageInfo>(layer);
+ layer.m_hasMaskImageInfo = true;
+ }
+ return *info;
+}
+
+void RenderLayer::MaskImageInfo::remove(RenderLayer& layer)
+{
+ ASSERT(layer.m_hasMaskImageInfo == layerToMaskMap().contains(&layer));
+
+ if (layerToMaskMap().remove(&layer))
+ layer.m_hasMaskImageInfo = false;
+}
+
+RenderLayer::MaskImageInfo::MaskImageInfo(RenderLayer& layer)
+ : m_layer(layer)
+{
+ m_svgDocumentClient = std::make_unique<MaskSVGDocumentClient>(this);
+ m_imageClient = std::make_unique<MaskImageClient>(this);
+}
+
+RenderLayer::MaskImageInfo::~MaskImageInfo()
+{
+ removeMaskImageClients();
+}
+
+void RenderLayer::MaskImageInfo::notifyFinished(CachedResource*)
+{
+ m_layer.renderer().repaint();
+}
+
+void RenderLayer::MaskImageInfo::imageChanged(CachedImage*, const IntRect*)
+{
+ m_layer.renderer().repaint();
+}
+
+void RenderLayer::MaskImageInfo::updateMaskImageClients()
+{
+ removeMaskImageClients();
+
+ const FillLayer* maskLayer = m_layer.renderer().style().maskLayers();
+ while (maskLayer) {
+ const RefPtr<MaskImageOperation> maskImage = maskLayer->maskImage();
+ maskImage->setRenderLayerImageClient(m_imageClient.get());
+ CachedSVGDocumentReference* documentReference = maskImage->cachedSVGDocumentReference();
+ CachedSVGDocument* cachedSVGDocument = documentReference ? documentReference->document() : nullptr;
+
+ if (cachedSVGDocument) {
+ // Reference is external; wait for notifyFinished().
+ cachedSVGDocument->addClient(m_svgDocumentClient.get());
+ m_externalSVGReferences.append(cachedSVGDocument);
+ } else {
+ // Reference is internal; add layer as a client so we can trigger
+ // mask repaint on SVG attribute change.
+ Element* masker = m_layer.renderer().document().getElementById(maskImage->fragment());
+ if (masker && is<SVGMaskElement>(masker)) {
+ downcast<SVGMaskElement>(masker)->addClientRenderLayer(&m_layer);
+ m_internalSVGReferences.append(masker);
+ }
+ }
+
+ maskLayer = maskLayer->next();
+ }
+}
+
+void RenderLayer::MaskImageInfo::removeMaskImageClients()
+{
+ const FillLayer* maskLayer = m_layer.renderer().style().maskLayers();
+ while (maskLayer) {
+ if (maskLayer->maskImage())
+ maskLayer->maskImage()->setRenderLayerImageClient(nullptr);
+
+ maskLayer = maskLayer->next();
+ }
+
+ for (auto externalSVGReference : m_externalSVGReferences)
+ externalSVGReference->removeClient(m_svgDocumentClient.get());
+ m_externalSVGReferences.clear();
+
+ for (auto internalSVGReference : m_internalSVGReferences)
+ downcast<SVGMaskElement>(internalSVGReference.get())->removeClientRenderLayer(&m_layer);
+ m_internalSVGReferences.clear();
+}
+
+} // namespace WebCore
</ins></span></pre></div>
<a id="trunkSourceWebCorerenderingRenderLayerMaskImageInfoh"></a>
<div class="addfile"><h4>Added: trunk/Source/WebCore/rendering/RenderLayerMaskImageInfo.h (0 => 176798)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/rendering/RenderLayerMaskImageInfo.h         (rev 0)
+++ trunk/Source/WebCore/rendering/RenderLayerMaskImageInfo.h        2014-12-04 17:05:12 UTC (rev 176798)
</span><span class="lines">@@ -0,0 +1,103 @@
</span><ins>+/*
+ * Copyright (C) 2014 Adobe Systems Incorporated. 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 THE COPYRIGHT HOLDER "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 THE COPYRIGHT HOLDER 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.
+ */
+
+#ifndef RenderLayerMaskImageInfo_h
+#define RenderLayerMaskImageInfo_h
+
+#include "CachedImageClient.h"
+#include "CachedResourceHandle.h"
+#include "CachedSVGDocumentClient.h"
+#include "MaskImageOperation.h"
+#include "RenderLayer.h"
+#include <memory>
+
+namespace WebCore {
+
+class Element;
+
+class RenderLayer::MaskImageInfo final {
+private:
+ class MaskResourceClient {
+ public:
+ MaskResourceClient(RenderLayer::MaskImageInfo* maskImageInfo)
+ : m_maskImageInfo(maskImageInfo)
+ {
+ ASSERT(m_maskImageInfo);
+ }
+ protected:
+ RenderLayer::MaskImageInfo* m_maskImageInfo;
+ };
+
+ class MaskSVGDocumentClient : public MaskResourceClient, public CachedSVGDocumentClient {
+ public:
+ MaskSVGDocumentClient(RenderLayer::MaskImageInfo* maskImageInfo)
+ : MaskResourceClient(maskImageInfo)
+ {
+ }
+
+ virtual void notifyFinished(CachedResource* resource) override { m_maskImageInfo->notifyFinished(resource); }
+ };
+
+ class MaskImageClient : public MaskResourceClient, public CachedImageClient {
+ public:
+ MaskImageClient(RenderLayer::MaskImageInfo* maskImageInfo)
+ : MaskResourceClient(maskImageInfo)
+ {
+ }
+
+ virtual void imageChanged(CachedImage* image, const IntRect* rect = nullptr) override { m_maskImageInfo->imageChanged(image, rect); }
+ };
+
+public:
+ static MaskImageInfo& get(RenderLayer&);
+ static MaskImageInfo* getIfExists(const RenderLayer&);
+ static void remove(RenderLayer&);
+
+ explicit MaskImageInfo(RenderLayer&);
+ ~MaskImageInfo();
+
+ void updateMaskImageClients();
+ void removeMaskImageClients();
+
+private:
+ friend void WTF::deleteOwnedPtr<MaskImageInfo>(MaskImageInfo*);
+
+ void notifyFinished(CachedResource*);
+ void imageChanged(CachedImage*, const IntRect*);
+
+ static HashMap<const RenderLayer*, std::unique_ptr<MaskImageInfo>>& layerToMaskMap();
+
+ RenderLayer& m_layer;
+
+ Vector<RefPtr<Element>> m_internalSVGReferences;
+ Vector<CachedResourceHandle<CachedSVGDocument>> m_externalSVGReferences;
+ std::unique_ptr<MaskSVGDocumentClient> m_svgDocumentClient;
+ std::unique_ptr<MaskImageClient> m_imageClient;
+};
+
+} // namespace WebCore
+
+#endif // RenderLayerMaskImageInfo_h
</ins></span></pre></div>
<a id="trunkSourceWebCorerenderingstyleFillLayercpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/rendering/style/FillLayer.cpp (176797 => 176798)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/rendering/style/FillLayer.cpp        2014-12-04 16:36:02 UTC (rev 176797)
+++ trunk/Source/WebCore/rendering/style/FillLayer.cpp        2014-12-04 17:05:12 UTC (rev 176798)
</span><span class="lines">@@ -28,6 +28,7 @@
</span><span class="cx"> FillLayer* next;
</span><span class="cx">
</span><span class="cx"> RefPtr<StyleImage> image;
</span><ins>+ RefPtr<MaskImageOperation> maskImageOperation;
</ins><span class="cx">
</span><span class="cx"> Length x;
</span><span class="cx"> Length y;
</span><span class="lines">@@ -74,6 +75,7 @@
</span><span class="cx">
</span><span class="cx"> FillLayer::FillLayer(const FillLayer& o)
</span><span class="cx"> : m_next(o.m_next ? std::make_unique<FillLayer>(*o.m_next) : nullptr)
</span><ins>+ , m_maskImageOperation(o.m_maskImageOperation)
</ins><span class="cx"> , m_image(o.m_image)
</span><span class="cx"> , m_xPosition(o.m_xPosition)
</span><span class="cx"> , m_yPosition(o.m_yPosition)
</span><span class="lines">@@ -116,6 +118,7 @@
</span><span class="cx"> m_next = o.m_next ? std::make_unique<FillLayer>(*o.m_next) : nullptr;
</span><span class="cx">
</span><span class="cx"> m_image = o.m_image;
</span><ins>+ m_maskImageOperation = o.m_maskImageOperation;
</ins><span class="cx"> m_xPosition = o.m_xPosition;
</span><span class="cx"> m_yPosition = o.m_yPosition;
</span><span class="cx"> m_backgroundXOrigin = o.m_backgroundXOrigin;
</span><span class="lines">@@ -153,7 +156,8 @@
</span><span class="cx"> {
</span><span class="cx"> // We do not check the "isSet" booleans for each property, since those are only used during initial construction
</span><span class="cx"> // to propagate patterns into layers. All layer comparisons happen after values have all been filled in anyway.
</span><del>- return StyleImage::imagesEquivalent(m_image.get(), o.m_image.get()) && m_xPosition == o.m_xPosition && m_yPosition == o.m_yPosition
</del><ins>+ return StyleImage::imagesEquivalent(m_image.get(), o.m_image.get()) && m_maskImageOperation == o.m_maskImageOperation
+ && m_xPosition == o.m_xPosition && m_yPosition == o.m_yPosition
</ins><span class="cx"> && m_backgroundXOrigin == o.m_backgroundXOrigin && m_backgroundYOrigin == o.m_backgroundYOrigin
</span><span class="cx"> && m_attachment == o.m_attachment && m_clip == o.m_clip && m_composite == o.m_composite
</span><span class="cx"> && m_blendMode == o.m_blendMode && m_origin == o.m_origin && m_repeatX == o.m_repeatX
</span><span class="lines">@@ -288,13 +292,21 @@
</span><span class="cx"> void FillLayer::cullEmptyLayers()
</span><span class="cx"> {
</span><span class="cx"> for (FillLayer* layer = this; layer; layer = layer->m_next.get()) {
</span><del>- if (layer->m_next && !layer->m_next->isImageSet()) {
</del><ins>+ if (layer->m_next && !layer->m_next->isImageSet() && !layer->m_next->hasMaskImage()) {
</ins><span class="cx"> layer->m_next = nullptr;
</span><span class="cx"> break;
</span><span class="cx"> }
</span><span class="cx"> }
</span><span class="cx"> }
</span><span class="cx">
</span><ins>+bool FillLayer::hasNonEmptyMaskImage() const
+{
+ if (hasMaskImage() && !maskImage()->isCSSValueNone())
+ return true;
+
+ return (next() ? next()->hasNonEmptyMaskImage() : false);
+}
+
</ins><span class="cx"> static inline EFillBox clipMax(EFillBox clipA, EFillBox clipB)
</span><span class="cx"> {
</span><span class="cx"> if (clipA == BorderFillBox || clipB == BorderFillBox)
</span><span class="lines">@@ -340,6 +352,9 @@
</span><span class="cx"> for (auto* layer = this; layer; layer = layer->m_next.get()) {
</span><span class="cx"> if (layer->m_image && !layer->m_image->isLoaded())
</span><span class="cx"> return false;
</span><ins>+
+ if (layer->hasMaskImage() && !layer->maskImage()->isMaskLoaded())
+ return false;
</ins><span class="cx"> }
</span><span class="cx"> return true;
</span><span class="cx"> }
</span></span></pre></div>
<a id="trunkSourceWebCorerenderingstyleFillLayerh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/rendering/style/FillLayer.h (176797 => 176798)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/rendering/style/FillLayer.h        2014-12-04 16:36:02 UTC (rev 176797)
+++ trunk/Source/WebCore/rendering/style/FillLayer.h        2014-12-04 17:05:12 UTC (rev 176798)
</span><span class="lines">@@ -27,6 +27,7 @@
</span><span class="cx">
</span><span class="cx"> #include "GraphicsTypes.h"
</span><span class="cx"> #include "LengthSize.h"
</span><ins>+#include "MaskImageOperation.h"
</ins><span class="cx"> #include "RenderStyleConstants.h"
</span><span class="cx"> #include "StyleImage.h"
</span><span class="cx"> #include <wtf/RefPtr.h>
</span><span class="lines">@@ -67,7 +68,9 @@
</span><span class="cx"> explicit FillLayer(EFillLayerType);
</span><span class="cx"> ~FillLayer();
</span><span class="cx">
</span><ins>+ const RefPtr<MaskImageOperation>& maskImage() const { return m_maskImageOperation; }
</ins><span class="cx"> StyleImage* image() const { return m_image.get(); }
</span><ins>+ StyleImage* imageOrMaskImage() const { return hasMaskImage() ? maskImage()->image() : image(); }
</ins><span class="cx"> const Length& xPosition() const { return m_xPosition; }
</span><span class="cx"> const Length& yPosition() const { return m_yPosition; }
</span><span class="cx"> BackgroundEdgeOrigin backgroundXOrigin() const { return static_cast<BackgroundEdgeOrigin>(m_backgroundXOrigin); }
</span><span class="lines">@@ -101,6 +104,7 @@
</span><span class="cx"> bool isSizeSet() const { return m_sizeType != SizeNone; }
</span><span class="cx"> bool isMaskSourceTypeSet() const { return m_maskSourceTypeSet; }
</span><span class="cx">
</span><ins>+ void setMaskImage(PassRefPtr<MaskImageOperation> maskImage) { m_maskImageOperation = maskImage; }
</ins><span class="cx"> void setImage(PassRefPtr<StyleImage> image) { m_image = image; m_imageSet = true; }
</span><span class="cx"> void setXPosition(Length length) { m_xPosition = WTF::move(length); m_xPosSet = true; }
</span><span class="cx"> void setYPosition(Length length) { m_yPosition = WTF::move(length); m_yPosSet = true; }
</span><span class="lines">@@ -118,6 +122,7 @@
</span><span class="cx"> void setSize(FillSize f) { m_sizeType = f.type; m_sizeLength = f.size; }
</span><span class="cx"> void setMaskSourceType(EMaskSourceType m) { m_maskSourceType = m; m_maskSourceTypeSet = true; }
</span><span class="cx">
</span><ins>+ void clearMaskImage() { m_maskImageOperation.clear(); }
</ins><span class="cx"> void clearImage() { m_image.clear(); m_imageSet = false; }
</span><span class="cx"> void clearXPosition() { m_xPosSet = false; m_backgroundOriginSet = false; }
</span><span class="cx"> void clearYPosition() { m_yPosSet = false; m_backgroundOriginSet = false; }
</span><span class="lines">@@ -143,6 +148,8 @@
</span><span class="cx"> bool containsImage(StyleImage&) const;
</span><span class="cx"> bool imagesAreLoaded() const;
</span><span class="cx"> bool hasImage() const;
</span><ins>+ bool hasMaskImage() const { return maskImage().get(); }
+ bool hasNonEmptyMaskImage() const;
</ins><span class="cx"> bool hasFixedImage() const;
</span><span class="cx"> bool hasOpaqueImage(const RenderElement&) const;
</span><span class="cx"> bool hasRepeatXY() const;
</span><span class="lines">@@ -175,6 +182,7 @@
</span><span class="cx">
</span><span class="cx"> std::unique_ptr<FillLayer> m_next;
</span><span class="cx">
</span><ins>+ RefPtr<MaskImageOperation> m_maskImageOperation;
</ins><span class="cx"> RefPtr<StyleImage> m_image;
</span><span class="cx">
</span><span class="cx"> Length m_xPosition;
</span></span></pre></div>
<a id="trunkSourceWebCorerenderingsvgRenderSVGResourceMaskercpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/rendering/svg/RenderSVGResourceMasker.cpp (176797 => 176798)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/rendering/svg/RenderSVGResourceMasker.cpp        2014-12-04 16:36:02 UTC (rev 176797)
+++ trunk/Source/WebCore/rendering/svg/RenderSVGResourceMasker.cpp        2014-12-04 17:05:12 UTC (rev 176798)
</span><span class="lines">@@ -25,6 +25,7 @@
</span><span class="cx"> #include "FloatPoint.h"
</span><span class="cx"> #include "Image.h"
</span><span class="cx"> #include "IntRect.h"
</span><ins>+#include "RenderBoxModelObject.h"
</ins><span class="cx"> #include "SVGRenderingContext.h"
</span><span class="cx">
</span><span class="cx"> namespace WebCore {
</span><span class="lines">@@ -53,10 +54,9 @@
</span><span class="cx"> markClientForInvalidation(client, markForInvalidation ? BoundariesInvalidation : ParentOnlyInvalidation);
</span><span class="cx"> }
</span><span class="cx">
</span><del>-bool RenderSVGResourceMasker::applyResource(RenderElement& renderer, const RenderStyle&, GraphicsContext*& context, unsigned short resourceMode)
</del><ins>+bool RenderSVGResourceMasker::applySVGMask(RenderElement& renderer, GraphicsContext*& context, bool applyClip)
</ins><span class="cx"> {
</span><span class="cx"> ASSERT(context);
</span><del>- ASSERT_UNUSED(resourceMode, resourceMode == ApplyToDefaultMode);
</del><span class="cx">
</span><span class="cx"> bool missingMaskerData = !m_masker.contains(&renderer);
</span><span class="cx"> if (missingMaskerData)
</span><span class="lines">@@ -75,18 +75,25 @@
</span><span class="cx"> if (!SVGRenderingContext::createImageBuffer(repaintRect, absoluteTransform, maskerData->maskImage, colorSpace, Unaccelerated))
</span><span class="cx"> return false;
</span><span class="cx">
</span><del>- if (!drawContentIntoMaskImage(maskerData, colorSpace, &renderer)) {
</del><ins>+ if (!drawContentIntoMaskImage(maskerData, colorSpace, &renderer))
</ins><span class="cx"> maskerData->maskImage.reset();
</span><del>- }
</del><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> if (!maskerData->maskImage)
</span><span class="cx"> return false;
</span><span class="cx">
</span><del>- SVGRenderingContext::clipToImageBuffer(context, absoluteTransform, repaintRect, maskerData->maskImage, missingMaskerData);
</del><ins>+ if (applyClip)
+ SVGRenderingContext::clipToImageBuffer(context, absoluteTransform, repaintRect, maskerData->maskImage, missingMaskerData);
+
</ins><span class="cx"> return true;
</span><span class="cx"> }
</span><span class="cx">
</span><ins>+bool RenderSVGResourceMasker::applyResource(RenderElement& renderer, const RenderStyle&, GraphicsContext*& context, unsigned short resourceMode)
+{
+ ASSERT_UNUSED(resourceMode, resourceMode == ApplyToDefaultMode);
+ return applySVGMask(renderer, context, true);
+}
+
</ins><span class="cx"> bool RenderSVGResourceMasker::drawContentIntoMaskImage(MaskerData* maskerData, ColorSpace colorSpace, RenderObject* object)
</span><span class="cx"> {
</span><span class="cx"> GraphicsContext* maskImageContext = maskerData->maskImage->context();
</span><span class="lines">@@ -127,6 +134,34 @@
</span><span class="cx"> return true;
</span><span class="cx"> }
</span><span class="cx">
</span><ins>+void RenderSVGResourceMasker::drawMaskForRenderer(RenderElement& renderer, const BackgroundImageGeometry& geometry, GraphicsContext* context, CompositeOperator compositeOp)
+{
+ if (context->paintingDisabled())
+ return;
+
+ if (!applySVGMask(renderer, context, false))
+ return;
+
+ MaskerData* maskerData = maskerDataForRenderer(renderer);
+ ASSERT(maskerData);
+
+ FloatRect oneTileRect;
+ FloatSize actualTileSize(geometry.tileSize().width() + geometry.spaceSize().width(), geometry.tileSize().height() + geometry.spaceSize().height());
+ oneTileRect.setX(geometry.destRect().x() + fmodf(fmodf(-geometry.relativePhase().x(), actualTileSize.width()) - actualTileSize.width(), actualTileSize.width()));
+ oneTileRect.setY(geometry.destRect().y() + fmodf(fmodf(-geometry.relativePhase().y(), actualTileSize.height()) - actualTileSize.height(), actualTileSize.height()));
+ oneTileRect.setSize(geometry.tileSize());
+
+ FloatSize intrinsicTileSize = maskerData->maskImage->logicalSize();
+ FloatSize scale(geometry.tileSize().width() / intrinsicTileSize.width(), geometry.tileSize().height() / intrinsicTileSize.height());
+
+ FloatRect visibleSrcRect;
+ visibleSrcRect.setX((geometry.destRect().x() - oneTileRect.x()) / scale.width());
+ visibleSrcRect.setY((geometry.destRect().y() - oneTileRect.y()) / scale.height());
+ visibleSrcRect.setWidth(geometry.destRect().width() / scale.width());
+ visibleSrcRect.setHeight(geometry.destRect().height() / scale.height());
+ context->drawImageBuffer(maskerData->maskImage.get(), ColorSpaceDeviceRGB, geometry.destRect(), visibleSrcRect, compositeOp);
+}
+
</ins><span class="cx"> void RenderSVGResourceMasker::calculateMaskContentRepaintRect()
</span><span class="cx"> {
</span><span class="cx"> for (Node* childNode = maskElement().firstChild(); childNode; childNode = childNode->nextSibling()) {
</span></span></pre></div>
<a id="trunkSourceWebCorerenderingsvgRenderSVGResourceMaskerh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/rendering/svg/RenderSVGResourceMasker.h (176797 => 176798)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/rendering/svg/RenderSVGResourceMasker.h        2014-12-04 16:36:02 UTC (rev 176797)
+++ trunk/Source/WebCore/rendering/svg/RenderSVGResourceMasker.h        2014-12-04 17:05:12 UTC (rev 176798)
</span><span class="lines">@@ -45,6 +45,7 @@
</span><span class="cx"> virtual void removeAllClientsFromCache(bool markForInvalidation = true) override;
</span><span class="cx"> virtual void removeClientFromCache(RenderElement&, bool markForInvalidation = true) override;
</span><span class="cx"> virtual bool applyResource(RenderElement&, const RenderStyle&, GraphicsContext*&, unsigned short resourceMode) override;
</span><ins>+ bool applySVGMask(RenderElement& renderer, GraphicsContext*&, bool applyClip);
</ins><span class="cx"> virtual FloatRect resourceBoundingBox(const RenderObject&) override;
</span><span class="cx">
</span><span class="cx"> SVGUnitTypes::SVGUnitType maskUnits() const { return maskElement().maskUnits(); }
</span><span class="lines">@@ -52,6 +53,9 @@
</span><span class="cx">
</span><span class="cx"> virtual RenderSVGResourceType resourceType() const override { return MaskerResourceType; }
</span><span class="cx">
</span><ins>+ MaskerData* maskerDataForRenderer(RenderObject& renderer) { return m_masker.get(&renderer); }
+ void drawMaskForRenderer(RenderElement& renderer, const BackgroundImageGeometry&, GraphicsContext*, CompositeOperator);
+
</ins><span class="cx"> private:
</span><span class="cx"> void element() const = delete;
</span><span class="cx">
</span></span></pre></div>
<a id="trunkSourceWebCoresvgSVGMaskElementcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/svg/SVGMaskElement.cpp (176797 => 176798)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/svg/SVGMaskElement.cpp        2014-12-04 16:36:02 UTC (rev 176797)
+++ trunk/Source/WebCore/svg/SVGMaskElement.cpp        2014-12-04 17:05:12 UTC (rev 176798)
</span><span class="lines">@@ -161,7 +161,33 @@
</span><span class="cx">
</span><span class="cx"> RenderPtr<RenderElement> SVGMaskElement::createElementRenderer(PassRef<RenderStyle> style)
</span><span class="cx"> {
</span><del>- return createRenderer<RenderSVGResourceMasker>(*this, WTF::move(style));
</del><ins>+ RenderPtr<RenderElement> maskRenderer = createRenderer<RenderSVGResourceMasker>(*this, WTF::move(style));
+
+ // Pass along existing render layer clients.
+ for (auto* clientLayer : m_clientLayers)
+ static_cast<RenderSVGResourceMasker*>(maskRenderer.get())->addClientRenderLayer(clientLayer);
+
+ return maskRenderer;
</ins><span class="cx"> }
</span><span class="cx">
</span><ins>+void SVGMaskElement::addClientRenderLayer(RenderLayer* client)
+{
+ ASSERT(client);
+ m_clientLayers.add(client);
+
+ // Pass it along to the renderer.
+ if (renderer())
+ static_cast<RenderSVGResourceMasker*>(renderer())->addClientRenderLayer(client);
</ins><span class="cx"> }
</span><ins>+
+void SVGMaskElement::removeClientRenderLayer(RenderLayer* client)
+{
+ ASSERT(client);
+ m_clientLayers.remove(client);
+
+ // Pass it along to the renderer.
+ if (renderer())
+ static_cast<RenderSVGResourceMasker*>(renderer())->removeClientRenderLayer(client);
+}
+
+}
</ins></span></pre></div>
<a id="trunkSourceWebCoresvgSVGMaskElementh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/svg/SVGMaskElement.h (176797 => 176798)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/svg/SVGMaskElement.h        2014-12-04 16:36:02 UTC (rev 176797)
+++ trunk/Source/WebCore/svg/SVGMaskElement.h        2014-12-04 17:05:12 UTC (rev 176798)
</span><span class="lines">@@ -30,6 +30,8 @@
</span><span class="cx"> #include "SVGUnitTypes.h"
</span><span class="cx">
</span><span class="cx"> namespace WebCore {
</span><ins>+
+class RenderLayer;
</ins><span class="cx">
</span><span class="cx"> class SVGMaskElement final : public SVGElement,
</span><span class="cx"> public SVGTests,
</span><span class="lines">@@ -37,6 +39,9 @@
</span><span class="cx"> public:
</span><span class="cx"> static PassRefPtr<SVGMaskElement> create(const QualifiedName&, Document&);
</span><span class="cx">
</span><ins>+ void addClientRenderLayer(RenderLayer*);
+ void removeClientRenderLayer(RenderLayer*);
+
</ins><span class="cx"> private:
</span><span class="cx"> SVGMaskElement(const QualifiedName&, Document&);
</span><span class="cx">
</span><span class="lines">@@ -48,6 +53,8 @@
</span><span class="cx"> virtual void svgAttributeChanged(const QualifiedName&) override;
</span><span class="cx"> virtual void childrenChanged(const ChildChange&) override;
</span><span class="cx">
</span><ins>+ HashSet<RenderLayer*> m_clientLayers;
+
</ins><span class="cx"> virtual RenderPtr<RenderElement> createElementRenderer(PassRef<RenderStyle>) override;
</span><span class="cx">
</span><span class="cx"> virtual bool selfHasRelativeLengths() const override { return true; }
</span></span></pre></div>
<a id="trunkSourceWebCoresvgSVGUseElementcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/svg/SVGUseElement.cpp (176797 => 176798)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/svg/SVGUseElement.cpp        2014-12-04 16:36:02 UTC (rev 176797)
+++ trunk/Source/WebCore/svg/SVGUseElement.cpp        2014-12-04 17:05:12 UTC (rev 176798)
</span><span class="lines">@@ -992,8 +992,11 @@
</span><span class="cx"> m_cachedDocument->removeClient(this);
</span><span class="cx">
</span><span class="cx"> m_cachedDocument = cachedDocument;
</span><del>- if (m_cachedDocument)
</del><ins>+ if (m_cachedDocument) {
+ // We don't need the SVG document to create a new frame because the new document belongs to the parent UseElement.
+ m_cachedDocument->setShouldCreateFrameForDocument(false);
</ins><span class="cx"> m_cachedDocument->addClient(this);
</span><ins>+ }
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> }
</span></span></pre></div>
<a id="trunkSourceWebCoresvggraphicsSVGImagecpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/svg/graphics/SVGImage.cpp (176797 => 176798)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/svg/graphics/SVGImage.cpp        2014-12-04 16:36:02 UTC (rev 176797)
+++ trunk/Source/WebCore/svg/graphics/SVGImage.cpp        2014-12-04 17:05:12 UTC (rev 176798)
</span><span class="lines">@@ -344,6 +344,8 @@
</span><span class="cx"> fillWithEmptyClients(pageConfiguration);
</span><span class="cx"> m_chromeClient = std::make_unique<SVGImageChromeClient>(this);
</span><span class="cx"> pageConfiguration.chromeClient = m_chromeClient.get();
</span><ins>+ bool canHaveScrollbars = false; // SVG Images will always synthesize a viewBox, if it's not available, and thus never see scrollbars.
+ bool transparent = true; // SVG Images are transparent.
</ins><span class="cx">
</span><span class="cx"> // FIXME: If this SVG ends up loading itself, we might leak the world.
</span><span class="cx"> // The Cache code does not know about CachedImages holding Frames and
</span><span class="lines">@@ -351,26 +353,8 @@
</span><span class="cx"> // This will become an issue when SVGImage will be able to load other
</span><span class="cx"> // SVGImage objects, but we're safe now, because SVGImage can only be
</span><span class="cx"> // loaded by a top-level document.
</span><del>- m_page = std::make_unique<Page>(pageConfiguration);
- m_page->settings().setMediaEnabled(false);
- m_page->settings().setScriptEnabled(false);
- m_page->settings().setPluginsEnabled(false);
</del><ins>+ m_page = Page::createPageFromBuffer(pageConfiguration, data(), "image/svg+xml", canHaveScrollbars, transparent);
</ins><span class="cx">
</span><del>- Frame& frame = m_page->mainFrame();
- frame.setView(FrameView::create(frame));
- frame.init();
- FrameLoader& loader = frame.loader();
- loader.forceSandboxFlags(SandboxAll);
-
- frame.view()->setCanHaveScrollbars(false); // SVG Images will always synthesize a viewBox, if it's not available, and thus never see scrollbars.
- frame.view()->setTransparent(true); // SVG Images are transparent.
-
- ASSERT(loader.activeDocumentLoader()); // DocumentLoader should have been created by frame->init().
- loader.activeDocumentLoader()->writer().setMIMEType("image/svg+xml");
- loader.activeDocumentLoader()->writer().begin(URL()); // create the empty document
- loader.activeDocumentLoader()->writer().addData(data()->data(), data()->size());
- loader.activeDocumentLoader()->writer().end();
-
</del><span class="cx"> // Set the intrinsic size before a container size is available.
</span><span class="cx"> m_intrinsicSize = containerSize();
</span><span class="cx"> }
</span></span></pre>
</div>
</div>
</body>
</html>