[SCM] WebKit Debian packaging branch, debian/unstable, updated. debian/1.1.15-1-40151-g37bb677

kocienda kocienda at 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Sat Sep 26 08:43:46 UTC 2009


The following commit has been merged in the debian/unstable branch:
commit b198c640355dc5f58423c5ba2b7808420c0b2f1e
Author: kocienda <kocienda at 268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date:   Fri Jun 4 18:17:26 2004 +0000

            Reviewed by Hyatt
    
            Made some progress on this set of related bugs:
    
            <rdar://problem/3675867>: "Make execCommand work as specified in the Javascript execCommand Compatibility Plan"
            <rdar://problem/3675898>: "Make queryCommandEnabled work as specified in the Javascript execCommand Compatibility Plan"
            <rdar://problem/3675899>: "Make queryCommandIndeterm work as specified in the Javascript execCommand Compatibility Plan"
            <rdar://problem/3675901>: "Make queryCommandState work as specified in the Javascript execCommand Compatibility Plan"
            <rdar://problem/3675903>: "Make queryCommandSupported work as specified in the Javascript execCommand Compatibility Plan"
            <rdar://problem/3675904>: "Make queryCommandValue work as specified in the Javascript execCommand Compatibility Plan"
    
            I did several things to move the ahead with the plan:
    
            1. The latter five methods did not appear in the tree at all. Now they do, although
    
            2. I removed the implementation for these editing methods from dom_docimpl.cpp, and moved
               them out to new js_editing.cpp/js_editing.h files. The remaining code in dom_docimpl.cpp
               is glue to call over to the new JSEditor object defined in the new files.
    
            3. For a couple of the command implementations in js_editing.cpp, I made a stab at returning sensible values.
               For others, I just return place-holder values. I have added some comments to describe what has been done and
               what still needs to be done.
    
            * WebCore.pbproj/project.pbxproj:
            * khtml/dom/dom_doc.cpp: Add call-overs for these methods.
            (DOM::Document::queryCommandEnabled):
            (DOM::Document::queryCommandIndeterm):
            (DOM::Document::queryCommandState):
            (DOM::Document::queryCommandSupported):
            (DOM::Document::queryCommandValue):
            * khtml/dom/dom_doc.h:
            * khtml/ecma/kjs_dom.cpp: Add queryCommandXXX terminology.
            (DOMDocumentProtoFunc::tryCall):
            * khtml/ecma/kjs_dom.h:
            (KJS::DOMDocument::):
            * khtml/ecma/kjs_dom.lut.h:
            (KJS::):
            * khtml/editing/jsediting.cpp: Added. This file implements the guts of editing-related JS methods.
            (DOM::execCommandNotImplemented):
            (DOM::queryBoolNotImplemented):
            (DOM::queryValueNotImplemented):
            (DOM::JSEditor::commandDict):
            (DOM::JSEditor::JSEditor):
            (DOM::JSEditor::~JSEditor):
            (DOM::JSEditor::commandIdentifier):
            (DOM::JSEditor::addCommand):
            (DOM::JSEditor::initDict):
            (DOM::JSEditor::execCommand):
            (DOM::JSEditor::queryCommandEnabled):
            (DOM::JSEditor::queryCommandIndeterm):
            (DOM::JSEditor::queryCommandState):
            (DOM::JSEditor::queryCommandSupported):
            (DOM::JSEditor::queryCommandValue):
            (DOM::JSEditor::execCommandCopy):
            (DOM::JSEditor::execCommandCut):
            (DOM::JSEditor::execCommandDelete):
            (DOM::JSEditor::execCommandInsertText):
            (DOM::JSEditor::execCommandPaste):
            (DOM::JSEditor::execCommandRedo):
            (DOM::JSEditor::execCommandSelectAll):
            (DOM::JSEditor::execCommandUndo):
            (DOM::JSEditor::enabledIfPartNotNull):
            (DOM::JSEditor::enabledIfSelectionNotEmpty):
            (DOM::JSEditor::enabledIfSelectionIsRange):
            (DOM::JSEditor::commandSupported):
            * khtml/editing/jsediting.h: Added.
            (DOM::JSEditor::CommandIdentifier::CommandIdentifier):
            (DOM::JSEditor::document):
            (DOM::JSEditor::part):
            * khtml/xml/dom_docimpl.cpp: Rework JS editing support into glue that calls over into new JSEditor object.
            (DocumentImpl::DocumentImpl):
            (DocumentImpl::~DocumentImpl):
            (DocumentImpl::jsEditor):
            (DocumentImpl::execCommand):
            (DocumentImpl::queryCommandEnabled):
            (DocumentImpl::queryCommandIndeterm):
            (DocumentImpl::queryCommandState):
            (DocumentImpl::queryCommandSupported):
            (DocumentImpl::queryCommandValue):
            * khtml/xml/dom_docimpl.h:
    
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@6765 268f45cc-cd09-0410-ab3c-d52691b4dbfc

diff --git a/WebCore/ChangeLog-2005-08-23 b/WebCore/ChangeLog-2005-08-23
index d56d208..12b8cd8 100644
--- a/WebCore/ChangeLog-2005-08-23
+++ b/WebCore/ChangeLog-2005-08-23
@@ -1,3 +1,86 @@
+2004-06-04  Ken Kocienda  <kocienda at apple.com>
+
+        Reviewed by Hyatt
+
+        Made some progress on this set of related bugs:
+        
+        <rdar://problem/3675867>: "Make execCommand work as specified in the Javascript execCommand Compatibility Plan"
+        <rdar://problem/3675898>: "Make queryCommandEnabled work as specified in the Javascript execCommand Compatibility Plan"
+        <rdar://problem/3675899>: "Make queryCommandIndeterm work as specified in the Javascript execCommand Compatibility Plan"
+        <rdar://problem/3675901>: "Make queryCommandState work as specified in the Javascript execCommand Compatibility Plan"
+        <rdar://problem/3675903>: "Make queryCommandSupported work as specified in the Javascript execCommand Compatibility Plan"
+        <rdar://problem/3675904>: "Make queryCommandValue work as specified in the Javascript execCommand Compatibility Plan"
+        
+        I did several things to move the ahead with the plan:
+        
+        1. The latter five methods did not appear in the tree at all. Now they do, although
+        
+        2. I removed the implementation for these editing methods from dom_docimpl.cpp, and moved
+           them out to new js_editing.cpp/js_editing.h files. The remaining code in dom_docimpl.cpp
+           is glue to call over to the new JSEditor object defined in the new files.
+           
+        3. For a couple of the command implementations in js_editing.cpp, I made a stab at returning sensible values.
+           For others, I just return place-holder values. I have added some comments to describe what has been done and
+           what still needs to be done. 
+
+        * WebCore.pbproj/project.pbxproj:
+        * khtml/dom/dom_doc.cpp: Add call-overs for these methods.
+        (DOM::Document::queryCommandEnabled):
+        (DOM::Document::queryCommandIndeterm):
+        (DOM::Document::queryCommandState):
+        (DOM::Document::queryCommandSupported):
+        (DOM::Document::queryCommandValue):
+        * khtml/dom/dom_doc.h:
+        * khtml/ecma/kjs_dom.cpp: Add queryCommandXXX terminology.
+        (DOMDocumentProtoFunc::tryCall):
+        * khtml/ecma/kjs_dom.h:
+        (KJS::DOMDocument::):
+        * khtml/ecma/kjs_dom.lut.h:
+        (KJS::):
+        * khtml/editing/jsediting.cpp: Added. This file implements the guts of editing-related JS methods.
+        (DOM::execCommandNotImplemented):
+        (DOM::queryBoolNotImplemented):
+        (DOM::queryValueNotImplemented):
+        (DOM::JSEditor::commandDict):
+        (DOM::JSEditor::JSEditor):
+        (DOM::JSEditor::~JSEditor):
+        (DOM::JSEditor::commandIdentifier):
+        (DOM::JSEditor::addCommand):
+        (DOM::JSEditor::initDict):
+        (DOM::JSEditor::execCommand):
+        (DOM::JSEditor::queryCommandEnabled):
+        (DOM::JSEditor::queryCommandIndeterm):
+        (DOM::JSEditor::queryCommandState):
+        (DOM::JSEditor::queryCommandSupported):
+        (DOM::JSEditor::queryCommandValue):
+        (DOM::JSEditor::execCommandCopy):
+        (DOM::JSEditor::execCommandCut):
+        (DOM::JSEditor::execCommandDelete):
+        (DOM::JSEditor::execCommandInsertText):
+        (DOM::JSEditor::execCommandPaste):
+        (DOM::JSEditor::execCommandRedo):
+        (DOM::JSEditor::execCommandSelectAll):
+        (DOM::JSEditor::execCommandUndo):
+        (DOM::JSEditor::enabledIfPartNotNull):
+        (DOM::JSEditor::enabledIfSelectionNotEmpty):
+        (DOM::JSEditor::enabledIfSelectionIsRange):
+        (DOM::JSEditor::commandSupported):
+        * khtml/editing/jsediting.h: Added.
+        (DOM::JSEditor::CommandIdentifier::CommandIdentifier):
+        (DOM::JSEditor::document):
+        (DOM::JSEditor::part):
+        * khtml/xml/dom_docimpl.cpp: Rework JS editing support into glue that calls over into new JSEditor object.
+        (DocumentImpl::DocumentImpl):
+        (DocumentImpl::~DocumentImpl):
+        (DocumentImpl::jsEditor):
+        (DocumentImpl::execCommand):
+        (DocumentImpl::queryCommandEnabled):
+        (DocumentImpl::queryCommandIndeterm):
+        (DocumentImpl::queryCommandState):
+        (DocumentImpl::queryCommandSupported):
+        (DocumentImpl::queryCommandValue):
+        * khtml/xml/dom_docimpl.h:
+
 2004-06-03  Richard Williamson   <rjw at apple.com>
 
 	Added setCompositeOperation method to Context2D.
