summaryrefslogtreecommitdiff
path: root/chromium/third_party/WebKit/Source/web/WebPluginContainerImpl.cpp
diff options
context:
space:
mode:
authorAllan Sandfeld Jensen <allan.jensen@theqtcompany.com>2015-08-14 11:38:45 +0200
committerAllan Sandfeld Jensen <allan.jensen@theqtcompany.com>2015-08-14 17:16:47 +0000
commit3a97ca8dd9b96b599ae2d33e40df0dd2f7ea5859 (patch)
tree43cc572ba067417c7341db81f71ae7cc6e0fcc3e /chromium/third_party/WebKit/Source/web/WebPluginContainerImpl.cpp
parentf61ab1ac7f855cd281809255c0aedbb1895e1823 (diff)
downloadqtwebengine-chromium-3a97ca8dd9b96b599ae2d33e40df0dd2f7ea5859.tar.gz
BASELINE: Update chromium to 45.0.2454.40
Change-Id: Id2121d9f11a8fc633677236c65a3e41feef589e4 Reviewed-by: Andras Becsi <andras.becsi@theqtcompany.com>
Diffstat (limited to 'chromium/third_party/WebKit/Source/web/WebPluginContainerImpl.cpp')
-rw-r--r--chromium/third_party/WebKit/Source/web/WebPluginContainerImpl.cpp94
1 files changed, 20 insertions, 74 deletions
diff --git a/chromium/third_party/WebKit/Source/web/WebPluginContainerImpl.cpp b/chromium/third_party/WebKit/Source/web/WebPluginContainerImpl.cpp
index 90f6ab0f74c..053aa1c50ac 100644
--- a/chromium/third_party/WebKit/Source/web/WebPluginContainerImpl.cpp
+++ b/chromium/third_party/WebKit/Source/web/WebPluginContainerImpl.cpp
@@ -49,12 +49,11 @@
#include "core/frame/LocalFrame.h"
#include "core/html/HTMLFormElement.h"
#include "core/html/HTMLPlugInElement.h"
+#include "core/input/EventHandler.h"
#include "core/layout/HitTestResult.h"
#include "core/layout/LayoutBox.h"
#include "core/layout/LayoutPart.h"
#include "core/loader/FrameLoadRequest.h"
-#include "core/page/Chrome.h"
-#include "core/page/EventHandler.h"
#include "core/page/FocusController.h"
#include "core/page/Page.h"
#include "core/page/scrolling/ScrollingCoordinator.h"
@@ -88,14 +87,11 @@
#include "public/web/WebPrintPresetOptions.h"
#include "public/web/WebViewClient.h"
#include "web/ChromeClientImpl.h"
-#include "web/ScrollbarGroup.h"
#include "web/WebDataSourceImpl.h"
#include "web/WebInputEventConversion.h"
#include "web/WebViewImpl.h"
#include "wtf/Assertions.h"
-#include <base/debug/stack_trace.h>
-
namespace blink {
// Public methods --------------------------------------------------------------
@@ -121,10 +117,10 @@ void WebPluginContainerImpl::paint(GraphicsContext* context, const IntRect& rect
if (!frameRect().intersects(rect))
return;
- LayoutObjectDrawingRecorder drawingRecorder(*context, *m_element->layoutObject(), DisplayItem::Type::WebPlugin, rect);
- if (drawingRecorder.canUseCachedDrawing())
+ if (LayoutObjectDrawingRecorder::useCachedDrawingIfPossible(*context, *m_element->layoutObject(), DisplayItem::Type::WebPlugin))
return;
+ LayoutObjectDrawingRecorder drawingRecorder(*context, *m_element->layoutObject(), DisplayItem::Type::WebPlugin, rect);
context->save();
ASSERT(parent()->isFrameView());
@@ -138,9 +134,7 @@ void WebPluginContainerImpl::paint(GraphicsContext* context, const IntRect& rect
WebCanvas* canvas = context->canvas();
IntRect windowRect = view->contentsToRootFrame(rect);
- m_isInPaint = true;
m_webPlugin->paint(canvas, windowRect);
- m_isInPaint = false;
context->restore();
}
@@ -161,12 +155,7 @@ void WebPluginContainerImpl::invalidateRect(const IntRect& rect)
m_pendingInvalidationRect.unite(dirtyRect);
- // Check layout before setting needs layout, as this method may be called
- // while layout is in progress and we do not wish to layout again in that case.
- // TODO(schenney): Investigate how to fix this. See comment #15 and #16 on
- // https://codereview.chromium.org/1076283002/, crbug.com/476660
- if (!m_isInPaint && !layoutObject->needsLayout())
- layoutObject->setNeedsLayout("Plugin Paint Invalidation");
+ layoutObject->setMayNeedPaintInvalidation();
}
void WebPluginContainerImpl::setFocus(bool focused, WebFocusType focusType)
@@ -354,13 +343,16 @@ int WebPluginContainerImpl::printBegin(const WebPrintParams& printParams) const
return m_webPlugin->printBegin(printParams);
}
-bool WebPluginContainerImpl::printPage(int pageNumber, GraphicsContext* gc)
+void WebPluginContainerImpl::printPage(int pageNumber, GraphicsContext* gc, const IntRect& printRect)
{
+ if (LayoutObjectDrawingRecorder::useCachedDrawingIfPossible(*gc, *m_element->layoutObject(), DisplayItem::Type::WebPlugin))
+ return;
+
+ LayoutObjectDrawingRecorder drawingRecorder(*gc, *m_element->layoutObject(), DisplayItem::Type::WebPlugin, printRect);
gc->save();
WebCanvas* canvas = gc->canvas();
- bool ret = m_webPlugin->printPage(pageNumber, canvas);
+ m_webPlugin->printPage(pageNumber, canvas);
gc->restore();
- return ret;
}
void WebPluginContainerImpl::printEnd()
@@ -430,11 +422,6 @@ void WebPluginContainerImpl::reportGeometry()
calculateGeometry(windowRect, clipRect, unobscuredRect, cutOutRects);
m_webPlugin->updateGeometry(windowRect, clipRect, unobscuredRect, cutOutRects, isVisible());
-
- if (m_scrollbarGroup) {
- m_scrollbarGroup->scrollAnimator()->contentsResized();
- m_scrollbarGroup->setFrameRect(frameRect());
- }
}
void WebPluginContainerImpl::allowScriptObjects()
@@ -525,7 +512,11 @@ void WebPluginContainerImpl::zoomLevelChanged(double zoomLevel)
bool WebPluginContainerImpl::isRectTopmost(const WebRect& rect)
{
- if (!m_element)
+ // Disallow access to the frame during dispose(), because it is not guaranteed to
+ // be valid memory once this object has started disposal. In particular, we might be being
+ // disposed because the frame has already be deleted and then something else dropped the
+ // last reference to the this object.
+ if (m_inDispose || !m_element)
return false;
LocalFrame* frame = m_element->document().frame();
@@ -690,25 +681,6 @@ void WebPluginContainerImpl::willDestroyPluginLoadObserver(WebPluginLoadObserver
m_pluginLoadObservers.remove(pos);
}
-ScrollbarGroup* WebPluginContainerImpl::scrollbarGroup()
-{
- if (!m_scrollbarGroup)
- m_scrollbarGroup = adoptPtr(new ScrollbarGroup(m_element->document().frame()->view(), frameRect()));
- return m_scrollbarGroup.get();
-}
-
-void WebPluginContainerImpl::willStartLiveResize()
-{
- if (m_scrollbarGroup)
- m_scrollbarGroup->willStartLiveResize();
-}
-
-void WebPluginContainerImpl::willEndLiveResize()
-{
- if (m_scrollbarGroup)
- m_scrollbarGroup->willEndLiveResize();
-}
-
// Private methods -------------------------------------------------------------
WebPluginContainerImpl::WebPluginContainerImpl(HTMLPlugInElement* element, WebPlugin* webPlugin)
@@ -716,9 +688,9 @@ WebPluginContainerImpl::WebPluginContainerImpl(HTMLPlugInElement* element, WebPl
, m_element(element)
, m_webPlugin(webPlugin)
, m_webLayer(nullptr)
- , m_isInPaint(false)
, m_touchEventRequestType(TouchEventRequestTypeNone)
, m_wantsWheelEvents(false)
+ , m_inDispose(false)
#if ENABLE(OILPAN)
, m_shouldDisposePlugin(false)
#endif
@@ -739,11 +711,14 @@ WebPluginContainerImpl::~WebPluginContainerImpl()
void WebPluginContainerImpl::dispose()
{
+ m_inDispose = true;
+
if (m_element && m_touchEventRequestType != TouchEventRequestTypeNone && m_element->document().frameHost())
m_element->document().frameHost()->eventHandlerRegistry().didRemoveEventHandler(*m_element, EventHandlerRegistry::TouchEvent);
for (size_t i = 0; i < m_pluginLoadObservers.size(); ++i)
m_pluginLoadObservers[i]->clearPluginContainer();
+
m_webPlugin->destroy();
m_webPlugin = nullptr;
@@ -751,7 +726,6 @@ void WebPluginContainerImpl::dispose()
GraphicsLayer::unregisterContentsLayer(m_webLayer);
m_pluginLoadObservers.clear();
- m_scrollbarGroup.clear();
m_element = nullptr;
}
@@ -798,18 +772,6 @@ void WebPluginContainerImpl::handleMouseEvent(MouseEvent* event)
if (event->type() == EventTypeNames::mousedown)
focusPlugin();
- if (m_scrollbarGroup) {
- // This needs to be set before the other callbacks in this scope, since
- // the scroll animator class might query the position in response.
- m_scrollbarGroup->setLastMousePosition(IntPoint(event->x(), event->y()));
- if (event->type() == EventTypeNames::mousemove)
- m_scrollbarGroup->scrollAnimator()->mouseMovedInContentArea();
- else if (event->type() == EventTypeNames::mouseover)
- m_scrollbarGroup->scrollAnimator()->mouseEnteredContentArea();
- else if (event->type() == EventTypeNames::mouseout)
- m_scrollbarGroup->scrollAnimator()->mouseExitedContentArea();
- }
-
WebCursorInfo cursorInfo;
if (m_webPlugin->handleInputEvent(webEvent, cursorInfo))
event->setDefaultHandled();
@@ -820,7 +782,7 @@ void WebPluginContainerImpl::handleMouseEvent(MouseEvent* event)
Page* page = parentView->frame().page();
if (!page)
return;
- toChromeClientImpl(page->chrome().client()).setCursorForPlugin(cursorInfo);
+ toChromeClientImpl(page->chromeClient()).setCursorForPlugin(cursorInfo);
}
void WebPluginContainerImpl::handleDragEvent(MouseEvent* event)
@@ -928,14 +890,6 @@ void WebPluginContainerImpl::handleTouchEvent(TouchEvent* event)
}
}
-static inline bool gestureScrollHelper(ScrollbarGroup* scrollbarGroup, ScrollDirection positiveDirection, ScrollDirection negativeDirection, float delta)
-{
- if (!delta)
- return false;
- float absDelta = delta > 0 ? delta : -delta;
- return scrollbarGroup->scroll(delta < 0 ? negativeDirection : positiveDirection, ScrollByPrecisePixel, absDelta);
-}
-
void WebPluginContainerImpl::handleGestureEvent(GestureEvent* event)
{
WebGestureEventBuilder webEvent(m_element->layoutObject(), *event);
@@ -949,14 +903,6 @@ void WebPluginContainerImpl::handleGestureEvent(GestureEvent* event)
return;
}
- if (webEvent.type == WebInputEvent::GestureScrollUpdate) {
- if (!m_scrollbarGroup)
- return;
- if (gestureScrollHelper(m_scrollbarGroup.get(), ScrollLeft, ScrollRight, webEvent.data.scrollUpdate.deltaX))
- event->setDefaultHandled();
- if (gestureScrollHelper(m_scrollbarGroup.get(), ScrollUp, ScrollDown, webEvent.data.scrollUpdate.deltaY))
- event->setDefaultHandled();
- }
// FIXME: Can a plugin change the cursor from a touch-event callback?
}