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

Unified Diff: third_party/WebKit/Source/web/DevToolsEmulator.cpp

Issue 1622633003: [DevTools] Check that mainFrameImpl() has been initalized before accessing it. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: more checks, better comments Created 4 years, 11 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/Source/web/DevToolsEmulator.cpp
diff --git a/third_party/WebKit/Source/web/DevToolsEmulator.cpp b/third_party/WebKit/Source/web/DevToolsEmulator.cpp
index 9732c91e87c3e3d65a730de989cad25975d464ce..d43ac88853648036c7a82b728c9ae2e4afb819ee 100644
--- a/third_party/WebKit/Source/web/DevToolsEmulator.cpp
+++ b/third_party/WebKit/Source/web/DevToolsEmulator.cpp
@@ -229,8 +229,12 @@ void DevToolsEmulator::enableDeviceEmulation(const WebDeviceEmulationParams& par
m_webViewImpl->setCompositorDeviceScaleFactorOverride(params.deviceScaleFactor);
m_webViewImpl->setRootLayerTransform(WebSize(params.offset.x, params.offset.y), params.scale);
- if (Document* document = m_webViewImpl->mainFrameImpl()->frame()->document())
- document->mediaQueryAffectingValueChanged();
+ // TODO(dgozman): mainFrameImpl() is null when it's remote. Figure out how
+ // we end up with enabling emulation in this case.
+ if (m_webViewImpl->mainFrameImpl()) {
+ if (Document* document = m_webViewImpl->mainFrameImpl()->frame()->document())
+ document->mediaQueryAffectingValueChanged();
+ }
}
void DevToolsEmulator::disableDeviceEmulation()
@@ -246,8 +250,11 @@ void DevToolsEmulator::disableDeviceEmulation()
m_webViewImpl->setCompositorDeviceScaleFactorOverride(0.f);
m_webViewImpl->setRootLayerTransform(WebSize(0.f, 0.f), 1.f);
m_webViewImpl->setPageScaleFactor(1.f);
- if (Document* document = m_webViewImpl->mainFrameImpl()->frame()->document())
- document->mediaQueryAffectingValueChanged();
+ // mainFrameImpl() could be null during cleanup or remote <-> local swap.
+ if (m_webViewImpl->mainFrameImpl()) {
+ if (Document* document = m_webViewImpl->mainFrameImpl()->frame()->document())
+ document->mediaQueryAffectingValueChanged();
+ }
}
bool DevToolsEmulator::resizeIsDeviceSizeChange()
@@ -280,7 +287,10 @@ void DevToolsEmulator::enableMobileEmulation()
m_originalDefaultMinimumPageScaleFactor = m_webViewImpl->defaultMinimumPageScaleFactor();
m_originalDefaultMaximumPageScaleFactor = m_webViewImpl->defaultMaximumPageScaleFactor();
m_webViewImpl->setDefaultPageScaleLimits(0.25f, 5);
- m_webViewImpl->mainFrameImpl()->frameView()->layout();
+ // TODO(dgozman): mainFrameImpl() is null when it's remote. Figure out how
+ // we end up with enabling emulation in this case.
+ if (m_webViewImpl->mainFrameImpl())
+ m_webViewImpl->mainFrameImpl()->frameView()->layout();
}
void DevToolsEmulator::disableMobileEmulation()
@@ -306,7 +316,9 @@ void DevToolsEmulator::disableMobileEmulation()
m_webViewImpl->setDefaultPageScaleLimits(
m_originalDefaultMinimumPageScaleFactor,
m_originalDefaultMaximumPageScaleFactor);
- m_webViewImpl->mainFrameImpl()->frameView()->layout();
+ // mainFrameImpl() could be null during cleanup or remote <-> local swap.
+ if (m_webViewImpl->mainFrameImpl())
+ m_webViewImpl->mainFrameImpl()->frameView()->layout();
}
void DevToolsEmulator::setTouchEventEmulationEnabled(bool enabled)
@@ -327,7 +339,14 @@ void DevToolsEmulator::setTouchEventEmulationEnabled(bool enabled)
m_webViewImpl->page()->settings().setMaxTouchPoints(enabled ? 1 : m_originalMaxTouchPoints);
}
m_touchEventEmulationEnabled = enabled;
- m_webViewImpl->mainFrameImpl()->frameView()->layout();
+ // TODO(dgozman): mainFrameImpl() check in this class should be unnecessary.
+ // It is only needed when we reattach and restore InspectorEmulationAgent,
+ // which happens before everything has been setup correctly, and therefore
+ // fails during remote -> local main frame transition.
+ // We should instead route emulation from browser through the WebViewImpl
+ // to the local main frame, and remove InspectorEmulationAgent entirely.
+ if (m_webViewImpl->mainFrameImpl())
+ m_webViewImpl->mainFrameImpl()->frameView()->layout();
}
void DevToolsEmulator::setScriptExecutionDisabled(bool scriptExecutionDisabled)
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698