https://bugs.webkit.org/show_bug.cgi?id=77383
[WebKit-https.git] / Source / WebCore / rendering / RenderEmbeddedObject.cpp
index 7fa5400..0140c1e 100644 (file)
@@ -26,6 +26,7 @@
 
 #include "Chrome.h"
 #include "ChromeClient.h"
+#include "Cursor.h"
 #include "CSSValueKeywords.h"
 #include "Font.h"
 #include "FontSelector.h"
@@ -37,6 +38,7 @@
 #include "HTMLNames.h"
 #include "HTMLObjectElement.h"
 #include "HTMLParamElement.h"
+#include "HitTestResult.h"
 #include "LocalizedStrings.h"
 #include "MIMETypeRegistry.h"
 #include "MouseEvent.h"
@@ -165,6 +167,11 @@ void RenderEmbeddedObject::paintReplaced(PaintInfo& paintInfo, const LayoutPoint
     float textWidth;
     if (!getReplacementTextGeometry(paintOffset, contentRect, path, replacementTextRect, font, run, textWidth))
         return;
+
+    if (Frame* frame = this->frame()) {
+        if (Page* page = frame->page())
+            page->addRelevantRepaintedObject(this, paintInfo.rect);
+    }
     
     GraphicsContextStateSaver stateSaver(*context);
     context->clip(contentRect);
@@ -180,7 +187,7 @@ void RenderEmbeddedObject::paintReplaced(PaintInfo& paintInfo, const LayoutPoint
     context->drawBidiText(font, run, FloatPoint(labelX, labelY));
 }
 
-bool RenderEmbeddedObject::getReplacementTextGeometry(const LayoutPoint& accumulatedOffset, FloatRect& contentRect, Path& path, FloatRect& replacementTextRect, Font& font, TextRun& run, float& textWidth)
+bool RenderEmbeddedObject::getReplacementTextGeometry(const LayoutPoint& accumulatedOffset, FloatRect& contentRect, Path& path, FloatRect& replacementTextRect, Font& font, TextRun& run, float& textWidth) const
 {
     contentRect = contentBoxRect();
     contentRect.moveBy(accumulatedOffset);
@@ -220,7 +227,7 @@ void RenderEmbeddedObject::layout()
     RenderPart::layout();
 
     m_overflow.clear();
-    addShadowOverflow();
+    addVisualEffectOverflow();
 
     updateLayerTransform();
 
@@ -248,8 +255,50 @@ void RenderEmbeddedObject::viewCleared()
             view->setMarginHeight(marginHeight);
     }
 }
-bool RenderEmbeddedObject::isInMissingPluginIndicator(MouseEvent* event)
+
+bool RenderEmbeddedObject::nodeAtPoint(const HitTestRequest& request, HitTestResult& result, const LayoutPoint& pointInContainer, const LayoutPoint& accumulatedOffset, HitTestAction hitTestAction)
+{
+    if (!RenderPart::nodeAtPoint(request, result, pointInContainer, accumulatedOffset, hitTestAction))
+        return false;
+
+    if (!widget() || !widget()->isPluginViewBase())
+        return true;
+
+    PluginViewBase* view = static_cast<PluginViewBase*>(widget());
+
+    if (Scrollbar* horizontalScrollbar = view->horizontalScrollbar()) {
+        if (horizontalScrollbar->shouldParticipateInHitTesting() && horizontalScrollbar->frameRect().contains(pointInContainer)) {
+            result.setScrollbar(horizontalScrollbar);
+            return true;
+        }
+    }
+
+    if (Scrollbar* verticalScrollbar = view->verticalScrollbar()) {
+        if (verticalScrollbar->shouldParticipateInHitTesting() && verticalScrollbar->frameRect().contains(pointInContainer)) {
+            result.setScrollbar(verticalScrollbar);
+            return true;
+        }
+    }
+
+    return true;
+}
+
+bool RenderEmbeddedObject::scroll(ScrollDirection direction, ScrollGranularity granularity, float, Node**)
+{
+    if (!widget() || !widget()->isPluginViewBase())
+        return false;
+
+    return static_cast<PluginViewBase*>(widget())->scroll(direction, granularity);
+}
+
+bool RenderEmbeddedObject::logicalScroll(ScrollLogicalDirection direction, ScrollGranularity granularity, float multiplier, Node** stopNode)
+{
+    // Plugins don't expose a writing direction, so assuming horizontal LTR.
+    return scroll(logicalToPhysical(direction, true, false), granularity, multiplier, stopNode);
+}
+
+
+bool RenderEmbeddedObject::isInMissingPluginIndicator(const LayoutPoint& point) const
 {
     FloatRect contentRect;
     Path path;
@@ -257,18 +306,25 @@ bool RenderEmbeddedObject::isInMissingPluginIndicator(MouseEvent* event)
     Font font;
     TextRun run("");
     float textWidth;
-    if (!getReplacementTextGeometry(IntPoint(), contentRect, path, replacementTextRect, font, run, textWidth))
-        return false;
-    
-    return path.contains(absoluteToLocal(event->absoluteLocation(), false, true));
+    return getReplacementTextGeometry(IntPoint(), contentRect, path, replacementTextRect, font, run, textWidth)
+        && path.contains(point);
+}
+
+bool RenderEmbeddedObject::isInMissingPluginIndicator(MouseEvent* event) const
+{
+    return isInMissingPluginIndicator(roundedLayoutPoint(absoluteToLocal(event->absoluteLocation(), false, true)));
+}
+
+static bool shouldMissingPluginMessageBeButton(Document* document)
+{
+    Page* page = document->page();
+    return page && page->chrome()->client()->shouldMissingPluginMessageBeButton();
 }
 
 void RenderEmbeddedObject::handleMissingPluginIndicatorEvent(Event* event)
 {
-    if (Page* page = document()->page()) {
-        if (!page->chrome()->client()->shouldMissingPluginMessageBeButton())
-            return;
-    }
+    if (!shouldMissingPluginMessageBeButton(document()))
+        return;
     
     if (!event->isMouseEvent())
         return;
@@ -307,4 +363,13 @@ void RenderEmbeddedObject::handleMissingPluginIndicatorEvent(Event* event)
     }
 }
 
+CursorDirective RenderEmbeddedObject::getCursor(const LayoutPoint& point, Cursor& cursor) const
+{
+    if (m_showsMissingPluginIndicator && shouldMissingPluginMessageBeButton(document()) && isInMissingPluginIndicator(point)) {
+        cursor = handCursor();
+        return SetCursor;
+    }
+    return RenderPart::getCursor(point, cursor);
+}
+
 }