Chromium Code Reviews| Index: third_party/WebKit/Source/web/WebViewImpl.cpp |
| diff --git a/third_party/WebKit/Source/web/WebViewImpl.cpp b/third_party/WebKit/Source/web/WebViewImpl.cpp |
| index 33c4cdd77443cdff181b43512a460f7e1e658f3e..9cf3c4d1926fcc7287cbb5e03044d7a57fd92473 100644 |
| --- a/third_party/WebKit/Source/web/WebViewImpl.cpp |
| +++ b/third_party/WebKit/Source/web/WebViewImpl.cpp |
| @@ -265,7 +265,7 @@ UserGestureNotifier::UserGestureNotifier(WebAutofillClient* client, bool* userGe |
| : m_client(client) |
| , m_userGestureObserved(userGestureObserved) |
| { |
| - ASSERT(m_userGestureObserved); |
| + DCHECK(m_userGestureObserved); |
| } |
| UserGestureNotifier::~UserGestureNotifier() |
| @@ -362,7 +362,7 @@ void WebView::willEnterModalLoop() |
| void WebView::didExitModalLoop() |
| { |
| - ASSERT(pageLoadDeferrerStack().size()); |
| + DCHECK(pageLoadDeferrerStack().size()); |
| pageLoadDeferrerStack().removeLast(); |
| } |
| @@ -373,13 +373,13 @@ void WebViewImpl::setMainFrame(WebFrame* frame) |
| void WebViewImpl::setCredentialManagerClient(WebCredentialManagerClient* webCredentialManagerClient) |
| { |
| - ASSERT(m_page); |
| + DCHECK(m_page); |
| provideCredentialManagerClientTo(*m_page, new CredentialManagerClient(webCredentialManagerClient)); |
| } |
| void WebViewImpl::setPrerendererClient(WebPrerendererClient* prerendererClient) |
| { |
| - ASSERT(m_page); |
| + DCHECK(m_page); |
| providePrerendererClientTo(*m_page, new PrerendererClientImpl(prerendererClient)); |
| } |
| @@ -478,12 +478,12 @@ WebViewImpl::WebViewImpl(WebViewClient* client) |
| WebViewImpl::~WebViewImpl() |
| { |
| - ASSERT(!m_page); |
| + DCHECK(!m_page); |
| // Each highlight uses m_owningWebViewImpl->m_linkHighlightsTimeline |
| // in destructor. m_linkHighlightsTimeline might be destroyed earlier |
| // than m_linkHighlights. |
| - ASSERT(m_linkHighlights.isEmpty()); |
| + DCHECK(m_linkHighlights.isEmpty()); |
| } |
| WebDevToolsAgentImpl* WebViewImpl::mainFrameDevToolsAgentImpl() |
| @@ -507,7 +507,7 @@ WebLocalFrameImpl* WebViewImpl::mainFrameImpl() const |
| bool WebViewImpl::tabKeyCyclesThroughElements() const |
| { |
| - ASSERT(m_page); |
| + DCHECK(m_page); |
| return m_page->tabKeyCyclesThroughElements(); |
| } |
| @@ -532,7 +532,7 @@ void WebViewImpl::handleMouseDown(LocalFrame& mainFrame, const WebMouseEvent& ev |
| if (event.button == WebMouseEvent::ButtonLeft) { |
| pagePopup = m_pagePopup; |
| hidePopups(); |
| - ASSERT(!m_pagePopup); |
| + DCHECK(!m_pagePopup); |
| } |
| m_lastMouseDownPoint = WebPoint(event.x, event.y); |
| @@ -659,7 +659,7 @@ WebGestureEvent WebViewImpl::createGestureScrollEventFromFling(WebInputEvent::Ty |
| bool WebViewImpl::scrollBy(const WebFloatSize& delta, const WebFloatSize& velocity) |
| { |
| - ASSERT(m_flingSourceDevice != WebGestureDeviceUninitialized); |
| + DCHECK_NE(m_flingSourceDevice, WebGestureDeviceUninitialized); |
| if (!m_page || !m_page->mainFrame() || !m_page->mainFrame()->isLocalFrame() || !m_page->deprecatedLocalMainFrame()->view()) |
| return false; |
| @@ -736,9 +736,9 @@ WebInputEventResult WebViewImpl::handleGestureEvent(const WebGestureEvent& event |
| m_globalPositionOnFlingStart = WebPoint(event.globalX, event.globalY); |
| m_flingModifier = event.modifiers; |
| m_flingSourceDevice = event.sourceDevice; |
| - ASSERT(m_flingSourceDevice != WebGestureDeviceUninitialized); |
| + DCHECK_NE(m_flingSourceDevice, WebGestureDeviceUninitialized); |
| OwnPtr<WebGestureCurve> flingCurve = adoptPtr(Platform::current()->createFlingAnimationCurve(event.sourceDevice, WebFloatPoint(event.data.flingStart.velocityX, event.data.flingStart.velocityY), WebSize())); |
| - ASSERT(flingCurve); |
| + DCHECK(flingCurve); |
| m_gestureAnimation = WebActiveGestureAnimation::createAtAnimationStart(flingCurve.release(), this); |
| scheduleAnimation(); |
| eventResult = WebInputEventResult::HandledSystem; |
| @@ -826,7 +826,7 @@ WebInputEventResult WebViewImpl::handleGestureEvent(const WebGestureEvent& event |
| // element from immediately reopening the same popup. |
| RefPtr<WebPagePopupImpl> pagePopup = m_pagePopup; |
| hidePopups(); |
| - ASSERT(!m_pagePopup); |
| + DCHECK(!m_pagePopup); |
| m_client->cancelScheduledContentIntents(); |
| if (detectContentOnTouch(targetedEvent)) { |
| @@ -912,10 +912,10 @@ WebInputEventResult WebViewImpl::handleGestureEvent(const WebGestureEvent& event |
| WebInputEventResult WebViewImpl::handleSyntheticWheelFromTouchpadPinchEvent(const WebGestureEvent& pinchEvent) |
| { |
| - ASSERT(pinchEvent.type == WebInputEvent::GesturePinchUpdate); |
| + DCHECK_EQ(pinchEvent.type, WebInputEvent::GesturePinchUpdate); |
| // Touchscreen pinch events should not reach Blink. |
| - ASSERT(pinchEvent.sourceDevice == WebGestureDeviceTouchpad); |
| + DCHECK_EQ(pinchEvent.sourceDevice, WebGestureDeviceTouchpad); |
| // For pinch gesture events, match typical trackpad behavior on Windows by sending fake |
| // wheel events with the ctrl modifier set when we see trackpad pinch gestures. Ideally |
| @@ -941,7 +941,7 @@ WebInputEventResult WebViewImpl::handleSyntheticWheelFromTouchpadPinchEvent(cons |
| // - a formula that's relatively easy to use from JavaScript |
| // Note that 'wheel' event deltaY values have their sign inverted. So to |
| // convert a wheel deltaY back to a scale use Math.exp(-deltaY/100). |
| - ASSERT(pinchEvent.data.pinchUpdate.scale > 0); |
| + DCHECK_GT(pinchEvent.data.pinchUpdate.scale, 0); |
| wheelEvent.deltaY = 100.0f * log(pinchEvent.data.pinchUpdate.scale); |
| wheelEvent.hasPreciseScrollingDeltas = true; |
| wheelEvent.wheelTicksX = 0; |
| @@ -955,14 +955,14 @@ WebInputEventResult WebViewImpl::handleSyntheticWheelFromTouchpadPinchEvent(cons |
| void WebViewImpl::transferActiveWheelFlingAnimation(const WebActiveWheelFlingParameters& parameters) |
| { |
| TRACE_EVENT0("blink", "WebViewImpl::transferActiveWheelFlingAnimation"); |
| - ASSERT(!m_gestureAnimation); |
| + DCHECK(!m_gestureAnimation); |
| m_positionOnFlingStart = parameters.point; |
| m_globalPositionOnFlingStart = parameters.globalPoint; |
| m_flingModifier = parameters.modifiers; |
| OwnPtr<WebGestureCurve> curve = adoptPtr(Platform::current()->createFlingAnimationCurve(parameters.sourceDevice, WebFloatPoint(parameters.delta), parameters.cumulativeScroll)); |
| - ASSERT(curve); |
| + DCHECK(curve); |
| m_gestureAnimation = WebActiveGestureAnimation::createWithTimeOffset(curve.release(), this, parameters.startTime); |
| - ASSERT(parameters.sourceDevice != WebGestureDeviceUninitialized); |
| + DCHECK_NE(parameters.sourceDevice, WebGestureDeviceUninitialized); |
| m_flingSourceDevice = parameters.sourceDevice; |
| scheduleAnimation(); |
| } |
| @@ -1064,7 +1064,7 @@ void WebViewImpl::acceptLanguagesChanged() |
| WebInputEventResult WebViewImpl::handleKeyEvent(const WebKeyboardEvent& event) |
| { |
| - ASSERT((event.type == WebInputEvent::RawKeyDown) |
| + DCHECK((event.type == WebInputEvent::RawKeyDown) |
| || (event.type == WebInputEvent::KeyDown) |
| || (event.type == WebInputEvent::KeyUp)); |
| TRACE_EVENT2("input", "WebViewImpl::handleKeyEvent", |
| @@ -1153,7 +1153,7 @@ WebInputEventResult WebViewImpl::handleKeyEvent(const WebKeyboardEvent& event) |
| WebInputEventResult WebViewImpl::handleCharEvent(const WebKeyboardEvent& event) |
| { |
| - ASSERT(event.type == WebInputEvent::Char); |
| + DCHECK_EQ(event.type, WebInputEvent::Char); |
| TRACE_EVENT1("input", "WebViewImpl::handleCharEvent", |
| "text", String(event.text).utf8()); |
| @@ -1258,8 +1258,8 @@ WebRect WebViewImpl::widenRectWithinPageBounds(const WebRect& source, int target |
| const int newWidth = source.width + leftMargin + rightMargin; |
| const int newX = source.x - leftMargin; |
| - ASSERT(newWidth >= 0); |
| - ASSERT(scrollOffset.width() + newX + newWidth <= maxSize.width); |
| + DCHECK_GE(newWidth, 0); |
| + DCHECK_LE(scrollOffset.width() + newX + newWidth, maxSize.width); |
| return WebRect(newX, source.y, newWidth, source.height); |
| } |
| @@ -1684,10 +1684,10 @@ bool WebViewImpl::mapKeyCodeForScroll( |
| PagePopup* WebViewImpl::openPagePopup(PagePopupClient* client) |
| { |
| - ASSERT(client); |
| + DCHECK(client); |
| if (hasOpenedPopup()) |
| hidePopups(); |
| - ASSERT(!m_pagePopup); |
| + DCHECK(!m_pagePopup); |
| WebWidget* popupWidget = m_client->createPopupMenu(WebPopupTypePage); |
| // createPopupMenu returns nullptr if this renderer process is about to die. |
| @@ -1704,9 +1704,9 @@ PagePopup* WebViewImpl::openPagePopup(PagePopupClient* client) |
| void WebViewImpl::closePagePopup(PagePopup* popup) |
| { |
| - ASSERT(popup); |
| + DCHECK(popup); |
| WebPagePopupImpl* popupImpl = toWebPagePopupImpl(popup); |
| - ASSERT(m_pagePopup.get() == popupImpl); |
| + DCHECK_EQ(m_pagePopup.get(), popupImpl); |
| if (m_pagePopup.get() != popupImpl) |
| return; |
| m_pagePopup->closePopup(); |
| @@ -1734,9 +1734,9 @@ void WebViewImpl::enablePopupMouseWheelEventListener() |
| // See https://crbug.com/566130 |
| if (!mainFrameImpl() || !mainFrameImpl()->frame()->isLocalFrame()) |
| return; |
| - ASSERT(!m_popupMouseWheelEventListener); |
| + DCHECK(!m_popupMouseWheelEventListener); |
| Document* document = mainFrameImpl()->frame()->document(); |
| - ASSERT(document); |
| + DCHECK(document); |
| // We register an empty event listener, EmptyEventListener, so that mouse |
| // wheel events get sent to the WebView. |
| m_popupMouseWheelEventListener = EmptyEventListener::create(); |
| @@ -1749,9 +1749,9 @@ void WebViewImpl::disablePopupMouseWheelEventListener() |
| // See https://crbug.com/566130 |
| if (!mainFrameImpl() || !mainFrameImpl()->frame()->isLocalFrame()) |
| return; |
| - ASSERT(m_popupMouseWheelEventListener); |
| + DCHECK(m_popupMouseWheelEventListener); |
| Document* document = mainFrameImpl()->frame()->document(); |
| - ASSERT(document); |
| + DCHECK(document); |
| // Document may have already removed the event listener, for instance, due |
| // to a navigation, but remove it anyway. |
| document->removeEventListener(EventTypeNames::mousewheel, m_popupMouseWheelEventListener.release(), false); |
| @@ -1777,7 +1777,7 @@ WebViewImpl* WebViewImpl::fromPage(Page* page) |
| void WebViewImpl::close() |
| { |
| WebDevToolsAgentImpl::webViewImplClosed(this); |
| - ASSERT(allInstances().contains(this)); |
| + DCHECK(allInstances().contains(this)); |
| allInstances().remove(this); |
| if (m_page) { |
| @@ -1869,7 +1869,7 @@ TopControls& WebViewImpl::topControls() |
| void WebViewImpl::resizeViewWhileAnchored(FrameView* view) |
| { |
| - ASSERT(mainFrameImpl() && mainFrameImpl()->frame()->isLocalFrame()); |
| + DCHECK(mainFrameImpl() && mainFrameImpl()->frame()->isLocalFrame()); |
|
tkent
2016/03/31 23:05:21
Please split this into two.
DCHECK(mainFrameIm
|
| { |
| // Avoids unnecessary invalidations while various bits of state in TextAutosizer are updated. |
| @@ -1938,14 +1938,14 @@ void WebViewImpl::didExitFullScreen() |
| void WebViewImpl::beginFrame(double lastFrameTimeMonotonic) |
| { |
| TRACE_EVENT1("blink", "WebViewImpl::beginFrame", "frameTime", lastFrameTimeMonotonic); |
| - ASSERT(lastFrameTimeMonotonic); |
| + DCHECK(lastFrameTimeMonotonic); |
| // Create synthetic wheel events as necessary for fling. |
| if (m_gestureAnimation) { |
| if (m_gestureAnimation->animate(lastFrameTimeMonotonic)) |
| scheduleAnimation(); |
| else { |
| - ASSERT(m_flingSourceDevice != WebGestureDeviceUninitialized); |
| + DCHECK_NE(m_flingSourceDevice, WebGestureDeviceUninitialized); |
| WebGestureDevice lastFlingSourceDevice = m_flingSourceDevice; |
| endActiveFlingAnimation(); |
| @@ -2016,7 +2016,7 @@ void WebViewImpl::paint(WebCanvas* canvas, const WebRect& rect) |
| { |
| // This should only be used when compositing is not being used for this |
| // WebView, and it is painting into the recording of its parent. |
| - ASSERT(!isAcceleratedCompositingActive()); |
| + DCHECK(!isAcceleratedCompositingActive()); |
| double paintStart = currentTime(); |
| PageWidgetDelegate::paint(*m_page, canvas, rect, *m_page->deprecatedLocalMainFrame()); |
| @@ -2034,7 +2034,7 @@ void WebViewImpl::paintCompositedDeprecated(WebCanvas* canvas, const WebRect& re |
| // Note: This method exists on OS(ANDROID) and will hopefully be |
| // removed once the link disambiguation feature renders using |
| // the compositor. |
| - ASSERT(isAcceleratedCompositingActive()); |
| + DCHECK(isAcceleratedCompositingActive()); |
| PageWidgetDelegate::paintIgnoringCompositing(*m_page, canvas, rect, *m_page->deprecatedLocalMainFrame()); |
| } |
| @@ -2396,7 +2396,7 @@ bool WebViewImpl::compositionRange(size_t* location, size_t* length) |
| return false; |
| Element* editable = focused->selection().rootEditableElementOrDocumentElement(); |
| - ASSERT(editable); |
| + DCHECK(editable); |
| PlainTextRange plainTextRange(PlainTextRange::create(*editable, range)); |
| if (plainTextRange.isNull()) |
| return false; |
| @@ -2794,7 +2794,7 @@ WebSettingsImpl* WebViewImpl::settingsImpl() |
| { |
| if (!m_webSettings) |
| m_webSettings = adoptPtr(new WebSettingsImpl(&m_page->settings(), m_devToolsEmulator.get())); |
| - ASSERT(m_webSettings); |
| + DCHECK(m_webSettings); |
| return m_webSettings.get(); |
| } |
| @@ -3133,19 +3133,19 @@ float WebViewImpl::clampPageScaleFactorToLimits(float scaleFactor) const |
| void WebViewImpl::setVisualViewportOffset(const WebFloatPoint& offset) |
| { |
| - ASSERT(page()); |
| + DCHECK(page()); |
| page()->frameHost().visualViewport().setLocation(offset); |
| } |
| WebFloatPoint WebViewImpl::visualViewportOffset() const |
| { |
| - ASSERT(page()); |
| + DCHECK(page()); |
| return page()->frameHost().visualViewport().visibleRect().location(); |
| } |
| WebFloatSize WebViewImpl::visualViewportSize() const |
| { |
| - ASSERT(page()); |
| + DCHECK(page()); |
| return page()->frameHost().visualViewport().visibleRect().size(); |
| } |
| @@ -3175,7 +3175,7 @@ void WebViewImpl::scrollAndRescaleViewports(float scaleFactor, |
| void WebViewImpl::setPageScaleFactorAndLocation(float scaleFactor, const FloatPoint& location) |
| { |
| - ASSERT(page()); |
| + DCHECK(page()); |
| page()->frameHost().visualViewport().setScaleAndLocation( |
| clampPageScaleFactorToLimits(scaleFactor), |
| @@ -3184,7 +3184,7 @@ void WebViewImpl::setPageScaleFactorAndLocation(float scaleFactor, const FloatPo |
| void WebViewImpl::setPageScaleFactor(float scaleFactor) |
| { |
| - ASSERT(page()); |
| + DCHECK(page()); |
| scaleFactor = clampPageScaleFactorToLimits(scaleFactor); |
| if (scaleFactor == pageScaleFactor()) |
| @@ -3621,7 +3621,7 @@ WebDragOperation WebViewImpl::dragTargetDragEnter( |
| WebDragOperationsMask operationsAllowed, |
| int modifiers) |
| { |
| - ASSERT(!m_currentDragData); |
| + DCHECK(!m_currentDragData); |
| m_currentDragData = DataObject::create(webDragData); |
| m_operationsAllowed = operationsAllowed; |
| @@ -3642,7 +3642,7 @@ WebDragOperation WebViewImpl::dragTargetDragOver( |
| void WebViewImpl::dragTargetDragLeave() |
| { |
| - ASSERT(m_currentDragData); |
| + DCHECK(m_currentDragData); |
| DragData dragData( |
| m_currentDragData.get(), |
| @@ -3662,7 +3662,7 @@ void WebViewImpl::dragTargetDrop(const WebPoint& clientPoint, |
| const WebPoint& screenPoint, |
| int modifiers) |
| { |
| - ASSERT(m_currentDragData); |
| + DCHECK(m_currentDragData); |
| WebAutofillClient* autofillClient = mainFrameImpl() ? mainFrameImpl()->autofillClient() : 0; |
| UserGestureNotifier notifier(autofillClient, &m_userGestureObserved); |
| @@ -3719,7 +3719,7 @@ void WebViewImpl::removeSpellingMarkersUnderWords(const WebVector<WebString>& wo |
| WebDragOperation WebViewImpl::dragTargetDragEnterOrOver(const WebPoint& clientPoint, const WebPoint& screenPoint, DragAction dragAction, int modifiers) |
| { |
| - ASSERT(m_currentDragData); |
| + DCHECK(m_currentDragData); |
| m_currentDragData->setModifiers(modifiers); |
| DragData dragData( |
| @@ -4131,14 +4131,14 @@ void WebViewImpl::startDragging(LocalFrame* frame, |
| { |
| if (!m_client) |
| return; |
| - ASSERT(!m_doingDragAndDrop); |
| + DCHECK(!m_doingDragAndDrop); |
| m_doingDragAndDrop = true; |
| m_client->startDragging(WebLocalFrameImpl::fromFrame(frame), dragData, mask, dragImage, dragImageOffset); |
| } |
| void WebViewImpl::setIgnoreInputEvents(bool newValue) |
| { |
| - ASSERT(m_ignoreInputEvents != newValue); |
| + DCHECK_NE(m_ignoreInputEvents, newValue); |
| m_ignoreInputEvents = newValue; |
| } |
| @@ -4240,7 +4240,7 @@ void WebViewImpl::setRootGraphicsLayer(GraphicsLayer* layer) |
| // In SPv2, we attach layers via PaintArtifactCompositor, rather than |
| // supplying a root GraphicsLayer from PaintLayerCompositor. |
| - ASSERT(!RuntimeEnabledFeatures::slimmingPaintV2Enabled()); |
| + DCHECK(!RuntimeEnabledFeatures::slimmingPaintV2Enabled()); |
| VisualViewport& visualViewport = page()->frameHost().visualViewport(); |
| visualViewport.attachToLayerTree(layer); |
| @@ -4334,7 +4334,7 @@ void WebViewImpl::initializeLayerTreeView() |
| // FIXME: only unittests, click to play, Android printing, and printing (for headers and footers) |
| // make this assert necessary. We should make them not hit this code and then delete allowsBrokenNullLayerTreeView. |
| - ASSERT(m_layerTreeView || !m_client || m_client->allowsBrokenNullLayerTreeView()); |
| + DCHECK(m_layerTreeView || !m_client || m_client->allowsBrokenNullLayerTreeView()); |
| if (Platform::current()->isThreadedAnimationEnabled() && m_layerTreeView) { |
| m_linkHighlightsTimeline = adoptPtr(CompositorFactory::current().createAnimationTimeline()); |
| @@ -4423,8 +4423,8 @@ void WebViewImpl::updateLayerTreeBackgroundColor() |
| void WebViewImpl::updateLayerTreeDeviceScaleFactor() |
| { |
| - ASSERT(page()); |
| - ASSERT(m_layerTreeView); |
| + DCHECK(page()); |
| + DCHECK(m_layerTreeView); |
| float deviceScaleFactor = m_compositorDeviceScaleFactorOverride ? m_compositorDeviceScaleFactorOverride : page()->deviceScaleFactor(); |
| m_layerTreeView->setDeviceScaleFactor(deviceScaleFactor); |
| @@ -4481,7 +4481,7 @@ WebViewScheduler* WebViewImpl::scheduler() const |
| void WebViewImpl::setVisibilityState(WebPageVisibilityState visibilityState, |
| bool isInitialState) { |
| - ASSERT(visibilityState == WebPageVisibilityStateVisible || visibilityState == WebPageVisibilityStateHidden || visibilityState == WebPageVisibilityStatePrerender); |
| + DCHECK(visibilityState == WebPageVisibilityStateVisible || visibilityState == WebPageVisibilityStateHidden || visibilityState == WebPageVisibilityStatePrerender); |
| if (page()) |
| m_page->setVisibilityState(static_cast<PageVisibilityState>(static_cast<int>(visibilityState)), isInitialState); |
| @@ -4565,13 +4565,13 @@ void WebViewImpl::attachPaintArtifactCompositor() |
| // Otherwise, PaintLayerCompositor is expected to supply a root |
| // GraphicsLayer via setRootGraphicsLayer. |
| - ASSERT(RuntimeEnabledFeatures::slimmingPaintV2Enabled()); |
| + DCHECK(RuntimeEnabledFeatures::slimmingPaintV2Enabled()); |
| // TODO(jbroman): This should probably have hookups for overlays, visual |
| // viewport, etc. |
| WebLayer* rootLayer = m_paintArtifactCompositor.getWebLayer(); |
| - ASSERT(rootLayer); |
| + DCHECK(rootLayer); |
| m_layerTreeView->setRootLayer(*rootLayer); |
| // TODO(jbroman): This is cargo-culted from setRootGraphicsLayer. Is it |