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
+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.
namespace {
+bool supportsPasteCommand = false;
+
struct CommandImp {
bool (*execFn)(KHTMLPart *part, bool userInterface, const DOMString &value);
bool (*enabledFn)(KHTMLPart *part);
bool JSEditor::queryCommandSupported(const DOMString &command)
{
+ if (!supportsPasteCommand && command.string().lower() == "paste")
+ return false;
return commandImp(command) != 0;
}
return cmd->valueFn(part);
}
+void JSEditor::setSupportsPasteCommand(bool flag)
+{
+ supportsPasteCommand = flag;
+}
+
// =============================================================================================
// Private stuff, all inside an anonymous namespace.
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();
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();
{ "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 } },
for (int i = 0; i < numCommands; ++i) {
commandDictionary.insert(commands[i].name, &commands[i].imp);
}
+#ifndef NDEBUG
+ supportsPasteCommand = true;
+#endif
return commandDictionary;
}
bool queryCommandSupported(const DOMString &command);
DOMString queryCommandValue(const DOMString &command);
+ static void setSupportsPasteCommand(bool flag=true);
+
private:
JSEditor(const JSEditor &);
JSEditor &operator=(const JSEditor &);
#endif
}
+void KHTMLPart::pasteFromPasteboard()
+{
+#if APPLE_CHANGES
+ KWQ(this)->issuePasteCommand();
+#endif
+}
+
void KHTMLPart::redo()
{
#if APPLE_CHANGES
#if !APPLE_CHANGES
+bool KHTMLPart::canPaste() const
+{
+ // FIXME: Implement.
+ return true;
+}
+
bool KHTMLPart::canRedo() const
{
// FIXME: Implement.
return [[KWQ(this)->_bridge undoManager] canRedo];
}
+bool KHTMLPart::canPaste() const
+{
+ return [KWQ(this)->_bridge canPaste];
+}
+
void KWQKHTMLPart::markMisspellingsInAdjacentWords(const VisiblePosition &p)
{
if (![_bridge isContinuousSpellCheckingEnabled])
#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"
#include "KWQTextStream.h"
using DOM::DocumentImpl;
+using DOM::JSEditor;
using DOM::NodeImpl;
using DOM::Position;
QString externalRepresentation(RenderObject *o)
{
+ JSEditor::setSupportsPasteCommand(true);
+
QString s;
{
QTextStream ts(&s);
- (BOOL)isEditable;
- (BOOL)shouldBeginEditing:(DOMRange *)range;
- (BOOL)shouldEndEditing:(DOMRange *)range;
+- (BOOL)canPaste;
- (NSString *)overrideMediaType;
+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.
[[_frame webView] paste:nil];
}
+- (BOOL)canPaste
+{
+ return [[_frame webView] _canPaste];
+}
+
- (void)setIsSelected:(BOOL)isSelected forView:(NSView *)view
{
if ([view respondsToSelector:@selector(webPlugInSetIsSelected:)]) {
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.
- (BOOL)_interceptEditingKeyEvent:(NSEvent *)event;
- (BOOL)_shouldBeginEditingInDOMRange:(DOMRange *)range;
- (BOOL)_shouldEndEditingInDOMRange:(DOMRange *)range;
+- (BOOL)_canPaste;
@end