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

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: Fix compilation. 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 195 matching lines...) Expand 10 before | Expand all | Expand 10 after
683 { 683 {
684 #if ENABLE(OILPAN) 684 #if ENABLE(OILPAN)
685 ThreadState::current()->registerPreFinalizer(this); 685 ThreadState::current()->registerPreFinalizer(this);
686 #endif 686 #endif
687 } 687 }
688 688
689 WebPluginContainerImpl::~WebPluginContainerImpl() 689 WebPluginContainerImpl::~WebPluginContainerImpl()
690 { 690 {
691 #if ENABLE(OILPAN) 691 #if ENABLE(OILPAN)
692 // The plugin container must have been disposed of by now. 692 // The plugin container must have been disposed of by now.
693 ASSERT(!m_webPlugin); 693 DCHECK(!m_webPlugin);
694 #else 694 #else
695 dispose(); 695 dispose();
696 #endif 696 #endif
697 } 697 }
698 698
699 void WebPluginContainerImpl::dispose() 699 void WebPluginContainerImpl::dispose()
700 { 700 {
701 m_isDisposed = true; 701 m_isDisposed = true;
702 702
703 requestTouchEventType(TouchEventRequestTypeNone); 703 requestTouchEventType(TouchEventRequestTypeNone);
704 setWantsWheelEvents(false); 704 setWantsWheelEvents(false);
705 705
706 if (m_webPlugin) { 706 if (m_webPlugin) {
707 RELEASE_ASSERT(!m_webPlugin->container() || m_webPlugin->container() == this); 707 CHECK(!m_webPlugin->container() || m_webPlugin->container() == this);
708 m_webPlugin->destroy(); 708 m_webPlugin->destroy();
709 m_webPlugin = nullptr; 709 m_webPlugin = nullptr;
710 } 710 }
711 711
712 if (m_webLayer) { 712 if (m_webLayer) {
713 GraphicsLayer::unregisterContentsLayer(m_webLayer); 713 GraphicsLayer::unregisterContentsLayer(m_webLayer);
714 m_webLayer = nullptr; 714 m_webLayer = nullptr;
715 } 715 }
716 } 716 }
717 717
718 DEFINE_TRACE(WebPluginContainerImpl) 718 DEFINE_TRACE(WebPluginContainerImpl)
719 { 719 {
720 visitor->trace(m_element); 720 visitor->trace(m_element);
721 LocalFrameLifecycleObserver::trace(visitor); 721 LocalFrameLifecycleObserver::trace(visitor);
722 PluginView::trace(visitor); 722 PluginView::trace(visitor);
723 } 723 }
724 724
725 void WebPluginContainerImpl::handleMouseEvent(MouseEvent* event) 725 void WebPluginContainerImpl::handleMouseEvent(MouseEvent* event)
726 { 726 {
727 ASSERT(parent()->isFrameView()); 727 DCHECK(parent()->isFrameView());
728 728
729 // We cache the parent FrameView here as the plugin widget could be deleted 729 // We cache the parent FrameView here as the plugin widget could be deleted
730 // in the call to HandleEvent. See http://b/issue?id=1362948 730 // in the call to HandleEvent. See http://b/issue?id=1362948
731 FrameView* parentView = toFrameView(parent()); 731 FrameView* parentView = toFrameView(parent());
732 732
733 WebMouseEventBuilder webEvent(this, m_element->layoutObject(), *event); 733 WebMouseEventBuilder webEvent(this, m_element->layoutObject(), *event);
734 if (webEvent.type == WebInputEvent::Undefined) 734 if (webEvent.type == WebInputEvent::Undefined)
735 return; 735 return;
736 736
737 if (event->type() == EventTypeNames::mousedown) 737 if (event->type() == EventTypeNames::mousedown)
738 focusPlugin(); 738 focusPlugin();
739 739
740 WebCursorInfo cursorInfo; 740 WebCursorInfo cursorInfo;
741 if (m_webPlugin->handleInputEvent(webEvent, cursorInfo) != WebInputEventResu lt::NotHandled) 741 if (m_webPlugin->handleInputEvent(webEvent, cursorInfo) != WebInputEventResu lt::NotHandled)
742 event->setDefaultHandled(); 742 event->setDefaultHandled();
743 743
744 // A windowless plugin can change the cursor in response to a mouse move 744 // A windowless plugin can change the cursor in response to a mouse move
745 // event. We need to reflect the changed cursor in the frame view as the 745 // event. We need to reflect the changed cursor in the frame view as the
746 // mouse is moved in the boundaries of the windowless plugin. 746 // mouse is moved in the boundaries of the windowless plugin.
747 Page* page = parentView->frame().page(); 747 Page* page = parentView->frame().page();
748 if (!page) 748 if (!page)
749 return; 749 return;
750 toChromeClientImpl(page->chromeClient()).setCursorForPlugin(cursorInfo, pare ntView->frame().localFrameRoot()); 750 toChromeClientImpl(page->chromeClient()).setCursorForPlugin(cursorInfo, pare ntView->frame().localFrameRoot());
751 } 751 }
752 752
753 void WebPluginContainerImpl::handleDragEvent(MouseEvent* event) 753 void WebPluginContainerImpl::handleDragEvent(MouseEvent* event)
754 { 754 {
755 ASSERT(event->isDragEvent()); 755 DCHECK(event->isDragEvent());
756 756
757 WebDragStatus dragStatus = WebDragStatusUnknown; 757 WebDragStatus dragStatus = WebDragStatusUnknown;
758 if (event->type() == EventTypeNames::dragenter) 758 if (event->type() == EventTypeNames::dragenter)
759 dragStatus = WebDragStatusEnter; 759 dragStatus = WebDragStatusEnter;
760 else if (event->type() == EventTypeNames::dragleave) 760 else if (event->type() == EventTypeNames::dragleave)
761 dragStatus = WebDragStatusLeave; 761 dragStatus = WebDragStatusLeave;
762 else if (event->type() == EventTypeNames::dragover) 762 else if (event->type() == EventTypeNames::dragover)
763 dragStatus = WebDragStatusOver; 763 dragStatus = WebDragStatusOver;
764 else if (event->type() == EventTypeNames::drop) 764 else if (event->type() == EventTypeNames::drop)
765 dragStatus = WebDragStatusDrop; 765 dragStatus = WebDragStatusDrop;
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after
900 if (!layoutObject) 900 if (!layoutObject)
901 return; 901 return;
902 902
903 layoutObject->invalidatePaintRectangle(LayoutRect(m_pendingInvalidationRect) ); 903 layoutObject->invalidatePaintRectangle(LayoutRect(m_pendingInvalidationRect) );
904 m_pendingInvalidationRect = IntRect(); 904 m_pendingInvalidationRect = IntRect();
905 } 905 }
906 906
907 void WebPluginContainerImpl::computeClipRectsForPlugin( 907 void WebPluginContainerImpl::computeClipRectsForPlugin(
908 const HTMLFrameOwnerElement* ownerElement, IntRect& windowRect, IntRect& cli ppedLocalRect, IntRect& unclippedIntLocalRect) const 908 const HTMLFrameOwnerElement* ownerElement, IntRect& windowRect, IntRect& cli ppedLocalRect, IntRect& unclippedIntLocalRect) const
909 { 909 {
910 ASSERT(ownerElement); 910 DCHECK(ownerElement);
911 911
912 if (!ownerElement->layoutObject()) { 912 if (!ownerElement->layoutObject()) {
913 clippedLocalRect = IntRect(); 913 clippedLocalRect = IntRect();
914 unclippedIntLocalRect = IntRect(); 914 unclippedIntLocalRect = IntRect();
915 return; 915 return;
916 } 916 }
917 917
918 LayoutView* rootView = m_element->document().view()->layoutView(); 918 LayoutView* rootView = m_element->document().view()->layoutView();
919 while (rootView->frame()->ownerLayoutObject()) 919 while (rootView->frame()->ownerLayoutObject())
920 rootView = rootView->frame()->ownerLayoutObject()->view(); 920 rootView = rootView->frame()->ownerLayoutObject()->view();
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
959 // frame view. 959 // frame view.
960 computeClipRectsForPlugin(m_element, windowRect, clipRect, unobscuredRec t); 960 computeClipRectsForPlugin(m_element, windowRect, clipRect, unobscuredRec t);
961 } 961 }
962 getPluginOcclusions(m_element, this->parent(), frameRect(), cutOutRects); 962 getPluginOcclusions(m_element, this->parent(), frameRect(), cutOutRects);
963 // Convert to the plugin position. 963 // Convert to the plugin position.
964 for (size_t i = 0; i < cutOutRects.size(); i++) 964 for (size_t i = 0; i < cutOutRects.size(); i++)
965 cutOutRects[i].move(-frameRect().x(), -frameRect().y()); 965 cutOutRects[i].move(-frameRect().x(), -frameRect().y());
966 } 966 }
967 967
968 } // namespace blink 968 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698