WebCore:
authorthatcher <thatcher@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 21 Jan 2006 03:05:26 +0000 (03:05 +0000)
committerthatcher <thatcher@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 21 Jan 2006 03:05:26 +0000 (03:05 +0000)
        Reviewed by John.

        Removes code that is no longer needed with the new Web Inspector.

        * bridge/mac/WebCoreFrameBridge.h: removes the WebCoreDOMTreeCopier protocol.
        * bridge/mac/WebCoreFrameBridge.mm: removes copyDOMNode:copier:

WebKit:

        Reviewed by John, some parts by Darin.

        Removes the old WebDebugDOMNode code, superseded by the ObjC DOM and the Web Inspector.
        Since Safari 2.0 still relies on these classes for the Debug menu's "Show DOM Tree", we remove
        that menu item to prevent a crash.

        * WebKit.exp: adds WebInspector, removes WebDebugDOMNode
        * WebKit.xcodeproj/project.pbxproj: added the REMOVE_SAFARI_DOM_TREE_DEBUG_ITEM define so the new WebView code doesn't build in the Default config
        * WebView.subproj/WebDebugDOMNode.h: Removed.
        * WebView.subproj/WebDebugDOMNode.m: Removed.
        * WebView.subproj/WebView.m:
        (+[WebView initialize]): check if we are in Safari and IncludeDebugMenu is true then observe for NSApplicationDidFinishLaunchingNotification and call _finishedLaunching
        (+[WebView _finishedLaunching]): observe for NSMenuDidAddItemNotification now that the main menu is loaded and wait for the Debug menu to be added
        (+[WebView _removeDOMTreeMenuItem:]): when the debug menu is added remove the "Show DOM Tree" item

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@12269 268f45cc-cd09-0410-ab3c-d52691b4dbfc

WebCore/ChangeLog
WebCore/bridge/mac/WebCoreFrameBridge.h
WebCore/bridge/mac/WebCoreFrameBridge.mm
WebKit/ChangeLog
WebKit/WebKit.exp
WebKit/WebKit.xcodeproj/project.pbxproj
WebKit/WebView.subproj/WebDebugDOMNode.h [deleted file]
WebKit/WebView.subproj/WebDebugDOMNode.m [deleted file]
WebKit/WebView.subproj/WebView.m

index 6be8d07..e93c8a1 100644 (file)
@@ -1,3 +1,12 @@
+2006-01-20  Timothy Hatcher  <timothy@apple.com>
+
+        Reviewed by John.
+
+        Removes code that is no longer needed with the new Web Inspector.
+
+        * bridge/mac/WebCoreFrameBridge.h: removes the WebCoreDOMTreeCopier protocol.
+        * bridge/mac/WebCoreFrameBridge.mm: removes copyDOMNode:copier:
+
 2006-01-21  Anders Carlsson  <andersca@mac.com>
 
         Reviewed by David Hyatt.
index 6c66ea2..261dd18 100644 (file)
@@ -64,7 +64,6 @@ typedef khtml::RenderPart KHTMLRenderPart;
 @class WebCoreSettings;
 @class WebScriptObject;
 
-@protocol WebCoreDOMTreeCopier;
 @protocol WebCoreRenderTreeCopier;
 @protocol WebCoreResourceHandle;
 @protocol WebCoreResourceLoader;
@@ -310,7 +309,6 @@ typedef enum
 - (NSView *)nextKeyViewInsideWebFrameViews;
 - (NSView *)previousKeyViewInsideWebFrameViews;
 
-- (NSObject *)copyDOMTree:(id <WebCoreDOMTreeCopier>)copier;
 - (NSObject *)copyRenderTree:(id <WebCoreRenderTreeCopier>)copier;
 - (NSString *)renderTreeAsExternalRepresentation;
 
@@ -684,10 +682,6 @@ typedef enum
 @interface WebCoreFrameBridge (SubclassResponsibility) <WebCoreFrameBridge>
 @end
 
