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

Side by Side Diff: Source/web/InspectorOverlayImpl.cpp

Issue 1311783003: Devtools[LayoutEditor]: Rework layout-editor workflow (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@resize
Patch Set: Rebase on dgozman changes Created 5 years, 3 months 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 146 matching lines...) Expand 10 before | Expand all | Expand 10 after
157 DEFINE_TRACE(InspectorOverlayImpl) 157 DEFINE_TRACE(InspectorOverlayImpl)
158 { 158 {
159 visitor->trace(m_highlightNode); 159 visitor->trace(m_highlightNode);
160 visitor->trace(m_eventTargetNode); 160 visitor->trace(m_eventTargetNode);
161 visitor->trace(m_overlayPage); 161 visitor->trace(m_overlayPage);
162 visitor->trace(m_overlayChromeClient); 162 visitor->trace(m_overlayChromeClient);
163 visitor->trace(m_overlayHost); 163 visitor->trace(m_overlayHost);
164 visitor->trace(m_layoutEditor); 164 visitor->trace(m_layoutEditor);
165 } 165 }
166 166
167 void InspectorOverlayImpl::init(InspectorCSSAgent* cssAgent, InspectorDebuggerAg ent* debuggerAgent) 167 void InspectorOverlayImpl::init(InspectorCSSAgent* cssAgent, InspectorDebuggerAg ent* debuggerAgent, InspectorDOMAgent* domAgent)
168 { 168 {
169 m_layoutEditor = LayoutEditor::create(cssAgent); 169 m_layoutEditor = LayoutEditor::create(cssAgent, domAgent);
170 m_debuggerAgent = debuggerAgent; 170 m_debuggerAgent = debuggerAgent;
171 m_overlayHost->setListener(this); 171 m_overlayHost->setListener(this);
172 } 172 }
173 173
174 void InspectorOverlayImpl::invalidate() 174 void InspectorOverlayImpl::invalidate()
175 { 175 {
176 if (!m_pageOverlay) 176 if (!m_pageOverlay)
177 m_pageOverlay = PageOverlay::create(m_webViewImpl, new InspectorPageOver layDelegate(*this)); 177 m_pageOverlay = PageOverlay::create(m_webViewImpl, new InspectorPageOver layDelegate(*this));
178 178
179 m_pageOverlay->update(); 179 m_pageOverlay->update();
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
232 } 232 }
233 233
234 void InspectorOverlayImpl::setInspectModeEnabled(bool enabled) 234 void InspectorOverlayImpl::setInspectModeEnabled(bool enabled)
235 { 235 {
236 m_inspectModeEnabled = enabled; 236 m_inspectModeEnabled = enabled;
237 update(); 237 update();
238 } 238 }
239 239
240 void InspectorOverlayImpl::hideHighlight() 240 void InspectorOverlayImpl::hideHighlight()
241 { 241 {
242 if (m_layoutEditor)
243 m_layoutEditor->setNode(nullptr);
244 m_highlightNode.clear(); 242 m_highlightNode.clear();
245 m_eventTargetNode.clear(); 243 m_eventTargetNode.clear();
246 m_highlightQuad.clear(); 244 m_highlightQuad.clear();
247 update(); 245
246 if (m_layoutEditor && m_layoutEditor->node())
247 highlightNode(m_layoutEditor->node(), 0, m_layoutEditor->highlightConfig (), false);
248 else
249 update();
248 } 250 }
249 251
250 void InspectorOverlayImpl::highlightNode(Node* node, Node* eventTarget, const In spectorHighlightConfig& highlightConfig, bool omitTooltip) 252 void InspectorOverlayImpl::highlightNode(Node* node, Node* eventTarget, const In spectorHighlightConfig& highlightConfig, bool omitTooltip)
251 { 253 {
252 m_nodeHighlightConfig = highlightConfig; 254 m_nodeHighlightConfig = highlightConfig;
253 m_highlightNode = node; 255 m_highlightNode = node;
254 if (m_layoutEditor && highlightConfig.showLayoutEditor)
255 m_layoutEditor->setNode(node);
256 m_eventTargetNode = eventTarget; 256 m_eventTargetNode = eventTarget;
257 m_omitTooltip = omitTooltip; 257 m_omitTooltip = omitTooltip;
258 update(); 258 update();
259 } 259 }
260 260
261 void InspectorOverlayImpl::highlightQuad(PassOwnPtr<FloatQuad> quad, const Inspe ctorHighlightConfig& highlightConfig) 261 void InspectorOverlayImpl::highlightQuad(PassOwnPtr<FloatQuad> quad, const Inspe ctorHighlightConfig& highlightConfig)
262 { 262 {
263 m_quadHighlightConfig = highlightConfig; 263 m_quadHighlightConfig = highlightConfig;
264 m_highlightQuad = quad; 264 m_highlightQuad = quad;
265 m_omitTooltip = false; 265 m_omitTooltip = false;
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
317 if (!m_highlightNode) 317 if (!m_highlightNode)
318 return; 318 return;
319 319
320 bool appendElementInfo = m_highlightNode->isElementNode() && !m_omitTooltip && m_nodeHighlightConfig.showInfo && m_highlightNode->layoutObject() && m_highli ghtNode->document().frame(); 320 bool appendElementInfo = m_highlightNode->isElementNode() && !m_omitTooltip && m_nodeHighlightConfig.showInfo && m_highlightNode->layoutObject() && m_highli ghtNode->document().frame();
321 InspectorHighlight highlight(m_highlightNode.get(), m_nodeHighlightConfig, a ppendElementInfo); 321 InspectorHighlight highlight(m_highlightNode.get(), m_nodeHighlightConfig, a ppendElementInfo);
322 if (m_eventTargetNode) 322 if (m_eventTargetNode)
323 highlight.appendEventTargetQuads(m_eventTargetNode.get(), m_nodeHighligh tConfig); 323 highlight.appendEventTargetQuads(m_eventTargetNode.get(), m_nodeHighligh tConfig);
324 324
325 RefPtr<JSONObject> highlightJSON = highlight.asJSONObject(); 325 RefPtr<JSONObject> highlightJSON = highlight.asJSONObject();
326 evaluateInOverlay("drawHighlight", highlightJSON.release()); 326 evaluateInOverlay("drawHighlight", highlightJSON.release());
327 if (m_layoutEditor && m_nodeHighlightConfig.showLayoutEditor) { 327 if (m_layoutEditor && m_layoutEditor->node() == m_highlightNode) {
328 RefPtr<JSONObject> layoutEditorInfo = m_layoutEditor->buildJSONInfo(); 328 RefPtr<JSONObject> layoutEditorInfo = m_layoutEditor->buildJSONInfo();
329 if (layoutEditorInfo) 329 if (layoutEditorInfo)
330 evaluateInOverlay("showLayoutEditor", layoutEditorInfo.release()); 330 evaluateInOverlay("showLayoutEditor", layoutEditorInfo.release());
331 } 331 }
332 } 332 }
333 333
334 void InspectorOverlayImpl::drawQuadHighlight() 334 void InspectorOverlayImpl::drawQuadHighlight()
335 { 335 {
336 if (!m_highlightQuad) 336 if (!m_highlightQuad)
337 return; 337 return;
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after
495 void InspectorOverlayImpl::overlayPropertyChanged(float value) 495 void InspectorOverlayImpl::overlayPropertyChanged(float value)
496 { 496 {
497 m_layoutEditor->overlayPropertyChanged(value); 497 m_layoutEditor->overlayPropertyChanged(value);
498 } 498 }
499 499
500 void InspectorOverlayImpl::overlayEndedPropertyChange() 500 void InspectorOverlayImpl::overlayEndedPropertyChange()
501 { 501 {
502 m_layoutEditor->overlayEndedPropertyChange(); 502 m_layoutEditor->overlayEndedPropertyChange();
503 } 503 }
504 504
505 void InspectorOverlayImpl::clearSelection(bool commitChanges)
506 {
507 m_layoutEditor->clearSelection(commitChanges);
508 }
509
505 void InspectorOverlayImpl::profilingStarted() 510 void InspectorOverlayImpl::profilingStarted()
506 { 511 {
507 if (!m_suspendCount++) 512 if (!m_suspendCount++)
508 clear(); 513 clear();
509 } 514 }
510 515
511 void InspectorOverlayImpl::profilingStopped() 516 void InspectorOverlayImpl::profilingStopped()
512 { 517 {
513 --m_suspendCount; 518 --m_suspendCount;
514 } 519 }
515 520
516 void InspectorOverlayImpl::pageLayoutInvalidated(bool resized) 521 void InspectorOverlayImpl::pageLayoutInvalidated(bool resized)
517 { 522 {
518 if (resized && m_drawViewSize) { 523 if (resized && m_drawViewSize) {
519 m_resizeTimerActive = true; 524 m_resizeTimerActive = true;
520 m_timer.startOneShot(1, FROM_HERE); 525 m_timer.startOneShot(1, FROM_HERE);
521 } 526 }
522 update(); 527 update();
523 } 528 }
524 529
525 void InspectorOverlayImpl::setShowViewportSizeOnResize(bool show, bool showGrid) 530 void InspectorOverlayImpl::setShowViewportSizeOnResize(bool show, bool showGrid)
526 { 531 {
527 m_drawViewSize = show; 532 m_drawViewSize = show;
528 m_drawViewSizeWithGrid = showGrid; 533 m_drawViewSizeWithGrid = showGrid;
529 } 534 }
530 535
536 void InspectorOverlayImpl::showLayoutEditorForNode(Node* node, const InspectorHi ghlightConfig& highlightConfig)
537 {
538 if (!m_layoutEditor)
539 return;
540
541 m_layoutEditor->setNode(node);
542 m_layoutEditor->setHighlightConfig(highlightConfig);
543 }
544
545
531 } // namespace blink 546 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698