WebCore:
authorkocienda <kocienda@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 22 Nov 2004 17:16:23 +0000 (17:16 +0000)
committerkocienda <kocienda@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 22 Nov 2004 17:16:23 +0000 (17:16 +0000)
        Reviewed by Harrison

        Change around the way we block the Javascript "Paste" command identifier from
        being available. Formerly, this was done with an ifdef we never compiled in.
        Now, this is done with a couple of cheap runtime checks. The advantage is that
        we can now compile this command into development builds, and still yet switch
        on the command in deployment builds through the use of WebCore SPI so we can
        write and run layout tests with all of our builds.

        * khtml/editing/jsediting.cpp:
        (DOM::JSEditor::queryCommandSupported): Checks state of paste command in case
        command being queried is the paste command.
        (DOM::JSEditor::setSupportsPasteCommand): New SPI to turn on paste command.
        * khtml/editing/jsediting.h: Ditto.
        * khtml/khtml_part.cpp:
        (KHTMLPart::pasteFromPasteboard): Added.
        (KHTMLPart::canPaste): Added.
        * kwq/KWQKHTMLPart.mm:
        (KHTMLPart::canPaste): Added.
        * kwq/KWQRenderTreeDebug.cpp:
        (externalRepresentation): Turn on paste command.
        * kwq/WebCoreBridge.h: Add canPaste call so WebKit can fill in the answer.

WebKit:

        Reviewed by Harrison

        * WebCoreSupport.subproj/WebBridge.m:
        (-[WebBridge canPaste]): Call WebView _canPaste.
        * WebView.subproj/WebView.m:
        (-[WebView _canPaste]): Try to forward to document view's implementation. Only WebHTMLView
        answers right now. Returns NO otherwise.
        * WebView.subproj/WebViewInternal.h: Add _canPaste method to WebView.

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

WebCore/ChangeLog-2005-08-23
WebCore/khtml/editing/jsediting.cpp
WebCore/khtml/editing/jsediting.h
WebCore/khtml/khtml_part.cpp
WebCore/kwq/KWQKHTMLPart.mm
WebCore/kwq/KWQRenderTreeDebug.cpp
WebCore/kwq/WebCoreBridge.h
WebKit/ChangeLog
WebKit/WebCoreSupport.subproj/WebBridge.m
WebKit/WebView.subproj/WebView.m
WebKit/WebView.subproj/WebViewInternal.h

index 254d7ca6b69377e6bcb92530781a7d8075b421f0..1125486e5463119c3d9bdb76339e69a74842bf11 100644 (file)
@@ -1,3 +1,28 @@
+2004-11-22  Ken Kocienda  <kocienda@apple.com>
+
+        Reviewed by Harrison
+
+        Change around the way we block the Javascript "Paste" command identifier from
+        being available. Formerly, this was done with an ifdef we never compiled in.
+        Now, this is done with a couple of cheap runtime checks. The advantage is that
+        we can now compile this command into development builds, and still yet switch
+        on the command in deployment builds through the use of WebCore SPI so we can
+        write and run layout tests with all of our builds.
+
+        * khtml/editing/jsediting.cpp:
+        (DOM::JSEditor::queryCommandSupported): Checks state of paste command in case
+        command being queried is the paste command. 
+        (DOM::JSEditor::setSupportsPasteCommand): New SPI to turn on paste command.
+        * khtml/editing/jsediting.h: Ditto.
+        * khtml/khtml_part.cpp:
+        (KHTMLPart::pasteFromPasteboard): Added.
+        (KHTMLPart::canPaste): Added.
+        * kwq/KWQKHTMLPart.mm:
+        (KHTMLPart::canPaste): Added.
+        * kwq/KWQRenderTreeDebug.cpp:
+        (externalRepresentation): Turn on paste command.
+        * kwq/WebCoreBridge.h: Add canPaste call so WebKit can fill in the answer.
+
 2004-11-21  Maciej Stachowiak  <mjs@apple.com>
 
         Reviewed by Richard.