-@protocol WebCoreDOMTreeCopier <NSObject>
-- (NSObject *)nodeWithName:(NSString *)name value:(NSString *)value source:(NSString *)source children:(NSArray *)children;
-@end
-
 @protocol WebCoreRenderTreeCopier <NSObject>
 - (NSObject *)nodeWithName:(NSString *)name position:(NSPoint)p rect:(NSRect)rect view:(NSView *)view children:(NSArray *)children;
 @end
index 58ceeb8..8dd78d0 100644 (file)
@@ -1049,29 +1049,6 @@ static BOOL nowPrinting(WebCoreFrameBridge *self)
     [self _setupRootForPrinting:NO];
 }
 
-- (NSObject *)copyDOMNode:(NodeImpl *)node copier:(id <WebCoreDOMTreeCopier>)copier
-{
-    NSMutableArray *children = [[NSMutableArray alloc] init];
-    for (NodeImpl *child = node->firstChild(); child; child = child->nextSibling()) {
-        [children addObject:[self copyDOMNode:child copier:copier]];
-    }
-    NSObject *copiedNode = [copier nodeWithName:node->nodeName().qstring().getNSString()
-                                          value:node->nodeValue().qstring().getNSString()
-                                         source:createMarkup(node, ChildrenOnly).getNSString()
-                                       children:children];
-    [children release];
-    return copiedNode;
-}
-
-- (NSObject *)copyDOMTree:(id <WebCoreDOMTreeCopier>)copier
-{
-    DocumentImpl *doc = m_frame->document();
-    if (!doc) {
-        return nil;
-    }
-    return [self copyDOMNode:doc copier:copier];
-}
-
 - (NSObject *)copyRenderNode:(RenderObject *)node copier:(id <WebCoreRenderTreeCopier>)copier
 {
     NSMutableArray *children = [[NSMutableArray alloc] init];
index a19528d..435f1af 100644 (file)
@@ -1,5 +1,22 @@
 2006-01-20  Timothy Hatcher  <timothy@apple.com>
 
+        Reviewed by John, some parts by Darin.
+
+        Removes the old WebDebugDOMNode code, superseded by the ObjC DOM and the Web Inspector.
+        Since Safari 2.0 still relies on these classes for the Debug menu's "Show DOM Tree", we remove
+        that menu item to prevent a crash.
+
+        * WebKit.exp: adds WebInspector, removes WebDebugDOMNode
+        * WebKit.xcodeproj/project.pbxproj: added the REMOVE_SAFARI_DOM_TREE_DEBUG_ITEM define so the new WebView code doesn't build in the Default config
+        * WebView.subproj/WebDebugDOMNode.h: Removed.
+        * WebView.subproj/WebDebugDOMNode.m: Removed.
+        * WebView.subproj/WebView.m:
+        (+[WebView initialize]): check if we are in Safari and IncludeDebugMenu is true then observe for NSApplicationDidFinishLaunchingNotification and call _finishedLaunching
+        (+[WebView _finishedLaunching]): observe for NSMenuDidAddItemNotification now that the main menu is loaded and wait for the Debug menu to be added
+        (+[WebView _removeDOMTreeMenuItem:]): when the debug menu is added remove the "Show DOM Tree" item
+
+2006-01-20  Timothy Hatcher  <timothy@apple.com>
+
         Reviewed by Hyatt.
 
         Corrects the cascade order for mapped attributes.
index 501eed6..88af1d9 100644 (file)
@@ -3,7 +3,6 @@
 .objc_class_name_WebBackForwardList
 .objc_class_name_WebCoreStatistics
 .objc_class_name_WebDataSource
-.objc_class_name_WebDebugDOMNode
 .objc_class_name_WebDefaultPolicyDelegate
 .objc_class_name_WebDownload
 .objc_class_name_WebDynamicScrollBarsView
@@ -16,6 +15,7 @@
 .objc_class_name_WebHistoryItem
 .objc_class_name_WebIconDatabase
 .objc_class_name_WebIconLoader
+.objc_class_name_WebInspector
 .objc_class_name_WebJavaScriptTextInputPanel
 .objc_class_name_WebKeyGenerator
 .objc_class_name_WebKitStatistics
index 5fe4469..fc807ad 100644 (file)
@@ -96,7 +96,6 @@
                939810490824BF01008DF038 /* WebClipView.h in Headers */ = {isa = PBXBuildFile; fileRef = 933D659903413FF2008635CE /* WebClipView.h */; };
                9398104B0824BF01008DF038 /* WebDataSource.h in Headers */ = {isa = PBXBuildFile; fileRef = 39446070020F50ED0ECA1767 /* WebDataSource.h */; settings = {ATTRIBUTES = (Public, ); }; };
                9398104C0824BF01008DF038 /* WebDataSourcePrivate.h in Headers */ = {isa = PBXBuildFile; fileRef = 39446072020F50ED0ECA1767 /* WebDataSourcePrivate.h */; settings = {ATTRIBUTES = (Private, ); }; };
-               9398104D0824BF01008DF038 /* WebDebugDOMNode.h in Headers */ = {isa = PBXBuildFile; fileRef = F57FB8C4034E180101A80180 /* WebDebugDOMNode.h */; settings = {ATTRIBUTES = (Private, ); }; };
                9398104E0824BF01008DF038 /* WebDefaultContextMenuDelegate.h in Headers */ = {isa = PBXBuildFile; fileRef = 5152FADD033FC50400CA2ACD /* WebDefaultContextMenuDelegate.h */; settings = {ATTRIBUTES = (); }; };
                9398104F0824BF01008DF038 /* WebDefaultPolicyDelegate.h in Headers */ = {isa = PBXBuildFile; fileRef = 5152FADF033FC50400CA2ACD /* WebDefaultPolicyDelegate.h */; settings = {ATTRIBUTES = (Private, ); }; };
                939810500824BF01008DF038 /* WebDocument.h in Headers */ = {isa = PBXBuildFile; fileRef = 35081DAE02B6D4F50ACA2ACA /* WebDocument.h */; settings = {ATTRIBUTES = (Public, ); }; };
                939810EA0824BF01008DF038 /* WebLoader.m in Sources */ = {isa = PBXBuildFile; fileRef = 51F6866D0366057300CA2D3A /* WebLoader.m */; };
                939810EB0824BF01008DF038 /* WebClipView.m in Sources */ = {isa = PBXBuildFile; fileRef = 933D659A03413FF2008635CE /* WebClipView.m */; };
                939810ED0824BF01008DF038 /* WebDataSource.m in Sources */ = {isa = PBXBuildFile; fileRef = 39446071020F50ED0ECA1767 /* WebDataSource.m */; };
-               939810EE0824BF01008DF038 /* WebDebugDOMNode.m in Sources */ = {isa = PBXBuildFile; fileRef = F57FB8C5034E180101A80180 /* WebDebugDOMNode.m */; };
                939810EF0824BF01008DF038 /* WebDefaultContextMenuDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 5152FADE033FC50400CA2ACD /* WebDefaultContextMenuDelegate.m */; };
                939810F00824BF01008DF038 /* WebDefaultPolicyDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 5152FAE0033FC50400CA2ACD /* WebDefaultPolicyDelegate.m */; };
                939810F10824BF01008DF038 /* WebDynamicScrollBarsView.m in Sources */ = {isa = PBXBuildFile; fileRef = 3944606C020F50ED0ECA1767 /* WebDynamicScrollBarsView.m */; };
                F5488CF502CB04EE01FF6274 /* WebCookieAdapter.m */ = {isa = PBXFileReference; fileEncoding = 4; indentWidth = 4; lastKnownFileType = sourcecode.c.objc; path = WebCookieAdapter.m; sourceTree = "<group>"; tabWidth = 8; usesTabs = 0; };
                F560BEBC030DAF4401C1A526 /* WebSearchableTextView.h */ = {isa = PBXFileReference; fileEncoding = 4; indentWidth = 4; lastKnownFileType = sourcecode.c.h; path = WebSearchableTextView.h; sourceTree = "<group>"; tabWidth = 8; usesTabs = 0; };
                F560BEBD030DAF4401C1A526 /* WebSearchableTextView.m */ = {isa = PBXFileReference; fileEncoding = 4; indentWidth = 4; lastKnownFileType = sourcecode.c.objc; path = WebSearchableTextView.m; sourceTree = "<group>"; tabWidth = 8; usesTabs = 0; };
