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

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

Issue 1839643009: RELEASE_ASSERT -> CHECK and ASSERT -> DCHECK in web. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Return DCHECK_IS_ON checks. Created 4 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
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2009 Google Inc. All rights reserved. 2 * Copyright (C) 2009 Google Inc. All rights reserved.
3 * Copyright (C) 2014 Opera Software ASA. All rights reserved. 3 * Copyright (C) 2014 Opera Software ASA. All rights reserved.
4 * 4 *
5 * Redistribution and use in source and binary forms, with or without 5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are 6 * modification, are permitted provided that the following conditions are
7 * met: 7 * met:
8 * 8 *
9 * * Redistributions of source code must retain the above copyright 9 * * Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer. 10 * notice, this list of conditions and the following disclaimer.
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after
133 m_webLayer, location(), size()); 133 m_webLayer, location(), size());
134 return; 134 return;
135 } 135 }
136 136
137 if (LayoutObjectDrawingRecorder::useCachedDrawingIfPossible(context, *m_elem ent->layoutObject(), DisplayItem::Type::WebPlugin)) 137 if (LayoutObjectDrawingRecorder::useCachedDrawingIfPossible(context, *m_elem ent->layoutObject(), DisplayItem::Type::WebPlugin))
138 return; 138 return;
139 139
140 LayoutObjectDrawingRecorder drawingRecorder(context, *m_element->layoutObjec t(), DisplayItem::Type::WebPlugin, cullRect.m_rect); 140 LayoutObjectDrawingRecorder drawingRecorder(context, *m_element->layoutObjec t(), DisplayItem::Type::WebPlugin, cullRect.m_rect);
141 context.save(); 141 context.save();
142 142
143 ASSERT(parent()->isFrameView()); 143 DCHECK(parent()->isFrameView());
144 FrameView* view = toFrameView(parent()); 144 FrameView* view = toFrameView(parent());
145 145
146 // The plugin is positioned in the root frame's coordinates, so it needs to 146 // The plugin is positioned in the root frame's coordinates, so it needs to
147 // be painted in them too. 147 // be painted in them too.
148 IntPoint origin = view->contentsToRootFrame(IntPoint(0, 0)); 148 IntPoint origin = view->contentsToRootFrame(IntPoint(0, 0));
149 context.translate(static_cast<float>(-origin.x()), static_cast<float>(-origi n.y())); 149 context.translate(static_cast<float>(-origin.x()), static_cast<float>(-origi n.y()));
150 150
151 WebCanvas* canvas = context.canvas(); 151 WebCanvas* canvas = context.canvas();
152 152
153 IntRect windowRect = view->contentsToRootFrame(cullRect.m_rect); 153 IntRect windowRect = view->contentsToRootFrame(cullRect.m_rect);
(...skipping 298 matching lines...) Expand 10 before | Expand all | Expand 10 after
452 if (!frame->script().canExecuteScripts(NotAboutToExecuteScript)) 452 if (!frame->script().canExecuteScripts(NotAboutToExecuteScript))
453 return v8::Local<v8::Object>(); 453 return v8::Local<v8::Object>();
454 454
455 ScriptState* scriptState = ScriptState::forMainWorld(frame); 455 ScriptState* scriptState = ScriptState::forMainWorld(frame);
456 if (!scriptState) 456 if (!scriptState)
457 return v8::Local<v8::Object>(); 457 return v8::Local<v8::Object>();
458 458
459 v8::Local<v8::Value> v8value = toV8(m_element.get(), scriptState->context()- >Global(), scriptState->isolate()); 459 v8::Local<v8::Value> v8value = toV8(m_element.get(), scriptState->context()- >Global(), scriptState->isolate());
460 if (v8value.IsEmpty()) 460 if (v8value.IsEmpty())
461 return v8::Local<v8::Object>(); 461 return v8::Local<v8::Object>();
462 ASSERT(v8value->IsObject()); 462 DCHECK(v8value->IsObject());
463 463
464 return v8::Local<v8::Object>::Cast(v8value); 464 return v8::Local<v8::Object>::Cast(v8value);
465 } 465 }
466 466
467 WebString WebPluginContainerImpl::executeScriptURL(const WebURL& url, bool popup sAllowed) 467 WebString WebPluginContainerImpl::executeScriptURL(const WebURL& url, bool popup sAllowed)
468 { 468 {
469 LocalFrame* frame = m_element->document().frame(); 469 LocalFrame* frame = m_element->document().frame();
470 if (!frame) 470 if (!frame)
471 return WebString(); 471 return WebString();
472 472
473 if (!m_element->document().contentSecurityPolicy()->allowJavaScriptURLs(m_el ement->document().url(), OrdinalNumber())) 473 if (!m_element->document().contentSecurityPolicy()->allowJavaScriptURLs(m_el ement->document().url(), OrdinalNumber()))
474 return WebString(); 474 return WebString();
475 475
476 const KURL& kurl = url; 476 const KURL& kurl = url;
477 ASSERT(kurl.protocolIs("javascript")); 477 DCHECK(kurl.protocolIs("javascript"));
478 478
479 String script = decodeURLEscapeSequences( 479 String script = decodeURLEscapeSequences(
480 kurl.getString().substring(strlen("javascript:"))); 480 kurl.getString().substring(strlen("javascript:")));
481 481
482 UserGestureIndicator gestureIndicator(popupsAllowed ? DefinitelyProcessingNe wUserGesture : PossiblyProcessingUserGesture); 482 UserGestureIndicator gestureIndicator(popupsAllowed ? DefinitelyProcessingNe wUserGesture : PossiblyProcessingUserGesture);
483 v8::HandleScope handleScope(toIsolate(frame)); 483 v8::HandleScope handleScope(toIsolate(frame));
484 v8::Local<v8::Value> result = frame->script().executeScriptInMainWorldAndRet urnValue(ScriptSourceCode(script)); 484 v8::Local<v8::Value> result = frame->script().executeScriptInMainWorldAndRet urnValue(ScriptSourceCode(script));
485 485
486 // Failure is reported as a null string. 486 // Failure is reported as a null string.
487 if (result.IsEmpty() || !result->IsString()) 487 if (result.IsEmpty() || !result->IsString())
(...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after
673 { 673 {
674 #if ENABLE(OILPAN) 674 #if ENABLE(OILPAN)
675 ThreadState::current()->registerPreFinalizer(this); 675 ThreadState::current()->registerPreFinalizer(this);
676 #endif 676 #endif
677 } 677 }
678 678
679 WebPluginContainerImpl::~WebPluginContainerImpl() 679 WebPluginContainerImpl::~WebPluginContainerImpl()
680 { 680 {
681 #if ENABLE(OILPAN) 681 #if ENABLE(OILPAN)
682 // The plugin container must have been disposed of by now. 682 // The plugin container must have been disposed of by now.
683 ASSERT(!m_webPlugin); 683 DCHECK(!m_webPlugin);
684 #else 684 #else
685 dispose(); 685 dispose();
686 #endif 686 #endif
687 } 687 }
688 688
689 void WebPluginContainerImpl::dispose() 689 void WebPluginContainerImpl::dispose()
690 { 690 {
691 m_isDisposed = true; 691 m_isDisposed = true;
692 692
693 requestTouchEventType(TouchEventRequestTypeNone); 693 requestTouchEventType(TouchEventRequestTypeNone);
694 setWantsWheelEvents(false); 694 setWantsWheelEvents(false);
695 695
696 if (m_webPlugin) { 696 if (m_webPlugin) {
697 RELEASE_ASSERT(!m_webPlugin->container() || m_webPlugin->container() == this); 697 CHECK(!m_webPlugin->container() || m_webPlugin->container() == this);
698 m_webPlugin->destroy(); 698 m_webPlugin->destroy();
699 m_webPlugin = nullptr; 699 m_webPlugin = nullptr;
700 } 700 }
701 701
702 if (m_webLayer) { 702 if (m_webLayer) {
703 GraphicsLayer::unregisterContentsLayer(m_webLayer); 703 GraphicsLayer::unregisterContentsLayer(m_webLayer);
704 m_webLayer = nullptr; 704 m_webLayer = nullptr;
705 } 705 }
706 } 706 }
707 707
708 DEFINE_TRACE(WebPluginContainerImpl) 708 DEFINE_TRACE(WebPluginContainerImpl)
709 { 709 {
710 visitor->trace(m_element); 710 visitor->trace(m_element);
711 LocalFrameLifecycleObserver::trace(visitor); 711 LocalFrameLifecycleObserver::trace(visitor);
712 PluginView::trace(visitor); 712 PluginView::trace(visitor);
713 } 713 }
714 714
715 void WebPluginContainerImpl::handleMouseEvent(MouseEvent* event) 715 void WebPluginContainerImpl::handleMouseEvent(MouseEvent* event)
716 { 716 {
717 ASSERT(parent()->isFrameView()); 717 DCHECK(parent()->isFrameView());
718 718
719 // We cache the parent FrameView here as the plugin widget could be deleted 719 // We cache the parent FrameView here as the plugin widget could be deleted
720 // in the call to HandleEvent. See http://b/issue?id=1362948 720 // in the call to HandleEvent. See http://b/issue?id=1362948
721 FrameView* parentView = toFrameView(parent()); 721 FrameView* parentView = toFrameView(parent());
722 722
723 WebMouseEventBuilder webEvent(this, m_element->layoutObject(), *event); 723 WebMouseEventBuilder webEvent(this, m_element->layoutObject(), *event);
724 if (webEvent.type == WebInputEvent::Undefined) 724 if (webEvent.type == WebInputEvent::Undefined)
725 return; 725 return;
726 726
727 if (event->type() == EventTypeNames::mousedown) 727 if (event->type() == EventTypeNames::mousedown)
728 focusPlugin(); 728 focusPlugin();
729 729
730 WebCursorInfo cursorInfo; 730 WebCursorInfo cursorInfo;
731 if (m_webPlugin->handleInputEvent(webEvent, cursorInfo) != WebInputEventResu lt::NotHandled) 731 if (m_webPlugin->handleInputEvent(webEvent, cursorInfo) != WebInputEventResu lt::NotHandled)
732 event->setDefaultHandled(); 732 event->setDefaultHandled();
733 733
734 // A windowless plugin can change the cursor in response to a mouse move 734 // A windowless plugin can change the cursor in response to a mouse move
735 // event. We need to reflect the changed cursor in the frame view as the 735 // event. We need to reflect the changed cursor in the frame view as the
736 // mouse is moved in the boundaries of the windowless plugin. 736 // mouse is moved in the boundaries of the windowless plugin.
737 Page* page = parentView->frame().page(); 737 Page* page = parentView->frame().page();
738 if (!page) 738 if (!page)
739 return; 739 return;
740 toChromeClientImpl(page->chromeClient()).setCursorForPlugin(cursorInfo, pare ntView->frame().localFrameRoot()); 740 toChromeClientImpl(page->chromeClient()).setCursorForPlugin(cursorInfo, pare ntView->frame().localFrameRoot());
741 } 741 }
742 742
743 void WebPluginContainerImpl::handleDragEvent(MouseEvent* event) 743 void WebPluginContainerImpl::handleDragEvent(MouseEvent* event)
744 { 744 {
745 ASSERT(event->isDragEvent()); 745 DCHECK(event->isDragEvent());
746 746
747 WebDragStatus dragStatus = WebDragStatusUnknown; 747 WebDragStatus dragStatus = WebDragStatusUnknown;
748 if (event->type() == EventTypeNames::dragenter) 748 if (event->type() == EventTypeNames::dragenter)
749 dragStatus = WebDragStatusEnter; 749 dragStatus = WebDragStatusEnter;
750 else if (event->type() == EventTypeNames::dragleave) 750 else if (event->type() == EventTypeNames::dragleave)
751 dragStatus = WebDragStatusLeave; 751 dragStatus = WebDragStatusLeave;
752 else if (event->type() == EventTypeNames::dragover) 752 else if (event->type() == EventTypeNames::dragover)
753 dragStatus = WebDragStatusOver; 753 dragStatus = WebDragStatusOver;
754 else if (event->type() == EventTypeNames::drop) 754 else if (event->type() == EventTypeNames::drop)
755 dragStatus = WebDragStatusDrop; 755 dragStatus = WebDragStatusDrop;
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after
890 if (!layoutObject) 890 if (!layoutObject)
891 return; 891 return;
892 892
893 layoutObject->invalidatePaintRectangle(LayoutRect(m_pendingInvalidationRect) ); 893 layoutObject->invalidatePaintRectangle(LayoutRect(m_pendingInvalidationRect) );
894 m_pendingInvalidationRect = IntRect(); 894 m_pendingInvalidationRect = IntRect();
895 } 895 }
896 896
897 void WebPluginContainerImpl::computeClipRectsForPlugin( 897 void WebPluginContainerImpl::computeClipRectsForPlugin(
898 const HTMLFrameOwnerElement* ownerElement, IntRect& windowRect, IntRect& cli ppedLocalRect, IntRect& unclippedIntLocalRect) const 898 const HTMLFrameOwnerElement* ownerElement, IntRect& windowRect, IntRect& cli ppedLocalRect, IntRect& unclippedIntLocalRect) const
899 { 899 {
900 ASSERT(ownerElement); 900 DCHECK(ownerElement);
901 901
902 if (!ownerElement->layoutObject()) { 902 if (!ownerElement->layoutObject()) {
903 clippedLocalRect = IntRect(); 903 clippedLocalRect = IntRect();
904 unclippedIntLocalRect = IntRect(); 904 unclippedIntLocalRect = IntRect();
905 return; 905 return;
906 } 906 }
907 907
908 LayoutView* rootView = m_element->document().view()->layoutView(); 908 LayoutView* rootView = m_element->document().view()->layoutView();
909 while (rootView->frame()->ownerLayoutObject()) 909 while (rootView->frame()->ownerLayoutObject())
910 rootView = rootView->frame()->ownerLayoutObject()->view(); 910 rootView = rootView->frame()->ownerLayoutObject()->view();
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
949 // frame view. 949 // frame view.
950 computeClipRectsForPlugin(m_element, windowRect, clipRect, unobscuredRec t); 950 computeClipRectsForPlugin(m_element, windowRect, clipRect, unobscuredRec t);
951 } 951 }
952 getPluginOcclusions(m_element, this->parent(), frameRect(), cutOutRects); 952 getPluginOcclusions(m_element, this->parent(), frameRect(), cutOutRects);
953 // Convert to the plugin position. 953 // Convert to the plugin position.
954 for (size_t i = 0; i < cutOutRects.size(); i++) 954 for (size_t i = 0; i < cutOutRects.size(); i++)
955 cutOutRects[i].move(-frameRect().x(), -frameRect().y()); 955 cutOutRects[i].move(-frameRect().x(), -frameRect().y());
956 } 956 }
957 957
958 } // namespace blink 958 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/web/WebPagePopupImpl.cpp ('k') | third_party/WebKit/Source/web/WebRemoteFrameImpl.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698