Upstream version 9.38.198.0
[platform/framework/web/crosswalk.git] / src / third_party / WebKit / Source / web / ChromeClientImpl.cpp
index 771d561..6f845f5 100644 (file)
 #include "config.h"
 #include "web/ChromeClientImpl.h"
 
-#include "bindings/v8/ScriptController.h"
+#include "bindings/core/v8/ScriptController.h"
 #include "core/HTMLNames.h"
 #include "core/accessibility/AXObject.h"
 #include "core/accessibility/AXObjectCache.h"
 #include "core/dom/Document.h"
-#include "core/dom/DocumentFullscreen.h"
+#include "core/dom/FullscreenElementStack.h"
 #include "core/dom/Node.h"
 #include "core/events/KeyboardEvent.h"
 #include "core/events/MouseEvent.h"
@@ -52,6 +52,7 @@
 #include "core/page/PagePopupDriver.h"
 #include "core/page/WindowFeatures.h"
 #include "core/rendering/HitTestResult.h"
+#include "core/rendering/RenderPart.h"
 #include "core/rendering/RenderWidget.h"
 #include "platform/ColorChooser.h"
 #include "platform/ColorChooserClient.h"
 #include "wtf/text/StringConcatenate.h"
 #include "wtf/unicode/CharacterNames.h"
 
