Reviewed by Anders.
authorweinig@apple.com <weinig@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 14 Dec 2007 01:10:00 +0000 (01:10 +0000)
committerweinig@apple.com <weinig@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 14 Dec 2007 01:10:00 +0000 (01:10 +0000)
        Fix for http://bugs.webkit.org/show_bug.cgi?id=16352
        Toolbar dragged inspector cannot be moved beyond screen edges

        * page/InspectorController.cpp:
        (WebCore::moveByUnrestricted):
        (WebCore::InspectorController::windowScriptObjectAvailable):
        (WebCore::InspectorController::moveByUnrestricted):
        * page/InspectorController.h:
        * page/inspector/inspector.js:

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

WebCore/ChangeLog
WebCore/page/InspectorController.cpp
WebCore/page/InspectorController.h
WebCore/page/inspector/inspector.js

index d7a802a..53cddd7 100644 (file)
@@ -1,3 +1,17 @@
+2007-12-13  Sam Weinig  <sam@webkit.org>
+
+        Reviewed by Anders.
+
+        Fix for http://bugs.webkit.org/show_bug.cgi?id=16352
+        Toolbar dragged inspector cannot be moved beyond screen edges
+
+        * page/InspectorController.cpp:
+        (WebCore::moveByUnrestricted):
+        (WebCore::InspectorController::windowScriptObjectAvailable):
+        (WebCore::InspectorController::moveByUnrestricted):
+        * page/InspectorController.h:
+        * page/inspector/inspector.js:
+
 2007-12-13  Adam Roben  <aroben@apple.com>
 
         Fix <rdar://5517707> Crash on wptv.wp.pl when "make bigger" button is clicked
index adf0bca..1f3f8bf 100644 (file)
 #include "Document.h"
 #include "DocumentLoader.h"
 #include "Element.h"
+#include "FloatConversion.h"
 #include "FloatRect.h"
 #include "Frame.h"
 #include "FrameLoader.h"
 #include "FrameTree.h"
 #include "HTMLFrameOwnerElement.h"
 #include "InspectorClient.h"
-#if ENABLE(DATABASE)
-#include "JSDatabase.h"
-#endif
 #include "JSRange.h"
 #include "Page.h"
 #include "Range.h"
 #include "ResourceRequest.h"
 #include "ResourceResponse.h"
 #include "Settings.h"
-#include <wtf/RefCounted.h>
 #include "SharedBuffer.h"
 #include "SystemTime.h"
 #include "TextEncoding.h"
 #include <JavaScriptCore/JSLock.h>
 #include <JavaScriptCore/JSRetainPtr.h>
 #include <JavaScriptCore/JSStringRef.h>
+#include <wtf/RefCounted.h>
+
+#if ENABLE(DATABASE)
+#include "JSDatabase.h"
+#endif
 
 namespace WebCore {
 
@@ -570,6 +572,20 @@ static JSValueRef platform(JSContextRef ctx, JSObjectRef /*function*/, JSObjectR
     return platformValue;
 }
 
+static JSValueRef moveByUnrestricted(JSContextRef ctx, JSObjectRef /*function*/, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* /*exception*/)
+{
+    InspectorController* controller = reinterpret_cast<InspectorController*>(JSObjectGetPrivate(thisObject));
+    if (!controller)
+        return JSValueMakeUndefined(ctx);
+
+    if (argumentCount < 2 )
+        return JSValueMakeUndefined(ctx);
+
+    controller->moveByUnrestricted(narrowPrecisionToFloat(JSValueToNumber(ctx, arguments[0], 0)), narrowPrecisionToFloat(JSValueToNumber(ctx, arguments[1], 0)));
+
+    return JSValueMakeUndefined(ctx);
+}
+
 InspectorController::InspectorController(Page* page, InspectorClient* client)
     : m_inspectedPage(page)
     , m_client(client)
@@ -747,21 +763,22 @@ void InspectorController::windowScriptObjectAvailable()
     ASSERT(global);
 
     static JSStaticFunction staticFunctions[] = {
-        { "addSourceToFrame", addSourceToFrame, kJSPropertyAttributeNone },
-        { "getResourceDocumentNode", getResourceDocumentNode, kJSPropertyAttributeNone },
-        { "highlightDOMNode", highlightDOMNode, kJSPropertyAttributeNone },
-        { "hideDOMNodeHighlight", hideDOMNodeHighlight, kJSPropertyAttributeNone },
-        { "loaded", loaded, kJSPropertyAttributeNone },
-        { "windowUnloading", unloading, kJSPropertyAttributeNone },
-        { "attach", attach, kJSPropertyAttributeNone },
-        { "detach", detach, kJSPropertyAttributeNone },
-        { "search", search, kJSPropertyAttributeNone },
+        { "addSourceToFrame", WebCore::addSourceToFrame, kJSPropertyAttributeNone },
+        { "getResourceDocumentNode", WebCore::getResourceDocumentNode, kJSPropertyAttributeNone },
+        { "highlightDOMNode", WebCore::highlightDOMNode, kJSPropertyAttributeNone },
+        { "hideDOMNodeHighlight", WebCore::hideDOMNodeHighlight, kJSPropertyAttributeNone },
+        { "loaded", WebCore::loaded, kJSPropertyAttributeNone },
+        { "windowUnloading", WebCore::unloading, kJSPropertyAttributeNone },
+        { "attach", WebCore::attach, kJSPropertyAttributeNone },
+        { "detach", WebCore::detach, kJSPropertyAttributeNone },
+        { "search", WebCore::search, kJSPropertyAttributeNone },
 #if ENABLE(DATABASE)
-        { "databaseTableNames", databaseTableNames, kJSPropertyAttributeNone },
+        { "databaseTableNames", WebCore::databaseTableNames, kJSPropertyAttributeNone },
 #endif
-        { "inspectedWindow", inspectedWindow, kJSPropertyAttributeNone },
-        { "localizedStringsURL", localizedStrings, kJSPropertyAttributeNone },
-        { "platform", platform, kJSPropertyAttributeNone },
+        { "inspectedWindow", WebCore::inspectedWindow, kJSPropertyAttributeNone },
+        { "localizedStringsURL", WebCore::localizedStrings, kJSPropertyAttributeNone },
+        { "platform", WebCore::platform, kJSPropertyAttributeNone },
+        { "moveByUnrestricted", WebCore::moveByUnrestricted, kJSPropertyAttributeNone },
         { 0, 0, 0 }
     };
 
@@ -1604,4 +1621,14 @@ void InspectorController::didOpenDatabase(Database* database, const String& doma
 }
 #endif
 
+void InspectorController::moveByUnrestricted(float x, float y) const
+{
+    if (!m_page || !enabled())
+        return;
+
+    FloatRect frameRect = m_page->chrome()->windowRect();
+    frameRect.move(x, y);
+    m_page->chrome()->setWindowRect(frameRect);
+}
+
 } // namespace WebCore
index 1686cb7..35c955e 100644 (file)
@@ -117,6 +117,8 @@ public:
 
     const ResourcesMap& resources() const { return m_resources; }
 
+    void moveByUnrestricted(float x, float y) const;
+
 private:
     void focusNode();
 
index 0c3985a..1c6b900 100644 (file)
@@ -583,7 +583,9 @@ WebInspector.toolbarDrag = function(event)
     toolbar.lastScreenX = event.screenX;
     toolbar.lastScreenY = event.screenY;
 
-    window.moveBy(x, y);
+    // We cannot call window.moveBy here becuase it restricts the movement of the window
+    // at the edges.
+    InspectorController.moveByUnrestricted(x, y);
 
     event.preventDefault();
 }