summaryrefslogtreecommitdiffstats
path: root/webkit/api/src
diff options
context:
space:
mode:
Diffstat (limited to 'webkit/api/src')
-rw-r--r--webkit/api/src/BackForwardListClientImpl.cpp138
-rw-r--r--webkit/api/src/BackForwardListClientImpl.h72
-rw-r--r--webkit/api/src/ChromeClientImpl.cpp662
-rw-r--r--webkit/api/src/ChromeClientImpl.h155
-rw-r--r--webkit/api/src/DragClientImpl.cpp103
-rw-r--r--webkit/api/src/DragClientImpl.h76
-rw-r--r--webkit/api/src/InspectorClientImpl.cpp262
-rw-r--r--webkit/api/src/InspectorClientImpl.h83
-rw-r--r--webkit/api/src/WebPopupMenuImpl.cpp311
-rw-r--r--webkit/api/src/WebPopupMenuImpl.h128
10 files changed, 1990 insertions, 0 deletions
diff --git a/webkit/api/src/BackForwardListClientImpl.cpp b/webkit/api/src/BackForwardListClientImpl.cpp
new file mode 100644
index 0000000..fc6defd
--- /dev/null
+++ b/webkit/api/src/BackForwardListClientImpl.cpp
@@ -0,0 +1,138 @@
+/*
+ * Copyright (C) 2009 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ * * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "BackForwardListClientImpl.h"
+
+#include "HistoryItem.h"
+#include "WebViewClient.h"
+
+// FIXME: Remove this once WebViewImpl moves out of glue/.
+#include "webkit/glue/webview_impl.h"
+
+using namespace WebCore;
+
+namespace WebKit {
+
+const char backForwardNavigationScheme[] = "chrome-back-forward";
+
+BackForwardListClientImpl::BackForwardListClientImpl(WebViewImpl* webView)
+ : m_webView(webView)
+{
+}
+
+BackForwardListClientImpl::~BackForwardListClientImpl()
+{
+}
+
+void BackForwardListClientImpl::SetCurrentHistoryItem(HistoryItem* item)
+{
+ m_previousItem = m_currentItem;
+ m_currentItem = item;
+}
+
+HistoryItem* BackForwardListClientImpl::GetPreviousHistoryItem() const
+{
+ return m_previousItem.get();
+}
+
+void BackForwardListClientImpl::addItem(PassRefPtr<HistoryItem> item)
+{
+ m_previousItem = m_currentItem;
+ m_currentItem = item;
+
+ // If WebCore adds a new HistoryItem, it means this is a new navigation (ie,
+ // not a reload or back/forward).
+ m_webView->ObserveNewNavigation();
+
+ if (m_webView->client())
+ m_webView->client()->didAddHistoryItem();
+}
+
+void BackForwardListClientImpl::goToItem(HistoryItem* item)
+{
+ m_previousItem = m_currentItem;
+ m_currentItem = item;
+
+ if (m_pendingHistoryItem == item)
+ m_pendingHistoryItem = 0;
+}
+
+HistoryItem* BackForwardListClientImpl::currentItem()
+{
+ return m_currentItem.get();
+}
+
+HistoryItem* BackForwardListClientImpl::itemAtIndex(int index)
+{
+ if (!m_webView->client())
+ return 0;
+
+ // Since we don't keep the entire back/forward list, we have no way to
+ // properly implement this method. We return a dummy entry instead that we
+ // intercept in our FrameLoaderClient implementation in case WebCore asks
+ // to navigate to this HistoryItem.
+
+ // FIXME: We should change WebCore to handle history.{back,forward,go}
+ // differently. It should perhaps just ask the FrameLoaderClient to
+ // perform those navigations.
+
+ String url_string = String::format(
+ "%s://go/%d", backForwardNavigationScheme, index);
+
+ m_pendingHistoryItem =
+ HistoryItem::create(url_string, String(), 0.0);
+ return m_pendingHistoryItem.get();
+}
+
+int BackForwardListClientImpl::backListCount()
+{
+ if (!m_webView->client())
+ return 0;
+
+ return m_webView->client()->historyBackListCount();
+}
+
+int BackForwardListClientImpl::forwardListCount()
+{
+ if (!m_webView->client())
+ return 0;
+
+ return m_webView->client()->historyForwardListCount();
+}
+
+void BackForwardListClientImpl::close()
+{
+ m_currentItem = 0;
+ m_previousItem = 0;
+ m_pendingHistoryItem = 0;
+}
+
+} // namespace WebKit
diff --git a/webkit/api/src/BackForwardListClientImpl.h b/webkit/api/src/BackForwardListClientImpl.h
new file mode 100644
index 0000000..e498ea0
--- /dev/null
+++ b/webkit/api/src/BackForwardListClientImpl.h
@@ -0,0 +1,72 @@
+/*
+ * Copyright (C) 2009 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ * * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef BackForwardListClientImpl_h
+#define BackForwardListClientImpl_h
+
+#include "BackForwardList.h"
+
+class WebViewImpl;
+
+namespace WebKit {
+
+extern const char backForwardNavigationScheme[];
+
+class BackForwardListClientImpl : public WebCore::BackForwardListClient {
+public:
+ BackForwardListClientImpl(WebViewImpl* webview);
+ ~BackForwardListClientImpl();
+
+ void SetCurrentHistoryItem(WebCore::HistoryItem* item);
+ WebCore::HistoryItem* GetPreviousHistoryItem() const;
+
+private:
+ // WebCore::BackForwardListClient methods:
+ virtual void addItem(PassRefPtr<WebCore::HistoryItem>);
+ virtual void goToItem(WebCore::HistoryItem*);
+ virtual WebCore::HistoryItem* currentItem();
+ virtual WebCore::HistoryItem* itemAtIndex(int index);
+ virtual int backListCount();
+ virtual int forwardListCount();
+ virtual void close();
+
+ WebViewImpl* m_webView;
+
+ RefPtr<WebCore::HistoryItem> m_previousItem;
+ RefPtr<WebCore::HistoryItem> m_currentItem;
+
+ // The last history item that was accessed via itemAtIndex(). We keep track
+ // of this until goToItem() is called, so we can track the navigation.
+ RefPtr<WebCore::HistoryItem> m_pendingHistoryItem;
+};
+
+} // namespace WebKit
+
+#endif
diff --git a/webkit/api/src/ChromeClientImpl.cpp b/webkit/api/src/ChromeClientImpl.cpp
new file mode 100644
index 0000000..a81c3aa
--- /dev/null
+++ b/webkit/api/src/ChromeClientImpl.cpp
@@ -0,0 +1,662 @@
+/*
+ * Copyright (C) 2009 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ * * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "ChromeClientImpl.h"
+
+#include "AccessibilityObject.h"
+#include "AXObjectCache.h"
+#include "CharacterNames.h"
+#include "Console.h"
+#include "Cursor.h"
+#include "Document.h"
+#include "DocumentLoader.h"
+#include "DatabaseTracker.h"
+#include "FloatRect.h"
+#include "FileChooser.h"
+#include "FrameLoadRequest.h"
+#include "FrameView.h"
+#include "HitTestResult.h"
+#include "IntRect.h"
+#include "Node.h"
+#include "NotificationPresenterImpl.h"
+#include "Page.h"
+#include "PopupMenuChromium.h"
+#include "ScriptController.h"
+#if USE(V8)
+#include "V8Proxy.h"
+#endif
+#include "WebAccessibilityObject.h"
+#include "WebConsoleMessage.h"
+#include "WebCursorInfo.h"
+#include "WebFileChooserCompletion.h"
+#include "WebFrameClient.h"
+#include "WebInputEvent.h"
+#include "WebKit.h"
+#include "WebPopupMenuInfo.h"
+#include "WebRect.h"
+#include "WebTextDirection.h"
+#include "WebURLRequest.h"
+#include "WebViewClient.h"
+#include "WebFileChooserCompletionImpl.h"
+#include "WebPopupMenuImpl.h"
+#include "WindowFeatures.h"
+#include "WrappedResourceRequest.h"
+
+// FIXME: Remove these once they move out of glue/.
+#include "webkit/glue/webframe_impl.h"
+#include "webkit/glue/webview_impl.h"
+
+using namespace WebCore;
+
+namespace WebKit {
+
+ChromeClientImpl::ChromeClientImpl(WebViewImpl* webView)
+ : m_webView(webView)
+ , m_toolbarsVisible(true)
+ , m_statusbarVisible(true)
+ , m_scrollbarsVisible(true)
+ , m_menubarVisible(true)
+ , m_resizable(true)
+ , m_ignoreNextSetCursor(false)
+{
+}
+
+ChromeClientImpl::~ChromeClientImpl()
+{
+}
+
+void ChromeClientImpl::chromeDestroyed()
+{
+ // Our lifetime is bound to the WebViewImpl.
+}
+
+void ChromeClientImpl::setWindowRect(const FloatRect& r)
+{
+ if (m_webView->client())
+ m_webView->client()->setWindowRect(IntRect(r));
+}
+
+FloatRect ChromeClientImpl::windowRect()
+{
+ WebRect rect;
+ if (m_webView->client())
+ rect = m_webView->client()->rootWindowRect();
+ else {
+ // These numbers will be fairly wrong. The window's x/y coordinates will
+ // be the top left corner of the screen and the size will be the content
+ // size instead of the window size.
+ rect.width = m_webView->size().width;
+ rect.height = m_webView->size().height;
+ }
+ return FloatRect(rect);
+}
+
+FloatRect ChromeClientImpl::pageRect()
+{
+ // We hide the details of the window's border thickness from the web page by
+ // simple re-using the window position here. So, from the point-of-view of
+ // the web page, the window has no border.
+ return windowRect();
+}
+
+float ChromeClientImpl::scaleFactor()
+{
+ // This is supposed to return the scale factor of the web page. It looks like
+ // the implementor of the graphics layer is responsible for doing most of the
+ // operations associated with scaling. However, this value is used ins some
+ // cases by WebCore. For example, this is used as a scaling factor in canvas
+ // so that things drawn in it are scaled just like the web page is.
+ //
+ // We don't currently implement scaling, so just return 1.0 (no scaling).
+ return 1.0;
+}
+
+void ChromeClientImpl::focus()
+{
+ if (!m_webView->client())
+ return;
+
+ m_webView->client()->didFocus();
+
+ // If accessibility is enabled, we should notify assistive technology that
+ // the active AccessibilityObject changed.
+ const Frame* frame = m_webView->GetFocusedWebCoreFrame();
+ if (!frame)
+ return;
+
+ Document* doc = frame->document();
+
+ if (doc && doc->axObjectCache()->accessibilityEnabled()) {
+ Node* focusedNode = m_webView->GetFocusedNode();
+
+ if (!focusedNode) {
+ // Could not retrieve focused Node.
+ return;
+ }
+
+ // Retrieve the focused AccessibilityObject.
+ AccessibilityObject* focusedAccObj =
+ doc->axObjectCache()->getOrCreate(focusedNode->renderer());
+
+ // Alert assistive technology that focus changed.
+ if (focusedAccObj)
+ m_webView->client()->focusAccessibilityObject(WebAccessibilityObject(focusedAccObj));
+ }
+}
+
+void ChromeClientImpl::unfocus()
+{
+ if (m_webView->client())
+ m_webView->client()->didBlur();
+}
+
+bool ChromeClientImpl::canTakeFocus(FocusDirection)
+{
+ // For now the browser can always take focus if we're not running layout
+ // tests.
+ return !layoutTestMode();
+}
+
+void ChromeClientImpl::takeFocus(FocusDirection direction)
+{
+ if (!m_webView->client())
+ return;
+ if (direction == FocusDirectionBackward)
+ m_webView->client()->focusPrevious();
+ else
+ m_webView->client()->focusNext();
+}
+
+Page* ChromeClientImpl::createWindow(
+ Frame* frame, const FrameLoadRequest& r, const WindowFeatures& features)
+{
+ if (!m_webView->client())
+ return 0;
+
+ WebViewImpl* newView = static_cast<WebViewImpl*>(
+ m_webView->client()->createView(WebFrameImpl::FromFrame(frame)));
+ if (!newView)
+ return 0;
+
+ // The request is empty when we are just being asked to open a blank window.
+ // This corresponds to window.open(""), for example.
+ if (!r.resourceRequest().isEmpty()) {
+ WrappedResourceRequest request(r.resourceRequest());
+ newView->main_frame()->loadRequest(request);
+ }
+
+ return newView->page();
+}
+
+static inline bool CurrentEventShouldCauseBackgroundTab(const WebInputEvent* inputEvent)
+{
+ if (!inputEvent)
+ return false;
+
+ if (inputEvent->type != WebInputEvent::MouseUp)
+ return false;
+
+ const WebMouseEvent* mouseEvent = static_cast<const WebMouseEvent*>(inputEvent);
+
+ WebNavigationPolicy policy;
+ unsigned short buttonNumber;
+ switch (mouseEvent->button) {
+ case WebMouseEvent::ButtonLeft:
+ buttonNumber = 0;
+ break;
+ case WebMouseEvent::ButtonMiddle:
+ buttonNumber = 1;
+ break;
+ case WebMouseEvent::ButtonRight:
+ buttonNumber = 2;
+ break;
+ default:
+ return false;
+ }
+ bool ctrl = mouseEvent->modifiers & WebMouseEvent::ControlKey;
+ bool shift = mouseEvent->modifiers & WebMouseEvent::ShiftKey;
+ bool alt = mouseEvent->modifiers & WebMouseEvent::AltKey;
+ bool meta = mouseEvent->modifiers & WebMouseEvent::MetaKey;
+
+ if (!WebViewImpl::NavigationPolicyFromMouseEvent(buttonNumber, ctrl, shift, alt, meta, &policy))
+ return false;
+
+ return policy == WebNavigationPolicyNewBackgroundTab;
+}
+
+void ChromeClientImpl::show()
+{
+ if (!m_webView->client())
+ return;
+
+ // If our default configuration was modified by a script or wasn't
+ // created by a user gesture, then show as a popup. Else, let this
+ // new window be opened as a toplevel window.
+ bool asPopup =
+ !m_toolbarsVisible ||
+ !m_statusbarVisible ||
+ !m_scrollbarsVisible ||
+ !m_menubarVisible ||
+ !m_resizable;
+
+ WebNavigationPolicy policy = WebNavigationPolicyNewForegroundTab;
+ if (asPopup)
+ policy = WebNavigationPolicyNewPopup;
+ if (CurrentEventShouldCauseBackgroundTab(WebViewImpl::current_input_event()))
+ policy = WebNavigationPolicyNewBackgroundTab;
+
+ m_webView->client()->show(policy);
+}
+
+bool ChromeClientImpl::canRunModal()
+{
+ return m_webView->client() != 0;
+}
+
+void ChromeClientImpl::runModal()
+{
+ if (m_webView->client())
+ m_webView->client()->runModal();
+}
+
+void ChromeClientImpl::setToolbarsVisible(bool value)
+{
+ m_toolbarsVisible = value;
+}
+
+bool ChromeClientImpl::toolbarsVisible()
+{
+ return m_toolbarsVisible;
+}
+
+void ChromeClientImpl::setStatusbarVisible(bool value)
+{
+ m_statusbarVisible = value;
+}
+
+bool ChromeClientImpl::statusbarVisible()
+{
+ return m_statusbarVisible;
+}
+
+void ChromeClientImpl::setScrollbarsVisible(bool value)
+{
+ m_scrollbarsVisible = value;
+ WebFrameImpl* web_frame = static_cast<WebFrameImpl*>(m_webView->mainFrame());
+ if (web_frame)
+ web_frame->SetAllowsScrolling(value);
+}
+
+bool ChromeClientImpl::scrollbarsVisible()
+{
+ return m_scrollbarsVisible;
+}
+
+void ChromeClientImpl::setMenubarVisible(bool value)
+{
+ m_menubarVisible = value;
+}
+
+bool ChromeClientImpl::menubarVisible()
+{
+ return m_menubarVisible;
+}
+
+void ChromeClientImpl::setResizable(bool value)
+{
+ m_resizable = value;
+}
+
+void ChromeClientImpl::addMessageToConsole(MessageSource source,
+ MessageType type,
+ MessageLevel level,
+ const String& message,
+ unsigned lineNumber,
+ const String& sourceID)
+{
+ if (m_webView->client()) {
+ m_webView->client()->didAddMessageToConsole(
+ WebConsoleMessage(static_cast<WebConsoleMessage::Level>(level), message),
+ sourceID,
+ lineNumber);
+ }
+}
+
+bool ChromeClientImpl::canRunBeforeUnloadConfirmPanel()
+{
+ return m_webView->client() != 0;
+}
+
+bool ChromeClientImpl::runBeforeUnloadConfirmPanel(const String& message, Frame* frame)
+{
+ if (m_webView->client()) {
+ return m_webView->client()->runModalBeforeUnloadDialog(
+ WebFrameImpl::FromFrame(frame), message);
+ }
+ return false;
+}
+
+void ChromeClientImpl::closeWindowSoon()
+{
+ // Make sure this Page can no longer be found by JS.
+ m_webView->page()->setGroupName(String());
+
+ // Make sure that all loading is stopped. Ensures that JS stops executing!
+ m_webView->mainFrame()->stopLoading();
+
+ if (m_webView->client())
+ m_webView->client()->closeWidgetSoon();
+}
+
+// Although a Frame is passed in, we don't actually use it, since we
+// already know our own m_webView.
+void ChromeClientImpl::runJavaScriptAlert(Frame* frame, const String& message)
+{
+ if (m_webView->client()) {
+#if USE(V8)
+ // Before showing the JavaScript dialog, we give the proxy implementation
+ // a chance to process any pending console messages.
+ V8Proxy::processConsoleMessages();
+#endif
+ m_webView->client()->runModalAlertDialog(
+ WebFrameImpl::FromFrame(frame), message);
+ }
+}
+
+// See comments for runJavaScriptAlert().
+bool ChromeClientImpl::runJavaScriptConfirm(Frame* frame, const String& message)
+{
+ if (m_webView->client()) {
+ return m_webView->client()->runModalConfirmDialog(
+ WebFrameImpl::FromFrame(frame), message);
+ }
+ return false;
+}
+
+// See comments for runJavaScriptAlert().
+bool ChromeClientImpl::runJavaScriptPrompt(Frame* frame,
+ const String& message,
+ const String& defaultValue,
+ String& result)
+{
+ if (m_webView->client()) {
+ WebString actualValue;
+ bool ok = m_webView->client()->runModalPromptDialog(
+ WebFrameImpl::FromFrame(frame),
+ message,
+ defaultValue,
+ &actualValue);
+ if (ok)
+ result = actualValue;
+ return ok;
+ }
+ return false;
+}
+
+void ChromeClientImpl::setStatusbarText(const String& message)
+{
+ if (m_webView->client())
+ m_webView->client()->setStatusText(message);
+}
+
+bool ChromeClientImpl::shouldInterruptJavaScript()
+{
+ // FIXME: implement me
+ return false;
+}
+
+bool ChromeClientImpl::tabsToLinks() const
+{
+ // Returns true if anchors should accept keyboard focus with the tab key.
+ // This method is used in a convoluted fashion by EventHandler::tabsToLinks.
+ // It's a twisted path (self-evident, but more complicated than seems
+ // necessary), but the net result is that returning true from here, on a
+ // platform other than MAC or QT, lets anchors get keyboard focus.
+ return m_webView->tabsToLinks();
+}
+
+IntRect ChromeClientImpl::windowResizerRect() const
+{
+ IntRect result;
+ if (m_webView->client())
+ result = m_webView->client()->windowResizerRect();
+ return result;
+}
+
+void ChromeClientImpl::repaint(
+ const IntRect& paintRect, bool contentChanged, bool immediate,
+ bool repaintContentOnly)
+{
+ // Ignore spurious calls.
+ if (!contentChanged || paintRect.isEmpty())
+ return;
+ if (m_webView->client())
+ m_webView->client()->didInvalidateRect(paintRect);
+}
+
+void ChromeClientImpl::scroll(
+ const IntSize& scrollDelta, const IntRect& scrollRect,
+ const IntRect& clipRect)
+{
+ if (m_webView->client()) {
+ int dx = scrollDelta.width();
+ int dy = scrollDelta.height();
+ m_webView->client()->didScrollRect(dx, dy, clipRect);
+ }
+}
+
+IntPoint ChromeClientImpl::screenToWindow(const IntPoint&) const
+{
+ notImplemented();
+ return IntPoint();
+}
+
+IntRect ChromeClientImpl::windowToScreen(const IntRect& rect) const {
+ IntRect screenRect(rect);
+
+ if (m_webView->client()) {
+ WebRect windowRect = m_webView->client()->windowRect();
+ screenRect.move(windowRect.x, windowRect.y);
+ }
+
+ return screenRect;
+}
+
+void ChromeClientImpl::contentsSizeChanged(Frame* frame, const IntSize& size) const
+{
+ WebFrameImpl* webframe = WebFrameImpl::FromFrame(frame);
+ if (webframe->client())
+ webframe->client()->didChangeContentsSize(webframe, size);
+}
+
+void ChromeClientImpl::scrollbarsModeDidChange() const
+{
+}
+
+void ChromeClientImpl::mouseDidMoveOverElement(
+ const HitTestResult& result, unsigned modifierFlags)
+{
+ if (!m_webView->client())
+ return;
+ // Find out if the mouse is over a link, and if so, let our UI know...
+ if (result.isLiveLink() && !result.absoluteLinkURL().string().isEmpty())
+ m_webView->client()->setMouseOverURL(result.absoluteLinkURL());
+ else
+ m_webView->client()->setMouseOverURL(WebURL());
+}
+
+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);
+}
+
+void ChromeClientImpl::print(Frame* frame)
+{
+ if (m_webView->client())
+ m_webView->client()->printPage(WebFrameImpl::FromFrame(frame));
+}
+
+void ChromeClientImpl::exceededDatabaseQuota(Frame* frame, const String& databaseName)
+{
+ // set a reasonable quota for now -- 5Mb should be enough for anybody
+ // TODO(dglazkov): this should be configurable
+ SecurityOrigin* origin = frame->document()->securityOrigin();
+ DatabaseTracker::tracker().setQuota(origin, 1024 * 1024 * 5);
+}
+
+#if ENABLE(OFFLINE_WEB_APPLICATIONS)
+void ChromeClientImpl::reachedMaxAppCacheSize(int64_t spaceNeeded)
+{
+ ASSERT_NOT_REACHED();
+}
+#endif
+
+void ChromeClientImpl::runOpenPanel(Frame* frame, PassRefPtr<FileChooser> fileChooser)
+{
+ WebViewClient* client = m_webView->client();
+ if (!client)
+ return;
+
+ bool multipleFiles = fileChooser->allowsMultipleFiles();
+
+ WebString suggestion;
+ if (fileChooser->filenames().size() > 0)
+ suggestion = fileChooser->filenames()[0];
+
+ WebFileChooserCompletionImpl* chooserCompletion =
+ new WebFileChooserCompletionImpl(fileChooser);
+ bool ok = client->runFileChooser(multipleFiles,
+ WebString(),
+ suggestion,
+ chooserCompletion);
+ if (!ok) {
+ // Choosing failed, so do callback with an empty list.
+ chooserCompletion->didChooseFile(WebVector<WebString>());
+ }
+}
+
+void ChromeClientImpl::popupOpened(PopupContainer* popupContainer,
+ const IntRect& bounds,
+ bool activatable,
+ bool handleExternally)
+{
+ if (!m_webView->client())
+ return;
+
+ WebWidget* webwidget;
+ if (handleExternally) {
+ WebPopupMenuInfo popupInfo;
+ getPopupMenuInfo(popupContainer, &popupInfo);
+ webwidget = m_webView->client()->createPopupMenu(popupInfo);
+ } else
+ webwidget = m_webView->client()->createPopupMenu(activatable);
+
+ static_cast<WebPopupMenuImpl*>(webwidget)->Init(popupContainer, bounds);
+}
+
+void ChromeClientImpl::setCursor(const WebCursorInfo& cursor)
+{
+ if (m_ignoreNextSetCursor) {
+ m_ignoreNextSetCursor = false;
+ return;
+ }
+
+ if (m_webView->client())
+ m_webView->client()->didChangeCursor(cursor);
+}
+
+void ChromeClientImpl::setCursorForPlugin(const WebCursorInfo& cursor)
+{
+ setCursor(cursor);
+
+ // Currently, Widget::setCursor is always called after this function in
+ // EventHandler.cpp and since we don't want that we set a flag indicating
+ // that the next SetCursor call is to be ignored.
+ m_ignoreNextSetCursor = true;
+}
+
+void ChromeClientImpl::formStateDidChange(const Node* node)
+{
+ // The current history item is not updated yet. That happens lazily when
+ // WebFrame::currentHistoryItem is requested.
+ WebFrameImpl* webframe = WebFrameImpl::FromFrame(node->document()->frame());
+ if (webframe->client())
+ webframe->client()->didUpdateCurrentHistoryItem(webframe);
+}
+
+void ChromeClientImpl::getPopupMenuInfo(PopupContainer* popupContainer,
+ WebPopupMenuInfo* info)
+{
+ const Vector<PopupItem*>& inputItems = popupContainer->popupData();
+
+ WebVector<WebPopupMenuInfo::Item> outputItems(inputItems.size());
+
+ for (size_t i = 0; i < inputItems.size(); ++i) {
+ const PopupItem& inputItem = *inputItems[i];
+ WebPopupMenuInfo::Item& outputItem = outputItems[i];
+
+ outputItem.label = inputItem.label;
+ outputItem.enabled = inputItem.enabled;
+
+ switch (inputItem.type) {
+ case PopupItem::TypeOption:
+ outputItem.type = WebPopupMenuInfo::Item::Option;
+ break;
+ case PopupItem::TypeGroup:
+ outputItem.type = WebPopupMenuInfo::Item::Group;
+ break;
+ case PopupItem::TypeSeparator:
+ outputItem.type = WebPopupMenuInfo::Item::Separator;
+ break;
+ default:
+ ASSERT_NOT_REACHED();
+ }
+ }
+
+ info->itemHeight = popupContainer->menuItemHeight();
+ info->selectedIndex = popupContainer->selectedIndex();
+ info->items.swap(outputItems);
+}
+
+#if ENABLE(NOTIFICATIONS)
+NotificationPresenter* ChromeClientImpl::notificationPresenter() const
+{
+ return m_webView->GetNotificationPresenter();
+}
+#endif
+
+} // namespace WebKit
diff --git a/webkit/api/src/ChromeClientImpl.h b/webkit/api/src/ChromeClientImpl.h
new file mode 100644
index 0000000..427390a
--- /dev/null
+++ b/webkit/api/src/ChromeClientImpl.h
@@ -0,0 +1,155 @@
+/*
+ * Copyright (C) 2009 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ * * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef ChromeClientImpl_h
+#define ChromeClientImpl_h
+
+#include "ChromeClientChromium.h"
+
+class WebViewImpl;
+
+namespace WebCore {
+class HTMLParserQuirks;
+class PopupContainer;
+class SecurityOrigin;
+struct WindowFeatures;
+}
+
+namespace WebKit {
+struct WebCursorInfo;
+struct WebPopupMenuInfo;
+
+// Handles window-level notifications from WebCore on behalf of a WebView.
+class ChromeClientImpl : public WebCore::ChromeClientChromium {
+public:
+ explicit ChromeClientImpl(WebViewImpl* webView);
+ virtual ~ChromeClientImpl();
+
+ WebViewImpl* webview() const { return m_webView; }
+
+ // ChromeClient methods:
+ virtual void chromeDestroyed();
+ virtual void setWindowRect(const WebCore::FloatRect&);
+ virtual WebCore::FloatRect windowRect();
+ virtual WebCore::FloatRect pageRect();
+ virtual float scaleFactor();
+ virtual void focus();
+ virtual void unfocus();
+ virtual bool canTakeFocus(WebCore::FocusDirection);
+ virtual void takeFocus(WebCore::FocusDirection);
+ virtual WebCore::Page* createWindow(
+ WebCore::Frame*, const WebCore::FrameLoadRequest&, const WebCore::WindowFeatures&);
+ virtual void show();
+ virtual bool canRunModal();
+ virtual void runModal();
+ virtual void setToolbarsVisible(bool);
+ virtual bool toolbarsVisible();
+ virtual void setStatusbarVisible(bool);
+ virtual bool statusbarVisible();
+ virtual void setScrollbarsVisible(bool);
+ virtual bool scrollbarsVisible();
+ virtual void setMenubarVisible(bool);
+ virtual bool menubarVisible();
+ virtual void setResizable(bool);
+ virtual void addMessageToConsole(
+ WebCore::MessageSource, WebCore::MessageType, WebCore::MessageLevel,
+ const WebCore::String& message, unsigned lineNumber,
+ const WebCore::String& sourceID);
+ virtual bool canRunBeforeUnloadConfirmPanel();
+ virtual bool runBeforeUnloadConfirmPanel(
+ const WebCore::String& message, WebCore::Frame*);
+ virtual void closeWindowSoon();
+ virtual void runJavaScriptAlert(WebCore::Frame*, const WebCore::String&);
+ virtual bool runJavaScriptConfirm(WebCore::Frame*, const WebCore::String&);
+ virtual bool runJavaScriptPrompt(
+ WebCore::Frame*, const WebCore::String& message,
+ const WebCore::String& defaultValue, WebCore::String& result);
+ virtual void setStatusbarText(const WebCore::String& message);
+ virtual bool shouldInterruptJavaScript();
+ virtual bool tabsToLinks() const;
+ virtual WebCore::IntRect windowResizerRect() const;
+ virtual void repaint(
+ const WebCore::IntRect&, bool contentChanged, bool immediate = false,
+ bool repaintContentOnly = false);
+ virtual void scroll(
+ const WebCore::IntSize& scrollDelta, const WebCore::IntRect& rectToScroll,
+ const WebCore::IntRect& clipRect);
+ virtual WebCore::IntPoint screenToWindow(const WebCore::IntPoint&) const;
+ virtual WebCore::IntRect windowToScreen(const WebCore::IntRect&) const;
+ virtual PlatformPageClient platformPageClient() const { return 0; }
+ virtual void contentsSizeChanged(WebCore::Frame*, const WebCore::IntSize&) const;
+ virtual void scrollRectIntoView(
+ const WebCore::IntRect&, const WebCore::ScrollView*) const { }
+ virtual void scrollbarsModeDidChange() const;
+ virtual void mouseDidMoveOverElement(
+ const WebCore::HitTestResult& result, unsigned modifierFlags);
+ virtual void setToolTip(const WebCore::String& tooltipText, WebCore::TextDirection);
+ virtual void print(WebCore::Frame*);
+ virtual void exceededDatabaseQuota(
+ WebCore::Frame*, const WebCore::String& databaseName);
+#if ENABLE(OFFLINE_WEB_APPLICATIONS)
+ virtual void reachedMaxAppCacheSize(int64_t spaceNeeded);
+#endif
+#if ENABLE(NOTIFICATIONS)
+ virtual WebCore::NotificationPresenter* notificationPresenter() const;
+#endif
+ virtual void requestGeolocationPermissionForFrame(
+ WebCore::Frame*, WebCore::Geolocation*) { }
+ virtual void runOpenPanel(WebCore::Frame*, PassRefPtr<WebCore::FileChooser>);
+ virtual bool setCursor(WebCore::PlatformCursorHandle) { return false; }
+ virtual void formStateDidChange(const WebCore::Node*);
+ virtual PassOwnPtr<WebCore::HTMLParserQuirks> createHTMLParserQuirks() { return 0; }
+
+ // ChromeClientChromium methods:
+ virtual void popupOpened(WebCore::PopupContainer* popupContainer,
+ const WebCore::IntRect& bounds,
+ bool activatable,
+ bool handleExternally);
+
+ // ChromeClientImpl:
+ void setCursor(const WebCursorInfo& cursor);
+ void setCursorForPlugin(const WebCursorInfo& cursor);
+
+private:
+ void getPopupMenuInfo(WebCore::PopupContainer*, WebPopupMenuInfo*);
+
+ WebViewImpl* m_webView; // weak pointer
+ bool m_toolbarsVisible;
+ bool m_statusbarVisible;
+ bool m_scrollbarsVisible;
+ bool m_menubarVisible;
+ bool m_resizable;
+ // Set to true if the next SetCursor is to be ignored.
+ bool m_ignoreNextSetCursor;
+};
+
+} // namespace WebKit
+
+#endif
diff --git a/webkit/api/src/DragClientImpl.cpp b/webkit/api/src/DragClientImpl.cpp
new file mode 100644
index 0000000..77c5ad8
--- /dev/null
+++ b/webkit/api/src/DragClientImpl.cpp
@@ -0,0 +1,103 @@
+/*
+ * Copyright (C) 2009 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ * * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "DragClientImpl.h"
+
+#include "ChromiumDataObject.h"
+#include "ClipboardChromium.h"
+#include "Frame.h"
+#include "WebDragData.h"
+#include "WebViewClient.h"
+
+// FIXME: Remove this once WebViewImpl moves out of glue/.
+#include "webkit/glue/webview_impl.h"
+
+using namespace WebCore;
+
+namespace WebKit {
+
+void DragClientImpl::willPerformDragDestinationAction(DragDestinationAction, DragData*)
+{
+ // FIXME
+}
+
+void DragClientImpl::willPerformDragSourceAction(DragSourceAction, const IntPoint&, Clipboard*)
+{
+ // FIXME
+}
+
+DragDestinationAction DragClientImpl::actionMaskForDrag(DragData*)
+{
+ if (m_webView->client() && m_webView->client()->acceptsLoadDrops())
+ return DragDestinationActionAny;
+
+ return static_cast<DragDestinationAction>(
+ DragDestinationActionDHTML | DragDestinationActionEdit);
+}
+
+DragSourceAction DragClientImpl::dragSourceActionMaskForPoint(const IntPoint& windowPoint)
+{
+ // We want to handle drag operations for all source types.
+ return DragSourceActionAny;
+}
+
+void DragClientImpl::startDrag(DragImageRef dragImage,
+ const IntPoint& dragImageOrigin,
+ const IntPoint& eventPos,
+ Clipboard* clipboard,
+ Frame* frame,
+ bool isLinkDrag)
+{
+ // Add a ref to the frame just in case a load occurs mid-drag.
+ RefPtr<Frame> frameProtector = frame;
+
+ WebDragData dragData = static_cast<ClipboardChromium*>(clipboard)->dataObject();
+
+ DragOperation dragOperationMask;
+ if (!clipboard->sourceOperation(dragOperationMask))
+ dragOperationMask = DragOperationEvery;
+
+ m_webView->StartDragging(
+ eventPos, dragData, static_cast<WebDragOperationsMask>(dragOperationMask));
+}
+
+DragImageRef DragClientImpl::createDragImageForLink(KURL&, const String& label, Frame*)
+{
+ // FIXME
+ return 0;
+}
+
+void DragClientImpl::dragControllerDestroyed()
+{
+ // Our lifetime is bound to the WebViewImpl.
+}
+
+} // namespace WebKit
diff --git a/webkit/api/src/DragClientImpl.h b/webkit/api/src/DragClientImpl.h
new file mode 100644
index 0000000..6eea773
--- /dev/null
+++ b/webkit/api/src/DragClientImpl.h
@@ -0,0 +1,76 @@
+/*
+ * Copyright (C) 2009 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ * * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef DragClientImpl_h
+#define DragClientImpl_h
+
+#include "DragClient.h"
+#include "DragActions.h"
+
+namespace WebCore {
+class ClipBoard;
+class DragData;
+class IntPoint;
+class KURL;
+}
+
+class WebViewImpl;
+
+namespace WebKit {
+
+class DragClientImpl : public WebCore::DragClient {
+public:
+ DragClientImpl(WebViewImpl* webView) : m_webView(webView) { }
+
+ virtual void willPerformDragDestinationAction(
+ WebCore::DragDestinationAction, WebCore::DragData*);
+ virtual void willPerformDragSourceAction(
+ WebCore::DragSourceAction, const WebCore::IntPoint&, WebCore::Clipboard*);
+ virtual WebCore::DragDestinationAction actionMaskForDrag(WebCore::DragData*);
+ virtual WebCore::DragSourceAction dragSourceActionMaskForPoint(
+ const WebCore::IntPoint& windowPoint);
+ virtual void startDrag(
+ WebCore::DragImageRef dragImage,
+ const WebCore::IntPoint& dragImageOrigin,
+ const WebCore::IntPoint& eventPos,
+ WebCore::Clipboard* clipboard,
+ WebCore::Frame* frame,
+ bool isLinkDrag = false);
+ virtual WebCore::DragImageRef createDragImageForLink(
+ WebCore::KURL&, const WebCore::String& label, WebCore::Frame*);
+ virtual void dragControllerDestroyed();
+
+private:
+ WebViewImpl* m_webView;
+};
+
+} // namespace WebKit
+
+#endif
diff --git a/webkit/api/src/InspectorClientImpl.cpp b/webkit/api/src/InspectorClientImpl.cpp
new file mode 100644
index 0000000..2dd3b7c
--- /dev/null
+++ b/webkit/api/src/InspectorClientImpl.cpp
@@ -0,0 +1,262 @@
+/*
+ * Copyright (C) 2009 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ * * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "InspectorClientImpl.h"
+
+#include "DOMWindow.h"
+#include "FloatRect.h"
+#include "InspectorController.h"
+#include "Page.h"
+#include "Settings.h"
+#include "WebRect.h"
+#include "WebURL.h"
+#include "WebURLRequest.h"
+#include "WebViewClient.h"
+#include <wtf/Vector.h>
+
+// FIXME: Remove this once WebDevToolsAgentImpl and WebViewImpl move out of glue/.
+#include "webkit/glue/webdevtoolsagent_impl.h"
+#include "webkit/glue/webview_impl.h"
+
+using namespace WebCore;
+
+namespace WebKit {
+
+InspectorClientImpl::InspectorClientImpl(WebViewImpl* webView)
+ : m_inspectedWebView(webView)
+{
+ ASSERT(m_inspectedWebView);
+}
+
+InspectorClientImpl::~InspectorClientImpl()
+{
+}
+
+void InspectorClientImpl::inspectorDestroyed()
+{
+ // Our lifetime is bound to the WebViewImpl.
+}
+
+Page* InspectorClientImpl::createPage()
+{
+ // This method should never be called in Chrome as inspector front-end lives
+ // in a separate process.
+ ASSERT_NOT_REACHED();
+ return 0;
+}
+
+void InspectorClientImpl::showWindow()
+{
+ ASSERT(m_inspectedWebView->GetWebDevToolsAgentImpl());
+ m_inspectedWebView->page()->inspectorController()->setWindowVisible(true);
+}
+
+void InspectorClientImpl::closeWindow()
+{
+ if (m_inspectedWebView->page())
+ m_inspectedWebView->page()->inspectorController()->setWindowVisible(false);
+}
+
+bool InspectorClientImpl::windowVisible()
+{
+ ASSERT(m_inspectedWebView->GetWebDevToolsAgentImpl());
+ return false;
+}
+
+void InspectorClientImpl::attachWindow()
+{
+ // FIXME: Implement this
+}
+
+void InspectorClientImpl::detachWindow()
+{
+ // FIXME: Implement this
+}
+
+void InspectorClientImpl::setAttachedWindowHeight(unsigned int height)
+{
+ // FIXME: Implement this
+ notImplemented();
+}
+
+static void invalidateNodeBoundingRect(WebViewImpl* webView)
+{
+ // FIXME: Is it important to just invalidate the rect of the node region
+ // given that this is not on a critical codepath? In order to do so, we'd
+ // have to take scrolling into account.
+ const WebSize& size = webView->size();
+ WebRect damagedRect(0, 0, size.width, size.height);
+ if (webView->client())
+ webView->client()->didInvalidateRect(damagedRect);
+}
+
+void InspectorClientImpl::highlight(Node* node)
+{
+ // InspectorController does the actually tracking of the highlighted node
+ // and the drawing of the highlight. Here we just make sure to invalidate
+ // the rects of the old and new nodes.
+ hideHighlight();
+}
+
+void InspectorClientImpl::hideHighlight()
+{
+ // FIXME: able to invalidate a smaller rect.
+ invalidateNodeBoundingRect(m_inspectedWebView);
+}
+
+void InspectorClientImpl::inspectedURLChanged(const String& newURL)
+{
+ // FIXME: Implement this
+}
+
+String InspectorClientImpl::localizedStringsURL()
+{
+ notImplemented();
+ return String();
+}
+
+String InspectorClientImpl::hiddenPanels()
+{
+ // Enumerate tabs that are currently disabled.
+ return "scripts,profiles,databases";
+}
+
+void InspectorClientImpl::populateSetting(const String& key, InspectorController::Setting& setting)
+{
+ loadSettings();
+ if (m_settings->contains(key))
+ setting = m_settings->get(key);
+}
+
+void InspectorClientImpl::storeSetting(const String& key, const InspectorController::Setting& setting)
+{
+ loadSettings();
+ m_settings->set(key, setting);
+ saveSettings();
+}
+
+void InspectorClientImpl::removeSetting(const String& key)
+{
+ loadSettings();
+ m_settings->remove(key);
+ saveSettings();
+}
+
+void InspectorClientImpl::inspectorWindowObjectCleared()
+{
+ notImplemented();
+}
+
+void InspectorClientImpl::loadSettings()
+{
+ if (m_settings)
+ return;
+
+ m_settings.set(new SettingsMap);
+ String data = m_inspectedWebView->inspectorSettings();
+ if (data.isEmpty())
+ return;
+
+ Vector<String> entries;
+ data.split("\n", entries);
+ for (Vector<String>::iterator it = entries.begin(); it != entries.end(); ++it) {
+ Vector<String> tokens;
+ it->split(":", tokens);
+ if (tokens.size() != 3)
+ continue;
+
+ String name = decodeURLEscapeSequences(tokens[0]);
+ String type = tokens[1];
+ InspectorController::Setting setting;
+ bool ok = true;
+ if (type == "string")
+ setting.set(decodeURLEscapeSequences(tokens[2]));
+ else if (type == "double")
+ setting.set(tokens[2].toDouble(&ok));
+ else if (type == "integer")
+ setting.set(static_cast<long>(tokens[2].toInt(&ok)));
+ else if (type == "boolean")
+ setting.set(tokens[2] == "true");
+ else
+ continue;
+
+ if (ok)
+ m_settings->set(name, setting);
+ }
+}
+
+void InspectorClientImpl::saveSettings()
+{
+ String data;
+ for (SettingsMap::iterator it = m_settings->begin(); it != m_settings->end(); ++it) {
+ String entry;
+ InspectorController::Setting value = it->second;
+ String name = encodeWithURLEscapeSequences(it->first);
+ switch (value.type()) {
+ case InspectorController::Setting::StringType:
+ entry = String::format(
+ "%s:string:%s",
+ name.utf8().data(),
+ encodeWithURLEscapeSequences(value.string()).utf8().data());
+ break;
+ case InspectorController::Setting::DoubleType:
+ entry = String::format(
+ "%s:double:%f",
+ name.utf8().data(),
+ value.doubleValue());
+ break;
+ case InspectorController::Setting::IntegerType:
+ entry = String::format(
+ "%s:integer:%ld",
+ name.utf8().data(),
+ value.integerValue());
+ break;
+ case InspectorController::Setting::BooleanType:
+ entry = String::format("%s:boolean:%s",
+ name.utf8().data(),
+ value.booleanValue() ? "true" : "false");
+ break;
+ case InspectorController::Setting::StringVectorType:
+ notImplemented();
+ break;
+ default:
+ ASSERT_NOT_REACHED();
+ break;
+ }
+ data.append(entry);
+ data.append("\n");
+ }
+ m_inspectedWebView->setInspectorSettings(data);
+ if (m_inspectedWebView->client())
+ m_inspectedWebView->client()->didUpdateInspectorSettings();
+}
+
+} // namespace WebKit
diff --git a/webkit/api/src/InspectorClientImpl.h b/webkit/api/src/InspectorClientImpl.h
new file mode 100644
index 0000000..aaeff93
--- /dev/null
+++ b/webkit/api/src/InspectorClientImpl.h
@@ -0,0 +1,83 @@
+/*
+ * Copyright (C) 2009 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ * * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef InspectorClientImpl_h
+#define InspectorClientImpl_h
+
+#include "InspectorClient.h"
+#include "InspectorController.h"
+#include <wtf/OwnPtr.h>
+
+class WebViewImpl;
+
+namespace WebKit {
+
+class InspectorClientImpl : public WebCore::InspectorClient {
+public:
+ InspectorClientImpl(WebViewImpl*);
+ ~InspectorClientImpl();
+
+ // InspectorClient methods:
+ virtual void inspectorDestroyed();
+ virtual WebCore::Page* createPage();
+ virtual WebCore::String localizedStringsURL();
+ virtual WebCore::String hiddenPanels();
+ virtual void showWindow();
+ virtual void closeWindow();
+ virtual bool windowVisible();
+ virtual void attachWindow();
+ virtual void detachWindow();
+ virtual void setAttachedWindowHeight(unsigned height);
+ virtual void highlight(WebCore::Node*);
+ virtual void hideHighlight();
+ virtual void inspectedURLChanged(const WebCore::String& newURL);
+ virtual void populateSetting(
+ const WebCore::String& key,
+ WebCore::InspectorController::Setting&);
+ virtual void storeSetting(
+ const WebCore::String& key,
+ const WebCore::InspectorController::Setting&);
+ virtual void removeSetting(const WebCore::String& key);
+ virtual void inspectorWindowObjectCleared();
+
+private:
+ void loadSettings();
+ void saveSettings();
+
+ // The WebViewImpl of the page being inspected; gets passed to the constructor
+ WebViewImpl* m_inspectedWebView;
+
+ typedef HashMap<WebCore::String, WebCore::InspectorController::Setting> SettingsMap;
+ OwnPtr<SettingsMap> m_settings;
+};
+
+} // namespace WebKit
+
+#endif
diff --git a/webkit/api/src/WebPopupMenuImpl.cpp b/webkit/api/src/WebPopupMenuImpl.cpp
new file mode 100644
index 0000000..299fbaf
--- /dev/null
+++ b/webkit/api/src/WebPopupMenuImpl.cpp
@@ -0,0 +1,311 @@
+/*
+ * Copyright (C) 2009 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ * * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "WebPopupMenuImpl.h"
+
+#include <skia/ext/platform_canvas.h>
+
+#include "Cursor.h"
+#include "FramelessScrollView.h"
+#include "FrameView.h"
+#include "IntRect.h"
+#include "PlatformContextSkia.h"
+#include "PlatformKeyboardEvent.h"
+#include "PlatformMouseEvent.h"
+#include "PlatformWheelEvent.h"
+#include "SkiaUtils.h"
+#include "WebInputEvent.h"
+#include "WebRect.h"
+#include "WebWidgetClient.h"
+#include "WebInputEventConversion.h"
+
+using namespace WebCore;
+
+namespace WebKit {
+
+// WebPopupMenu ---------------------------------------------------------------
+
+WebPopupMenu* WebPopupMenu::create(WebWidgetClient* client)
+{
+ return new WebPopupMenuImpl(client);
+}
+
+// WebWidget ------------------------------------------------------------------
+
+WebPopupMenuImpl::WebPopupMenuImpl(WebWidgetClient* client)
+ : m_client(client)
+ , m_widget(0)
+{
+ // set to impossible point so we always get the first mouse pos
+ m_lastMousePosition = WebPoint(-1, -1);
+}
+
+WebPopupMenuImpl::~WebPopupMenuImpl()
+{
+ if (m_widget)
+ m_widget->setClient(0);
+}
+
+void WebPopupMenuImpl::Init(FramelessScrollView* widget, const WebRect& bounds)
+{
+ m_widget = widget;
+ m_widget->setClient(this);
+
+ if (m_client) {
+ m_client->setWindowRect(bounds);
+ m_client->show(WebNavigationPolicy()); // Policy is ignored
+ }
+}
+
+void WebPopupMenuImpl::MouseMove(const WebMouseEvent& event)
+{
+ // don't send mouse move messages if the mouse hasn't moved.
+ if (event.x != m_lastMousePosition.x || event.y != m_lastMousePosition.y) {
+ m_lastMousePosition = WebPoint(event.x, event.y);
+ m_widget->handleMouseMoveEvent(PlatformMouseEventBuilder(m_widget, event));
+ }
+}
+
+void WebPopupMenuImpl::MouseLeave(const WebMouseEvent& event)
+{
+ m_widget->handleMouseMoveEvent(PlatformMouseEventBuilder(m_widget, event));
+}
+
+void WebPopupMenuImpl::MouseDown(const WebMouseEvent& event)
+{
+ m_widget->handleMouseDownEvent(PlatformMouseEventBuilder(m_widget, event));
+}
+
+void WebPopupMenuImpl::MouseUp(const WebMouseEvent& event)
+{
+ mouseCaptureLost();
+ m_widget->handleMouseReleaseEvent(PlatformMouseEventBuilder(m_widget, event));
+}
+
+void WebPopupMenuImpl::MouseWheel(const WebMouseWheelEvent& event)
+{
+ m_widget->handleWheelEvent(PlatformWheelEventBuilder(m_widget, event));
+}
+
+bool WebPopupMenuImpl::KeyEvent(const WebKeyboardEvent& event)
+{
+ return m_widget->handleKeyEvent(PlatformKeyboardEventBuilder(event));
+}
+
+// WebWidget -------------------------------------------------------------------
+
+void WebPopupMenuImpl::close()
+{
+ if (m_widget)
+ m_widget->hide();
+
+ m_client = 0;
+
+ deref(); // Balances ref() from WebWidget::Create
+}
+
+void WebPopupMenuImpl::resize(const WebSize& newSize)
+{
+ if (m_size == newSize)
+ return;
+ m_size = newSize;
+
+ if (m_widget) {
+ IntRect newGeometry(0, 0, m_size.width, m_size.height);
+ m_widget->setFrameRect(newGeometry);
+ }
+
+ if (m_client) {
+ WebRect damagedRect(0, 0, m_size.width, m_size.height);
+ m_client->didInvalidateRect(damagedRect);
+ }
+}
+
+void WebPopupMenuImpl::layout()
+{
+}
+
+void WebPopupMenuImpl::paint(WebCanvas* canvas, const WebRect& rect)
+{
+ if (!m_widget)
+ return;
+
+ if (!rect.isEmpty()) {
+#if WEBKIT_USING_CG
+ GraphicsContext gc(canvas);
+#elif WEBKIT_USING_SKIA
+ PlatformContextSkia context(canvas);
+ // PlatformGraphicsContext is actually a pointer to PlatformContextSkia.
+ GraphicsContext gc(reinterpret_cast<PlatformGraphicsContext*>(&context));
+#else
+ notImplemented();
+#endif
+ m_widget->paint(&gc, rect);
+ }
+}
+
+bool WebPopupMenuImpl::handleInputEvent(const WebInputEvent& inputEvent)
+{
+ if (!m_widget)
+ return false;
+
+ // TODO (jcampan): WebKit seems to always return false on mouse events
+ // methods. For now we'll assume it has processed them (as we are only
+ // interested in whether keyboard events are processed).
+ switch (inputEvent.type) {
+ case WebInputEvent::MouseMove:
+ MouseMove(*static_cast<const WebMouseEvent*>(&inputEvent));
+ return true;
+
+ case WebInputEvent::MouseLeave:
+ MouseLeave(*static_cast<const WebMouseEvent*>(&inputEvent));
+ return true;
+
+ case WebInputEvent::MouseWheel:
+ MouseWheel(*static_cast<const WebMouseWheelEvent*>(&inputEvent));
+ return true;
+
+ case WebInputEvent::MouseDown:
+ MouseDown(*static_cast<const WebMouseEvent*>(&inputEvent));
+ return true;
+
+ case WebInputEvent::MouseUp:
+ MouseUp(*static_cast<const WebMouseEvent*>(&inputEvent));
+ return true;
+
+ // In Windows, RawKeyDown only has information about the physical key, but
+ // for "selection", we need the information about the character the key
+ // translated into. For English, the physical key value and the character
+ // value are the same, hence, "selection" works for English. But for other
+ // languages, such as Hebrew, the character value is different from the
+ // physical key value. Thus, without accepting Char event type which
+ // contains the key's character value, the "selection" won't work for
+ // non-English languages, such as Hebrew.
+ case WebInputEvent::RawKeyDown:
+ case WebInputEvent::KeyDown:
+ case WebInputEvent::KeyUp:
+ case WebInputEvent::Char:
+ return KeyEvent(*static_cast<const WebKeyboardEvent*>(&inputEvent));
+
+ default:
+ break;
+ }
+ return false;
+}
+
+void WebPopupMenuImpl::mouseCaptureLost()
+{
+}
+
+void WebPopupMenuImpl::setFocus(bool enable)
+{
+}
+
+bool WebPopupMenuImpl::handleCompositionEvent(
+ WebCompositionCommand command, int cursorPosition, int targetStart,
+ int targetEnd, const WebString& imeString)
+{
+ return false;
+}
+
+bool WebPopupMenuImpl::queryCompositionStatus(bool* enabled, WebRect* caretRect)
+{
+ return false;
+}
+
+void WebPopupMenuImpl::setTextDirection(WebTextDirection direction)
+{
+}
+
+
+//-----------------------------------------------------------------------------
+// WebCore::HostWindow
+
+void WebPopupMenuImpl::repaint(const IntRect& paintRect,
+ bool contentChanged,
+ bool immediate,
+ bool repaintContentOnly)
+{
+ // Ignore spurious calls.
+ if (!contentChanged || paintRect.isEmpty())
+ return;
+ if (m_client)
+ m_client->didInvalidateRect(paintRect);
+}
+
+void WebPopupMenuImpl::scroll(const IntSize& scrollDelta,
+ const IntRect& scrollRect,
+ const IntRect& clipRect)
+{
+ if (m_client) {
+ int dx = scrollDelta.width();
+ int dy = scrollDelta.height();
+ m_client->didScrollRect(dx, dy, clipRect);
+ }
+}
+
+IntPoint WebPopupMenuImpl::screenToWindow(const IntPoint& point) const
+{
+ notImplemented();
+ return IntPoint();
+}
+
+IntRect WebPopupMenuImpl::windowToScreen(const IntRect& rect) const
+{
+ notImplemented();
+ return IntRect();
+}
+
+void WebPopupMenuImpl::scrollRectIntoView(const IntRect&, const ScrollView*) const
+{
+ // Nothing to be done here since we do not have the concept of a container
+ // that implements its own scrolling.
+}
+
+void WebPopupMenuImpl::scrollbarsModeDidChange() const
+{
+ // Nothing to be done since we have no concept of different scrollbar modes.
+}
+
+//-----------------------------------------------------------------------------
+// WebCore::FramelessScrollViewClient
+
+void WebPopupMenuImpl::popupClosed(FramelessScrollView* widget)
+{
+ ASSERT(widget == m_widget);
+ if (m_widget) {
+ m_widget->setClient(0);
+ m_widget = 0;
+ }
+ m_client->closeWidgetSoon();
+}
+
+} // namespace WebKit
diff --git a/webkit/api/src/WebPopupMenuImpl.h b/webkit/api/src/WebPopupMenuImpl.h
new file mode 100644
index 0000000..13eb674
--- /dev/null
+++ b/webkit/api/src/WebPopupMenuImpl.h
@@ -0,0 +1,128 @@
+/*
+ * Copyright (C) 2009 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ * * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef WebPopupMenuImpl_h
+#define WebPopupMenuImpl_h
+
+// FIXME: Add this to FramelessScrollViewClient.h
+namespace WebCore { class FramelessScrollView; }
+
+#include "FramelessScrollViewClient.h"
+// FIXME: remove the relative paths once glue/ consumers are removed.
+#include "../public/WebPoint.h"
+#include "../public/WebPopupMenu.h"
+#include "../public/WebSize.h"
+#include <wtf/RefCounted.h>
+
+namespace WebCore {
+class Frame;
+class FramelessScrollView;
+class KeyboardEvent;
+class Page;
+class PlatformKeyboardEvent;
+class Range;
+class Widget;
+}
+
+namespace WebKit {
+class WebKeyboardEvent;
+class WebMouseEvent;
+class WebMouseWheelEvent;
+struct WebRect;
+
+class WebPopupMenuImpl : public WebPopupMenu,
+ public WebCore::FramelessScrollViewClient,
+ public RefCounted<WebPopupMenuImpl> {
+public:
+ // WebWidget
+ virtual void close();
+ virtual WebSize size() { return m_size; }
+ virtual void resize(const WebSize&);
+ virtual void layout();
+ virtual void paint(WebCanvas* canvas, const WebRect& rect);
+ virtual bool handleInputEvent(const WebInputEvent&);
+ virtual void mouseCaptureLost();
+ virtual void setFocus(bool enable);
+ virtual bool handleCompositionEvent(
+ WebCompositionCommand command, int cursorPosition,
+ int targetStart, int targetEnd, const WebString& text);
+ virtual bool queryCompositionStatus(bool* enabled, WebRect* caretRect);
+ virtual void setTextDirection(WebTextDirection direction);
+
+ // WebPopupMenuImpl
+ void Init(WebCore::FramelessScrollView* widget,
+ const WebRect& bounds);
+
+ WebWidgetClient* client() { return m_client; }
+
+ void MouseMove(const WebMouseEvent&);
+ void MouseLeave(const WebMouseEvent&);
+ void MouseDown(const WebMouseEvent&);
+ void MouseUp(const WebMouseEvent&);
+ void MouseDoubleClick(const WebMouseEvent&);
+ void MouseWheel(const WebMouseWheelEvent&);
+ bool KeyEvent(const WebKeyboardEvent&);
+
+ protected:
+ friend class WebPopupMenu; // For WebPopupMenu::create
+ friend class WTF::RefCounted<WebPopupMenuImpl>;
+
+ WebPopupMenuImpl(WebWidgetClient* client);
+ ~WebPopupMenuImpl();
+
+ // WebCore::HostWindow methods:
+ virtual void repaint(
+ const WebCore::IntRect&, bool contentChanged, bool immediate = false,
+ bool repaintContentOnly = false);
+ virtual void scroll(
+ const WebCore::IntSize& scrollDelta, const WebCore::IntRect& scrollRect,
+ const WebCore::IntRect& clipRect);
+ virtual WebCore::IntPoint screenToWindow(const WebCore::IntPoint&) const;
+ virtual WebCore::IntRect windowToScreen(const WebCore::IntRect&) const;
+ virtual PlatformPageClient platformPageClient() const { return 0; }
+ virtual void scrollRectIntoView(const WebCore::IntRect&, const WebCore::ScrollView*) const;
+ virtual void scrollbarsModeDidChange() const;
+
+ // WebCore::FramelessScrollViewClient methods:
+ virtual void popupClosed(WebCore::FramelessScrollView*);
+
+ WebWidgetClient* m_client;
+ WebSize m_size;
+
+ WebPoint m_lastMousePosition;
+
+ // This is a non-owning ref. The popup will notify us via popupClosed()
+ // before it is destroyed.
+ WebCore::FramelessScrollView* m_widget;
+};
+
+} // namespace WebKit
+
+#endif