diff --git a/WebCore/WebCore.pbproj/project.pbxproj b/WebCore/WebCore.pbproj/project.pbxproj
index d0ae7e9..41ef021 100644
--- a/WebCore/WebCore.pbproj/project.pbxproj
+++ b/WebCore/WebCore.pbproj/project.pbxproj
@@ -533,6 +533,7 @@
 				51F6A3E00663C2EC004D2919,
 				2D90660D0665D937006B6F1A,
 				BE02F484066E1C550013A9F6,
+				BE02D4E8066F908A0076809F,
 			);
 			isa = PBXHeadersBuildPhase;
 			runOnlyForDeploymentPostprocessing = 0;
@@ -816,6 +817,7 @@
 				51F6A3DF0663C2EC004D2919,
 				2D90660E0665D937006B6F1A,
 				BE02F485066E1C550013A9F6,
+				BE02D4E9066F908A0076809F,
 			);
 			isa = PBXSourcesBuildPhase;
 			runOnlyForDeploymentPostprocessing = 0;
@@ -2847,6 +2849,36 @@
 //BE2
 //BE3
 //BE4
+		BE02D4E6066F908A0076809F = {
+			fileEncoding = 30;
+			isa = PBXFileReference;
+			lastKnownFileType = sourcecode.c.h;
+			name = jsediting.h;
+			path = editing/jsediting.h;
+			refType = 4;
+			sourceTree = "<group>";
+		};
+		BE02D4E7066F908A0076809F = {
+			fileEncoding = 30;
+			isa = PBXFileReference;
+			lastKnownFileType = sourcecode.cpp.cpp;
+			name = jsediting.cpp;
+			path = editing/jsediting.cpp;
+			refType = 4;
+			sourceTree = "<group>";
+		};
+		BE02D4E8066F908A0076809F = {
+			fileRef = BE02D4E6066F908A0076809F;
+			isa = PBXBuildFile;
+			settings = {
+			};
+		};
+		BE02D4E9066F908A0076809F = {
+			fileRef = BE02D4E7066F908A0076809F;
+			isa = PBXBuildFile;
+			settings = {
+			};
+		};
 		BE02F482066E1C550013A9F6 = {
 			fileEncoding = 30;
 			isa = PBXFileReference;
@@ -3185,6 +3217,8 @@
 				BE9185DD05EE59B80081354D,
 				BE9185DE05EE59B80081354D,
 				BE9185DF05EE59B80081354D,
+				BE02D4E6066F908A0076809F,
+				BE02D4E7066F908A0076809F,
 			);
 			isa = PBXGroup;
 			name = editing;
diff --git a/WebCore/khtml/dom/dom_doc.cpp b/WebCore/khtml/dom/dom_doc.cpp
index 743f161..f32cf07 100644
--- a/WebCore/khtml/dom/dom_doc.cpp
+++ b/WebCore/khtml/dom/dom_doc.cpp
@@ -497,6 +497,46 @@ bool Document::execCommand(const DOMString &command, bool userInterface, const D
     return static_cast<DocumentImpl*>(impl)->execCommand(command, userInterface, value);
 }
 
+bool Document::queryCommandEnabled(const DOMString &command)
+{
+    if (!impl)
+	throw DOMException(DOMException::NOT_FOUND_ERR);
+
+    return static_cast<DocumentImpl*>(impl)->queryCommandEnabled(command);
+}
+
+bool Document::queryCommandIndeterm(const DOMString &command)
+{
+    if (!impl)
+	throw DOMException(DOMException::NOT_FOUND_ERR);
+
+    return static_cast<DocumentImpl*>(impl)->queryCommandIndeterm(command);
+}
+
+bool Document::queryCommandState(const DOMString &command)
+{
+    if (!impl)
+	throw DOMException(DOMException::NOT_FOUND_ERR);
+
+    return static_cast<DocumentImpl*>(impl)->queryCommandState(command);
+}
+
+bool Document::queryCommandSupported(const DOMString &command)
+{
+    if (!impl)
+	throw DOMException(DOMException::NOT_FOUND_ERR);
+
+    return static_cast<DocumentImpl*>(impl)->queryCommandSupported(command);
+}
+
+DOMString Document::queryCommandValue(const DOMString &command)
+{
+    if (!impl)
+	throw DOMException(DOMException::NOT_FOUND_ERR);
+
+    return static_cast<DocumentImpl*>(impl)->queryCommandValue(command);
+}
+
 // ----------------------------------------------------------------------------
 
 DocumentFragment::DocumentFragment() : Node()
diff --git a/WebCore/khtml/dom/dom_doc.h b/WebCore/khtml/dom/dom_doc.h
index 932c806..2394bb8 100644
--- a/WebCore/khtml/dom/dom_doc.h
+++ b/WebCore/khtml/dom/dom_doc.h
@@ -791,9 +791,14 @@ public:
     /**
      * not part of the DOM
      *
-     * executes an editing command
+     * javascript editing command support
      */
     bool execCommand(const DOMString &command, bool userInterface, const DOMString &value);
+    bool queryCommandEnabled(const DOMString &command);
+    bool queryCommandIndeterm(const DOMString &command);
+    bool queryCommandState(const DOMString &command);
+    bool queryCommandSupported(const DOMString &command);
+    DOMString queryCommandValue(const DOMString &command);
 
     Document( DocumentImpl *i);
 
