Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(55)

Side by Side Diff: third_party/WebKit/Source/web/InspectorOverlay.cpp

Issue 2421983002: [DevTools] Remove layout editor experiment. (Closed)
Patch Set: rebased Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 21 matching lines...) Expand all
32 #include "bindings/core/v8/ScriptSourceCode.h" 32 #include "bindings/core/v8/ScriptSourceCode.h"
33 #include "bindings/core/v8/V8InspectorOverlayHost.h" 33 #include "bindings/core/v8/V8InspectorOverlayHost.h"
34 #include "core/dom/Node.h" 34 #include "core/dom/Node.h"
35 #include "core/dom/StaticNodeList.h" 35 #include "core/dom/StaticNodeList.h"
36 #include "core/frame/FrameHost.h" 36 #include "core/frame/FrameHost.h"
37 #include "core/frame/FrameView.h" 37 #include "core/frame/FrameView.h"
38 #include "core/frame/LocalFrame.h" 38 #include "core/frame/LocalFrame.h"
39 #include "core/frame/Settings.h" 39 #include "core/frame/Settings.h"
40 #include "core/frame/VisualViewport.h" 40 #include "core/frame/VisualViewport.h"
41 #include "core/input/EventHandler.h" 41 #include "core/input/EventHandler.h"
42 #include "core/inspector/InspectorCSSAgent.h"
43 #include "core/inspector/InspectorOverlayHost.h" 42 #include "core/inspector/InspectorOverlayHost.h"
44 #include "core/inspector/LayoutEditor.h"
45 #include "core/layout/api/LayoutViewItem.h" 43 #include "core/layout/api/LayoutViewItem.h"
46 #include "core/loader/EmptyClients.h" 44 #include "core/loader/EmptyClients.h"
47 #include "core/loader/FrameLoadRequest.h" 45 #include "core/loader/FrameLoadRequest.h"
48 #include "core/page/ChromeClient.h" 46 #include "core/page/ChromeClient.h"
49 #include "core/page/Page.h" 47 #include "core/page/Page.h"
50 #include "platform/ScriptForbiddenScope.h" 48 #include "platform/ScriptForbiddenScope.h"
51 #include "platform/graphics/GraphicsContext.h" 49 #include "platform/graphics/GraphicsContext.h"
52 #include "platform/graphics/paint/CullRect.h" 50 #include "platform/graphics/paint/CullRect.h"
53 #include "public/platform/Platform.h" 51 #include "public/platform/Platform.h"
54 #include "public/platform/WebData.h" 52 #include "public/platform/WebData.h"
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
138 DEFINE_INLINE_VIRTUAL_TRACE() { 136 DEFINE_INLINE_VIRTUAL_TRACE() {
139 visitor->trace(m_client); 137 visitor->trace(m_client);
140 visitor->trace(m_overlay); 138 visitor->trace(m_overlay);
141 EmptyChromeClient::trace(visitor); 139 EmptyChromeClient::trace(visitor);
142 } 140 }
143 141
144 void setCursor(const Cursor& cursor, LocalFrame* localRoot) override { 142 void setCursor(const Cursor& cursor, LocalFrame* localRoot) override {
145 toChromeClientImpl(m_client)->setCursorOverridden(false); 143 toChromeClientImpl(m_client)->setCursorOverridden(false);
146 toChromeClientImpl(m_client)->setCursor(cursor, 144 toChromeClientImpl(m_client)->setCursor(cursor,
147 m_overlay->m_frameImpl->frame()); 145 m_overlay->m_frameImpl->frame());
148 bool overrideCursor = m_overlay->m_layoutEditor; 146 toChromeClientImpl(m_client)->setCursorOverridden(false);
149 toChromeClientImpl(m_client)->setCursorOverridden(overrideCursor);
150 } 147 }
151 148
152 void setToolTip(LocalFrame& frame, 149 void setToolTip(LocalFrame& frame,
153 const String& tooltip, 150 const String& tooltip,
154 TextDirection direction) override { 151 TextDirection direction) override {
155 DCHECK_EQ(&frame, m_overlay->overlayMainFrame()); 152 DCHECK_EQ(&frame, m_overlay->overlayMainFrame());
156 m_client->setToolTip(*m_overlay->m_frameImpl->frame(), tooltip, direction); 153 m_client->setToolTip(*m_overlay->m_frameImpl->frame(), tooltip, direction);
157 } 154 }
158 155
159 void invalidateRect(const IntRect&) override { m_overlay->invalidate(); } 156 void invalidateRect(const IntRect&) override { m_overlay->invalidate(); }
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
191 } 188 }
192 189
193 DEFINE_TRACE(InspectorOverlay) { 190 DEFINE_TRACE(InspectorOverlay) {
194 visitor->trace(m_frameImpl); 191 visitor->trace(m_frameImpl);
195 visitor->trace(m_highlightNode); 192 visitor->trace(m_highlightNode);
196 visitor->trace(m_eventTargetNode); 193 visitor->trace(m_eventTargetNode);
197 visitor->trace(m_overlayPage); 194 visitor->trace(m_overlayPage);
198 visitor->trace(m_overlayChromeClient); 195 visitor->trace(m_overlayChromeClient);
199 visitor->trace(m_overlayHost); 196 visitor->trace(m_overlayHost);
200 visitor->trace(m_domAgent); 197 visitor->trace(m_domAgent);
201 visitor->trace(m_cssAgent);
202 visitor->trace(m_layoutEditor);
203 visitor->trace(m_hoveredNodeForInspectMode); 198 visitor->trace(m_hoveredNodeForInspectMode);
204 } 199 }
205 200
206 void InspectorOverlay::init(InspectorCSSAgent* cssAgent, 201 void InspectorOverlay::init(v8_inspector::V8InspectorSession* v8Session,
207 v8_inspector::V8InspectorSession* v8Session,
208 InspectorDOMAgent* domAgent) { 202 InspectorDOMAgent* domAgent) {
209 m_v8Session = v8Session; 203 m_v8Session = v8Session;
210 m_domAgent = domAgent; 204 m_domAgent = domAgent;
211 m_cssAgent = cssAgent;
212 m_overlayHost->setListener(this); 205 m_overlayHost->setListener(this);
213 } 206 }
214 207
215 void InspectorOverlay::invalidate() { 208 void InspectorOverlay::invalidate() {
216 if (!m_pageOverlay) { 209 if (!m_pageOverlay) {
217 m_pageOverlay = PageOverlay::create( 210 m_pageOverlay = PageOverlay::create(
218 m_frameImpl, wrapUnique(new InspectorPageOverlayDelegate(*this))); 211 m_frameImpl, wrapUnique(new InspectorPageOverlayDelegate(*this)));
219 } 212 }
220 213
221 m_pageOverlay->update(); 214 m_pageOverlay->update();
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after
353 m_nodeHighlightConfig = highlightConfig; 346 m_nodeHighlightConfig = highlightConfig;
354 m_highlightNode = node; 347 m_highlightNode = node;
355 m_eventTargetNode = eventTarget; 348 m_eventTargetNode = eventTarget;
356 m_omitTooltip = omitTooltip; 349 m_omitTooltip = omitTooltip;
357 scheduleUpdate(); 350 scheduleUpdate();
358 } 351 }
359 352
360 void InspectorOverlay::setInspectMode( 353 void InspectorOverlay::setInspectMode(
361 InspectorDOMAgent::SearchMode searchMode, 354 InspectorDOMAgent::SearchMode searchMode,
362 std::unique_ptr<InspectorHighlightConfig> highlightConfig) { 355 std::unique_ptr<InspectorHighlightConfig> highlightConfig) {
363 if (m_layoutEditor)
364 overlayClearSelection(true);
365
366 m_inspectMode = searchMode; 356 m_inspectMode = searchMode;
367 scheduleUpdate(); 357 scheduleUpdate();
368 358
369 if (searchMode != InspectorDOMAgent::NotSearching) { 359 if (searchMode != InspectorDOMAgent::NotSearching) {
370 m_inspectModeHighlightConfig = std::move(highlightConfig); 360 m_inspectModeHighlightConfig = std::move(highlightConfig);
371 } else { 361 } else {
372 m_hoveredNodeForInspectMode.clear(); 362 m_hoveredNodeForInspectMode.clear();
373 hideHighlight(); 363 hideHighlight();
374 } 364 }
375 } 365 }
376 366
377 void InspectorOverlay::setInspectedNode(Node* node) {
378 if (m_inspectMode != InspectorDOMAgent::ShowLayoutEditor ||
379 (m_layoutEditor && m_layoutEditor->element() == node))
380 return;
381
382 if (m_layoutEditor) {
383 m_layoutEditor->commitChanges();
384 m_layoutEditor.clear();
385 }
386 initializeLayoutEditorIfNeeded(node);
387 }
388
389 void InspectorOverlay::highlightQuad( 367 void InspectorOverlay::highlightQuad(
390 std::unique_ptr<FloatQuad> quad, 368 std::unique_ptr<FloatQuad> quad,
391 const InspectorHighlightConfig& highlightConfig) { 369 const InspectorHighlightConfig& highlightConfig) {
392 m_quadHighlightConfig = highlightConfig; 370 m_quadHighlightConfig = highlightConfig;
393 m_highlightQuad = std::move(quad); 371 m_highlightQuad = std::move(quad);
394 m_omitTooltip = false; 372 m_omitTooltip = false;
395 scheduleUpdate(); 373 scheduleUpdate();
396 } 374 }
397 375
398 bool InspectorOverlay::isEmpty() { 376 bool InspectorOverlay::isEmpty() {
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
437 reset(viewportSize, visibleRectInDocument.location()); 415 reset(viewportSize, visibleRectInDocument.location());
438 416
439 if (m_showReloadingBlanket) { 417 if (m_showReloadingBlanket) {
440 evaluateInOverlay("showReloadingBlanket", ""); 418 evaluateInOverlay("showReloadingBlanket", "");
441 return; 419 return;
442 } 420 }
443 drawNodeHighlight(); 421 drawNodeHighlight();
444 drawQuadHighlight(); 422 drawQuadHighlight();
445 drawPausedInDebuggerMessage(); 423 drawPausedInDebuggerMessage();
446 drawViewSize(); 424 drawViewSize();
447 if (m_layoutEditor && !m_highlightNode)
448 m_layoutEditor->rebuild();
449 } 425 }
450 426
451 static std::unique_ptr<protocol::DictionaryValue> buildObjectForSize( 427 static std::unique_ptr<protocol::DictionaryValue> buildObjectForSize(
452 const IntSize& size) { 428 const IntSize& size) {
453 std::unique_ptr<protocol::DictionaryValue> result = 429 std::unique_ptr<protocol::DictionaryValue> result =
454 protocol::DictionaryValue::create(); 430 protocol::DictionaryValue::create();
455 result->setInteger("width", size.width()); 431 result->setInteger("width", size.width());
456 result->setInteger("height", size.height()); 432 result->setInteger("height", size.height());
457 return result; 433 return result;
458 } 434 }
(...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after
672 ScriptController::ExecuteScriptWhenScriptsDisabled); 648 ScriptController::ExecuteScriptWhenScriptsDisabled);
673 return toCoreStringWithUndefinedOrNullCheck(string); 649 return toCoreStringWithUndefinedOrNullCheck(string);
674 } 650 }
675 651
676 void InspectorOverlay::onTimer(TimerBase*) { 652 void InspectorOverlay::onTimer(TimerBase*) {
677 m_resizeTimerActive = false; 653 m_resizeTimerActive = false;
678 scheduleUpdate(); 654 scheduleUpdate();
679 } 655 }
680 656
681 void InspectorOverlay::clearInternal() { 657 void InspectorOverlay::clearInternal() {
682 if (m_layoutEditor)
683 m_layoutEditor.clear();
684
685 if (m_overlayPage) { 658 if (m_overlayPage) {
686 m_overlayPage->willBeDestroyed(); 659 m_overlayPage->willBeDestroyed();
687 m_overlayPage.clear(); 660 m_overlayPage.clear();
688 m_overlayChromeClient.clear(); 661 m_overlayChromeClient.clear();
689 } 662 }
690 m_resizeTimerActive = false; 663 m_resizeTimerActive = false;
691 m_pausedInDebuggerMessage = String(); 664 m_pausedInDebuggerMessage = String();
692 m_inspectMode = InspectorDOMAgent::NotSearching; 665 m_inspectMode = InspectorDOMAgent::NotSearching;
693 m_timer.stop(); 666 m_timer.stop();
694 hideHighlight(); 667 hideHighlight();
695 } 668 }
696 669
697 void InspectorOverlay::clear() { 670 void InspectorOverlay::clear() {
698 clearInternal(); 671 clearInternal();
699 m_v8Session = nullptr; 672 m_v8Session = nullptr;
700 m_domAgent.clear(); 673 m_domAgent.clear();
701 m_cssAgent.clear();
702 m_overlayHost->setListener(nullptr); 674 m_overlayHost->setListener(nullptr);
703 } 675 }
704 676
705 void InspectorOverlay::overlayResumed() { 677 void InspectorOverlay::overlayResumed() {
706 if (m_v8Session) 678 if (m_v8Session)
707 m_v8Session->resume(); 679 m_v8Session->resume();
708 } 680 }
709 681
710 void InspectorOverlay::overlaySteppedOver() { 682 void InspectorOverlay::overlaySteppedOver() {
711 if (m_v8Session) 683 if (m_v8Session)
712 m_v8Session->stepOver(); 684 m_v8Session->stepOver();
713 } 685 }
714 686
715 void InspectorOverlay::overlayStartedPropertyChange(const String& property) {
716 DCHECK(m_layoutEditor);
717 m_layoutEditor->overlayStartedPropertyChange(property);
718 }
719
720 void InspectorOverlay::overlayPropertyChanged(float value) {
721 DCHECK(m_layoutEditor);
722 m_layoutEditor->overlayPropertyChanged(value);
723 }
724
725 void InspectorOverlay::overlayEndedPropertyChange() {
726 DCHECK(m_layoutEditor);
727 m_layoutEditor->overlayEndedPropertyChange();
728 }
729
730 void InspectorOverlay::overlayNextSelector() {
731 DCHECK(m_layoutEditor);
732 m_layoutEditor->nextSelector();
733 }
734
735 void InspectorOverlay::overlayPreviousSelector() {
736 DCHECK(m_layoutEditor);
737 m_layoutEditor->previousSelector();
738 }
739
740 void InspectorOverlay::overlayClearSelection(bool commitChanges) {
741 DCHECK(m_layoutEditor);
742 m_hoveredNodeForInspectMode = m_layoutEditor->element();
743
744 if (commitChanges)
745 m_layoutEditor->commitChanges();
746
747 if (m_layoutEditor) {
748 m_layoutEditor->dispose();
749 m_layoutEditor.clear();
750 }
751
752 if (m_inspectModeHighlightConfig)
753 highlightNode(m_hoveredNodeForInspectMode.get(),
754 *m_inspectModeHighlightConfig, false);
755
756 toChromeClientImpl(m_frameImpl->frame()->host()->chromeClient())
757 .setCursorOverridden(false);
758 toChromeClientImpl(m_frameImpl->frame()->host()->chromeClient())
759 .setCursor(pointerCursor(), overlayMainFrame());
760 }
761
762 void InspectorOverlay::suspend() { 687 void InspectorOverlay::suspend() {
763 if (!m_suspended) { 688 if (!m_suspended) {
764 m_suspended = true; 689 m_suspended = true;
765 clearInternal(); 690 clearInternal();
766 } 691 }
767 } 692 }
768 693
769 void InspectorOverlay::resume() { 694 void InspectorOverlay::resume() {
770 m_suspended = false; 695 m_suspended = false;
771 } 696 }
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
850 Node* node = hoveredNodeForEvent(m_frameImpl->frame(), event, false); 775 Node* node = hoveredNodeForEvent(m_frameImpl->frame(), event, false);
851 if (node && m_inspectModeHighlightConfig) { 776 if (node && m_inspectModeHighlightConfig) {
852 highlightNode(node, *m_inspectModeHighlightConfig, false); 777 highlightNode(node, *m_inspectModeHighlightConfig, false);
853 inspect(node); 778 inspect(node);
854 return true; 779 return true;
855 } 780 }
856 return false; 781 return false;
857 } 782 }
858 783
859 bool InspectorOverlay::shouldSearchForNode() { 784 bool InspectorOverlay::shouldSearchForNode() {
860 return m_inspectMode != InspectorDOMAgent::NotSearching && !m_layoutEditor; 785 return m_inspectMode != InspectorDOMAgent::NotSearching;
861 } 786 }
862 787
863 void InspectorOverlay::inspect(Node* node) { 788 void InspectorOverlay::inspect(Node* node) {
864 if (m_domAgent) 789 if (m_domAgent)
865 m_domAgent->inspect(node); 790 m_domAgent->inspect(node);
866
867 initializeLayoutEditorIfNeeded(node);
868 if (m_layoutEditor)
869 hideHighlight();
870 }
871
872 void InspectorOverlay::initializeLayoutEditorIfNeeded(Node* node) {
873 if (m_inspectMode != InspectorDOMAgent::ShowLayoutEditor || !node ||
874 !node->isElementNode() || !node->ownerDocument()->isActive() ||
875 !m_cssAgent || !m_domAgent)
876 return;
877 m_layoutEditor = LayoutEditor::create(toElement(node), m_cssAgent, m_domAgent,
878 &overlayMainFrame()->script());
879 toChromeClientImpl(m_frameImpl->frame()->host()->chromeClient())
880 .setCursorOverridden(true);
881 } 791 }
882 792
883 } // namespace blink 793 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/web/InspectorOverlay.h ('k') | third_party/WebKit/Source/web/WebDevToolsAgentImpl.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698