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

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

Issue 2004313003: DevTools: migrate from OwnPtr to std::unique_ptr for inspector protocol classes. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebaselined Created 4 years, 6 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
« no previous file with comments | « third_party/WebKit/Source/web/InspectorOverlay.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 378 matching lines...) Expand 10 before | Expand all | Expand 10 after
389 reset(viewportSize, visibleRectInDocument.location()); 389 reset(viewportSize, visibleRectInDocument.location());
390 390
391 drawNodeHighlight(); 391 drawNodeHighlight();
392 drawQuadHighlight(); 392 drawQuadHighlight();
393 drawPausedInDebuggerMessage(); 393 drawPausedInDebuggerMessage();
394 drawViewSize(); 394 drawViewSize();
395 if (m_layoutEditor && !m_highlightNode) 395 if (m_layoutEditor && !m_highlightNode)
396 m_layoutEditor->rebuild(); 396 m_layoutEditor->rebuild();
397 } 397 }
398 398
399 static PassOwnPtr<protocol::DictionaryValue> buildObjectForSize(const IntSize& s ize) 399 static std::unique_ptr<protocol::DictionaryValue> buildObjectForSize(const IntSi ze& size)
400 { 400 {
401 OwnPtr<protocol::DictionaryValue> result = protocol::DictionaryValue::create (); 401 std::unique_ptr<protocol::DictionaryValue> result = protocol::DictionaryValu e::create();
402 result->setNumber("width", size.width()); 402 result->setNumber("width", size.width());
403 result->setNumber("height", size.height()); 403 result->setNumber("height", size.height());
404 return result; 404 return result;
405 } 405 }
406 406
407 void InspectorOverlay::drawNodeHighlight() 407 void InspectorOverlay::drawNodeHighlight()
408 { 408 {
409 if (!m_highlightNode) 409 if (!m_highlightNode)
410 return; 410 return;
411 411
412 String selectors = m_nodeHighlightConfig.selectorList; 412 String selectors = m_nodeHighlightConfig.selectorList;
413 StaticElementList* elements = nullptr; 413 StaticElementList* elements = nullptr;
414 TrackExceptionState exceptionState; 414 TrackExceptionState exceptionState;
415 ContainerNode* queryBase = m_highlightNode->containingShadowRoot(); 415 ContainerNode* queryBase = m_highlightNode->containingShadowRoot();
416 if (!queryBase) 416 if (!queryBase)
417 queryBase = m_highlightNode->ownerDocument(); 417 queryBase = m_highlightNode->ownerDocument();
418 if (selectors.length()) 418 if (selectors.length())
419 elements = queryBase->querySelectorAll(AtomicString(selectors), exceptio nState); 419 elements = queryBase->querySelectorAll(AtomicString(selectors), exceptio nState);
420 if (elements && !exceptionState.hadException()) { 420 if (elements && !exceptionState.hadException()) {
421 for (unsigned i = 0; i < elements->length(); ++i) { 421 for (unsigned i = 0; i < elements->length(); ++i) {
422 Element* element = elements->item(i); 422 Element* element = elements->item(i);
423 InspectorHighlight highlight(element, m_nodeHighlightConfig, false); 423 InspectorHighlight highlight(element, m_nodeHighlightConfig, false);
424 OwnPtr<protocol::DictionaryValue> highlightJSON = highlight.asProtoc olValue(); 424 std::unique_ptr<protocol::DictionaryValue> highlightJSON = highlight .asProtocolValue();
425 evaluateInOverlay("drawHighlight", std::move(highlightJSON)); 425 evaluateInOverlay("drawHighlight", std::move(highlightJSON));
426 } 426 }
427 } 427 }
428 428
429 bool appendElementInfo = m_highlightNode->isElementNode() && !m_omitTooltip && m_nodeHighlightConfig.showInfo && m_highlightNode->layoutObject() && m_highli ghtNode->document().frame(); 429 bool appendElementInfo = m_highlightNode->isElementNode() && !m_omitTooltip && m_nodeHighlightConfig.showInfo && m_highlightNode->layoutObject() && m_highli ghtNode->document().frame();
430 InspectorHighlight highlight(m_highlightNode.get(), m_nodeHighlightConfig, a ppendElementInfo); 430 InspectorHighlight highlight(m_highlightNode.get(), m_nodeHighlightConfig, a ppendElementInfo);
431 if (m_eventTargetNode) 431 if (m_eventTargetNode)
432 highlight.appendEventTargetQuads(m_eventTargetNode.get(), m_nodeHighligh tConfig); 432 highlight.appendEventTargetQuads(m_eventTargetNode.get(), m_nodeHighligh tConfig);
433 433
434 OwnPtr<protocol::DictionaryValue> highlightJSON = highlight.asProtocolValue( ); 434 std::unique_ptr<protocol::DictionaryValue> highlightJSON = highlight.asProto colValue();
435 evaluateInOverlay("drawHighlight", std::move(highlightJSON)); 435 evaluateInOverlay("drawHighlight", std::move(highlightJSON));
436 } 436 }
437 437
438 void InspectorOverlay::drawQuadHighlight() 438 void InspectorOverlay::drawQuadHighlight()
439 { 439 {
440 if (!m_highlightQuad) 440 if (!m_highlightQuad)
441 return; 441 return;
442 442
443 InspectorHighlight highlight; 443 InspectorHighlight highlight;
444 highlight.appendQuad(*m_highlightQuad, m_quadHighlightConfig.content, m_quad HighlightConfig.contentOutline); 444 highlight.appendQuad(*m_highlightQuad, m_quadHighlightConfig.content, m_quad HighlightConfig.contentOutline);
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
521 return m_overlayPage.get(); 521 return m_overlayPage.get();
522 } 522 }
523 523
524 LocalFrame* InspectorOverlay::overlayMainFrame() 524 LocalFrame* InspectorOverlay::overlayMainFrame()
525 { 525 {
526 return toLocalFrame(overlayPage()->mainFrame()); 526 return toLocalFrame(overlayPage()->mainFrame());
527 } 527 }
528 528
529 void InspectorOverlay::reset(const IntSize& viewportSize, const IntPoint& docume ntScrollOffset) 529 void InspectorOverlay::reset(const IntSize& viewportSize, const IntPoint& docume ntScrollOffset)
530 { 530 {
531 OwnPtr<protocol::DictionaryValue> resetData = protocol::DictionaryValue::cre ate(); 531 std::unique_ptr<protocol::DictionaryValue> resetData = protocol::DictionaryV alue::create();
532 resetData->setNumber("deviceScaleFactor", m_webViewImpl->page()->deviceScale Factor()); 532 resetData->setNumber("deviceScaleFactor", m_webViewImpl->page()->deviceScale Factor());
533 resetData->setNumber("pageScaleFactor", m_webViewImpl->page()->pageScaleFact or()); 533 resetData->setNumber("pageScaleFactor", m_webViewImpl->page()->pageScaleFact or());
534 resetData->setObject("viewportSize", buildObjectForSize(viewportSize)); 534 resetData->setObject("viewportSize", buildObjectForSize(viewportSize));
535 resetData->setNumber("pageZoomFactor", m_webViewImpl->mainFrameImpl()->frame ()->pageZoomFactor()); 535 resetData->setNumber("pageZoomFactor", m_webViewImpl->mainFrameImpl()->frame ()->pageZoomFactor());
536 resetData->setNumber("scrollX", documentScrollOffset.x()); 536 resetData->setNumber("scrollX", documentScrollOffset.x());
537 resetData->setNumber("scrollY", documentScrollOffset.y()); 537 resetData->setNumber("scrollY", documentScrollOffset.y());
538 evaluateInOverlay("reset", std::move(resetData)); 538 evaluateInOverlay("reset", std::move(resetData));
539 } 539 }
540 540
541 void InspectorOverlay::evaluateInOverlay(const String& method, const String& arg ument) 541 void InspectorOverlay::evaluateInOverlay(const String& method, const String& arg ument)
542 { 542 {
543 ScriptForbiddenScope::AllowUserAgentScript allowScript; 543 ScriptForbiddenScope::AllowUserAgentScript allowScript;
544 OwnPtr<protocol::ListValue> command = protocol::ListValue::create(); 544 std::unique_ptr<protocol::ListValue> command = protocol::ListValue::create() ;
545 command->pushValue(protocol::StringValue::create(method)); 545 command->pushValue(protocol::StringValue::create(method));
546 command->pushValue(protocol::StringValue::create(argument)); 546 command->pushValue(protocol::StringValue::create(argument));
547 toLocalFrame(overlayPage()->mainFrame())->script().executeScriptInMainWorld( "dispatch(" + command->toJSONString() + ")", ScriptController::ExecuteScriptWhen ScriptsDisabled); 547 toLocalFrame(overlayPage()->mainFrame())->script().executeScriptInMainWorld( "dispatch(" + command->toJSONString() + ")", ScriptController::ExecuteScriptWhen ScriptsDisabled);
548 } 548 }
549 549
550 void InspectorOverlay::evaluateInOverlay(const String& method, PassOwnPtr<protoc ol::Value> argument) 550 void InspectorOverlay::evaluateInOverlay(const String& method, std::unique_ptr<p rotocol::Value> argument)
551 { 551 {
552 ScriptForbiddenScope::AllowUserAgentScript allowScript; 552 ScriptForbiddenScope::AllowUserAgentScript allowScript;
553 OwnPtr<protocol::ListValue> command = protocol::ListValue::create(); 553 std::unique_ptr<protocol::ListValue> command = protocol::ListValue::create() ;
554 command->pushValue(protocol::StringValue::create(method)); 554 command->pushValue(protocol::StringValue::create(method));
555 command->pushValue(std::move(argument)); 555 command->pushValue(std::move(argument));
556 toLocalFrame(overlayPage()->mainFrame())->script().executeScriptInMainWorld( "dispatch(" + command->toJSONString() + ")", ScriptController::ExecuteScriptWhen ScriptsDisabled); 556 toLocalFrame(overlayPage()->mainFrame())->script().executeScriptInMainWorld( "dispatch(" + command->toJSONString() + ")", ScriptController::ExecuteScriptWhen ScriptsDisabled);
557 } 557 }
558 558
559 String InspectorOverlay::evaluateInOverlayForTest(const String& script) 559 String InspectorOverlay::evaluateInOverlayForTest(const String& script)
560 { 560 {
561 ScriptForbiddenScope::AllowUserAgentScript allowScript; 561 ScriptForbiddenScope::AllowUserAgentScript allowScript;
562 v8::HandleScope handleScope(toIsolate(overlayMainFrame())); 562 v8::HandleScope handleScope(toIsolate(overlayMainFrame()));
563 v8::Local<v8::Value> string = toLocalFrame(overlayPage()->mainFrame())->scri pt().executeScriptInMainWorldAndReturnValue(ScriptSourceCode(script), ScriptCont roller::ExecuteScriptWhenScriptsDisabled); 563 v8::Local<v8::Value> string = toLocalFrame(overlayPage()->mainFrame())->scri pt().executeScriptInMainWorldAndReturnValue(ScriptSourceCode(script), ScriptCont roller::ExecuteScriptWhenScriptsDisabled);
(...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after
776 776
777 void InspectorOverlay::initializeLayoutEditorIfNeeded(Node* node) 777 void InspectorOverlay::initializeLayoutEditorIfNeeded(Node* node)
778 { 778 {
779 if (m_inspectMode != InspectorDOMAgent::ShowLayoutEditor || !node || !node-> isElementNode() || !node->ownerDocument()->isActive() || !m_cssAgent || !m_domAg ent) 779 if (m_inspectMode != InspectorDOMAgent::ShowLayoutEditor || !node || !node-> isElementNode() || !node->ownerDocument()->isActive() || !m_cssAgent || !m_domAg ent)
780 return; 780 return;
781 m_layoutEditor = LayoutEditor::create(toElement(node), m_cssAgent, m_domAgen t, &overlayMainFrame()->script()); 781 m_layoutEditor = LayoutEditor::create(toElement(node), m_cssAgent, m_domAgen t, &overlayMainFrame()->script());
782 toChromeClientImpl(m_webViewImpl->page()->chromeClient()).setCursorOverridde n(true); 782 toChromeClientImpl(m_webViewImpl->page()->chromeClient()).setCursorOverridde n(true);
783 } 783 }
784 784
785 } // namespace blink 785 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/web/InspectorOverlay.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698