<!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>[46947] trunk/WebKit/mac</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/46947">46947</a></dd>
<dt>Author</dt> <dd>simon.fraser@apple.com</dd>
<dt>Date</dt> <dd>2009-08-07 21:08:24 -0700 (Fri, 07 Aug 2009)</dd>
</dl>

<h3>Log Message</h3>
<pre>2009-08-07  Simon Fraser  &lt;simon.fraser@apple.com&gt;

        Reviewed by Dan Bernstein.

        Work around an issue on Leopard where composited layers are misplaced and squished when the page
        gets over 4096px tall.
        https://bugs.webkit.org/show_bug.cgi?id=27272
        &lt;rdar://problem/7067892&gt; [Leopard] Composisted layers are misplaced and squished on on long pages
        &lt;rdar://problem/7068252&gt; [Leopard] When switching to a tab with HW layers, they fade in

        * WebView/WebDynamicScrollBarsView.mm:
        (-[WebDynamicScrollBarsView reflectScrolledClipView:]):
        Call -_updateLayerHostingViewPosition after scrolling.

        * WebView/WebHTMLView.mm:
        (-[WebHTMLView _frameOrBoundsChanged]):
        Call -_updateLayerHostingViewPosition after the view changes size.

        (-[WebHTMLView attachRootLayer:]):
        Turn off default animations, to avoid animations of sublayer transform, and fading-in
        when tab switching.

        * WebView/WebHTMLViewInternal.h:
        (-[WebHTMLView _updateLayerHostingViewPosition]):
        New method that constrains the height of the layer-hosting view to a max height
        of 4096px, and compensates for the height restriction by placing the layer-hosting
        view at the top of the visible part of the WebHTMLView, and adjusting the position
        of the hosted layers via sublayer transform.</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkWebKitmacChangeLog">trunk/WebKit/mac/ChangeLog</a></li>
