Upstream version 10.39.225.0
[platform/framework/web/crosswalk.git] / src / third_party / WebKit / Source / web / ExternalPopupMenu.cpp
index 067830e..3794402 100644 (file)
 #include "platform/text/TextDirection.h"
 #include "public/platform/WebVector.h"
 #include "public/web/WebExternalPopupMenu.h"
+#include "public/web/WebFrameClient.h"
 #include "public/web/WebMenuItemInfo.h"
 #include "public/web/WebPopupMenuInfo.h"
-#include "public/web/WebViewClient.h"
+#include "web/WebLocalFrameImpl.h"
 #include "web/WebViewImpl.h"
 
 namespace blink {
 
 ExternalPopupMenu::ExternalPopupMenu(LocalFrame& frame, PopupMenuClient* popupMenuClient, WebViewImpl& webView)
     : m_popupMenuClient(popupMenuClient)
-    , m_frameView(frame.view())
+    , m_localFrame(frame)
     , m_webView(webView)
     , m_dispatchEventTimer(this, &ExternalPopupMenu::dispatchEvent)
     , m_webExternalPopupMenu(0)
@@ -59,6 +60,12 @@ ExternalPopupMenu::~ExternalPopupMenu()
 {
 }
 
+void ExternalPopupMenu::trace(Visitor* visitor)
+{
+    visitor->trace(m_localFrame);
+    PopupMenu::trace(visitor);
+}
+
 void ExternalPopupMenu::show(const FloatQuad& controlPosition, const IntSize&, int index)
 {
     IntRect rect(controlPosition.enclosingBoundingBox());
@@ -73,9 +80,10 @@ void ExternalPopupMenu::show(const FloatQuad& controlPosition, const IntSize&, i
     getPopupMenuInfo(info, *m_popupMenuClient);
     if (info.items.isEmpty())
         return;
-    m_webExternalPopupMenu = m_webView.client()->createExternalPopupMenu(info, this);
+    WebLocalFrameImpl* webframe = WebLocalFrameImpl::fromFrame(m_localFrame.get());
+    m_webExternalPopupMenu = webframe->client()->createExternalPopupMenu(info, this);
     if (m_webExternalPopupMenu) {
-        m_webExternalPopupMenu->show(m_frameView->contentsToWindow(rect));
+        m_webExternalPopupMenu->show(m_localFrame->view()->contentsToWindow(rect));
 #if OS(MACOSX)
         const WebInputEvent* currentEvent = WebViewImpl::currentInputEvent();
         if (currentEvent && currentEvent->type == WebInputEvent::MouseDown) {
@@ -133,7 +141,7 @@ void ExternalPopupMenu::didAcceptIndex(int index)
     // derefed. This ensures it does not get deleted while we are running this
     // method.
     int popupMenuItemIndex = toPopupMenuItemIndex(index, *m_popupMenuClient);
-    RefPtr<ExternalPopupMenu> guard(this);
+    RefPtrWillBeRawPtr<ExternalPopupMenu> guard(this);
 
     if (m_popupMenuClient) {
         m_popupMenuClient->popupDidHide();
@@ -152,7 +160,7 @@ void ExternalPopupMenu::didAcceptIndices(const WebVector<int>& indices)
     // Calling methods on the PopupMenuClient might lead to this object being
     // derefed. This ensures it does not get deleted while we are running this
     // method.
-    RefPtr<ExternalPopupMenu> protect(this);
+    RefPtrWillBeRawPtr<ExternalPopupMenu> protect(this);
 
     if (!indices.size())
         m_popupMenuClient->valueChanged(static_cast<unsigned>(-1), true);
@@ -172,7 +180,7 @@ void ExternalPopupMenu::didAcceptIndices(const WebVector<int>& indices)
 void ExternalPopupMenu::didCancel()
 {
     // See comment in didAcceptIndex on why we need this.
-    RefPtr<ExternalPopupMenu> guard(this);
+    RefPtrWillBeRawPtr<ExternalPopupMenu> guard(this);
 
     if (m_popupMenuClient)
         m_popupMenuClient->popupDidHide();