* Allow adding the Inspect ContextMenuItem to our Menu
authorzecke@webkit.org <zecke@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 3 Dec 2007 17:58:23 +0000 (17:58 +0000)
committerzecke@webkit.org <zecke@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 3 Dec 2007 17:58:23 +0000 (17:58 +0000)
* Open the Inspector when Inspect was activated. This requires
  that we keep the innerNonSharedNode from the HitTest around. This
  forces us to include <wtf/RefPtr.h> in the private header. It is
  the first non Qt header but should be okay.

Signed-off-by: Simon
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@28348 268f45cc-cd09-0410-ab3c-d52691b4dbfc

WebKit/qt/Api/qwebpage.cpp
WebKit/qt/Api/qwebpage.h
WebKit/qt/Api/qwebpage_p.h
WebKit/qt/ChangeLog

index f0e6a0a28b4542df94923fe27e643a56a663404b..8876e68f90612928a33b16e9fbc76301a9335e08 100644 (file)
@@ -47,6 +47,7 @@
 #include "Image.h"
 #include "IconDatabase.h"
 #include "InspectorClientQt.h"
+#include "InspectorController.h"
 #include "FocusController.h"
 #include "Editor.h"
 #include "PlatformScrollBar.h"
@@ -157,6 +158,7 @@ static QWebPage::WebAction webActionForContextMenuAction(WebCore::ContextMenuAct
         case WebCore::ContextMenuItemTagBold: return QWebPage::ToggleBold;
         case WebCore::ContextMenuItemTagItalic: return QWebPage::ToggleItalic;
         case WebCore::ContextMenuItemTagUnderline: return QWebPage::ToggleUnderline;
+        case WebCore::ContextMenuItemTagInspectElement: return QWebPage::InspectElement;
         default: break;
     }
     return QWebPage::NoWebAction;
@@ -591,6 +593,7 @@ void QWebPage::triggerAction(WebAction action, bool checked)
             editor->setBaseWritingDirection("rtl");
             break;
 
+
         case ToggleBold:
             command = "ToggleBold";
             break;
@@ -599,6 +602,9 @@ void QWebPage::triggerAction(WebAction action, bool checked)
             break;
         case ToggleUnderline:
             editor->toggleUnderline();
+
+        case InspectElement:
+            d->page->inspectorController()->inspect(d->currentContext.d->innerNonSharedNode.get());
             break;
 
         default: break;
@@ -742,6 +748,10 @@ QAction *QWebPage::action(WebAction action) const
             checkable = true;
             break;
 
+        case InspectElement:
+            text = contextMenuItemTagInspectElement();
+            break;
+
         case NoWebAction:
             return 0;
     }
@@ -1269,6 +1279,7 @@ QWebPageContext::QWebPageContext(const WebCore::HitTestResult &hitTest)
     d->text = hitTest.textContent();
     d->linkUrl = hitTest.absoluteLinkURL().url();
     d->imageUrl = hitTest.absoluteImageURL().url();
+    d->innerNonSharedNode = hitTest.innerNonSharedNode();
     WebCore::Image *img = hitTest.image();
     if (img) {
         QPixmap *pix = img->getPixmap();
index 620450f1faea05202c860f6fc7442a107a6c71c8..8cd5f5d5576d31bf69a1aeb5293fd8f6a77cb359 100644 (file)
@@ -130,6 +130,8 @@ public:
         ToggleItalic,
         ToggleUnderline,
 
+        InspectElement,
+
         WebActionCount
     };
 
index b050a456cf3155388f7bb20f83322f792c77c6f0..98e4debd113ec8e79424abfca31231aa21f9dc28 100644 (file)
@@ -28,6 +28,8 @@
 #include "qwebpage.h"
 #include "qwebframe.h"
 
+#include <wtf/RefPtr.h>
+
 namespace WebCore
 {
     class ChromeClientQt;
@@ -35,6 +37,7 @@ namespace WebCore
     class ContextMenuItem;
     class ContextMenu;
     class EditorClientQt;
+    class Node;
     class Page;
 }
 
@@ -50,6 +53,7 @@ public:
     QUrl imageUrl;
     QPixmap image;
     QPointer<QWebFrame> targetFrame;
+    RefPtr<WebCore::Node> innerNonSharedNode;
 };
 
 class QWebPageContext
index ebbe6872b3447b48763c262243a4cd72a6c935af..5ef1300a39dfdc358ff0a5ee1fbda63489f8a522 100644 (file)
@@ -1,3 +1,22 @@
+2007-12-03  Holger Hans Peter Freyther  <holger.freyther@trolltech.com>
+
+        Reviewed by Simon.
+
+        * Allow adding the Inspect ContextMenuItem to our Menu
+        * Open the Inspector when Inspect was activated. This requires
+        that we keep the innerNonSharedNode from the HitTest around. This
+        forces us to include <wtf/RefPtr.h> in the private header. It is
+        the first non Qt header but should be okay.
+        
+
+        * Api/qwebpage.cpp:
+        (webActionForContextMenuAction):
+        (QWebPage::triggerAction):
+        (QWebPage::action):
+        (QWebPageContext::QWebPageContext):
+        * Api/qwebpage.h:
+        * Api/qwebpage_p.h:
+
 2007-12-03  Holger Hans Peter Freyther  <holger.freyther@trolltech.com>
 
         Reviewed by Simon.