<!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>[201727] 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/201727">201727</a></dd>
<dt>Author</dt> <dd>commit-queue@webkit.org</dd>
<dt>Date</dt> <dd>2016-06-06 13:58:19 -0700 (Mon, 06 Jun 2016)</dd>
</dl>
<h3>Log Message</h3>
<pre>Position of WebGL <canvas> on iOS is incorrect with CSS borders
https://bugs.webkit.org/show_bug.cgi?id=156790
Patch by Antoine Quint <graouts@apple.com> on 2016-06-06
Reviewed by Simon Fraser.
Source/WebKit2:
WebGL layers on iOS are hosted by a WKRemoteView, which applies a transform scaling
its content by the inverse of the device pixel ratio, which affects how positions are
applied to the WebGL layer. The container layer of the layer hosted by a WKRemoteView
then has an inverse transform applied to it in the PlatformCALayerRemoteCustom
constructor. However, the position of a CALayer is not affected by its transform.
The fix for <rdar://problem/18316542> should be specific to video, so we only apply the
scaling in the case of a LayerTypeAVPlayerLayer.
* UIProcess/ios/RemoteLayerTreeHostIOS.mm:
(-[WKRemoteView initWithFrame:contextID:]):
(WebKit::RemoteLayerTreeHost::createLayer):
(-[WKRemoteView initWithFrame:contextID:hostingDeviceScaleFactor:]): Deleted.
* WebProcess/WebPage/mac/PlatformCALayerRemoteCustom.mm:
(WebKit::PlatformCALayerRemoteCustom::PlatformCALayerRemoteCustom):
LayoutTests:
Adding new tests checking that CSS border, box-shadow and padding properties used on a
WebGL <canvas> element correctly affect the position of the WebGL content.
* webgl/webgl-border-expected.html: Added.
* webgl/webgl-border.html: Added.
* webgl/webgl-box-shadow-expected.html: Added.
* webgl/webgl-box-shadow.html: Added.
* webgl/webgl-padding-expected.html: Added.
* webgl/webgl-padding.html: Added.</pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkLayoutTestsChangeLog">trunk/LayoutTests/ChangeLog</a></li>
<li><a href="#trunkSourceWebKit2ChangeLog">trunk/Source/WebKit2/ChangeLog</a></li>
<li><a href="#trunkSourceWebKit2UIProcessiosRemoteLayerTreeHostIOSmm">trunk/Source/WebKit2/UIProcess/ios/RemoteLayerTreeHostIOS.mm</a></li>
<li><a href="#trunkSourceWebKit2WebProcessWebPagemacPlatformCALayerRemoteCustommm">trunk/Source/WebKit2/WebProcess/WebPage/mac/PlatformCALayerRemoteCustom.mm</a></li>
</ul>
<h3>Added Paths</h3>
<ul>
<li><a href="#trunkLayoutTestswebglwebglborderexpectedhtml">trunk/LayoutTests/webgl/webgl-border-expected.html</a></li>
<li><a href="#trunkLayoutTestswebglwebglborderhtml">trunk/LayoutTests/webgl/webgl-border.html</a></li>
<li><a href="#trunkLayoutTestswebglwebglboxshadowexpectedhtml">trunk/LayoutTests/webgl/webgl-box-shadow-expected.html</a></li>
<li><a href="#trunkLayoutTestswebglwebglboxshadowhtml">trunk/LayoutTests/webgl/webgl-box-shadow.html</a></li>
<li><a href="#trunkLayoutTestswebglwebglpaddingexpectedhtml">trunk/LayoutTests/webgl/webgl-padding-expected.html</a></li>
<li><a href="#trunkLayoutTestswebglwebglpaddinghtml">trunk/LayoutTests/webgl/webgl-padding.html</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkLayoutTestsChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/ChangeLog (201726 => 201727)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/ChangeLog        2016-06-06 20:34:07 UTC (rev 201726)
+++ trunk/LayoutTests/ChangeLog        2016-06-06 20:58:19 UTC (rev 201727)
</span><span class="lines">@@ -1,3 +1,20 @@
</span><ins>+2016-06-06 Antoine Quint <graouts@apple.com>
+
+ Position of WebGL <canvas> on iOS is incorrect with CSS borders
+ https://bugs.webkit.org/show_bug.cgi?id=156790
+
+ Reviewed by Simon Fraser.
+
+ Adding new tests checking that CSS border, box-shadow and padding properties used on a
+ WebGL <canvas> element correctly affect the position of the WebGL content.
+
+ * webgl/webgl-border-expected.html: Added.
+ * webgl/webgl-border.html: Added.
+ * webgl/webgl-box-shadow-expected.html: Added.
+ * webgl/webgl-box-shadow.html: Added.
+ * webgl/webgl-padding-expected.html: Added.
+ * webgl/webgl-padding.html: Added.
+
</ins><span class="cx"> 2016-06-06 Skachkov Oleksandr <gskachkov@gmail.com>
</span><span class="cx">
</span><span class="cx"> [ESNext] Support trailing commas in function param lists
</span></span></pre></div>
<a id="trunkLayoutTestswebglwebglborderexpectedhtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/webgl/webgl-border-expected.html (0 => 201727)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/webgl/webgl-border-expected.html         (rev 0)
+++ trunk/LayoutTests/webgl/webgl-border-expected.html        2016-06-06 20:58:19 UTC (rev 201727)
</span><span class="lines">@@ -0,0 +1,14 @@
</span><ins>+<head>
+ <meta name="viewport" content="width=device-width">
+ <style>
+
+ div {
+ width: 100px;
+ height: 100px;
+ background-color: black;
+ border: 20px solid blue;
+ }
+
+ </style>
+</head>
+<div></div>
</ins></span></pre></div>
<a id="trunkLayoutTestswebglwebglborderhtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/webgl/webgl-border.html (0 => 201727)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/webgl/webgl-border.html         (rev 0)
+++ trunk/LayoutTests/webgl/webgl-border.html        2016-06-06 20:58:19 UTC (rev 201727)
</span><span class="lines">@@ -0,0 +1,26 @@
</span><ins>+<head>
+ <meta name="viewport" content="width=device-width">
+ <style>
+
+ canvas {
+ width: 100px;
+ height: 100px;
+ background-color: red;
+ border: 20px solid blue;
+ }
+
+ </style>
+</head>
+<canvas>
+<script type="text/javascript">
+
+ var canvas = document.querySelector("canvas");
+ canvas.width = canvas.clientWidth * window.devicePixelRatio;
+ canvas.height = canvas.clientHeight * window.devicePixelRatio;
+
+ var gl = canvas.getContext("webgl");
+ gl.clearColor(0, 0, 0, 1);
+ gl.clear(gl.COLOR_BUFFER_BIT);
+
+</script>
+</canvas>
</ins></span></pre></div>
<a id="trunkLayoutTestswebglwebglboxshadowexpectedhtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/webgl/webgl-box-shadow-expected.html (0 => 201727)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/webgl/webgl-box-shadow-expected.html         (rev 0)
+++ trunk/LayoutTests/webgl/webgl-box-shadow-expected.html        2016-06-06 20:58:19 UTC (rev 201727)
</span><span class="lines">@@ -0,0 +1,14 @@
</span><ins>+<head>
+ <meta name="viewport" content="width=device-width">
+ <style>
+
+ div {
+ width: 100px;
+ height: 100px;
+ background-color: black;
+ box-shadow: 10px 10px 0px blue;
+ }
+
+ </style>
+</head>
+<div></div>
</ins></span></pre></div>
<a id="trunkLayoutTestswebglwebglboxshadowhtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/webgl/webgl-box-shadow.html (0 => 201727)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/webgl/webgl-box-shadow.html         (rev 0)
+++ trunk/LayoutTests/webgl/webgl-box-shadow.html        2016-06-06 20:58:19 UTC (rev 201727)
</span><span class="lines">@@ -0,0 +1,26 @@
</span><ins>+<head>
+ <meta name="viewport" content="width=device-width">
+ <style>
+
+ canvas {
+ width: 100px;
+ height: 100px;
+ background-color: red;
+ box-shadow: 10px 10px 0px blue;
+ }
+
+ </style>
+</head>
+<canvas>
+<script type="text/javascript">
+
+ var canvas = document.querySelector("canvas");
+ canvas.width = canvas.clientWidth * window.devicePixelRatio;
+ canvas.height = canvas.clientHeight * window.devicePixelRatio;
+
+ var gl = canvas.getContext("webgl");
+ gl.clearColor(0, 0, 0, 1);
+ gl.clear(gl.COLOR_BUFFER_BIT);
+
+</script>
+</canvas>
</ins></span></pre></div>
<a id="trunkLayoutTestswebglwebglpaddingexpectedhtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/webgl/webgl-padding-expected.html (0 => 201727)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/webgl/webgl-padding-expected.html         (rev 0)
+++ trunk/LayoutTests/webgl/webgl-padding-expected.html        2016-06-06 20:58:19 UTC (rev 201727)
</span><span class="lines">@@ -0,0 +1,14 @@
</span><ins>+<head>
+ <meta name="viewport" content="width=device-width">
+ <style>
+
+ div {
+ width: 100px;
+ height: 100px;
+ background-color: black;
+ padding: 10px;
+ }
+
+ </style>
+</head>
+<div></div>
</ins></span></pre></div>
<a id="trunkLayoutTestswebglwebglpaddinghtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/webgl/webgl-padding.html (0 => 201727)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/webgl/webgl-padding.html         (rev 0)
+++ trunk/LayoutTests/webgl/webgl-padding.html        2016-06-06 20:58:19 UTC (rev 201727)
</span><span class="lines">@@ -0,0 +1,26 @@
</span><ins>+<head>
+ <meta name="viewport" content="width=device-width">
+ <style>
+
+ canvas {
+ width: 100px;
+ height: 100px;
+ background-color: black;
+ padding: 10px;
+ }
+
+ </style>
+</head>
+<canvas>
+<script type="text/javascript">
+
+ var canvas = document.querySelector("canvas");
+ canvas.width = canvas.clientWidth * window.devicePixelRatio;
+ canvas.height = canvas.clientHeight * window.devicePixelRatio;
+
+ var gl = canvas.getContext("webgl");
+ gl.clearColor(0, 0, 0, 1);
+ gl.clear(gl.COLOR_BUFFER_BIT);
+
+</script>
+</canvas>
</ins></span></pre></div>
<a id="trunkSourceWebKit2ChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/ChangeLog (201726 => 201727)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/ChangeLog        2016-06-06 20:34:07 UTC (rev 201726)
+++ trunk/Source/WebKit2/ChangeLog        2016-06-06 20:58:19 UTC (rev 201727)
</span><span class="lines">@@ -1,3 +1,26 @@
</span><ins>+2016-06-06 Antoine Quint <graouts@apple.com>
+
+ Position of WebGL <canvas> on iOS is incorrect with CSS borders
+ https://bugs.webkit.org/show_bug.cgi?id=156790
+
+ Reviewed by Simon Fraser.
+
+ WebGL layers on iOS are hosted by a WKRemoteView, which applies a transform scaling
+ its content by the inverse of the device pixel ratio, which affects how positions are
+ applied to the WebGL layer. The container layer of the layer hosted by a WKRemoteView
+ then has an inverse transform applied to it in the PlatformCALayerRemoteCustom
+ constructor. However, the position of a CALayer is not affected by its transform.
+
+ The fix for <rdar://problem/18316542> should be specific to video, so we only apply the
+ scaling in the case of a LayerTypeAVPlayerLayer.
+
+ * UIProcess/ios/RemoteLayerTreeHostIOS.mm:
+ (-[WKRemoteView initWithFrame:contextID:]):
+ (WebKit::RemoteLayerTreeHost::createLayer):
+ (-[WKRemoteView initWithFrame:contextID:hostingDeviceScaleFactor:]): Deleted.
+ * WebProcess/WebPage/mac/PlatformCALayerRemoteCustom.mm:
+ (WebKit::PlatformCALayerRemoteCustom::PlatformCALayerRemoteCustom):
+
</ins><span class="cx"> 2016-06-06 Brady Eidson <beidson@apple.com>
</span><span class="cx">
</span><span class="cx"> Fix build after r201717
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessiosRemoteLayerTreeHostIOSmm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/ios/RemoteLayerTreeHostIOS.mm (201726 => 201727)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/ios/RemoteLayerTreeHostIOS.mm        2016-06-06 20:34:07 UTC (rev 201726)
+++ trunk/Source/WebKit2/UIProcess/ios/RemoteLayerTreeHostIOS.mm        2016-06-06 20:58:19 UTC (rev 201727)
</span><span class="lines">@@ -140,14 +140,10 @@
</span><span class="cx">
</span><span class="cx"> @implementation WKRemoteView
</span><span class="cx">
</span><del>-- (instancetype)initWithFrame:(CGRect)frame contextID:(uint32_t)contextID hostingDeviceScaleFactor:(float)scaleFactor
</del><ins>+- (instancetype)initWithFrame:(CGRect)frame contextID:(uint32_t)contextID
</ins><span class="cx"> {
</span><del>- if ((self = [super initWithFrame:frame])) {
</del><ins>+ if ((self = [super initWithFrame:frame]))
</ins><span class="cx"> [[self layer] setContextId:contextID];
</span><del>- // Invert the scale transform added in the WebProcess to fix <rdar://problem/18316542>.
- float inverseScale = 1 / scaleFactor;
- [[self layer] setTransform:CATransform3DMakeScale(inverseScale, inverseScale, 1)];
- }
</del><span class="cx">
</span><span class="cx"> return self;
</span><span class="cx"> }
</span><span class="lines">@@ -211,9 +207,14 @@
</span><span class="cx"> case PlatformCALayer::LayerTypeCustom:
</span><span class="cx"> case PlatformCALayer::LayerTypeAVPlayerLayer:
</span><span class="cx"> case PlatformCALayer::LayerTypeWebGLLayer:
</span><del>- if (!m_isDebugLayerTreeHost)
- view = adoptNS([[WKRemoteView alloc] initWithFrame:CGRectZero contextID:properties.hostingContextID hostingDeviceScaleFactor:properties.hostingDeviceScaleFactor]);
- else
</del><ins>+ if (!m_isDebugLayerTreeHost) {
+ view = adoptNS([[WKRemoteView alloc] initWithFrame:CGRectZero contextID:properties.hostingContextID]);
+ if (properties.type == PlatformCALayer::LayerTypeAVPlayerLayer) {
+ // Invert the scale transform added in the WebProcess to fix <rdar://problem/18316542>.
+ float inverseScale = 1 / properties.hostingDeviceScaleFactor;
+ [[view layer] setTransform:CATransform3DMakeScale(inverseScale, inverseScale, 1)];
+ }
+ } else
</ins><span class="cx"> view = adoptNS([[WKCompositingView alloc] init]);
</span><span class="cx"> break;
</span><span class="cx"> case PlatformCALayer::LayerTypeShapeLayer:
</span></span></pre></div>
<a id="trunkSourceWebKit2WebProcessWebPagemacPlatformCALayerRemoteCustommm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/WebProcess/WebPage/mac/PlatformCALayerRemoteCustom.mm (201726 => 201727)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/WebProcess/WebPage/mac/PlatformCALayerRemoteCustom.mm        2016-06-06 20:34:07 UTC (rev 201726)
+++ trunk/Source/WebKit2/WebProcess/WebPage/mac/PlatformCALayerRemoteCustom.mm        2016-06-06 20:58:19 UTC (rev 201727)
</span><span class="lines">@@ -65,10 +65,12 @@
</span><span class="cx"> case LayerHostingMode::OutOfProcess:
</span><span class="cx"> m_layerHostingContext = LayerHostingContext::createForExternalHostingProcess();
</span><span class="cx"> #if PLATFORM(IOS)
</span><del>- float scaleFactor = context.deviceScaleFactor();
- // Set a scale factor here to make convertRect:toLayer:nil take scale factor into account. <rdar://problem/18316542>.
- // This scale factor is inverted in the hosting process.
- [customLayer setTransform:CATransform3DMakeScale(scaleFactor, scaleFactor, 1)];
</del><ins>+ if (layerType == LayerTypeAVPlayerLayer) {
+ float scaleFactor = context.deviceScaleFactor();
+ // Set a scale factor here to make convertRect:toLayer:nil take scale factor into account. <rdar://problem/18316542>.
+ // This scale factor is inverted in the hosting process.
+ [customLayer setTransform:CATransform3DMakeScale(scaleFactor, scaleFactor, 1)];
+ }
</ins><span class="cx"> #endif
</span><span class="cx"> break;
</span><span class="cx"> #endif
</span></span></pre>
</div>
</div>
</body>
</html>