<li><a href="#trunkWebKitmacWebViewWebDynamicScrollBarsViewmm">trunk/WebKit/mac/WebView/WebDynamicScrollBarsView.mm</a></li>
<li><a href="#trunkWebKitmacWebViewWebHTMLViewmm">trunk/WebKit/mac/WebView/WebHTMLView.mm</a></li>
<li><a href="#trunkWebKitmacWebViewWebHTMLViewInternalh">trunk/WebKit/mac/WebView/WebHTMLViewInternal.h</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkWebKitmacChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/WebKit/mac/ChangeLog (46946 => 46947)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/WebKit/mac/ChangeLog        2009-08-08 03:31:18 UTC (rev 46946)
+++ trunk/WebKit/mac/ChangeLog        2009-08-08 04:08:24 UTC (rev 46947)
</span><span class="lines">@@ -1,3 +1,32 @@
</span><ins>+2009-08-07  Simon Fraser  &lt;simon.fraser@apple.com&gt;
+
+        Reviewed by Dan Bernstein.
+
+        Work around an issue on Leopard where composited layers are misplaced and squished when the page
+        gets over 4096px tall.
+        https://bugs.webkit.org/show_bug.cgi?id=27272
+        &lt;rdar://problem/7067892&gt; [Leopard] Composisted layers are misplaced and squished on on long pages
+        &lt;rdar://problem/7068252&gt; [Leopard] When switching to a tab with HW layers, they fade in
+
+        * WebView/WebDynamicScrollBarsView.mm:
+        (-[WebDynamicScrollBarsView reflectScrolledClipView:]):
+        Call -_updateLayerHostingViewPosition after scrolling.
+        
+        * WebView/WebHTMLView.mm:
+        (-[WebHTMLView _frameOrBoundsChanged]):
+        Call -_updateLayerHostingViewPosition after the view changes size.
+
+        (-[WebHTMLView attachRootLayer:]):
+        Turn off default animations, to avoid animations of sublayer transform, and fading-in
+        when tab switching.
+        
+        * WebView/WebHTMLViewInternal.h:
+        (-[WebHTMLView _updateLayerHostingViewPosition]):
+        New method that constrains the height of the layer-hosting view to a max height
+        of 4096px, and compensates for the height restriction by placing the layer-hosting
+        view at the top of the visible part of the WebHTMLView, and adjusting the position
+        of the hosted layers via sublayer transform.
+
</ins><span class="cx"> 2009-08-07  Anders Carlsson  &lt;andersca@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         Fix Tiger build.
</span></span></pre></div>
<a id="trunkWebKitmacWebViewWebDynamicScrollBarsViewmm"></a>
<div class="modfile"><h4>Modified: trunk/WebKit/mac/WebView/WebDynamicScrollBarsView.mm (46946 => 46947)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/WebKit/mac/WebView/WebDynamicScrollBarsView.mm        2009-08-08 03:31:18 UTC (rev 46946)
+++ trunk/WebKit/mac/WebView/WebDynamicScrollBarsView.mm        2009-08-08 04:08:24 UTC (rev 46947)
</span><span class="lines">@@ -218,6 +218,15 @@
</span><span class="cx">         [[self horizontalScroller] setNeedsDisplay: NO]; 
</span><span class="cx">     }
</span><span class="cx"> #endif
</span><ins>+
+#if USE(ACCELERATED_COMPOSITING) &amp;&amp; defined(BUILDING_ON_LEOPARD)
+    NSView *documentView = [self documentView];
+    if ([documentView isKindOfClass:[WebHTMLView class]]) {
+        WebHTMLView* htmlView = (WebHTMLView*)documentView;
+        if ([htmlView _isUsingAcceleratedCompositing])
+            [htmlView _updateLayerHostingViewPosition];
+    }
+#endif
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> - (BOOL)allowsHorizontalScrolling
</span></span></pre></div>
<a id="trunkWebKitmacWebViewWebHTMLViewmm"></a>
<div class="modfile"><h4>Modified: trunk/WebKit/mac/WebView/WebHTMLView.mm (46946 => 46947)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/WebKit/mac/WebView/WebHTMLView.mm        2009-08-08 03:31:18 UTC (rev 46946)
+++ trunk/WebKit/mac/WebView/WebHTMLView.mm        2009-08-08 04:08:24 UTC (rev 46947)
</span><span class="lines">@@ -1166,6 +1166,10 @@
</span><span class="cx">                                                               _updateMouseoverTimerCallback, &amp;context);
</span><span class="cx">         CFRunLoopAddTimer(CFRunLoopGetCurrent(), _private-&gt;updateMouseoverTimer, kCFRunLoopDefaultMode);
</span><span class="cx">     }
</span><ins>+    
+#if USE(ACCELERATED_COMPOSITING) &amp;&amp; defined(BUILDING_ON_LEOPARD)
+    [self _updateLayerHostingViewPosition];
+#endif
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> - (void)_setAsideSubviews
</span><span class="lines">@@ -5387,7 +5391,9 @@
</span><span class="cx"> {
</span><span class="cx">     if (!_private-&gt;layerHostingView) {
</span><span class="cx">         NSView* hostingView = [[NSView alloc] initWithFrame:[self bounds]];
</span><ins>+#if !defined(BUILDING_ON_LEOPARD)
</ins><span class="cx">         [hostingView setAutoresizingMask:(NSViewWidthSizable | NSViewHeightSizable)];
</span><ins>+#endif
</ins><span class="cx">         [self addSubview:hostingView];
</span><span class="cx">         [hostingView release];
</span><span class="cx">         // hostingView is owned by being a subview of self
</span><span class="lines">@@ -5395,13 +5401,33 @@
</span><span class="cx">         [[self _webView] _startedAcceleratedCompositingForFrame:[self _frame]];
</span><span class="cx">     }
</span><span class="cx"> 
</span><del>-    // Make a container layer, which will get sized/positioned by AppKit and CA
</del><ins>+    // Make a container layer, which will get sized/positioned by AppKit and CA.
</ins><span class="cx">     CALayer* viewLayer = [CALayer layer];
</span><ins>+
+#if defined(BUILDING_ON_LEOPARD)
+    // Turn off default animations.
+    NSNull *nullValue = [NSNull null];
+    NSDictionary *actions = [NSDictionary dictionaryWithObjectsAndKeys:
+                             nullValue, @&quot;anchorPoint&quot;,
+                             nullValue, @&quot;bounds&quot;,
+                             nullValue, @&quot;contents&quot;,
+                             nullValue, @&quot;contentsRect&quot;,
+                             nullValue, @&quot;opacity&quot;,
+                             nullValue, @&quot;position&quot;,
+                             nullValue, @&quot;sublayerTransform&quot;,
+                             nullValue, @&quot;sublayers&quot;,
+                             nullValue, @&quot;transform&quot;,
+                             nil];
+    [viewLayer setStyle:[NSDictionary dictionaryWithObject:actions forKey:@&quot;actions&quot;]];
+#endif
+
</ins><span class="cx">     [_private-&gt;layerHostingView setLayer:viewLayer];
</span><span class="cx">     [_private-&gt;layerHostingView setWantsLayer:YES];
</span><span class="cx">     
</span><span class="cx">     // Parent our root layer in the container layer
</span><span class="cx">     [viewLayer addSublayer:layer];
</span><ins>+    
+    [self _updateLayerHostingViewPosition];
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> - (void)detachRootLayer
</span><span class="lines">@@ -5414,8 +5440,38 @@
</span><span class="cx">         [[self _webView] _stoppedAcceleratedCompositingForFrame:[self _frame]];
</span><span class="cx">     }
</span><span class="cx"> }
</span><del>-#endif
</del><span class="cx"> 
</span><ins>+#if defined(BUILDING_ON_LEOPARD)
+// This method is necessary on Leopard to work around &lt;rdar://problem/7067892&gt;.
+- (void)_updateLayerHostingViewPosition
+{
+    if (!_private-&gt;layerHostingView)
+        return;
+    
+    const CGFloat maxHeight = 4096;
+    NSRect layerViewFrame = [self bounds];
+
+    if (layerViewFrame.size.height &gt; maxHeight) {
+        CGFloat documentHeight = layerViewFrame.size.height;
+            
+        // Clamp the size of the view to &lt;= 4096px to avoid the bug.
+        layerViewFrame.size.height = maxHeight;
+        NSRect visibleRect = [[self enclosingScrollView] documentVisibleRect];
+        
+        // Place the top of the layer-hosting view at the top of the visibleRect.
+        CGFloat topOffset = NSMinY(visibleRect);
+        layerViewFrame.origin.y = topOffset;
+
+        // Compensate for the moved view by adjusting the sublayer transform on the view's layer (using flipped coords).
+        CGFloat bottomOffset = documentHeight - layerViewFrame.size.height - topOffset;
+        [[_private-&gt;layerHostingView layer] setSublayerTransform:CATransform3DMakeTranslation(0, -bottomOffset, 0)];
+    }
+        
+    [_private-&gt;layerHostingView setFrame:layerViewFrame];
+}
+#endif // defined(BUILDING_ON_LEOPARD)
+#endif // USE(ACCELERATED_COMPOSITING)
+
</ins><span class="cx"> @end
</span><span class="cx"> 
</span><span class="cx"> @implementation WebHTMLView (WebNSTextInputSupport)
</span></span></pre></div>
<a id="trunkWebKitmacWebViewWebHTMLViewInternalh"></a>
<div class="modfile"><h4>Modified: trunk/WebKit/mac/WebView/WebHTMLViewInternal.h (46946 => 46947)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/WebKit/mac/WebView/WebHTMLViewInternal.h        2009-08-08 03:31:18 UTC (rev 46946)
+++ trunk/WebKit/mac/WebView/WebHTMLViewInternal.h        2009-08-08 04:08:24 UTC (rev 46947)
</span><span class="lines">@@ -65,4 +65,8 @@
</span><span class="cx"> - (void)detachRootLayer;
</span><span class="cx"> #endif
</span><span class="cx"> 
</span><ins>+#if USE(ACCELERATED_COMPOSITING) &amp;&amp; defined(BUILDING_ON_LEOPARD)
+- (void)_updateLayerHostingViewPosition;
+#endif
+
</ins><span class="cx"> @end
</span></span></pre>
</div>
</div>

</body>
</html>