-               F57FB8C4034E180101A80180 /* WebDebugDOMNode.h */ = {isa = PBXFileReference; fileEncoding = 4; indentWidth = 4; lastKnownFileType = sourcecode.c.h; name = WebDebugDOMNode.h; path = ../WebView.subproj/WebDebugDOMNode.h; sourceTree = "<group>"; tabWidth = 8; usesTabs = 0; };
-               F57FB8C5034E180101A80180 /* WebDebugDOMNode.m */ = {isa = PBXFileReference; fileEncoding = 4; indentWidth = 4; lastKnownFileType = sourcecode.c.objc; name = WebDebugDOMNode.m; path = ../WebView.subproj/WebDebugDOMNode.m; sourceTree = "<group>"; tabWidth = 8; usesTabs = 0; };
                F5883BDE025E5C6A01000102 /* nullplugin.tiff */ = {isa = PBXFileReference; lastKnownFileType = image.tiff; name = nullplugin.tiff; path = Resources/nullplugin.tiff; sourceTree = "<group>"; };
                F5883BE0025E5E9D01000102 /* WebNullPluginView.h */ = {isa = PBXFileReference; fileEncoding = 4; indentWidth = 4; lastKnownFileType = sourcecode.c.h; path = WebNullPluginView.h; sourceTree = "<group>"; tabWidth = 8; usesTabs = 0; };
                F5883BE1025E5E9D01000102 /* WebNullPluginView.m */ = {isa = PBXFileReference; fileEncoding = 4; indentWidth = 4; lastKnownFileType = sourcecode.c.objc; path = WebNullPluginView.m; sourceTree = "<group>"; tabWidth = 8; usesTabs = 0; };
                                BEE18F930472A0CF00CA289C /* WebAssertions.m */,
                                F59EAE3E0253C7EE018635CA /* WebCoreStatistics.h */,
                                F59EAE410253C8DE018635CA /* WebCoreStatistics.m */,
