Commit 7c6268b9 authored by eric@webkit.org's avatar eric@webkit.org

2009-11-09 Yaar Schnitman <yaar@chromium.org>

        Reviewed by Dimitri Glazkov.

        Upstreaming the Chromium WebKit API: WebVector to WebWorkerClient

        https://bugs.webkit.org/show_bug.cgi?id=28394

        * public/WebVector.h: Added.
        (WebKit::WebVector::~WebVector):
        (WebKit::WebVector::WebVector):
        (WebKit::WebVector::operator=):
        (WebKit::WebVector::assign):
        (WebKit::WebVector::size):
        (WebKit::WebVector::isEmpty):
        (WebKit::WebVector::operator[]):
        (WebKit::WebVector::data):
        (WebKit::WebVector::swap):
        (WebKit::WebVector::initialize):
        (WebKit::WebVector::initializeFrom):
        (WebKit::WebVector::destroy):
        * public/WebView.h: Added.
        (WebKit::WebView::~WebView):
        * public/WebViewClient.h: Added.
        (WebKit::WebViewClient::createView):
        (WebKit::WebViewClient::createPopupMenu):
        (WebKit::WebViewClient::didAddMessageToConsole):
        (WebKit::WebViewClient::printPage):
        (WebKit::WebViewClient::notificationPresenter):
        (WebKit::WebViewClient::didStartLoading):
        (WebKit::WebViewClient::didStopLoading):
        (WebKit::WebViewClient::shouldBeginEditing):
        (WebKit::WebViewClient::shouldEndEditing):
        (WebKit::WebViewClient::shouldInsertNode):
        (WebKit::WebViewClient::shouldInsertText):
        (WebKit::WebViewClient::shouldChangeSelectedRange):
        (WebKit::WebViewClient::shouldDeleteRange):
        (WebKit::WebViewClient::shouldApplyStyle):
        (WebKit::WebViewClient::isSmartInsertDeleteEnabled):
        (WebKit::WebViewClient::isSelectTrailingWhitespaceEnabled):
        (WebKit::WebViewClient::setInputMethodEnabled):
        (WebKit::WebViewClient::didBeginEditing):
        (WebKit::WebViewClient::didChangeSelection):
        (WebKit::WebViewClient::didChangeContents):
        (WebKit::WebViewClient::didExecuteCommand):
        (WebKit::WebViewClient::didEndEditing):
        (WebKit::WebViewClient::handleCurrentKeyboardEvent):
        (WebKit::WebViewClient::spellCheck):
        (WebKit::WebViewClient::autoCorrectWord):
        (WebKit::WebViewClient::showSpellingUI):
        (WebKit::WebViewClient::isShowingSpellingUI):
        (WebKit::WebViewClient::updateSpellingUIWithMisspelledWord):
        (WebKit::WebViewClient::runFileChooser):
        (WebKit::WebViewClient::runModalAlertDialog):
        (WebKit::WebViewClient::runModalConfirmDialog):
        (WebKit::WebViewClient::runModalPromptDialog):
        (WebKit::WebViewClient::runModalBeforeUnloadDialog):
        (WebKit::WebViewClient::setStatusText):
        (WebKit::WebViewClient::setMouseOverURL):
        (WebKit::WebViewClient::setKeyboardFocusURL):
        (WebKit::WebViewClient::setToolTipText):
        (WebKit::WebViewClient::showContextMenu):
        (WebKit::WebViewClient::startDragging):
        (WebKit::WebViewClient::acceptsLoadDrops):
        (WebKit::WebViewClient::focusNext):
        (WebKit::WebViewClient::focusPrevious):
        (WebKit::WebViewClient::navigateBackForwardSoon):
        (WebKit::WebViewClient::historyBackListCount):
        (WebKit::WebViewClient::historyForwardListCount):
        (WebKit::WebViewClient::didAddHistoryItem):
        (WebKit::WebViewClient::focusAccessibilityObject):
        (WebKit::WebViewClient::didUpdateInspectorSettings):
        (WebKit::WebViewClient::queryAutofillSuggestions):
        (WebKit::WebViewClient::removeAutofillSuggestions):
        (WebKit::WebViewClient::~WebViewClient):
        * public/WebWidget.h: Added.
        (WebKit::WebWidget::~WebWidget):
        * public/WebWidgetClient.h: Added.
        (WebKit::WebWidgetClient::didInvalidateRect):
        (WebKit::WebWidgetClient::didScrollRect):
        (WebKit::WebWidgetClient::didFocus):
        (WebKit::WebWidgetClient::didBlur):
        (WebKit::WebWidgetClient::didChangeCursor):
        (WebKit::WebWidgetClient::closeWidgetSoon):
        (WebKit::WebWidgetClient::show):
        (WebKit::WebWidgetClient::runModal):
        (WebKit::WebWidgetClient::windowRect):
        (WebKit::WebWidgetClient::setWindowRect):
        (WebKit::WebWidgetClient::windowResizerRect):
        (WebKit::WebWidgetClient::rootWindowRect):
        (WebKit::WebWidgetClient::screenInfo):
        (WebKit::WebWidgetClient::~WebWidgetClient):
        * public/WebWorker.h: Added.
        (WebKit::WebWorker::~WebWorker):
        * public/WebWorkerClient.h: Added.
        (WebKit::WebWorkerClient::~WebWorkerClient):

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@50681 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent a749608e
2009-11-09 Yaar Schnitman <yaar@chromium.org>
Reviewed by Dimitri Glazkov.
Upstreaming the Chromium WebKit API: WebVector to WebWorkerClient
https://bugs.webkit.org/show_bug.cgi?id=28394
* public/WebVector.h: Added.
(WebKit::WebVector::~WebVector):
(WebKit::WebVector::WebVector):
(WebKit::WebVector::operator=):
(WebKit::WebVector::assign):
(WebKit::WebVector::size):
(WebKit::WebVector::isEmpty):
(WebKit::WebVector::operator[]):
(WebKit::WebVector::data):
(WebKit::WebVector::swap):
(WebKit::WebVector::initialize):
(WebKit::WebVector::initializeFrom):
(WebKit::WebVector::destroy):
* public/WebView.h: Added.
(WebKit::WebView::~WebView):
* public/WebViewClient.h: Added.
(WebKit::WebViewClient::createView):
(WebKit::WebViewClient::createPopupMenu):
(WebKit::WebViewClient::didAddMessageToConsole):
(WebKit::WebViewClient::printPage):
(WebKit::WebViewClient::notificationPresenter):
(WebKit::WebViewClient::didStartLoading):
(WebKit::WebViewClient::didStopLoading):
(WebKit::WebViewClient::shouldBeginEditing):
(WebKit::WebViewClient::shouldEndEditing):
(WebKit::WebViewClient::shouldInsertNode):
(WebKit::WebViewClient::shouldInsertText):
(WebKit::WebViewClient::shouldChangeSelectedRange):
(WebKit::WebViewClient::shouldDeleteRange):
(WebKit::WebViewClient::shouldApplyStyle):
(WebKit::WebViewClient::isSmartInsertDeleteEnabled):
(WebKit::WebViewClient::isSelectTrailingWhitespaceEnabled):
(WebKit::WebViewClient::setInputMethodEnabled):
(WebKit::WebViewClient::didBeginEditing):
(WebKit::WebViewClient::didChangeSelection):
(WebKit::WebViewClient::didChangeContents):
(WebKit::WebViewClient::didExecuteCommand):
(WebKit::WebViewClient::didEndEditing):
(WebKit::WebViewClient::handleCurrentKeyboardEvent):
(WebKit::WebViewClient::spellCheck):
(WebKit::WebViewClient::autoCorrectWord):
(WebKit::WebViewClient::showSpellingUI):
(WebKit::WebViewClient::isShowingSpellingUI):
(WebKit::WebViewClient::updateSpellingUIWithMisspelledWord):
(WebKit::WebViewClient::runFileChooser):
(WebKit::WebViewClient::runModalAlertDialog):
(WebKit::WebViewClient::runModalConfirmDialog):
(WebKit::WebViewClient::runModalPromptDialog):
(WebKit::WebViewClient::runModalBeforeUnloadDialog):
(WebKit::WebViewClient::setStatusText):
(WebKit::WebViewClient::setMouseOverURL):
(WebKit::WebViewClient::setKeyboardFocusURL):
(WebKit::WebViewClient::setToolTipText):
(WebKit::WebViewClient::showContextMenu):
(WebKit::WebViewClient::startDragging):
(WebKit::WebViewClient::acceptsLoadDrops):
(WebKit::WebViewClient::focusNext):
(WebKit::WebViewClient::focusPrevious):
(WebKit::WebViewClient::navigateBackForwardSoon):
(WebKit::WebViewClient::historyBackListCount):
(WebKit::WebViewClient::historyForwardListCount):
(WebKit::WebViewClient::didAddHistoryItem):
(WebKit::WebViewClient::focusAccessibilityObject):
(WebKit::WebViewClient::didUpdateInspectorSettings):
(WebKit::WebViewClient::queryAutofillSuggestions):
(WebKit::WebViewClient::removeAutofillSuggestions):
(WebKit::WebViewClient::~WebViewClient):
* public/WebWidget.h: Added.
(WebKit::WebWidget::~WebWidget):
* public/WebWidgetClient.h: Added.
(WebKit::WebWidgetClient::didInvalidateRect):
(WebKit::WebWidgetClient::didScrollRect):
(WebKit::WebWidgetClient::didFocus):
(WebKit::WebWidgetClient::didBlur):
(WebKit::WebWidgetClient::didChangeCursor):
(WebKit::WebWidgetClient::closeWidgetSoon):
(WebKit::WebWidgetClient::show):
(WebKit::WebWidgetClient::runModal):
(WebKit::WebWidgetClient::windowRect):
(WebKit::WebWidgetClient::setWindowRect):
(WebKit::WebWidgetClient::windowResizerRect):
(WebKit::WebWidgetClient::rootWindowRect):
(WebKit::WebWidgetClient::screenInfo):
(WebKit::WebWidgetClient::~WebWidgetClient):
* public/WebWorker.h: Added.
(WebKit::WebWorker::~WebWorker):
* public/WebWorkerClient.h: Added.
(WebKit::WebWorkerClient::~WebWorkerClient):
2009-11-09 Nate Chapin <japhet@chromium.org>
Reviewed by Dimitri Glazkov.
......
/*
* 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 WebVector_h
#define WebVector_h
#include "WebCommon.h"
#include <algorithm>
namespace WebKit {
// A simple vector class.
//
// Sample usage:
//
// void Foo(WebVector<int>& result)
// {
// WebVector<int> data(10);
// for (size_t i = 0; i < data.size(); ++i)
// data[i] = ...
// result.swap(data);
// }
//
// It is also possible to assign from other types of random access
// containers:
//
// void Foo(const std::vector<std::string>& input)
// {
// WebVector<WebCString> cstrings = input;
// ...
// }
//
template <typename T>
class WebVector {
public:
typedef T ValueType;
~WebVector()
{
destroy();
}
explicit WebVector(size_t size = 0)
{
initialize(size);
}
WebVector(const WebVector<T>& other)
{
initializeFrom(other.m_ptr, other.m_size);
}
template <typename C>
WebVector(const C& other)
{
initializeFrom(other.size() ? &other[0] : 0, other.size());
}
template <typename C>
WebVector<T>& operator=(const C& other)
{
if (this != reinterpret_cast<const WebVector<T>*>(&other))
assign(other);
return *this;
}
template <typename C>
void assign(const C& other)
{
assign(other.size() ? &other[0] : 0, other.size());
}
template <typename U>
void assign(const U* values, size_t size)
{
destroy();
initializeFrom(values, size);
}
size_t size() const { return m_size; }
bool isEmpty() const { return !m_size; }
T& operator[](size_t i) { return m_ptr[i]; }
const T& operator[](size_t i) const { return m_ptr[i]; }
T* data() { return m_ptr; }
const T* data() const { return m_ptr; }
void swap(WebVector<T>& other)
{
std::swap(m_ptr, other.m_ptr);
std::swap(m_size, other.m_size);
}
private:
void initialize(size_t size)
{
m_size = size;
if (!m_size)
m_ptr = 0;
else {
m_ptr = static_cast<T*>(::operator new(sizeof(T) * m_size));
for (size_t i = 0; i < m_size; ++i)
new (&m_ptr[i]) T();
}
}
template <typename U>
void initializeFrom(const U* values, size_t size)
{
m_size = size;
if (!m_size)
m_ptr = 0;
else {
m_ptr = static_cast<T*>(::operator new(sizeof(T) * m_size));
for (size_t i = 0; i < m_size; ++i)
new (&m_ptr[i]) T(values[i]);
}
}
void destroy()
{
for (size_t i = 0; i < m_size; ++i)
m_ptr[i].~T();
::operator delete(m_ptr);
}
T* m_ptr;
size_t m_size;
};
} // namespace WebKit
#endif
/*
* 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 WebView_h
#define WebView_h
#include "WebDragOperation.h"
#include "WebWidget.h"
namespace WebKit {
class WebAccessibilityObject;
class WebDevToolsAgent;
class WebDragData;
class WebFrame;
class WebFrameClient;
class WebNode;
class WebSettings;
class WebString;
class WebViewClient;
struct WebMediaPlayerAction;
struct WebPoint;
template <typename T> class WebVector;
class WebView : public WebWidget {
public:
// Initialization ------------------------------------------------------
// Creates a WebView that is NOT yet initialized. You will need to
// call initializeMainFrame to finish the initialization. It is valid
// to pass a null WebViewClient pointer.
WEBKIT_API static WebView* create(WebViewClient*);
// After creating a WebView, you should immediately call this method.
// You can optionally modify the settings before calling this method.
// The WebFrameClient will receive events for the main frame and any
// child frames. It is valid to pass a null WebFrameClient pointer.
virtual void initializeMainFrame(WebFrameClient*) = 0;
// Options -------------------------------------------------------------
// The returned pointer is valid for the lifetime of the WebView.
virtual WebSettings* settings() = 0;
// Corresponds to the encoding of the main frame. Setting the page
// encoding may cause the main frame to reload.
virtual WebString pageEncoding() const = 0;
virtual void setPageEncoding(const WebString&) = 0;
// Makes the WebView transparent. This is useful if you want to have
// some custom background rendered behind it.
virtual bool isTransparent() const = 0;
virtual void setIsTransparent(bool) = 0;
// Controls whether pressing Tab key advances focus to links.
virtual bool tabsToLinks() const = 0;
virtual void setTabsToLinks(bool) = 0;
// Method that controls whether pressing Tab key cycles through page
// elements or inserts a '\t' char in the focused text area.
virtual bool tabKeyCyclesThroughElements() const = 0;
virtual void setTabKeyCyclesThroughElements(bool) = 0;
// Controls the WebView's active state, which may affect the rendering
// of elements on the page (i.e., tinting of input elements).
virtual bool isActive() const = 0;
virtual void setIsActive(bool) = 0;
// Closing -------------------------------------------------------------
// Runs beforeunload handlers for the current page, returning false if
// any handler suppressed unloading.
virtual bool dispatchBeforeUnloadEvent() = 0;
// Runs unload handlers for the current page.
virtual void dispatchUnloadEvent() = 0;
// Frames --------------------------------------------------------------
virtual WebFrame* mainFrame() = 0;
// Returns the frame identified by the given name. This method
// supports pseudo-names like _self, _top, and _blank. It traverses
// the entire frame tree containing this tree looking for a frame that
// matches the given name. If the optional relativeToFrame parameter
// is specified, then the search begins with the given frame and its
// children.
virtual WebFrame* findFrameByName(
const WebString& name, WebFrame* relativeToFrame = 0) = 0;
// Focus ---------------------------------------------------------------
virtual WebFrame* focusedFrame() = 0;
virtual void setFocusedFrame(WebFrame*) = 0;
// Focus the first (last if reverse is true) focusable node.
virtual void setInitialFocus(bool reverse) = 0;
// Clears the focused node (and selection if a text field is focused)
// to ensure that a text field on the page is not eating keystrokes we
// send it.
virtual void clearFocusedNode() = 0;
// Zoom ----------------------------------------------------------------
// Change the text zoom level. It will make the zoom level 20% larger
// or smaller. If textOnly is set, the text size will be changed.
// When unset, the entire page's zoom factor will be changed.
//
// You can only have either text zoom or full page zoom at one time.
// Changing the mode will change things in weird ways. Generally the
// app should only support text zoom or full page zoom, and not both.
//
// zoomDefault will reset both full page and text zoom.
virtual void zoomIn(bool textOnly) = 0;
virtual void zoomOut(bool textOnly) = 0;
virtual void zoomDefault() = 0;
// Media ---------------------------------------------------------------
// Performs the specified action on the node at the given location.
virtual void performMediaPlayerAction(
const WebMediaPlayerAction&, const WebPoint& location) = 0;
// Data exchange -------------------------------------------------------
// Copy to the clipboard the image located at a particular point in the
// WebView (if there is such an image)
virtual void copyImageAt(const WebPoint&) = 0;
// Notifies the WebView that a drag has terminated.
virtual void dragSourceEndedAt(
const WebPoint& clientPoint, const WebPoint& screenPoint,
WebDragOperation operation) = 0;
// Notifies the WebView that a drag and drop operation is in progress, with
// dropable items over the view.
virtual void dragSourceMovedTo(
const WebPoint& clientPoint, const WebPoint& screenPoint) = 0;
// Notfies the WebView that the system drag and drop operation has ended.
virtual void dragSourceSystemDragEnded() = 0;
// Callback methods when a drag-and-drop operation is trying to drop
// something on the WebView.
virtual WebDragOperation dragTargetDragEnter(
const WebDragData&, int identity,
const WebPoint& clientPoint, const WebPoint& screenPoint,
WebDragOperationsMask operationsAllowed) = 0;
virtual WebDragOperation dragTargetDragOver(
const WebPoint& clientPoint, const WebPoint& screenPoint,
WebDragOperationsMask operationsAllowed) = 0;
virtual void dragTargetDragLeave() = 0;
virtual void dragTargetDrop(
const WebPoint& clientPoint, const WebPoint& screenPoint) = 0;
virtual int dragIdentity() = 0;
// Helper method for drag and drop target operations: override the
// default drop effect with either a "copy" (accept true) or "none"
// (accept false) effect. Return true on success.
virtual bool setDropEffect(bool accept) = 0;
// Developer tools -----------------------------------------------------
// Inspect a particular point in the WebView. (x = -1 || y = -1) is a
// special case, meaning inspect the current page and not a specific
// point.
virtual void inspectElementAt(const WebPoint&) = 0;
// Settings used by the inspector.
virtual WebString inspectorSettings() const = 0;
virtual void setInspectorSettings(const WebString&) = 0;
// The embedder may optionally engage a WebDevToolsAgent. This may only
// be set once per WebView.
virtual WebDevToolsAgent* devToolsAgent() = 0;
virtual void setDevToolsAgent(WebDevToolsAgent*) = 0;
// Accessibility -------------------------------------------------------
// Returns the accessibility object for this view.
virtual WebAccessibilityObject accessibilityObject() = 0;
// Autofill ------------------------------------------------------------
// Notifies the WebView that autofill suggestions are available for a node.
virtual void applyAutofillSuggestions(
const WebNode&,
const WebVector<WebString>& suggestions,
int defaultSuggestionIndex) = 0;
// Hides the autofill popup if any are showing.
virtual void hideAutofillPopup() = 0;
// Visited link state --------------------------------------------------
// Tells all WebView instances to update the visited link state for the
// specified hash.
WEBKIT_API static void updateVisitedLinkState(unsigned long long hash);
// Tells all WebView instances to update the visited state for all
// their links.
WEBKIT_API static void resetVisitedLinkState();
protected:
~WebView() {}
};
} // namespace WebKit
#endif
/*
* 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 WebViewClient_h
#define WebViewClient_h
#include "WebDragOperation.h"
#include "WebEditingAction.h"
#include "WebFileChooserCompletion.h"
#include "WebString.h"
#include "WebTextAffinity.h"
#include "WebTextDirection.h"
#include "WebWidgetClient.h"
namespace WebKit {
class WebAccessibilityObject;
class WebDragData;
class WebFileChooserCompletion;
class WebFrame;
class WebNode;
class WebNotificationPresenter;
class WebRange;
class WebURL;
class WebView;
class WebWidget;
struct WebConsoleMessage;
struct WebContextMenuData;
struct WebPoint;
struct WebPopupMenuInfo;
// Since a WebView is a WebWidget, a WebViewClient is a WebWidgetClient.
// Virtual inheritance allows an implementation of WebWidgetClient to be
// easily reused as part of an implementation of WebViewClient.
class WebViewClient : virtual public WebWidgetClient {
public:
// Factory methods -----------------------------------------------------
// Create a new related WebView.
virtual WebView* createView(WebFrame* creator) { return 0; }
// Create a new WebPopupMenu. In the second form, the client is
// responsible for rendering the contents of the popup menu.
virtual WebWidget* createPopupMenu(bool activatable) { return 0; }
virtual WebWidget* createPopupMenu(const WebPopupMenuInfo&) { return 0; }
// Misc ----------------------------------------------------------------
// A new message was added to the console.
virtual void didAddMessageToConsole(
const WebConsoleMessage&, const WebString& sourceName, unsigned sourceLine) { }
// Called when script in the page calls window.print(). If frame is
// non-null, then it selects a particular frame, including its
// children, to print. Otherwise, the main frame and its children
// should be printed.
virtual void printPage(WebFrame*) { }
// Called to retrieve the provider of desktop notifications.
virtual WebNotificationPresenter* notificationPresenter() { return 0; }
// Navigational --------------------------------------------------------
// These notifications bracket any loading that occurs in the WebView.
virtual void didStartLoading() { }
virtual void didStopLoading() { }
// Editing -------------------------------------------------------------
// These methods allow the client to intercept and overrule editing
// operations.
virtual bool shouldBeginEditing(const WebRange&) { return true; }
virtual bool shouldEndEditing(const WebRange&) { return true; }
virtual bool shouldInsertNode(
const WebNode&, const WebRange&, WebEditingAction) { return true; }
virtual bool shouldInsertText(
const WebString&, const WebRange&, WebEditingAction) { return true; }
virtual bool shouldChangeSelectedRange(
const WebRange& from, const WebRange& to, WebTextAffinity,
bool stillSelecting) { return true; }
virtual bool shouldDeleteRange(const WebRange&) { return true; }
virtual bool shouldApplyStyle(const WebString& style, const WebRange&) { return true; }
virtual bool isSmartInsertDeleteEnabled() { return true; }
virtual bool isSelectTrailingWhitespaceEnabled() { return true; }
virtual void setInputMethodEnabled(bool enabled) { }
virtual void didBeginEditing() { }
virtual void didChangeSelection(bool isSelectionEmpty) { }
virtual void didChangeContents() { }
virtual void didExecuteCommand(const WebString& commandName) { }
virtual void didEndEditing() { }
// This method is called in response to WebView's handleInputEvent()
// when the default action for the current keyboard event is not
// suppressed by the page, to give the embedder a chance to handle