diff --git a/WebCore/khtml/ecma/kjs_dom.cpp b/WebCore/khtml/ecma/kjs_dom.cpp
index 065d6ff..4e07438 100644
--- a/WebCore/khtml/ecma/kjs_dom.cpp
+++ b/WebCore/khtml/ecma/kjs_dom.cpp
@@ -737,7 +737,7 @@ void DOMAttr::putValue(ExecState *exec, int token, const Value& value, int /*att
 // -------------------------------------------------------------------------
 
 /* Source for DOMDocumentProtoTable. Use "make hashtables" to regenerate.
- at begin DOMDocumentProtoTable 23
+ at begin DOMDocumentProtoTable 29
   createElement   DOMDocument::CreateElement                   DontDelete|Function 1
   createDocumentFragment DOMDocument::CreateDocumentFragment   DontDelete|Function 1
   createTextNode  DOMDocument::CreateTextNode                  DontDelete|Function 1
@@ -758,6 +758,11 @@ void DOMAttr::putValue(ExecState *exec, int token, const Value& value, int /*att
   createEvent        DOMDocument::CreateEvent                  DontDelete|Function 1
   getOverrideStyle   DOMDocument::GetOverrideStyle             DontDelete|Function 2
   execCommand        DOMDocument::ExecCommand                  DontDelete|Function 3
+  queryCommandEnabled DOMDocument::QueryCommandEnabled         DontDelete|Function 1
+  queryCommandIndeterm DOMDocument::QueryCommandIndeterm       DontDelete|Function 1
+  queryCommandState DOMDocument::QueryCommandState             DontDelete|Function 1
+  queryCommandSupported DOMDocument::QueryCommandSupported     DontDelete|Function 1
+  queryCommandValue DOMDocument::QueryCommandValue             DontDelete|Function 1
 @end
 */
 DEFINE_PROTOTYPE("DOMDocument", DOMDocumentProto)
@@ -935,6 +940,28 @@ Value DOMDocumentProtoFunc::tryCall(ExecState *exec, Object &thisObj, const List
   case DOMDocument::ExecCommand: {
     return Boolean(doc.execCommand(args[0].toString(exec).string(), args[1].toBoolean(exec), args[2].toString(exec).string()));
   }
+  case DOMDocument::QueryCommandEnabled: {
+    return Boolean(doc.queryCommandEnabled(args[0].toString(exec).string()));
+  }
+  case DOMDocument::QueryCommandIndeterm: {
+    return Boolean(doc.queryCommandIndeterm(args[0].toString(exec).string()));
+  }
+  case DOMDocument::QueryCommandState: {
+    return Boolean(doc.queryCommandState(args[0].toString(exec).string()));
+  }
+  case DOMDocument::QueryCommandSupported: {
+    return Boolean(doc.queryCommandSupported(args[0].toString(exec).string()));
+  }
+  case DOMDocument::QueryCommandValue: {
+    DOM::DOMString commandValue(doc.queryCommandValue(args[0].toString(exec).string()));
+    // Method returns null DOMString to signal command is unsupported.
+    // Micorsoft documentation for this method says:
+    // "If not supported [for a command identifier], this method returns a Boolean set to false."
+    if (commandValue.isNull())
+        return Boolean(false);
+    else 
+        return String(commandValue);
+  }
   default:
     break;
   }
diff --git a/WebCore/khtml/ecma/kjs_dom.h b/WebCore/khtml/ecma/kjs_dom.h
index 8eac4a3..56ee05c 100644
--- a/WebCore/khtml/ecma/kjs_dom.h
+++ b/WebCore/khtml/ecma/kjs_dom.h
@@ -123,7 +123,9 @@ namespace KJS {
            CreateAttributeNS, GetElementsByTagNameNS, GetElementById,
            CreateRange, CreateNodeIterator, CreateTreeWalker, DefaultView,
            CreateEvent, StyleSheets, PreferredStylesheetSet, 
-           SelectedStylesheetSet, GetOverrideStyle, ReadyState, ExecCommand };
+           SelectedStylesheetSet, GetOverrideStyle, ReadyState, 
+           ExecCommand, QueryCommandEnabled, QueryCommandIndeterm, QueryCommandState, 
+           QueryCommandSupported, QueryCommandValue };
   };
 
   class DOMAttr : public DOMNode {
diff --git a/WebCore/khtml/ecma/kjs_dom.lut.h b/WebCore/khtml/ecma/kjs_dom.lut.h
index 8d241ca..0eb99af 100644
--- a/WebCore/khtml/ecma/kjs_dom.lut.h
+++ b/WebCore/khtml/ecma/kjs_dom.lut.h
@@ -131,40 +131,45 @@ const struct HashTable DOMAttrTable = { 2, 5, DOMAttrTableEntries, 5 };
 namespace KJS {
 
 const struct HashEntry DOMDocumentProtoTableEntries[] = {
-   { "createCDATASection", DOMDocument::CreateCDATASection, DontDelete|Function, 1, 0 },
    { 0, 0, 0, 0, 0 },
-   { "createDocumentFragment", DOMDocument::CreateDocumentFragment, DontDelete|Function, 1, &DOMDocumentProtoTableEntries[29] },
-   { 0, 0, 0, 0, 0 },
-   { "getElementsByTagName", DOMDocument::GetElementsByTagName, DontDelete|Function, 1, &DOMDocumentProtoTableEntries[25] },
+   { "createEntityReference", DOMDocument::CreateEntityReference, DontDelete|Function, 1, 0 },
+   { "getElementById", DOMDocument::GetElementById, DontDelete|Function, 1, &DOMDocumentProtoTableEntries[34] },
    { 0, 0, 0, 0, 0 },
+   { "getElementsByTagName", DOMDocument::GetElementsByTagName, DontDelete|Function, 1, &DOMDocumentProtoTableEntries[31] },
+   { "queryCommandIndeterm", DOMDocument::QueryCommandIndeterm, DontDelete|Function, 1, 0 },
    { 0, 0, 0, 0, 0 },
    { 0, 0, 0, 0, 0 },
-   { "createElement", DOMDocument::CreateElement, DontDelete|Function, 1, &DOMDocumentProtoTableEntries[23] },
-   { "createTreeWalker", DOMDocument::CreateTreeWalker, DontDelete|Function, 4, 0 },
+   { "createElement", DOMDocument::CreateElement, DontDelete|Function, 1, 0 },
+   { "queryCommandEnabled", DOMDocument::QueryCommandEnabled, DontDelete|Function, 1, &DOMDocumentProtoTableEntries[35] },
+   { "createAttribute", DOMDocument::CreateAttribute, DontDelete|Function, 1, 0 },
+   { "createEvent", DOMDocument::CreateEvent, DontDelete|Function, 1, 0 },
    { 0, 0, 0, 0, 0 },
+   { "importNode", DOMDocument::ImportNode, DontDelete|Function, 2, &DOMDocumentProtoTableEntries[33] },
    { 0, 0, 0, 0, 0 },
-   { "createAttribute", DOMDocument::CreateAttribute, DontDelete|Function, 1, &DOMDocumentProtoTableEntries[24] },
-   { "createTextNode", DOMDocument::CreateTextNode, DontDelete|Function, 1, 0 },
-   { "createEntityReference", DOMDocument::CreateEntityReference, DontDelete|Function, 1, &DOMDocumentProtoTableEntries[26] },
-   { "createProcessingInstruction", DOMDocument::CreateProcessingInstruction, DontDelete|Function, 1, &DOMDocumentProtoTableEntries[28] },
    { 0, 0, 0, 0, 0 },
-   { "createComment", DOMDocument::CreateComment, DontDelete|Function, 1, &DOMDocumentProtoTableEntries[27] },
    { 0, 0, 0, 0, 0 },
+   { "createDocumentFragment", DOMDocument::CreateDocumentFragment, DontDelete|Function, 1, &DOMDocumentProtoTableEntries[29] },
+   { "createTextNode", DOMDocument::CreateTextNode, DontDelete|Function, 1, &DOMDocumentProtoTableEntries[32] },
+   { "createRange", DOMDocument::CreateRange, DontDelete|Function, 0, 0 },
+   { "createCDATASection", DOMDocument::CreateCDATASection, DontDelete|Function, 1, &DOMDocumentProtoTableEntries[30] },
    { 0, 0, 0, 0, 0 },
-   { "createNodeIterator", DOMDocument::CreateNodeIterator, DontDelete|Function, 3, &DOMDocumentProtoTableEntries[30] },
+   { "execCommand", DOMDocument::ExecCommand, DontDelete|Function, 3, 0 },
    { 0, 0, 0, 0, 0 },
-   { "importNode", DOMDocument::ImportNode, DontDelete|Function, 2, 0 },
    { "createElementNS", DOMDocument::CreateElementNS, DontDelete|Function, 2, 0 },
+   { "createProcessingInstruction", DOMDocument::CreateProcessingInstruction, DontDelete|Function, 1, 0 },
    { "createAttributeNS", DOMDocument::CreateAttributeNS, DontDelete|Function, 2, 0 },
-   { "getElementsByTagNameNS", DOMDocument::GetElementsByTagNameNS, DontDelete|Function, 2, 0 },
-   { "getElementById", DOMDocument::GetElementById, DontDelete|Function, 1, 0 },
-   { "createRange", DOMDocument::CreateRange, DontDelete|Function, 0, 0 },
-   { "createEvent", DOMDocument::CreateEvent, DontDelete|Function, 1, 0 },
+   { 0, 0, 0, 0, 0 },
    { "getOverrideStyle", DOMDocument::GetOverrideStyle, DontDelete|Function, 2, 0 },
-   { "execCommand", DOMDocument::ExecCommand, DontDelete|Function, 3, 0 }
+   { "createComment", DOMDocument::CreateComment, DontDelete|Function, 1, 0 },
+   { "getElementsByTagNameNS", DOMDocument::GetElementsByTagNameNS, DontDelete|Function, 2, 0 },
+   { "createNodeIterator", DOMDocument::CreateNodeIterator, DontDelete|Function, 3, 0 },
+   { "createTreeWalker", DOMDocument::CreateTreeWalker, DontDelete|Function, 4, 0 },
+   { "queryCommandState", DOMDocument::QueryCommandState, DontDelete|Function, 1, 0 },
+   { "queryCommandSupported", DOMDocument::QueryCommandSupported, DontDelete|Function, 1, 0 },
+   { "queryCommandValue", DOMDocument::QueryCommandValue, DontDelete|Function, 1, 0 }
 };
 
-const struct HashTable DOMDocumentProtoTable = { 2, 31, DOMDocumentProtoTableEntries, 23 };
+const struct HashTable DOMDocumentProtoTable = { 2, 36, DOMDocumentProtoTableEntries, 29 };
 
 } // namespace
 
diff --git a/WebCore/khtml/editing/jsediting.cpp b/WebCore/khtml/editing/jsediting.cpp
new file mode 100644
index 0000000..d937559
--- /dev/null
+++ b/WebCore/khtml/editing/jsediting.cpp
@@ -0,0 +1,832 @@
+/*
+ * Copyright (C) 2004 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.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``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 COMPUTER, INC. OR
+ * 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. 
+ */
+
+#include "jsediting.h"
+
+#include "dom_selection.h"
+#include "htmlediting.h"
+#include "khtml_part.h"
+#include "KWQKHTMLPart.h"
+#include "qstring.h"
+
+#if APPLE_CHANGES
+#include "KWQAssertions.h"
+#include "KWQLogging.h"
+#else
+#define ASSERT(assertion) ((void)0)
+#define ASSERT_WITH_MESSAGE(assertion, formatAndArgs...) ((void)0)
+#define ASSERT_NOT_REACHED() ((void)0)
+#define LOG(channel, formatAndArgs...) ((void)0)
+#define ERROR(formatAndArgs...) ((void)0)
+#endif
+
+#define NoExec (0)
+#define NoEnabled (0)
+#define NoIndeterm (0)
+#define NoState (0)
+#define NoSupported (0)
+#define NoValue (0)
+
+using khtml::TypingCommand;
+
+namespace DOM {
+
+class DocumentImpl;
+
+static bool execCommandNotImplemented()
+{
+    ERROR("unimplemented");
+    return false;
+}
+
+static bool queryBoolNotImplemented()
+{
+    ERROR("unimplemented");
+    return false;
+}
+
+static DOMString queryValueNotImplemented()
+{
+    ERROR("unimplemented");
+    return DOMString();
+}
+
+QDict<JSEditor::CommandIdentifier> &JSEditor::commandDict()
+{
+    static QDict<JSEditor::CommandIdentifier> dict;
+    return dict;
+}
+
+JSEditor::JSEditor(DocumentImpl *doc) : m_doc(doc) 
+{
+    initDict();
+ }
+
+JSEditor::CommandIdentifier *JSEditor::commandIdentifier(const DOMString &command)
+{
+    return commandDict().find(command.string().lower());
+}
+
+void JSEditor::addCommand(const QString &command, execCommandFn exec, queryBoolFn enabled, queryBoolFn indeterm, queryBoolFn state, queryBoolFn supported, queryValueFn value)
+{
+    commandDict().insert(command.lower(), new CommandIdentifier(exec, enabled, indeterm, state, supported, value));
+}
+
+void JSEditor::initDict()
+{
+    static bool initFlag = false;
+    if (initFlag)
+        return;
+    initFlag = true;
+    
+    //
+    // All commands are listed with a "supported" or "not supported" label.
+    //
+    // The "supported" commands need to have all their functions implemented. These bugs 
+    // correspond to this work.
+    // <rdar://problem/3675867>: "Make execCommand work as specified in the Javascript execCommand Compatibility Plan"
+    // <rdar://problem/3675898>: "Make queryCommandEnabled work as specified in the Javascript execCommand Compatibility Plan"
+    // <rdar://problem/3675899>: "Make queryCommandIndeterm work as specified in the Javascript execCommand Compatibility Plan"
+    // <rdar://problem/3675901>: "Make queryCommandState work as specified in the Javascript execCommand Compatibility Plan"
+    // <rdar://problem/3675903>: "Make queryCommandSupported work as specified in the Javascript execCommand Compatibility Plan"
+    // <rdar://problem/3675904>: "Make queryCommandValue work as specified in the Javascript execCommand Compatibility Plan"
+    //
+    // The "unsupported" commands are listed here since they appear in the Microsoft
+    // documentation used as the basis for the list. It seems reasonable that these
+    // commands should do something, even if it is to return a default placeholder value.
+    //
+    
+    // 2d-position command (not supported)
+    addCommand("2d-position", NoExec, NoEnabled, NoIndeterm, NoState, NoSupported, NoValue);
+
+    // absoluteposition command (not supported)
+    addCommand("absoluteposition", NoExec, NoEnabled, NoIndeterm, NoState, NoSupported, NoValue);
+
+    // backcolor command (supported)
+    addCommand(
+        "backcolor", 
+        NoExec, 
+        &JSEditor::enabledIfPartNotNull, 
+        NoIndeterm, 
+        NoState, 
+        &JSEditor::commandSupported, 
+        NoValue
+    );
+
+    // blockdirltr command (not supported)
+    addCommand("blockdirltr", NoExec, NoEnabled, NoIndeterm, NoState, NoSupported, NoValue);
+
+    // blockdirrtl command (not supported)
+    addCommand("blockdirrtl", NoExec, NoEnabled, NoIndeterm, NoState, NoSupported, NoValue);
+
+    // bold command (supported)
+    addCommand(
+        "bold", 
+        NoExec, 
+        &JSEditor::enabledIfSelectionNotEmpty, 
+        NoIndeterm, 
+        NoState, 
+        &JSEditor::commandSupported, 
+        NoValue
+    );
+
+    // browsemode command (not supported)
+    addCommand("browsemode", NoExec, NoEnabled, NoIndeterm, NoState, NoSupported, NoValue);
+
+    // clearauthenticationcache command (not supported)
+    addCommand("clearauthenticationcache", NoExec, NoEnabled, NoIndeterm, NoState, NoSupported, NoValue);
+
+    // copy command (supported)
+    addCommand(
+        "copy", 
+        &JSEditor::execCommandCopy, 
+        &JSEditor::enabledIfSelectionIsRange, 
+        NoIndeterm, 
+        NoState, 
+        &JSEditor::commandSupported, 
+        NoValue
+    );
+
+    // createbookmark command (not supported)
+    addCommand("createbookmark", NoExec, NoEnabled, NoIndeterm, NoState, NoSupported, NoValue);
+
+    // createlink command (not supported)
+    addCommand("createlink", NoExec, NoEnabled, NoIndeterm, NoState, NoSupported, NoValue);
+
+    // cut command (supported)
+    addCommand(
+        "cut", 
+        &JSEditor::execCommandCut, 
+        &JSEditor::enabledIfSelectionIsRange, 
+        NoIndeterm, 
+        NoState, 
+        &JSEditor::commandSupported, 
+        NoValue
+    );
+
+    // delete command (supported)
+    addCommand(
+        "delete", 
+        &JSEditor::execCommandDelete, 
+        &JSEditor::enabledIfSelectionNotEmpty, 
+        NoIndeterm, 
+        NoState, 
+        &JSEditor::commandSupported, 
+        NoValue
+    );
+
+    // dirltr command (not supported)
+    addCommand("dirltr", NoExec, NoEnabled, NoIndeterm, NoState, NoSupported, NoValue);
+
+    // dirrtl command (not supported)
+    addCommand("dirrtl", NoExec, NoEnabled, NoIndeterm, NoState, NoSupported, NoValue);
+
+    // editmode command (not supported)
+    addCommand("editmode", NoExec, NoEnabled, NoIndeterm, NoState, NoSupported, NoValue);
+
+    // fontname command (supported)
+    addCommand(
+        "fontname", 
+        NoExec, 
+        &JSEditor::enabledIfSelectionNotEmpty, 
+        NoIndeterm, 
+        NoState, 
+        &JSEditor::commandSupported, 
+        NoValue
+    );
+
+    // fontsize command (supported)
+    addCommand(
+        "fontsize", 
+        NoExec, 
+        &JSEditor::enabledIfSelectionNotEmpty, 
+        NoIndeterm, 
+        NoState, 
+        &JSEditor::commandSupported, 
+        NoValue
+    );
+
+    // forecolor command (supported)
+    addCommand(
+        "forecolor", 
+        NoExec, 
+        &JSEditor::enabledIfSelectionNotEmpty, 
+        NoIndeterm, 
+        NoState, 
+        &JSEditor::commandSupported, 
+        NoValue
+    );
+
+    // formatblock command (not supported)
+    addCommand("formatblock", NoExec, NoEnabled, NoIndeterm, NoState, NoSupported, NoValue);
+
+    // indent command (supported)
+    addCommand(
+        "indent", 
+        NoExec, 
+        &JSEditor::enabledIfSelectionNotEmpty, 
+        NoIndeterm, 
+        NoState, 
+        &JSEditor::commandSupported, 
+        NoValue
+    );
+
+    // inlinedirltr command (not supported)
+    addCommand("inlinedirltr", NoExec, NoEnabled, NoIndeterm, NoState, NoSupported, NoValue);
+
+    // inlinedirrtl command (not supported)
+    addCommand("inlinedirrtl", NoExec, NoEnabled, NoIndeterm, NoState, NoSupported, NoValue);
+
+    // insertbutton command (not supported)
+    addCommand("insertbutton", NoExec, NoEnabled, NoIndeterm, NoState, NoSupported, NoValue);
+
+    // insertfieldset command (not supported)
+    addCommand("insertfieldset", NoExec, NoEnabled, NoIndeterm, NoState, NoSupported, NoValue);
+
+    // inserthorizontalrule command (not supported)
+    addCommand("inserthorizontalrule", NoExec, NoEnabled, NoIndeterm, NoState, NoSupported, NoValue);
+
+    // insertiframe command (not supported)
+    addCommand("insertiframe", NoExec, NoEnabled, NoIndeterm, NoState, NoSupported, NoValue);
+
+    // insertimage command (not supported)
+    addCommand("insertimage", NoExec, NoEnabled, NoIndeterm, NoState, NoSupported, NoValue);
+
+    // insertinputbutton command (not supported)
+    addCommand("insertinputbutton", NoExec, NoEnabled, NoIndeterm, NoState, NoSupported, NoValue);
+
+    // insertinputcheckbox command (not supported)
+    addCommand("insertinputcheckbox", NoExec, NoEnabled, NoIndeterm, NoState, NoSupported, NoValue);
+
+    // insertinputfileupload command (not supported)
+    addCommand("insertinputfileupload", NoExec, NoEnabled, NoIndeterm, NoState, NoSupported, NoValue);
+
+    // insertinputhidden command (not supported)
+    addCommand("insertinputhidden", NoExec, NoEnabled, NoIndeterm, NoState, NoSupported, NoValue);
+
+    // insertinputimage command (not supported)
+    addCommand("insertinputimage", NoExec, NoEnabled, NoIndeterm, NoState, NoSupported, NoValue);
+
+    // insertinputpassword command (not supported)
+    addCommand("insertinputpassword", NoExec, NoEnabled, NoIndeterm, NoState, NoSupported, NoValue);
+
+    // insertinputradio command (not supported)
+    addCommand("insertinputradio", NoExec, NoEnabled, NoIndeterm, NoState, NoSupported, NoValue);
+
+    // insertinputreset command (not supported)
+    addCommand("insertinputreset", NoExec, NoEnabled, NoIndeterm, NoState, NoSupported, NoValue);
+
+    // insertinputsubmit command (not supported)
+    addCommand("insertinputsubmit", NoExec, NoEnabled, NoIndeterm, NoState, NoSupported, NoValue);
+
+    // insertinputtext command (not supported)
+    addCommand("insertinputtext", NoExec, NoEnabled, NoIndeterm, NoState, NoSupported, NoValue);
+
+    // insertmarquee command (not supported)
+    addCommand("insertmarquee", NoExec, NoEnabled, NoIndeterm, NoState, NoSupported, NoValue);
+
+    // insertorderedlist command (not supported)
+    addCommand("insertorderedlist", NoExec, NoEnabled, NoIndeterm, NoState, NoSupported, NoValue);
+
+    // insertparagraph command (supported)
+    addCommand(
+        "insertparagraph", 
+        NoExec, 
+        &JSEditor::enabledIfSelectionNotEmpty, 
+        NoIndeterm, 
+        NoState, 
+        &JSEditor::commandSupported, 
+        NoValue
+    );
+
+    // insertselectdropdown command (not supported)
+    addCommand("insertselectdropdown", NoExec, NoEnabled, NoIndeterm, NoState, NoSupported, NoValue);
+
+    // insertselectlistbox command (not supported)
+    addCommand("insertselectlistbox", NoExec, NoEnabled, NoIndeterm, NoState, NoSupported, NoValue);
+
+    // inserttext command (supported)
+    addCommand(
+        "inserttext", 
+        &JSEditor::execCommandInsertText, 
+        &JSEditor::enabledIfSelectionNotEmpty, 
+        NoIndeterm, 
+        NoState, 
+        &JSEditor::commandSupported, 
+        NoValue
+    );
+
+    // inserttextarea command (not supported)
+    addCommand("inserttextarea", NoExec, NoEnabled, NoIndeterm, NoState, NoSupported, NoValue);
+
+    // insertunorderedlist command (not supported)
+    addCommand("insertunorderedlist", NoExec, NoEnabled, NoIndeterm, NoState, NoSupported, NoValue);
+
+    // italic command (supported)
+    addCommand(
+        "italic", 
+        NoExec, 
+        &JSEditor::enabledIfSelectionNotEmpty, 
+        NoIndeterm, 
+        NoState, 
+        &JSEditor::commandSupported, 
+        NoValue
+    );
+
+    // justifycenter command (supported)
+    addCommand(
+        "justifycenter", 
+        NoExec, 
+        &JSEditor::enabledIfSelectionNotEmpty, 
+        NoIndeterm, 
+        NoState, 
+        &JSEditor::commandSupported, 
+        NoValue
+    );
+
+    // justifyfull command (supported)
+    addCommand(
+        "justifyfull", 
+        NoExec, 
+        &JSEditor::enabledIfSelectionNotEmpty, 
+        NoIndeterm, 
+        NoState, 
+        &JSEditor::commandSupported, 
+        NoValue
+    );
+
+    // justifyleft command (supported)
+    addCommand(
+        "justifyleft", 
+        NoExec, 
+        &JSEditor::enabledIfSelectionNotEmpty, 
+        NoIndeterm, 
+        NoState, 
+        &JSEditor::commandSupported, 
+        NoValue
+    );
+
+    // justifynone command (supported)
+    addCommand(
+        "justifynone", 
+        NoExec, 
+        &JSEditor::enabledIfSelectionNotEmpty, 
+        NoIndeterm, 
+        NoState, 
+        &JSEditor::commandSupported, 
+        NoValue
+    );
+
+    // justifyright command (supported)
+    addCommand(
+        "justifyright", 
+        NoExec, 
+        &JSEditor::enabledIfSelectionNotEmpty, 
+        NoIndeterm, 
+        NoState, 
+        &JSEditor::commandSupported, 
+        NoValue
+    );
+
+    // liveresize command (not supported)
+    addCommand("liveresize", NoExec, NoEnabled, NoIndeterm, NoState, NoSupported, NoValue);
+
+    // multipleselection command (not supported)
+    addCommand("multipleselection", NoExec, NoEnabled, NoIndeterm, NoState, NoSupported, NoValue);
+
+    // open command (not supported)
+    addCommand("open", NoExec, NoEnabled, NoIndeterm, NoState, NoSupported, NoValue);
+
+    // outdent command (supported)
+    addCommand(
+        "outdent", 
+        NoExec, 
+        &JSEditor::enabledIfSelectionNotEmpty, 
+        NoIndeterm, 
+        NoState, 
+        &JSEditor::commandSupported, 
+        NoValue
+    );
+
+    // overwrite command (not supported)
+    addCommand("overwrite", NoExec, NoEnabled, NoIndeterm, NoState, NoSupported, NoValue);
+
+    // paste command (supported)
+    addCommand(
+        "paste", 
+        &JSEditor::execCommandPaste, 
+        // EDIT FIXME: Should check if there is something on the pasteboard to paste
+        &JSEditor::enabledIfSelectionNotEmpty, 
+        NoIndeterm, 
+        NoState, 
+        &JSEditor::commandSupported, 
+        NoValue
+    );
+
+    // playimage command (not supported)
+    addCommand("playimage", NoExec, NoEnabled, NoIndeterm, NoState, NoSupported, NoValue);
+
+    // print command (supported)
+    addCommand(
+        "print", 
+        NoExec, 
+        &JSEditor::enabledIfPartNotNull, 
+        NoIndeterm, 
+        NoState, 
+        &JSEditor::commandSupported, 
+        NoValue
+    );
+
+    // redo command (supported)
+    addCommand(
+        "redo", 
+        &JSEditor::execCommandRedo, 
+        // EDIT FIXME: Should check if the undo manager has something to redo
+        &JSEditor::enabledIfPartNotNull, 
+        NoIndeterm, 
+        NoState, 
+        &JSEditor::commandSupported, 
+        NoValue
+    );
+
+    // refresh command (not supported)
+    addCommand("refresh", NoExec, NoEnabled, NoIndeterm, NoState, NoSupported, NoValue);
+
+    // removeformat command (not supported)
+    addCommand("removeformat", NoExec, NoEnabled, NoIndeterm, NoState, NoSupported, NoValue);
+
+    // removeparaformat command (not supported)
+    addCommand("removeparaformat", NoExec, NoEnabled, NoIndeterm, NoState, NoSupported, NoValue);
+
+    // saveas command (not supported)
+    addCommand("saveas", NoExec, NoEnabled, NoIndeterm, NoState, NoSupported, NoValue);
+
+    // selectall command (supported)
+    addCommand(
+        "selectAll", 
+        &JSEditor::execCommandSelectAll, 
+        &JSEditor::enabledIfPartNotNull, 
+        NoIndeterm, 
+        NoState, 
+        &JSEditor::commandSupported, 
+        NoValue
+    );
+
+    // sizetocontrol command (not supported)
+    addCommand("sizetocontrol", NoExec, NoEnabled, NoIndeterm, NoState, NoSupported, NoValue);
+
+    // sizetocontrolheight command (not supported)
+    addCommand("sizetocontrolheight", NoExec, NoEnabled, NoIndeterm, NoState, NoSupported, NoValue);
+
+    // sizetocontrolwidth command (not supported)
+    addCommand("sizetocontrolwidth", NoExec, NoEnabled, NoIndeterm, NoState, NoSupported, NoValue);
+
+    // stop command (not supported)
+    addCommand("stop", NoExec, NoEnabled, NoIndeterm, NoState, &JSEditor::commandSupported, NoValue);
+
+    // stopimage command (not supported)
+    addCommand("stopimage", NoExec, NoEnabled, NoIndeterm, NoState, NoSupported, NoValue);
+
+    // strikethrough command (not supported)
+    addCommand("strikethrough", NoExec, NoEnabled, NoIndeterm, NoState, NoSupported, NoValue);
+
+    // subscript command (supported)
+    addCommand(
+        "subscript", 
+        NoExec, 
+        &JSEditor::enabledIfSelectionNotEmpty, 
+        NoIndeterm, 
+        NoState, 
+        &JSEditor::commandSupported, 
+        NoValue
+    );
+
+    // superscript command (supported)
+    addCommand(
+        "superscript", 
+        NoExec, 
+        &JSEditor::enabledIfSelectionNotEmpty, 
+        NoIndeterm, 
+        NoState, 
+        &JSEditor::commandSupported, 
+        NoValue
+    );
+
+    // unbookmark command (not supported)
+    addCommand("unbookmark", NoExec, NoEnabled, NoIndeterm, NoState, NoSupported, NoValue);
+
+    // underline command (not supported)
+    addCommand("underline", NoExec, NoEnabled, NoIndeterm, NoState, NoSupported, NoValue);
+
+    // undo command (supported)
+    addCommand(
+        "undo", 
+        &JSEditor::execCommandUndo, 
+        // EDIT FIXME: Should check if the undo manager has something to undo
+        &JSEditor::enabledIfPartNotNull, 
+        NoIndeterm, 
+        NoState, 
+        &JSEditor::commandSupported, 
+        NoValue
+    );
+
+    // unlink command (not supported)
+    addCommand("unlink", NoExec, NoEnabled, NoIndeterm, NoState, NoSupported, NoValue);
+
+    // unselect command (supported)
+    addCommand(
+        "unselect", 
+        NoExec, 
+        &JSEditor::enabledIfSelectionIsRange, 
+        NoIndeterm, 
+        NoState, 
+        &JSEditor::commandSupported, 
+        NoValue
+    );
+}
+
+bool JSEditor::execCommand(const DOMString &command, bool userInterface, const DOMString &value) 
+{ 
+    CommandIdentifier *cmd = commandIdentifier(command);
+    if (!cmd || !cmd->execFn)
+        return execCommandNotImplemented();
+        
+    ASSERT(document());
+    document()->updateLayout();
+    return (this->*(cmd->execFn))(userInterface, value);
+}
+
+bool JSEditor::queryCommandEnabled(const DOMString &command)
+{ 
+    CommandIdentifier *cmd = commandIdentifier(command);
+    if (!cmd || !cmd->enabledFn)
+        return queryBoolNotImplemented();
+        
+    ASSERT(document());
+    document()->updateLayout();
+    return (this->*(cmd->enabledFn))();
+}
+
+bool JSEditor::queryCommandIndeterm(const DOMString &command)
+{
+    CommandIdentifier *cmd = commandIdentifier(command);
+    if (!cmd || !cmd->indetermFn)
+        return queryBoolNotImplemented();
+        
+    ASSERT(document());
+    document()->updateLayout();
+    return (this->*(cmd->indetermFn))();
+}
+
+bool JSEditor::queryCommandState(const DOMString &command)
+{
+    CommandIdentifier *cmd = commandIdentifier(command);
+    if (!cmd || !cmd->stateFn)
+        return queryBoolNotImplemented();
+        
+    ASSERT(document());
+    document()->updateLayout();
+    return (this->*(cmd->stateFn))();
+}
+
+bool JSEditor::queryCommandSupported(const DOMString &command)
+{
+    CommandIdentifier *cmd = commandIdentifier(command);
+    if (!cmd || !cmd->supportedFn)
+        return queryBoolNotImplemented();
+        
+    ASSERT(document());
+    document()->updateLayout();
+    return (this->*(cmd->supportedFn))();
+}
+
+DOMString JSEditor::queryCommandValue(const DOMString &command)
+{ 
+    CommandIdentifier *cmd = commandIdentifier(command);
+    if (!cmd || !cmd->valueFn)
+        return queryValueNotImplemented();
+    
+    ASSERT(document());
+    document()->updateLayout();
+    return (this->*(cmd->valueFn))();
+}
+
+// =============================================================================================
+//
+// execCommand implementations
+//
+// EDIT FIXME: All these responses should be tested against the behavior
+// of Microsoft browsers to ensure we are as compatible with their
+// behavior as is sensible.
+
+bool JSEditor::execCommandCopy(bool userInterface, const DOMString &value)
+{
+    KHTMLPart *part = document()->part();
+    if (!part || part->selection().state() != Selection::RANGE)
+        return false;
+    KWQ(part)->issueCopyCommand();
+    return true;
+}
+
+bool JSEditor::execCommandCut(bool userInterface, const DOMString &value)
+{
+    if (!part() || part()->selection().state() != Selection::RANGE)
+        return false;
+    KWQ(part())->issueCutCommand();
+    return true;
+}
+
+bool JSEditor::execCommandDelete(bool userInterface, const DOMString &value)
+{
+    KHTMLPart *part = document()->part();
+    if (!part || part->selection().isEmpty())
+        return false;
+    TypingCommand::deleteKeyPressed(document());
+    return true;
+}
+
+bool JSEditor::execCommandInsertText(bool userInterface, const DOMString &value)
+{
+    KHTMLPart *part = document()->part();
+    if (!part || part->selection().isEmpty())
+        return false;
+    TypingCommand::insertText(document(), value);
+    return true;
+}
+
+bool JSEditor::execCommandPaste(bool userInterface, const DOMString &value)
+{
+    KHTMLPart *part = document()->part();
+    if (!part || part->selection().isEmpty())
+        return false;
+    KWQ(part)->issuePasteCommand();
+    return true;
+}
+
+bool JSEditor::execCommandRedo(bool userInterface, const DOMString &value)
+{
+    KHTMLPart *part = document()->part();
+    if (!part || part->selection().state() != Selection::RANGE)
+        return false;
+    KWQ(part)->issueRedoCommand();
+    return true;
+}
+
+bool JSEditor::execCommandSelectAll(bool userInterface, const DOMString &value)
+{
+    KHTMLPart *part = document()->part();
+    if (!part)
+        return false;
+    part->selectAll();
+    return true;
+}
+
+bool JSEditor::execCommandUndo(bool userInterface, const DOMString &value)
+{
+    KHTMLPart *part = document()->part();
+    if (!part || part->selection().state() != Selection::RANGE)
+        return false;
+    KWQ(part)->issueUndoCommand();
+    return true;
+}
+
+// =============================================================================================
+//
+// queryCommandEnabled implementations
+//
+// EDIT FIXME: All these responses should be tested against the behavior
+// of Microsoft browsers to ensure we are as compatible with their
+// behavior as is sensible. For now, the returned values are just my best
+// guesses.
+//
+// It's a bit confusing to get a clear notion of the difference between
+// "supported" and "enabled" from reading the Microsoft documentation, but
+// what little I could glean from that seems to make some sense.
+//     Supported = The command is supported by this object.
+//     Enabled =   The command is available and enabled.
+// 
+// With this definition, the different commands return true or false
+// based on simple, and for now incomplete, checks on the part and
+// selection.
+
+bool JSEditor::enabledIfPartNotNull()
+{
+    return part() != 0;
+}
+
+bool JSEditor::enabledIfSelectionNotEmpty()
+{
+    return part() && part()->selection().notEmpty();
+}
+
+bool JSEditor::enabledIfSelectionIsRange()
+{
+    return part() && part()->selection().state() == Selection::RANGE;
+}
+
+// =============================================================================================
+//
+// queryCommandIndeterm implementations
+//
+// EDIT FIXME: All these responses should be tested against the behavior
+// of Microsoft browsers to ensure we are as compatible with their
+// behavior as is sensible. For now, the returned values are just my best
+// guesses.
+//
+// It's a bit confusing to get a clear notion of what this method is supposed
+// to do from reading the Microsoft documentation, but my current guess is this:
+//
+//     queryCommandState and queryCommandIndeterm work in concert to return
+//     the two bits of information that are needed to tell, for instance,
+//     if the text of a selection is bold. The answer can be "yes", "no", or
+//     "partially".
+// 
+// If this is so, then queryCommandState should return "yes" in the case where
+// all the text is bold and "no" for non-bold or partially-bold text.
+// Then, queryCommandIndeterm should return "no" in the case where
+// all the text is either all bold or not-bold and and "yes" for partially-bold 
+// text.
+//
+// Note that, for now, the returned values are just place-holders.
+
+// =============================================================================================
+//
+// queryCommandState implementations
+//
+// EDIT FIXME: All these responses should be tested against the behavior
+// of Microsoft browsers to ensure we are as compatible with their
+// behavior as is sensible. For now, the returned values are just my best
+// guesses.
+//
+// It's a bit confusing to get a clear notion of what this method is supposed
+// to do from reading the Microsoft documentation, but my current guess is this:
+//
+//     queryCommandState and queryCommandIndeterm work in concert to return
+//     the two bits of information that are needed to tell, for instance,
+//     if the text of a selection is bold. The answer can be "yes", "no", or
+//     "partially".
+// 
+// If this is so, then queryCommandState should return "yes" in the case where
+// all the text is bold and "no" for non-bold or partially-bold text.
+// Then, queryCommandIndeterm should return "no" in the case where
+// all the text is either all bold or not-bold and and "yes" for partially-bold 
+// text.
+//
+// Note that, for now, the returned values are just place-holders.
+
+
+// =============================================================================================
+//
+// queryCommandSupported implementations
+//
+// EDIT FIXME: All these responses should be tested against the behavior
+// of Microsoft browsers to ensure we are as compatible with their
+// behavior as is sensible. For now, the returned values are just my best
+// guesses.
+//
+// It's a bit confusing to get a clear notion of the difference between
+// "supported" and "enabled" from reading the Microsoft documentation, but
+// what little I could glean from that seems to make some sense.
+//     Supported = The command is supported by this object.
+//     Enabled =   The command is available and enabled.
+// 
+// With this definition, all the commands we support return true unconditionally.
+
+bool JSEditor::commandSupported()
+{
+    return true;
+}
+
+// =============================================================================================
+//
+// queryCommandValue implementations
+//
+// EDIT FIXME: All these responses should be tested against the behavior
+// of Microsoft browsers to ensure we are as compatible with their
+// behavior as is sensible. For now, the returned values are just place-holders.
+
+// =============================================================================================
+
+} // namespace khtml
diff --git a/WebCore/khtml/editing/jsediting.h b/WebCore/khtml/editing/jsediting.h
new file mode 100644
index 0000000..d5dbd76
--- /dev/null
+++ b/WebCore/khtml/editing/jsediting.h
@@ -0,0 +1,104 @@
+/*
+ * Copyright (C) 2004 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.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``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 COMPUTER, INC. OR
+ * 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. 
+ */
+
+#ifndef __jsediting_h__
+#define __jsediting_h__
+
+#include "dom_docimpl.h"
+#include "dom_string.h"
+#include "qdict.h"
+
+class KHTMLPart;
+class QString;
+
+namespace DOM {
+
+class DocumentImpl;
+
+class JSEditor {
+
+public:
+    JSEditor(DocumentImpl *);
+
+    typedef bool (JSEditor::*execCommandFn)(bool userInterface, const DOMString &value);
+    typedef bool (JSEditor::*queryBoolFn)();
+    typedef DOM::DOMString (JSEditor::*queryValueFn)();
+
+    struct CommandIdentifier {
+        CommandIdentifier() {}
+        CommandIdentifier(execCommandFn exec, queryBoolFn enabled, queryBoolFn indeterm, queryBoolFn state, queryBoolFn supported, queryValueFn value)
+            : execFn(exec), enabledFn(enabled), indetermFn(indeterm), stateFn(state), supportedFn(supported), valueFn(value) {}
+
+        JSEditor::execCommandFn execFn;
+        queryBoolFn enabledFn;
+        queryBoolFn indetermFn;
+        queryBoolFn stateFn;
+        queryBoolFn supportedFn;
+        queryValueFn valueFn;
+    };
+    
+    bool execCommand(const DOMString &command, bool userInterface, const DOMString &value);
+    bool queryCommandEnabled(const DOMString &command);
+    bool queryCommandIndeterm(const DOMString &command);
+    bool queryCommandState(const DOMString &command);
+    bool queryCommandSupported(const DOMString &command);
+    DOM::DOMString queryCommandValue(const DOMString &command);
+
+private:
+    JSEditor(const JSEditor &);
+    JSEditor &operator=(const JSEditor &);
+
+    // execCommand implementations
+    bool execCommandCopy(bool userInterface, const DOMString &value);
+    bool execCommandCut(bool userInterface, const DOMString &value);
+    bool execCommandDelete(bool userInterface, const DOMString &value);
+    bool execCommandInsertText(bool userInterface, const DOMString &value);
+    bool execCommandPaste(bool userInterface, const DOMString &value);
+    bool execCommandRedo(bool userInterface, const DOMString &value);
+    bool execCommandSelectAll(bool userInterface, const DOMString &value);
+    bool execCommandUndo(bool userInterface, const DOMString &value);
+
+    // queryCommandEnabled implementations
+    bool enabledIfPartNotNull();
+    bool enabledIfSelectionNotEmpty();
+    bool enabledIfSelectionIsRange();
+
+    // queryCommandSupported implementations
+    bool commandSupported();
+
+    QDict<JSEditor::CommandIdentifier> &commandDict();
+    DocumentImpl *document() { return m_doc; }
+    KHTMLPart *part() { return document()->part(); }
+    CommandIdentifier *commandIdentifier(const DOMString &command);
+
+    void addCommand(const QString &cmd, execCommandFn exec, queryBoolFn enabled, queryBoolFn indeterm, queryBoolFn state, queryBoolFn supported, queryValueFn value);
+    void initDict();
+
+    DocumentImpl *m_doc;
+};
+
+} // end namespace DOM
+
+#endif
diff --git a/WebCore/khtml/xml/dom_docimpl.cpp b/WebCore/khtml/xml/dom_docimpl.cpp
index f3d31a5..497d557 100644
--- a/WebCore/khtml/xml/dom_docimpl.cpp
+++ b/WebCore/khtml/xml/dom_docimpl.cpp
@@ -74,6 +74,8 @@
 
 #include "cssvalues.h"
 
+#include "jsediting.h"
+
 #include <kio/job.h>
 
 #ifndef KHTML_NO_XBL
@@ -327,6 +329,8 @@ DocumentImpl::DocumentImpl(DOMImplementationImpl *_implementation, KHTMLView *v)
     m_processingLoadEvent = false;
     m_startTime.restart();
     m_overMinimumLayoutThreshold = false;
+    
+    m_jsEditor = 0;
 }
 
 DocumentImpl::~DocumentImpl()