-                               F57FB8C4034E180101A80180 /* WebDebugDOMNode.h */,
-                               F57FB8C5034E180101A80180 /* WebDebugDOMNode.m */,
                                93AEB17D032C1735008635CE /* WebKitLogging.h */,
                                93AEB17E032C1735008635CE /* WebKitLogging.m */,
                                F53444CE02E87CBA018635CA /* WebKitStatistics.h */,
                                939810490824BF01008DF038 /* WebClipView.h in Headers */,
                                9398104B0824BF01008DF038 /* WebDataSource.h in Headers */,
                                9398104C0824BF01008DF038 /* WebDataSourcePrivate.h in Headers */,
-                               9398104D0824BF01008DF038 /* WebDebugDOMNode.h in Headers */,
                                9398104E0824BF01008DF038 /* WebDefaultContextMenuDelegate.h in Headers */,
                                9398104F0824BF01008DF038 /* WebDefaultPolicyDelegate.h in Headers */,
                                939810500824BF01008DF038 /* WebDocument.h in Headers */,
                                939810EA0824BF01008DF038 /* WebLoader.m in Sources */,
                                939810EB0824BF01008DF038 /* WebClipView.m in Sources */,
                                939810ED0824BF01008DF038 /* WebDataSource.m in Sources */,
-                               939810EE0824BF01008DF038 /* WebDebugDOMNode.m in Sources */,
                                939810EF0824BF01008DF038 /* WebDefaultContextMenuDelegate.m in Sources */,
                                939810F00824BF01008DF038 /* WebDefaultPolicyDelegate.m in Sources */,
                                939810F10824BF01008DF038 /* WebDynamicScrollBarsView.m in Sources */,
                        buildSettings = {
                                GCC_OPTIMIZATION_LEVEL = 2;
                                GCC_THREADSAFE_STATICS = NO;
-                               PER_CONFIGURATION_PREPROCESSOR_DEFINES = ENABLE_WEBKIT_UNSET_DYLD_FRAMEWORK_PATH;
+                               PER_CONFIGURATION_PREPROCESSOR_DEFINES = "ENABLE_WEBKIT_UNSET_DYLD_FRAMEWORK_PATH REMOVE_SAFARI_DOM_TREE_DEBUG_ITEM";
                        };
                        name = Development;
                };
                        isa = XCBuildConfiguration;
                        buildSettings = {
                                GCC_THREADSAFE_STATICS = NO;
-                               PER_CONFIGURATION_PREPROCESSOR_DEFINES = ENABLE_WEBKIT_UNSET_DYLD_FRAMEWORK_PATH;
+                               PER_CONFIGURATION_PREPROCESSOR_DEFINES = "ENABLE_WEBKIT_UNSET_DYLD_FRAMEWORK_PATH REMOVE_SAFARI_DOM_TREE_DEBUG_ITEM";
                        };
                        name = Deployment;
                };
                        isa = XCBuildConfiguration;
                        buildSettings = {
                                GCC_THREADSAFE_STATICS = NO;
-                               PER_CONFIGURATION_PREPROCESSOR_DEFINES = ENABLE_WEBKIT_UNSET_DYLD_FRAMEWORK_PATH;
+                               PER_CONFIGURATION_PREPROCESSOR_DEFINES = "ENABLE_WEBKIT_UNSET_DYLD_FRAMEWORK_PATH REMOVE_SAFARI_DOM_TREE_DEBUG_ITEM";
                        };
                        name = OptimizedWithSymbols;
                };
