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

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

Issue 898593002: DevTools: use per-LocalFrame instrumenting agents instead of per-Page ones. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: fixed assertion Created 5 years, 10 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 | Annotate | Revision Log
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 484 matching lines...) Expand 10 before | Expand all | Expand 10 after
495 } 495 }
496 } 496 }
497 497
498 void InspectorPageAgent::enable(ErrorString*) 498 void InspectorPageAgent::enable(ErrorString*)
499 { 499 {
500 m_enabled = true; 500 m_enabled = true;
501 m_state->setBoolean(PageAgentState::pageAgentEnabled, true); 501 m_state->setBoolean(PageAgentState::pageAgentEnabled, true);
502 m_instrumentingAgents->setInspectorPageAgent(this); 502 m_instrumentingAgents->setInspectorPageAgent(this);
503 if (m_inspectorResourceContentLoader) 503 if (m_inspectorResourceContentLoader)
504 m_inspectorResourceContentLoader->dispose(); 504 m_inspectorResourceContentLoader->dispose();
505 m_inspectorResourceContentLoader = adoptPtrWillBeNoop(new InspectorResourceC ontentLoader(m_page)); 505 m_inspectorResourceContentLoader = adoptPtrWillBeNoop(new InspectorResourceC ontentLoader(inspectedFrame()));
506 } 506 }
507 507
508 void InspectorPageAgent::discardAgent() 508 void InspectorPageAgent::discardAgent()
509 { 509 {
510 if (!m_inspectorResourceContentLoader) 510 if (!m_inspectorResourceContentLoader)
511 return; 511 return;
512 m_inspectorResourceContentLoader->dispose(); 512 m_inspectorResourceContentLoader->dispose();
513 m_inspectorResourceContentLoader.clear(); 513 m_inspectorResourceContentLoader.clear();
514 } 514 }
515 515
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
581 *error = "Script not found"; 581 *error = "Script not found";
582 return; 582 return;
583 } 583 }
584 scripts->remove(identifier); 584 scripts->remove(identifier);
585 } 585 }
586 586
587 void InspectorPageAgent::reload(ErrorString*, const bool* const optionalIgnoreCa che, const String* optionalScriptToEvaluateOnLoad, const String* optionalScriptP reprocessor) 587 void InspectorPageAgent::reload(ErrorString*, const bool* const optionalIgnoreCa che, const String* optionalScriptToEvaluateOnLoad, const String* optionalScriptP reprocessor)
588 { 588 {
589 m_pendingScriptToEvaluateOnLoadOnce = optionalScriptToEvaluateOnLoad ? *opti onalScriptToEvaluateOnLoad : ""; 589 m_pendingScriptToEvaluateOnLoadOnce = optionalScriptToEvaluateOnLoad ? *opti onalScriptToEvaluateOnLoad : "";
590 m_pendingScriptPreprocessor = optionalScriptPreprocessor ? *optionalScriptPr eprocessor : ""; 590 m_pendingScriptPreprocessor = optionalScriptPreprocessor ? *optionalScriptPr eprocessor : "";
591 m_page->mainFrame()->reload(asBool(optionalIgnoreCache) ? EndToEndReload : N ormalReload, NotClientRedirect); 591 inspectedFrame()->reload(asBool(optionalIgnoreCache) ? EndToEndReload : Norm alReload, NotClientRedirect);
592 } 592 }
593 593
594 void InspectorPageAgent::navigate(ErrorString*, const String& url, String* outFr ameId) 594 void InspectorPageAgent::navigate(ErrorString*, const String& url, String* outFr ameId)
595 { 595 {
596 LocalFrame* frame = m_page->deprecatedLocalMainFrame(); 596 *outFrameId = frameId(inspectedFrame());
597 *outFrameId = frameId(frame);
598 } 597 }
599 598
600 static PassRefPtr<TypeBuilder::Page::Cookie> buildObjectForCookie(const Cookie& cookie) 599 static PassRefPtr<TypeBuilder::Page::Cookie> buildObjectForCookie(const Cookie& cookie)
601 { 600 {
602 return TypeBuilder::Page::Cookie::create() 601 return TypeBuilder::Page::Cookie::create()
603 .setName(cookie.name) 602 .setName(cookie.name)
604 .setValue(cookie.value) 603 .setValue(cookie.value)
605 .setDomain(cookie.domain) 604 .setDomain(cookie.domain)
606 .setPath(cookie.path) 605 .setPath(cookie.path)
607 .setExpires(cookie.expires) 606 .setExpires(cookie.expires)
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
693 for (const auto& resource : allResources) 692 for (const auto& resource : allResources)
694 result.append(urlWithoutFragment(resource->url())); 693 result.append(urlWithoutFragment(resource->url()));
695 694
696 return result; 695 return result;
697 } 696 }
698 697
699 void InspectorPageAgent::getCookies(ErrorString*, RefPtr<TypeBuilder::Array<Type Builder::Page::Cookie> >& cookies) 698 void InspectorPageAgent::getCookies(ErrorString*, RefPtr<TypeBuilder::Array<Type Builder::Page::Cookie> >& cookies)
700 { 699 {
701 ListHashSet<Cookie> rawCookiesList; 700 ListHashSet<Cookie> rawCookiesList;
702 701
703 for (Frame* frame = mainFrame(); frame; frame = frame->tree().traverseNext(m ainFrame())) { 702 for (Frame* frame = inspectedFrame(); frame; frame = frame->tree().traverseN ext(inspectedFrame())) {
704 if (!frame->isLocalFrame()) 703 if (!frame->isLocalFrame())
705 continue; 704 continue;
706 Document* document = toLocalFrame(frame)->document(); 705 Document* document = toLocalFrame(frame)->document();
707 Vector<KURL> allURLs = allResourcesURLsForFrame(toLocalFrame(frame)); 706 Vector<KURL> allURLs = allResourcesURLsForFrame(toLocalFrame(frame));
708 for (const auto& url : allURLs) { 707 for (const auto& url : allURLs) {
709 Vector<Cookie> docCookiesList; 708 Vector<Cookie> docCookiesList;
710 getRawCookies(document, url, docCookiesList); 709 getRawCookies(document, url, docCookiesList);
711 int cookiesSize = docCookiesList.size(); 710 int cookiesSize = docCookiesList.size();
712 for (int i = 0; i < cookiesSize; i++) { 711 for (int i = 0; i < cookiesSize; i++) {
713 if (!rawCookiesList.contains(docCookiesList[i])) 712 if (!rawCookiesList.contains(docCookiesList[i]))
714 rawCookiesList.add(docCookiesList[i]); 713 rawCookiesList.add(docCookiesList[i]);
715 } 714 }
716 } 715 }
717 } 716 }
718 717
719 cookies = buildArrayForCookies(rawCookiesList); 718 cookies = buildArrayForCookies(rawCookiesList);
720 } 719 }
721 720
722 void InspectorPageAgent::deleteCookie(ErrorString*, const String& cookieName, co nst String& url) 721 void InspectorPageAgent::deleteCookie(ErrorString*, const String& cookieName, co nst String& url)
723 { 722 {
724 KURL parsedURL(ParsedURLString, url); 723 KURL parsedURL(ParsedURLString, url);
725 for (Frame* frame = m_page->mainFrame(); frame; frame = frame->tree().traver seNext(m_page->mainFrame())) { 724 for (Frame* frame = inspectedFrame(); frame; frame = frame->tree().traverseN ext(inspectedFrame())) {
726 if (frame->isLocalFrame()) 725 if (frame->isLocalFrame())
727 blink::deleteCookie(toLocalFrame(frame)->document(), parsedURL, cook ieName); 726 blink::deleteCookie(toLocalFrame(frame)->document(), parsedURL, cook ieName);
728 } 727 }
729 } 728 }
730 729
731 void InspectorPageAgent::getResourceTree(ErrorString*, RefPtr<TypeBuilder::Page: :FrameResourceTree>& object) 730 void InspectorPageAgent::getResourceTree(ErrorString*, RefPtr<TypeBuilder::Page: :FrameResourceTree>& object)
732 { 731 {
733 object = buildObjectForFrameTree(m_page->deprecatedLocalMainFrame()); 732 object = buildObjectForFrameTree(inspectedFrame());
734 } 733 }
735 734
736 void InspectorPageAgent::getResourceContentAfterResourcesContentLoaded(const Str ing& frameId, const String& url, PassRefPtrWillBeRawPtr<GetResourceContentCallba ck> callback) 735 void InspectorPageAgent::getResourceContentAfterResourcesContentLoaded(const Str ing& frameId, const String& url, PassRefPtrWillBeRawPtr<GetResourceContentCallba ck> callback)
737 { 736 {
738 ErrorString errorString; 737 ErrorString errorString;
739 LocalFrame* frame = assertFrame(&errorString, frameId); 738 LocalFrame* frame = assertFrame(&errorString, frameId);
740 if (!frame) { 739 if (!frame) {
741 callback->sendFailure(errorString); 740 callback->sendFailure(errorString);
742 return; 741 return;
743 } 742 }
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after
902 || scale != currentScale 901 || scale != currentScale
903 || offsetX != currentOffsetX 902 || offsetX != currentOffsetX
904 || offsetY != currentOffsetY; 903 || offsetY != currentOffsetY;
905 } 904 }
906 905
907 void InspectorPageAgent::setShowPaintRects(ErrorString*, bool show) 906 void InspectorPageAgent::setShowPaintRects(ErrorString*, bool show)
908 { 907 {
909 m_state->setBoolean(PageAgentState::pageAgentShowPaintRects, show); 908 m_state->setBoolean(PageAgentState::pageAgentShowPaintRects, show);
910 m_client->setShowPaintRects(show); 909 m_client->setShowPaintRects(show);
911 910
912 if (!show && mainFrame() && mainFrame()->view()) 911 if (!show && inspectedFrame() && inspectedFrame()->isMainFrame() && inspecte dFrame()->view())
913 mainFrame()->view()->invalidate(); 912 inspectedFrame()->view()->invalidate();
914 } 913 }
915 914
916 void InspectorPageAgent::setShowDebugBorders(ErrorString* errorString, bool show ) 915 void InspectorPageAgent::setShowDebugBorders(ErrorString* errorString, bool show )
917 { 916 {
918 m_state->setBoolean(PageAgentState::pageAgentShowDebugBorders, show); 917 m_state->setBoolean(PageAgentState::pageAgentShowDebugBorders, show);
919 if (show && !compositingEnabled(errorString)) 918 if (show && !compositingEnabled(errorString))
920 return; 919 return;
921 m_client->setShowDebugBorders(show); 920 m_client->setShowDebugBorders(show);
922 } 921 }
923 922
(...skipping 19 matching lines...) Expand all
943 m_state->setBoolean(PageAgentState::pageAgentShowScrollBottleneckRects, show ); 942 m_state->setBoolean(PageAgentState::pageAgentShowScrollBottleneckRects, show );
944 if (show && !compositingEnabled(errorString)) 943 if (show && !compositingEnabled(errorString))
945 return; 944 return;
946 m_client->setShowScrollBottleneckRects(show); 945 m_client->setShowScrollBottleneckRects(show);
947 } 946 }
948 947
949 void InspectorPageAgent::getScriptExecutionStatus(ErrorString*, PageCommandHandl er::Result::Enum* status) 948 void InspectorPageAgent::getScriptExecutionStatus(ErrorString*, PageCommandHandl er::Result::Enum* status)
950 { 949 {
951 bool disabledByScriptController = false; 950 bool disabledByScriptController = false;
952 bool disabledInSettings = false; 951 bool disabledInSettings = false;
953 LocalFrame* frame = mainFrame(); 952 LocalFrame* frame = inspectedFrame();
954 if (frame) { 953 if (frame) {
955 disabledByScriptController = !frame->script().canExecuteScripts(NotAbout ToExecuteScript); 954 disabledByScriptController = !frame->script().canExecuteScripts(NotAbout ToExecuteScript);
956 if (frame->settings()) 955 if (frame->settings())
957 disabledInSettings = !frame->settings()->scriptEnabled(); 956 disabledInSettings = !frame->settings()->scriptEnabled();
958 } 957 }
959 958
960 // Order is important. 959 // Order is important.
961 if (disabledInSettings) 960 if (disabledInSettings)
962 *status = PageCommandHandler::Result::Disabled; 961 *status = PageCommandHandler::Result::Disabled;
963 else if (disabledByScriptController) 962 else if (disabledByScriptController)
964 *status = PageCommandHandler::Result::Forbidden; 963 *status = PageCommandHandler::Result::Forbidden;
965 else 964 else
966 *status = PageCommandHandler::Result::Allowed; 965 *status = PageCommandHandler::Result::Allowed;
967 } 966 }
968 967
969 void InspectorPageAgent::setScriptExecutionDisabled(ErrorString*, bool value) 968 void InspectorPageAgent::setScriptExecutionDisabled(ErrorString*, bool value)
970 { 969 {
971 m_state->setBoolean(PageAgentState::pageAgentScriptExecutionDisabled, value) ; 970 m_state->setBoolean(PageAgentState::pageAgentScriptExecutionDisabled, value) ;
972 if (!mainFrame()) 971 if (!inspectedFrame())
973 return; 972 return;
974 973
975 Settings* settings = mainFrame()->settings(); 974 Settings* settings = inspectedFrame()->settings();
976 if (settings) { 975 if (settings) {
977 m_ignoreScriptsEnabledNotification = true; 976 m_ignoreScriptsEnabledNotification = true;
978 settings->setScriptEnabled(!value); 977 settings->setScriptEnabled(!value);
979 m_ignoreScriptsEnabledNotification = false; 978 m_ignoreScriptsEnabledNotification = false;
980 } 979 }
981 } 980 }
982 981
983 void InspectorPageAgent::didClearDocumentOfWindowObject(LocalFrame* frame) 982 void InspectorPageAgent::didClearDocumentOfWindowObject(LocalFrame* frame)
984 { 983 {
985 if (!m_frontend) 984 if (!m_frontend)
986 return; 985 return;
987 986
988 RefPtr<JSONObject> scripts = m_state->getObject(PageAgentState::pageAgentScr iptsToEvaluateOnLoad); 987 RefPtr<JSONObject> scripts = m_state->getObject(PageAgentState::pageAgentScr iptsToEvaluateOnLoad);
989 if (scripts) { 988 if (scripts) {
990 for (const auto& script : *scripts) { 989 for (const auto& script : *scripts) {
991 String scriptText; 990 String scriptText;
992 if (script.value->asString(&scriptText)) 991 if (script.value->asString(&scriptText))
993 frame->script().executeScriptInMainWorld(scriptText); 992 frame->script().executeScriptInMainWorld(scriptText);
994 } 993 }
995 } 994 }
996 if (!m_scriptToEvaluateOnLoadOnce.isEmpty()) 995 if (!m_scriptToEvaluateOnLoadOnce.isEmpty())
997 frame->script().executeScriptInMainWorld(m_scriptToEvaluateOnLoadOnce); 996 frame->script().executeScriptInMainWorld(m_scriptToEvaluateOnLoadOnce);
998 } 997 }
999 998
1000 void InspectorPageAgent::domContentLoadedEventFired(LocalFrame* frame) 999 void InspectorPageAgent::domContentLoadedEventFired(LocalFrame* frame)
1001 { 1000 {
1002 if (!frame->isMainFrame()) 1001 if (frame != inspectedFrame())
1003 return; 1002 return;
1004 m_frontend->domContentEventFired(currentTime()); 1003 m_frontend->domContentEventFired(currentTime());
1005 } 1004 }
1006 1005
1007 void InspectorPageAgent::loadEventFired(LocalFrame* frame) 1006 void InspectorPageAgent::loadEventFired(LocalFrame* frame)
1008 { 1007 {
1009 if (!frame->isMainFrame()) 1008 if (frame != inspectedFrame())
1010 return; 1009 return;
1011 m_frontend->loadEventFired(currentTime()); 1010 m_frontend->loadEventFired(currentTime());
1012 } 1011 }
1013 1012
1014 void InspectorPageAgent::didCommitLoad(LocalFrame*, DocumentLoader* loader) 1013 void InspectorPageAgent::didCommitLoad(LocalFrame*, DocumentLoader* loader)
1015 { 1014 {
1016 // FIXME: If "frame" is always guaranteed to be in the same Page as loader-> frame() 1015 if (loader->frame() == inspectedFrame()) {
1017 // then all we need to check here is loader->frame()->isMainFrame()
1018 // and we don't need "frame" at all.
1019 if (loader->frame() == m_page->mainFrame()) {
1020 m_scriptToEvaluateOnLoadOnce = m_pendingScriptToEvaluateOnLoadOnce; 1016 m_scriptToEvaluateOnLoadOnce = m_pendingScriptToEvaluateOnLoadOnce;
1021 m_scriptPreprocessorSource = m_pendingScriptPreprocessor; 1017 m_scriptPreprocessorSource = m_pendingScriptPreprocessor;
1022 m_pendingScriptToEvaluateOnLoadOnce = String(); 1018 m_pendingScriptToEvaluateOnLoadOnce = String();
1023 m_pendingScriptPreprocessor = String(); 1019 m_pendingScriptPreprocessor = String();
1024 if (m_inspectorResourceContentLoader) 1020 if (m_inspectorResourceContentLoader)
1025 m_inspectorResourceContentLoader->stop(); 1021 m_inspectorResourceContentLoader->stop();
1026 } 1022 }
1027 m_frontend->frameNavigated(buildObjectForFrame(loader->frame())); 1023 m_frontend->frameNavigated(buildObjectForFrame(loader->frame()));
1028 viewportChanged(); 1024 viewportChanged();
1029 } 1025 }
1030 1026
1031 void InspectorPageAgent::frameAttachedToParent(LocalFrame* frame) 1027 void InspectorPageAgent::frameAttachedToParent(LocalFrame* frame)
1032 { 1028 {
1033 Frame* parentFrame = frame->tree().parent(); 1029 Frame* parentFrame = frame->tree().parent();
1034 if (!parentFrame->isLocalFrame()) 1030 if (!parentFrame->isLocalFrame())
1035 parentFrame = 0; 1031 parentFrame = 0;
1036 m_frontend->frameAttached(frameId(frame), frameId(toLocalFrame(parentFrame)) ); 1032 m_frontend->frameAttached(frameId(frame), frameId(toLocalFrame(parentFrame)) );
1037 } 1033 }
1038 1034
1039 void InspectorPageAgent::frameDetachedFromParent(LocalFrame* frame) 1035 void InspectorPageAgent::frameDetachedFromParent(LocalFrame* frame)
1040 { 1036 {
1041 HashMap<LocalFrame*, String>::iterator iterator = m_frameToIdentifier.find(f rame); 1037 HashMap<LocalFrame*, String>::iterator iterator = m_frameToIdentifier.find(f rame);
1042 if (iterator != m_frameToIdentifier.end()) { 1038 if (iterator != m_frameToIdentifier.end()) {
1043 m_frontend->frameDetached(iterator->value); 1039 m_frontend->frameDetached(iterator->value);
1044 m_identifierToFrame.remove(iterator->value); 1040 m_identifierToFrame.remove(iterator->value);
1045 m_frameToIdentifier.remove(iterator); 1041 m_frameToIdentifier.remove(iterator);
1046 } 1042 }
1047 } 1043 }
1048 1044
1049 LocalFrame* InspectorPageAgent::mainFrame() 1045 FrameHost* InspectorPageAgent::frameHost()
1046 {
1047 return &m_page->frameHost();
1048 }
1049
1050 LocalFrame* InspectorPageAgent::inspectedFrame()
1050 { 1051 {
1051 return m_page->deprecatedLocalMainFrame(); 1052 return m_page->deprecatedLocalMainFrame();
1052 } 1053 }
1053 1054
1054 LocalFrame* InspectorPageAgent::frameForId(const String& frameId) 1055 LocalFrame* InspectorPageAgent::frameForId(const String& frameId)
1055 { 1056 {
1056 return frameId.isEmpty() ? nullptr : m_identifierToFrame.get(frameId); 1057 return frameId.isEmpty() ? nullptr : m_identifierToFrame.get(frameId);
1057 } 1058 }
1058 1059
1059 String InspectorPageAgent::frameId(LocalFrame* frame) 1060 String InspectorPageAgent::frameId(LocalFrame* frame)
(...skipping 21 matching lines...) Expand all
1081 String identifier = m_loaderToIdentifier.get(loader); 1082 String identifier = m_loaderToIdentifier.get(loader);
1082 if (identifier.isNull()) { 1083 if (identifier.isNull()) {
1083 identifier = IdentifiersFactory::createIdentifier(); 1084 identifier = IdentifiersFactory::createIdentifier();
1084 m_loaderToIdentifier.set(loader, identifier); 1085 m_loaderToIdentifier.set(loader, identifier);
1085 } 1086 }
1086 return identifier; 1087 return identifier;
1087 } 1088 }
1088 1089
1089 LocalFrame* InspectorPageAgent::findFrameWithSecurityOrigin(const String& origin RawString) 1090 LocalFrame* InspectorPageAgent::findFrameWithSecurityOrigin(const String& origin RawString)
1090 { 1091 {
1091 for (Frame* frame = m_page->mainFrame(); frame; frame = frame->tree().traver seNext()) { 1092 for (Frame* frame = inspectedFrame(); frame; frame = frame->tree().traverseN ext(inspectedFrame())) {
1092 // FIXME: RemoteFrame security origins are not yet available.
1093 if (!frame->isLocalFrame()) 1093 if (!frame->isLocalFrame())
1094 continue; 1094 continue;
1095 RefPtr<SecurityOrigin> documentOrigin = toLocalFrame(frame)->document()- >securityOrigin(); 1095 RefPtr<SecurityOrigin> documentOrigin = toLocalFrame(frame)->document()- >securityOrigin();
1096 if (documentOrigin->toRawString() == originRawString) 1096 if (documentOrigin->toRawString() == originRawString)
1097 return toLocalFrame(frame); 1097 return toLocalFrame(frame);
1098 } 1098 }
1099 return nullptr; 1099 return nullptr;
1100 } 1100 }
1101 1101
1102 LocalFrame* InspectorPageAgent::assertFrame(ErrorString* errorString, const Stri ng& frameId) 1102 LocalFrame* InspectorPageAgent::assertFrame(ErrorString* errorString, const Stri ng& frameId)
1103 { 1103 {
1104 LocalFrame* frame = frameForId(frameId); 1104 LocalFrame* frame = frameForId(frameId);
1105 if (!frame) 1105 if (!frame)
1106 *errorString = "No frame for given id found"; 1106 *errorString = "No frame for given id found";
1107 return frame; 1107 return frame;
1108 } 1108 }
1109 1109
1110 const AtomicString& InspectorPageAgent::resourceSourceMapURL(const String& url) 1110 const AtomicString& InspectorPageAgent::resourceSourceMapURL(const String& url)
1111 { 1111 {
1112 DEFINE_STATIC_LOCAL(const AtomicString, sourceMapHttpHeader, ("SourceMap", A tomicString::ConstructFromLiteral)); 1112 DEFINE_STATIC_LOCAL(const AtomicString, sourceMapHttpHeader, ("SourceMap", A tomicString::ConstructFromLiteral));
1113 DEFINE_STATIC_LOCAL(const AtomicString, deprecatedSourceMapHttpHeader, ("X-S ourceMap", AtomicString::ConstructFromLiteral)); 1113 DEFINE_STATIC_LOCAL(const AtomicString, deprecatedSourceMapHttpHeader, ("X-S ourceMap", AtomicString::ConstructFromLiteral));
1114 if (url.isEmpty()) 1114 if (url.isEmpty())
1115 return nullAtom; 1115 return nullAtom;
1116 LocalFrame* frame = mainFrame(); 1116 LocalFrame* frame = inspectedFrame();
1117 if (!frame) 1117 if (!frame)
1118 return nullAtom; 1118 return nullAtom;
1119 Resource* resource = cachedResource(frame, KURL(ParsedURLString, url)); 1119 Resource* resource = cachedResource(frame, KURL(ParsedURLString, url));
1120 if (!resource) 1120 if (!resource)
1121 return nullAtom; 1121 return nullAtom;
1122 const AtomicString& deprecatedHeaderSourceMapURL = resource->response().http HeaderField(deprecatedSourceMapHttpHeader); 1122 const AtomicString& deprecatedHeaderSourceMapURL = resource->response().http HeaderField(deprecatedSourceMapHttpHeader);
1123 if (!deprecatedHeaderSourceMapURL.isEmpty()) { 1123 if (!deprecatedHeaderSourceMapURL.isEmpty()) {
1124 // FIXME: add deprecated console message here. 1124 // FIXME: add deprecated console message here.
1125 return deprecatedHeaderSourceMapURL; 1125 return deprecatedHeaderSourceMapURL;
1126 } 1126 }
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
1210 1210
1211 void InspectorPageAgent::didScroll() 1211 void InspectorPageAgent::didScroll()
1212 { 1212 {
1213 if (m_enabled) 1213 if (m_enabled)
1214 m_overlay->update(); 1214 m_overlay->update();
1215 viewportChanged(); 1215 viewportChanged();
1216 } 1216 }
1217 1217
1218 void InspectorPageAgent::viewportChanged() 1218 void InspectorPageAgent::viewportChanged()
1219 { 1219 {
1220 if (!m_enabled || !m_deviceMetricsOverridden) 1220 if (!m_enabled || !m_deviceMetricsOverridden || !inspectedFrame()->isMainFra me())
1221 return; 1221 return;
1222 IntSize contentsSize = m_page->deprecatedLocalMainFrame()->view()->contentsS ize(); 1222 IntSize contentsSize = inspectedFrame()->view()->contentsSize();
1223 IntRect viewRect = m_page->deprecatedLocalMainFrame()->view()->visibleConten tRect(); 1223 IntRect viewRect = inspectedFrame()->view()->visibleContentRect();
1224 RefPtr<TypeBuilder::Page::Viewport> viewport = TypeBuilder::Page::Viewport:: create() 1224 RefPtr<TypeBuilder::Page::Viewport> viewport = TypeBuilder::Page::Viewport:: create()
1225 .setScrollX(viewRect.x()) 1225 .setScrollX(viewRect.x())
1226 .setScrollY(viewRect.y()) 1226 .setScrollY(viewRect.y())
1227 .setContentsWidth(contentsSize.width()) 1227 .setContentsWidth(contentsSize.width())
1228 .setContentsHeight(contentsSize.height()) 1228 .setContentsHeight(contentsSize.height())
1229 .setPageScaleFactor(m_page->pageScaleFactor()) 1229 .setPageScaleFactor(m_page->pageScaleFactor())
1230 .setMinimumPageScaleFactor(m_client->minimumPageScaleFactor()) 1230 .setMinimumPageScaleFactor(m_client->minimumPageScaleFactor())
1231 .setMaximumPageScaleFactor(m_client->maximumPageScaleFactor()); 1231 .setMaximumPageScaleFactor(m_client->maximumPageScaleFactor());
1232 m_frontend->viewportChanged(viewport); 1232 m_frontend->viewportChanged(viewport);
1233 } 1233 }
1234 1234
1235 void InspectorPageAgent::didResizeMainFrame() 1235 void InspectorPageAgent::didResizeMainFrame()
1236 { 1236 {
1237 if (!inspectedFrame()->isMainFrame())
1238 return;
1237 #if !OS(ANDROID) 1239 #if !OS(ANDROID)
1238 if (m_enabled && m_state->getBoolean(PageAgentState::showSizeOnResize)) 1240 if (m_enabled && m_state->getBoolean(PageAgentState::showSizeOnResize))
1239 m_overlay->showAndHideViewSize(m_state->getBoolean(PageAgentState::showG ridOnResize)); 1241 m_overlay->showAndHideViewSize(m_state->getBoolean(PageAgentState::showG ridOnResize));
1240 #endif 1242 #endif
1241 m_frontend->frameResized(); 1243 m_frontend->frameResized();
1242 viewportChanged(); 1244 viewportChanged();
1243 } 1245 }
1244 1246
1245 void InspectorPageAgent::didRecalculateStyle(int) 1247 void InspectorPageAgent::didRecalculateStyle(int)
1246 { 1248 {
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
1339 double scale = m_state->getDouble(PageAgentState::deviceScale, 1); 1341 double scale = m_state->getDouble(PageAgentState::deviceScale, 1);
1340 double offsetX = m_state->getDouble(PageAgentState::deviceOffsetX, 0); 1342 double offsetX = m_state->getDouble(PageAgentState::deviceOffsetX, 0);
1341 double offsetY = m_state->getDouble(PageAgentState::deviceOffsetY, 0); 1343 double offsetY = m_state->getDouble(PageAgentState::deviceOffsetY, 0);
1342 updateViewMetrics(enabled, width, height, deviceScaleFactor, mobile, fitWind ow, scale, offsetX, offsetY); 1344 updateViewMetrics(enabled, width, height, deviceScaleFactor, mobile, fitWind ow, scale, offsetX, offsetY);
1343 } 1345 }
1344 1346
1345 void InspectorPageAgent::updateViewMetrics(bool enabled, int width, int height, double deviceScaleFactor, bool mobile, bool fitWindow, double scale, double offs etX, double offsetY) 1347 void InspectorPageAgent::updateViewMetrics(bool enabled, int width, int height, double deviceScaleFactor, bool mobile, bool fitWindow, double scale, double offs etX, double offsetY)
1346 { 1348 {
1347 if (enabled && !m_page->settings().acceleratedCompositingEnabled()) 1349 if (enabled && !m_page->settings().acceleratedCompositingEnabled())
1348 return; 1350 return;
1351 if (!inspectedFrame()->isMainFrame())
1352 return;
1349 1353
1350 m_deviceMetricsOverridden = enabled; 1354 m_deviceMetricsOverridden = enabled;
1351 m_emulateMobileEnabled = mobile; 1355 m_emulateMobileEnabled = mobile;
1352 if (enabled) 1356 if (enabled)
1353 m_client->setDeviceMetricsOverride(width, height, static_cast<float>(dev iceScaleFactor), mobile, fitWindow, static_cast<float>(scale), static_cast<float >(offsetX), static_cast<float>(offsetY)); 1357 m_client->setDeviceMetricsOverride(width, height, static_cast<float>(dev iceScaleFactor), mobile, fitWindow, static_cast<float>(scale), static_cast<float >(offsetX), static_cast<float>(offsetY));
1354 else 1358 else
1355 m_client->clearDeviceMetricsOverride(); 1359 m_client->clearDeviceMetricsOverride();
1356 1360
1357 Document* document = mainFrame()->document(); 1361 Document* document = inspectedFrame()->document();
1358 if (document) { 1362 if (document) {
1359 document->styleResolverChanged(); 1363 document->styleResolverChanged();
1360 document->mediaQueryAffectingValueChanged(); 1364 document->mediaQueryAffectingValueChanged();
1361 } 1365 }
1362 1366
1363 if (m_deviceMetricsOverridden) { 1367 if (m_deviceMetricsOverridden) {
1364 m_page->settings().setTextAutosizingEnabled(mobile); 1368 m_page->settings().setTextAutosizingEnabled(mobile);
1365 m_page->settings().setPreferCompositingToLCDTextEnabled(mobile); 1369 m_page->settings().setPreferCompositingToLCDTextEnabled(mobile);
1366 m_page->settings().setDeviceScaleAdjustment(calculateFontScaleFactor(wid th, height, static_cast<float>(deviceScaleFactor))); 1370 m_page->settings().setDeviceScaleAdjustment(calculateFontScaleFactor(wid th, height, static_cast<float>(deviceScaleFactor)));
1367 } else { 1371 } else {
1368 m_page->settings().setTextAutosizingEnabled(m_embedderTextAutosizingEnab led); 1372 m_page->settings().setTextAutosizingEnabled(m_embedderTextAutosizingEnab led);
1369 m_page->settings().setPreferCompositingToLCDTextEnabled(m_embedderPrefer CompositingToLCDTextEnabled); 1373 m_page->settings().setPreferCompositingToLCDTextEnabled(m_embedderPrefer CompositingToLCDTextEnabled);
1370 m_page->settings().setDeviceScaleAdjustment(m_embedderFontScaleFactor); 1374 m_page->settings().setDeviceScaleAdjustment(m_embedderFontScaleFactor);
1371 } 1375 }
1372 1376
1373 // FIXME: allow metrics override, fps counter and continuous painting at the same time: crbug.com/299837. 1377 // FIXME: allow metrics override, fps counter and continuous painting at the same time: crbug.com/299837.
1374 m_client->setShowFPSCounter(m_state->getBoolean(PageAgentState::pageAgentSho wFPSCounter) && !m_deviceMetricsOverridden); 1378 m_client->setShowFPSCounter(m_state->getBoolean(PageAgentState::pageAgentSho wFPSCounter) && !m_deviceMetricsOverridden);
1375 m_client->setContinuousPaintingEnabled(m_state->getBoolean(PageAgentState::p ageAgentContinuousPaintingEnabled) && !m_deviceMetricsOverridden); 1379 m_client->setContinuousPaintingEnabled(m_state->getBoolean(PageAgentState::p ageAgentContinuousPaintingEnabled) && !m_deviceMetricsOverridden);
1376 } 1380 }
1377 1381
1378 void InspectorPageAgent::updateTouchEventEmulationInPage(bool enabled) 1382 void InspectorPageAgent::updateTouchEventEmulationInPage(bool enabled)
1379 { 1383 {
1384 if (!inspectedFrame()->isMainFrame())
1385 return;
1380 if (!m_touchEmulationEnabled) { 1386 if (!m_touchEmulationEnabled) {
1381 m_originalTouchEnabled = RuntimeEnabledFeatures::touchEnabled(); 1387 m_originalTouchEnabled = RuntimeEnabledFeatures::touchEnabled();
1382 m_originalDeviceSupportsMouse = m_page->settings().deviceSupportsMouse() ; 1388 m_originalDeviceSupportsMouse = m_page->settings().deviceSupportsMouse() ;
1383 m_originalDeviceSupportsTouch = m_page->settings().deviceSupportsTouch() ; 1389 m_originalDeviceSupportsTouch = m_page->settings().deviceSupportsTouch() ;
1384 m_originalMaxTouchPoints = m_page->settings().maxTouchPoints(); 1390 m_originalMaxTouchPoints = m_page->settings().maxTouchPoints();
1385 } 1391 }
1386 RuntimeEnabledFeatures::setTouchEnabled(enabled ? true : m_originalTouchEnab led); 1392 RuntimeEnabledFeatures::setTouchEnabled(enabled ? true : m_originalTouchEnab led);
1387 if (!m_originalDeviceSupportsTouch) { 1393 if (!m_originalDeviceSupportsTouch) {
1388 m_page->settings().setDeviceSupportsMouse(enabled ? false : m_originalDe viceSupportsMouse); 1394 m_page->settings().setDeviceSupportsMouse(enabled ? false : m_originalDe viceSupportsMouse);
1389 m_page->settings().setDeviceSupportsTouch(enabled ? true : m_originalDev iceSupportsTouch); 1395 m_page->settings().setDeviceSupportsTouch(enabled ? true : m_originalDev iceSupportsTouch);
1390 // Currently emulation does not provide multiple touch points. 1396 // Currently emulation does not provide multiple touch points.
1391 m_page->settings().setMaxTouchPoints(enabled ? 1 : m_originalMaxTouchPoi nts); 1397 m_page->settings().setMaxTouchPoints(enabled ? 1 : m_originalMaxTouchPoi nts);
1392 } 1398 }
1393 m_touchEmulationEnabled = enabled; 1399 m_touchEmulationEnabled = enabled;
1394 m_client->setTouchEventEmulationEnabled(enabled); 1400 m_client->setTouchEventEmulationEnabled(enabled);
1395 m_page->deprecatedLocalMainFrame()->view()->layout(); 1401 inspectedFrame()->view()->layout();
1396 } 1402 }
1397 1403
1398 void InspectorPageAgent::setTouchEmulationEnabled(ErrorString*, bool enabled, co nst String* configuration) 1404 void InspectorPageAgent::setTouchEmulationEnabled(ErrorString*, bool enabled, co nst String* configuration)
1399 { 1405 {
1400 if (m_state->getBoolean(PageAgentState::touchEventEmulationEnabled) == enabl ed) 1406 if (m_state->getBoolean(PageAgentState::touchEventEmulationEnabled) == enabl ed)
1401 return; 1407 return;
1402 1408
1403 m_state->setBoolean(PageAgentState::touchEventEmulationEnabled, enabled); 1409 m_state->setBoolean(PageAgentState::touchEventEmulationEnabled, enabled);
1404 updateTouchEventEmulationInPage(enabled); 1410 updateTouchEventEmulationInPage(enabled);
1405 } 1411 }
1406 1412
1407 void InspectorPageAgent::setEmulatedMedia(ErrorString*, const String& media) 1413 void InspectorPageAgent::setEmulatedMedia(ErrorString*, const String& media)
1408 { 1414 {
1415 if (!inspectedFrame()->isMainFrame())
1416 return;
1409 String currentMedia = m_state->getString(PageAgentState::pageAgentEmulatedMe dia); 1417 String currentMedia = m_state->getString(PageAgentState::pageAgentEmulatedMe dia);
1410 if (media == currentMedia) 1418 if (media == currentMedia)
1411 return; 1419 return;
1412 1420
1413 m_state->setString(PageAgentState::pageAgentEmulatedMedia, media); 1421 m_state->setString(PageAgentState::pageAgentEmulatedMedia, media);
1414 Document* document = 0; 1422 Document* document = inspectedFrame()->document();
1415 if (m_page->mainFrame())
1416 document = m_page->deprecatedLocalMainFrame()->document();
1417 if (document) { 1423 if (document) {
1418 document->mediaQueryAffectingValueChanged(); 1424 document->mediaQueryAffectingValueChanged();
1419 document->styleResolverChanged(); 1425 document->styleResolverChanged();
1420 document->updateLayout(); 1426 document->updateLayout();
1421 } 1427 }
1422 } 1428 }
1423 1429
1424 bool InspectorPageAgent::applyViewportStyleOverride(StyleResolver* resolver) 1430 bool InspectorPageAgent::applyViewportStyleOverride(StyleResolver* resolver)
1425 { 1431 {
1426 if (!m_deviceMetricsOverridden || !m_emulateMobileEnabled) 1432 if (!m_deviceMetricsOverridden || !m_emulateMobileEnabled)
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
1467 m_state->setBoolean(PageAgentState::showGridOnResize, asBool(showGrid)); 1473 m_state->setBoolean(PageAgentState::showGridOnResize, asBool(showGrid));
1468 } 1474 }
1469 1475
1470 void InspectorPageAgent::setOverlayMessage(ErrorString*, const String* message) 1476 void InspectorPageAgent::setOverlayMessage(ErrorString*, const String* message)
1471 { 1477 {
1472 m_overlay->setPausedInDebuggerMessage(message); 1478 m_overlay->setPausedInDebuggerMessage(message);
1473 } 1479 }
1474 1480
1475 void InspectorPageAgent::animationsPlaybackRate(ErrorString*, double* playbackRa te) 1481 void InspectorPageAgent::animationsPlaybackRate(ErrorString*, double* playbackRa te)
1476 { 1482 {
1477 *playbackRate = toLocalFrame(m_page->mainFrame())->document()->timeline().pl aybackRate(); 1483 *playbackRate = inspectedFrame()->document()->timeline().playbackRate();
1478 } 1484 }
1479 1485
1480 void InspectorPageAgent::setAnimationsPlaybackRate(ErrorString*, double playback Rate) 1486 void InspectorPageAgent::setAnimationsPlaybackRate(ErrorString*, double playback Rate)
1481 { 1487 {
1482 for (Frame* frame = m_page->mainFrame(); frame; frame = frame->tree().traver seNext()) { 1488 for (Frame* frame = inspectedFrame(); frame; frame = frame->tree().traverseN ext(inspectedFrame())) {
1483 if (frame->isLocalFrame()) 1489 if (frame->isLocalFrame())
1484 toLocalFrame(frame)->document()->timeline().setPlaybackRate(playback Rate); 1490 toLocalFrame(frame)->document()->timeline().setPlaybackRate(playback Rate);
1485 } 1491 }
1486 } 1492 }
1487 1493
1488 void InspectorPageAgent::clearEditedResourcesContent() 1494 void InspectorPageAgent::clearEditedResourcesContent()
1489 { 1495 {
1490 m_editedResourceContent.clear(); 1496 m_editedResourceContent.clear();
1491 } 1497 }
1492 1498
(...skipping 13 matching lines...) Expand all
1506 void InspectorPageAgent::trace(Visitor* visitor) 1512 void InspectorPageAgent::trace(Visitor* visitor)
1507 { 1513 {
1508 visitor->trace(m_page); 1514 visitor->trace(m_page);
1509 visitor->trace(m_injectedScriptManager); 1515 visitor->trace(m_injectedScriptManager);
1510 visitor->trace(m_inspectorResourceContentLoader); 1516 visitor->trace(m_inspectorResourceContentLoader);
1511 InspectorBaseAgent::trace(visitor); 1517 InspectorBaseAgent::trace(visitor);
1512 } 1518 }
1513 1519
1514 } // namespace blink 1520 } // namespace blink
1515 1521
OLDNEW
« no previous file with comments | « Source/core/inspector/InspectorPageAgent.h ('k') | Source/core/inspector/InspectorResourceAgent.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698