index eb03cdfad993822740941a964474d7ba05369b4c..b473dec7174368402e6812bca1b9667456b19f85 100644 (file)
@@ -43,6 +43,8 @@ class DocumentImpl;
 
 namespace {
 
+bool supportsPasteCommand = false;
+
 struct CommandImp {
     bool (*execFn)(KHTMLPart *part, bool userInterface, const DOMString &value);
     bool (*enabledFn)(KHTMLPart *part);
@@ -110,6 +112,8 @@ bool JSEditor::queryCommandState(const DOMString &command)
 
 bool JSEditor::queryCommandSupported(const DOMString &command)
 {
+    if (!supportsPasteCommand && command.string().lower() == "paste")
+        return false;
     return commandImp(command) != 0;
 }
 
@@ -125,6 +129,11 @@ DOMString JSEditor::queryCommandValue(const DOMString &command)
     return cmd->valueFn(part);
 }
 
+void JSEditor::setSupportsPasteCommand(bool flag)
+{
+    supportsPasteCommand = flag;
+}
+
 // =============================================================================================
 
 // Private stuff, all inside an anonymous namespace.
@@ -276,16 +285,12 @@ bool execOutdent(KHTMLPart *part, bool userInterface, const DOMString &value)
     return false;
 }
 
-#if SUPPORT_PASTE
-
 bool execPaste(KHTMLPart *part, bool userInterface, const DOMString &value)
 {
     part->pasteFromPasteboard();
     return true;
 }
 
-#endif
-
 bool execPrint(KHTMLPart *part, bool userInterface, const DOMString &value)
 {
     part->print();
@@ -352,15 +357,11 @@ bool enabledAnySelection(KHTMLPart *part)
     return part->selection().isCaretOrRange();
 }
 
-#if SUPPORT_PASTE
-
 bool enabledPaste(KHTMLPart *part)
 {
-    return part->canPaste();
+    return supportsPasteCommand && part->canPaste();
 }
 
-#endif
-
 bool enabledRangeSelection(KHTMLPart *part)
 {
     return part->selection().isRange();
@@ -480,9 +481,7 @@ QDict<CommandImp> createCommandDictionary()
         { "JustifyNone", { execJustifyLeft, enabledAnySelection, stateNone, valueNull } },
         { "JustifyRight", { execJustifyRight, enabledAnySelection, stateNone, valueNull } },
         { "Outdent", { execOutdent, enabledAnySelection, stateNone, valueNull } },
-#if SUPPORT_PASTE
         { "Paste", { execPaste, enabledPaste, stateNone, valueNull } },
-#endif
         { "Print", { execPrint, enabled, stateNone, valueNull } },
         { "Redo", { execRedo, enabledRedo, stateNone, valueNull } },
         { "SelectAll", { execSelectAll, enabled, stateNone, valueNull } },
@@ -556,6 +555,9 @@ QDict<CommandImp> createCommandDictionary()
     for (int i = 0; i < numCommands; ++i) {
         commandDictionary.insert(commands[i].name, &commands[i].imp);
     }
+#ifndef NDEBUG
+    supportsPasteCommand = true;
+#endif
     return commandDictionary;
 }
 
index 5cc1606e6155e00dc31c1a31b8795ef071022bd0..850462d03f818d9238cf94c107534a55509199bb 100644 (file)
@@ -49,6 +49,8 @@ public:
     bool queryCommandSupported(const DOMString &command);
     DOMString queryCommandValue(const DOMString &command);
 
+    static void setSupportsPasteCommand(bool flag=true);
+
 private:
     JSEditor(const JSEditor &);
     JSEditor &operator=(const JSEditor &);
index 72f185fd09fc1013b60a1dbf5acb6433b8150600..f8f4b07989bbbf9d098be19d08aa234ce45baad8 100644 (file)
@@ -5292,6 +5292,13 @@ void KHTMLPart::cutToPasteboard()
 #endif
 }
 
