Move node highlight drawing code to WebCore
authoraroben@apple.com <aroben@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 31 Jan 2008 18:44:38 +0000 (18:44 +0000)
committeraroben@apple.com <aroben@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 31 Jan 2008 18:44:38 +0000 (18:44 +0000)
 WebCore:

         Add node highlight drawing code to InspectorController

         The code came from WebKit/win/WebNodeHighlight.cpp. It's not quite as
         complete as the Mac implementation (in particular, it doesn't handle
         line-box rects), but it's a start.

         Reviewed by Darin.

         * page/InspectorController.cpp:
         (WebCore::InspectorController::drawNodeHighlight): Added.
         * page/InspectorController.h:

 WebKit/win:

         Move node highlight drawing code to WebCore

         Reviewed by Darin.

         * WebNodeHighlight.cpp:
         (WebNodeHighlight::updateWindow): Call into WebCore to do the node
         highlight drawing.

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

WebCore/ChangeLog
WebCore/page/InspectorController.cpp
WebCore/page/InspectorController.h
WebKit/win/ChangeLog
WebKit/win/WebNodeHighlight.cpp

index fee66c8..1dfa167 100644 (file)
@@ -1,3 +1,17 @@
+2008-01-31  Adam Roben  <aroben@apple.com>
+
+        Add node highlight drawing code to InspectorController
+
+        The code came from WebKit/win/WebNodeHighlight.cpp. It's not quite as
+        complete as the Mac implementation (in particular, it doesn't handle
+        line-box rects), but it's a start.
+
+        Reviewed by Darin.
+
+        * page/InspectorController.cpp:
+        (WebCore::InspectorController::drawNodeHighlight): Added.
+        * page/InspectorController.h:
+
 2008-01-31  Dan Bernstein  <mitz@apple.com>
 
         Reviewed by Dave Hyatt.
index 5f791f2..01483b8 100644 (file)
@@ -40,6 +40,7 @@
 #include "Frame.h"
 #include "FrameLoader.h"
 #include "FrameTree.h"
+#include "GraphicsContext.h"
 #include "HTMLFrameOwnerElement.h"
 #include "InspectorClient.h"
 #include "JSRange.h"
@@ -1577,4 +1578,18 @@ void InspectorController::moveWindowBy(float x, float y) const
     m_page->chrome()->setWindowRect(frameRect);
 }
 
+void InspectorController::drawNodeHighlight(GraphicsContext& context, const IntRect& overlayRect, const IntRect& highlightedNodeRect)
+{
+    static const Color overlayFillColor(0, 0, 0, 128);
+    static const int outlineThickness = 1;
+
+    context.clipOut(highlightedNodeRect);
+
+    context.fillRect(overlayRect, overlayFillColor);
+
+    IntRect outlineRect(highlightedNodeRect);
+    outlineRect.inflate(outlineThickness);
+    context.fillRect(outlineRect, Color::white);
+}
+
 } // namespace WebCore
index ace2ac5..a18db30 100644 (file)
@@ -39,6 +39,7 @@ namespace WebCore {
 
 class Database;
 class DocumentLoader;
+class GraphicsContext;
 class InspectorClient;
 class Node;
 class ResourceResponse;
@@ -119,6 +120,8 @@ public:
 
     void moveWindowBy(float x, float y) const;
 
+    static void drawNodeHighlight(GraphicsContext&, const IntRect& overlayRect, const IntRect& highlightedNodeRect);
+
 private:
     void focusNode();
 
index ef70a5d..071d1f7 100644 (file)
@@ -1,3 +1,13 @@
+2008-01-31  Adam Roben  <aroben@apple.com>
+
+        Move node highlight drawing code to WebCore
+
+        Reviewed by Darin.
+
+        * WebNodeHighlight.cpp:
+        (WebNodeHighlight::updateWindow): Call into WebCore to do the node
+        highlight drawing.
+
 2008-01-29  Adam Roben  <aroben@apple.com>
 
         Fix a crash when opening the Inspector
index f86b5c4..0c3fbcd 100644 (file)
@@ -32,6 +32,7 @@
 #pragma warning(push, 0)
 #include <WebCore/Color.h>
 #include <WebCore/GraphicsContext.h>
+#include <WebCore/InspectorController.h>
 #include <WebCore/WindowMessageBroadcaster.h>
 #pragma warning(pop)
 #include <wtf/OwnPtr.h>
@@ -123,25 +124,15 @@ void WebNodeHighlight::updateWindow()
 
     void* pixels = 0;
     OwnPtr<HBITMAP> hbmp(::CreateDIBSection(hdc, &bitmapInfo, DIB_RGB_COLORS, &pixels, 0, 0));
-    if (!hbmp) {
-        DWORD error = ::GetLastError();
-        error++;
-        return;
-    }
 
     ::SelectObject(hdc, hbmp.get());
 
     GraphicsContext context(hdc);
 
-    context.clipOut(m_rect);
-
-    FloatRect overlayRect(webViewRect);
-    overlayRect.setLocation(FloatPoint(0, 0));
-    context.fillRect(overlayRect, Color(0, 0, 0, 128));
+    IntRect overlayRect(webViewRect);
+    overlayRect.setLocation(IntPoint(0, 0));
 
-    IntRect outlineRect(m_rect);
-    outlineRect.inflate(1);
-    context.fillRect(outlineRect, Color::white);
+    InspectorController::drawNodeHighlight(context, overlayRect, m_rect);
 
     BLENDFUNCTION bf;
     bf.BlendOp = AC_SRC_OVER;