<!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" /><style type="text/css"><!--
#msg dl { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer { 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 #fc0 solid; padding: 6px; }
#msg ul, pre { overflow: auto; }
#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>
<title>[20741] trunk/WebKitTools</title>
</head>
<body>

<div id="msg">
<dl>
<dt>Revision</dt> <dd><a href="http://trac.webkit.org/projects/webkit/changeset/20741">20741</a></dd>
<dt>Author</dt> <dd>andersca</dd>
<dt>Date</dt> <dd>2007-04-05 18:46:42 -0700 (Thu, 05 Apr 2007)</dd>
</dl>

<h3>Log Message</h3>
<pre>        Reviewed by Maciej.

        Move WebView and NSWindow creation to a separate function in preparation of supporting opening new
        windows in DRT.

        * DumpRenderTree/DumpRenderTree.m:
        (createWebView):
        (dumpRenderTree):</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkWebKitToolsChangeLog">trunk/WebKitTools/ChangeLog</a></li>
<li><a href="#trunkWebKitToolsDumpRenderTreeDumpRenderTreem">trunk/WebKitTools/DumpRenderTree/DumpRenderTree.m</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkWebKitToolsChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/WebKitTools/ChangeLog (20740 => 20741)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/WebKitTools/ChangeLog        2007-04-06 01:05:58 UTC (rev 20740)
+++ trunk/WebKitTools/ChangeLog        2007-04-06 01:46:42 UTC (rev 20741)
</span><span class="lines">@@ -1,3 +1,14 @@
</span><ins>+2007-04-05  Anders Carlsson  &lt;andersca@apple.com&gt;
+
+        Reviewed by Maciej.
+
+        Move WebView and NSWindow creation to a separate function in preparation of supporting opening new
+        windows in DRT.
+
+        * DumpRenderTree/DumpRenderTree.m:
+        (createWebView):
+        (dumpRenderTree):
+
</ins><span class="cx"> 2007-04-03  Anders Carlsson  &lt;andersca@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         Reviewed by Darin.
</span></span></pre></div>
<a id="trunkWebKitToolsDumpRenderTreeDumpRenderTreem"></a>
<div class="modfile"><h4>Modified: trunk/WebKitTools/DumpRenderTree/DumpRenderTree.m (20740 => 20741)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/WebKitTools/DumpRenderTree/DumpRenderTree.m        2007-04-06 01:05:58 UTC (rev 20740)
+++ trunk/WebKitTools/DumpRenderTree/DumpRenderTree.m        2007-04-06 01:46:42 UTC (rev 20741)
</span><span class="lines">@@ -112,6 +112,12 @@
</span><span class="cx"> volatile BOOL done;
</span><span class="cx"> static NavigationController *navigationController;
</span><span class="cx"> 
</span><ins>+// Delegates
+static WaitUntilDoneDelegate *waitUntilDoneDelegate;
+static UIDelegate *uiDelegate;
+static EditingDelegate *editingDelegate;
+static ResourceLoadDelegate *resourceLoadDelegate;
+
</ins><span class="cx"> // Deciding when it's OK to dump out the state is a bit tricky.  All these must be true:
</span><span class="cx"> // - There is no load in progress
</span><span class="cx"> // - There is no work queued up (see workQueue var, below)
</span><span class="lines">@@ -351,6 +357,38 @@
</span><span class="cx">     zone-&gt;realloc = checkedRealloc;
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+WebView *createWebView()
+{
+    NSRect rect = NSMakeRect(0, 0, maxViewWidth, maxViewHeight);
+    WebView *webView = [[WebView alloc] initWithFrame:rect];
+        
+    [webView setUIDelegate:uiDelegate];
+    [webView setFrameLoadDelegate:waitUntilDoneDelegate];
+    [webView setEditingDelegate:editingDelegate];
+    [webView setResourceLoadDelegate:resourceLoadDelegate];
+    
+    // The back/forward cache is causing problems due to layouts during transition from one page to another.
+    // So, turn it off for now, but we might want to turn it back on some day.
+    [[webView backForwardList] setPageCacheSize:0];
+    
+    [webView setContinuousSpellCheckingEnabled:YES];
+    
+    // To make things like certain NSViews, dragging, and plug-ins work, put the WebView a window, but put it off-screen so you don't see it.
+    // Put it at -10000, -10000 in &quot;flipped coordinates&quot;, since WebCore and the DOM use flipped coordinates.
+    NSRect windowRect = NSOffsetRect(rect, -10000, [[[NSScreen screens] objectAtIndex:0] frame].size.height - rect.size.height + 10000);
+    NSWindow *window = [[NSWindow alloc] initWithContentRect:windowRect styleMask:NSBorderlessWindowMask backing:NSBackingStoreBuffered defer:YES];
+    [[window contentView] addSubview:webView];
+    [window orderBack:nil];
+    [window setAutodisplay:NO];
+    
+    // For reasons that are not entirely clear, the following pair of calls makes WebView handle its
+    // dynamic scrollbars properly. Without it, every frame will always have scrollbars.
+    NSBitmapImageRep *imageRep = [webView bitmapImageRepForCachingDisplayInRect:[webView bounds]];
+    [webView cacheDisplayInRect:[webView bounds] toBitmapImageRep:imageRep];
+        
+    return webView;
+}
+
</ins><span class="cx"> void dumpRenderTree(int argc, const char *argv[])
</span><span class="cx"> {    
</span><span class="cx">     [NSApplication sharedApplication];
</span><span class="lines">@@ -420,45 +458,22 @@
</span><span class="cx">     }
</span><span class="cx">     
</span><span class="cx">     localPasteboards = [[NSMutableDictionary alloc] init];
</span><del>-
</del><span class="cx">     navigationController = [[NavigationController alloc] init];
</span><del>-
-    NSRect rect = NSMakeRect(0, 0, maxViewWidth, maxViewHeight);
-    WebView *webView = [[WebView alloc] initWithFrame:rect];
-    frame = [webView mainFrame];
</del><ins>+    waitUntilDoneDelegate = [[WaitUntilDoneDelegate alloc] init];
+    uiDelegate = [[UIDelegate alloc] init];
+    editingDelegate = [[EditingDelegate alloc] init];    
+    resourceLoadDelegate = [[ResourceLoadDelegate alloc] init];
</ins><span class="cx">     
</span><del>-    WaitUntilDoneDelegate *waitUntilDoneDelegate = [[WaitUntilDoneDelegate alloc] init];
-    [webView setFrameLoadDelegate:waitUntilDoneDelegate];
-    
-    UIDelegate *uiDelegate = [[UIDelegate alloc] init];
-    [webView setUIDelegate:uiDelegate];
-
-    EditingDelegate *editingDelegate = [[EditingDelegate alloc] init];
-    [webView setEditingDelegate:editingDelegate];
-    
-    ResourceLoadDelegate *resourceLoadDelegate = [[ResourceLoadDelegate alloc] init];
-    [webView setResourceLoadDelegate:resourceLoadDelegate];
-    
</del><span class="cx">     NSString *pwd = [[NSString stringWithUTF8String:argv[0]] stringByDeletingLastPathComponent];
</span><span class="cx">     [WebPluginDatabase setAdditionalWebPlugInPaths:[NSArray arrayWithObject:pwd]];
</span><span class="cx">     [[WebPluginDatabase sharedDatabase] refresh];
</span><del>-
-    // The back/forward cache is causing problems due to layouts during transition from one page to another.
-    // So, turn it off for now, but we might want to turn it back on some day.
-    [[webView backForwardList] setPageCacheSize:0];
-
-    // To make things like certain NSViews, dragging, and plug-ins work, put the WebView a window, but put it off-screen so you don't see it.
-    // Put it at -10000, -10000 in &quot;flipped coordinates&quot;, since WebCore and the DOM use flipped coordinates.
-    NSRect windowRect = NSOffsetRect(rect, -10000, [[[NSScreen screens] objectAtIndex:0] frame].size.height - rect.size.height + 10000);
-    NSWindow *window = [[NSWindow alloc] initWithContentRect:windowRect styleMask:NSBorderlessWindowMask backing:NSBackingStoreBuffered defer:YES];
-    [[window contentView] addSubview:webView];
-    [window orderBack:nil];
-    [window setAutodisplay:NO];
-
</del><ins>+    
+    WebView *webView = createWebView();    
+    frame = [webView mainFrame];
+    NSWindow *window = [webView window];
+    
</ins><span class="cx">     workQueue = [[NSMutableArray alloc] init];
</span><span class="cx"> 
</span><del>-    [webView setContinuousSpellCheckingEnabled:YES];
-
</del><span class="cx">     makeLargeMallocFailSilently();
</span><span class="cx"> 
</span><span class="cx">     signal(SIGILL, crashHandler);    /* 4:   illegal instruction (not reset when caught) */
</span><span class="lines">@@ -474,11 +489,6 @@
</span><span class="cx">     
</span><span class="cx">     [[NSURLCache sharedURLCache] removeAllCachedResponses];
</span><span class="cx">     
</span><del>-    // For reasons that are not entirely clear, the following pair of calls makes WebView handle its
-    // dynamic scrollbars properly. Without it, every frame will always have scrollbars.
-    NSBitmapImageRep *imageRep = [webView bitmapImageRepForCachingDisplayInRect:[webView bounds]];
-    [webView cacheDisplayInRect:[webView bounds] toBitmapImageRep:imageRep];
-
</del><span class="cx">     if (threaded)
</span><span class="cx">         startJavaScriptThreads();
</span><span class="cx">     
</span></span></pre>
</div>
</div>

</body>
</html>