<!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>[213466] trunk</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/213466">213466</a></dd>
<dt>Author</dt> <dd>simon.fraser@apple.com</dd>
<dt>Date</dt> <dd>2017-03-06 13:45:38 -0800 (Mon, 06 Mar 2017)</dd>
</dl>

<h3>Log Message</h3>
<pre>Only use layer backing store which supports subpixel antialiased text if we know subpixel antialiased will be painted into it
https://bugs.webkit.org/show_bug.cgi?id=169191

Reviewed by Zalan Bujtas.

Source/WebCore:

Instead of unconditionally calling setSupportsSubpixelAntialiasedText() on GraphicsLayers created
by RenderLayerBacking, only do so when we know (or suspect) that a layer contains smoothed text.

This is done by enhancing RenderLayer::isVisuallyNonEmpty() and RenderLayer::hasNonEmptyChildRenderers()
to take a PaintedContentRequest parameter, which allows the caller to specify what qualities of
the layer contents it is interested in. Most of the time, this is just any painted content, but on
platforms where GraphicsLayer::supportsSubpixelAntialiasedLayerText() returns true, the query also
asks about whether the layer will contain subpixel-antialiased text. In this case, it can't early
return as soon as painted content is found; it must keep iterating renderers while all the query
requests are unsatisfied, or until it hits depth or sibling limits. If a limit is hit, we take the
same path of assuming there is subpixel-antialiased text (via the &quot;Undetermined&quot; state).

RenderLayerBacking also makes use of PaintedContentRequest during its non-composited child layer walk.

To offset the additional cost of this tree walking, RenderLayerBacking now caches information about its
painted content for the duration of a single update via PaintedContentsInfo, so we no longer call
isDirectlyCompositedImage() and isSimpleContainerCompositingLayer() multiple times per backing per update.
The traversal code here too now has to continue until all necessary states in the request have been computed.

Add some functions to RenderImage so that we know if it's showing the alt text or has a non-bitmap image
(which may contain text).

Subpixel-antialiased (&quot;smoothed&quot;) text is disabled by DRT and WTR by default, so we need Internals API to enable it.

Platforms now express their support for subpixel-antialiased text via GraphicsLayer::supportsSubpixelAntialiasedLayerText()
which only returns true on Mac.

Tests: compositing/contents-format/subpixel-antialiased-text-configs-antialiasing-style.html
       compositing/contents-format/subpixel-antialiased-text-configs.html
       compositing/contents-format/subpixel-antialiased-text-images.html
       compositing/contents-format/subpixel-antialiased-text-visibility.html

* platform/graphics/GraphicsLayer.cpp:
(WebCore::GraphicsLayer::supportsSubpixelAntialiasedLayerText):
* platform/graphics/GraphicsLayer.h:
* platform/graphics/ca/GraphicsLayerCA.cpp:
(WebCore::GraphicsLayer::supportsSubpixelAntialiasedLayerText):
(WebCore::GraphicsLayerCA::changeLayerTypeTo):
* rendering/RenderImage.cpp:
(WebCore::RenderImage::isShowingMissingOrImageError):
(WebCore::RenderImage::isShowingAltText):
(WebCore::RenderImage::hasNonBitmapImage):
* rendering/RenderImage.h:
* rendering/RenderLayer.cpp:
(WebCore::RenderLayer::calculateClipRects):
* rendering/RenderLayer.h:
* rendering/RenderLayerBacking.cpp:
(WebCore::PaintedContentsInfo::PaintedContentsInfo):
(WebCore::PaintedContentsInfo::setWantsSubpixelAntialiasedTextState):
(WebCore::PaintedContentsInfo::paintsBoxDecorations):
(WebCore::PaintedContentsInfo::paintsContent):
(WebCore::PaintedContentsInfo::paintsSubpixelAntialiasedText):
(WebCore::PaintedContentsInfo::isSimpleContainer):
(WebCore::PaintedContentsInfo::isDirectlyCompositedImage):
(WebCore::PaintedContentsInfo::paintsBoxDecorationsDetermination):
(WebCore::PaintedContentsInfo::paintsContentDetermination):
(WebCore::PaintedContentsInfo::paintsSubpixelAntialiasedTextDetermination):
(WebCore::PaintedContentsInfo::contentsTypeDetermination):
(WebCore::RenderLayerBacking::createGraphicsLayer):
(WebCore::RenderLayerBacking::updateConfiguration):
(WebCore::RenderLayerBacking::computeParentGraphicsLayerRect):
(WebCore::RenderLayerBacking::updateAfterDescendants):
(WebCore::RenderLayerBacking::updateDirectlyCompositedBoxDecorations):
(WebCore::RenderLayerBacking::updateDrawsContent):
(WebCore::RenderLayerBacking::updateDirectlyCompositedBackgroundColor):
(WebCore::RenderLayerBacking::updateDirectlyCompositedBackgroundImage):
(WebCore::RenderLayerBacking::paintsContent):
(WebCore::RenderLayerBacking::isSimpleContainerCompositingLayer):
(WebCore::RenderLayerBacking::isPaintDestinationForDescendantLayers):
(WebCore::RenderLayerBacking::hasVisibleNonCompositedDescendants):
(WebCore::RenderLayerBacking::containsPaintedContent):
(WebCore::RenderLayerBacking::contentChanged):
(WebCore::RenderLayerBacking::updateImageContents):
(WebCore::RenderLayerBacking::paintsChildRenderers): Deleted.
* rendering/RenderLayerBacking.h:
* rendering/RenderLayerCompositor.cpp:
(WebCore::RenderLayerCompositor::logLayerInfo):
* testing/Internals.cpp:
(WebCore::Internals::setFontSmoothingEnabled):
* testing/Internals.h:
* testing/Internals.idl:

LayoutTests:

Test lots of layer configs for subpixel antialiased text support. Only Mac results show the
&quot;(supports subpixel antialiased text 1)&quot; flag on layers now, since the patch makes this
dependent on platform support.

* compositing/contents-format/subpixel-antialiased-text-configs-antialiasing-style-expected.txt: Added.
* compositing/contents-format/subpixel-antialiased-text-configs-antialiasing-style.html: Added.
* compositing/contents-format/subpixel-antialiased-text-configs-expected.txt: Added.
* compositing/contents-format/subpixel-antialiased-text-configs.html: Added.
* compositing/contents-format/subpixel-antialiased-text-enabled-expected.txt:
* compositing/contents-format/subpixel-antialiased-text-enabled.html:
* compositing/contents-format/subpixel-antialiased-text-images-expected.txt: Added.
* compositing/contents-format/subpixel-antialiased-text-images.html: Added.
* compositing/contents-format/subpixel-antialiased-text-visibility-expected.txt: Added.
* compositing/contents-format/subpixel-antialiased-text-visibility.html: Added.
* compositing/resources/circle-with-text.svg: Added.
* compositing/resources/circle.svg: Added.
* platform/mac-wk1/compositing/contents-format/subpixel-antialiased-text-enabled-expected.txt:
* platform/mac/compositing/contents-format/subpixel-antialiased-text-configs-antialiasing-style-expected.txt: Added.
* platform/mac/compositing/contents-format/subpixel-antialiased-text-configs-expected.txt: Added.
* platform/mac/compositing/contents-format/subpixel-antialiased-text-enabled-expected.txt: Copied from LayoutTests/compositing/contents-format/subpixel-antialiased-text-enabled-expected.txt.
* platform/mac/compositing/contents-format/subpixel-antialiased-text-images-expected.txt: Added.
* platform/mac/compositing/contents-format/subpixel-antialiased-text-visibility-expected.txt: Added.</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkLayoutTestsChangeLog">trunk/LayoutTests/ChangeLog</a></li>
<li><a href="#trunkLayoutTestscompositingcontentsformatsubpixelantialiasedtextenabledexpectedtxt">trunk/LayoutTests/compositing/contents-format/subpixel-antialiased-text-enabled-expected.txt</a></li>
<li><a href="#trunkLayoutTestscompositingcontentsformatsubpixelantialiasedtextenabledhtml">trunk/LayoutTests/compositing/contents-format/subpixel-antialiased-text-enabled.html</a></li>
<li><a href="#trunkLayoutTestsplatformmacwk1compositingcontentsformatsubpixelantialiasedtextenabledexpectedtxt">trunk/LayoutTests/platform/mac-wk1/compositing/contents-format/subpixel-antialiased-text-enabled-expected.txt</a></li>
<li><a href="#trunkSourceWebCoreChangeLog">trunk/Source/WebCore/ChangeLog</a></li>
<li><a href="#trunkSourceWebCoreplatformgraphicsGraphicsLayercpp">trunk/Source/WebCore/platform/graphics/GraphicsLayer.cpp</a></li>
<li><a href="#trunkSourceWebCoreplatformgraphicsGraphicsLayerh">trunk/Source/WebCore/platform/graphics/GraphicsLayer.h</a></li>
<li><a href="#trunkSourceWebCoreplatformgraphicscaGraphicsLayerCAcpp">trunk/Source/WebCore/platform/graphics/ca/GraphicsLayerCA.cpp</a></li>
<li><a href="#trunkSourceWebCorerenderingRenderImagecpp">trunk/Source/WebCore/rendering/RenderImage.cpp</a></li>
<li><a href="#trunkSourceWebCorerenderingRenderImageh">trunk/Source/WebCore/rendering/RenderImage.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="#trunkSourceWebCorerenderingRenderLayerBackingcpp">trunk/Source/WebCore/rendering/RenderLayerBacking.cpp</a></li>
<li><a href="#trunkSourceWebCorerenderingRenderLayerBackingh">trunk/Source/WebCore/rendering/RenderLayerBacking.h</a></li>
<li><a href="#trunkSourceWebCorerenderingRenderLayerCompositorcpp">trunk/Source/WebCore/rendering/RenderLayerCompositor.cpp</a></li>
<li><a href="#trunkSourceWebCoretestingInternalscpp">trunk/Source/WebCore/testing/Internals.cpp</a></li>
<li><a href="#trunkSourceWebCoretestingInternalsh">trunk/Source/WebCore/testing/Internals.h</a></li>
<li><a href="#trunkSourceWebCoretestingInternalsidl">trunk/Source/WebCore/testing/Internals.idl</a></li>
</ul>