@@ -391,6 +395,11 @@ DocumentImpl::~DocumentImpl()
         m_decoder->deref();
         m_decoder = 0;
     }
+    
+    if (m_jsEditor) {
+        delete m_jsEditor;
+        m_jsEditor = 0;
+    }
 }
 
 void DocumentImpl::resetLinkColor()
@@ -2816,70 +2825,44 @@ DOMString DocumentImpl::toString() const
 
 #endif // APPLE_CHANGES
 
+// ----------------------------------------------------------------------------
+// Support for Javascript execCommand, and related methods
+
+JSEditor *DocumentImpl::jsEditor()
+{
+    if (!m_jsEditor)
+        m_jsEditor = new JSEditor(this);
+    return m_jsEditor;
+}
+
 bool DocumentImpl::execCommand(const DOMString &command, bool userInterface, const DOMString &value)
 {
-    static AtomicString selectAllCommand("selectall");
-    static AtomicString insertTextCommand("inserttext");
-    static AtomicString undoCommand("undo");
-    static AtomicString redoCommand("redo");
-    static AtomicString deleteCommand("delete");
-    static AtomicString cutCommand("cut");
-    static AtomicString copyCommand("copy");
-    static AtomicString pasteCommand("paste");
+    return jsEditor()->execCommand(command, userInterface, value);
+}
 
