2008-08-15 HÃ¥vard Wall <hwall@trolltech.com>
[WebKit-https.git] / WebKit / qt / WebCoreSupport / EditorClientQt.cpp
index 560f9585a671323775b1ae98f8097cbfc649552f..7463571b1ce35bafeb450531f3f1f9f9236671d0 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2006 Nikolas Zimmermann <zimmermann@kde.org> 
+ * Copyright (C) 2006 Nikolas Zimmermann <zimmermann@kde.org>
  * Copyright (C) 2006 Zack Rusin <zack@kde.org>
  * Copyright (C) 2006 Apple Computer, Inc.
  *
@@ -73,7 +73,7 @@ void QWEBKIT_EXPORT qt_dump_set_accepts_editing(bool b)
 static QString dumpPath(WebCore::Node *node)
 {
     QString str = node->nodeName();
-    
+
     WebCore::Node *parent = node->parentNode();
     while (parent) {
         str.append(QLatin1String(" > "));
@@ -94,14 +94,14 @@ static QString dumpRange(WebCore::Range *range)
                 range->endOffset(code), dumpPath(range->endContainer(code)).unicode());
     return str;
 }
-    
+
 
 namespace WebCore {
 
 
 bool EditorClientQt::shouldDeleteRange(Range* range)
 {
-    if (dumpEditingCallbacks) 
+    if (dumpEditingCallbacks)
         printf("EDITING DELEGATE: shouldDeleteDOMRange:%s\n", dumpRange(range).toUtf8().constData());
 
     return true;
@@ -109,7 +109,7 @@ bool EditorClientQt::shouldDeleteRange(Range* range)
 
 bool EditorClientQt::shouldShowDeleteInterface(HTMLElement* element)
 {
-    if (drt_run) 
+    if (drt_run)
         return element->className() == "needsDeletionUI";
     return false;
 }
@@ -151,7 +151,7 @@ bool EditorClientQt::shouldInsertText(const String& string, Range* range, Editor
             "WebViewInsertActionPasted",
             "WebViewInsertActionDropped",
         };
-        
+
         printf("EDITING DELEGATE: shouldInsertText:%s replacingDOMRange:%s givenAction:%s\n",
                QString(string).toUtf8().constData(), dumpRange(range).toUtf8().constData(), insertactionstring[action]);
     }
@@ -169,7 +169,7 @@ bool EditorClientQt::shouldChangeSelectedRange(Range* currentRange, Range* propo
             "FALSE",
             "TRUE"
         };
-        
+
         printf("EDITING DELEGATE: shouldChangeSelectedDOMRange:%s toDOMRange:%s affinity:%s stillSelecting:%s\n",
                dumpRange(currentRange).toUtf8().constData(),
                dumpRange(proposedRange).toUtf8().constData(),
@@ -249,11 +249,13 @@ bool EditorClientQt::isEditable()
 
 void EditorClientQt::registerCommandForUndo(WTF::PassRefPtr<WebCore::EditCommand> cmd)
 {
+#ifndef QT_NO_UNDOSTACK
     Frame* frame = m_page->d->page->focusController()->focusedOrMainFrame();
     if (m_inUndoRedo || (frame && !frame->editor()->lastEditCommand() /* HACK!! Don't recreate undos */)) {
         return;
     }
     m_page->undoStack()->push(new EditCommandQt(cmd));
+#endif // QT_NO_UNDOSTACK
 }
 
 void EditorClientQt::registerCommandForRedo(WTF::PassRefPtr<WebCore::EditCommand>)
@@ -262,31 +264,45 @@ void EditorClientQt::registerCommandForRedo(WTF::PassRefPtr<WebCore::EditCommand
 
 void EditorClientQt::clearUndoRedoOperations()
 {
+#ifndef QT_NO_UNDOSTACK
     return m_page->undoStack()->clear();
+#endif
 }
 
 bool EditorClientQt::canUndo() const
 {
+#ifdef QT_NO_UNDOSTACK
+    return false;
+#else
     return m_page->undoStack()->canUndo();
+#endif
 }
 
 bool EditorClientQt::canRedo() const
 {
+#ifdef QT_NO_UNDOSTACK
+    return false;
+#else
     return m_page->undoStack()->canRedo();
+#endif
 }
 
 void EditorClientQt::undo()
 {
+#ifndef QT_NO_UNDOSTACK
     m_inUndoRedo = true;
     m_page->undoStack()->undo();
     m_inUndoRedo = false;
+#endif
 }
 
 void EditorClientQt::redo()
 {
+#ifndef QT_NO_UNDOSTACK
     m_inUndoRedo = true;
     m_page->undoStack()->redo();
     m_inUndoRedo = false;
+#endif
 }
 
 bool EditorClientQt::shouldInsertNode(Node* node, Range* range, EditorInsertAction action)
@@ -297,7 +313,7 @@ bool EditorClientQt::shouldInsertNode(Node* node, Range* range, EditorInsertActi
             "WebViewInsertActionPasted",
             "WebViewInsertActionDropped",
         };
-        
+
         printf("EDITING DELEGATE: shouldInsertNode:%s replacingDOMRange:%s givenAction:%s\n", dumpPath(node).toUtf8().constData(),
                dumpRange(range).toUtf8().constData(), insertactionstring[action]);
     }