+void KHTMLPart::pasteFromPasteboard()
+{
+#if APPLE_CHANGES
+    KWQ(this)->issuePasteCommand();
+#endif
+}
+
 void KHTMLPart::redo()
 {
 #if APPLE_CHANGES
@@ -5308,6 +5315,12 @@ void KHTMLPart::undo()
 
 #if !APPLE_CHANGES
 
+bool KHTMLPart::canPaste() const
+{
+    // FIXME: Implement.
+    return true;
+}
+
 bool KHTMLPart::canRedo() const
 {
     // FIXME: Implement.
index 9f62ae2d79afdc9a54603f2fd864ae7a4e053737..09a209547a547d36850a192e92d2e5a89fa1e6a6 100644 (file)
@@ -3958,6 +3958,11 @@ bool KHTMLPart::canRedo() const
     return [[KWQ(this)->_bridge undoManager] canRedo];
 }
 
+bool KHTMLPart::canPaste() const
+{
+    return [KWQ(this)->_bridge canPaste];
+}
+
 void KWQKHTMLPart::markMisspellingsInAdjacentWords(const VisiblePosition &p)
 {
     if (![_bridge isContinuousSpellCheckingEnabled])
index d6601387ef5d45c257cfbb89a27cd0c639f443d8..1726ac2b43f247ec0d8917c77144488de8d2beb9 100644 (file)
@@ -28,6 +28,7 @@
 #include "dom_docimpl.h"
 #include "dom_position.h"
 #include "htmltags.h"
+#include "jsediting.h"
 #include "khtmlview.h"
 #include "render_canvas.h"
 #include "render_replaced.h"
@@ -40,6 +41,7 @@
 #include "KWQTextStream.h"
 
 using DOM::DocumentImpl;
+using DOM::JSEditor;
 using DOM::NodeImpl;
 using DOM::Position;
 
@@ -424,6 +426,8 @@ static void writeSelection(QTextStream &ts, const RenderObject *o)
 
 QString externalRepresentation(RenderObject *o)
 {
+    JSEditor::setSupportsPasteCommand(true);
+
     QString s;
     {
         QTextStream ts(&s);
index d230e6498ec97e3908279dc0da759e3b24e9c654..6f9d2366938b2b9500a0605c98823ef63b2a40da 100644 (file)
@@ -541,6 +541,7 @@ typedef enum {
 - (BOOL)isEditable;
 - (BOOL)shouldBeginEditing:(DOMRange *)range;
 - (BOOL)shouldEndEditing:(DOMRange *)range;
+- (BOOL)canPaste;
 
 - (NSString *)overrideMediaType;
 
index fc6f93f6d94eb1763648aab1886cd4827cb8b765..d03d91eba9a2c37398bfac79884a98981ed176fb 100644 (file)
@@ -1,3 +1,14 @@
+2004-11-22  Ken Kocienda  <kocienda@apple.com>
+
+        Reviewed by Harrison
+
+        * WebCoreSupport.subproj/WebBridge.m:
+        (-[WebBridge canPaste]): Call WebView _canPaste.
+        * WebView.subproj/WebView.m:
+        (-[WebView _canPaste]): Try to forward to document view's implementation. Only WebHTMLView
+        answers right now. Returns NO otherwise.
+        * WebView.subproj/WebViewInternal.h: Add _canPaste method to WebView.
+
 2004-11-22  Maciej Stachowiak  <mjs@apple.com>
 
        Back  out the window closing fix, it seems to be causing crashes.
index aa7e8a1c1cbb2e7ab3693d0e896953020f058844..f138367151834ad84addcae893313f0ae137713e 100644 (file)
@@ -1350,6 +1350,11 @@ static id <WebFormDelegate> formDelegate(WebBridge *self)
     [[_frame webView] paste:nil];
 }
 
+- (BOOL)canPaste
+{
+    return [[_frame webView] _canPaste];
+}
+
 - (void)setIsSelected:(BOOL)isSelected forView:(NSView *)view
 {
     if ([view respondsToSelector:@selector(webPlugInSetIsSelected:)]) {
index c792b5c3125c9db38e30188daf1059a4f2ecddb9..40aa881762d90a85cf23d6a2ef176e49f1e6313b 100644 (file)
@@ -2513,6 +2513,12 @@ static WebFrame *incrementFrame(WebFrame *curr, BOOL forward, BOOL wrapFlag)
     return [[self _editingDelegateForwarder] webView:self shouldEndEditingInDOMRange:range];
 }
 
+- (BOOL)_canPaste
+{
+    id documentView = [[[self mainFrame] frameView] documentView];
+    return [documentView respondsToSelector:@selector(_canPaste)] && [documentView _canPaste];
+}
+
 - (void)setSelectedDOMRange:(DOMRange *)range affinity:(NSSelectionAffinity)selectionAffinity
 {
     // Derive the bridge to use from the range passed in.
index 27cbd0324781c514ff6370da151efaa80f4393da..096e937a2eeeda43cc92caa0db1c54b1ecd49c10 100644 (file)
 - (BOOL)_interceptEditingKeyEvent:(NSEvent *)event;
 - (BOOL)_shouldBeginEditingInDOMRange:(DOMRange *)range;
 - (BOOL)_shouldEndEditingInDOMRange:(DOMRange *)range;
+- (BOOL)_canPaste;
 @end