Changeset 29887 in webkit
- Timestamp:
- Jan 31, 2008, 10:47:44 AM (17 years ago)
- Location:
- trunk
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/WebCore/ChangeLog
r29886 r29887 1 2008-01-31 Adam Roben <aroben@apple.com> 2 3 Put more knowledge about the node highlight in WebCore 4 5 InspectorController now calculates the overlay rect and node rect when 6 drawing the node highlight instead of having them be passed in. 7 InspectorController now holds onto the highlighted node so that it can 8 determine these rects. 9 10 Once all platforms are calling down to drawNodeHighlight instead of 11 drawing the highlight themselves, we can change 12 InspectorClient::highlight(Node*) to something like 13 InspectorClient::updateAndShowHighlight(). 14 15 This also fixes Bug 14264: Node highlight makes it impossible to 16 scroll the page 17 <http://bugs.webkit.org/show_bug.cgi?id=14264> 18 <rdar://5712788> 19 20 Reviewed by Darin. 21 22 * page/InspectorController.cpp: 23 (WebCore::InspectorController::highlight): Store the node for use in 24 drawNodeHighlight. 25 (WebCore::InspectorController::drawNodeHighlight): Changed to be a 26 const instance method. Now calculates the overlay rect and node rect 27 instead of having them passed in. 28 * page/InspectorController.h: 29 1 30 2008-01-31 Adam Roben <aroben@apple.com> 2 31 -
trunk/WebCore/page/InspectorController.cpp
r29886 r29887 41 41 #include "FrameLoader.h" 42 42 #include "FrameTree.h" 43 #include "FrameView.h" 43 44 #include "GraphicsContext.h" 44 45 #include "HTMLFrameOwnerElement.h" … … 669 670 return; 670 671 ASSERT_ARG(node, node); 672 m_highlightedNode = node; 671 673 m_client->highlight(node); 672 674 } … … 1579 1581 } 1580 1582 1581 void InspectorController::drawNodeHighlight(GraphicsContext& context , const IntRect& overlayRect, const IntRect& highlightedNodeRect)1583 void InspectorController::drawNodeHighlight(GraphicsContext& context) const 1582 1584 { 1583 1585 static const Color overlayFillColor(0, 0, 0, 128); 1584 1586 static const int outlineThickness = 1; 1585 1587 1586 context.clipOut(highlightedNodeRect); 1588 if (!m_highlightedNode) 1589 return; 1590 1591 FrameView* view = m_inspectedPage->mainFrame()->view(); 1592 FloatRect overlayRect = static_cast<ScrollView*>(view)->visibleContentRect(); 1593 context.translate(-overlayRect.x(), -overlayRect.y()); 1594 1595 RenderObject* renderer = m_highlightedNode->renderer(); 1596 if (!renderer) 1597 return; 1598 IntRect nodeRect(renderer->absoluteBoundingBoxRect()); 1599 1600 if (!overlayRect.contains(nodeRect) && !nodeRect.contains(enclosingIntRect(overlayRect))) { 1601 Element* element; 1602 if (m_highlightedNode->isElementNode()) 1603 element = static_cast<Element*>(m_highlightedNode.get()); 1604 else 1605 element = static_cast<Element*>(m_highlightedNode->parent()); 1606 element->scrollIntoViewIfNeeded(); 1607 } 1608 1609 context.clipOut(nodeRect); 1587 1610 1588 1611 context.fillRect(overlayRect, overlayFillColor); 1589 1612 1590 IntRect outlineRect( highlightedNodeRect);1613 IntRect outlineRect(nodeRect); 1591 1614 outlineRect.inflate(outlineThickness); 1592 1615 context.fillRect(outlineRect, Color::white); -
trunk/WebCore/page/InspectorController.h
r29886 r29887 121 121 void moveWindowBy(float x, float y) const; 122 122 123 static void drawNodeHighlight(GraphicsContext&, const IntRect& overlayRect, const IntRect& highlightedNodeRect);123 void drawNodeHighlight(GraphicsContext&) const; 124 124 125 125 private: … … 170 170 SpecialPanels m_showAfterVisible; 171 171 long long m_nextIdentifier; 172 RefPtr<Node> m_highlightedNode; 172 173 }; 173 174 -
trunk/WebKit/win/ChangeLog
r29886 r29887 1 2008-01-31 Adam Roben <aroben@apple.com> 2 3 Let WebCore take care of the highlight drawing entirely 4 5 Reviewed by Darin. 6 7 * WebInspectorClient.cpp: 8 (WebInspectorClient::highlight): We now just show our highlight 9 window and let WebCore figure out what/where to paint. Once all ports 10 follow suit the Node* parameter to this method should be removed 11 entirely, and the name should probably change to 12 updateAndShowHighlight or something similar. 13 * WebNodeHighlight.cpp: Renamed m_webView to m_inspectedWebViewWindow. 14 (WebNodeHighlight::WebNodeHighlight): Now takes a WebView* parameter. 15 (WebNodeHighlight::show): Renamed from highlight(). Now gets the 16 WebView's HWND. Updated for member rename/removal. 17 (WebNodeHighlight::updateWindow): Updated for member rename and for 18 InspectorController changes. 19 * WebNodeHighlight.h: Added m_inspectedWebView member, removed m_rect 20 member, renamed highlight(Node*) -> show(). 21 1 22 2008-01-31 Adam Roben <aroben@apple.com> 2 23 -
trunk/WebKit/win/WebInspectorClient.cpp
r29863 r29887 271 271 } 272 272 273 void WebInspectorClient::highlight(Node* node) 274 { 275 ASSERT_ARG(node, node); 276 277 HWND hwnd; 278 if (FAILED(m_inspectedWebView->viewWindow((OLE_HANDLE*)&hwnd))) 279 return; 280 RECT rect; 281 ::GetClientRect(hwnd, &rect); 282 IntRect webViewRect(rect); 283 284 RenderObject* renderer = node->renderer(); 285 if (!renderer) 286 return; 287 IntRect nodeRect(renderer->absoluteBoundingBoxRect()); 288 289 if (!webViewRect.contains(nodeRect) && !nodeRect.contains(webViewRect)) { 290 Element* element; 291 if (node->isElementNode()) 292 element = static_cast<Element*>(node); 293 else 294 element = static_cast<Element*>(node->parent()); 295 element->scrollIntoViewIfNeeded(); 296 } 297 298 IntSize offset = m_inspectedWebView->page()->mainFrame()->view()->scrollOffset(); 299 nodeRect.move(-offset); 300 273 void WebInspectorClient::highlight(Node*) 274 { 301 275 if (!m_highlight) 302 m_highlight.set(new WebNodeHighlight( hwnd));303 304 m_highlight-> highlight(nodeRect);276 m_highlight.set(new WebNodeHighlight(m_inspectedWebView)); 277 278 m_highlight->show(); 305 279 } 306 280 -
trunk/WebKit/win/WebNodeHighlight.cpp
r29886 r29887 30 30 #include "WebNodeHighlight.h" 31 31 32 #include "WebView.h" 32 33 #pragma warning(push, 0) 33 34 #include <WebCore/Color.h> 34 35 #include <WebCore/GraphicsContext.h> 35 36 #include <WebCore/InspectorController.h> 37 #include <WebCore/Page.h> 36 38 #include <WebCore/WindowMessageBroadcaster.h> 37 39 #pragma warning(pop) … … 45 47 static LPCTSTR kWebNodeHighlightPointerProp = TEXT("WebNodeHighlightPointer"); 46 48 47 WebNodeHighlight::WebNodeHighlight(HWND webView) 48 : m_webView(webView) 49 WebNodeHighlight::WebNodeHighlight(WebView* webView) 50 : m_inspectedWebView(webView) 51 , m_inspectedWebViewWindow(0) 49 52 , m_overlay(0) 50 53 , m_observedWindow(0) … … 61 64 } 62 65 63 void WebNodeHighlight:: highlight(const IntRect& rect)66 void WebNodeHighlight::show() 64 67 { 65 68 if (!m_overlay) { 69 if (FAILED(m_inspectedWebView->viewWindow(reinterpret_cast<OLE_HANDLE*>(&m_inspectedWebViewWindow))) || !IsWindow(m_inspectedWebViewWindow)) 70 return; 71 66 72 registerOverlayClass(); 67 73 68 74 m_overlay = ::CreateWindowEx(WS_EX_LAYERED | WS_EX_TOOLWINDOW, kOverlayWindowClassName, 0, WS_POPUP | WS_VISIBLE, 69 75 0, 0, 0, 0, 70 m_ webView, 0, 0, 0);76 m_inspectedWebViewWindow, 0, 0, 0); 71 77 if (!m_overlay) 72 78 return; 73 79 74 80 ::SetProp(m_overlay, kWebNodeHighlightPointerProp, reinterpret_cast<HANDLE>(this)); 75 ::SetWindowPos(m_overlay, m_ webView, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE);76 77 m_observedWindow = GetAncestor(m_ webView, GA_ROOT);81 ::SetWindowPos(m_overlay, m_inspectedWebViewWindow, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE); 82 83 m_observedWindow = GetAncestor(m_inspectedWebViewWindow, GA_ROOT); 78 84 WindowMessageBroadcaster::addListener(m_observedWindow, this); 79 85 } 80 86 81 m_rect = rect;82 87 updateWindow(); 83 88 ::ShowWindow(m_overlay, SW_SHOW); … … 104 109 105 110 RECT webViewRect; 106 ::GetWindowRect(m_ webView, &webViewRect);111 ::GetWindowRect(m_inspectedWebViewWindow, &webViewRect); 107 112 108 113 SIZE size; … … 130 135 GraphicsContext context(hdc); 131 136 132 IntRect overlayRect(webViewRect); 133 overlayRect.setLocation(IntPoint(0, 0)); 134 135 InspectorController::drawNodeHighlight(context, overlayRect, m_rect); 137 m_inspectedWebView->page()->inspectorController()->drawNodeHighlight(context); 136 138 137 139 BLENDFUNCTION bf; -
trunk/WebKit/win/WebNodeHighlight.h
r27765 r29887 31 31 32 32 #pragma warning(push, 0) 33 #include <WebCore/IntRect.h>34 33 #include <WebCore/WindowMessageListener.h> 35 34 #pragma warning(pop) … … 37 36 #include <windows.h> 38 37 38 class WebView; 39 39 40 class WebNodeHighlight : WebCore::WindowMessageListener { 40 41 public: 41 WebNodeHighlight( HWND webView);42 WebNodeHighlight(WebView*); 42 43 ~WebNodeHighlight(); 43 44 44 void highlight(const WebCore::IntRect&);45 void show(); 45 46 void hide(); 46 47 … … 51 52 virtual void windowReceivedMessage(HWND, UINT message, WPARAM, LPARAM); 52 53 53 HWND m_webView; 54 WebView* m_inspectedWebView; 55 HWND m_inspectedWebViewWindow; 54 56 HWND m_overlay; 55 57 HWND m_observedWindow; 56 57 WebCore::IntRect m_rect;58 58 59 59 friend static LRESULT CALLBACK OverlayWndProc(HWND, UINT, WPARAM, LPARAM);
Note:
See TracChangeset
for help on using the changeset viewer.