| Index: Source/core/inspector/InspectorPageAgent.cpp
|
| diff --git a/Source/core/inspector/InspectorPageAgent.cpp b/Source/core/inspector/InspectorPageAgent.cpp
|
| index 076da51099406fa7aa744e7abf7e9511ef5adc72..b7d087e9524d7457da727c4addac7e1a3a296328 100644
|
| --- a/Source/core/inspector/InspectorPageAgent.cpp
|
| +++ b/Source/core/inspector/InspectorPageAgent.cpp
|
| @@ -502,7 +502,7 @@ void InspectorPageAgent::enable(ErrorString*)
|
| m_instrumentingAgents->setInspectorPageAgent(this);
|
| if (m_inspectorResourceContentLoader)
|
| m_inspectorResourceContentLoader->dispose();
|
| - m_inspectorResourceContentLoader = adoptPtrWillBeNoop(new InspectorResourceContentLoader(m_page));
|
| + m_inspectorResourceContentLoader = adoptPtrWillBeNoop(new InspectorResourceContentLoader(inspectedFrame()));
|
| }
|
|
|
| void InspectorPageAgent::discardAgent()
|
| @@ -588,13 +588,12 @@ void InspectorPageAgent::reload(ErrorString*, const bool* const optionalIgnoreCa
|
| {
|
| m_pendingScriptToEvaluateOnLoadOnce = optionalScriptToEvaluateOnLoad ? *optionalScriptToEvaluateOnLoad : "";
|
| m_pendingScriptPreprocessor = optionalScriptPreprocessor ? *optionalScriptPreprocessor : "";
|
| - m_page->mainFrame()->reload(asBool(optionalIgnoreCache) ? EndToEndReload : NormalReload, NotClientRedirect);
|
| + inspectedFrame()->reload(asBool(optionalIgnoreCache) ? EndToEndReload : NormalReload, NotClientRedirect);
|
| }
|
|
|
| void InspectorPageAgent::navigate(ErrorString*, const String& url, String* outFrameId)
|
| {
|
| - LocalFrame* frame = m_page->deprecatedLocalMainFrame();
|
| - *outFrameId = frameId(frame);
|
| + *outFrameId = frameId(inspectedFrame());
|
| }
|
|
|
| static PassRefPtr<TypeBuilder::Page::Cookie> buildObjectForCookie(const Cookie& cookie)
|
| @@ -700,7 +699,7 @@ void InspectorPageAgent::getCookies(ErrorString*, RefPtr<TypeBuilder::Array<Type
|
| {
|
| ListHashSet<Cookie> rawCookiesList;
|
|
|
| - for (Frame* frame = mainFrame(); frame; frame = frame->tree().traverseNext(mainFrame())) {
|
| + for (Frame* frame = inspectedFrame(); frame; frame = frame->tree().traverseNext(inspectedFrame())) {
|
| if (!frame->isLocalFrame())
|
| continue;
|
| Document* document = toLocalFrame(frame)->document();
|
| @@ -722,7 +721,7 @@ void InspectorPageAgent::getCookies(ErrorString*, RefPtr<TypeBuilder::Array<Type
|
| void InspectorPageAgent::deleteCookie(ErrorString*, const String& cookieName, const String& url)
|
| {
|
| KURL parsedURL(ParsedURLString, url);
|
| - for (Frame* frame = m_page->mainFrame(); frame; frame = frame->tree().traverseNext(m_page->mainFrame())) {
|
| + for (Frame* frame = inspectedFrame(); frame; frame = frame->tree().traverseNext(inspectedFrame())) {
|
| if (frame->isLocalFrame())
|
| blink::deleteCookie(toLocalFrame(frame)->document(), parsedURL, cookieName);
|
| }
|
| @@ -730,7 +729,7 @@ void InspectorPageAgent::deleteCookie(ErrorString*, const String& cookieName, co
|
|
|
| void InspectorPageAgent::getResourceTree(ErrorString*, RefPtr<TypeBuilder::Page::FrameResourceTree>& object)
|
| {
|
| - object = buildObjectForFrameTree(m_page->deprecatedLocalMainFrame());
|
| + object = buildObjectForFrameTree(inspectedFrame());
|
| }
|
|
|
| void InspectorPageAgent::getResourceContentAfterResourcesContentLoaded(const String& frameId, const String& url, PassRefPtrWillBeRawPtr<GetResourceContentCallback> callback)
|
| @@ -909,8 +908,8 @@ void InspectorPageAgent::setShowPaintRects(ErrorString*, bool show)
|
| m_state->setBoolean(PageAgentState::pageAgentShowPaintRects, show);
|
| m_client->setShowPaintRects(show);
|
|
|
| - if (!show && mainFrame() && mainFrame()->view())
|
| - mainFrame()->view()->invalidate();
|
| + if (!show && inspectedFrame() && inspectedFrame()->isMainFrame() && inspectedFrame()->view())
|
| + inspectedFrame()->view()->invalidate();
|
| }
|
|
|
| void InspectorPageAgent::setShowDebugBorders(ErrorString* errorString, bool show)
|
| @@ -950,7 +949,7 @@ void InspectorPageAgent::getScriptExecutionStatus(ErrorString*, PageCommandHandl
|
| {
|
| bool disabledByScriptController = false;
|
| bool disabledInSettings = false;
|
| - LocalFrame* frame = mainFrame();
|
| + LocalFrame* frame = inspectedFrame();
|
| if (frame) {
|
| disabledByScriptController = !frame->script().canExecuteScripts(NotAboutToExecuteScript);
|
| if (frame->settings())
|
| @@ -969,10 +968,10 @@ void InspectorPageAgent::getScriptExecutionStatus(ErrorString*, PageCommandHandl
|
| void InspectorPageAgent::setScriptExecutionDisabled(ErrorString*, bool value)
|
| {
|
| m_state->setBoolean(PageAgentState::pageAgentScriptExecutionDisabled, value);
|
| - if (!mainFrame())
|
| + if (!inspectedFrame())
|
| return;
|
|
|
| - Settings* settings = mainFrame()->settings();
|
| + Settings* settings = inspectedFrame()->settings();
|
| if (settings) {
|
| m_ignoreScriptsEnabledNotification = true;
|
| settings->setScriptEnabled(!value);
|
| @@ -999,24 +998,21 @@ void InspectorPageAgent::didClearDocumentOfWindowObject(LocalFrame* frame)
|
|
|
| void InspectorPageAgent::domContentLoadedEventFired(LocalFrame* frame)
|
| {
|
| - if (!frame->isMainFrame())
|
| + if (frame != inspectedFrame())
|
| return;
|
| m_frontend->domContentEventFired(currentTime());
|
| }
|
|
|
| void InspectorPageAgent::loadEventFired(LocalFrame* frame)
|
| {
|
| - if (!frame->isMainFrame())
|
| + if (frame != inspectedFrame())
|
| return;
|
| m_frontend->loadEventFired(currentTime());
|
| }
|
|
|
| void InspectorPageAgent::didCommitLoad(LocalFrame*, DocumentLoader* loader)
|
| {
|
| - // FIXME: If "frame" is always guaranteed to be in the same Page as loader->frame()
|
| - // then all we need to check here is loader->frame()->isMainFrame()
|
| - // and we don't need "frame" at all.
|
| - if (loader->frame() == m_page->mainFrame()) {
|
| + if (loader->frame() == inspectedFrame()) {
|
| m_scriptToEvaluateOnLoadOnce = m_pendingScriptToEvaluateOnLoadOnce;
|
| m_scriptPreprocessorSource = m_pendingScriptPreprocessor;
|
| m_pendingScriptToEvaluateOnLoadOnce = String();
|
| @@ -1046,7 +1042,12 @@ void InspectorPageAgent::frameDetachedFromParent(LocalFrame* frame)
|
| }
|
| }
|
|
|
| -LocalFrame* InspectorPageAgent::mainFrame()
|
| +FrameHost* InspectorPageAgent::frameHost()
|
| +{
|
| + return &m_page->frameHost();
|
| +}
|
| +
|
| +LocalFrame* InspectorPageAgent::inspectedFrame()
|
| {
|
| return m_page->deprecatedLocalMainFrame();
|
| }
|
| @@ -1088,8 +1089,7 @@ String InspectorPageAgent::loaderId(DocumentLoader* loader)
|
|
|
| LocalFrame* InspectorPageAgent::findFrameWithSecurityOrigin(const String& originRawString)
|
| {
|
| - for (Frame* frame = m_page->mainFrame(); frame; frame = frame->tree().traverseNext()) {
|
| - // FIXME: RemoteFrame security origins are not yet available.
|
| + for (Frame* frame = inspectedFrame(); frame; frame = frame->tree().traverseNext(inspectedFrame())) {
|
| if (!frame->isLocalFrame())
|
| continue;
|
| RefPtr<SecurityOrigin> documentOrigin = toLocalFrame(frame)->document()->securityOrigin();
|
| @@ -1113,7 +1113,7 @@ const AtomicString& InspectorPageAgent::resourceSourceMapURL(const String& url)
|
| DEFINE_STATIC_LOCAL(const AtomicString, deprecatedSourceMapHttpHeader, ("X-SourceMap", AtomicString::ConstructFromLiteral));
|
| if (url.isEmpty())
|
| return nullAtom;
|
| - LocalFrame* frame = mainFrame();
|
| + LocalFrame* frame = inspectedFrame();
|
| if (!frame)
|
| return nullAtom;
|
| Resource* resource = cachedResource(frame, KURL(ParsedURLString, url));
|
| @@ -1217,10 +1217,10 @@ void InspectorPageAgent::didScroll()
|
|
|
| void InspectorPageAgent::viewportChanged()
|
| {
|
| - if (!m_enabled || !m_deviceMetricsOverridden)
|
| + if (!m_enabled || !m_deviceMetricsOverridden || !inspectedFrame()->isMainFrame())
|
| return;
|
| - IntSize contentsSize = m_page->deprecatedLocalMainFrame()->view()->contentsSize();
|
| - IntRect viewRect = m_page->deprecatedLocalMainFrame()->view()->visibleContentRect();
|
| + IntSize contentsSize = inspectedFrame()->view()->contentsSize();
|
| + IntRect viewRect = inspectedFrame()->view()->visibleContentRect();
|
| RefPtr<TypeBuilder::Page::Viewport> viewport = TypeBuilder::Page::Viewport::create()
|
| .setScrollX(viewRect.x())
|
| .setScrollY(viewRect.y())
|
| @@ -1234,6 +1234,8 @@ void InspectorPageAgent::viewportChanged()
|
|
|
| void InspectorPageAgent::didResizeMainFrame()
|
| {
|
| + if (!inspectedFrame()->isMainFrame())
|
| + return;
|
| #if !OS(ANDROID)
|
| if (m_enabled && m_state->getBoolean(PageAgentState::showSizeOnResize))
|
| m_overlay->showAndHideViewSize(m_state->getBoolean(PageAgentState::showGridOnResize));
|
| @@ -1346,6 +1348,8 @@ void InspectorPageAgent::updateViewMetrics(bool enabled, int width, int height,
|
| {
|
| if (enabled && !m_page->settings().acceleratedCompositingEnabled())
|
| return;
|
| + if (!inspectedFrame()->isMainFrame())
|
| + return;
|
|
|
| m_deviceMetricsOverridden = enabled;
|
| m_emulateMobileEnabled = mobile;
|
| @@ -1354,7 +1358,7 @@ void InspectorPageAgent::updateViewMetrics(bool enabled, int width, int height,
|
| else
|
| m_client->clearDeviceMetricsOverride();
|
|
|
| - Document* document = mainFrame()->document();
|
| + Document* document = inspectedFrame()->document();
|
| if (document) {
|
| document->styleResolverChanged();
|
| document->mediaQueryAffectingValueChanged();
|
| @@ -1377,6 +1381,8 @@ void InspectorPageAgent::updateViewMetrics(bool enabled, int width, int height,
|
|
|
| void InspectorPageAgent::updateTouchEventEmulationInPage(bool enabled)
|
| {
|
| + if (!inspectedFrame()->isMainFrame())
|
| + return;
|
| if (!m_touchEmulationEnabled) {
|
| m_originalTouchEnabled = RuntimeEnabledFeatures::touchEnabled();
|
| m_originalDeviceSupportsMouse = m_page->settings().deviceSupportsMouse();
|
| @@ -1392,7 +1398,7 @@ void InspectorPageAgent::updateTouchEventEmulationInPage(bool enabled)
|
| }
|
| m_touchEmulationEnabled = enabled;
|
| m_client->setTouchEventEmulationEnabled(enabled);
|
| - m_page->deprecatedLocalMainFrame()->view()->layout();
|
| + inspectedFrame()->view()->layout();
|
| }
|
|
|
| void InspectorPageAgent::setTouchEmulationEnabled(ErrorString*, bool enabled, const String* configuration)
|
| @@ -1406,14 +1412,14 @@ void InspectorPageAgent::setTouchEmulationEnabled(ErrorString*, bool enabled, co
|
|
|
| void InspectorPageAgent::setEmulatedMedia(ErrorString*, const String& media)
|
| {
|
| + if (!inspectedFrame()->isMainFrame())
|
| + return;
|
| String currentMedia = m_state->getString(PageAgentState::pageAgentEmulatedMedia);
|
| if (media == currentMedia)
|
| return;
|
|
|
| m_state->setString(PageAgentState::pageAgentEmulatedMedia, media);
|
| - Document* document = 0;
|
| - if (m_page->mainFrame())
|
| - document = m_page->deprecatedLocalMainFrame()->document();
|
| + Document* document = inspectedFrame()->document();
|
| if (document) {
|
| document->mediaQueryAffectingValueChanged();
|
| document->styleResolverChanged();
|
| @@ -1474,12 +1480,12 @@ void InspectorPageAgent::setOverlayMessage(ErrorString*, const String* message)
|
|
|
| void InspectorPageAgent::animationsPlaybackRate(ErrorString*, double* playbackRate)
|
| {
|
| - *playbackRate = toLocalFrame(m_page->mainFrame())->document()->timeline().playbackRate();
|
| + *playbackRate = inspectedFrame()->document()->timeline().playbackRate();
|
| }
|
|
|
| void InspectorPageAgent::setAnimationsPlaybackRate(ErrorString*, double playbackRate)
|
| {
|
| - for (Frame* frame = m_page->mainFrame(); frame; frame = frame->tree().traverseNext()) {
|
| + for (Frame* frame = inspectedFrame(); frame; frame = frame->tree().traverseNext(inspectedFrame())) {
|
| if (frame->isLocalFrame())
|
| toLocalFrame(frame)->document()->timeline().setPlaybackRate(playbackRate);
|
| }
|
|
|