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

Side by Side Diff: third_party/WebKit/Source/core/inspector/InspectorPageAgent.cpp

Issue 2467933002: [DevTools] migrate InspectorPageAgent and InspectorMemoryAgent to new style (Closed)
Patch Set: rebased Created 4 years, 1 month 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 are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * 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 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 351 matching lines...) Expand 10 before | Expand all | Expand 10 after
362 m_v8Session(v8Session), 362 m_v8Session(v8Session),
363 m_client(client), 363 m_client(client),
364 m_lastScriptIdentifier(0), 364 m_lastScriptIdentifier(0),
365 m_enabled(false), 365 m_enabled(false),
366 m_reloading(false), 366 m_reloading(false),
367 m_inspectorResourceContentLoader(resourceContentLoader), 367 m_inspectorResourceContentLoader(resourceContentLoader),
368 m_resourceContentLoaderClientId(resourceContentLoader->createClientId()) { 368 m_resourceContentLoaderClientId(resourceContentLoader->createClientId()) {
369 } 369 }
370 370
371 void InspectorPageAgent::restore() { 371 void InspectorPageAgent::restore() {
372 ErrorString error;
373 if (m_state->booleanProperty(PageAgentState::pageAgentEnabled, false)) 372 if (m_state->booleanProperty(PageAgentState::pageAgentEnabled, false))
374 enable(&error); 373 enable();
375 setBlockedEventsWarningThreshold( 374 setBlockedEventsWarningThreshold(m_state->doubleProperty(
376 &error, m_state->doubleProperty( 375 PageAgentState::blockedEventsWarningThreshold, 0.0));
377 PageAgentState::blockedEventsWarningThreshold, 0.0));
378 if (m_client) { 376 if (m_client) {
379 String overlayMessage; 377 String overlayMessage;
380 m_state->getString(PageAgentState::overlayMessage, &overlayMessage); 378 m_state->getString(PageAgentState::overlayMessage, &overlayMessage);
381 m_client->configureOverlay( 379 m_client->configureOverlay(
382 m_state->booleanProperty(PageAgentState::overlaySuspended, false), 380 m_state->booleanProperty(PageAgentState::overlaySuspended, false),
383 overlayMessage); 381 overlayMessage);
384 } 382 }
385 } 383 }
386 384
387 void InspectorPageAgent::enable(ErrorString*) { 385 Response InspectorPageAgent::enable() {
388 m_enabled = true; 386 m_enabled = true;
389 m_state->setBoolean(PageAgentState::pageAgentEnabled, true); 387 m_state->setBoolean(PageAgentState::pageAgentEnabled, true);
390 m_instrumentingAgents->addInspectorPageAgent(this); 388 m_instrumentingAgents->addInspectorPageAgent(this);
389 return Response::OK();
391 } 390 }
392 391
393 void InspectorPageAgent::disable(ErrorString*) { 392 Response InspectorPageAgent::disable() {
394 m_enabled = false; 393 m_enabled = false;
395 m_state->setBoolean(PageAgentState::pageAgentEnabled, false); 394 m_state->setBoolean(PageAgentState::pageAgentEnabled, false);
396 m_state->remove(PageAgentState::pageAgentScriptsToEvaluateOnLoad); 395 m_state->remove(PageAgentState::pageAgentScriptsToEvaluateOnLoad);
397 m_scriptToEvaluateOnLoadOnce = String(); 396 m_scriptToEvaluateOnLoadOnce = String();
398 m_pendingScriptToEvaluateOnLoadOnce = String(); 397 m_pendingScriptToEvaluateOnLoadOnce = String();
399 m_instrumentingAgents->removeInspectorPageAgent(this); 398 m_instrumentingAgents->removeInspectorPageAgent(this);
400 m_inspectorResourceContentLoader->cancel(m_resourceContentLoaderClientId); 399 m_inspectorResourceContentLoader->cancel(m_resourceContentLoaderClientId);
401 400
402 stopScreencast(0); 401 stopScreencast();
403 configureOverlay(nullptr, false, String()); 402 configureOverlay(false, String());
404 403
405 finishReload(); 404 finishReload();
405 return Response::OK();
406 } 406 }
407 407
408 void InspectorPageAgent::addScriptToEvaluateOnLoad(ErrorString*, 408 Response InspectorPageAgent::addScriptToEvaluateOnLoad(const String& source,
409 const String& source, 409 String* identifier) {
410 String* identifier) {
411 protocol::DictionaryValue* scripts = 410 protocol::DictionaryValue* scripts =
412 m_state->getObject(PageAgentState::pageAgentScriptsToEvaluateOnLoad); 411 m_state->getObject(PageAgentState::pageAgentScriptsToEvaluateOnLoad);
413 if (!scripts) { 412 if (!scripts) {
414 std::unique_ptr<protocol::DictionaryValue> newScripts = 413 std::unique_ptr<protocol::DictionaryValue> newScripts =
415 protocol::DictionaryValue::create(); 414 protocol::DictionaryValue::create();
416 scripts = newScripts.get(); 415 scripts = newScripts.get();
417 m_state->setObject(PageAgentState::pageAgentScriptsToEvaluateOnLoad, 416 m_state->setObject(PageAgentState::pageAgentScriptsToEvaluateOnLoad,
418 std::move(newScripts)); 417 std::move(newScripts));
419 } 418 }
420 // Assure we don't override existing ids -- m_lastScriptIdentifier could get 419 // Assure we don't override existing ids -- m_lastScriptIdentifier could get
421 // out of sync WRT actual scripts once we restored the scripts from the cookie 420 // out of sync WRT actual scripts once we restored the scripts from the cookie
422 // during navigation. 421 // during navigation.
423 do { 422 do {
424 *identifier = String::number(++m_lastScriptIdentifier); 423 *identifier = String::number(++m_lastScriptIdentifier);
425 } while (scripts->get(*identifier)); 424 } while (scripts->get(*identifier));
426 scripts->setString(*identifier, source); 425 scripts->setString(*identifier, source);
426 return Response::OK();
427 } 427 }
428 428
429 void InspectorPageAgent::removeScriptToEvaluateOnLoad( 429 Response InspectorPageAgent::removeScriptToEvaluateOnLoad(
430 ErrorString* error,
431 const String& identifier) { 430 const String& identifier) {
432 protocol::DictionaryValue* scripts = 431 protocol::DictionaryValue* scripts =
433 m_state->getObject(PageAgentState::pageAgentScriptsToEvaluateOnLoad); 432 m_state->getObject(PageAgentState::pageAgentScriptsToEvaluateOnLoad);
434 if (!scripts || !scripts->get(identifier)) { 433 if (!scripts || !scripts->get(identifier))
435 *error = "Script not found"; 434 return Response::Error("Script not found");
436 return;
437 }
438 scripts->remove(identifier); 435 scripts->remove(identifier);
436 return Response::OK();
439 } 437 }
440 438
441 void InspectorPageAgent::setAutoAttachToCreatedPages(ErrorString*, 439 Response InspectorPageAgent::setAutoAttachToCreatedPages(bool autoAttach) {
442 bool autoAttach) {
443 m_state->setBoolean(PageAgentState::autoAttachToCreatedPages, autoAttach); 440 m_state->setBoolean(PageAgentState::autoAttachToCreatedPages, autoAttach);
441 return Response::OK();
444 } 442 }
445 443
446 void InspectorPageAgent::reload( 444 Response InspectorPageAgent::reload(
447 ErrorString*, 445 Maybe<bool> optionalBypassCache,
448 const Maybe<bool>& optionalBypassCache, 446 Maybe<String> optionalScriptToEvaluateOnLoad) {
449 const Maybe<String>& optionalScriptToEvaluateOnLoad) {
450 m_pendingScriptToEvaluateOnLoadOnce = 447 m_pendingScriptToEvaluateOnLoadOnce =
451 optionalScriptToEvaluateOnLoad.fromMaybe(""); 448 optionalScriptToEvaluateOnLoad.fromMaybe("");
452 m_v8Session->setSkipAllPauses(true); 449 m_v8Session->setSkipAllPauses(true);
453 m_reloading = true; 450 m_reloading = true;
454 FrameLoadType reloadType = FrameLoadTypeReload; 451 FrameLoadType reloadType = FrameLoadTypeReload;
455 if (optionalBypassCache.fromMaybe(false)) 452 if (optionalBypassCache.fromMaybe(false))
456 reloadType = FrameLoadTypeReloadBypassingCache; 453 reloadType = FrameLoadTypeReloadBypassingCache;
457 else if (RuntimeEnabledFeatures:: 454 else if (RuntimeEnabledFeatures::
458 reloadwithoutSubResourceCacheRevalidationEnabled()) 455 reloadwithoutSubResourceCacheRevalidationEnabled())
459 reloadType = FrameLoadTypeReloadMainResource; 456 reloadType = FrameLoadTypeReloadMainResource;
460 m_inspectedFrames->root()->reload(reloadType, 457 m_inspectedFrames->root()->reload(reloadType,
461 ClientRedirectPolicy::NotClientRedirect); 458 ClientRedirectPolicy::NotClientRedirect);
459 return Response::OK();
462 } 460 }
463 461
464 void InspectorPageAgent::navigate(ErrorString*, 462 Response InspectorPageAgent::navigate(const String& url, String* outFrameId) {
465 const String& url,
466 String* outFrameId) {
467 *outFrameId = frameId(m_inspectedFrames->root()); 463 *outFrameId = frameId(m_inspectedFrames->root());
464 return Response::OK();
468 } 465 }
469 466
470 static void cachedResourcesForDocument(Document* document, 467 static void cachedResourcesForDocument(Document* document,
471 HeapVector<Member<Resource>>& result, 468 HeapVector<Member<Resource>>& result,
472 bool skipXHRs) { 469 bool skipXHRs) {
473 const ResourceFetcher::DocumentResourceMap& allResources = 470 const ResourceFetcher::DocumentResourceMap& allResources =
474 document->fetcher()->allResources(); 471 document->fetcher()->allResources();
475 for (const auto& resource : allResources) { 472 for (const auto& resource : allResources) {
476 Resource* cachedResource = resource.value.get(); 473 Resource* cachedResource = resource.value.get();
477 if (!cachedResource) 474 if (!cachedResource)
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
510 HeapVector<Member<Document>> loaders = 507 HeapVector<Member<Document>> loaders =
511 InspectorPageAgent::importsForFrame(frame); 508 InspectorPageAgent::importsForFrame(frame);
512 509
513 cachedResourcesForDocument(rootDocument, result, skipXHRs); 510 cachedResourcesForDocument(rootDocument, result, skipXHRs);
514 for (size_t i = 0; i < loaders.size(); ++i) 511 for (size_t i = 0; i < loaders.size(); ++i)
515 cachedResourcesForDocument(loaders[i], result, skipXHRs); 512 cachedResourcesForDocument(loaders[i], result, skipXHRs);
516 513
517 return result; 514 return result;
518 } 515 }
519 516
520 void InspectorPageAgent::getResourceTree( 517 Response InspectorPageAgent::getResourceTree(
521 ErrorString*,
522 std::unique_ptr<protocol::Page::FrameResourceTree>* object) { 518 std::unique_ptr<protocol::Page::FrameResourceTree>* object) {
523 *object = buildObjectForFrameTree(m_inspectedFrames->root()); 519 *object = buildObjectForFrameTree(m_inspectedFrames->root());
520 return Response::OK();
524 } 521 }
525 522
526 void InspectorPageAgent::finishReload() { 523 void InspectorPageAgent::finishReload() {
527 if (!m_reloading) 524 if (!m_reloading)
528 return; 525 return;
529 m_reloading = false; 526 m_reloading = false;
530 m_v8Session->setSkipAllPauses(false); 527 m_v8Session->setSkipAllPauses(false);
531 } 528 }
532 529
533 void InspectorPageAgent::getResourceContentAfterResourcesContentLoaded( 530 void InspectorPageAgent::getResourceContentAfterResourcesContentLoaded(
534 const String& frameId, 531 const String& frameId,
535 const String& url, 532 const String& url,
536 std::unique_ptr<GetResourceContentCallback> callback) { 533 std::unique_ptr<GetResourceContentCallback> callback) {
537 LocalFrame* frame = IdentifiersFactory::frameById(m_inspectedFrames, frameId); 534 LocalFrame* frame = IdentifiersFactory::frameById(m_inspectedFrames, frameId);
538 if (!frame) { 535 if (!frame) {
539 callback->sendFailure("No frame for given id found"); 536 callback->sendFailure(Response::Error("No frame for given id found"));
540 return; 537 return;
541 } 538 }
542 String content; 539 String content;
543 bool base64Encoded; 540 bool base64Encoded;
544 if (InspectorPageAgent::cachedResourceContent( 541 if (InspectorPageAgent::cachedResourceContent(
545 InspectorPageAgent::cachedResource(frame, KURL(ParsedURLString, url)), 542 InspectorPageAgent::cachedResource(frame, KURL(ParsedURLString, url)),
546 &content, &base64Encoded)) 543 &content, &base64Encoded))
547 callback->sendSuccess(content, base64Encoded); 544 callback->sendSuccess(content, base64Encoded);
548 else 545 else
549 callback->sendFailure("No resource with given URL found"); 546 callback->sendFailure(Response::Error("No resource with given URL found"));
550 } 547 }
551 548
552 void InspectorPageAgent::getResourceContent( 549 void InspectorPageAgent::getResourceContent(
553 const String& frameId, 550 const String& frameId,
554 const String& url, 551 const String& url,
555 std::unique_ptr<GetResourceContentCallback> callback) { 552 std::unique_ptr<GetResourceContentCallback> callback) {
556 if (!m_enabled) { 553 if (!m_enabled) {
557 callback->sendFailure("Agent is not enabled."); 554 callback->sendFailure(Response::Error("Agent is not enabled."));
558 return; 555 return;
559 } 556 }
560 m_inspectorResourceContentLoader->ensureResourcesContentLoaded( 557 m_inspectorResourceContentLoader->ensureResourcesContentLoaded(
561 m_resourceContentLoaderClientId, 558 m_resourceContentLoaderClientId,
562 WTF::bind( 559 WTF::bind(
563 &InspectorPageAgent::getResourceContentAfterResourcesContentLoaded, 560 &InspectorPageAgent::getResourceContentAfterResourcesContentLoaded,
564 wrapPersistent(this), frameId, url, passed(std::move(callback)))); 561 wrapPersistent(this), frameId, url, passed(std::move(callback))));
565 } 562 }
566 563
567 void InspectorPageAgent::searchContentAfterResourcesContentLoaded( 564 void InspectorPageAgent::searchContentAfterResourcesContentLoaded(
568 const String& frameId, 565 const String& frameId,
569 const String& url, 566 const String& url,
570 const String& query, 567 const String& query,
571 bool caseSensitive, 568 bool caseSensitive,
572 bool isRegex, 569 bool isRegex,
573 std::unique_ptr<SearchInResourceCallback> callback) { 570 std::unique_ptr<SearchInResourceCallback> callback) {
574 LocalFrame* frame = IdentifiersFactory::frameById(m_inspectedFrames, frameId); 571 LocalFrame* frame = IdentifiersFactory::frameById(m_inspectedFrames, frameId);
575 if (!frame) { 572 if (!frame) {
576 callback->sendFailure("No frame for given id found"); 573 callback->sendFailure(Response::Error("No frame for given id found"));
577 return; 574 return;
578 } 575 }
579 String content; 576 String content;
580 bool base64Encoded; 577 bool base64Encoded;
581 if (!InspectorPageAgent::cachedResourceContent( 578 if (!InspectorPageAgent::cachedResourceContent(
582 InspectorPageAgent::cachedResource(frame, KURL(ParsedURLString, url)), 579 InspectorPageAgent::cachedResource(frame, KURL(ParsedURLString, url)),
583 &content, &base64Encoded)) { 580 &content, &base64Encoded)) {
584 callback->sendFailure("No resource with given URL found"); 581 callback->sendFailure(Response::Error("No resource with given URL found"));
585 return; 582 return;
586 } 583 }
587 584
588 auto matches = m_v8Session->searchInTextByLines( 585 auto matches = m_v8Session->searchInTextByLines(
589 toV8InspectorStringView(content), toV8InspectorStringView(query), 586 toV8InspectorStringView(content), toV8InspectorStringView(query),
590 caseSensitive, isRegex); 587 caseSensitive, isRegex);
591 auto results = protocol::Array< 588 auto results = protocol::Array<
592 v8_inspector::protocol::Debugger::API::SearchMatch>::create(); 589 v8_inspector::protocol::Debugger::API::SearchMatch>::create();
593 for (size_t i = 0; i < matches.size(); ++i) 590 for (size_t i = 0; i < matches.size(); ++i)
594 results->addItem(std::move(matches[i])); 591 results->addItem(std::move(matches[i]));
595 callback->sendSuccess(std::move(results)); 592 callback->sendSuccess(std::move(results));
596 } 593 }
597 594
598 void InspectorPageAgent::searchInResource( 595 void InspectorPageAgent::searchInResource(
599 const String& frameId, 596 const String& frameId,
600 const String& url, 597 const String& url,
601 const String& query, 598 const String& query,
602 const Maybe<bool>& optionalCaseSensitive, 599 Maybe<bool> optionalCaseSensitive,
603 const Maybe<bool>& optionalIsRegex, 600 Maybe<bool> optionalIsRegex,
604 std::unique_ptr<SearchInResourceCallback> callback) { 601 std::unique_ptr<SearchInResourceCallback> callback) {
605 if (!m_enabled) { 602 if (!m_enabled) {
606 callback->sendFailure("Agent is not enabled."); 603 callback->sendFailure(Response::Error("Agent is not enabled."));
607 return; 604 return;
608 } 605 }
609 m_inspectorResourceContentLoader->ensureResourcesContentLoaded( 606 m_inspectorResourceContentLoader->ensureResourcesContentLoaded(
610 m_resourceContentLoaderClientId, 607 m_resourceContentLoaderClientId,
611 WTF::bind(&InspectorPageAgent::searchContentAfterResourcesContentLoaded, 608 WTF::bind(&InspectorPageAgent::searchContentAfterResourcesContentLoaded,
612 wrapPersistent(this), frameId, url, query, 609 wrapPersistent(this), frameId, url, query,
613 optionalCaseSensitive.fromMaybe(false), 610 optionalCaseSensitive.fromMaybe(false),
614 optionalIsRegex.fromMaybe(false), passed(std::move(callback)))); 611 optionalIsRegex.fromMaybe(false), passed(std::move(callback))));
615 } 612 }
616 613
617 void InspectorPageAgent::setDocumentContent(ErrorString* errorString, 614 Response InspectorPageAgent::setDocumentContent(const String& frameId,
618 const String& frameId, 615 const String& html) {
619 const String& html) {
620 LocalFrame* frame = IdentifiersFactory::frameById(m_inspectedFrames, frameId); 616 LocalFrame* frame = IdentifiersFactory::frameById(m_inspectedFrames, frameId);
621 if (!frame) { 617 if (!frame)
622 *errorString = "No frame for given id found"; 618 return Response::Error("No frame for given id found");
623 return;
624 }
625 619
626 Document* document = frame->document(); 620 Document* document = frame->document();
627 if (!document) { 621 if (!document)
628 *errorString = "No Document instance to set HTML for"; 622 return Response::Error("No Document instance to set HTML for");
629 return;
630 }
631 DOMPatchSupport::patchDocument(*document, html); 623 DOMPatchSupport::patchDocument(*document, html);
624 return Response::OK();
632 } 625 }
633 626
634 void InspectorPageAgent::didClearDocumentOfWindowObject(LocalFrame* frame) { 627 void InspectorPageAgent::didClearDocumentOfWindowObject(LocalFrame* frame) {
635 if (!frontend()) 628 if (!frontend())
636 return; 629 return;
637 630
638 protocol::DictionaryValue* scripts = 631 protocol::DictionaryValue* scripts =
639 m_state->getObject(PageAgentState::pageAgentScriptsToEvaluateOnLoad); 632 m_state->getObject(PageAgentState::pageAgentScriptsToEvaluateOnLoad);
640 if (scripts) { 633 if (scripts) {
641 for (size_t i = 0; i < scripts->size(); ++i) { 634 for (size_t i = 0; i < scripts->size(); ++i) {
(...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after
819 continue; 812 continue;
820 if (!childrenArray) 813 if (!childrenArray)
821 childrenArray = 814 childrenArray =
822 protocol::Array<protocol::Page::FrameResourceTree>::create(); 815 protocol::Array<protocol::Page::FrameResourceTree>::create();
823 childrenArray->addItem(buildObjectForFrameTree(toLocalFrame(child))); 816 childrenArray->addItem(buildObjectForFrameTree(toLocalFrame(child)));
824 } 817 }
825 result->setChildFrames(std::move(childrenArray)); 818 result->setChildFrames(std::move(childrenArray));
826 return result; 819 return result;
827 } 820 }
828 821
829 void InspectorPageAgent::startScreencast(ErrorString*, 822 Response InspectorPageAgent::startScreencast(Maybe<String> format,
830 const Maybe<String>& format, 823 Maybe<int> quality,
831 const Maybe<int>& quality, 824 Maybe<int> maxWidth,
832 const Maybe<int>& maxWidth, 825 Maybe<int> maxHeight,
833 const Maybe<int>& maxHeight, 826 Maybe<int> everyNthFrame) {
834 const Maybe<int>& everyNthFrame) {
835 m_state->setBoolean(PageAgentState::screencastEnabled, true); 827 m_state->setBoolean(PageAgentState::screencastEnabled, true);
828 return Response::OK();
836 } 829 }
837 830
838 void InspectorPageAgent::stopScreencast(ErrorString*) { 831 Response InspectorPageAgent::stopScreencast() {
839 m_state->setBoolean(PageAgentState::screencastEnabled, false); 832 m_state->setBoolean(PageAgentState::screencastEnabled, false);
833 return Response::OK();
840 } 834 }
841 835
842 void InspectorPageAgent::configureOverlay(ErrorString*, 836 Response InspectorPageAgent::configureOverlay(Maybe<bool> suspended,
843 const Maybe<bool>& suspended, 837 Maybe<String> message) {
844 const Maybe<String>& message) {
845 m_state->setBoolean(PageAgentState::overlaySuspended, 838 m_state->setBoolean(PageAgentState::overlaySuspended,
846 suspended.fromMaybe(false)); 839 suspended.fromMaybe(false));
847 m_state->setString(PageAgentState::overlaySuspended, 840 m_state->setString(PageAgentState::overlaySuspended,
848 message.fromMaybe(String())); 841 message.fromMaybe(String()));
849 if (m_client) 842 if (m_client)
850 m_client->configureOverlay(suspended.fromMaybe(false), 843 m_client->configureOverlay(suspended.fromMaybe(false),
851 message.fromMaybe(String())); 844 message.fromMaybe(String()));
845 return Response::OK();
852 } 846 }
853 847
854 void InspectorPageAgent::setBlockedEventsWarningThreshold(ErrorString*, 848 Response InspectorPageAgent::setBlockedEventsWarningThreshold(
855 double threshold) { 849 double threshold) {
856 m_state->setDouble(PageAgentState::blockedEventsWarningThreshold, threshold); 850 m_state->setDouble(PageAgentState::blockedEventsWarningThreshold, threshold);
857 FrameHost* host = m_inspectedFrames->root()->host(); 851 FrameHost* host = m_inspectedFrames->root()->host();
858 if (!host) 852 if (!host)
859 return; 853 return Response::Error("Host not found");
860 host->settings().setBlockedMainThreadEventsWarningThreshold(threshold); 854 host->settings().setBlockedMainThreadEventsWarningThreshold(threshold);
855 return Response::OK();
861 } 856 }
862 857
863 void InspectorPageAgent::getLayoutMetrics( 858 Response InspectorPageAgent::getLayoutMetrics(
864 ErrorString*,
865 std::unique_ptr<protocol::Page::LayoutViewport>* outLayoutViewport, 859 std::unique_ptr<protocol::Page::LayoutViewport>* outLayoutViewport,
866 std::unique_ptr<protocol::Page::VisualViewport>* outVisualViewport) { 860 std::unique_ptr<protocol::Page::VisualViewport>* outVisualViewport) {
867 LocalFrame* mainFrame = m_inspectedFrames->root(); 861 LocalFrame* mainFrame = m_inspectedFrames->root();
868 VisualViewport& visualViewport = mainFrame->host()->visualViewport(); 862 VisualViewport& visualViewport = mainFrame->host()->visualViewport();
869 863
870 mainFrame->document()->updateStyleAndLayoutIgnorePendingStylesheets(); 864 mainFrame->document()->updateStyleAndLayoutIgnorePendingStylesheets();
871 865
872 IntRect visibleContents = mainFrame->view()->visibleContentRect(); 866 IntRect visibleContents = mainFrame->view()->visibleContentRect();
873 *outLayoutViewport = protocol::Page::LayoutViewport::create() 867 *outLayoutViewport = protocol::Page::LayoutViewport::create()
874 .setPageX(visibleContents.x()) 868 .setPageX(visibleContents.x())
(...skipping 13 matching lines...) Expand all
888 *outVisualViewport = 882 *outVisualViewport =
889 protocol::Page::VisualViewport::create() 883 protocol::Page::VisualViewport::create()
890 .setOffsetX(adjustScrollForAbsoluteZoom(visibleRect.x(), pageZoom)) 884 .setOffsetX(adjustScrollForAbsoluteZoom(visibleRect.x(), pageZoom))
891 .setOffsetY(adjustScrollForAbsoluteZoom(visibleRect.y(), pageZoom)) 885 .setOffsetY(adjustScrollForAbsoluteZoom(visibleRect.y(), pageZoom))
892 .setPageX(adjustScrollForAbsoluteZoom(pageOffset.width(), pageZoom)) 886 .setPageX(adjustScrollForAbsoluteZoom(pageOffset.width(), pageZoom))
893 .setPageY(adjustScrollForAbsoluteZoom(pageOffset.height(), pageZoom)) 887 .setPageY(adjustScrollForAbsoluteZoom(pageOffset.height(), pageZoom))
894 .setClientWidth(visibleRect.width() - scrollbarWidth) 888 .setClientWidth(visibleRect.width() - scrollbarWidth)
895 .setClientHeight(visibleRect.height() - scrollbarHeight) 889 .setClientHeight(visibleRect.height() - scrollbarHeight)
896 .setScale(scale) 890 .setScale(scale)
897 .build(); 891 .build();
892 return Response::OK();
898 } 893 }
899 894
900 DEFINE_TRACE(InspectorPageAgent) { 895 DEFINE_TRACE(InspectorPageAgent) {
901 visitor->trace(m_inspectedFrames); 896 visitor->trace(m_inspectedFrames);
902 visitor->trace(m_inspectorResourceContentLoader); 897 visitor->trace(m_inspectorResourceContentLoader);
903 InspectorBaseAgent::trace(visitor); 898 InspectorBaseAgent::trace(visitor);
904 } 899 }
905 900
906 } // namespace blink 901 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/inspector/InspectorPageAgent.h ('k') | third_party/inspector_protocol/CodeGenerator.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698