-    updateLayout();
+bool DocumentImpl::queryCommandEnabled(const DOMString &command)
+{
+    return jsEditor()->queryCommandEnabled(command);
+}
 
-    AtomicString atom(command.lower());
-    if (atom == selectAllCommand) {
-        if (!part())
-            return false;
-        part()->selectAll();
-        return true;
-    }
-    else if (atom == insertTextCommand) {
-        if (!part() || part()->selection().isEmpty())
-            return false;
-        TypingCommand::insertText(this, value);
-        return true;
-    }
-    else if (atom == undoCommand) {
-        if (!part())
-            return false;
-        KWQ(part())->issueUndoCommand();
-        return true;
-    }
-    else if (atom == redoCommand) {
-        if (!part())
-            return false;
-        KWQ(part())->issueRedoCommand();
-        return true;
-    }
-    else if (atom == deleteCommand) {
-        if (!part() || part()->selection().isEmpty())
-            return false;
-        TypingCommand::deleteKeyPressed(this);
-        return true;
-    }
-    else if (atom == cutCommand) {
-        if (!part() || part()->selection().state() != Selection::RANGE)
-            return false;
-        KWQ(part())->issueCutCommand();
-        return true;
-    }
-    else if (atom == copyCommand) {
-        if (!part() || part()->selection().state() != Selection::RANGE)
-            return false;
-        KWQ(part())->issueCopyCommand();
-        return true;
-    }
-    else if (atom == pasteCommand) {
-        if (!part() || part()->selection().isEmpty())
-            return false;
-        KWQ(part())->issuePasteCommand();
-        return true;
-    }
+bool DocumentImpl::queryCommandIndeterm(const DOMString &command)
+{
+    return jsEditor()->queryCommandIndeterm(command);
+}
 