diff --git a/WebKit/WebView.subproj/WebDebugDOMNode.h b/WebKit/WebView.subproj/WebDebugDOMNode.h
deleted file mode 100644 (file)
index 54d6612..0000000
+++ /dev/null
@@ -1,48 +0,0 @@
-/*
- * Copyright (C) 2005 Apple Computer, Inc.  All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1.  Redistributions of source code must retain the above copyright
- *     notice, this list of conditions and the following disclaimer. 
- * 2.  Redistributions in binary form must reproduce the above copyright
- *     notice, this list of conditions and the following disclaimer in the
- *     documentation and/or other materials provided with the distribution. 
- * 3.  Neither the name of Apple Computer, Inc. ("Apple") nor the names of
- *     its contributors may be used to endorse or promote products derived
- *     from this software without specific prior written permission. 
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
- * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#import <Foundation/Foundation.h>
-
-@class WebFrameView;
-
-@interface WebDebugDOMNode : NSObject
-{
-    NSArray *children;
-    NSString *name;
-    NSString *value;
-    NSString *source;
-}
-
-- (id)initWithWebFrameView:(WebFrameView *)view;
-
-- (NSArray *)children;
-- (NSString *)name;
-- (NSString *)value;
-- (NSString *)source;
-
-@end
diff --git a/WebKit/WebView.subproj/WebDebugDOMNode.m b/WebKit/WebView.subproj/WebDebugDOMNode.m
deleted file mode 100644 (file)
index 29cce7c..0000000
+++ /dev/null
@@ -1,112 +0,0 @@
-/*
- * Copyright (C) 2005 Apple Computer, Inc.  All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1.  Redistributions of source code must retain the above copyright
- *     notice, this list of conditions and the following disclaimer. 
- * 2.  Redistributions in binary form must reproduce the above copyright
- *     notice, this list of conditions and the following disclaimer in the
- *     documentation and/or other materials provided with the distribution. 
- * 3.  Neither the name of Apple Computer, Inc. ("Apple") nor the names of
- *     its contributors may be used to endorse or promote products derived
- *     from this software without specific prior written permission. 
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
- * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#import "WebDebugDOMNode.h"
-
-#import <WebKit/WebFrameBridge.h>
-#import <WebKit/WebFrameView.h>
-#import <WebKit/WebHTMLViewPrivate.h>
-#import <WebKit/WebNSViewExtras.h>
-
-@interface WebKitDOMTreeCopier : NSObject <WebCoreDOMTreeCopier>
-@end
-
-@implementation WebDebugDOMNode
-
-- initWithName:(NSString *)n value:(NSString *)v source:(NSString *)s children:(NSArray *)c
-{
-    self = [super init];
-    if (!self)
-        return nil;
-
-    children = [c copy];
-    name = [n copy];
-    value = [v copy];
-    source = [s copy];
-    
-    return self;
-}
-
-- initWithWebFrameView:(WebFrameView *)view
-{
-    WebKitDOMTreeCopier *copier;
-    
-    [self release];
-
-    if (![[view documentView] isMemberOfClass:[WebHTMLView class]]) {
-        return nil;
-    }
-    
-    copier = [[WebKitDOMTreeCopier alloc] init];
-    WebHTMLView *htmlView = (WebHTMLView *)[view documentView];
-    self = [[[htmlView _bridge] copyDOMTree:copier] retain];
-    [copier release];
-    
-    return self;
-}
-
-- (void)dealloc
-{
-    [children release];
-    [name release];
-    [value release];
-    [source release];
-    
-    [super dealloc];
-}
-
-- (NSArray *)children
-{
-    return children;
-}
-
-- (NSString *)name
-{
-    return name;
-}
-
-- (NSString *)value
-{
-    return value;
-}
-
-- (NSString *)source
-{
-    return source;
-}
-
-@end
-
-@implementation WebKitDOMTreeCopier
-
-- (NSObject *)nodeWithName:(NSString *)n value:(NSString *)v source:(NSString *)s children:(NSArray *)c
-{
-    return [[[WebDebugDOMNode alloc] initWithName:n value:v source:s children:c] autorelease];
-}
-
-@end
index 9c21885..ca57552 100644 (file)
@@ -1501,6 +1501,35 @@ NSMutableDictionary *countInvocations;
 
 @implementation WebView
 
+#if REMOVE_SAFARI_DOM_TREE_DEBUG_ITEM
+// this prevents open source users from crashing when using the Show DOM Tree menu item in Safari
+// FIXME: remove this when it is no longer needed to prevent Safari from crashing
++(void)initialize
+{
+    static BOOL tooLate = NO;
+    if (!tooLate) {
+        if ([[[NSBundle mainBundle] bundleIdentifier] isEqualToString:@"com.apple.Safari"] && [[NSUserDefaults standardUserDefaults] boolForKey:@"IncludeDebugMenu"])
+            [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(_finishedLaunching) name:NSApplicationDidFinishLaunchingNotification object:NSApp];
+        tooLate = YES;
+    }
+}
+
++(void)_finishedLaunching
+{
+    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(_removeDOMTreeMenuItem:) name:NSMenuDidAddItemNotification object:[NSApp mainMenu]];
+    [[NSNotificationCenter defaultCenter] removeObserver:self name:NSApplicationDidFinishLaunchingNotification object:NSApp];
+}
+
++(void)_removeDOMTreeMenuItem:(NSNotification *)notification
+{
+    NSMenu *debugMenu = [[[[NSApp mainMenu] itemArray] lastObject] submenu];
+    NSMenuItem *domTree = [debugMenu itemWithTitle:@"Show DOM Tree"];
+    if (domTree)
+        [debugMenu removeItem:domTree];
+    [[NSNotificationCenter defaultCenter] removeObserver:self name:NSMenuDidAddItemNotification object:[NSApp mainMenu]];
+}
+#endif
+
 + (BOOL)canShowMIMEType:(NSString *)MIMEType
 {
     return [self _viewClass:nil andRepresentationClass:nil forMIMEType:MIMEType];