OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2011 Google Inc. All rights reserved. | 2 * Copyright (C) 2011 Google Inc. All rights reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions | 5 * modification, are permitted provided that the following conditions |
6 * are met: | 6 * are met: |
7 * | 7 * |
8 * 1. Redistributions of source code must retain the above copyright | 8 * 1. Redistributions of source code must retain the above copyright |
9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
10 * 2. Redistributions in binary form must reproduce the above copyright | 10 * 2. Redistributions in binary form must reproduce the above copyright |
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
146 | 146 |
147 static bool buildNodeQuads(Node* node, Vector<FloatQuad>& quads) | 147 static bool buildNodeQuads(Node* node, Vector<FloatQuad>& quads) |
148 { | 148 { |
149 RenderObject* renderer = node->renderer(); | 149 RenderObject* renderer = node->renderer(); |
150 LocalFrame* containingFrame = node->document().frame(); | 150 LocalFrame* containingFrame = node->document().frame(); |
151 | 151 |
152 if (!renderer || !containingFrame) | 152 if (!renderer || !containingFrame) |
153 return false; | 153 return false; |
154 | 154 |
155 FrameView* containingView = containingFrame->view(); | 155 FrameView* containingView = containingFrame->view(); |
156 FrameView* mainView = containingFrame->page()->mainFrame()->view(); | 156 FrameView* mainView = containingFrame->page()->deprecatedLocalMainFrame()->v
iew(); |
157 IntRect boundingBox = pixelSnappedIntRect(containingView->contentsToRootView
(renderer->absoluteBoundingBoxRect())); | 157 IntRect boundingBox = pixelSnappedIntRect(containingView->contentsToRootView
(renderer->absoluteBoundingBoxRect())); |
158 boundingBox.move(mainView->scrollOffset()); | 158 boundingBox.move(mainView->scrollOffset()); |
159 | 159 |
160 // RenderSVGRoot should be highlighted through the isBox() code path, all ot
her SVG elements should just dump their absoluteQuads(). | 160 // RenderSVGRoot should be highlighted through the isBox() code path, all ot
her SVG elements should just dump their absoluteQuads(). |
161 if (renderer->node() && renderer->node()->isSVGElement() && !renderer->isSVG
Root()) { | 161 if (renderer->node() && renderer->node()->isSVGElement() && !renderer->isSVG
Root()) { |
162 renderer->absoluteQuads(quads); | 162 renderer->absoluteQuads(quads); |
163 for (size_t i = 0; i < quads.size(); ++i) | 163 for (size_t i = 0; i < quads.size(); ++i) |
164 contentsQuadToPage(mainView, containingView, quads[i]); | 164 contentsQuadToPage(mainView, containingView, quads[i]); |
165 return false; | 165 return false; |
166 } | 166 } |
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
264 InspectorOverlay::~InspectorOverlay() | 264 InspectorOverlay::~InspectorOverlay() |
265 { | 265 { |
266 ASSERT(!m_overlayPage); | 266 ASSERT(!m_overlayPage); |
267 } | 267 } |
268 | 268 |
269 void InspectorOverlay::paint(GraphicsContext& context) | 269 void InspectorOverlay::paint(GraphicsContext& context) |
270 { | 270 { |
271 if (isEmpty()) | 271 if (isEmpty()) |
272 return; | 272 return; |
273 GraphicsContextStateSaver stateSaver(context); | 273 GraphicsContextStateSaver stateSaver(context); |
274 FrameView* view = overlayPage()->mainFrame()->view(); | 274 FrameView* view = toLocalFrame(overlayPage()->mainFrame())->view(); |
275 ASSERT(!view->needsLayout()); | 275 ASSERT(!view->needsLayout()); |
276 view->paint(&context, IntRect(0, 0, view->width(), view->height())); | 276 view->paint(&context, IntRect(0, 0, view->width(), view->height())); |
277 } | 277 } |
278 | 278 |
279 void InspectorOverlay::invalidate() | 279 void InspectorOverlay::invalidate() |
280 { | 280 { |
281 m_client->highlight(); | 281 m_client->highlight(); |
282 } | 282 } |
283 | 283 |
284 bool InspectorOverlay::handleGestureEvent(const PlatformGestureEvent& event) | 284 bool InspectorOverlay::handleGestureEvent(const PlatformGestureEvent& event) |
285 { | 285 { |
286 if (isEmpty()) | 286 if (isEmpty()) |
287 return false; | 287 return false; |
288 | 288 |
289 return overlayPage()->mainFrame()->eventHandler().handleGestureEvent(event); | 289 return toLocalFrame(overlayPage()->mainFrame())->eventHandler().handleGestur
eEvent(event); |
290 } | 290 } |
291 | 291 |
292 bool InspectorOverlay::handleMouseEvent(const PlatformMouseEvent& event) | 292 bool InspectorOverlay::handleMouseEvent(const PlatformMouseEvent& event) |
293 { | 293 { |
294 if (isEmpty()) | 294 if (isEmpty()) |
295 return false; | 295 return false; |
296 | 296 |
297 EventHandler& eventHandler = overlayPage()->mainFrame()->eventHandler(); | 297 EventHandler& eventHandler = toLocalFrame(overlayPage()->mainFrame())->event
Handler(); |
298 bool result; | 298 bool result; |
299 switch (event.type()) { | 299 switch (event.type()) { |
300 case PlatformEvent::MouseMoved: | 300 case PlatformEvent::MouseMoved: |
301 result = eventHandler.handleMouseMoveEvent(event); | 301 result = eventHandler.handleMouseMoveEvent(event); |
302 break; | 302 break; |
303 case PlatformEvent::MousePressed: | 303 case PlatformEvent::MousePressed: |
304 result = eventHandler.handleMousePressEvent(event); | 304 result = eventHandler.handleMousePressEvent(event); |
305 break; | 305 break; |
306 case PlatformEvent::MouseReleased: | 306 case PlatformEvent::MouseReleased: |
307 result = eventHandler.handleMouseReleaseEvent(event); | 307 result = eventHandler.handleMouseReleaseEvent(event); |
308 break; | 308 break; |
309 default: | 309 default: |
310 return false; | 310 return false; |
311 } | 311 } |
312 | 312 |
313 overlayPage()->mainFrame()->document()->updateLayout(); | 313 toLocalFrame(overlayPage()->mainFrame())->document()->updateLayout(); |
314 return result; | 314 return result; |
315 } | 315 } |
316 | 316 |
317 bool InspectorOverlay::handleTouchEvent(const PlatformTouchEvent& event) | 317 bool InspectorOverlay::handleTouchEvent(const PlatformTouchEvent& event) |
318 { | 318 { |
319 if (isEmpty()) | 319 if (isEmpty()) |
320 return false; | 320 return false; |
321 | 321 |
322 return overlayPage()->mainFrame()->eventHandler().handleTouchEvent(event); | 322 return toLocalFrame(overlayPage()->mainFrame())->eventHandler().handleTouchE
vent(event); |
323 } | 323 } |
324 | 324 |
325 bool InspectorOverlay::handleKeyboardEvent(const PlatformKeyboardEvent& event) | 325 bool InspectorOverlay::handleKeyboardEvent(const PlatformKeyboardEvent& event) |
326 { | 326 { |
327 if (isEmpty()) | 327 if (isEmpty()) |
328 return false; | 328 return false; |
329 | 329 |
330 return overlayPage()->mainFrame()->eventHandler().keyEvent(event); | 330 return toLocalFrame(overlayPage()->mainFrame())->eventHandler().keyEvent(eve
nt); |
331 } | 331 } |
332 | 332 |
333 void InspectorOverlay::drawOutline(GraphicsContext* context, const LayoutRect& r
ect, const Color& color) | 333 void InspectorOverlay::drawOutline(GraphicsContext* context, const LayoutRect& r
ect, const Color& color) |
334 { | 334 { |
335 FloatRect outlineRect = rect; | 335 FloatRect outlineRect = rect; |
336 drawOutlinedQuad(context, outlineRect, Color(), color); | 336 drawOutlinedQuad(context, outlineRect, Color(), color); |
337 } | 337 } |
338 | 338 |
339 void InspectorOverlay::setPausedInDebuggerMessage(const String* message) | 339 void InspectorOverlay::setPausedInDebuggerMessage(const String* message) |
340 { | 340 { |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
395 return !(hasAlwaysVisibleElements || (hasInvisibleInInspectModeElements && !
m_inspectModeEnabled)); | 395 return !(hasAlwaysVisibleElements || (hasInvisibleInInspectModeElements && !
m_inspectModeEnabled)); |
396 } | 396 } |
397 | 397 |
398 void InspectorOverlay::update() | 398 void InspectorOverlay::update() |
399 { | 399 { |
400 if (isEmpty()) { | 400 if (isEmpty()) { |
401 m_client->hideHighlight(); | 401 m_client->hideHighlight(); |
402 return; | 402 return; |
403 } | 403 } |
404 | 404 |
405 FrameView* view = m_page->mainFrame()->view(); | 405 FrameView* view = m_page->deprecatedLocalMainFrame()->view(); |
406 if (!view) | 406 if (!view) |
407 return; | 407 return; |
408 | 408 |
409 // Include scrollbars to avoid masking them by the gutter. | 409 // Include scrollbars to avoid masking them by the gutter. |
410 IntSize size = view->unscaledVisibleContentSize(IncludeScrollbars); | 410 IntSize size = view->unscaledVisibleContentSize(IncludeScrollbars); |
411 overlayPage()->mainFrame()->view()->resize(size); | 411 toLocalFrame(overlayPage()->mainFrame())->view()->resize(size); |
412 | 412 |
413 // Clear canvas and paint things. | 413 // Clear canvas and paint things. |
414 IntRect viewRect = view->visibleContentRect(); | 414 IntRect viewRect = view->visibleContentRect(); |
415 reset(size, viewRect.x(), viewRect.y()); | 415 reset(size, viewRect.x(), viewRect.y()); |
416 | 416 |
417 drawNodeHighlight(); | 417 drawNodeHighlight(); |
418 drawQuadHighlight(); | 418 drawQuadHighlight(); |
419 if (!m_inspectModeEnabled) | 419 if (!m_inspectModeEnabled) |
420 drawPausedInDebuggerMessage(); | 420 drawPausedInDebuggerMessage(); |
421 drawViewSize(); | 421 drawViewSize(); |
422 | 422 |
423 // Position DOM elements. | 423 // Position DOM elements. |
424 overlayPage()->mainFrame()->document()->setNeedsStyleRecalc(SubtreeStyleChan
ge); | 424 toLocalFrame(overlayPage()->mainFrame())->document()->setNeedsStyleRecalc(Su
btreeStyleChange); |
425 overlayPage()->mainFrame()->document()->updateLayout(); | 425 toLocalFrame(overlayPage()->mainFrame())->document()->updateLayout(); |
426 | 426 |
427 // Kick paint. | 427 // Kick paint. |
428 m_client->highlight(); | 428 m_client->highlight(); |
429 } | 429 } |
430 | 430 |
431 void InspectorOverlay::hide() | 431 void InspectorOverlay::hide() |
432 { | 432 { |
433 m_timer.stop(); | 433 m_timer.stop(); |
434 m_highlightNode.clear(); | 434 m_highlightNode.clear(); |
435 m_eventTargetNode.clear(); | 435 m_eventTargetNode.clear(); |
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
543 RenderObject* renderer = node->renderer(); | 543 RenderObject* renderer = node->renderer(); |
544 if (!renderer || !renderer->isBox() || !toRenderBox(renderer)->shapeOutsideI
nfo()) | 544 if (!renderer || !renderer->isBox() || !toRenderBox(renderer)->shapeOutsideI
nfo()) |
545 return nullptr; | 545 return nullptr; |
546 | 546 |
547 LocalFrame* containingFrame = node->document().frame(); | 547 LocalFrame* containingFrame = node->document().frame(); |
548 RenderBox* renderBox = toRenderBox(renderer); | 548 RenderBox* renderBox = toRenderBox(renderer); |
549 const ShapeOutsideInfo* shapeOutsideInfo = renderBox->shapeOutsideInfo(); | 549 const ShapeOutsideInfo* shapeOutsideInfo = renderBox->shapeOutsideInfo(); |
550 | 550 |
551 LayoutRect shapeBounds = shapeOutsideInfo->computedShapePhysicalBoundingBox(
); | 551 LayoutRect shapeBounds = shapeOutsideInfo->computedShapePhysicalBoundingBox(
); |
552 FloatQuad shapeQuad = renderBox->localToAbsoluteQuad(FloatRect(shapeBounds))
; | 552 FloatQuad shapeQuad = renderBox->localToAbsoluteQuad(FloatRect(shapeBounds))
; |
553 FrameView* mainView = containingFrame->page()->mainFrame()->view(); | 553 FrameView* mainView = containingFrame->page()->deprecatedLocalMainFrame()->v
iew(); |
554 FrameView* containingView = containingFrame->view(); | 554 FrameView* containingView = containingFrame->view(); |
555 contentsQuadToPage(mainView, containingView, shapeQuad); | 555 contentsQuadToPage(mainView, containingView, shapeQuad); |
556 | 556 |
557 Shape::DisplayPaths paths; | 557 Shape::DisplayPaths paths; |
558 shapeOutsideInfo->computedShape().buildDisplayPaths(paths); | 558 shapeOutsideInfo->computedShape().buildDisplayPaths(paths); |
559 RefPtr<TypeBuilder::Array<JSONValue> > shapePath = TypeBuilder::Array<JSONVa
lue>::create(); | 559 RefPtr<TypeBuilder::Array<JSONValue> > shapePath = TypeBuilder::Array<JSONVa
lue>::create(); |
560 RefPtr<TypeBuilder::Array<JSONValue> > marginShapePath = TypeBuilder::Array<
JSONValue>::create(); | 560 RefPtr<TypeBuilder::Array<JSONValue> > marginShapePath = TypeBuilder::Array<
JSONValue>::create(); |
561 | 561 |
562 if (paths.shape.length()) { | 562 if (paths.shape.length()) { |
563 PathApplyInfo info; | 563 PathApplyInfo info; |
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
731 | 731 |
732 return m_overlayPage.get(); | 732 return m_overlayPage.get(); |
733 } | 733 } |
734 | 734 |
735 void InspectorOverlay::reset(const IntSize& viewportSize, int scrollX, int scrol
lY) | 735 void InspectorOverlay::reset(const IntSize& viewportSize, int scrollX, int scrol
lY) |
736 { | 736 { |
737 RefPtr<JSONObject> resetData = JSONObject::create(); | 737 RefPtr<JSONObject> resetData = JSONObject::create(); |
738 resetData->setNumber("pageScaleFactor", m_page->settings().pinchVirtualViewp
ortEnabled() ? 1 : m_page->pageScaleFactor()); | 738 resetData->setNumber("pageScaleFactor", m_page->settings().pinchVirtualViewp
ortEnabled() ? 1 : m_page->pageScaleFactor()); |
739 resetData->setNumber("deviceScaleFactor", m_page->deviceScaleFactor()); | 739 resetData->setNumber("deviceScaleFactor", m_page->deviceScaleFactor()); |
740 resetData->setObject("viewportSize", buildObjectForSize(viewportSize)); | 740 resetData->setObject("viewportSize", buildObjectForSize(viewportSize)); |
741 resetData->setNumber("pageZoomFactor", m_page->mainFrame()->pageZoomFactor()
); | 741 resetData->setNumber("pageZoomFactor", m_page->deprecatedLocalMainFrame()->p
ageZoomFactor()); |
742 resetData->setNumber("scrollX", scrollX); | 742 resetData->setNumber("scrollX", scrollX); |
743 resetData->setNumber("scrollY", scrollY); | 743 resetData->setNumber("scrollY", scrollY); |
744 evaluateInOverlay("reset", resetData.release()); | 744 evaluateInOverlay("reset", resetData.release()); |
745 } | 745 } |
746 | 746 |
747 void InspectorOverlay::evaluateInOverlay(const String& method, const String& arg
ument) | 747 void InspectorOverlay::evaluateInOverlay(const String& method, const String& arg
ument) |
748 { | 748 { |
749 RefPtr<JSONArray> command = JSONArray::create(); | 749 RefPtr<JSONArray> command = JSONArray::create(); |
750 command->pushString(method); | 750 command->pushString(method); |
751 command->pushString(argument); | 751 command->pushString(argument); |
752 overlayPage()->mainFrame()->script().executeScriptInMainWorld("dispatch(" +
command->toJSONString() + ")", ScriptController::ExecuteScriptWhenScriptsDisable
d); | 752 toLocalFrame(overlayPage()->mainFrame())->script().executeScriptInMainWorld(
"dispatch(" + command->toJSONString() + ")", ScriptController::ExecuteScriptWhen
ScriptsDisabled); |
753 } | 753 } |
754 | 754 |
755 void InspectorOverlay::evaluateInOverlay(const String& method, PassRefPtr<JSONVa
lue> argument) | 755 void InspectorOverlay::evaluateInOverlay(const String& method, PassRefPtr<JSONVa
lue> argument) |
756 { | 756 { |
757 RefPtr<JSONArray> command = JSONArray::create(); | 757 RefPtr<JSONArray> command = JSONArray::create(); |
758 command->pushString(method); | 758 command->pushString(method); |
759 command->pushValue(argument); | 759 command->pushValue(argument); |
760 overlayPage()->mainFrame()->script().executeScriptInMainWorld("dispatch(" +
command->toJSONString() + ")", ScriptController::ExecuteScriptWhenScriptsDisable
d); | 760 toLocalFrame(overlayPage()->mainFrame())->script().executeScriptInMainWorld(
"dispatch(" + command->toJSONString() + ")", ScriptController::ExecuteScriptWhen
ScriptsDisabled); |
761 } | 761 } |
762 | 762 |
763 void InspectorOverlay::onTimer(Timer<InspectorOverlay>*) | 763 void InspectorOverlay::onTimer(Timer<InspectorOverlay>*) |
764 { | 764 { |
765 m_drawViewSize = false; | 765 m_drawViewSize = false; |
766 update(); | 766 update(); |
767 } | 767 } |
768 | 768 |
769 bool InspectorOverlay::getBoxModel(Node* node, Vector<FloatQuad>* quads) | 769 bool InspectorOverlay::getBoxModel(Node* node, Vector<FloatQuad>* quads) |
770 { | 770 { |
771 return buildNodeQuads(node, *quads); | 771 return buildNodeQuads(node, *quads); |
772 } | 772 } |
773 | 773 |
774 void InspectorOverlay::freePage() | 774 void InspectorOverlay::freePage() |
775 { | 775 { |
776 if (m_overlayPage) { | 776 if (m_overlayPage) { |
777 // FIXME: This logic is duplicated in SVGImage and WebViewImpl. Perhaps
it can be combined | 777 // FIXME: This logic is duplicated in SVGImage and WebViewImpl. Perhaps
it can be combined |
778 // into Page's destructor. | 778 // into Page's destructor. |
779 m_overlayPage->mainFrame()->loader().frameDetached(); | 779 toLocalFrame(m_overlayPage->mainFrame())->loader().frameDetached(); |
780 m_overlayPage->willBeDestroyed(); | 780 m_overlayPage->willBeDestroyed(); |
781 m_overlayPage.clear(); | 781 m_overlayPage.clear(); |
782 } | 782 } |
783 m_overlayChromeClient.clear(); | 783 m_overlayChromeClient.clear(); |
784 m_timer.stop(); | 784 m_timer.stop(); |
785 | 785 |
786 // This will clear internal structures and issue update to the client. Safe
to call last. | 786 // This will clear internal structures and issue update to the client. Safe
to call last. |
787 hideHighlight(); | 787 hideHighlight(); |
788 } | 788 } |
789 | 789 |
790 void InspectorOverlay::startedRecordingProfile() | 790 void InspectorOverlay::startedRecordingProfile() |
791 { | 791 { |
792 if (!m_activeProfilerCount++) | 792 if (!m_activeProfilerCount++) |
793 freePage(); | 793 freePage(); |
794 } | 794 } |
795 | 795 |
796 } // namespace WebCore | 796 } // namespace WebCore |
OLD | NEW |