<h3>Added Paths</h3>
<ul>
<li><a href="#trunkLayoutTestscompositingcontentsformatsubpixelantialiasedtextconfigsantialiasingstyleexpectedtxt">trunk/LayoutTests/compositing/contents-format/subpixel-antialiased-text-configs-antialiasing-style-expected.txt</a></li>
<li><a href="#trunkLayoutTestscompositingcontentsformatsubpixelantialiasedtextconfigsantialiasingstylehtml">trunk/LayoutTests/compositing/contents-format/subpixel-antialiased-text-configs-antialiasing-style.html</a></li>
<li><a href="#trunkLayoutTestscompositingcontentsformatsubpixelantialiasedtextconfigsexpectedtxt">trunk/LayoutTests/compositing/contents-format/subpixel-antialiased-text-configs-expected.txt</a></li>
<li><a href="#trunkLayoutTestscompositingcontentsformatsubpixelantialiasedtextconfigshtml">trunk/LayoutTests/compositing/contents-format/subpixel-antialiased-text-configs.html</a></li>
<li><a href="#trunkLayoutTestscompositingcontentsformatsubpixelantialiasedtextimagesexpectedtxt">trunk/LayoutTests/compositing/contents-format/subpixel-antialiased-text-images-expected.txt</a></li>
<li><a href="#trunkLayoutTestscompositingcontentsformatsubpixelantialiasedtextimageshtml">trunk/LayoutTests/compositing/contents-format/subpixel-antialiased-text-images.html</a></li>
<li><a href="#trunkLayoutTestscompositingcontentsformatsubpixelantialiasedtextvisibilityexpectedtxt">trunk/LayoutTests/compositing/contents-format/subpixel-antialiased-text-visibility-expected.txt</a></li>
<li><a href="#trunkLayoutTestscompositingcontentsformatsubpixelantialiasedtextvisibilityhtml">trunk/LayoutTests/compositing/contents-format/subpixel-antialiased-text-visibility.html</a></li>
<li><a href="#trunkLayoutTestscompositingresourcescirclewithtextsvg">trunk/LayoutTests/compositing/resources/circle-with-text.svg</a></li>
<li><a href="#trunkLayoutTestscompositingresourcescirclesvg">trunk/LayoutTests/compositing/resources/circle.svg</a></li>
<li>trunk/LayoutTests/platform/mac/compositing/contents-format/</li>
<li><a href="#trunkLayoutTestsplatformmaccompositingcontentsformatsubpixelantialiasedtextconfigsantialiasingstyleexpectedtxt">trunk/LayoutTests/platform/mac/compositing/contents-format/subpixel-antialiased-text-configs-antialiasing-style-expected.txt</a></li>
<li><a href="#trunkLayoutTestsplatformmaccompositingcontentsformatsubpixelantialiasedtextconfigsexpectedtxt">trunk/LayoutTests/platform/mac/compositing/contents-format/subpixel-antialiased-text-configs-expected.txt</a></li>
<li><a href="#trunkLayoutTestsplatformmaccompositingcontentsformatsubpixelantialiasedtextenabledexpectedtxt">trunk/LayoutTests/platform/mac/compositing/contents-format/subpixel-antialiased-text-enabled-expected.txt</a></li>
<li><a href="#trunkLayoutTestsplatformmaccompositingcontentsformatsubpixelantialiasedtextimagesexpectedtxt">trunk/LayoutTests/platform/mac/compositing/contents-format/subpixel-antialiased-text-images-expected.txt</a></li>
<li><a href="#trunkLayoutTestsplatformmaccompositingcontentsformatsubpixelantialiasedtextvisibilityexpectedtxt">trunk/LayoutTests/platform/mac/compositing/contents-format/subpixel-antialiased-text-visibility-expected.txt</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkLayoutTestsChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/ChangeLog (213465 => 213466)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/ChangeLog        2017-03-06 21:44:20 UTC (rev 213465)
+++ trunk/LayoutTests/ChangeLog        2017-03-06 21:45:38 UTC (rev 213466)
</span><span class="lines">@@ -1,3 +1,33 @@
</span><ins>+2017-03-06  Simon Fraser  &lt;simon.fraser@apple.com&gt;
+
+        Only use layer backing store which supports subpixel antialiased text if we know subpixel antialiased will be painted into it
+        https://bugs.webkit.org/show_bug.cgi?id=169191
+
+        Reviewed by Zalan Bujtas.
+
+        Test lots of layer configs for subpixel antialiased text support. Only Mac results show the
+        &quot;(supports subpixel antialiased text 1)&quot; flag on layers now, since the patch makes this
+        dependent on platform support.
+
+        * compositing/contents-format/subpixel-antialiased-text-configs-antialiasing-style-expected.txt: Added.
+        * compositing/contents-format/subpixel-antialiased-text-configs-antialiasing-style.html: Added.
+        * compositing/contents-format/subpixel-antialiased-text-configs-expected.txt: Added.
+        * compositing/contents-format/subpixel-antialiased-text-configs.html: Added.
+        * compositing/contents-format/subpixel-antialiased-text-enabled-expected.txt:
+        * compositing/contents-format/subpixel-antialiased-text-enabled.html:
+        * compositing/contents-format/subpixel-antialiased-text-images-expected.txt: Added.
+        * compositing/contents-format/subpixel-antialiased-text-images.html: Added.
+        * compositing/contents-format/subpixel-antialiased-text-visibility-expected.txt: Added.
+        * compositing/contents-format/subpixel-antialiased-text-visibility.html: Added.
+        * compositing/resources/circle-with-text.svg: Added.
+        * compositing/resources/circle.svg: Added.
+        * platform/mac-wk1/compositing/contents-format/subpixel-antialiased-text-enabled-expected.txt:
+        * platform/mac/compositing/contents-format/subpixel-antialiased-text-configs-antialiasing-style-expected.txt: Added.
+        * platform/mac/compositing/contents-format/subpixel-antialiased-text-configs-expected.txt: Added.
+        * platform/mac/compositing/contents-format/subpixel-antialiased-text-enabled-expected.txt: Copied from LayoutTests/compositing/contents-format/subpixel-antialiased-text-enabled-expected.txt.
+        * platform/mac/compositing/contents-format/subpixel-antialiased-text-images-expected.txt: Added.
+        * platform/mac/compositing/contents-format/subpixel-antialiased-text-visibility-expected.txt: Added.
+
</ins><span class="cx"> 2017-03-06  Myles C. Maxfield  &lt;mmaxfield@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         Expand font-weight and font-stretch to take any number
</span></span></pre></div>
<a id="trunkLayoutTestscompositingcontentsformatsubpixelantialiasedtextconfigsantialiasingstyleexpectedtxt"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/compositing/contents-format/subpixel-antialiased-text-configs-antialiasing-style-expected.txt (0 => 213466)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/compositing/contents-format/subpixel-antialiased-text-configs-antialiasing-style-expected.txt                                (rev 0)
+++ trunk/LayoutTests/compositing/contents-format/subpixel-antialiased-text-configs-antialiasing-style-expected.txt        2017-03-06 21:45:38 UTC (rev 213466)
</span><span class="lines">@@ -0,0 +1,118 @@
</span><ins>+     
+Text here
+
+Antialiased text
+
+Smoothed text
+
+Antialised text
+Smoothed text
+
+Child composited layer
+
+Smoothed text
+
+Antialiased text
+
+Antialiased text
+
+Smoothed text
+
+Exceeds depth test antialiased
+
+Exceeds depth test smoothed
+
+(GraphicsLayer
+  (anchor 0.00 0.00)
+  (bounds 800.00 600.00)
+  (children 1
+    (GraphicsLayer
+      (bounds 800.00 600.00)
+      (contentsOpaque 1)
+      (children 12
+        (GraphicsLayer
+          (position 12.00 17.00)
+          (bounds 162.00 162.00)
+          (drawsContent 1)
+        )
+        (GraphicsLayer
+          (position 182.00 17.00)
+          (bounds 162.00 162.00)
+          (drawsContent 1)
+        )
+        (GraphicsLayer
+          (position 352.00 17.00)
+          (bounds 162.00 162.00)
+          (drawsContent 1)
+        )
+        (GraphicsLayer
+          (position 522.00 17.00)
+          (bounds 162.00 162.00)
+          (drawsContent 1)
+        )
+        (GraphicsLayer
+          (position 12.00 187.00)
+          (bounds 162.00 162.00)
+          (drawsContent 1)
+        )
+        (GraphicsLayer
+          (position 182.00 187.00)
+          (bounds 162.00 162.00)
+          (drawsContent 1)
+        )
+        (GraphicsLayer
+          (position 352.00 187.00)
+          (bounds 162.00 162.00)
+          (drawsContent 1)
+        )
+        (GraphicsLayer
+          (position 522.00 187.00)
+          (bounds 162.00 162.00)
+          (drawsContent 1)
+          (children 1
+            (GraphicsLayer
+              (position 27.00 43.00)
+              (bounds 108.00 60.00)
+              (drawsContent 1)
+            )
+          )
+        )
+        (GraphicsLayer
+          (position 12.00 357.00)
+          (bounds 162.00 162.00)
+          (drawsContent 1)
+          (children 1
+            (GraphicsLayer
+              (position 27.00 43.00)
+              (bounds 108.00 20.00)
+              (drawsContent 1)
+            )
+          )
+        )
+        (GraphicsLayer
+          (position 182.00 357.00)
+          (bounds 162.00 162.00)
+          (drawsContent 1)
+          (children 1
+            (GraphicsLayer
+              (position 27.00 43.00)
+              (bounds 108.00 20.00)
+              (drawsContent 1)
+            )
+          )
+        )
+        (GraphicsLayer
+          (position 352.00 357.00)
+          (bounds 162.00 162.00)
+          (drawsContent 1)
+        )
+        (GraphicsLayer
+          (position 522.00 357.00)
+          (bounds 162.00 162.00)
+          (drawsContent 1)
+        )
+      )
+    )
+  )
+)
+
</ins></span></pre></div>
<a id="trunkLayoutTestscompositingcontentsformatsubpixelantialiasedtextconfigsantialiasingstylehtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/compositing/contents-format/subpixel-antialiased-text-configs-antialiasing-style.html (0 => 213466)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/compositing/contents-format/subpixel-antialiased-text-configs-antialiasing-style.html                                (rev 0)
+++ trunk/LayoutTests/compositing/contents-format/subpixel-antialiased-text-configs-antialiasing-style.html        2017-03-06 21:45:38 UTC (rev 213466)
</span><span class="lines">@@ -0,0 +1,138 @@
</span><ins>+&lt;!DOCTYPE html&gt;
+
+&lt;html&gt;
+&lt;head&gt;
+    &lt;style&gt;
+        .container {
+            height: 150px;
+            width: 150px;
+            float: left;
+            position: relative;
+            border: 1px solid black;
+            padding: 20px;
+            margin: 10px;
+            box-sizing: border-box;
+            box-shadow: 0 0 4px rgba(0, 0, 0, 0.2);
+        }
+
+        .box {
+            position: relative;
+            height: 40px;
+            width: 100px;
+            background-color: rgba(0, 0, 128, 0.5);
+        }
+        
+        p {
+            line-height: 20px;
+        }
+
+        .composited {
+            will-change: transform;
+        }
+
+        .antialiased {
+            -webkit-font-smoothing: antialiased;
+        }
+
+        .smoothed {
+            -webkit-font-smoothing: subpixel-antialiased;
+        }
+    &lt;/style&gt;
+    &lt;script&gt;
+        if (window.testRunner)
+            testRunner.dumpAsText();
+
+        if (window.internals) {
+            internals.setFontSmoothingEnabled(true);
+            internals.settings.setSubpixelAntialiasedLayerTextEnabled(true)
+        }
+
+        function doTest()
+        {
+            if (window.internals)
+                document.getElementById('layers').innerText = internals.layerTreeAsText(document);
+        }
+
+        window.addEventListener('load', doTest, false);
+    &lt;/script&gt;
+&lt;/head&gt;
+&lt;body&gt;
+
+&lt;div class=&quot;composited container&quot;&gt;
+&lt;/div&gt;
+
+&lt;div class=&quot;composited container&quot;&gt;
+    &lt;span&gt; &lt;/span&gt; &lt;p class=&quot;smoothed&quot;&gt; &lt;/p&gt;
+&lt;/div&gt;
+
+&lt;div class=&quot;composited container&quot;&gt;
+    &amp;nbsp; &amp;nbsp; &amp;nbsp;
+&lt;/div&gt;
+
+&lt;div class=&quot;composited container&quot;&gt;
+    &lt;p&gt;Text here&lt;/p&gt;
+&lt;/div&gt;
+
+&lt;div class=&quot;composited container antialiased&quot;&gt;
+    &lt;p&gt;Antialiased text&lt;/p&gt;
+&lt;/div&gt;
+
+&lt;div class=&quot;composited container smoothed&quot;&gt;
+    &lt;p&gt;Smoothed text&lt;/p&gt;
+&lt;/div&gt;
+
+&lt;div class=&quot;composited container&quot;&gt;
+    &lt;div class=&quot;antialiased&quot;&gt;Antialised text&lt;/div&gt;
+    &lt;div class=&quot;smoothed&quot; style=&quot;position: relative;&quot;&gt;
+        &lt;p&gt;Smoothed text&lt;/p&gt;
+    &lt;/div&gt;
+&lt;/div&gt;
+
+&lt;div class=&quot;composited container&quot;&gt;
+    &lt;div class=&quot;composited&quot;&gt;
+        &lt;p&gt;Child composited layer&lt;/p&gt;
+    &lt;/div&gt;
+&lt;/div&gt;
+
+&lt;div class=&quot;composited container&quot;&gt;
+    &lt;div class=&quot;composited&quot;&gt;
+        &lt;p class=&quot;smoothed&quot;&gt;Smoothed text&lt;/p&gt;
+    &lt;/div&gt;
+    &lt;p class=&quot;antialiased&quot;&gt;Antialiased text&lt;/p&gt;
+&lt;/div&gt;
+
+&lt;div class=&quot;composited container&quot;&gt;
+    &lt;div class=&quot;composited&quot;&gt;
+        &lt;p class=&quot;antialiased&quot;&gt;Antialiased text&lt;/p&gt;
+    &lt;/div&gt;
+    &lt;p class=&quot;smoothed&quot;&gt;Smoothed text&lt;/p&gt;
+&lt;/div&gt;
+
+&lt;div class=&quot;composited container&quot;&gt;
+    &lt;div style=&quot;position-relative&quot;&gt;
+        &lt;div style=&quot;position-relative&quot;&gt;
+            &lt;div style=&quot;position-relative&quot;&gt;
+                &lt;div style=&quot;position-relative&quot;&gt;
+                    &lt;p class=&quot;antialiased&quot;&gt;Exceeds depth test antialiased&lt;/p&gt;
+                &lt;/div&gt;
+            &lt;/div&gt;
+        &lt;/div&gt;
+    &lt;/div&gt;
+&lt;/div&gt;
+
+&lt;div class=&quot;composited container&quot;&gt;
+    &lt;div style=&quot;position-relative&quot;&gt;
+        &lt;div style=&quot;position-relative&quot;&gt;
+            &lt;div style=&quot;position-relative&quot;&gt;
+                &lt;div style=&quot;position-relative&quot;&gt;
+                    &lt;p class=&quot;smoothed&quot;&gt;Exceeds depth test smoothed&lt;/p&gt;
+                &lt;/div&gt;
+            &lt;/div&gt;
+        &lt;/div&gt;
+    &lt;/div&gt;
+&lt;/div&gt;
+
+&lt;pre id=&quot;layers&quot;&gt;&lt;/pre&gt;
+
+&lt;/body&gt;
+&lt;/html&gt;
</ins></span></pre></div>
<a id="trunkLayoutTestscompositingcontentsformatsubpixelantialiasedtextconfigsexpectedtxt"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/compositing/contents-format/subpixel-antialiased-text-configs-expected.txt (0 => 213466)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/compositing/contents-format/subpixel-antialiased-text-configs-expected.txt                                (rev 0)
+++ trunk/LayoutTests/compositing/contents-format/subpixel-antialiased-text-configs-expected.txt        2017-03-06 21:45:38 UTC (rev 213466)
</span><span class="lines">@@ -0,0 +1,103 @@
</span><ins>+      Solid background
+Text here
+
+Text here
+
+Negative z-index child
+And more content
+Child layer
+
+Child composited layer
+
+Child composited layer
+
+Text here.  
+(GraphicsLayer
+  (anchor 0.00 0.00)
+  (bounds 800.00 600.00)
+  (children 1
+    (GraphicsLayer
+      (bounds 800.00 600.00)
+      (contentsOpaque 1)
+      (children 11
+        (GraphicsLayer
+          (position 12.00 17.00)
+          (bounds 162.00 162.00)
+          (drawsContent 1)
+        )
+        (GraphicsLayer
+          (position 182.00 17.00)
+          (bounds 162.00 162.00)
+          (drawsContent 1)
+        )
+        (GraphicsLayer
+          (position 352.00 17.00)
+          (bounds 162.00 162.00)
+          (drawsContent 1)
+        )
+        (GraphicsLayer
+          (position 522.00 17.00)
+          (bounds 162.00 162.00)
+          (drawsContent 1)
+        )
+        (GraphicsLayer
+          (position 12.00 187.00)
+          (bounds 162.00 162.00)
+          (drawsContent 1)
+        )
+        (GraphicsLayer
+          (position 182.00 187.00)
+          (bounds 162.00 162.00)
+          (drawsContent 1)
+          (children 1
+            (GraphicsLayer
+              (position 27.00 79.00)
+              (bounds 100.00 40.00)
+              (drawsContent 1)
+            )
+          )
+        )
+        (GraphicsLayer
+          (position 352.00 187.00)
+          (bounds 162.00 162.00)
+          (drawsContent 1)
+        )
+        (GraphicsLayer
+          (position 522.00 187.00)
+          (bounds 162.00 162.00)
+          (drawsContent 1)
+          (children 1
+            (GraphicsLayer
+              (position 27.00 43.00)
+              (bounds 108.00 60.00)
+              (drawsContent 1)
+            )
+          )
+        )
+        (GraphicsLayer
+          (position 12.00 357.00)
+          (bounds 162.00 162.00)
+          (drawsContent 1)
+          (children 1
+            (GraphicsLayer
+              (position 27.00 43.00)
+              (bounds 108.00 60.00)
+              (drawsContent 1)
+            )
+          )
+        )
+        (GraphicsLayer
+          (position 182.00 357.00)
+          (bounds 162.00 162.00)
+          (drawsContent 1)
+        )
+        (GraphicsLayer
+          (position 352.00 357.00)
+          (bounds 162.00 162.00)
+          (drawsContent 1)
+        )
+      )
+    )
+  )
+)
+
</ins></span></pre></div>
<a id="trunkLayoutTestscompositingcontentsformatsubpixelantialiasedtextconfigshtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/compositing/contents-format/subpixel-antialiased-text-configs.html (0 => 213466)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/compositing/contents-format/subpixel-antialiased-text-configs.html                                (rev 0)
+++ trunk/LayoutTests/compositing/contents-format/subpixel-antialiased-text-configs.html        2017-03-06 21:45:38 UTC (rev 213466)
</span><span class="lines">@@ -0,0 +1,113 @@
</span><ins>+&lt;!DOCTYPE html&gt;
+
+&lt;html&gt;
+&lt;head&gt;
+    &lt;style&gt;
+        .container {
+            height: 150px;
+            width: 150px;
+            float: left;
+            position: relative;
+            border: 1px solid black;
+            padding: 20px;
+            margin: 10px;
+            box-sizing: border-box;
+            box-shadow: 0 0 4px rgba(0, 0, 0, 0.2);
+        }
+        
+        .box {
+            position: relative;
+            height: 40px;
+            width: 100px;
+            background-color: rgba(0, 0, 128, 0.5);
+        }
+
+        p {
+            line-height: 20px;
+        }
+
+        .composited {
+            will-change: transform;
+        }
+    &lt;/style&gt;
+    &lt;script&gt;
+        if (window.testRunner)
+            testRunner.dumpAsText();
+
+        if (window.internals) {
+            internals.setFontSmoothingEnabled(true);
+            internals.settings.setSubpixelAntialiasedLayerTextEnabled(true)
+        }
+
+        function doTest()
+        {
+            if (window.internals)
+                document.getElementById('layers').innerText = internals.layerTreeAsText(document);
+        }
+
+        window.addEventListener('load', doTest, false);
+    &lt;/script&gt;
+&lt;/head&gt;
+&lt;body&gt;
+
+&lt;div class=&quot;composited container&quot;&gt;
+&lt;/div&gt;
+
+&lt;div class=&quot;composited container&quot;&gt;
+    &lt;span&gt; &lt;/span&gt; &lt;p&gt; &lt;/p&gt;
+&lt;/div&gt;
+
+&lt;div class=&quot;composited container&quot;&gt;
+    &amp;nbsp; &amp;nbsp; &amp;nbsp;
+&lt;/div&gt;
+
+&lt;div class=&quot;composited container&quot; style=&quot;background-color: silver;&quot;&gt;
+    Solid background
+&lt;/div&gt;
+
+&lt;div class=&quot;composited container&quot;&gt;
+    &lt;p&gt;Text here&lt;/p&gt;
+&lt;/div&gt;
+
+&lt;div class=&quot;composited container&quot;&gt;
+    &lt;p&gt;Text here&lt;/p&gt;
+    &lt;div class=&quot;composited box&quot;&gt;
+        Negative z-index child
+    &lt;/div&gt;
+    And more content
+&lt;/div&gt;
+
+&lt;div class=&quot;composited container&quot;&gt;
+    &lt;div style=&quot;position: relative;&quot;&gt;
+        &lt;p&gt;Child layer&lt;/p&gt;
+    &lt;/div&gt;
+&lt;/div&gt;
+
+&lt;div class=&quot;composited container&quot;&gt;
+    &lt;div class=&quot;composited&quot;&gt;
+        &lt;p&gt;Child composited layer&lt;/p&gt;
+    &lt;/div&gt;
+&lt;/div&gt;
+
+&lt;div class=&quot;composited container&quot;&gt;
+    &lt;div class=&quot;composited&quot;&gt;
+        &lt;p&gt;Child composited layer&lt;/p&gt;
+    &lt;/div&gt;
+    Text here.
+&lt;/div&gt;
+
+&lt;div class=&quot;composited container&quot;&gt;
+    &lt;input type=&quot;text&quot; style=&quot;width: 90%&quot; value=&quot;input&quot;&gt;
+&lt;/div&gt;
+
+&lt;div class=&quot;composited container&quot;&gt;
+    &lt;select style=&quot;width: 90%&quot;&gt;
+        &lt;option&gt;First option&lt;/option&gt;
+        &lt;option&gt;Second option&lt;/option&gt;
+    &lt;/select&gt;
+&lt;/div&gt;
+
+&lt;pre id=&quot;layers&quot;&gt;&lt;/pre&gt;
+
+&lt;/body&gt;
+&lt;/html&gt;
</ins></span></pre></div>
<a id="trunkLayoutTestscompositingcontentsformatsubpixelantialiasedtextenabledexpectedtxt"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/compositing/contents-format/subpixel-antialiased-text-enabled-expected.txt (213465 => 213466)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/compositing/contents-format/subpixel-antialiased-text-enabled-expected.txt        2017-03-06 21:44:20 UTC (rev 213465)
+++ trunk/LayoutTests/compositing/contents-format/subpixel-antialiased-text-enabled-expected.txt        2017-03-06 21:45:38 UTC (rev 213466)
</span><span class="lines">@@ -1,5 +1,6 @@
</span><span class="cx"> Normal layer
</span><span class="cx"> Tiled layer
</span><ins>+Become-tiled layer
</ins><span class="cx"> (GraphicsLayer
</span><span class="cx">   (anchor 0.00 0.00)
</span><span class="cx">   (bounds 5018.00 2018.00)
</span><span class="lines">@@ -7,17 +8,14 @@
</span><span class="cx">     (GraphicsLayer
</span><span class="cx">       (bounds 5018.00 2018.00)
</span><span class="cx">       (contentsOpaque 1)
</span><del>-      (supports subpixel antialiased text 1)
</del><span class="cx">       (tile cache coverage 0, 0 1024 x 1024)
</span><span class="cx">       (tile size 512 x 512)
</span><span class="cx">       (top left tile 0, 0 tiles grid 2 x 2)
</span><span class="cx">       (in window 1)
</span><del>-      (children 2
</del><ins>+      (children 3
</ins><span class="cx">         (GraphicsLayer
</span><span class="cx">           (position 18.00 10.00)
</span><span class="cx">           (bounds 100.00 100.00)
</span><del>-          (contentsOpaque 1)
-          (supports subpixel antialiased text 1)
</del><span class="cx">           (drawsContent 1)
</span><span class="cx">         )
</span><span class="cx">         (GraphicsLayer
</span><span class="lines">@@ -24,8 +22,6 @@
</span><span class="cx">           (position 18.00 120.00)
</span><span class="cx">           (bounds 5000.00 100.00)
</span><span class="cx">           (usingTiledLayer 1)
</span><del>-          (contentsOpaque 1)
-          (supports subpixel antialiased text 1)
</del><span class="cx">           (drawsContent 1)
</span><span class="cx">           (tile cache coverage 0, 0 1024 x 100)
</span><span class="cx">           (tile size 512 x 512)
</span><span class="lines">@@ -32,6 +28,16 @@
</span><span class="cx">           (top left tile 0, 0 tiles grid 2 x 1)
</span><span class="cx">           (in window 1)
</span><span class="cx">         )
</span><ins>+        (GraphicsLayer
+          (position 18.00 230.00)
+          (bounds 5000.00 100.00)
+          (usingTiledLayer 1)
+          (drawsContent 1)
+          (tile cache coverage 0, 0 1024 x 100)
+          (tile size 512 x 512)
+          (top left tile 0, 0 tiles grid 2 x 1)
+          (in window 1)
+        )
</ins><span class="cx">       )
</span><span class="cx">     )
</span><span class="cx">   )
</span></span></pre></div>
<a id="trunkLayoutTestscompositingcontentsformatsubpixelantialiasedtextenabledhtml"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/compositing/contents-format/subpixel-antialiased-text-enabled.html (213465 => 213466)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/compositing/contents-format/subpixel-antialiased-text-enabled.html        2017-03-06 21:44:20 UTC (rev 213465)
+++ trunk/LayoutTests/compositing/contents-format/subpixel-antialiased-text-enabled.html        2017-03-06 21:45:38 UTC (rev 213466)
</span><span class="lines">@@ -5,12 +5,13 @@
</span><span class="cx">     &lt;style&gt;
</span><span class="cx">         body {
</span><span class="cx">             height: 2000px;
</span><ins>+            -webkit-font-smoothing: subpixel-antialiased;
</ins><span class="cx">         }
</span><span class="cx">         
</span><span class="cx">         .box {
</span><span class="cx">             height: 100px;
</span><span class="cx">             width: 100px;
</span><del>-            background-color: blue;
</del><ins>+            background-color: rgba(0, 0, 128, 0.6);
</ins><span class="cx">             margin: 10px;
</span><span class="cx">         }
</span><span class="cx">         
</span><span class="lines">@@ -17,6 +18,10 @@
</span><span class="cx">         .composited {
</span><span class="cx">             transform: translateZ(0);
</span><span class="cx">         }
</span><ins>+
+        p {
+            line-height: 20px;
+        }
</ins><span class="cx">         
</span><span class="cx">         .tiled {
</span><span class="cx">             width: 5000px;
</span><span class="lines">@@ -30,20 +35,27 @@
</span><span class="cx"> 
</span><span class="cx">         function doAfterReload()
</span><span class="cx">         {
</span><del>-            if (window.internals)
-                document.getElementById('layers').innerText = internals.layerTreeAsText(document, internals.LAYER_TREE_INCLUDES_TILE_CACHES);
</del><ins>+            setTimeout(function() {
+                document.getElementById('become-tiled').classList.add('tiled');
+                setTimeout(function() {
+                    if (window.internals)
+                        document.getElementById('layers').innerText = internals.layerTreeAsText(document, internals.LAYER_TREE_INCLUDES_TILE_CACHES);
</ins><span class="cx"> 
</span><del>-            delete window.localStorage.stage;
</del><ins>+                    delete window.localStorage.stage;
</ins><span class="cx"> 
</span><del>-            if (window.testRunner)
-                testRunner.notifyDone();
</del><ins>+                    if (window.testRunner)
+                        testRunner.notifyDone();
+                }, 0);
+            }, 0);
</ins><span class="cx">         }
</span><span class="cx"> 
</span><span class="cx">         function doOnFirstLoad()
</span><span class="cx">         {
</span><span class="cx">             window.localStorage.stage = 1;
</span><del>-            if (window.internals)
</del><ins>+            if (window.internals) {
+                internals.setFontSmoothingEnabled(true);
</ins><span class="cx">                 internals.settings.setSubpixelAntialiasedLayerTextEnabled(true)
</span><ins>+            }
</ins><span class="cx"> 
</span><span class="cx">             // Reload so that the setting affects page tiles.
</span><span class="cx">             location.reload();
</span><span class="lines">@@ -69,6 +81,10 @@
</span><span class="cx">     Tiled layer
</span><span class="cx"> &lt;/div&gt;
</span><span class="cx"> 
</span><ins>+&lt;div id=&quot;become-tiled&quot; class=&quot;composited box&quot;&gt;
+    Become-tiled layer
+&lt;/div&gt;
+
</ins><span class="cx"> &lt;pre id=&quot;layers&quot;&gt;&lt;/pre&gt;
</span><span class="cx"> &lt;/body&gt;
</span><span class="cx"> &lt;/html&gt;
</span></span></pre></div>
<a id="trunkLayoutTestscompositingcontentsformatsubpixelantialiasedtextimagesexpectedtxt"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/compositing/contents-format/subpixel-antialiased-text-images-expected.txt (0 => 213466)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/compositing/contents-format/subpixel-antialiased-text-images-expected.txt                                (rev 0)
+++ trunk/LayoutTests/compositing/contents-format/subpixel-antialiased-text-images-expected.txt        2017-03-06 21:45:38 UTC (rev 213466)
</span><span class="lines">@@ -0,0 +1,61 @@
</span><ins>+ Image and some text   
+Image and some text child layer
+
+Image and some text with z-index
+
+Image and some text child composited
+(GraphicsLayer
+  (anchor 0.00 0.00)
+  (bounds 800.00 600.00)
+  (children 1
+    (GraphicsLayer
+      (bounds 800.00 600.00)
+      (contentsOpaque 1)
+      (children 7
+        (GraphicsLayer
+          (position 12.00 17.00)
+          (bounds 162.00 162.00)
+          (drawsContent 1)
+        )
+        (GraphicsLayer
+          (position 182.00 17.00)
+          (bounds 162.00 162.00)
+          (drawsContent 1)
+        )
+        (GraphicsLayer
+          (position 352.00 17.00)
+          (bounds 162.00 162.00)
+          (drawsContent 1)
+        )
+        (GraphicsLayer
+          (position 522.00 17.00)
+          (bounds 162.00 162.00)
+          (drawsContent 1)
+        )
+        (GraphicsLayer
+          (position 12.00 187.00)
+          (bounds 162.00 162.00)
+          (drawsContent 1)
+        )
+        (GraphicsLayer
+          (position 182.00 187.00)
+          (bounds 162.00 162.00)
+          (drawsContent 1)
+        )
+        (GraphicsLayer
+          (position 352.00 187.00)
+          (bounds 162.00 162.00)
+          (drawsContent 1)
+          (children 1
+            (GraphicsLayer
+              (position 27.00 101.00)
+              (bounds 108.00 60.00)
+              (drawsContent 1)
+            )
+          )
+        )
+      )
+    )
+  )
+)
+
</ins></span></pre></div>
<a id="trunkLayoutTestscompositingcontentsformatsubpixelantialiasedtextimageshtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/compositing/contents-format/subpixel-antialiased-text-images.html (0 => 213466)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/compositing/contents-format/subpixel-antialiased-text-images.html                                (rev 0)
+++ trunk/LayoutTests/compositing/contents-format/subpixel-antialiased-text-images.html        2017-03-06 21:45:38 UTC (rev 213466)
</span><span class="lines">@@ -0,0 +1,96 @@
</span><ins>+&lt;!DOCTYPE html&gt;
+
+&lt;html&gt;
+&lt;head&gt;
+    &lt;style&gt;
+        .container {
+            height: 150px;
+            width: 150px;
+            float: left;
+            position: relative;
+            border: 1px solid black;
+            padding: 20px;
+            margin: 10px;
+            box-sizing: border-box;
+            box-shadow: 0 0 4px rgba(0, 0, 0, 0.2);
+        }
+
+        .box {
+            position: relative;
+            height: 40px;
+            width: 100px;
+            background-color: rgba(0, 0, 128, 0.5);
+        }
+
+        p, div {
+            line-height: 20px;
+        }
+        
+        div &gt; div {
+            width: 100%;
+        }
+
+        .composited {
+            will-change: transform;
+        }
+
+        img {
+            width: 95%;
+        }
+    &lt;/style&gt;
+    &lt;script&gt;
+        if (window.testRunner)
+            testRunner.dumpAsText();
+
+        if (window.internals) {
+            internals.setFontSmoothingEnabled(true);
+            internals.settings.setSubpixelAntialiasedLayerTextEnabled(true)
+        }
+
+        function doTest()
+        {
+            if (window.internals)
+                document.getElementById('layers').innerText = internals.layerTreeAsText(document);
+        }
+
+        window.addEventListener('load', doTest, false);
+    &lt;/script&gt;
+&lt;/head&gt;
+&lt;body&gt;
+
+&lt;div class=&quot;composited container image&quot;&gt;
+    &lt;img src=&quot;../resources/thiswayup.png&quot;&gt;
+&lt;/div&gt;
+
+&lt;div class=&quot;composited container mixed&quot;&gt;
+    &lt;img src=&quot;../resources/thiswayup.png&quot;&gt;
+    &lt;span&gt;Image and some text&lt;/span&gt;
+&lt;/div&gt;
+
+&lt;div class=&quot;composited container svg-image&quot;&gt;
+    &lt;img src=&quot;../resources/circle.svg&quot;&gt;
+&lt;/div&gt;
+
+&lt;div class=&quot;composited container text-svg&quot;&gt;
+    &lt;img src=&quot;../resources/circle-with-text.svg&quot;&gt;
+&lt;/div&gt;
+
+&lt;div class=&quot;composited container mixed&quot;&gt;
+    &lt;img src=&quot;../resources/thiswayup.png&quot;&gt;
+    &lt;div style=&quot;position: relative;&quot;&gt;Image and some text child layer&lt;/div&gt;
+&lt;/div&gt;
+
+&lt;div class=&quot;composited container mixed&quot;&gt;
+    &lt;img src=&quot;../resources/thiswayup.png&quot;&gt;
+    &lt;div style=&quot;position: relative; z-index: 0&quot;&gt;Image and some text with z-index&lt;/div&gt;
+&lt;/div&gt;
+
+&lt;div class=&quot;composited container mixed&quot;&gt;
+    &lt;img src=&quot;../resources/thiswayup.png&quot;&gt;
+    &lt;div class=&quot;composited&quot;&gt;Image and some text child composited&lt;/div&gt;
+&lt;/div&gt;
+
+&lt;pre id=&quot;layers&quot;&gt;&lt;/pre&gt;
+
+&lt;/body&gt;
+&lt;/html&gt;
</ins></span></pre></div>
<a id="trunkLayoutTestscompositingcontentsformatsubpixelantialiasedtextvisibilityexpectedtxt"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/compositing/contents-format/subpixel-antialiased-text-visibility-expected.txt (0 => 213466)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/compositing/contents-format/subpixel-antialiased-text-visibility-expected.txt                                (rev 0)
+++ trunk/LayoutTests/compositing/contents-format/subpixel-antialiased-text-visibility-expected.txt        2017-03-06 21:45:38 UTC (rev 213466)
</span><span class="lines">@@ -0,0 +1,42 @@
</span><ins>+Visibility hidden ancestor with visible child
+
+
+
+Only visible text is antialiased
+
+This text is antialiased. There is a hidden smoothed child
+
+
+(GraphicsLayer
+  (anchor 0.00 0.00)
+  (bounds 800.00 600.00)
+  (children 1
+    (GraphicsLayer
+      (bounds 800.00 600.00)
+      (contentsOpaque 1)
+      (children 4
+        (GraphicsLayer
+          (position 12.00 17.00)
+          (bounds 162.00 162.00)
+          (drawsContent 1)
+        )
+        (GraphicsLayer
+          (position 182.00 17.00)
+          (bounds 162.00 162.00)
+          (drawsContent 1)
+        )
+        (GraphicsLayer
+          (position 352.00 17.00)
+          (bounds 162.00 162.00)
+          (drawsContent 1)
+        )
+        (GraphicsLayer
+          (position 522.00 17.00)
+          (bounds 162.00 162.00)
+          (drawsContent 1)
+        )
+      )
+    )
+  )
+)
+
</ins></span></pre></div>
<a id="trunkLayoutTestscompositingcontentsformatsubpixelantialiasedtextvisibilityhtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/compositing/contents-format/subpixel-antialiased-text-visibility.html (0 => 213466)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/compositing/contents-format/subpixel-antialiased-text-visibility.html                                (rev 0)
+++ trunk/LayoutTests/compositing/contents-format/subpixel-antialiased-text-visibility.html        2017-03-06 21:45:38 UTC (rev 213466)
</span><span class="lines">@@ -0,0 +1,91 @@
</span><ins>+&lt;!DOCTYPE html&gt;
+
+&lt;html&gt;
+&lt;head&gt;
+    &lt;style&gt;
+        .container {
+            height: 150px;
+            width: 150px;
+            float: left;
+            position: relative;
+            border: 1px solid black;
+            padding: 20px;
+            margin: 10px;
+            box-sizing: border-box;
+            box-shadow: 0 0 4px rgba(0, 0, 0, 0.2);
+        }
+
+        .box {
+            position: relative;
+            height: 40px;
+            width: 100px;
+            background-color: rgba(0, 0, 128, 0.5);
+        }
+
+        p {
+            line-height: 20px;
+        }
+
+        .composited {
+            will-change: transform;
+        }
+
+        .antialiased {
+            -webkit-font-smoothing: antialiased;
+        }
+
+        .smoothed {
+            -webkit-font-smoothing: subpixel-antialiased;
+        }
+    &lt;/style&gt;
+    &lt;script&gt;
+        if (window.testRunner)
+            testRunner.dumpAsText();
+
+        if (window.internals) {
+            internals.setFontSmoothingEnabled(true);
+            internals.settings.setSubpixelAntialiasedLayerTextEnabled(true)
+        }
+
+        function doTest()
+        {
+            if (window.internals)
+                document.getElementById('layers').innerText = internals.layerTreeAsText(document);
+        }
+
+        window.addEventListener('load', doTest, false);
+    &lt;/script&gt;
+&lt;/head&gt;
+&lt;body&gt;
+
+&lt;div class=&quot;composited container&quot; style=&quot;visibility:hidden&quot;&gt;
+    This text is hidden.
+    &lt;div style=&quot;position: relative; visibility: visible;&quot;&gt;
+        &lt;p&gt;Visibility hidden ancestor with visible child&lt;/p&gt;
+    &lt;/div&gt;
+&lt;/div&gt;
+
+&lt;div class=&quot;composited container&quot;&gt;
+    &lt;div style=&quot;position: relative; visibility: hidden;&quot;&gt;
+        &lt;p&gt;Hidden child with text&lt;/p&gt;
+    &lt;/div&gt;
+&lt;/div&gt;
+
+&lt;div class=&quot;composited container&quot; style=&quot;visibility:hidden&quot;&gt;
+    &lt;p class=&quot;smoothed&quot;&gt;This text is hidden.&lt;/p&gt;
+    &lt;div style=&quot;position: relative; visibility: visible;&quot;&gt;
+        &lt;p class=&quot;antialiased&quot;&gt;Only visible text is antialiased&lt;/p&gt;
+    &lt;/div&gt;
+&lt;/div&gt;
+
+&lt;div class=&quot;composited container&quot;&gt;
+    &lt;p class=&quot;antialiased&quot;&gt;This text is antialiased. There is a hidden smoothed child&lt;/p&gt;
+    &lt;div style=&quot;position: relative; visibility: hidden;&quot;&gt;
+        &lt;p class=&quot;smoothed&quot;&gt;This smoothed text is hidden&lt;/p&gt;
+    &lt;/div&gt;
+&lt;/div&gt;
+
+&lt;pre id=&quot;layers&quot;&gt;&lt;/pre&gt;
+
+&lt;/body&gt;
+&lt;/html&gt;
</ins></span></pre></div>
<a id="trunkLayoutTestscompositingresourcescirclewithtextsvg"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/compositing/resources/circle-with-text.svg (0 => 213466)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/compositing/resources/circle-with-text.svg                                (rev 0)
+++ trunk/LayoutTests/compositing/resources/circle-with-text.svg        2017-03-06 21:45:38 UTC (rev 213466)
</span><span class="lines">@@ -0,0 +1,4 @@
</span><ins>+&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;200&quot; height=&quot;200&quot;&gt;
+    &lt;circle cx=&quot;50%&quot; cy=&quot;50%&quot; r=&quot;80&quot; style=&quot;fill:blue;&quot; /&gt;
+    &lt;text x=&quot;20%&quot; y=&quot;50%&quot; fill=&quot;white&quot;&gt;Here is some text&lt;/text&gt;
+&lt;/svg&gt;
</ins></span></pre></div>
<a id="trunkLayoutTestscompositingresourcescirclesvg"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/compositing/resources/circle.svg (0 => 213466)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/compositing/resources/circle.svg                                (rev 0)
+++ trunk/LayoutTests/compositing/resources/circle.svg        2017-03-06 21:45:38 UTC (rev 213466)
</span><span class="lines">@@ -0,0 +1,3 @@
</span><ins>+&lt;svg xmlns='http://www.w3.org/2000/svg' width='200' height='200'&gt;
+    &lt;circle cx=&quot;50%&quot; cy=&quot;50%&quot; r=&quot;80&quot; style=&quot;fill:blue;&quot; /&gt;
+&lt;/svg&gt;
</ins></span></pre></div>
<a id="trunkLayoutTestsplatformmaccompositingcontentsformatsubpixelantialiasedtextconfigsantialiasingstyleexpectedtxt"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/platform/mac/compositing/contents-format/subpixel-antialiased-text-configs-antialiasing-style-expected.txt (0 => 213466)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/platform/mac/compositing/contents-format/subpixel-antialiased-text-configs-antialiasing-style-expected.txt                                (rev 0)
+++ trunk/LayoutTests/platform/mac/compositing/contents-format/subpixel-antialiased-text-configs-antialiasing-style-expected.txt        2017-03-06 21:45:38 UTC (rev 213466)
</span><span class="lines">@@ -0,0 +1,127 @@
</span><ins>+     
+Text here
+
+Antialiased text
+
+Smoothed text
+
+Antialised text
+Smoothed text
+
+Child composited layer
+
+Smoothed text
+
+Antialiased text
+
+Antialiased text
+
+Smoothed text
+
+Exceeds depth test antialiased
+
+Exceeds depth test smoothed
+
+(GraphicsLayer
+  (anchor 0.00 0.00)
+  (bounds 800.00 600.00)
+  (children 1
+    (GraphicsLayer
+      (bounds 800.00 600.00)
+      (contentsOpaque 1)
+      (children 12
+        (GraphicsLayer
+          (position 12.00 17.00)
+          (bounds 162.00 162.00)
+          (drawsContent 1)
+        )
+        (GraphicsLayer
+          (position 182.00 17.00)
+          (bounds 162.00 162.00)
+          (drawsContent 1)
+        )
+        (GraphicsLayer
+          (position 352.00 17.00)
+          (bounds 162.00 162.00)
+          (supports subpixel antialiased text 1)
+          (drawsContent 1)
+        )
+        (GraphicsLayer
+          (position 522.00 17.00)
+          (bounds 162.00 162.00)
+          (supports subpixel antialiased text 1)
+          (drawsContent 1)
+        )
+        (GraphicsLayer
+          (position 12.00 187.00)
+          (bounds 162.00 162.00)
+          (drawsContent 1)
+        )
+        (GraphicsLayer
+          (position 182.00 187.00)
+          (bounds 162.00 162.00)
+          (supports subpixel antialiased text 1)
+          (drawsContent 1)
+        )
+        (GraphicsLayer
+          (position 352.00 187.00)
+          (bounds 162.00 162.00)
+          (supports subpixel antialiased text 1)
+          (drawsContent 1)
+        )
+        (GraphicsLayer
+          (position 522.00 187.00)
+          (bounds 162.00 162.00)
+          (drawsContent 1)
+          (children 1
+            (GraphicsLayer
+              (position 27.00 43.00)
+              (bounds 108.00 60.00)
+              (supports subpixel antialiased text 1)
+              (drawsContent 1)
+            )
+          )
+        )
+        (GraphicsLayer
+          (position 12.00 357.00)
+          (bounds 162.00 162.00)
+          (drawsContent 1)
+          (children 1
+            (GraphicsLayer
+              (position 27.00 43.00)
+              (bounds 108.00 20.00)
+              (supports subpixel antialiased text 1)
+              (drawsContent 1)
+            )
+          )
+        )
+        (GraphicsLayer
+          (position 182.00 357.00)
+          (bounds 162.00 162.00)
+          (supports subpixel antialiased text 1)
+          (drawsContent 1)
+          (children 1
+            (GraphicsLayer
+              (position 27.00 43.00)
+              (bounds 108.00 20.00)
+              (drawsContent 1)
+            )
+          )
+        )
+        (GraphicsLayer
+          (position 352.00 357.00)
+          (bounds 162.00 162.00)
+          (supports subpixel antialiased text 1)
+          (drawsContent 1)
+        )
+        (GraphicsLayer
+          (position 522.00 357.00)
+          (bounds 162.00 162.00)
+          (supports subpixel antialiased text 1)
+          (drawsContent 1)
+        )
+      )
+    )
+  )
+)
+
</ins></span></pre></div>
<a id="trunkLayoutTestsplatformmaccompositingcontentsformatsubpixelantialiasedtextconfigsexpectedtxt"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/platform/mac/compositing/contents-format/subpixel-antialiased-text-configs-expected.txt (0 => 213466)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/platform/mac/compositing/contents-format/subpixel-antialiased-text-configs-expected.txt                                (rev 0)
+++ trunk/LayoutTests/platform/mac/compositing/contents-format/subpixel-antialiased-text-configs-expected.txt        2017-03-06 21:45:38 UTC (rev 213466)
</span><span class="lines">@@ -0,0 +1,114 @@
</span><ins>+      Solid background
+Text here
+
+Text here
+
+Negative z-index child
+And more content
+Child layer
+
+Child composited layer
+
+Child composited layer
+
+Text here.  
+(GraphicsLayer
+  (anchor 0.00 0.00)
+  (bounds 800.00 600.00)
+  (children 1
+    (GraphicsLayer
+      (bounds 800.00 600.00)
+      (contentsOpaque 1)
+      (children 11
+        (GraphicsLayer
+          (position 12.00 17.00)
+          (bounds 162.00 162.00)
+          (drawsContent 1)
+        )
+        (GraphicsLayer
+          (position 182.00 17.00)
+          (bounds 162.00 162.00)
+          (drawsContent 1)
+        )
+        (GraphicsLayer
+          (position 352.00 17.00)
+          (bounds 162.00 162.00)
+          (supports subpixel antialiased text 1)
+          (drawsContent 1)
+        )
+        (GraphicsLayer
+          (position 522.00 17.00)
+          (bounds 162.00 162.00)
+          (supports subpixel antialiased text 1)
+          (drawsContent 1)
+        )
+        (GraphicsLayer
+          (position 12.00 187.00)
+          (bounds 162.00 162.00)
+          (supports subpixel antialiased text 1)
+          (drawsContent 1)
+        )
+        (GraphicsLayer
+          (position 182.00 187.00)
+          (bounds 162.00 162.00)
+          (supports subpixel antialiased text 1)
+          (drawsContent 1)
+          (children 1
+            (GraphicsLayer
+              (position 27.00 79.00)
+              (bounds 100.00 40.00)
+              (supports subpixel antialiased text 1)
+              (drawsContent 1)
+            )
+          )
+        )
+        (GraphicsLayer
+          (position 352.00 187.00)
+          (bounds 162.00 162.00)
+          (supports subpixel antialiased text 1)
+          (drawsContent 1)
+        )
+        (GraphicsLayer
+          (position 522.00 187.00)
+          (bounds 162.00 162.00)
+          (drawsContent 1)
+          (children 1
+            (GraphicsLayer
+              (position 27.00 43.00)
+              (bounds 108.00 60.00)
+              (supports subpixel antialiased text 1)
+              (drawsContent 1)
+            )
+          )
+        )
+        (GraphicsLayer
+          (position 12.00 357.00)
+          (bounds 162.00 162.00)
+          (supports subpixel antialiased text 1)
+          (drawsContent 1)
+          (children 1
+            (GraphicsLayer
+              (position 27.00 43.00)
+              (bounds 108.00 60.00)
+              (supports subpixel antialiased text 1)
+              (drawsContent 1)
+            )
+          )
+        )
+        (GraphicsLayer
+          (position 182.00 357.00)
+          (bounds 162.00 162.00)
+          (supports subpixel antialiased text 1)
+          (drawsContent 1)
+        )
+        (GraphicsLayer
+          (position 352.00 357.00)
+          (bounds 162.00 162.00)
+          (supports subpixel antialiased text 1)
+          (drawsContent 1)
+        )
+      )
+    )
+  )
+)
+
</ins></span></pre></div>
<a id="trunkLayoutTestsplatformmaccompositingcontentsformatsubpixelantialiasedtextenabledexpectedtxtfromrev213465trunkLayoutTestscompositingcontentsformatsubpixelantialiasedtextenabledexpectedtxt"></a>
<div class="copfile"><h4>Copied: trunk/LayoutTests/platform/mac/compositing/contents-format/subpixel-antialiased-text-enabled-expected.txt (from rev 213465, trunk/LayoutTests/compositing/contents-format/subpixel-antialiased-text-enabled-expected.txt) (0 => 213466)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/platform/mac/compositing/contents-format/subpixel-antialiased-text-enabled-expected.txt                                (rev 0)
+++ trunk/LayoutTests/platform/mac/compositing/contents-format/subpixel-antialiased-text-enabled-expected.txt        2017-03-06 21:45:38 UTC (rev 213466)
</span><span class="lines">@@ -0,0 +1,48 @@
</span><ins>+Normal layer
+Tiled layer
+Become-tiled layer
+(GraphicsLayer
+  (anchor 0.00 0.00)
+  (bounds 5018.00 2018.00)
+  (children 1
+    (GraphicsLayer
+      (bounds 5018.00 2018.00)
+      (contentsOpaque 1)
+      (tile cache coverage 0, 0 1024 x 1024)
+      (tile size 512 x 512)
+      (top left tile 0, 0 tiles grid 2 x 2)
+      (in window 1)
+      (children 3
+        (GraphicsLayer
+          (position 18.00 10.00)
+          (bounds 100.00 100.00)
+          (supports subpixel antialiased text 1)
+          (drawsContent 1)
+        )
+        (GraphicsLayer
+          (position 18.00 120.00)
+          (bounds 5000.00 100.00)
+          (usingTiledLayer 1)
+          (supports subpixel antialiased text 1)
+          (drawsContent 1)
+          (tile cache coverage 0, 0 1024 x 100)
+          (tile size 512 x 512)
+          (top left tile 0, 0 tiles grid 2 x 1)
+          (in window 1)
+        )
+        (GraphicsLayer
+          (position 18.00 230.00)
+          (bounds 5000.00 100.00)
+          (usingTiledLayer 1)
+          (supports subpixel antialiased text 1)
+          (drawsContent 1)
+          (tile cache coverage 0, 0 1024 x 100)
+          (tile size 512 x 512)
+          (top left tile 0, 0 tiles grid 2 x 1)
+          (in window 1)
+        )
+      )
+    )
+  )
+)
+
</ins></span></pre></div>
<a id="trunkLayoutTestsplatformmaccompositingcontentsformatsubpixelantialiasedtextimagesexpectedtxt"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/platform/mac/compositing/contents-format/subpixel-antialiased-text-images-expected.txt (0 => 213466)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/platform/mac/compositing/contents-format/subpixel-antialiased-text-images-expected.txt                                (rev 0)
+++ trunk/LayoutTests/platform/mac/compositing/contents-format/subpixel-antialiased-text-images-expected.txt        2017-03-06 21:45:38 UTC (rev 213466)
</span><span class="lines">@@ -0,0 +1,67 @@
</span><ins>+ Image and some text   
+Image and some text child layer
+
+Image and some text with z-index
+
+Image and some text child composited
+(GraphicsLayer
+  (anchor 0.00 0.00)
+  (bounds 800.00 600.00)
+  (children 1
+    (GraphicsLayer
+      (bounds 800.00 600.00)
+      (contentsOpaque 1)
+      (children 7
+        (GraphicsLayer
+          (position 12.00 17.00)
+          (bounds 162.00 162.00)
+          (drawsContent 1)
+        )
+        (GraphicsLayer
+          (position 182.00 17.00)
+          (bounds 162.00 162.00)
+          (supports subpixel antialiased text 1)
+          (drawsContent 1)
+        )
+        (GraphicsLayer
+          (position 352.00 17.00)
+          (bounds 162.00 162.00)
+          (supports subpixel antialiased text 1)
+          (drawsContent 1)
+        )
+        (GraphicsLayer
+          (position 522.00 17.00)
+          (bounds 162.00 162.00)
+          (supports subpixel antialiased text 1)
+          (drawsContent 1)
+        )
+        (GraphicsLayer
+          (position 12.00 187.00)
+          (bounds 162.00 162.00)
+          (supports subpixel antialiased text 1)
+          (drawsContent 1)
+        )
+        (GraphicsLayer
+          (position 182.00 187.00)
+          (bounds 162.00 162.00)
+          (supports subpixel antialiased text 1)
+          (drawsContent 1)
+        )
+        (GraphicsLayer
+          (position 352.00 187.00)
+          (bounds 162.00 162.00)
+          (drawsContent 1)
+          (children 1
+            (GraphicsLayer
+              (position 27.00 101.00)
+              (bounds 108.00 60.00)
+              (supports subpixel antialiased text 1)
+              (drawsContent 1)
+            )
+          )
+        )
+      )
+    )
+  )
+)
+
</ins></span></pre></div>
<a id="trunkLayoutTestsplatformmaccompositingcontentsformatsubpixelantialiasedtextvisibilityexpectedtxt"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/platform/mac/compositing/contents-format/subpixel-antialiased-text-visibility-expected.txt (0 => 213466)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/platform/mac/compositing/contents-format/subpixel-antialiased-text-visibility-expected.txt                                (rev 0)
+++ trunk/LayoutTests/platform/mac/compositing/contents-format/subpixel-antialiased-text-visibility-expected.txt        2017-03-06 21:45:38 UTC (rev 213466)
</span><span class="lines">@@ -0,0 +1,43 @@
</span><ins>+Visibility hidden ancestor with visible child
+
+
+
+Only visible text is antialiased
+
+This text is antialiased. There is a hidden smoothed child
+
+
+(GraphicsLayer
+  (anchor 0.00 0.00)
+  (bounds 800.00 600.00)
+  (children 1
+    (GraphicsLayer
+      (bounds 800.00 600.00)
+      (contentsOpaque 1)
+      (children 4
+        (GraphicsLayer
+          (position 12.00 17.00)
+          (bounds 162.00 162.00)
+          (supports subpixel antialiased text 1)
+          (drawsContent 1)
+        )
+        (GraphicsLayer
+          (position 182.00 17.00)
+          (bounds 162.00 162.00)
+          (drawsContent 1)
+        )
+        (GraphicsLayer
+          (position 352.00 17.00)
+          (bounds 162.00 162.00)
+          (drawsContent 1)
+        )
+        (GraphicsLayer
+          (position 522.00 17.00)
+          (bounds 162.00 162.00)
+          (drawsContent 1)
+        )
+      )
+    )
+  )
+)
+
</ins></span></pre></div>
<a id="trunkLayoutTestsplatformmacwk1compositingcontentsformatsubpixelantialiasedtextenabledexpectedtxt"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/platform/mac-wk1/compositing/contents-format/subpixel-antialiased-text-enabled-expected.txt (213465 => 213466)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/platform/mac-wk1/compositing/contents-format/subpixel-antialiased-text-enabled-expected.txt        2017-03-06 21:44:20 UTC (rev 213465)
+++ trunk/LayoutTests/platform/mac-wk1/compositing/contents-format/subpixel-antialiased-text-enabled-expected.txt        2017-03-06 21:45:38 UTC (rev 213466)
</span><span class="lines">@@ -1,5 +1,6 @@
</span><span class="cx"> Normal layer
</span><span class="cx"> Tiled layer
</span><ins>+Become-tiled layer
</ins><span class="cx"> (GraphicsLayer
</span><span class="cx">   (anchor 0.00 0.00)
</span><span class="cx">   (bounds 5018.00 2018.00)
</span><span class="lines">@@ -7,12 +8,10 @@
</span><span class="cx">     (GraphicsLayer
</span><span class="cx">       (bounds 5018.00 2018.00)
</span><span class="cx">       (contentsOpaque 1)
</span><del>-      (supports subpixel antialiased text 1)
-      (children 2
</del><ins>+      (children 3
</ins><span class="cx">         (GraphicsLayer
</span><span class="cx">           (position 18.00 10.00)
</span><span class="cx">           (bounds 100.00 100.00)
</span><del>-          (contentsOpaque 1)
</del><span class="cx">           (supports subpixel antialiased text 1)
</span><span class="cx">           (drawsContent 1)
</span><span class="cx">         )
</span><span class="lines">@@ -20,7 +19,6 @@
</span><span class="cx">           (position 18.00 120.00)
</span><span class="cx">           (bounds 5000.00 100.00)
</span><span class="cx">           (usingTiledLayer 1)
</span><del>-          (contentsOpaque 1)
</del><span class="cx">           (supports subpixel antialiased text 1)
</span><span class="cx">           (drawsContent 1)
</span><span class="cx">           (tile cache coverage 0, 0 1024 x 100)
</span><span class="lines">@@ -28,6 +26,17 @@
</span><span class="cx">           (top left tile 0, 0 tiles grid 2 x 1)
</span><span class="cx">           (in window 1)
</span><span class="cx">         )
</span><ins>+        (GraphicsLayer
+          (position 18.00 230.00)
+          (bounds 5000.00 100.00)
+          (usingTiledLayer 1)
+          (supports subpixel antialiased text 1)
+          (drawsContent 1)
+          (tile cache coverage 0, 0 1024 x 100)
+          (tile size 512 x 512)
+          (top left tile 0, 0 tiles grid 2 x 1)
+          (in window 1)
+        )
</ins><span class="cx">       )
</span><span class="cx">     )
</span><span class="cx">   )
</span></span></pre></div>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (213465 => 213466)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog        2017-03-06 21:44:20 UTC (rev 213465)
+++ trunk/Source/WebCore/ChangeLog        2017-03-06 21:45:38 UTC (rev 213466)
</span><span class="lines">@@ -1,3 +1,92 @@
</span><ins>+2017-03-06  Simon Fraser  &lt;simon.fraser@apple.com&gt;
+
+        Only use layer backing store which supports subpixel antialiased text if we know subpixel antialiased will be painted into it
+        https://bugs.webkit.org/show_bug.cgi?id=169191
+
+        Reviewed by Zalan Bujtas.
+
+        Instead of unconditionally calling setSupportsSubpixelAntialiasedText() on GraphicsLayers created
+        by RenderLayerBacking, only do so when we know (or suspect) that a layer contains smoothed text.
+        
+        This is done by enhancing RenderLayer::isVisuallyNonEmpty() and RenderLayer::hasNonEmptyChildRenderers()
+        to take a PaintedContentRequest parameter, which allows the caller to specify what qualities of
+        the layer contents it is interested in. Most of the time, this is just any painted content, but on
+        platforms where GraphicsLayer::supportsSubpixelAntialiasedLayerText() returns true, the query also
+        asks about whether the layer will contain subpixel-antialiased text. In this case, it can't early
+        return as soon as painted content is found; it must keep iterating renderers while all the query 
+        requests are unsatisfied, or until it hits depth or sibling limits. If a limit is hit, we take the
+        same path of assuming there is subpixel-antialiased text (via the &quot;Undetermined&quot; state).
+
+        RenderLayerBacking also makes use of PaintedContentRequest during its non-composited child layer walk.
+
+        To offset the additional cost of this tree walking, RenderLayerBacking now caches information about its
+        painted content for the duration of a single update via PaintedContentsInfo, so we no longer call
+        isDirectlyCompositedImage() and isSimpleContainerCompositingLayer() multiple times per backing per update.
+        The traversal code here too now has to continue until all necessary states in the request have been computed.
+        
+        Add some functions to RenderImage so that we know if it's showing the alt text or has a non-bitmap image
+        (which may contain text).
+        
+        Subpixel-antialiased (&quot;smoothed&quot;) text is disabled by DRT and WTR by default, so we need Internals API to enable it.
+        
+        Platforms now express their support for subpixel-antialiased text via GraphicsLayer::supportsSubpixelAntialiasedLayerText()
+        which only returns true on Mac.
+
+        Tests: compositing/contents-format/subpixel-antialiased-text-configs-antialiasing-style.html
+               compositing/contents-format/subpixel-antialiased-text-configs.html
+               compositing/contents-format/subpixel-antialiased-text-images.html
+               compositing/contents-format/subpixel-antialiased-text-visibility.html
+
+        * platform/graphics/GraphicsLayer.cpp:
+        (WebCore::GraphicsLayer::supportsSubpixelAntialiasedLayerText):
+        * platform/graphics/GraphicsLayer.h:
+        * platform/graphics/ca/GraphicsLayerCA.cpp:
+        (WebCore::GraphicsLayer::supportsSubpixelAntialiasedLayerText):
+        (WebCore::GraphicsLayerCA::changeLayerTypeTo):
+        * rendering/RenderImage.cpp:
+        (WebCore::RenderImage::isShowingMissingOrImageError):
+        (WebCore::RenderImage::isShowingAltText):
+        (WebCore::RenderImage::hasNonBitmapImage):
+        * rendering/RenderImage.h:
+        * rendering/RenderLayer.cpp:
+        (WebCore::RenderLayer::calculateClipRects):
+        * rendering/RenderLayer.h:
+        * rendering/RenderLayerBacking.cpp:
+        (WebCore::PaintedContentsInfo::PaintedContentsInfo):
+        (WebCore::PaintedContentsInfo::setWantsSubpixelAntialiasedTextState):
+        (WebCore::PaintedContentsInfo::paintsBoxDecorations):
+        (WebCore::PaintedContentsInfo::paintsContent):
+        (WebCore::PaintedContentsInfo::paintsSubpixelAntialiasedText):
+        (WebCore::PaintedContentsInfo::isSimpleContainer):
+        (WebCore::PaintedContentsInfo::isDirectlyCompositedImage):
+        (WebCore::PaintedContentsInfo::paintsBoxDecorationsDetermination):
+        (WebCore::PaintedContentsInfo::paintsContentDetermination):
+        (WebCore::PaintedContentsInfo::paintsSubpixelAntialiasedTextDetermination):
+        (WebCore::PaintedContentsInfo::contentsTypeDetermination):
+        (WebCore::RenderLayerBacking::createGraphicsLayer):
+        (WebCore::RenderLayerBacking::updateConfiguration):
+        (WebCore::RenderLayerBacking::computeParentGraphicsLayerRect):
+        (WebCore::RenderLayerBacking::updateAfterDescendants):
+        (WebCore::RenderLayerBacking::updateDirectlyCompositedBoxDecorations):
+        (WebCore::RenderLayerBacking::updateDrawsContent):
+        (WebCore::RenderLayerBacking::updateDirectlyCompositedBackgroundColor):
+        (WebCore::RenderLayerBacking::updateDirectlyCompositedBackgroundImage):
+        (WebCore::RenderLayerBacking::paintsContent):
+        (WebCore::RenderLayerBacking::isSimpleContainerCompositingLayer):
+        (WebCore::RenderLayerBacking::isPaintDestinationForDescendantLayers):
+        (WebCore::RenderLayerBacking::hasVisibleNonCompositedDescendants):
+        (WebCore::RenderLayerBacking::containsPaintedContent):
+        (WebCore::RenderLayerBacking::contentChanged):
+        (WebCore::RenderLayerBacking::updateImageContents):
+        (WebCore::RenderLayerBacking::paintsChildRenderers): Deleted.
+        * rendering/RenderLayerBacking.h:
+        * rendering/RenderLayerCompositor.cpp:
+        (WebCore::RenderLayerCompositor::logLayerInfo):
+        * testing/Internals.cpp:
+        (WebCore::Internals::setFontSmoothingEnabled):
+        * testing/Internals.h:
+        * testing/Internals.idl:
+
</ins><span class="cx"> 2017-03-06  Myles C. Maxfield  &lt;mmaxfield@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         Expand font-weight and font-stretch to take any number
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformgraphicsGraphicsLayercpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/graphics/GraphicsLayer.cpp (213465 => 213466)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/graphics/GraphicsLayer.cpp        2017-03-06 21:44:20 UTC (rev 213465)
+++ trunk/Source/WebCore/platform/graphics/GraphicsLayer.cpp        2017-03-06 21:45:38 UTC (rev 213466)
</span><span class="lines">@@ -95,6 +95,11 @@
</span><span class="cx">     return false;
</span><span class="cx"> #endif
</span><span class="cx"> }
</span><ins>+
+bool GraphicsLayer::supportsSubpixelAntialiasedLayerText()
+{
+    return false;
+}
</ins><span class="cx"> #endif
</span><span class="cx"> 
</span><span class="cx"> #if !USE(COORDINATED_GRAPHICS)
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformgraphicsGraphicsLayerh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/graphics/GraphicsLayer.h (213465 => 213466)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/graphics/GraphicsLayer.h        2017-03-06 21:44:20 UTC (rev 213465)
+++ trunk/Source/WebCore/platform/graphics/GraphicsLayer.h        2017-03-06 21:45:38 UTC (rev 213466)
</span><span class="lines">@@ -554,6 +554,7 @@
</span><span class="cx">     static bool supportsBackgroundColorContent();
</span><span class="cx">     static bool supportsLayerType(Type);
</span><span class="cx">     static bool supportsContentsTiling();
</span><ins>+    static bool supportsSubpixelAntialiasedLayerText();
</ins><span class="cx"> 
</span><span class="cx">     void updateDebugIndicators();
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformgraphicscaGraphicsLayerCAcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/graphics/ca/GraphicsLayerCA.cpp (213465 => 213466)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/graphics/ca/GraphicsLayerCA.cpp        2017-03-06 21:44:20 UTC (rev 213465)
+++ trunk/Source/WebCore/platform/graphics/ca/GraphicsLayerCA.cpp        2017-03-06 21:45:38 UTC (rev 213466)
</span><span class="lines">@@ -317,6 +317,15 @@
</span><span class="cx">     return true;
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+bool GraphicsLayer::supportsSubpixelAntialiasedLayerText()
+{
+#if PLATFORM(MAC)
+    return true;
+#else
+    return false;
+#endif
+}
+
</ins><span class="cx"> std::unique_ptr&lt;GraphicsLayer&gt; GraphicsLayer::create(GraphicsLayerFactory* factory, GraphicsLayerClient&amp; client, Type layerType)
</span><span class="cx"> {
</span><span class="cx">     std::unique_ptr&lt;GraphicsLayer&gt; graphicsLayer;
</span><span class="lines">@@ -3616,6 +3625,7 @@
</span><span class="cx">         | BackgroundColorChanged
</span><span class="cx">         | ContentsScaleChanged
</span><span class="cx">         | AcceleratesDrawingChanged
</span><ins>+        | SupportsSubpixelAntialiasedTextChanged
</ins><span class="cx">         | FiltersChanged
</span><span class="cx">         | BackdropFiltersChanged
</span><span class="cx">         | MaskLayerChanged
</span></span></pre></div>
<a id="trunkSourceWebCorerenderingRenderImagecpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/rendering/RenderImage.cpp (213465 => 213466)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/rendering/RenderImage.cpp        2017-03-06 21:44:20 UTC (rev 213465)
+++ trunk/Source/WebCore/rendering/RenderImage.cpp        2017-03-06 21:45:38 UTC (rev 213466)
</span><span class="lines">@@ -349,6 +349,25 @@
</span><span class="cx">     }
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+bool RenderImage::isShowingMissingOrImageError() const
+{
+    return !imageResource().hasImage() || imageResource().errorOccurred();
+}
+
+bool RenderImage::isShowingAltText() const
+{
+    return isShowingMissingOrImageError() &amp;&amp; !m_altText.isEmpty();
+}
+
+bool RenderImage::hasNonBitmapImage() const
+{
+    if (!imageResource().hasImage())
+        return false;
+
+    Image* image = cachedImage()-&gt;imageForRenderer(this);
+    return image &amp;&amp; !is&lt;BitmapImage&gt;(image);
+}
+
</ins><span class="cx"> void RenderImage::paintReplaced(PaintInfo&amp; paintInfo, const LayoutPoint&amp; paintOffset)
</span><span class="cx"> {
</span><span class="cx">     LayoutSize contentSize = this-&gt;contentSize();
</span></span></pre></div>
<a id="trunkSourceWebCorerenderingRenderImageh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/rendering/RenderImage.h (213465 => 213466)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/rendering/RenderImage.h        2017-03-06 21:44:20 UTC (rev 213465)
+++ trunk/Source/WebCore/rendering/RenderImage.h        2017-03-06 21:45:38 UTC (rev 213466)
</span><span class="lines">@@ -69,7 +69,12 @@
</span><span class="cx">     float imageDevicePixelRatio() const { return m_imageDevicePixelRatio; }
</span><span class="cx"> 
</span><span class="cx">     void setHasShadowControls(bool hasShadowControls) { m_hasShadowControls = hasShadowControls; }
</span><ins>+    
+    bool isShowingMissingOrImageError() const;
+    bool isShowingAltText() const;
</ins><span class="cx"> 
</span><ins>+    bool hasNonBitmapImage() const;
+
</ins><span class="cx"> protected:
</span><span class="cx">     bool needsPreferredWidthsRecalculation() const final;
</span><span class="cx">     RenderBox* embeddedContentBox() const final;
</span></span></pre></div>
<a id="trunkSourceWebCorerenderingRenderLayercpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/rendering/RenderLayer.cpp (213465 => 213466)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/rendering/RenderLayer.cpp        2017-03-06 21:44:20 UTC (rev 213465)
+++ trunk/Source/WebCore/rendering/RenderLayer.cpp        2017-03-06 21:45:38 UTC (rev 213466)
</span><span class="lines">@@ -89,6 +89,7 @@
</span><span class="cx"> #include &quot;RenderFlexibleBox.h&quot;
</span><span class="cx"> #include &quot;RenderFlowThread.h&quot;
</span><span class="cx"> #include &quot;RenderGeometryMap.h&quot;
</span><ins>+#include &quot;RenderImage.h&quot;
</ins><span class="cx"> #include &quot;RenderInline.h&quot;
</span><span class="cx"> #include &quot;RenderIterator.h&quot;
</span><span class="cx"> #include &quot;RenderLayerBacking.h&quot;
</span><span class="lines">@@ -6579,19 +6580,29 @@
</span><span class="cx">     return renderer.hasVisibleBoxDecorations() || renderer.style().hasOutline();
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+static bool styleHasSmoothingTextMode(const RenderStyle&amp; style)
+{
+    FontSmoothingMode smoothingMode = style.fontDescription().fontSmoothing();
+    return smoothingMode == AutoSmoothing || smoothingMode == SubpixelAntialiased;
+}
+
</ins><span class="cx"> // Constrain the depth and breadth of the search for performance.
</span><span class="cx"> static const int maxDescendentDepth = 3;
</span><span class="cx"> static const int maxSiblingCount = 20;
</span><span class="cx"> 
</span><del>-static bool hasPaintingNonLayerDescendants(const RenderElement&amp; renderer, int depth)
</del><ins>+static void determineNonLayerDescendantsPaintedContent(const RenderElement&amp; renderer, int depth, RenderLayer::PaintedContentRequest&amp; request)
</ins><span class="cx"> {
</span><del>-    if (depth &gt; maxDescendentDepth)
-        return true;
</del><ins>+    if (depth &gt; maxDescendentDepth) {
+        request.makeStatesUndetermined();
+        return;
+    }
</ins><span class="cx">     
</span><span class="cx">     int siblingCount = 0;
</span><span class="cx">     for (const auto&amp; child : childrenOfType&lt;RenderObject&gt;(renderer)) {
</span><del>-        if (++siblingCount &gt; maxSiblingCount)
-            return true;
</del><ins>+        if (++siblingCount &gt; maxSiblingCount) {
+            request.makeStatesUndetermined();
+            return;
+        }
</ins><span class="cx"> 
</span><span class="cx">         if (is&lt;RenderText&gt;(child)) {
</span><span class="cx">             const auto&amp; renderText = downcast&lt;RenderText&gt;(child);
</span><span class="lines">@@ -6599,10 +6610,17 @@
</span><span class="cx">                 continue;
</span><span class="cx"> 
</span><span class="cx">             if (renderer.style().userSelect() != SELECT_NONE)
</span><del>-                return true;
</del><ins>+                request.setHasPaintedContent();
</ins><span class="cx"> 
</span><del>-            if (!renderText.text()-&gt;containsOnlyWhitespace())
-                return true;
</del><ins>+            if (!renderText.text()-&gt;containsOnlyWhitespace()) {
+                request.setHasPaintedContent();
+
+                if (request.needToDetermineSubpixelAntialiasedTextState() &amp;&amp; styleHasSmoothingTextMode(child.style()))
+                    request.setHasSubpixelAntialiasedText();
+            }
+
+            if (request.isSatisfied())
+                return;
</ins><span class="cx">         }
</span><span class="cx">         
</span><span class="cx">         if (!is&lt;RenderElement&gt;(child))
</span><span class="lines">@@ -6613,22 +6631,36 @@
</span><span class="cx">         if (is&lt;RenderLayerModelObject&gt;(renderElementChild) &amp;&amp; downcast&lt;RenderLayerModelObject&gt;(renderElementChild).hasSelfPaintingLayer())
</span><span class="cx">             continue;
</span><span class="cx"> 
</span><del>-        if (hasVisibleBoxDecorationsOrBackground(renderElementChild))
-            return true;
</del><ins>+        if (hasVisibleBoxDecorationsOrBackground(renderElementChild)) {
+            request.setHasPaintedContent();
+            if (request.isSatisfied())
+                return;
+        }
</ins><span class="cx">         
</span><del>-        if (is&lt;RenderReplaced&gt;(renderElementChild))
-            return true;
</del><ins>+        if (is&lt;RenderReplaced&gt;(renderElementChild)) {
+            request.setHasPaintedContent();
</ins><span class="cx"> 
</span><del>-        if (hasPaintingNonLayerDescendants(renderElementChild, depth + 1))
-            return true;
</del><ins>+            if (is&lt;RenderImage&gt;(renderElementChild) &amp;&amp; request.needToDetermineSubpixelAntialiasedTextState()) {
+                auto&amp; imageRenderer = downcast&lt;RenderImage&gt;(renderElementChild);
+                // May draw text if showing alt text, or image is an SVG image or PDF image.
+                if ((imageRenderer.isShowingAltText() || imageRenderer.hasNonBitmapImage()) &amp;&amp; styleHasSmoothingTextMode(child.style()))
+                    request.setHasSubpixelAntialiasedText();
+            }
+
+            if (request.isSatisfied())
+                return;
+        }
+
+        determineNonLayerDescendantsPaintedContent(renderElementChild, depth + 1, request);
+        if (request.isSatisfied())
+            return;
</ins><span class="cx">     }
</span><del>-
-    return false;
</del><span class="cx"> }
</span><span class="cx"> 
</span><del>-bool RenderLayer::hasNonEmptyChildRenderers() const
</del><ins>+bool RenderLayer::hasNonEmptyChildRenderers(PaintedContentRequest&amp; request) const
</ins><span class="cx"> {
</span><del>-    return hasPaintingNonLayerDescendants(renderer(), 0);
</del><ins>+    determineNonLayerDescendantsPaintedContent(renderer(), 0, request);
+    return request.probablyHasPaintedContent();
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> bool RenderLayer::hasVisibleBoxDecorationsOrBackground() const
</span><span class="lines">@@ -6644,7 +6676,7 @@
</span><span class="cx">     return hasVisibleBoxDecorationsOrBackground() || hasOverflowControls();
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-bool RenderLayer::isVisuallyNonEmpty() const
</del><ins>+bool RenderLayer::isVisuallyNonEmpty(PaintedContentRequest* request) const
</ins><span class="cx"> {
</span><span class="cx">     ASSERT(!m_visibleDescendantStatusDirty);
</span><span class="cx"> 
</span><span class="lines">@@ -6651,16 +6683,22 @@
</span><span class="cx">     if (!hasVisibleContent() || !renderer().style().opacity())
</span><span class="cx">         return false;
</span><span class="cx"> 
</span><del>-    if (renderer().isRenderReplaced() || hasOverflowControls())
</del><ins>+    if (renderer().isRenderReplaced() || hasOverflowControls()) {
+        if (request)
+            request-&gt;setHasPaintedContent();
</ins><span class="cx">         return true;
</span><ins>+    }
</ins><span class="cx"> 
</span><del>-    if (hasVisibleBoxDecorationsOrBackground())
</del><ins>+    if (hasVisibleBoxDecorationsOrBackground()) {
+        if (request)
+            request-&gt;setHasPaintedContent();
</ins><span class="cx">         return true;
</span><ins>+    }
</ins><span class="cx">     
</span><del>-    if (hasNonEmptyChildRenderers())
-        return true;
-
-    return false;
</del><ins>+    PaintedContentRequest localRequest;
+    if (!request)
+        request = &amp;localRequest;
+    return hasNonEmptyChildRenderers(*request);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void RenderLayer::updateStackingContextsAfterStyleChange(const RenderStyle* oldStyle)
</span></span></pre></div>
<a id="trunkSourceWebCorerenderingRenderLayerh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/rendering/RenderLayer.h (213465 => 213466)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/rendering/RenderLayer.h        2017-03-06 21:44:20 UTC (rev 213465)
+++ trunk/Source/WebCore/rendering/RenderLayer.h        2017-03-06 21:45:38 UTC (rev 213466)
</span><span class="lines">@@ -109,6 +109,14 @@
</span><span class="cx"> };
</span><span class="cx"> typedef unsigned LayerScrollCoordinationRoles;
</span><span class="cx"> 
</span><ins>+enum class RequestState {
+    Unknown,
+    DontCare,
+    False,
+    True,
+    Undetermined
+};
+
</ins><span class="cx"> class RenderLayer final : public ScrollableArea {
</span><span class="cx">     WTF_MAKE_FAST_ALLOCATED;
</span><span class="cx"> public:
</span><span class="lines">@@ -388,10 +396,36 @@
</span><span class="cx"> 
</span><span class="cx">     bool hasVisibleBoxDecorationsOrBackground() const;
</span><span class="cx">     bool hasVisibleBoxDecorations() const;
</span><ins>+
+    struct PaintedContentRequest {
+        void makeStatesUndetermined()
+        {
+            if (hasPaintedContent == RequestState::Unknown)
+                hasPaintedContent = RequestState::Undetermined;
+
+            if (hasSubpixelAntialiasedText == RequestState::Unknown)
+                hasSubpixelAntialiasedText = RequestState::Undetermined;
+        }
+
+        void setHasPaintedContent() { hasPaintedContent = RequestState::True; }
+        void setHasSubpixelAntialiasedText() { hasSubpixelAntialiasedText = RequestState::True; }
+
+        bool needToDeterminePaintedContentState() const { return hasPaintedContent == RequestState::Unknown; }
+        bool needToDetermineSubpixelAntialiasedTextState() const { return hasSubpixelAntialiasedText == RequestState::Unknown; }
+
+        bool probablyHasPaintedContent() const { return hasPaintedContent == RequestState::True || hasPaintedContent == RequestState::Undetermined; }
+        bool probablyHasSubpixelAntialiasedText() const { return hasSubpixelAntialiasedText == RequestState::True || hasSubpixelAntialiasedText == RequestState::Undetermined; }
+        
+        bool isSatisfied() const { return hasPaintedContent != RequestState::Unknown &amp;&amp; hasSubpixelAntialiasedText != RequestState::Unknown; }
+
+        RequestState hasPaintedContent { RequestState::Unknown };
+        RequestState hasSubpixelAntialiasedText { RequestState::DontCare };
+    };
+
</ins><span class="cx">     // Returns true if this layer has visible content (ignoring any child layers).
</span><del>-    bool isVisuallyNonEmpty() const;
</del><ins>+    bool isVisuallyNonEmpty(PaintedContentRequest* = nullptr) const;
</ins><span class="cx">     // True if this layer container renderers that paint.
</span><del>-    bool hasNonEmptyChildRenderers() const;
</del><ins>+    bool hasNonEmptyChildRenderers(PaintedContentRequest&amp;) const;
</ins><span class="cx"> 
</span><span class="cx">     // FIXME: We should ASSERT(!m_hasSelfPaintingLayerDescendantDirty); here but we hit the same bugs as visible content above.
</span><span class="cx">     // Part of the issue is with subtree relayout: we don't check if our ancestors have some descendant flags dirty, missing some updates.
</span></span></pre></div>
<a id="trunkSourceWebCorerenderingRenderLayerBackingcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/rendering/RenderLayerBacking.cpp (213465 => 213466)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/rendering/RenderLayerBacking.cpp        2017-03-06 21:44:20 UTC (rev 213465)
+++ trunk/Source/WebCore/rendering/RenderLayerBacking.cpp        2017-03-06 21:45:38 UTC (rev 213466)
</span><span class="lines">@@ -91,6 +91,118 @@
</span><span class="cx"> #endif
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+// This acts as a cache of what we know about what is painting into this RenderLayerBacking.
+class PaintedContentsInfo {
+public:
+    enum class ContentsTypeDetermination {
+        Unknown,
+        SimpleContainer,
+        DirectlyCompositedImage,
+        Painted
+    };
+
+    PaintedContentsInfo(RenderLayerBacking&amp; inBacking)
+        : m_backing(inBacking)
+    {
+    }
+    
+    void setWantsSubpixelAntialiasedTextState(bool wantsSubpixelAntialiasedTextState)
+    {
+        m_subpixelAntialiasedText = wantsSubpixelAntialiasedTextState ? RequestState::Unknown : RequestState::DontCare;
+    }
+
+    RequestState paintsBoxDecorationsDetermination();
+    bool paintsBoxDecorations()
+    {
+        RequestState state = paintsBoxDecorationsDetermination();
+        return state == RequestState::True || state == RequestState::Undetermined;
+    }
+
+    RequestState paintsContentDetermination();
+    bool paintsContent()
+    {
+        RequestState state = paintsContentDetermination();
+        return state == RequestState::True || state == RequestState::Undetermined;
+    }
+
+    RequestState paintsSubpixelAntialiasedTextDetermination();
+    bool paintsSubpixelAntialiasedText()
+    {
+        RequestState state = paintsSubpixelAntialiasedTextDetermination();
+        return state == RequestState::True || state == RequestState::Undetermined;
+    }
+
+    ContentsTypeDetermination contentsTypeDetermination();
+    bool isSimpleContainer()
+    {
+        return contentsTypeDetermination() == ContentsTypeDetermination::SimpleContainer;
+    }
+
+    bool isDirectlyCompositedImage()
+    {
+        return contentsTypeDetermination() == ContentsTypeDetermination::DirectlyCompositedImage;
+    }
+
+    RenderLayerBacking&amp; m_backing;
+    RequestState m_boxDecorations { RequestState::Unknown };
+    RequestState m_content { RequestState::Unknown };
+    RequestState m_subpixelAntialiasedText { RequestState::DontCare };
+
+    ContentsTypeDetermination m_contentsType { ContentsTypeDetermination::Unknown };
+};
+
+RequestState PaintedContentsInfo::paintsBoxDecorationsDetermination()
+{
+    if (m_boxDecorations != RequestState::Unknown)
+        return m_boxDecorations;
+
+    m_boxDecorations = m_backing.paintsBoxDecorations() ? RequestState::True : RequestState::False;
+    return m_boxDecorations;
+}
+
+RequestState PaintedContentsInfo::paintsContentDetermination()
+{
+    if (m_content != RequestState::Unknown &amp;&amp; m_subpixelAntialiasedText != RequestState::Unknown)
+        return m_content;
+
+    RenderLayer::PaintedContentRequest contentRequest;
+    if (m_subpixelAntialiasedText == RequestState::Unknown)
+        contentRequest.hasSubpixelAntialiasedText = RequestState::Unknown;
+
+    m_content = m_backing.paintsContent(contentRequest) ? RequestState::True : RequestState::False;
+
+    if (m_subpixelAntialiasedText == RequestState::Unknown)
+        m_subpixelAntialiasedText = contentRequest.hasSubpixelAntialiasedText;
+
+    return m_content;
+}
+
+RequestState PaintedContentsInfo::paintsSubpixelAntialiasedTextDetermination()
+{
+    if (m_subpixelAntialiasedText != RequestState::Unknown)
+        return m_subpixelAntialiasedText;
+
+    paintsContentDetermination();
+
+    return m_subpixelAntialiasedText;
+}
+
+PaintedContentsInfo::ContentsTypeDetermination PaintedContentsInfo::contentsTypeDetermination()
+{
+    if (m_contentsType != ContentsTypeDetermination::Unknown)
+        return m_contentsType;
+
+    if (m_backing.isSimpleContainerCompositingLayer(*this))
+        m_contentsType = ContentsTypeDetermination::SimpleContainer;
+    else if (m_backing.isDirectlyCompositedImage())
+        m_contentsType = ContentsTypeDetermination::DirectlyCompositedImage;
+    else
+        m_contentsType = ContentsTypeDetermination::Painted;
+
+    return m_contentsType;
+}
+
+
</ins><span class="cx"> RenderLayerBacking::RenderLayerBacking(RenderLayer&amp; layer)
</span><span class="cx">     : m_owningLayer(layer)
</span><span class="cx"> {
</span><span class="lines">@@ -142,7 +254,6 @@
</span><span class="cx"> #if PLATFORM(COCOA) &amp;&amp; USE(CA)
</span><span class="cx">     graphicsLayer-&gt;setAcceleratesDrawing(compositor().acceleratedDrawingEnabled());
</span><span class="cx">     graphicsLayer-&gt;setUsesDisplayListDrawing(compositor().displayListDrawingEnabled());
</span><del>-    graphicsLayer-&gt;setSupportsSubpixelAntialiasedText(renderer().settings().subpixelAntialiasedLayerTextEnabled());
</del><span class="cx"> #endif
</span><span class="cx">     
</span><span class="cx">     return graphicsLayer;
</span><span class="lines">@@ -609,15 +720,16 @@
</span><span class="cx">     } else
</span><span class="cx">         m_graphicsLayer-&gt;setReplicatedByLayer(nullptr);
</span><span class="cx"> 
</span><ins>+    PaintedContentsInfo contentsInfo(*this);
+
</ins><span class="cx">     if (!m_owningLayer.isRootLayer()) {
</span><del>-        bool isSimpleContainer = isSimpleContainerCompositingLayer();
</del><span class="cx">         bool didUpdateContentsRect = false;
</span><del>-        updateDirectlyCompositedBoxDecorations(isSimpleContainer, didUpdateContentsRect);
</del><ins>+        updateDirectlyCompositedBoxDecorations(contentsInfo, didUpdateContentsRect);
</ins><span class="cx">     } else
</span><span class="cx">         updateRootLayerConfiguration();
</span><span class="cx">     
</span><del>-    if (isDirectlyCompositedImage())
-        updateImageContents();
</del><ins>+    if (contentsInfo.isDirectlyCompositedImage())
+        updateImageContents(contentsInfo);
</ins><span class="cx"> 
</span><span class="cx">     if (is&lt;RenderEmbeddedObject&gt;(renderer()) &amp;&amp; downcast&lt;RenderEmbeddedObject&gt;(renderer()).allowsAcceleratedCompositing()) {
</span><span class="cx">         PluginViewBase* pluginViewBase = downcast&lt;PluginViewBase&gt;(downcast&lt;RenderWidget&gt;(renderer()).widget());
</span><span class="lines">@@ -784,7 +896,7 @@
</span><span class="cx">     auto* ancestorBackingLayer = compositedAncestor-&gt;backing();
</span><span class="cx">     LayoutRect parentGraphicsLayerRect;
</span><span class="cx">     if (m_owningLayer.isInsideFlowThread()) {
</span><del>-        /// FIXME: flows/columns need work.
</del><ins>+        // FIXME: flows/columns need work.
</ins><span class="cx">         LayoutRect ancestorCompositedBounds = ancestorBackingLayer-&gt;compositedBounds();
</span><span class="cx">         ancestorCompositedBounds.setLocation(LayoutPoint());
</span><span class="cx">         adjustAncestorCompositingBoundsForFlowThread(ancestorCompositedBounds, compositedAncestor);
</span><span class="lines">@@ -1092,17 +1204,18 @@
</span><span class="cx"> 
</span><span class="cx"> void RenderLayerBacking::updateAfterDescendants()
</span><span class="cx"> {
</span><del>-    bool isSimpleContainer = false;
</del><ins>+    // FIXME: this potentially duplicates work we did in updateConfiguration().
+    PaintedContentsInfo contentsInfo(*this);
+    contentsInfo.setWantsSubpixelAntialiasedTextState(GraphicsLayer::supportsSubpixelAntialiasedLayerText());
+
</ins><span class="cx">     if (!m_owningLayer.isRootLayer()) {
</span><span class="cx">         bool didUpdateContentsRect = false;
</span><del>-        // FIXME: this duplicates work we did in updateConfiguration().
-        isSimpleContainer = isSimpleContainerCompositingLayer();
-        updateDirectlyCompositedBoxDecorations(isSimpleContainer, didUpdateContentsRect);
</del><ins>+        updateDirectlyCompositedBoxDecorations(contentsInfo, didUpdateContentsRect);
</ins><span class="cx">         if (!didUpdateContentsRect &amp;&amp; m_graphicsLayer-&gt;usesContentsLayer())
</span><span class="cx">             resetContentsRect();
</span><span class="cx">     }
</span><span class="cx"> 
</span><del>-    updateDrawsContent(isSimpleContainer);
</del><ins>+    updateDrawsContent(contentsInfo);
</ins><span class="cx"> 
</span><span class="cx">     m_graphicsLayer-&gt;setContentsVisible(m_owningLayer.hasVisibleContent() || hasVisibleNonCompositedDescendants());
</span><span class="cx">     if (m_scrollingLayer) {
</span><span class="lines">@@ -1181,7 +1294,7 @@
</span><span class="cx">     }
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-void RenderLayerBacking::updateDirectlyCompositedBoxDecorations(bool isSimpleContainer, bool&amp; didUpdateContentsRect)
</del><ins>+void RenderLayerBacking::updateDirectlyCompositedBoxDecorations(PaintedContentsInfo&amp; contentsInfo, bool&amp; didUpdateContentsRect)
</ins><span class="cx"> {
</span><span class="cx">     if (!m_owningLayer.hasVisibleContent())
</span><span class="cx">         return;
</span><span class="lines">@@ -1188,8 +1301,8 @@
</span><span class="cx"> 
</span><span class="cx">     // The order of operations here matters, since the last valid type of contents needs
</span><span class="cx">     // to also update the contentsRect.
</span><del>-    updateDirectlyCompositedBackgroundColor(isSimpleContainer, didUpdateContentsRect);
-    updateDirectlyCompositedBackgroundImage(isSimpleContainer, didUpdateContentsRect);
</del><ins>+    updateDirectlyCompositedBackgroundColor(contentsInfo, didUpdateContentsRect);
+    updateDirectlyCompositedBackgroundImage(contentsInfo, didUpdateContentsRect);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void RenderLayerBacking::updateInternalHierarchy()
</span><span class="lines">@@ -1258,10 +1371,13 @@
</span><span class="cx"> 
</span><span class="cx"> void RenderLayerBacking::updateDrawsContent()
</span><span class="cx"> {
</span><del>-    updateDrawsContent(isSimpleContainerCompositingLayer());
</del><ins>+    PaintedContentsInfo contentsInfo(*this);
+    contentsInfo.setWantsSubpixelAntialiasedTextState(GraphicsLayer::supportsSubpixelAntialiasedLayerText());
+
+    updateDrawsContent(contentsInfo);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><del>-void RenderLayerBacking::updateDrawsContent(bool isSimpleContainer)
</del><ins>+void RenderLayerBacking::updateDrawsContent(PaintedContentsInfo&amp; contentsInfo)
</ins><span class="cx"> {
</span><span class="cx">     if (m_scrollingLayer) {
</span><span class="cx">         // We don't have to consider overflow controls, because we know that the scrollbars are drawn elsewhere.
</span><span class="lines">@@ -1271,17 +1387,25 @@
</span><span class="cx">         bool hasNonScrollingPaintedContent = m_owningLayer.hasVisibleContent() &amp;&amp; m_owningLayer.hasVisibleBoxDecorationsOrBackground();
</span><span class="cx">         m_graphicsLayer-&gt;setDrawsContent(hasNonScrollingPaintedContent);
</span><span class="cx"> 
</span><del>-        bool hasScrollingPaintedContent = m_owningLayer.hasVisibleContent() &amp;&amp; (renderer().hasBackground() || paintsChildRenderers());
</del><ins>+        bool hasScrollingPaintedContent = m_owningLayer.hasVisibleContent() &amp;&amp; (renderer().hasBackground() || contentsInfo.paintsContent());
</ins><span class="cx">         m_scrollingContentsLayer-&gt;setDrawsContent(hasScrollingPaintedContent);
</span><span class="cx">         return;
</span><span class="cx">     }
</span><span class="cx"> 
</span><del>-    bool hasPaintedContent = containsPaintedContent(isSimpleContainer);
</del><ins>+    bool hasPaintedContent = containsPaintedContent(contentsInfo);
</ins><span class="cx"> 
</span><ins>+    m_paintsSubpixelAntialiasedText = renderer().settings().subpixelAntialiasedLayerTextEnabled() &amp;&amp; contentsInfo.paintsSubpixelAntialiasedText();
+
</ins><span class="cx">     // FIXME: we could refine this to only allocate backing for one of these layers if possible.
</span><span class="cx">     m_graphicsLayer-&gt;setDrawsContent(hasPaintedContent);
</span><del>-    if (m_foregroundLayer)
</del><ins>+    if (m_foregroundLayer) {
</ins><span class="cx">         m_foregroundLayer-&gt;setDrawsContent(hasPaintedContent);
</span><ins>+        m_foregroundLayer-&gt;setSupportsSubpixelAntialiasedText(m_paintsSubpixelAntialiasedText);
+        // The text content is painted into the foreground layer.
+        // FIXME: this ignores SVG background images which may contain text.
+        m_graphicsLayer-&gt;setSupportsSubpixelAntialiasedText(false);
+    } else
+        m_graphicsLayer-&gt;setSupportsSubpixelAntialiasedText(m_paintsSubpixelAntialiasedText);
</ins><span class="cx"> 
</span><span class="cx">     if (m_backgroundLayer)
</span><span class="cx">         m_backgroundLayer-&gt;setDrawsContent(hasPaintedContent);
</span><span class="lines">@@ -1770,9 +1894,9 @@
</span><span class="cx">     return backgroundRenderer-&gt;style().visitedDependentColor(CSSPropertyBackgroundColor);
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-void RenderLayerBacking::updateDirectlyCompositedBackgroundColor(bool isSimpleContainer, bool&amp; didUpdateContentsRect)
</del><ins>+void RenderLayerBacking::updateDirectlyCompositedBackgroundColor(PaintedContentsInfo&amp; contentsInfo, bool&amp; didUpdateContentsRect)
</ins><span class="cx"> {
</span><del>-    if (!isSimpleContainer || (is&lt;RenderBox&gt;(renderer()) &amp;&amp; !downcast&lt;RenderBox&gt;(renderer()).paintsOwnBackground())) {
</del><ins>+    if (!contentsInfo.isSimpleContainer() || (is&lt;RenderBox&gt;(renderer()) &amp;&amp; !downcast&lt;RenderBox&gt;(renderer()).paintsOwnBackground())) {
</ins><span class="cx">         m_graphicsLayer-&gt;setContentsToSolidColor(Color());
</span><span class="cx">         return;
</span><span class="cx">     }
</span><span class="lines">@@ -1787,16 +1911,16 @@
</span><span class="cx">     didUpdateContentsRect = true;
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-void RenderLayerBacking::updateDirectlyCompositedBackgroundImage(bool isSimpleContainer, bool&amp; didUpdateContentsRect)
</del><ins>+void RenderLayerBacking::updateDirectlyCompositedBackgroundImage(PaintedContentsInfo&amp; contentsInfo, bool&amp; didUpdateContentsRect)
</ins><span class="cx"> {
</span><span class="cx">     if (!GraphicsLayer::supportsContentsTiling())
</span><span class="cx">         return;
</span><span class="cx"> 
</span><del>-    if (isDirectlyCompositedImage())
</del><ins>+    if (contentsInfo.isDirectlyCompositedImage())
</ins><span class="cx">         return;
</span><span class="cx"> 
</span><span class="cx">     auto&amp; style = renderer().style();
</span><del>-    if (!isSimpleContainer || !style.hasBackgroundImage()) {
</del><ins>+    if (!contentsInfo.isSimpleContainer() || !style.hasBackgroundImage()) {
</ins><span class="cx">         m_graphicsLayer-&gt;setContentsToImage(0);
</span><span class="cx">         return;
</span><span class="cx">     }
</span><span class="lines">@@ -1871,15 +1995,29 @@
</span><span class="cx">     return !supportsDirectlyCompositedBoxDecorations(renderer());
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-bool RenderLayerBacking::paintsChildRenderers() const
</del><ins>+bool RenderLayerBacking::paintsContent(RenderLayer::PaintedContentRequest&amp; request) const
</ins><span class="cx"> {
</span><del>-    if (m_owningLayer.hasVisibleContent() &amp;&amp; m_owningLayer.hasNonEmptyChildRenderers())
-        return true;
</del><ins>+    bool paintsContent = false;
</ins><span class="cx"> 
</span><del>-    if (isPaintDestinationForDescendantLayers())
-        return true;
</del><ins>+    if (m_owningLayer.hasVisibleContent() &amp;&amp; m_owningLayer.hasNonEmptyChildRenderers(request))
+        paintsContent = true;
</ins><span class="cx"> 
</span><del>-    return false;
</del><ins>+    if (request.isSatisfied())
+        return paintsContent;
+
+    if (isPaintDestinationForDescendantLayers(request))
+        paintsContent = true;
+
+    if (request.isSatisfied())
+        return paintsContent;
+
+    if (request.hasPaintedContent == RequestState::Unknown)
+        request.hasPaintedContent = RequestState::False;
+
+    if (request.hasSubpixelAntialiasedText == RequestState::Unknown)
+        request.hasSubpixelAntialiasedText = RequestState::False;
+
+    return paintsContent;
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> static bool isRestartedPlugin(RenderObject&amp; renderer)
</span><span class="lines">@@ -1902,7 +2040,7 @@
</span><span class="cx"> // A &quot;simple container layer&quot; is a RenderLayer which has no visible content to render.
</span><span class="cx"> // It may have no children, or all its children may be themselves composited.
</span><span class="cx"> // This is a useful optimization, because it allows us to avoid allocating backing store.
</span><del>-bool RenderLayerBacking::isSimpleContainerCompositingLayer() const
</del><ins>+bool RenderLayerBacking::isSimpleContainerCompositingLayer(PaintedContentsInfo&amp; contentsInfo) const
</ins><span class="cx"> {
</span><span class="cx">     if (renderer().isRenderReplaced() &amp;&amp; (!isCompositedPlugin(renderer()) || isRestartedPlugin(renderer())))
</span><span class="cx">         return false;
</span><span class="lines">@@ -1910,7 +2048,7 @@
</span><span class="cx">     if (renderer().isTextControl())
</span><span class="cx">         return false;
</span><span class="cx"> 
</span><del>-    if (paintsBoxDecorations() || paintsChildRenderers())
</del><ins>+    if (contentsInfo.paintsBoxDecorations() || contentsInfo.paintsContent())
</ins><span class="cx">         return false;
</span><span class="cx"> 
</span><span class="cx">     if (renderer().style().backgroundClip() == TextFillBox)
</span><span class="lines">@@ -1948,6 +2086,7 @@
</span><span class="cx">     return true;
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+// Returning true stops the traversal.
</ins><span class="cx"> enum class LayerTraversal { Continue, Stop };
</span><span class="cx"> 
</span><span class="cx"> static LayerTraversal traverseVisibleNonCompositedDescendantLayers(RenderLayer&amp; parent, std::function&lt;LayerTraversal (const RenderLayer&amp;)&gt; layerFunc)
</span><span class="lines">@@ -2008,12 +2147,12 @@
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> // Conservative test for having no rendered children.
</span><del>-bool RenderLayerBacking::isPaintDestinationForDescendantLayers() const
</del><ins>+bool RenderLayerBacking::isPaintDestinationForDescendantLayers(RenderLayer::PaintedContentRequest&amp; request) const
</ins><span class="cx"> {
</span><span class="cx">     bool hasPaintingDescendant = false;
</span><del>-    traverseVisibleNonCompositedDescendantLayers(m_owningLayer, [&amp;hasPaintingDescendant](const RenderLayer&amp; layer) {
-        hasPaintingDescendant = layer.isVisuallyNonEmpty();
-        return hasPaintingDescendant ? LayerTraversal::Stop : LayerTraversal::Continue;
</del><ins>+    traverseVisibleNonCompositedDescendantLayers(m_owningLayer, [&amp;hasPaintingDescendant, &amp;request](const RenderLayer&amp; layer) {
+        hasPaintingDescendant |= layer.isVisuallyNonEmpty(&amp;request);
+        return (hasPaintingDescendant &amp;&amp; request.isSatisfied()) ? LayerTraversal::Stop : LayerTraversal::Continue;
</ins><span class="cx">     });
</span><span class="cx"> 
</span><span class="cx">     return hasPaintingDescendant;
</span><span class="lines">@@ -2023,7 +2162,7 @@
</span><span class="cx"> {
</span><span class="cx">     bool hasVisibleDescendant = false;
</span><span class="cx">     traverseVisibleNonCompositedDescendantLayers(m_owningLayer, [&amp;hasVisibleDescendant](const RenderLayer&amp; layer) {
</span><del>-        hasVisibleDescendant = layer.hasVisibleContent();
</del><ins>+        hasVisibleDescendant |= layer.hasVisibleContent();
</ins><span class="cx">         return hasVisibleDescendant ? LayerTraversal::Stop : LayerTraversal::Continue;
</span><span class="cx">     });
</span><span class="cx"> 
</span><span class="lines">@@ -2030,12 +2169,12 @@
</span><span class="cx">     return hasVisibleDescendant;
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-bool RenderLayerBacking::containsPaintedContent(bool isSimpleContainer) const
</del><ins>+bool RenderLayerBacking::containsPaintedContent(PaintedContentsInfo&amp; contentsInfo) const
</ins><span class="cx"> {
</span><del>-    if (isSimpleContainer || paintsIntoWindow() || paintsIntoCompositedAncestor() || m_artificiallyInflatedBounds || m_owningLayer.isReflection())
</del><ins>+    if (contentsInfo.isSimpleContainer() || paintsIntoWindow() || paintsIntoCompositedAncestor() || m_artificiallyInflatedBounds || m_owningLayer.isReflection())
</ins><span class="cx">         return false;
</span><span class="cx"> 
</span><del>-    if (isDirectlyCompositedImage())
</del><ins>+    if (contentsInfo.isDirectlyCompositedImage())
</ins><span class="cx">         return false;
</span><span class="cx"> 
</span><span class="cx">     // FIXME: we could optimize cases where the image, video or canvas is known to fill the border box entirely,
</span><span class="lines">@@ -2085,8 +2224,9 @@
</span><span class="cx"> 
</span><span class="cx"> void RenderLayerBacking::contentChanged(ContentChangeType changeType)
</span><span class="cx"> {
</span><del>-    if ((changeType == ImageChanged) &amp;&amp; isDirectlyCompositedImage()) {
-        updateImageContents();
</del><ins>+    PaintedContentsInfo contentsInfo(*this);
+    if ((changeType == ImageChanged) &amp;&amp; contentsInfo.isDirectlyCompositedImage()) {
+        updateImageContents(contentsInfo);
</ins><span class="cx">         return;
</span><span class="cx">     }
</span><span class="cx"> 
</span><span class="lines">@@ -2107,7 +2247,7 @@
</span><span class="cx"> #endif
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-void RenderLayerBacking::updateImageContents()
</del><ins>+void RenderLayerBacking::updateImageContents(PaintedContentsInfo&amp; contentsInfo)
</ins><span class="cx"> {
</span><span class="cx">     auto&amp; imageRenderer = downcast&lt;RenderImage&gt;(renderer());
</span><span class="cx"> 
</span><span class="lines">@@ -2132,9 +2272,9 @@
</span><span class="cx">     m_graphicsLayer-&gt;setContentsClippingRect(contentsClippingRect);
</span><span class="cx"> 
</span><span class="cx">     m_graphicsLayer-&gt;setContentsToImage(image);
</span><del>-    bool isSimpleContainer = false;
-    updateDrawsContent(isSimpleContainer);
</del><span class="cx">     
</span><ins>+    updateDrawsContent(contentsInfo);
+    
</ins><span class="cx">     // Image animation is &quot;lazy&quot;, in that it automatically stops unless someone is drawing
</span><span class="cx">     // the image. So we have to kick the animation each time; this has the downside that the
</span><span class="cx">     // image will keep animating, even if its layer is not visible.
</span></span></pre></div>
<a id="trunkSourceWebCorerenderingRenderLayerBackingh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/rendering/RenderLayerBacking.h (213465 => 213466)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/rendering/RenderLayerBacking.h        2017-03-06 21:44:20 UTC (rev 213465)
+++ trunk/Source/WebCore/rendering/RenderLayerBacking.h        2017-03-06 21:45:38 UTC (rev 213466)
</span><span class="lines">@@ -35,6 +35,7 @@
</span><span class="cx"> namespace WebCore {
</span><span class="cx"> 
</span><span class="cx"> class KeyframeList;
</span><ins>+class PaintedContentsInfo;
</ins><span class="cx"> class RenderLayerCompositor;
</span><span class="cx"> class TiledBacking;
</span><span class="cx"> class TransformationMatrix;
</span><span class="lines">@@ -188,6 +189,7 @@
</span><span class="cx">     void setTiledBackingHasMargins(bool hasExtendedBackgroundOnLeftAndRight, bool hasExtendedBackgroundOnTopAndBottom);
</span><span class="cx">     
</span><span class="cx">     void updateDebugIndicators(bool showBorder, bool showRepaintCounter);
</span><ins>+    bool paintsSubpixelAntialiasedText() const { return m_paintsSubpixelAntialiasedText; }
</ins><span class="cx"> 
</span><span class="cx">     // GraphicsLayerClient interface
</span><span class="cx">     void tiledBackingUsageChanged(const GraphicsLayer*, bool /*usingTiledBacking*/) override;
</span><span class="lines">@@ -251,6 +253,8 @@
</span><span class="cx">     WEBCORE_EXPORT String replayDisplayListAsText(DisplayList::AsTextFlags) const;
</span><span class="cx"> 
</span><span class="cx"> private:
</span><ins>+    friend class PaintedContentsInfo;
+
</ins><span class="cx">     FloatRect backgroundBoxForSimpleContainerPainting() const;
</span><span class="cx"> 
</span><span class="cx">     void createPrimaryGraphicsLayer();
</span><span class="lines">@@ -277,7 +281,7 @@
</span><span class="cx">     bool requiresVerticalScrollbarLayer() const;
</span><span class="cx">     bool requiresScrollCornerLayer() const;
</span><span class="cx">     bool updateScrollingLayers(bool scrollingLayers);
</span><del>-    void updateDrawsContent(bool isSimpleContainer);
</del><ins>+
</ins><span class="cx">     void updateChildClippingStrategy(bool needsDescendantsClippingLayer);
</span><span class="cx"> 
</span><span class="cx">     void updateMaskingLayerGeometry();
</span><span class="lines">@@ -306,29 +310,30 @@
</span><span class="cx"> 
</span><span class="cx">     // Return the opacity value that this layer should use for compositing.
</span><span class="cx">     float compositingOpacity(float rendererOpacity) const;
</span><del>-    
</del><ins>+    Color rendererBackgroundColor() const;
+
</ins><span class="cx">     bool isMainFrameRenderViewLayer() const;
</span><span class="cx">     
</span><span class="cx">     bool paintsBoxDecorations() const;
</span><del>-    bool paintsChildRenderers() const;
</del><ins>+    bool paintsContent(RenderLayer::PaintedContentRequest&amp;) const;
</ins><span class="cx"> 
</span><ins>+    void updateDrawsContent(PaintedContentsInfo&amp;);
+
</ins><span class="cx">     // Returns true if this compositing layer has no visible content.
</span><del>-    bool isSimpleContainerCompositingLayer() const;
</del><ins>+    bool isSimpleContainerCompositingLayer(PaintedContentsInfo&amp;) const;
</ins><span class="cx">     // Returns true if this layer has content that needs to be rendered by painting into the backing store.
</span><del>-    bool containsPaintedContent(bool isSimpleContainer) const;
</del><ins>+    bool containsPaintedContent(PaintedContentsInfo&amp;) const;
</ins><span class="cx">     // Returns true if the RenderLayer just contains an image that we can composite directly.
</span><span class="cx">     bool isDirectlyCompositedImage() const;
</span><del>-    void updateImageContents();
</del><ins>+    void updateImageContents(PaintedContentsInfo&amp;);
</ins><span class="cx"> 
</span><del>-    Color rendererBackgroundColor() const;
</del><ins>+    void updateDirectlyCompositedBoxDecorations(PaintedContentsInfo&amp;, bool&amp; didUpdateContentsRect);
+    void updateDirectlyCompositedBackgroundColor(PaintedContentsInfo&amp;, bool&amp; didUpdateContentsRect);
+    void updateDirectlyCompositedBackgroundImage(PaintedContentsInfo&amp;, bool&amp; didUpdateContentsRect);
</ins><span class="cx"> 
</span><del>-    void updateDirectlyCompositedBoxDecorations(bool isSimpleContainer, bool&amp; didUpdateContentsRect);
-    void updateDirectlyCompositedBackgroundColor(bool isSimpleContainer, bool&amp; didUpdateContentsRect);
-    void updateDirectlyCompositedBackgroundImage(bool isSimpleContainer, bool&amp; didUpdateContentsRect);
-
</del><span class="cx">     void resetContentsRect();
</span><span class="cx"> 
</span><del>-    bool isPaintDestinationForDescendantLayers() const;
</del><ins>+    bool isPaintDestinationForDescendantLayers(RenderLayer::PaintedContentRequest&amp;) const;
</ins><span class="cx">     bool hasVisibleNonCompositedDescendants() const;
</span><span class="cx"> 
</span><span class="cx">     bool shouldClipCompositedBounds() const;
</span><span class="lines">@@ -382,6 +387,7 @@
</span><span class="cx">     bool m_canCompositeBackdropFilters { false };
</span><span class="cx"> #endif
</span><span class="cx">     bool m_backgroundLayerPaintsFixedRootBackground { false };
</span><ins>+    bool m_paintsSubpixelAntialiasedText { false }; // This is for logging only.
</ins><span class="cx"> };
</span><span class="cx"> 
</span><span class="cx"> enum CanvasCompositingStrategy {
</span></span></pre></div>
<a id="trunkSourceWebCorerenderingRenderLayerCompositorcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/rendering/RenderLayerCompositor.cpp (213465 => 213466)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/rendering/RenderLayerCompositor.cpp        2017-03-06 21:44:20 UTC (rev 213465)
+++ trunk/Source/WebCore/rendering/RenderLayerCompositor.cpp        2017-03-06 21:45:38 UTC (rev 213466)
</span><span class="lines">@@ -841,6 +841,12 @@
</span><span class="cx">             else
</span><span class="cx">                 logString.appendLiteral(&quot;background&quot;);
</span><span class="cx">         }
</span><ins>+        
+        if (backing-&gt;paintsSubpixelAntialiasedText()) {
+            if (prependSpace)
+                logString.appendLiteral(&quot;, &quot;);
+            logString.appendLiteral(&quot;texty&quot;);
+        }
</ins><span class="cx"> 
</span><span class="cx">         logString.appendLiteral(&quot;] &quot;);
</span><span class="cx">     }
</span></span></pre></div>
<a id="trunkSourceWebCoretestingInternalscpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/testing/Internals.cpp (213465 => 213466)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/testing/Internals.cpp        2017-03-06 21:44:20 UTC (rev 213465)
+++ trunk/Source/WebCore/testing/Internals.cpp        2017-03-06 21:45:38 UTC (rev 213466)
</span><span class="lines">@@ -1348,6 +1348,11 @@
</span><span class="cx">     FontCache::singleton().invalidate();
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+void Internals::setFontSmoothingEnabled(bool enabled)
+{
+    WebCore::FontCascade::setShouldUseSmoothing(enabled);
+}
+
</ins><span class="cx"> ExceptionOr&lt;void&gt; Internals::setLowPowerModeEnabled(bool isEnabled)
</span><span class="cx"> {
</span><span class="cx">     auto* document = contextDocument();
</span></span></pre></div>
<a id="trunkSourceWebCoretestingInternalsh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/testing/Internals.h (213465 => 213466)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/testing/Internals.h        2017-03-06 21:44:20 UTC (rev 213465)
+++ trunk/Source/WebCore/testing/Internals.h        2017-03-06 21:45:38 UTC (rev 213466)
</span><span class="lines">@@ -176,6 +176,8 @@
</span><span class="cx">     ExceptionOr&lt;void&gt; setMarkedTextMatchesAreHighlighted(bool);
</span><span class="cx"> 
</span><span class="cx">     void invalidateFontCache();
</span><ins>+    void setFontSmoothingEnabled(bool);
+    
</ins><span class="cx">     ExceptionOr&lt;void&gt; setLowPowerModeEnabled(bool);
</span><span class="cx"> 
</span><span class="cx">     ExceptionOr&lt;void&gt; setScrollViewPosition(int x, int y);
</span></span></pre></div>
<a id="trunkSourceWebCoretestingInternalsidl"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/testing/Internals.idl (213465 => 213466)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/testing/Internals.idl        2017-03-06 21:44:20 UTC (rev 213465)
+++ trunk/Source/WebCore/testing/Internals.idl        2017-03-06 21:45:38 UTC (rev 213466)
</span><span class="lines">@@ -160,6 +160,7 @@
</span><span class="cx">     [MayThrowException] void setMarkedTextMatchesAreHighlighted(boolean flag);
</span><span class="cx"> 
</span><span class="cx">     void invalidateFontCache();
</span><ins>+    void setFontSmoothingEnabled(boolean enabled);
</ins><span class="cx"> 
</span><span class="cx">     [MayThrowException] void setScrollViewPosition(long x, long y);
</span><span class="cx"> 
</span></span></pre>
</div>
</div>

</body>
</html>