-using namespace WebCore;
-
 namespace blink {
 
-// Converts a WebCore::AXObjectCache::AXNotification to a blink::WebAXEvent
+// Converts a AXObjectCache::AXNotification to a WebAXEvent
 static WebAXEvent toWebAXEvent(AXObjectCache::AXNotification notification)
 {
     // These enums have the same values; enforced in AssertMatchingEnums.cpp.
@@ -200,19 +199,12 @@ void ChromeClientImpl::focusedNodeChanged(Node* node)
     m_webView->client()->focusedNodeChanged(WebNode(node));
 
     WebURL focusURL;
-    if (node && node->isLink()) {
-        // This HitTestResult hack is the easiest way to get a link URL out of a
-        // WebCore::Node.
-        HitTestResult hitTest(IntPoint(0, 0));
-        // This cast must be valid because of the isLink() check.
-        hitTest.setURLElement(toElement(node));
-        if (hitTest.isLiveLink())
-            focusURL = hitTest.absoluteLinkURL();
-    }
+    if (node && node->isElementNode() && toElement(node)->isLiveLink())
+        focusURL = toElement(node)->hrefURL();
     m_webView->client()->setKeyboardFocusURL(focusURL);
 }
 
-void ChromeClientImpl::focusedFrameChanged(WebCore::LocalFrame* frame)
+void ChromeClientImpl::focusedFrameChanged(LocalFrame* frame)
 {
     WebLocalFrameImpl* webframe = WebLocalFrameImpl::fromFrame(frame);
     if (webframe && webframe->client())
@@ -230,7 +222,7 @@ Page* ChromeClientImpl::createWindow(LocalFrame* frame, const FrameLoadRequest&
         policy = getNavigationPolicy();
 
     ASSERT(frame->document());
-    DocumentFullscreen::webkitCancelFullScreen(*frame->document());
+    FullscreenElementStack::from(*frame->document()).fullyExitFullscreen();
 
     WebViewImpl* newView = toWebViewImpl(
         m_webView->client()->createView(WebLocalFrameImpl::fromFrame(frame), WrappedResourceRequest(r.resourceRequest()), features, r.frameName(), policy, shouldSendReferrer == NeverSendReferrer));
@@ -364,7 +356,7 @@ void ChromeClientImpl::setResizable(bool value)
 
 bool ChromeClientImpl::shouldReportDetailedMessageForSource(const String& url)
 {
-    WebLocalFrameImpl* webframe = m_webView->mainFrameImpl();
+    WebLocalFrameImpl* webframe = m_webView->localFrameRootTemporary();
     return webframe->client() && webframe->client()->shouldReportDetailedMessageForSource(url);
 }
 
@@ -392,7 +384,7 @@ bool ChromeClientImpl::runBeforeUnloadConfirmPanel(const String& message, LocalF
     bool isReload = false;
     WebDataSource* ds = webframe->provisionalDataSource();
     if (ds)
-        isReload = (ds->navigationType() == blink::WebNavigationTypeReload);
+        isReload = (ds->navigationType() == WebNavigationTypeReload);
 
     if (webframe->client())
         return webframe->client()->runModalBeforeUnloadDialog(isReload, message);
@@ -493,19 +485,10 @@ void ChromeClientImpl::scheduleAnimation()
     m_webView->scheduleAnimation();
 }
 
-void ChromeClientImpl::scroll(
-    const IntSize& scrollDelta, const IntRect& scrollRect,
-    const IntRect& clipRect)
+void ChromeClientImpl::scroll()
 {
-    if (!m_webView->isAcceleratedCompositingActive()) {
-        if (m_webView->client()) {
-            int dx = scrollDelta.width();
-            int dy = scrollDelta.height();
-            m_webView->client()->didScrollRect(dx, dy, intersection(scrollRect, clipRect));
-        }
-    } else {
+    if (m_webView->isAcceleratedCompositingActive())
         m_webView->scrollRootLayer();
-    }
 }
 
 IntRect ChromeClientImpl::rootViewToScreen(const IntRect& rect) const
@@ -573,13 +556,8 @@ void ChromeClientImpl::mouseDidMoveOverElement(
 
 void ChromeClientImpl::setToolTip(const String& tooltipText, TextDirection dir)
 {
-    if (!m_webView->client())
-        return;
-    WebTextDirection textDirection = (dir == RTL) ?
-        WebTextDirectionRightToLeft :
-        WebTextDirectionLeftToRight;
-    m_webView->client()->setToolTipText(
-        tooltipText, textDirection);
+    if (m_webView->client())
+        m_webView->client()->setToolTipText(tooltipText, toWebTextDirection(dir));
 }
 
 void ChromeClientImpl::dispatchViewportPropertiesDidChange(const ViewportDescription& description) const
@@ -626,9 +604,8 @@ void ChromeClientImpl::runOpenPanel(LocalFrame* frame, PassRefPtr<FileChooser> f
     params.selectedFiles = fileChooser->settings().selectedFiles;
     if (params.selectedFiles.size() > 0)
         params.initialValue = params.selectedFiles[0];
-#if ENABLE(MEDIA_CAPTURE)
     params.useMediaCapture = fileChooser->settings().useMediaCapture;
-#endif
+
     WebFileChooserCompletionImpl* chooserCompletion =
         new WebFileChooserCompletionImpl(fileChooser);
 
@@ -655,7 +632,7 @@ void ChromeClientImpl::enumerateChosenDirectory(FileChooser* fileChooser)
         chooserCompletion->didChooseFile(WebVector<WebString>());
 }
 
-void ChromeClientImpl::setCursor(const WebCore::Cursor& cursor)
+void ChromeClientImpl::setCursor(const Cursor& cursor)
 {
     setCursor(WebCursorInfo(cursor));
 }
@@ -720,6 +697,11 @@ void ChromeClientImpl::exitFullScreenForElement(Element* element)
     m_webView->exitFullScreenForElement(element);
 }
 
+void ChromeClientImpl::clearCompositedSelectionBounds()
+{
+    m_webView->clearCompositedSelectionBounds();
+}
+
 bool ChromeClientImpl::hasOpenedPopup() const
 {
     return m_webView->hasOpenedPopup();
@@ -766,7 +748,7 @@ bool ChromeClientImpl::shouldRunModalDialogDuringPageDismissal(const DialogType&
     int dismissal = static_cast<int>(dismissalType) - 1; // Exclude NoDismissal.
     ASSERT_WITH_SECURITY_IMPLICATION(0 <= dismissal && dismissal < static_cast<int>(arraysize(kDismissals)));
 
-    blink::Platform::current()->histogramEnumeration("Renderer.ModalDialogsDuringPageDismissal", dismissal * arraysize(kDialogs) + dialog, arraysize(kDialogs) * arraysize(kDismissals));
+    Platform::current()->histogramEnumeration("Renderer.ModalDialogsDuringPageDismissal", dismissal * arraysize(kDialogs) + dialog, arraysize(kDialogs) * arraysize(kDismissals));
 
     String message = String("Blocked ") + kDialogs[dialog] + "('" + dialogMessage + "') during " + kDismissals[dismissal] + ".";
     m_webView->mainFrame()->addMessageToConsole(WebConsoleMessage(WebConsoleMessage::LevelError, message));
@@ -828,6 +810,12 @@ void ChromeClientImpl::didUpdateTextOfFocusedElementByNonUserInput()
         m_webView->client()->didUpdateTextOfFocusedElementByNonUserInput();
 }
 
+void ChromeClientImpl::showImeIfNeeded()
+{
+    if (m_webView->client())
+        m_webView->client()->showImeIfNeeded();
+}
+
 void ChromeClientImpl::handleKeyboardEventOnTextField(HTMLInputElement& inputElement, KeyboardEvent& event)
 {
     if (!m_webView->autofillClient())
@@ -838,25 +826,30 @@ void ChromeClientImpl::handleKeyboardEventOnTextField(HTMLInputElement& inputEle
 // FIXME: Remove this code once we have input routing in the browser
 // process. See http://crbug.com/339659.
 void ChromeClientImpl::forwardInputEvent(
-    WebCore::Frame* frame, WebCore::Event* event)
+    Frame* frame, Event* event)
 {
-    WebLocalFrameImpl* webFrame = WebLocalFrameImpl::fromFrame(toLocalFrameTemporary(frame));
+    // FIXME: Input event forwarding to out-of-process frames is broken until
+    // WebRemoteFrameImpl has a WebFrameClient.
+    if (frame->isRemoteFrame())
+        return;
+
+    WebLocalFrameImpl* webFrame = WebLocalFrameImpl::fromFrame(toLocalFrame(frame));
 
     // This is only called when we have out-of-process iframes, which
     // need to forward input events across processes.
     // FIXME: Add a check for out-of-process iframes enabled.
     if (event->isKeyboardEvent()) {
-        WebKeyboardEventBuilder webEvent(*static_cast<WebCore::KeyboardEvent*>(event));
+        WebKeyboardEventBuilder webEvent(*static_cast<KeyboardEvent*>(event));
         webFrame->client()->forwardInputEvent(&webEvent);
     } else if (event->isMouseEvent()) {
-        WebMouseEventBuilder webEvent(webFrame->frameView(), frame->ownerRenderer(), *static_cast<WebCore::MouseEvent*>(event));
+        WebMouseEventBuilder webEvent(webFrame->frameView(), frame->ownerRenderer(), *static_cast<MouseEvent*>(event));
         // Internal Blink events should not be forwarded.
         if (webEvent.type == WebInputEvent::Undefined)
             return;
 
         webFrame->client()->forwardInputEvent(&webEvent);
     } else if (event->isWheelEvent()) {
-        WebMouseWheelEventBuilder webEvent(webFrame->frameView(), frame->ownerRenderer(), *static_cast<WebCore::WheelEvent*>(event));
+        WebMouseWheelEventBuilder webEvent(webFrame->frameView(), frame->ownerRenderer(), *static_cast<WheelEvent*>(event));
         if (webEvent.type == WebInputEvent::Undefined)
             return;
         webFrame->client()->forwardInputEvent(&webEvent);
@@ -882,9 +875,4 @@ void ChromeClientImpl::openTextDataListChooser(HTMLInputElement& input)
         m_webView->autofillClient()->openTextDataListChooser(WebInputElement(&input));
 }
 
-bool ChromeClientImpl::usesGpuRasterization()
-{
-    return m_webView->layerTreeView()->usesGpuRasterization();
-}
-
 } // namespace blink