-    return false;
+bool DocumentImpl::queryCommandState(const DOMString &command)
+{
+    return jsEditor()->queryCommandState(command);
+}
+
+bool DocumentImpl::queryCommandSupported(const DOMString &command)
+{
+    return jsEditor()->queryCommandSupported(command);
+}
+
+DOMString DocumentImpl::queryCommandValue(const DOMString &command)
+{
+    return jsEditor()->queryCommandValue(command);
 }
 
 // ----------------------------------------------------------------------------
diff --git a/WebCore/khtml/xml/dom_docimpl.h b/WebCore/khtml/xml/dom_docimpl.h
index 5473727..4bcadb1 100644
--- a/WebCore/khtml/xml/dom_docimpl.h
+++ b/WebCore/khtml/xml/dom_docimpl.h
@@ -101,6 +101,7 @@ namespace DOM {
     class HTMLElementImpl;
     class HTMLImageLoader;
     class HTMLMapElementImpl;
+    class JSEditor;
     class NodeFilter;
     class NodeFilterImpl;
     class NodeIteratorImpl;
@@ -517,7 +518,12 @@ public:
     DOMString toString() const;
     
     bool execCommand(const DOMString &command, bool userInterface, const DOMString &value);
-    
+    bool queryCommandEnabled(const DOMString &command);
+    bool queryCommandIndeterm(const DOMString &command);
+    bool queryCommandState(const DOMString &command);
+    bool queryCommandSupported(const DOMString &command);
+    DOMString queryCommandValue(const DOMString &command);
+
 #ifndef KHTML_NO_XBL
     // XBL methods
     XBL::XBLBindingManager* bindingManager() const { return m_bindingManager; }
@@ -655,6 +661,9 @@ public:
     khtml::Decoder *decoder() const { return m_decoder; }
 
 private:
+    JSEditor *jsEditor();
+
+    JSEditor *m_jsEditor;
     bool relinquishesEditingFocus(NodeImpl *node);
     bool acceptsEditingFocus(NodeImpl *node);
 

-- 
WebKit Debian packaging



More information about the Pkg-webkit-commits mailing list