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

Side by Side Diff: third_party/WebKit/Source/web/WebFrameWidgetImpl.cpp

Issue 2775113002: Audit use of m_client in WebFrameWidgetImpl and remove null checks. (Closed)
Patch Set: Created 3 years, 8 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2014 Google Inc. All rights reserved. 2 * Copyright (C) 2014 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 170 matching lines...) Expand 10 before | Expand all | Expand 10 after
181 181
182 void WebFrameWidgetImpl::sendResizeEventAndRepaint() { 182 void WebFrameWidgetImpl::sendResizeEventAndRepaint() {
183 // FIXME: This is wrong. The FrameView is responsible sending a resizeEvent 183 // FIXME: This is wrong. The FrameView is responsible sending a resizeEvent
184 // as part of layout. Layout is also responsible for sending invalidations 184 // as part of layout. Layout is also responsible for sending invalidations
185 // to the embedder. This method and all callers may be wrong. -- eseidel. 185 // to the embedder. This method and all callers may be wrong. -- eseidel.
186 if (m_localRoot->frameView()) { 186 if (m_localRoot->frameView()) {
187 // Enqueues the resize event. 187 // Enqueues the resize event.
188 m_localRoot->frame()->document()->enqueueResizeEvent(); 188 m_localRoot->frame()->document()->enqueueResizeEvent();
189 } 189 }
190 190
191 if (m_client) { 191 DCHECK(m_client);
192 if (isAcceleratedCompositingActive()) { 192 if (isAcceleratedCompositingActive()) {
193 updateLayerTreeViewport(); 193 updateLayerTreeViewport();
194 } else { 194 } else {
195 WebRect damagedRect(0, 0, m_size.width, m_size.height); 195 WebRect damagedRect(0, 0, m_size.width, m_size.height);
196 m_client->didInvalidateRect(damagedRect); 196 m_client->didInvalidateRect(damagedRect);
197 }
198 } 197 }
199 } 198 }
200 199
201 void WebFrameWidgetImpl::resizeVisualViewport(const WebSize& newSize) { 200 void WebFrameWidgetImpl::resizeVisualViewport(const WebSize& newSize) {
202 // TODO(alexmos, kenrb): resizing behavior such as this should be changed 201 // TODO(alexmos, kenrb): resizing behavior such as this should be changed
203 // to use Page messages. https://crbug.com/599688. 202 // to use Page messages. https://crbug.com/599688.
204 page()->visualViewport().setSize(newSize); 203 page()->visualViewport().setSize(newSize);
205 page()->visualViewport().clampToBoundaries(); 204 page()->visualViewport().clampToBoundaries();
206 205
207 view()->didUpdateFullscreenSize(); 206 view()->didUpdateFullscreenSize();
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after
333 // Report the event to be NOT processed by WebKit, so that the browser can 332 // Report the event to be NOT processed by WebKit, so that the browser can
334 // handle it appropriately. 333 // handle it appropriately.
335 if (ignoreInputEvents()) 334 if (ignoreInputEvents())
336 return WebInputEventResult::NotHandled; 335 return WebInputEventResult::NotHandled;
337 336
338 // FIXME: pass event to m_localRoot's WebDevToolsAgentImpl once available. 337 // FIXME: pass event to m_localRoot's WebDevToolsAgentImpl once available.
339 338
340 AutoReset<const WebInputEvent*> currentEventChange(&m_currentInputEvent, 339 AutoReset<const WebInputEvent*> currentEventChange(&m_currentInputEvent,
341 &inputEvent); 340 &inputEvent);
342 341
342 DCHECK(m_client);
dcheng 2017/03/27 04:33:24 (Also, I'm not sure where this DCHECK comes from;
343 if (m_client->isPointerLocked() && 343 if (m_client->isPointerLocked() &&
344 WebInputEvent::isMouseEventType(inputEvent.type())) { 344 WebInputEvent::isMouseEventType(inputEvent.type())) {
345 pointerLockMouseEvent(inputEvent); 345 pointerLockMouseEvent(inputEvent);
346 return WebInputEventResult::HandledSystem; 346 return WebInputEventResult::HandledSystem;
347 } 347 }
348 348
349 if (m_mouseCaptureNode && 349 if (m_mouseCaptureNode &&
350 WebInputEvent::isMouseEventType(inputEvent.type())) { 350 WebInputEvent::isMouseEventType(inputEvent.type())) {
351 TRACE_EVENT1("input", "captured mouse event", "type", inputEvent.type()); 351 TRACE_EVENT1("input", "captured mouse event", "type", inputEvent.type());
352 // Save m_mouseCaptureNode since mouseCaptureLost() will clear it. 352 // Save m_mouseCaptureNode since mouseCaptureLost() will clear it.
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
416 WebInputMethodControllerImpl* 416 WebInputMethodControllerImpl*
417 WebFrameWidgetImpl::getActiveWebInputMethodController() const { 417 WebFrameWidgetImpl::getActiveWebInputMethodController() const {
418 return WebInputMethodControllerImpl::fromFrame(focusedLocalFrameInWidget()); 418 return WebInputMethodControllerImpl::fromFrame(focusedLocalFrameInWidget());
419 } 419 }
420 420
421 void WebFrameWidgetImpl::scheduleAnimation() { 421 void WebFrameWidgetImpl::scheduleAnimation() {
422 if (m_layerTreeView) { 422 if (m_layerTreeView) {
423 m_layerTreeView->setNeedsBeginFrame(); 423 m_layerTreeView->setNeedsBeginFrame();
424 return; 424 return;
425 } 425 }
426 if (m_client) 426 DCHECK(m_client);
427 m_client->scheduleAnimation(); 427 m_client->scheduleAnimation();
428 } 428 }
429 429
430 CompositorMutatorImpl& WebFrameWidgetImpl::mutator() { 430 CompositorMutatorImpl& WebFrameWidgetImpl::mutator() {
431 if (!m_mutator) { 431 if (!m_mutator) {
432 std::unique_ptr<CompositorMutatorClient> mutatorClient = 432 std::unique_ptr<CompositorMutatorClient> mutatorClient =
433 CompositorMutatorImpl::createClient(); 433 CompositorMutatorImpl::createClient();
434 m_mutator = static_cast<CompositorMutatorImpl*>(mutatorClient->mutator()); 434 m_mutator = static_cast<CompositorMutatorImpl*>(mutatorClient->mutator());
435 m_layerTreeView->setMutatorClient(std::move(mutatorClient)); 435 m_layerTreeView->setMutatorClient(std::move(mutatorClient));
436 } 436 }
437 437
(...skipping 386 matching lines...) Expand 10 before | Expand all | Expand 10 after
824 } 824 }
825 825
826 WebInputEventResult WebFrameWidgetImpl::handleMouseWheel( 826 WebInputEventResult WebFrameWidgetImpl::handleMouseWheel(
827 LocalFrame& mainFrame, 827 LocalFrame& mainFrame,
828 const WebMouseWheelEvent& event) { 828 const WebMouseWheelEvent& event) {
829 return PageWidgetEventHandler::handleMouseWheel(mainFrame, event); 829 return PageWidgetEventHandler::handleMouseWheel(mainFrame, event);
830 } 830 }
831 831
832 WebInputEventResult WebFrameWidgetImpl::handleGestureEvent( 832 WebInputEventResult WebFrameWidgetImpl::handleGestureEvent(
833 const WebGestureEvent& event) { 833 const WebGestureEvent& event) {
834 DCHECK(m_client);
dcheng 2017/03/27 04:33:24 Ditto.
834 WebInputEventResult eventResult = WebInputEventResult::NotHandled; 835 WebInputEventResult eventResult = WebInputEventResult::NotHandled;
835 bool eventCancelled = false; 836 bool eventCancelled = false;
836 switch (event.type()) { 837 switch (event.type()) {
837 case WebInputEvent::GestureScrollBegin: 838 case WebInputEvent::GestureScrollBegin:
838 case WebInputEvent::GestureScrollEnd: 839 case WebInputEvent::GestureScrollEnd:
839 case WebInputEvent::GestureScrollUpdate: 840 case WebInputEvent::GestureScrollUpdate:
840 case WebInputEvent::GestureTap: 841 case WebInputEvent::GestureTap:
841 case WebInputEvent::GestureTapUnconfirmed: 842 case WebInputEvent::GestureTapUnconfirmed:
842 case WebInputEvent::GestureTapDown: 843 case WebInputEvent::GestureTapDown:
843 case WebInputEvent::GestureShowPress: 844 case WebInputEvent::GestureShowPress:
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after
983 return nullptr; 984 return nullptr;
984 985
985 Document* document = frame->document(); 986 Document* document = frame->document();
986 if (!document) 987 if (!document)
987 return nullptr; 988 return nullptr;
988 989
989 return document->focusedElement(); 990 return document->focusedElement();
990 } 991 }
991 992
992 void WebFrameWidgetImpl::initializeLayerTreeView() { 993 void WebFrameWidgetImpl::initializeLayerTreeView() {
993 if (m_client) { 994 DCHECK(m_client);
994 DCHECK(!m_mutator); 995 DCHECK(!m_mutator);
995 m_layerTreeView = m_client->initializeLayerTreeView(); 996 m_layerTreeView = m_client->initializeLayerTreeView();
996 if (m_layerTreeView && m_layerTreeView->compositorAnimationHost()) { 997 if (m_layerTreeView && m_layerTreeView->compositorAnimationHost()) {
997 m_animationHost = WTF::makeUnique<CompositorAnimationHost>( 998 m_animationHost = WTF::makeUnique<CompositorAnimationHost>(
998 m_layerTreeView->compositorAnimationHost()); 999 m_layerTreeView->compositorAnimationHost());
999 }
1000 } 1000 }
1001 1001
1002 if (WebDevToolsAgentImpl* devTools = m_localRoot->devToolsAgentImpl()) 1002 if (WebDevToolsAgentImpl* devTools = m_localRoot->devToolsAgentImpl())
1003 devTools->layerTreeViewChanged(m_layerTreeView); 1003 devTools->layerTreeViewChanged(m_layerTreeView);
1004 1004
1005 page()->settings().setAcceleratedCompositingEnabled(m_layerTreeView); 1005 page()->settings().setAcceleratedCompositingEnabled(m_layerTreeView);
1006 if (m_layerTreeView) { 1006 if (m_layerTreeView) {
1007 page()->layerTreeViewInitialized(*m_layerTreeView, 1007 page()->layerTreeViewInitialized(*m_layerTreeView,
1008 m_localRoot->frame()->view()); 1008 m_localRoot->frame()->view());
1009 } 1009 }
1010 1010
1011 // FIXME: only unittests, click to play, Android priting, and printing (for 1011 // FIXME: only unittests, click to play, Android priting, and printing (for
1012 // headers and footers) make this assert necessary. We should make them not 1012 // headers and footers) make this assert necessary. We should make them not
1013 // hit this code and then delete allowsBrokenNullLayerTreeView. 1013 // hit this code and then delete allowsBrokenNullLayerTreeView.
1014 DCHECK(m_layerTreeView || !m_client || 1014 DCHECK(m_layerTreeView || m_client->allowsBrokenNullLayerTreeView());
1015 m_client->allowsBrokenNullLayerTreeView());
1016 } 1015 }
1017 1016
1018 void WebFrameWidgetImpl::setIsAcceleratedCompositingActive(bool active) { 1017 void WebFrameWidgetImpl::setIsAcceleratedCompositingActive(bool active) {
1019 // In the middle of shutting down; don't try to spin back up a compositor. 1018 // In the middle of shutting down; don't try to spin back up a compositor.
1020 // FIXME: compositing startup/shutdown should be refactored so that it 1019 // FIXME: compositing startup/shutdown should be refactored so that it
1021 // turns on explicitly rather than lazily, which causes this awkwardness. 1020 // turns on explicitly rather than lazily, which causes this awkwardness.
1022 if (m_layerTreeViewClosed) 1021 if (m_layerTreeViewClosed)
1023 return; 1022 return;
1024 1023
1025 DCHECK(!active || m_layerTreeView); 1024 DCHECK(!active || m_layerTreeView);
1026 1025
1027 if (m_isAcceleratedCompositingActive == active) 1026 if (m_isAcceleratedCompositingActive == active)
1028 return; 1027 return;
1029 1028
1030 if (!m_client)
1031 return;
1032
1033 if (active) { 1029 if (active) {
1034 TRACE_EVENT0("blink", 1030 TRACE_EVENT0("blink",
1035 "WebViewImpl::setIsAcceleratedCompositingActive(true)"); 1031 "WebViewImpl::setIsAcceleratedCompositingActive(true)");
1036 m_layerTreeView->setRootLayer(*m_rootLayer); 1032 m_layerTreeView->setRootLayer(*m_rootLayer);
1037 1033
1038 m_layerTreeView->setVisible(page()->isPageVisible()); 1034 m_layerTreeView->setVisible(page()->isPageVisible());
1039 updateLayerTreeDeviceScaleFactor(); 1035 updateLayerTreeDeviceScaleFactor();
1040 updateLayerTreeBackgroundColor(); 1036 updateLayerTreeBackgroundColor();
1041 m_layerTreeView->setHasTransparentBackground(isTransparent()); 1037 m_layerTreeView->setHasTransparentBackground(isTransparent());
1042 updateLayerTreeViewport(); 1038 updateLayerTreeViewport();
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
1141 return nullptr; 1137 return nullptr;
1142 } 1138 }
1143 1139
1144 LocalFrame* WebFrameWidgetImpl::focusedLocalFrameAvailableForIme() const { 1140 LocalFrame* WebFrameWidgetImpl::focusedLocalFrameAvailableForIme() const {
1145 if (!m_imeAcceptEvents) 1141 if (!m_imeAcceptEvents)
1146 return nullptr; 1142 return nullptr;
1147 return focusedLocalFrameInWidget(); 1143 return focusedLocalFrameInWidget();
1148 } 1144 }
1149 1145
1150 } // namespace blink 1146 } // namespace blink
OLDNEW
« 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