[SCM] WebKit Debian packaging branch, webkit-1.1, updated. upstream/1.1.16-1409-g5afdf4d
eric at webkit.org
eric at webkit.org
Thu Dec 3 13:31:03 UTC 2009
The following commit has been merged in the webkit-1.1 branch:
commit 243b03890c2574c1e61c2beae6f2a81c51874e2f
Author: eric at webkit.org <eric at webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date: Tue Nov 10 18:04:41 2009 +0000
2009-11-10 Yaar Schnitman <yaar at chromium.org>
Reviewed by Dimitri Glazkov.
Up-streaming Chromium API src files: WebString...WebViewImpl
https://bugs.webkit.org/show_bug.cgi?id=31276
* src/WebString.cpp: Added.
(WebKit::WebString::reset):
(WebKit::WebString::assign):
(WebKit::WebString::length):
(WebKit::WebString::data):
(WebKit::WebString::utf8):
(WebKit::WebString::fromUTF8):
(WebKit::WebString::WebString):
(WebKit::WebString::operator=):
(WebKit::WebString::operator WebCore::String):
(WebKit::WebString::operator WebCore::AtomicString):
* src/WebURL.cpp: Added.
(WebKit::WebURL::WebURL):
(WebKit::WebURL::operator=):
(WebKit::WebURL::operator WebCore::KURL):
* src/WebURLError.cpp: Added.
(WebKit::WebURLError::WebURLError):
(WebKit::WebURLError::operator=):
(WebKit::WebURLError::operator ResourceError):
* src/WebURLRequest.cpp: Added.
(WebKit::WebURLRequestPrivateImpl::WebURLRequestPrivateImpl):
(WebKit::WebURLRequestPrivateImpl::dispose):
(WebKit::WebURLRequest::initialize):
(WebKit::WebURLRequest::reset):
(WebKit::WebURLRequest::assign):
(WebKit::WebURLRequest::isNull):
(WebKit::WebURLRequest::url):
(WebKit::WebURLRequest::setURL):
(WebKit::WebURLRequest::firstPartyForCookies):
(WebKit::WebURLRequest::setFirstPartyForCookies):
(WebKit::WebURLRequest::allowCookies):
(WebKit::WebURLRequest::setAllowCookies):
(WebKit::WebURLRequest::allowStoredCredentials):
(WebKit::WebURLRequest::setAllowStoredCredentials):
(WebKit::WebURLRequest::cachePolicy):
(WebKit::WebURLRequest::setCachePolicy):
(WebKit::WebURLRequest::httpMethod):
(WebKit::WebURLRequest::setHTTPMethod):
(WebKit::WebURLRequest::httpHeaderField):
(WebKit::WebURLRequest::setHTTPHeaderField):
(WebKit::WebURLRequest::addHTTPHeaderField):
(WebKit::WebURLRequest::clearHTTPHeaderField):
(WebKit::WebURLRequest::visitHTTPHeaderFields):
(WebKit::WebURLRequest::httpBody):
(WebKit::WebURLRequest::setHTTPBody):
(WebKit::WebURLRequest::reportUploadProgress):
(WebKit::WebURLRequest::setReportUploadProgress):
(WebKit::WebURLRequest::targetType):
(WebKit::WebURLRequest::setTargetType):
(WebKit::WebURLRequest::requestorID):
(WebKit::WebURLRequest::setRequestorID):
(WebKit::WebURLRequest::requestorProcessID):
(WebKit::WebURLRequest::setRequestorProcessID):
(WebKit::WebURLRequest::appCacheHostID):
(WebKit::WebURLRequest::setAppCacheHostID):
(WebKit::WebURLRequest::toMutableResourceRequest):
(WebKit::WebURLRequest::toResourceRequest):
* src/WebURLRequestPrivate.h: Added.
(WebKit::WebURLRequestPrivate::WebURLRequestPrivate):
* src/WebURLResponse.cpp: Added.
(WebKit::WebURLResponsePrivateImpl::WebURLResponsePrivateImpl):
(WebKit::WebURLResponsePrivateImpl::dispose):
(WebKit::WebURLResponse::initialize):
(WebKit::WebURLResponse::reset):
(WebKit::WebURLResponse::assign):
(WebKit::WebURLResponse::isNull):
(WebKit::WebURLResponse::url):
(WebKit::WebURLResponse::setURL):
(WebKit::WebURLResponse::mimeType):
(WebKit::WebURLResponse::setMIMEType):
(WebKit::WebURLResponse::expectedContentLength):
(WebKit::WebURLResponse::setExpectedContentLength):
(WebKit::WebURLResponse::textEncodingName):
(WebKit::WebURLResponse::setTextEncodingName):
(WebKit::WebURLResponse::suggestedFileName):
(WebKit::WebURLResponse::setSuggestedFileName):
(WebKit::WebURLResponse::httpStatusCode):
(WebKit::WebURLResponse::setHTTPStatusCode):
(WebKit::WebURLResponse::httpStatusText):
(WebKit::WebURLResponse::setHTTPStatusText):
(WebKit::WebURLResponse::httpHeaderField):
(WebKit::WebURLResponse::setHTTPHeaderField):
(WebKit::WebURLResponse::addHTTPHeaderField):
(WebKit::WebURLResponse::clearHTTPHeaderField):
(WebKit::WebURLResponse::visitHTTPHeaderFields):
(WebKit::WebURLResponse::lastModifiedDate):
(WebKit::WebURLResponse::setLastModifiedDate):
(WebKit::WebURLResponse::isContentFiltered):
(WebKit::WebURLResponse::setIsContentFiltered):
(WebKit::WebURLResponse::appCacheID):
(WebKit::WebURLResponse::setAppCacheID):
(WebKit::WebURLResponse::appCacheManifestURL):
(WebKit::WebURLResponse::setAppCacheManifestURL):
(WebKit::WebURLResponse::securityInfo):
(WebKit::WebURLResponse::setSecurityInfo):
(WebKit::WebURLResponse::toMutableResourceResponse):
(WebKit::WebURLResponse::toResourceResponse):
* src/WebURLResponsePrivate.h: Added.
(WebKit::WebURLResponsePrivate::WebURLResponsePrivate):
* src/WebViewImpl.cpp: Added.
(WebKit::):
(WebKit::WebView::create):
(WebKit::WebView::updateVisitedLinkState):
(WebKit::WebView::resetVisitedLinkState):
(WebKit::WebViewImpl::initializeMainFrame):
(WebKit::WebViewImpl::WebViewImpl):
(WebKit::WebViewImpl::~WebViewImpl):
(WebKit::WebViewImpl::theme):
(WebKit::WebViewImpl::mainFrameImpl):
(WebKit::WebViewImpl::tabKeyCyclesThroughElements):
(WebKit::WebViewImpl::setTabKeyCyclesThroughElements):
(WebKit::WebViewImpl::mouseMove):
(WebKit::WebViewImpl::mouseLeave):
(WebKit::WebViewImpl::mouseDown):
(WebKit::WebViewImpl::mouseContextMenu):
(WebKit::WebViewImpl::mouseUp):
(WebKit::WebViewImpl::mouseWheel):
(WebKit::WebViewImpl::keyEvent):
(WebKit::WebViewImpl::autocompleteHandleKeyEvent):
(WebKit::WebViewImpl::charEvent):
(WebKit::WebViewImpl::sendContextMenuEvent):
(WebKit::WebViewImpl::keyEventDefault):
(WebKit::WebViewImpl::scrollViewWithKeyboard):
(WebKit::WebViewImpl::propagateScroll):
(WebKit::WebViewImpl::focusedWebCoreFrame):
(WebKit::WebViewImpl::fromPage):
(WebKit::WebViewImpl::close):
(WebKit::WebViewImpl::resize):
(WebKit::WebViewImpl::layout):
(WebKit::WebViewImpl::paint):
(WebKit::WebViewImpl::handleInputEvent):
(WebKit::WebViewImpl::mouseCaptureLost):
(WebKit::WebViewImpl::setFocus):
(WebKit::WebViewImpl::handleCompositionEvent):
(WebKit::WebViewImpl::queryCompositionStatus):
(WebKit::WebViewImpl::setTextDirection):
(WebKit::WebViewImpl::settings):
(WebKit::WebViewImpl::pageEncoding):
(WebKit::WebViewImpl::setPageEncoding):
(WebKit::WebViewImpl::dispatchBeforeUnloadEvent):
(WebKit::WebViewImpl::dispatchUnloadEvent):
(WebKit::WebViewImpl::mainFrame):
(WebKit::WebViewImpl::findFrameByName):
(WebKit::WebViewImpl::focusedFrame):
(WebKit::WebViewImpl::setFocusedFrame):
(WebKit::WebViewImpl::setInitialFocus):
(WebKit::WebViewImpl::clearFocusedNode):
(WebKit::WebViewImpl::zoomIn):
(WebKit::WebViewImpl::zoomOut):
(WebKit::WebViewImpl::zoomDefault):
(WebKit::WebViewImpl::performMediaPlayerAction):
(WebKit::WebViewImpl::copyImageAt):
(WebKit::WebViewImpl::dragSourceEndedAt):
(WebKit::WebViewImpl::dragSourceMovedTo):
(WebKit::WebViewImpl::dragSourceSystemDragEnded):
(WebKit::WebViewImpl::dragTargetDragEnter):
(WebKit::WebViewImpl::dragTargetDragOver):
(WebKit::WebViewImpl::dragTargetDragLeave):
(WebKit::WebViewImpl::dragTargetDrop):
(WebKit::WebViewImpl::dragIdentity):
(WebKit::WebViewImpl::inspectElementAt):
(WebKit::WebViewImpl::inspectorSettings):
(WebKit::WebViewImpl::setInspectorSettings):
(WebKit::WebViewImpl::devToolsAgent):
(WebKit::WebViewImpl::setDevToolsAgent):
(WebKit::WebViewImpl::accessibilityObject):
(WebKit::WebViewImpl::applyAutofillSuggestions):
(WebKit::WebViewImpl::hideAutofillPopup):
(WebKit::WebViewImpl::setDropEffect):
(WebKit::WebViewImpl::setIsTransparent):
(WebKit::WebViewImpl::isTransparent):
(WebKit::WebViewImpl::setIsActive):
(WebKit::WebViewImpl::isActive):
(WebKit::WebViewImpl::didCommitLoad):
(WebKit::WebViewImpl::navigationPolicyFromMouseEvent):
(WebKit::WebViewImpl::startDragging):
(WebKit::WebViewImpl::setCurrentHistoryItem):
(WebKit::WebViewImpl::previousHistoryItem):
(WebKit::WebViewImpl::observeNewNavigation):
(WebKit::WebViewImpl::hideAutoCompletePopup):
(WebKit::WebViewImpl::autoCompletePopupDidHide):
(WebKit::WebViewImpl::setIgnoreInputEvents):
(WebKit::WebViewImpl::notificationPresenterImpl):
(WebKit::WebViewImpl::refreshAutofillPopup):
(WebKit::WebViewImpl::focusedWebCoreNode):
(WebKit::WebViewImpl::hitTestResultForWindowPos):
(WebKit::WebViewImpl::setTabsToLinks):
(WebKit::WebViewImpl::tabsToLinks):
* src/WebViewImpl.h: Added.
(WebKit::WebViewImpl::size):
(WebKit::WebViewImpl::devToolsAgentPrivate):
(WebKit::WebViewImpl::lastMouseDownPoint):
(WebKit::WebViewImpl::client):
(WebKit::WebViewImpl::page):
(WebKit::WebViewImpl::contextMenuAllowed):
(WebKit::WebViewImpl::setInitialNavigationPolicy):
(WebKit::WebViewImpl::initialNavigationPolicy):
(WebKit::WebViewImpl::currentInputEvent):
(WebKit::WebViewImpl::):
git-svn-id: http://svn.webkit.org/repository/webkit/trunk@50739 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/WebKit/chromium/ChangeLog b/WebKit/chromium/ChangeLog
index 8cf5495..509fefa 100644
--- a/WebKit/chromium/ChangeLog
+++ b/WebKit/chromium/ChangeLog
@@ -1,3 +1,211 @@
+2009-11-10 Yaar Schnitman <yaar at chromium.org>
+
+ Reviewed by Dimitri Glazkov.
+
+ Up-streaming Chromium API src files: WebString...WebViewImpl
+
+ https://bugs.webkit.org/show_bug.cgi?id=31276
+
+ * src/WebString.cpp: Added.
+ (WebKit::WebString::reset):
+ (WebKit::WebString::assign):
+ (WebKit::WebString::length):
+ (WebKit::WebString::data):
+ (WebKit::WebString::utf8):
+ (WebKit::WebString::fromUTF8):
+ (WebKit::WebString::WebString):
+ (WebKit::WebString::operator=):
+ (WebKit::WebString::operator WebCore::String):
+ (WebKit::WebString::operator WebCore::AtomicString):
+ * src/WebURL.cpp: Added.
+ (WebKit::WebURL::WebURL):
+ (WebKit::WebURL::operator=):
+ (WebKit::WebURL::operator WebCore::KURL):
+ * src/WebURLError.cpp: Added.
+ (WebKit::WebURLError::WebURLError):
+ (WebKit::WebURLError::operator=):
+ (WebKit::WebURLError::operator ResourceError):
+ * src/WebURLRequest.cpp: Added.
+ (WebKit::WebURLRequestPrivateImpl::WebURLRequestPrivateImpl):
+ (WebKit::WebURLRequestPrivateImpl::dispose):
+ (WebKit::WebURLRequest::initialize):
+ (WebKit::WebURLRequest::reset):
+ (WebKit::WebURLRequest::assign):
+ (WebKit::WebURLRequest::isNull):
+ (WebKit::WebURLRequest::url):
+ (WebKit::WebURLRequest::setURL):
+ (WebKit::WebURLRequest::firstPartyForCookies):
+ (WebKit::WebURLRequest::setFirstPartyForCookies):
+ (WebKit::WebURLRequest::allowCookies):
+ (WebKit::WebURLRequest::setAllowCookies):
+ (WebKit::WebURLRequest::allowStoredCredentials):
+ (WebKit::WebURLRequest::setAllowStoredCredentials):
+ (WebKit::WebURLRequest::cachePolicy):
+ (WebKit::WebURLRequest::setCachePolicy):
+ (WebKit::WebURLRequest::httpMethod):
+ (WebKit::WebURLRequest::setHTTPMethod):
+ (WebKit::WebURLRequest::httpHeaderField):
+ (WebKit::WebURLRequest::setHTTPHeaderField):
+ (WebKit::WebURLRequest::addHTTPHeaderField):
+ (WebKit::WebURLRequest::clearHTTPHeaderField):
+ (WebKit::WebURLRequest::visitHTTPHeaderFields):
+ (WebKit::WebURLRequest::httpBody):
+ (WebKit::WebURLRequest::setHTTPBody):
+ (WebKit::WebURLRequest::reportUploadProgress):
+ (WebKit::WebURLRequest::setReportUploadProgress):
+ (WebKit::WebURLRequest::targetType):
+ (WebKit::WebURLRequest::setTargetType):
+ (WebKit::WebURLRequest::requestorID):
+ (WebKit::WebURLRequest::setRequestorID):
+ (WebKit::WebURLRequest::requestorProcessID):
+ (WebKit::WebURLRequest::setRequestorProcessID):
+ (WebKit::WebURLRequest::appCacheHostID):
+ (WebKit::WebURLRequest::setAppCacheHostID):
+ (WebKit::WebURLRequest::toMutableResourceRequest):
+ (WebKit::WebURLRequest::toResourceRequest):
+ * src/WebURLRequestPrivate.h: Added.
+ (WebKit::WebURLRequestPrivate::WebURLRequestPrivate):
+ * src/WebURLResponse.cpp: Added.
+ (WebKit::WebURLResponsePrivateImpl::WebURLResponsePrivateImpl):
+ (WebKit::WebURLResponsePrivateImpl::dispose):
+ (WebKit::WebURLResponse::initialize):
+ (WebKit::WebURLResponse::reset):
+ (WebKit::WebURLResponse::assign):
+ (WebKit::WebURLResponse::isNull):
+ (WebKit::WebURLResponse::url):
+ (WebKit::WebURLResponse::setURL):
+ (WebKit::WebURLResponse::mimeType):
+ (WebKit::WebURLResponse::setMIMEType):
+ (WebKit::WebURLResponse::expectedContentLength):
+ (WebKit::WebURLResponse::setExpectedContentLength):
+ (WebKit::WebURLResponse::textEncodingName):
+ (WebKit::WebURLResponse::setTextEncodingName):
+ (WebKit::WebURLResponse::suggestedFileName):
+ (WebKit::WebURLResponse::setSuggestedFileName):
+ (WebKit::WebURLResponse::httpStatusCode):
+ (WebKit::WebURLResponse::setHTTPStatusCode):
+ (WebKit::WebURLResponse::httpStatusText):
+ (WebKit::WebURLResponse::setHTTPStatusText):
+ (WebKit::WebURLResponse::httpHeaderField):
+ (WebKit::WebURLResponse::setHTTPHeaderField):
+ (WebKit::WebURLResponse::addHTTPHeaderField):
+ (WebKit::WebURLResponse::clearHTTPHeaderField):
+ (WebKit::WebURLResponse::visitHTTPHeaderFields):
+ (WebKit::WebURLResponse::lastModifiedDate):
+ (WebKit::WebURLResponse::setLastModifiedDate):
+ (WebKit::WebURLResponse::isContentFiltered):
+ (WebKit::WebURLResponse::setIsContentFiltered):
+ (WebKit::WebURLResponse::appCacheID):
+ (WebKit::WebURLResponse::setAppCacheID):
+ (WebKit::WebURLResponse::appCacheManifestURL):
+ (WebKit::WebURLResponse::setAppCacheManifestURL):
+ (WebKit::WebURLResponse::securityInfo):
+ (WebKit::WebURLResponse::setSecurityInfo):
+ (WebKit::WebURLResponse::toMutableResourceResponse):
+ (WebKit::WebURLResponse::toResourceResponse):
+ * src/WebURLResponsePrivate.h: Added.
+ (WebKit::WebURLResponsePrivate::WebURLResponsePrivate):
+ * src/WebViewImpl.cpp: Added.
+ (WebKit::):
+ (WebKit::WebView::create):
+ (WebKit::WebView::updateVisitedLinkState):
+ (WebKit::WebView::resetVisitedLinkState):
+ (WebKit::WebViewImpl::initializeMainFrame):
+ (WebKit::WebViewImpl::WebViewImpl):
+ (WebKit::WebViewImpl::~WebViewImpl):
+ (WebKit::WebViewImpl::theme):
+ (WebKit::WebViewImpl::mainFrameImpl):
+ (WebKit::WebViewImpl::tabKeyCyclesThroughElements):
+ (WebKit::WebViewImpl::setTabKeyCyclesThroughElements):
+ (WebKit::WebViewImpl::mouseMove):
+ (WebKit::WebViewImpl::mouseLeave):
+ (WebKit::WebViewImpl::mouseDown):
+ (WebKit::WebViewImpl::mouseContextMenu):
+ (WebKit::WebViewImpl::mouseUp):
+ (WebKit::WebViewImpl::mouseWheel):
+ (WebKit::WebViewImpl::keyEvent):
+ (WebKit::WebViewImpl::autocompleteHandleKeyEvent):
+ (WebKit::WebViewImpl::charEvent):
+ (WebKit::WebViewImpl::sendContextMenuEvent):
+ (WebKit::WebViewImpl::keyEventDefault):
+ (WebKit::WebViewImpl::scrollViewWithKeyboard):
+ (WebKit::WebViewImpl::propagateScroll):
+ (WebKit::WebViewImpl::focusedWebCoreFrame):
+ (WebKit::WebViewImpl::fromPage):
+ (WebKit::WebViewImpl::close):
+ (WebKit::WebViewImpl::resize):
+ (WebKit::WebViewImpl::layout):
+ (WebKit::WebViewImpl::paint):
+ (WebKit::WebViewImpl::handleInputEvent):
+ (WebKit::WebViewImpl::mouseCaptureLost):
+ (WebKit::WebViewImpl::setFocus):
+ (WebKit::WebViewImpl::handleCompositionEvent):
+ (WebKit::WebViewImpl::queryCompositionStatus):
+ (WebKit::WebViewImpl::setTextDirection):
+ (WebKit::WebViewImpl::settings):
+ (WebKit::WebViewImpl::pageEncoding):
+ (WebKit::WebViewImpl::setPageEncoding):
+ (WebKit::WebViewImpl::dispatchBeforeUnloadEvent):
+ (WebKit::WebViewImpl::dispatchUnloadEvent):
+ (WebKit::WebViewImpl::mainFrame):
+ (WebKit::WebViewImpl::findFrameByName):
+ (WebKit::WebViewImpl::focusedFrame):
+ (WebKit::WebViewImpl::setFocusedFrame):
+ (WebKit::WebViewImpl::setInitialFocus):
+ (WebKit::WebViewImpl::clearFocusedNode):
+ (WebKit::WebViewImpl::zoomIn):
+ (WebKit::WebViewImpl::zoomOut):
+ (WebKit::WebViewImpl::zoomDefault):
+ (WebKit::WebViewImpl::performMediaPlayerAction):
+ (WebKit::WebViewImpl::copyImageAt):
+ (WebKit::WebViewImpl::dragSourceEndedAt):
+ (WebKit::WebViewImpl::dragSourceMovedTo):
+ (WebKit::WebViewImpl::dragSourceSystemDragEnded):
+ (WebKit::WebViewImpl::dragTargetDragEnter):
+ (WebKit::WebViewImpl::dragTargetDragOver):
+ (WebKit::WebViewImpl::dragTargetDragLeave):
+ (WebKit::WebViewImpl::dragTargetDrop):
+ (WebKit::WebViewImpl::dragIdentity):
+ (WebKit::WebViewImpl::inspectElementAt):
+ (WebKit::WebViewImpl::inspectorSettings):
+ (WebKit::WebViewImpl::setInspectorSettings):
+ (WebKit::WebViewImpl::devToolsAgent):
+ (WebKit::WebViewImpl::setDevToolsAgent):
+ (WebKit::WebViewImpl::accessibilityObject):
+ (WebKit::WebViewImpl::applyAutofillSuggestions):
+ (WebKit::WebViewImpl::hideAutofillPopup):
+ (WebKit::WebViewImpl::setDropEffect):
+ (WebKit::WebViewImpl::setIsTransparent):
+ (WebKit::WebViewImpl::isTransparent):
+ (WebKit::WebViewImpl::setIsActive):
+ (WebKit::WebViewImpl::isActive):
+ (WebKit::WebViewImpl::didCommitLoad):
+ (WebKit::WebViewImpl::navigationPolicyFromMouseEvent):
+ (WebKit::WebViewImpl::startDragging):
+ (WebKit::WebViewImpl::setCurrentHistoryItem):
+ (WebKit::WebViewImpl::previousHistoryItem):
+ (WebKit::WebViewImpl::observeNewNavigation):
+ (WebKit::WebViewImpl::hideAutoCompletePopup):
+ (WebKit::WebViewImpl::autoCompletePopupDidHide):
+ (WebKit::WebViewImpl::setIgnoreInputEvents):
+ (WebKit::WebViewImpl::notificationPresenterImpl):
+ (WebKit::WebViewImpl::refreshAutofillPopup):
+ (WebKit::WebViewImpl::focusedWebCoreNode):
+ (WebKit::WebViewImpl::hitTestResultForWindowPos):
+ (WebKit::WebViewImpl::setTabsToLinks):
+ (WebKit::WebViewImpl::tabsToLinks):
+ * src/WebViewImpl.h: Added.
+ (WebKit::WebViewImpl::size):
+ (WebKit::WebViewImpl::devToolsAgentPrivate):
+ (WebKit::WebViewImpl::lastMouseDownPoint):
+ (WebKit::WebViewImpl::client):
+ (WebKit::WebViewImpl::page):
+ (WebKit::WebViewImpl::contextMenuAllowed):
+ (WebKit::WebViewImpl::setInitialNavigationPolicy):
+ (WebKit::WebViewImpl::initialNavigationPolicy):
+ (WebKit::WebViewImpl::currentInputEvent):
+ (WebKit::WebViewImpl::):
+
2009-11-09 Nate Chapin <japhet at chromium.org>
Reviewed by Dimitri Glazkov.
diff --git a/WebKit/chromium/src/WebString.cpp b/WebKit/chromium/src/WebString.cpp
new file mode 100644
index 0000000..f45e05f
--- /dev/null
+++ b/WebKit/chromium/src/WebString.cpp
@@ -0,0 +1,134 @@
+/*
+ * 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 "WebString.h"
+
+#include "AtomicString.h"
+#include "CString.h"
+#include "PlatformString.h"
+
+#include "WebCString.h"
+
+namespace WebKit {
+
+class WebStringPrivate : public WebCore::StringImpl {
+};
+
+void WebString::reset()
+{
+ if (m_private) {
+ m_private->deref();
+ m_private = 0;
+ }
+}
+
+void WebString::assign(const WebString& other)
+{
+ assign(const_cast<WebStringPrivate*>(other.m_private));
+}
+
+void WebString::assign(const WebUChar* data, size_t length)
+{
+ assign(static_cast<WebStringPrivate*>(
+ WebCore::StringImpl::create(data, length).get()));
+}
+
+size_t WebString::length() const
+{
+ return m_private ? const_cast<WebStringPrivate*>(m_private)->length() : 0;
+}
+
+const WebUChar* WebString::data() const
+{
+ return m_private ? const_cast<WebStringPrivate*>(m_private)->characters() : 0;
+}
+
+WebCString WebString::utf8() const
+{
+ return WebCore::String(m_private).utf8();
+}
+
+WebString WebString::fromUTF8(const char* data, size_t length)
+{
+ return WebCore::String::fromUTF8(data, length);
+}
+
+WebString WebString::fromUTF8(const char* data)
+{
+ return WebCore::String::fromUTF8(data);
+}
+
+WebString::WebString(const WebCore::String& s)
+ : m_private(static_cast<WebStringPrivate*>(s.impl()))
+{
+ if (m_private)
+ m_private->ref();
+}
+
+WebString& WebString::operator=(const WebCore::String& s)
+{
+ assign(static_cast<WebStringPrivate*>(s.impl()));
+ return *this;
+}
+
+WebString::operator WebCore::String() const
+{
+ return m_private;
+}
+
+WebString::WebString(const WebCore::AtomicString& s)
+ : m_private(0)
+{
+ assign(s.string());
+}
+
+WebString& WebString::operator=(const WebCore::AtomicString& s)
+{
+ assign(s.string());
+ return *this;
+}
+
+WebString::operator WebCore::AtomicString() const
+{
+ return WebCore::AtomicString(static_cast<WebCore::StringImpl *>(m_private));
+}
+
+void WebString::assign(WebStringPrivate* p)
+{
+ // Take care to handle the case where m_private == p
+ if (p)
+ p->ref();
+ if (m_private)
+ m_private->deref();
+ m_private = p;
+}
+
+} // namespace WebKit
diff --git a/WebKit/chromium/src/WebURL.cpp b/WebKit/chromium/src/WebURL.cpp
new file mode 100644
index 0000000..feb92c1
--- /dev/null
+++ b/WebKit/chromium/src/WebURL.cpp
@@ -0,0 +1,58 @@
+/*
+ * 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 "WebURL.h"
+
+#include "KURL.h"
+
+namespace WebKit {
+
+WebURL::WebURL(const WebCore::KURL& url)
+ : m_spec(url.utf8String())
+ , m_parsed(url.parsed())
+ , m_isValid(url.isValid())
+{
+}
+
+WebURL& WebURL::operator=(const WebCore::KURL& url)
+{
+ m_spec = url.utf8String();
+ m_parsed = url.parsed();
+ m_isValid = url.isValid();
+ return *this;
+}
+
+WebURL::operator WebCore::KURL() const
+{
+ return WebCore::KURL(m_spec, m_parsed, m_isValid);
+}
+
+} // namespace WebKit
diff --git a/WebKit/chromium/src/WebURLError.cpp b/WebKit/chromium/src/WebURLError.cpp
new file mode 100644
index 0000000..a038aee
--- /dev/null
+++ b/WebKit/chromium/src/WebURLError.cpp
@@ -0,0 +1,69 @@
+/*
+ * 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 "WebURLError.h"
+
+#include "CString.h"
+#include "KURL.h"
+#include "ResourceError.h"
+
+using namespace WebCore;
+
+namespace WebKit {
+
+WebURLError::WebURLError(const ResourceError& error)
+{
+ *this = error;
+}
+
+WebURLError& WebURLError::operator=(const ResourceError& error)
+{
+ if (error.isNull())
+ *this = WebURLError();
+ else {
+ domain = error.domain();
+ reason = error.errorCode();
+ unreachableURL = KURL(ParsedURLString, error.failingURL());
+ }
+ return *this;
+}
+
+WebURLError::operator ResourceError() const
+{
+ if (!reason)
+ return ResourceError();
+ CString spec = unreachableURL.spec();
+ return ResourceError(domain, reason,
+ String::fromUTF8(spec.data(), spec.length()),
+ String());
+}
+
+} // namespace WebKit
diff --git a/WebKit/chromium/src/WebURLRequest.cpp b/WebKit/chromium/src/WebURLRequest.cpp
new file mode 100644
index 0000000..46fa842
--- /dev/null
+++ b/WebKit/chromium/src/WebURLRequest.cpp
@@ -0,0 +1,265 @@
+/*
+ * 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 "WebURLRequest.h"
+
+#include "ResourceRequest.h"
+
+#include "WebHTTPBody.h"
+#include "WebHTTPHeaderVisitor.h"
+#include "WebURL.h"
+#include "WebURLRequestPrivate.h"
+
+using namespace WebCore;
+
+namespace WebKit {
+
+// The standard implementation of WebURLRequestPrivate, which maintains
+// ownership of a ResourceRequest instance.
+class WebURLRequestPrivateImpl : public WebURLRequestPrivate {
+public:
+ WebURLRequestPrivateImpl()
+ {
+ m_resourceRequest = &m_resourceRequestAllocation;
+ }
+
+ WebURLRequestPrivateImpl(const WebURLRequestPrivate* p)
+ : m_resourceRequestAllocation(*p->m_resourceRequest)
+ {
+ m_resourceRequest = &m_resourceRequestAllocation;
+ }
+
+ virtual void dispose() { delete this; }
+
+ ResourceRequest m_resourceRequestAllocation;
+};
+
+void WebURLRequest::initialize()
+{
+ assign(new WebURLRequestPrivateImpl());
+}
+
+void WebURLRequest::reset()
+{
+ assign(0);
+}
+
+void WebURLRequest::assign(const WebURLRequest& r)
+{
+ if (&r != this)
+ assign(r.m_private ? new WebURLRequestPrivateImpl(r.m_private) : 0);
+}
+
+bool WebURLRequest::isNull() const
+{
+ return !m_private || m_private->m_resourceRequest->isNull();
+}
+
+WebURL WebURLRequest::url() const
+{
+ return m_private->m_resourceRequest->url();
+}
+
+void WebURLRequest::setURL(const WebURL& url)
+{
+ m_private->m_resourceRequest->setURL(url);
+}
+
+WebURL WebURLRequest::firstPartyForCookies() const
+{
+ return m_private->m_resourceRequest->firstPartyForCookies();
+}
+
+void WebURLRequest::setFirstPartyForCookies(const WebURL& firstPartyForCookies)
+{
+ m_private->m_resourceRequest->setFirstPartyForCookies(firstPartyForCookies);
+}
+
+bool WebURLRequest::allowCookies() const
+{
+ return m_private->m_resourceRequest->allowCookies();
+}
+
+void WebURLRequest::setAllowCookies(bool allowCookies)
+{
+ m_private->m_resourceRequest->setAllowCookies(allowCookies);
+}
+
+bool WebURLRequest::allowStoredCredentials() const
+{
+ return m_private->m_allowStoredCredentials;
+}
+
+void WebURLRequest::setAllowStoredCredentials(bool allowStoredCredentials)
+{
+ m_private->m_allowStoredCredentials = allowStoredCredentials;
+}
+
+WebURLRequest::CachePolicy WebURLRequest::cachePolicy() const
+{
+ return static_cast<WebURLRequest::CachePolicy>(
+ m_private->m_resourceRequest->cachePolicy());
+}
+
+void WebURLRequest::setCachePolicy(CachePolicy cachePolicy)
+{
+ m_private->m_resourceRequest->setCachePolicy(
+ static_cast<ResourceRequestCachePolicy>(cachePolicy));
+}
+
+WebString WebURLRequest::httpMethod() const
+{
+ return m_private->m_resourceRequest->httpMethod();
+}
+
+void WebURLRequest::setHTTPMethod(const WebString& httpMethod)
+{
+ m_private->m_resourceRequest->setHTTPMethod(httpMethod);
+}
+
+WebString WebURLRequest::httpHeaderField(const WebString& name) const
+{
+ return m_private->m_resourceRequest->httpHeaderField(name);
+}
+
+void WebURLRequest::setHTTPHeaderField(const WebString& name, const WebString& value)
+{
+ m_private->m_resourceRequest->setHTTPHeaderField(name, value);
+}
+
+void WebURLRequest::addHTTPHeaderField(const WebString& name, const WebString& value)
+{
+ m_private->m_resourceRequest->addHTTPHeaderField(name, value);
+}
+
+void WebURLRequest::clearHTTPHeaderField(const WebString& name)
+{
+ // FIXME: Add a clearHTTPHeaderField method to ResourceRequest.
+ const HTTPHeaderMap& map = m_private->m_resourceRequest->httpHeaderFields();
+ const_cast<HTTPHeaderMap*>(&map)->remove(name);
+}
+
+void WebURLRequest::visitHTTPHeaderFields(WebHTTPHeaderVisitor* visitor) const
+{
+ const HTTPHeaderMap& map = m_private->m_resourceRequest->httpHeaderFields();
+ for (HTTPHeaderMap::const_iterator it = map.begin(); it != map.end(); ++it)
+ visitor->visitHeader(it->first, it->second);
+}
+
+WebHTTPBody WebURLRequest::httpBody() const
+{
+ return WebHTTPBody(m_private->m_resourceRequest->httpBody());
+}
+
+void WebURLRequest::setHTTPBody(const WebHTTPBody& httpBody)
+{
+ m_private->m_resourceRequest->setHTTPBody(httpBody);
+}
+
+bool WebURLRequest::reportUploadProgress() const
+{
+ return m_private->m_resourceRequest->reportUploadProgress();
+}
+
+void WebURLRequest::setReportUploadProgress(bool reportUploadProgress)
+{
+ m_private->m_resourceRequest->setReportUploadProgress(reportUploadProgress);
+}
+
+WebURLRequest::TargetType WebURLRequest::targetType() const
+{
+ return static_cast<TargetType>(m_private->m_resourceRequest->targetType());
+}
+
+void WebURLRequest::setTargetType(TargetType targetType)
+{
+ m_private->m_resourceRequest->setTargetType(
+ static_cast<ResourceRequest::TargetType>(targetType));
+}
+
+int WebURLRequest::requestorID() const
+{
+ return m_private->m_resourceRequest->requestorID();
+}
+
+void WebURLRequest::setRequestorID(int requestorID)
+{
+ m_private->m_resourceRequest->setRequestorID(requestorID);
+}
+
+int WebURLRequest::requestorProcessID() const
+{
+ return m_private->m_resourceRequest->requestorProcessID();
+}
+
+void WebURLRequest::setRequestorProcessID(int requestorProcessID)
+{
+ m_private->m_resourceRequest->setRequestorProcessID(requestorProcessID);
+}
+
+int WebURLRequest::appCacheHostID() const
+{
+ return m_private->m_resourceRequest->appCacheHostID();
+}
+
+void WebURLRequest::setAppCacheHostID(int appCacheHostID)
+{
+ m_private->m_resourceRequest->setAppCacheHostID(appCacheHostID);
+}
+
+ResourceRequest& WebURLRequest::toMutableResourceRequest()
+{
+ ASSERT(m_private);
+ ASSERT(m_private->m_resourceRequest);
+
+ return *m_private->m_resourceRequest;
+}
+
+const ResourceRequest& WebURLRequest::toResourceRequest() const
+{
+ ASSERT(m_private);
+ ASSERT(m_private->m_resourceRequest);
+
+ return *m_private->m_resourceRequest;
+}
+
+void WebURLRequest::assign(WebURLRequestPrivate* p)
+{
+ // Subclasses may call this directly so a self-assignment check is needed
+ // here as well as in the public assign method.
+ if (m_private == p)
+ return;
+ if (m_private)
+ m_private->dispose();
+ m_private = p;
+}
+
+} // namespace WebKit
diff --git a/WebKit/chromium/src/WebURLRequestPrivate.h b/WebKit/chromium/src/WebURLRequestPrivate.h
new file mode 100644
index 0000000..2f7c25f
--- /dev/null
+++ b/WebKit/chromium/src/WebURLRequestPrivate.h
@@ -0,0 +1,51 @@
+/*
+ * 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 WebURLRequestPrivate_h
+#define WebURLRequestPrivate_h
+
+namespace WebCore { class ResourceRequest; }
+
+namespace WebKit {
+
+class WebURLRequestPrivate {
+public:
+ WebURLRequestPrivate() : m_resourceRequest(0), m_allowStoredCredentials(true) { }
+
+ // Called by WebURLRequest when it no longer needs this object.
+ virtual void dispose() = 0;
+
+ WebCore::ResourceRequest* m_resourceRequest;
+ bool m_allowStoredCredentials;
+};
+
+} // namespace WebKit
+
+#endif
diff --git a/WebKit/chromium/src/WebURLResponse.cpp b/WebKit/chromium/src/WebURLResponse.cpp
new file mode 100644
index 0000000..49f07f9
--- /dev/null
+++ b/WebKit/chromium/src/WebURLResponse.cpp
@@ -0,0 +1,269 @@
+/*
+ * 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 "WebURLResponse.h"
+
+#include "ResourceResponse.h"
+
+#include "WebHTTPHeaderVisitor.h"
+#include "WebString.h"
+#include "WebURL.h"
+#include "WebURLResponsePrivate.h"
+
+using namespace WebCore;
+
+namespace WebKit {
+
+// The standard implementation of WebURLResponsePrivate, which maintains
+// ownership of a ResourceResponse instance.
+class WebURLResponsePrivateImpl : public WebURLResponsePrivate {
+public:
+ WebURLResponsePrivateImpl()
+ {
+ m_resourceResponse = &m_resourceResponseAllocation;
+ }
+
+ WebURLResponsePrivateImpl(const WebURLResponsePrivate* p)
+ : m_resourceResponseAllocation(*p->m_resourceResponse)
+ {
+ m_resourceResponse = &m_resourceResponseAllocation;
+ }
+
+ virtual void dispose() { delete this; }
+
+ ResourceResponse m_resourceResponseAllocation;
+};
+
+void WebURLResponse::initialize()
+{
+ assign(new WebURLResponsePrivateImpl());
+}
+
+void WebURLResponse::reset()
+{
+ assign(0);
+}
+
+void WebURLResponse::assign(const WebURLResponse& r)
+{
+ if (&r != this)
+ assign(r.m_private ? new WebURLResponsePrivateImpl(r.m_private) : 0);
+}
+
+bool WebURLResponse::isNull() const
+{
+ return !m_private || m_private->m_resourceResponse->isNull();
+}
+
+WebURL WebURLResponse::url() const
+{
+ return m_private->m_resourceResponse->url();
+}
+
+void WebURLResponse::setURL(const WebURL& url)
+{
+ m_private->m_resourceResponse->setURL(url);
+}
+
+WebString WebURLResponse::mimeType() const
+{
+ return m_private->m_resourceResponse->mimeType();
+}
+
+void WebURLResponse::setMIMEType(const WebString& mimeType)
+{
+ m_private->m_resourceResponse->setMimeType(mimeType);
+}
+
+long long WebURLResponse::expectedContentLength() const
+{
+ return m_private->m_resourceResponse->expectedContentLength();
+}
+
+void WebURLResponse::setExpectedContentLength(long long expectedContentLength)
+{
+ m_private->m_resourceResponse->setExpectedContentLength(expectedContentLength);
+}
+
+WebString WebURLResponse::textEncodingName() const
+{
+ return m_private->m_resourceResponse->textEncodingName();
+}
+
+void WebURLResponse::setTextEncodingName(const WebString& textEncodingName)
+{
+ m_private->m_resourceResponse->setTextEncodingName(textEncodingName);
+}
+
+WebString WebURLResponse::suggestedFileName() const
+{
+ return m_private->m_resourceResponse->suggestedFilename();
+}
+
+void WebURLResponse::setSuggestedFileName(const WebString& suggestedFileName)
+{
+ m_private->m_resourceResponse->setSuggestedFilename(suggestedFileName);
+}
+
+int WebURLResponse::httpStatusCode() const
+{
+ return m_private->m_resourceResponse->httpStatusCode();
+}
+
+void WebURLResponse::setHTTPStatusCode(int httpStatusCode)
+{
+ m_private->m_resourceResponse->setHTTPStatusCode(httpStatusCode);
+}
+
+WebString WebURLResponse::httpStatusText() const
+{
+ return m_private->m_resourceResponse->httpStatusText();
+}
+
+void WebURLResponse::setHTTPStatusText(const WebString& httpStatusText)
+{
+ m_private->m_resourceResponse->setHTTPStatusText(httpStatusText);
+}
+
+WebString WebURLResponse::httpHeaderField(const WebString& name) const
+{
+ return m_private->m_resourceResponse->httpHeaderField(name);
+}
+
+void WebURLResponse::setHTTPHeaderField(const WebString& name, const WebString& value)
+{
+ m_private->m_resourceResponse->setHTTPHeaderField(name, value);
+}
+
+void WebURLResponse::addHTTPHeaderField(const WebString& name, const WebString& value)
+{
+ // FIXME: Add an addHTTPHeaderField method to ResourceResponse.
+ const HTTPHeaderMap& map = m_private->m_resourceResponse->httpHeaderFields();
+ String valueStr(value);
+ pair<HTTPHeaderMap::iterator, bool> result =
+ const_cast<HTTPHeaderMap*>(&map)->add(name, valueStr);
+ if (!result.second)
+ result.first->second += ", " + valueStr;
+}
+
+void WebURLResponse::clearHTTPHeaderField(const WebString& name)
+{
+ // FIXME: Add a clearHTTPHeaderField method to ResourceResponse.
+ const HTTPHeaderMap& map = m_private->m_resourceResponse->httpHeaderFields();
+ const_cast<HTTPHeaderMap*>(&map)->remove(name);
+}
+
+void WebURLResponse::visitHTTPHeaderFields(WebHTTPHeaderVisitor* visitor) const
+{
+ const HTTPHeaderMap& map = m_private->m_resourceResponse->httpHeaderFields();
+ for (HTTPHeaderMap::const_iterator it = map.begin(); it != map.end(); ++it)
+ visitor->visitHeader(it->first, it->second);
+}
+
+double WebURLResponse::lastModifiedDate() const
+{
+ return static_cast<double>(m_private->m_resourceResponse->lastModifiedDate());
+}
+
+void WebURLResponse::setLastModifiedDate(double lastModifiedDate)
+{
+ m_private->m_resourceResponse->setLastModifiedDate(static_cast<time_t>(lastModifiedDate));
+}
+
+bool WebURLResponse::isContentFiltered() const
+{
+ return m_private->m_resourceResponse->isContentFiltered();
+}
+
+void WebURLResponse::setIsContentFiltered(bool isContentFiltered)
+{
+ m_private->m_resourceResponse->setIsContentFiltered(isContentFiltered);
+}
+
+long long WebURLResponse::appCacheID() const
+{
+ return m_private->m_resourceResponse->appCacheID();
+}
+
+void WebURLResponse::setAppCacheID(long long appCacheID)
+{
+ m_private->m_resourceResponse->setAppCacheID(appCacheID);
+}
+
+WebURL WebURLResponse::appCacheManifestURL() const
+{
+ return m_private->m_resourceResponse->appCacheManifestURL();
+}
+
+void WebURLResponse::setAppCacheManifestURL(const WebURL& url)
+{
+ m_private->m_resourceResponse->setAppCacheManifestURL(url);
+}
+
+WebCString WebURLResponse::securityInfo() const
+{
+ // FIXME: getSecurityInfo is misnamed.
+ return m_private->m_resourceResponse->getSecurityInfo();
+}
+
+void WebURLResponse::setSecurityInfo(const WebCString& securityInfo)
+{
+ m_private->m_resourceResponse->setSecurityInfo(securityInfo);
+}
+
+ResourceResponse& WebURLResponse::toMutableResourceResponse()
+{
+ ASSERT(m_private);
+ ASSERT(m_private->m_resourceResponse);
+
+ return *m_private->m_resourceResponse;
+}
+
+const ResourceResponse& WebURLResponse::toResourceResponse() const
+{
+ ASSERT(m_private);
+ ASSERT(m_private->m_resourceResponse);
+
+ return *m_private->m_resourceResponse;
+}
+
+void WebURLResponse::assign(WebURLResponsePrivate* p)
+{
+ // Subclasses may call this directly so a self-assignment check is needed
+ // here as well as in the public assign method.
+ if (m_private == p)
+ return;
+ if (m_private)
+ m_private->dispose();
+ m_private = p;
+}
+
+} // namespace WebKit
diff --git a/WebKit/chromium/src/WebURLResponsePrivate.h b/WebKit/chromium/src/WebURLResponsePrivate.h
new file mode 100644
index 0000000..716c8db
--- /dev/null
+++ b/WebKit/chromium/src/WebURLResponsePrivate.h
@@ -0,0 +1,50 @@
+/*
+ * 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 WebURLResponsePrivate_h
+#define WebURLResponsePrivate_h
+
+namespace WebCore { class ResourceResponse; }
+
+namespace WebKit {
+
+class WebURLResponsePrivate {
+public:
+ WebURLResponsePrivate() : m_resourceResponse(0) { }
+
+ // Called by WebURLResponse when it no longer needs this object.
+ virtual void dispose() = 0;
+
+ WebCore::ResourceResponse* m_resourceResponse;
+};
+
+} // namespace WebKit
+
+#endif
diff --git a/WebKit/chromium/src/WebViewImpl.cpp b/WebKit/chromium/src/WebViewImpl.cpp
new file mode 100644
index 0000000..0192c5d
--- /dev/null
+++ b/WebKit/chromium/src/WebViewImpl.cpp
@@ -0,0 +1,1786 @@
+/*
+ * 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 "WebViewImpl.h"
+
+#include "AutocompletePopupMenuClient.h"
+#include "AXObjectCache.h"
+#include "CSSStyleSelector.h"
+#include "CSSValueKeywords.h"
+#include "Cursor.h"
+#include "Document.h"
+#include "DocumentLoader.h"
+#include "DOMUtilitiesPrivate.h"
+#include "DragController.h"
+#include "DragData.h"
+#include "Editor.h"
+#include "EventHandler.h"
+#include "FocusController.h"
+#include "FontDescription.h"
+#include "FrameLoader.h"
+#include "FrameTree.h"
+#include "FrameView.h"
+#include "GraphicsContext.h"
+#include "HitTestResult.h"
+#include "HTMLInputElement.h"
+#include "HTMLMediaElement.h"
+#include "HTMLNames.h"
+#include "Image.h"
+#include "InspectorController.h"
+#include "IntRect.h"
+#include "KeyboardCodes.h"
+#include "KeyboardEvent.h"
+#include "MIMETypeRegistry.h"
+#include "NodeRenderStyle.h"
+#include "Page.h"
+#include "PageGroup.h"
+#include "Pasteboard.h"
+#include "PlatformContextSkia.h"
+#include "PlatformKeyboardEvent.h"
+#include "PlatformMouseEvent.h"
+#include "PlatformWheelEvent.h"
+#include "PluginInfoStore.h"
+#include "PopupMenuChromium.h"
+#include "PopupMenuClient.h"
+#include "RenderView.h"
+#include "ResourceHandle.h"
+#include "SecurityOrigin.h"
+#include "SelectionController.h"
+#include "Settings.h"
+#include "TypingCommand.h"
+#include "WebAccessibilityObject.h"
+#include "WebDevToolsAgentPrivate.h"
+#include "WebDragData.h"
+#include "WebFrameImpl.h"
+#include "WebInputEvent.h"
+#include "WebInputEventConversion.h"
+#include "WebMediaPlayerAction.h"
+#include "WebNode.h"
+#include "WebPoint.h"
+#include "WebPopupMenuImpl.h"
+#include "WebRect.h"
+#include "WebSettingsImpl.h"
+#include "WebString.h"
+#include "WebVector.h"
+#include "WebViewClient.h"
+
+#if PLATFORM(WIN_OS)
+#include "KeyboardCodesWin.h"
+#include "RenderThemeChromiumWin.h"
+#else
+#include "KeyboardCodesPosix.h"
+#include "RenderTheme.h"
+#endif
+
+// Get rid of WTF's pow define so we can use std::pow.
+#undef pow
+#include <cmath> // for std::pow
+
+using namespace WebCore;
+
+namespace WebKit {
+
+// Change the text zoom level by kTextSizeMultiplierRatio each time the user
+// zooms text in or out (ie., change by 20%). The min and max values limit
+// text zoom to half and 3x the original text size. These three values match
+// those in Apple's port in WebKit/WebKit/WebView/WebView.mm
+static const double textSizeMultiplierRatio = 1.2;
+static const double minTextSizeMultiplier = 0.5;
+static const double maxTextSizeMultiplier = 3.0;
+
+// The group name identifies a namespace of pages. Page group is used on OSX
+// for some programs that use HTML views to display things that don't seem like
+// web pages to the user (so shouldn't have visited link coloring). We only use
+// one page group.
+const char* pageGroupName = "default";
+
+// Ensure that the WebDragOperation enum values stay in sync with the original
+// DragOperation constants.
+#define COMPILE_ASSERT_MATCHING_ENUM(coreName) \
+ COMPILE_ASSERT(int(coreName) == int(Web##coreName), dummy##coreName)
+COMPILE_ASSERT_MATCHING_ENUM(DragOperationNone);
+COMPILE_ASSERT_MATCHING_ENUM(DragOperationCopy);
+COMPILE_ASSERT_MATCHING_ENUM(DragOperationLink);
+COMPILE_ASSERT_MATCHING_ENUM(DragOperationGeneric);
+COMPILE_ASSERT_MATCHING_ENUM(DragOperationPrivate);
+COMPILE_ASSERT_MATCHING_ENUM(DragOperationMove);
+COMPILE_ASSERT_MATCHING_ENUM(DragOperationDelete);
+COMPILE_ASSERT_MATCHING_ENUM(DragOperationEvery);
+
+// Note that focusOnShow is false so that the autocomplete popup is shown not
+// activated. We need the page to still have focus so the user can keep typing
+// while the popup is showing.
+static const PopupContainerSettings autocompletePopupSettings = {
+ false, // focusOnShow
+ false, // setTextOnIndexChange
+ false, // acceptOnAbandon
+ true, // loopSelectionNavigation
+ true, // restrictWidthOfListBox. Same as other browser (Fx, IE, and safari)
+ // For autocomplete, we use the direction of the input field as the direction
+ // of the popup items. The main reason is to keep the display of items in
+ // drop-down the same as the items in the input field.
+ PopupContainerSettings::DOMElementDirection,
+};
+
+// WebView ----------------------------------------------------------------
+
+WebView* WebView::create(WebViewClient* client)
+{
+ return new WebViewImpl(client);
+}
+
+void WebView::updateVisitedLinkState(unsigned long long linkHash)
+{
+ Page::visitedStateChanged(PageGroup::pageGroup(pageGroupName), linkHash);
+}
+
+void WebView::resetVisitedLinkState()
+{
+ Page::allVisitedStateChanged(PageGroup::pageGroup(pageGroupName));
+}
+
+void WebViewImpl::initializeMainFrame(WebFrameClient* frameClient)
+{
+ // NOTE: The WebFrameImpl takes a reference to itself within InitMainFrame
+ // and releases that reference once the corresponding Frame is destroyed.
+ RefPtr<WebFrameImpl> frame = WebFrameImpl::create(frameClient);
+
+ frame->initializeAsMainFrame(this);
+
+ // Restrict the access to the local file system
+ // (see WebView.mm WebView::_commonInitializationWithFrameName).
+ SecurityOrigin::setLocalLoadPolicy(SecurityOrigin::AllowLocalLoadsForLocalOnly);
+}
+
+WebViewImpl::WebViewImpl(WebViewClient* client)
+ : m_client(client)
+ , m_backForwardListClientImpl(this)
+ , m_chromeClientImpl(this)
+ , m_contextMenuClientImpl(this)
+ , m_dragClientImpl(this)
+ , m_editorClientImpl(this)
+ , m_inspectorClientImpl(this)
+ , m_observedNewNavigation(false)
+#ifndef NDEBUG
+ , m_newNavigationLoader(0)
+#endif
+ , m_zoomLevel(0)
+ , m_contextMenuAllowed(false)
+ , m_doingDragAndDrop(false)
+ , m_ignoreInputEvents(false)
+ , m_suppressNextKeypressEvent(false)
+ , m_initialNavigationPolicy(WebNavigationPolicyIgnore)
+ , m_imeAcceptEvents(true)
+ , m_dragTargetDispatch(false)
+ , m_dragIdentity(0)
+ , m_dropEffect(DropEffectDefault)
+ , m_operationsAllowed(WebDragOperationNone)
+ , m_dragOperation(WebDragOperationNone)
+ , m_autocompletePopupShowing(false)
+ , m_isTransparent(false)
+ , m_tabsToLinks(false)
+{
+ // WebKit/win/WebView.cpp does the same thing, except they call the
+ // KJS specific wrapper around this method. We need to have threading
+ // initialized because CollatorICU requires it.
+ WTF::initializeThreading();
+
+ // set to impossible point so we always get the first mouse pos
+ m_lastMousePosition = WebPoint(-1, -1);
+
+ // the page will take ownership of the various clients
+ m_page.set(new Page(&m_chromeClientImpl,
+ &m_contextMenuClientImpl,
+ &m_editorClientImpl,
+ &m_dragClientImpl,
+ &m_inspectorClientImpl,
+ 0));
+
+ m_page->backForwardList()->setClient(&m_backForwardListClientImpl);
+ m_page->setGroupName(pageGroupName);
+}
+
+WebViewImpl::~WebViewImpl()
+{
+ ASSERT(!m_page);
+}
+
+RenderTheme* WebViewImpl::theme() const
+{
+ return m_page.get() ? m_page->theme() : RenderTheme::defaultTheme().get();
+}
+
+WebFrameImpl* WebViewImpl::mainFrameImpl()
+{
+ return m_page.get() ? WebFrameImpl::fromFrame(m_page->mainFrame()) : 0;
+}
+
+bool WebViewImpl::tabKeyCyclesThroughElements() const
+{
+ ASSERT(m_page.get());
+ return m_page->tabKeyCyclesThroughElements();
+}
+
+void WebViewImpl::setTabKeyCyclesThroughElements(bool value)
+{
+ if (m_page)
+ m_page->setTabKeyCyclesThroughElements(value);
+}
+
+void WebViewImpl::mouseMove(const WebMouseEvent& event)
+{
+ if (!mainFrameImpl() || !mainFrameImpl()->frameView())
+ return;
+
+ m_lastMousePosition = WebPoint(event.x, event.y);
+
+ // We call mouseMoved here instead of handleMouseMovedEvent because we need
+ // our ChromeClientImpl to receive changes to the mouse position and
+ // tooltip text, and mouseMoved handles all of that.
+ mainFrameImpl()->frame()->eventHandler()->mouseMoved(
+ PlatformMouseEventBuilder(mainFrameImpl()->frameView(), event));
+}
+
+void WebViewImpl::mouseLeave(const WebMouseEvent& event)
+{
+ // This event gets sent as the main frame is closing. In that case, just
+ // ignore it.
+ if (!mainFrameImpl() || !mainFrameImpl()->frameView())
+ return;
+
+ m_client->setMouseOverURL(WebURL());
+
+ mainFrameImpl()->frame()->eventHandler()->handleMouseMoveEvent(
+ PlatformMouseEventBuilder(mainFrameImpl()->frameView(), event));
+}
+
+void WebViewImpl::mouseDown(const WebMouseEvent& event)
+{
+ if (!mainFrameImpl() || !mainFrameImpl()->frameView())
+ return;
+
+ m_lastMouseDownPoint = WebPoint(event.x, event.y);
+
+ // If a text field that has focus is clicked again, we should display the
+ // autocomplete popup.
+ RefPtr<Node> clickedNode;
+ if (event.button == WebMouseEvent::ButtonLeft) {
+ RefPtr<Node> focusedNode = focusedWebCoreNode();
+ if (focusedNode.get() && toHTMLInputElement(focusedNode.get())) {
+ IntPoint point(event.x, event.y);
+ point = m_page->mainFrame()->view()->windowToContents(point);
+ HitTestResult result(point);
+ result = m_page->mainFrame()->eventHandler()->hitTestResultAtPoint(point, false);
+ if (result.innerNonSharedNode() == focusedNode) {
+ // Already focused text field was clicked, let's remember this. If
+ // focus has not changed after the mouse event is processed, we'll
+ // trigger the autocomplete.
+ clickedNode = focusedNode;
+ }
+ }
+ }
+
+ mainFrameImpl()->frame()->eventHandler()->handleMousePressEvent(
+ PlatformMouseEventBuilder(mainFrameImpl()->frameView(), event));
+
+ if (clickedNode.get() && clickedNode == focusedWebCoreNode()) {
+ // Focus has not changed, show the autocomplete popup.
+ static_cast<EditorClientImpl*>(m_page->editorClient())->
+ showFormAutofillForNode(clickedNode.get());
+ }
+
+ // Dispatch the contextmenu event regardless of if the click was swallowed.
+ // On Windows, we handle it on mouse up, not down.
+#if PLATFORM(DARWIN)
+ if (event.button == WebMouseEvent::ButtonRight
+ || (event.button == WebMouseEvent::ButtonLeft
+ && event.modifiers & WebMouseEvent::ControlKey))
+ mouseContextMenu(event);
+#elif PLATFORM(LINUX)
+ if (event.button == WebMouseEvent::ButtonRight)
+ mouseContextMenu(event);
+#endif
+}
+
+void WebViewImpl::mouseContextMenu(const WebMouseEvent& event)
+{
+ if (!mainFrameImpl() || !mainFrameImpl()->frameView())
+ return;
+
+ m_page->contextMenuController()->clearContextMenu();
+
+ PlatformMouseEventBuilder pme(mainFrameImpl()->frameView(), event);
+
+ // Find the right target frame. See issue 1186900.
+ HitTestResult result = hitTestResultForWindowPos(pme.pos());
+ Frame* targetFrame;
+ if (result.innerNonSharedNode())
+ targetFrame = result.innerNonSharedNode()->document()->frame();
+ else
+ targetFrame = m_page->focusController()->focusedOrMainFrame();
+
+#if PLATFORM(WIN_OS)
+ targetFrame->view()->setCursor(pointerCursor());
+#endif
+
+ m_contextMenuAllowed = true;
+ targetFrame->eventHandler()->sendContextMenuEvent(pme);
+ m_contextMenuAllowed = false;
+ // Actually showing the context menu is handled by the ContextMenuClient
+ // implementation...
+}
+
+void WebViewImpl::mouseUp(const WebMouseEvent& event)
+{
+ if (!mainFrameImpl() || !mainFrameImpl()->frameView())
+ return;
+
+#if PLATFORM(LINUX)
+ // If the event was a middle click, attempt to copy text into the focused
+ // frame. We execute this before we let the page have a go at the event
+ // because the page may change what is focused during in its event handler.
+ //
+ // This code is in the mouse up handler. There is some debate about putting
+ // this here, as opposed to the mouse down handler.
+ // xterm: pastes on up.
+ // GTK: pastes on down.
+ // Firefox: pastes on up.
+ // Midori: couldn't paste at all with 0.1.2
+ //
+ // There is something of a webcompat angle to this well, as highlighted by
+ // crbug.com/14608. Pages can clear text boxes 'onclick' and, if we paste on
+ // down then the text is pasted just before the onclick handler runs and
+ // clears the text box. So it's important this happens after the
+ // handleMouseReleaseEvent() earlier in this function
+ if (event.button == WebMouseEvent::ButtonMiddle) {
+ Frame* focused = focusedWebCoreFrame();
+ IntPoint clickPoint(m_lastMouseDownPoint.x, m_lastMouseDownPoint.y);
+ clickPoint = m_page->mainFrame()->view()->windowToContents(clickPoint);
+ HitTestResult hitTestResult =
+ focused->eventHandler()->hitTestResultAtPoint(clickPoint, false, false,
+ ShouldHitTestScrollbars);
+ // We don't want to send a paste when middle clicking a scroll bar or a
+ // link (which will navigate later in the code).
+ if (!hitTestResult.scrollbar() && !hitTestResult.isLiveLink() && focused) {
+ Editor* editor = focused->editor();
+ Pasteboard* pasteboard = Pasteboard::generalPasteboard();
+ bool oldSelectionMode = pasteboard->isSelectionMode();
+ pasteboard->setSelectionMode(true);
+ editor->command(AtomicString("Paste")).execute();
+ pasteboard->setSelectionMode(oldSelectionMode);
+ }
+ }
+#endif
+
+ mouseCaptureLost();
+ mainFrameImpl()->frame()->eventHandler()->handleMouseReleaseEvent(
+ PlatformMouseEventBuilder(mainFrameImpl()->frameView(), event));
+
+#if PLATFORM(WIN_OS)
+ // Dispatch the contextmenu event regardless of if the click was swallowed.
+ // On Mac/Linux, we handle it on mouse down, not up.
+ if (event.button == WebMouseEvent::ButtonRight)
+ mouseContextMenu(event);
+#endif
+}
+
+void WebViewImpl::mouseWheel(const WebMouseWheelEvent& event)
+{
+ PlatformWheelEventBuilder platformEvent(mainFrameImpl()->frameView(), event);
+ mainFrameImpl()->frame()->eventHandler()->handleWheelEvent(platformEvent);
+}
+
+bool WebViewImpl::keyEvent(const WebKeyboardEvent& event)
+{
+ ASSERT((event.type == WebInputEvent::RawKeyDown)
+ || (event.type == WebInputEvent::KeyDown)
+ || (event.type == WebInputEvent::KeyUp));
+
+ // Please refer to the comments explaining the m_suppressNextKeypressEvent
+ // member.
+ // The m_suppressNextKeypressEvent is set if the KeyDown is handled by
+ // Webkit. A keyDown event is typically associated with a keyPress(char)
+ // event and a keyUp event. We reset this flag here as this is a new keyDown
+ // event.
+ m_suppressNextKeypressEvent = false;
+
+ // Give autocomplete a chance to consume the key events it is interested in.
+ if (autocompleteHandleKeyEvent(event))
+ return true;
+
+ Frame* frame = focusedWebCoreFrame();
+ if (!frame)
+ return false;
+
+ EventHandler* handler = frame->eventHandler();
+ if (!handler)
+ return keyEventDefault(event);
+
+#if PLATFORM(WIN_OS) || PLATFORM(LINUX)
+ if ((!event.modifiers && (event.windowsKeyCode == VKEY_APPS))
+ || ((event.modifiers == WebInputEvent::ShiftKey) && (event.windowsKeyCode == VKEY_F10))) {
+ sendContextMenuEvent(event);
+ return true;
+ }
+#endif
+
+ // It's not clear if we should continue after detecting a capslock keypress.
+ // I'll err on the side of continuing, which is the pre-existing behaviour.
+ if (event.windowsKeyCode == VKEY_CAPITAL)
+ handler->capsLockStateMayHaveChanged();
+
+ PlatformKeyboardEventBuilder evt(event);
+
+ if (handler->keyEvent(evt)) {
+ if (WebInputEvent::RawKeyDown == event.type && !evt.isSystemKey())
+ m_suppressNextKeypressEvent = true;
+ return true;
+ }
+
+ return keyEventDefault(event);
+}
+
+bool WebViewImpl::autocompleteHandleKeyEvent(const WebKeyboardEvent& event)
+{
+ if (!m_autocompletePopupShowing
+ // Home and End should be left to the text field to process.
+ || event.windowsKeyCode == VKEY_HOME
+ || event.windowsKeyCode == VKEY_END)
+ return false;
+
+ // Pressing delete triggers the removal of the selected suggestion from the DB.
+ if (event.windowsKeyCode == VKEY_DELETE
+ && m_autocompletePopup->selectedIndex() != -1) {
+ Node* node = focusedWebCoreNode();
+ if (!node || (node->nodeType() != Node::ELEMENT_NODE)) {
+ ASSERT_NOT_REACHED();
+ return false;
+ }
+ Element* element = static_cast<Element*>(node);
+ if (!element->hasLocalName(HTMLNames::inputTag)) {
+ ASSERT_NOT_REACHED();
+ return false;
+ }
+
+ int selectedIndex = m_autocompletePopup->selectedIndex();
+ HTMLInputElement* inputElement = static_cast<HTMLInputElement*>(element);
+ WebString name = inputElement->name();
+ WebString value = m_autocompletePopupClient->itemText(selectedIndex);
+ m_client->removeAutofillSuggestions(name, value);
+ // Update the entries in the currently showing popup to reflect the
+ // deletion.
+ m_autocompletePopupClient->removeItemAtIndex(selectedIndex);
+ refreshAutofillPopup();
+ return false;
+ }
+
+ if (!m_autocompletePopup->isInterestedInEventForKey(event.windowsKeyCode))
+ return false;
+
+ if (m_autocompletePopup->handleKeyEvent(PlatformKeyboardEventBuilder(event))) {
+ // We need to ignore the next Char event after this otherwise pressing
+ // enter when selecting an item in the menu will go to the page.
+ if (WebInputEvent::RawKeyDown == event.type)
+ m_suppressNextKeypressEvent = true;
+ return true;
+ }
+
+ return false;
+}
+
+bool WebViewImpl::charEvent(const WebKeyboardEvent& event)
+{
+ ASSERT(event.type == WebInputEvent::Char);
+
+ // Please refer to the comments explaining the m_suppressNextKeypressEvent
+ // member. The m_suppressNextKeypressEvent is set if the KeyDown is
+ // handled by Webkit. A keyDown event is typically associated with a
+ // keyPress(char) event and a keyUp event. We reset this flag here as it
+ // only applies to the current keyPress event.
+ if (m_suppressNextKeypressEvent) {
+ m_suppressNextKeypressEvent = false;
+ return true;
+ }
+
+ Frame* frame = focusedWebCoreFrame();
+ if (!frame)
+ return false;
+
+ EventHandler* handler = frame->eventHandler();
+ if (!handler)
+ return keyEventDefault(event);
+
+ PlatformKeyboardEventBuilder evt(event);
+ if (!evt.isCharacterKey())
+ return true;
+
+ // Safari 3.1 does not pass off windows system key messages (WM_SYSCHAR) to
+ // the eventHandler::keyEvent. We mimic this behavior on all platforms since
+ // for now we are converting other platform's key events to windows key
+ // events.
+ if (evt.isSystemKey())
+ return handler->handleAccessKey(evt);
+
+ if (!handler->keyEvent(evt))
+ return keyEventDefault(event);
+
+ return true;
+}
+
+// The WebViewImpl::SendContextMenuEvent function is based on the Webkit
+// function
+// bool WebView::handleContextMenuEvent(WPARAM wParam, LPARAM lParam) in
+// webkit\webkit\win\WebView.cpp. The only significant change in this
+// function is the code to convert from a Keyboard event to the Right
+// Mouse button up event.
+//
+// This function is an ugly copy/paste and should be cleaned up when the
+// WebKitWin version is cleaned: https://bugs.webkit.org/show_bug.cgi?id=20438
+#if PLATFORM(WIN_OS) || PLATFORM(LINUX)
+// FIXME: implement on Mac
+bool WebViewImpl::sendContextMenuEvent(const WebKeyboardEvent& event)
+{
+ static const int kContextMenuMargin = 1;
+ Frame* mainFrameImpl = page()->mainFrame();
+ FrameView* view = mainFrameImpl->view();
+ if (!view)
+ return false;
+
+ IntPoint coords(-1, -1);
+#if PLATFORM(WIN_OS)
+ int rightAligned = ::GetSystemMetrics(SM_MENUDROPALIGNMENT);
+#else
+ int rightAligned = 0;
+#endif
+ IntPoint location;
+
+ // The context menu event was generated from the keyboard, so show the
+ // context menu by the current selection.
+ Position start = mainFrameImpl->selection()->selection().start();
+ Position end = mainFrameImpl->selection()->selection().end();
+
+ if (!start.node() || !end.node()) {
+ location = IntPoint(
+ rightAligned ? view->contentsWidth() - kContextMenuMargin : kContextMenuMargin,
+ kContextMenuMargin);
+ } else {
+ RenderObject* renderer = start.node()->renderer();
+ if (!renderer)
+ return false;
+
+ RefPtr<Range> selection = mainFrameImpl->selection()->toNormalizedRange();
+ IntRect firstRect = mainFrameImpl->firstRectForRange(selection.get());
+
+ int x = rightAligned ? firstRect.right() : firstRect.x();
+ location = IntPoint(x, firstRect.bottom());
+ }
+
+ location = view->contentsToWindow(location);
+ // FIXME: The IntSize(0, -1) is a hack to get the hit-testing to result in
+ // the selected element. Ideally we'd have the position of a context menu
+ // event be separate from its target node.
+ coords = location + IntSize(0, -1);
+
+ // The contextMenuController() holds onto the last context menu that was
+ // popped up on the page until a new one is created. We need to clear
+ // this menu before propagating the event through the DOM so that we can
+ // detect if we create a new menu for this event, since we won't create
+ // a new menu if the DOM swallows the event and the defaultEventHandler does
+ // not run.
+ page()->contextMenuController()->clearContextMenu();
+
+ Frame* focusedFrame = page()->focusController()->focusedOrMainFrame();
+ focusedFrame->view()->setCursor(pointerCursor());
+ WebMouseEvent mouseEvent;
+ mouseEvent.button = WebMouseEvent::ButtonRight;
+ mouseEvent.x = coords.x();
+ mouseEvent.y = coords.y();
+ mouseEvent.type = WebInputEvent::MouseUp;
+
+ PlatformMouseEventBuilder platformEvent(view, mouseEvent);
+
+ m_contextMenuAllowed = true;
+ bool handled = focusedFrame->eventHandler()->sendContextMenuEvent(platformEvent);
+ m_contextMenuAllowed = false;
+ return handled;
+}
+#endif
+
+bool WebViewImpl::keyEventDefault(const WebKeyboardEvent& event)
+{
+ Frame* frame = focusedWebCoreFrame();
+ if (!frame)
+ return false;
+
+ switch (event.type) {
+ case WebInputEvent::Char:
+ if (event.windowsKeyCode == VKEY_SPACE) {
+ int keyCode = ((event.modifiers & WebInputEvent::ShiftKey) ? VKEY_PRIOR : VKEY_NEXT);
+ return scrollViewWithKeyboard(keyCode, event.modifiers);
+ }
+ break;
+ case WebInputEvent::RawKeyDown:
+ if (event.modifiers == WebInputEvent::ControlKey) {
+ switch (event.windowsKeyCode) {
+ case 'A':
+ focusedFrame()->executeCommand(WebString::fromUTF8("SelectAll"));
+ return true;
+ case VKEY_INSERT:
+ case 'C':
+ focusedFrame()->executeCommand(WebString::fromUTF8("Copy"));
+ return true;
+ // Match FF behavior in the sense that Ctrl+home/end are the only Ctrl
+ // key combinations which affect scrolling. Safari is buggy in the
+ // sense that it scrolls the page for all Ctrl+scrolling key
+ // combinations. For e.g. Ctrl+pgup/pgdn/up/down, etc.
+ case VKEY_HOME:
+ case VKEY_END:
+ break;
+ default:
+ return false;
+ }
+ }
+ if (!event.isSystemKey && !(event.modifiers & WebInputEvent::ShiftKey))
+ return scrollViewWithKeyboard(event.windowsKeyCode, event.modifiers);
+ break;
+ default:
+ break;
+ }
+ return false;
+}
+
+bool WebViewImpl::scrollViewWithKeyboard(int keyCode, int modifiers)
+{
+ ScrollDirection scrollDirection;
+ ScrollGranularity scrollGranularity;
+
+ switch (keyCode) {
+ case VKEY_LEFT:
+ scrollDirection = ScrollLeft;
+ scrollGranularity = ScrollByLine;
+ break;
+ case VKEY_RIGHT:
+ scrollDirection = ScrollRight;
+ scrollGranularity = ScrollByLine;
+ break;
+ case VKEY_UP:
+ scrollDirection = ScrollUp;
+ scrollGranularity = ScrollByLine;
+ break;
+ case VKEY_DOWN:
+ scrollDirection = ScrollDown;
+ scrollGranularity = ScrollByLine;
+ break;
+ case VKEY_HOME:
+ scrollDirection = ScrollUp;
+ scrollGranularity = ScrollByDocument;
+ break;
+ case VKEY_END:
+ scrollDirection = ScrollDown;
+ scrollGranularity = ScrollByDocument;
+ break;
+ case VKEY_PRIOR: // page up
+ scrollDirection = ScrollUp;
+ scrollGranularity = ScrollByPage;
+ break;
+ case VKEY_NEXT: // page down
+ scrollDirection = ScrollDown;
+ scrollGranularity = ScrollByPage;
+ break;
+ default:
+ return false;
+ }
+
+ return propagateScroll(scrollDirection, scrollGranularity);
+}
+
+bool WebViewImpl::propagateScroll(ScrollDirection scrollDirection,
+ ScrollGranularity scrollGranularity)
+{
+ Frame* frame = focusedWebCoreFrame();
+ if (!frame)
+ return false;
+
+ bool scrollHandled =
+ frame->eventHandler()->scrollOverflow(scrollDirection,
+ scrollGranularity);
+ Frame* currentFrame = frame;
+ while (!scrollHandled && currentFrame) {
+ scrollHandled = currentFrame->view()->scroll(scrollDirection,
+ scrollGranularity);
+ currentFrame = currentFrame->tree()->parent();
+ }
+ return scrollHandled;
+}
+
+Frame* WebViewImpl::focusedWebCoreFrame()
+{
+ return m_page.get() ? m_page->focusController()->focusedOrMainFrame() : 0;
+}
+
+WebViewImpl* WebViewImpl::fromPage(Page* page)
+{
+ if (!page)
+ return 0;
+
+ return static_cast<ChromeClientImpl*>(page->chrome()->client())->webView();
+}
+
+// WebWidget ------------------------------------------------------------------
+
+void WebViewImpl::close()
+{
+ RefPtr<WebFrameImpl> mainFrameImpl;
+
+ if (m_page.get()) {
+ // Initiate shutdown for the entire frameset. This will cause a lot of
+ // notifications to be sent.
+ if (m_page->mainFrame()) {
+ mainFrameImpl = WebFrameImpl::fromFrame(m_page->mainFrame());
+ m_page->mainFrame()->loader()->frameDetached();
+ }
+ m_page.clear();
+ }
+
+ // Should happen after m_page.clear().
+ if (m_devToolsAgent.get())
+ m_devToolsAgent.clear();
+
+ // We drop the client after the page has been destroyed to support the
+ // WebFrameClient::didDestroyScriptContext method.
+ if (mainFrameImpl)
+ mainFrameImpl->dropClient();
+
+ // Reset the delegate to prevent notifications being sent as we're being
+ // deleted.
+ m_client = 0;
+
+ deref(); // Balances ref() acquired in WebView::create
+}
+
+void WebViewImpl::resize(const WebSize& newSize)
+{
+ if (m_size == newSize)
+ return;
+ m_size = newSize;
+
+ if (mainFrameImpl()->frameView()) {
+ mainFrameImpl()->frameView()->resize(m_size.width, m_size.height);
+ mainFrameImpl()->frame()->eventHandler()->sendResizeEvent();
+ }
+
+ if (m_client) {
+ WebRect damagedRect(0, 0, m_size.width, m_size.height);
+ m_client->didInvalidateRect(damagedRect);
+ }
+}
+
+void WebViewImpl::layout()
+{
+ WebFrameImpl* webframe = mainFrameImpl();
+ if (webframe) {
+ // In order for our child HWNDs (NativeWindowWidgets) to update properly,
+ // they need to be told that we are updating the screen. The problem is
+ // that the native widgets need to recalculate their clip region and not
+ // overlap any of our non-native widgets. To force the resizing, call
+ // setFrameRect(). This will be a quick operation for most frames, but
+ // the NativeWindowWidgets will update a proper clipping region.
+ FrameView* view = webframe->frameView();
+ if (view)
+ view->setFrameRect(view->frameRect());
+
+ // setFrameRect may have the side-effect of causing existing page
+ // layout to be invalidated, so layout needs to be called last.
+
+ webframe->layout();
+ }
+}
+
+void WebViewImpl::paint(WebCanvas* canvas, const WebRect& rect)
+{
+ WebFrameImpl* webframe = mainFrameImpl();
+ if (webframe)
+ webframe->paint(canvas, rect);
+}
+
+// FIXME: m_currentInputEvent should be removed once ChromeClient::show() can
+// get the current-event information from WebCore.
+const WebInputEvent* WebViewImpl::m_currentInputEvent = 0;
+
+bool WebViewImpl::handleInputEvent(const WebInputEvent& inputEvent)
+{
+ // If we've started a drag and drop operation, ignore input events until
+ // we're done.
+ if (m_doingDragAndDrop)
+ return true;
+
+ if (m_ignoreInputEvents)
+ return true;
+
+ // FIXME: Remove m_currentInputEvent.
+ // This only exists to allow ChromeClient::show() to know which mouse button
+ // triggered a window.open event.
+ // Safari must perform a similar hack, ours is in our WebKit glue layer
+ // theirs is in the application. This should go when WebCore can be fixed
+ // to pass more event information to ChromeClient::show()
+ m_currentInputEvent = &inputEvent;
+
+ bool handled = true;
+
+ // FIXME: WebKit seems to always return false on mouse events processing
+ // 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));
+ break;
+
+ case WebInputEvent::MouseLeave:
+ mouseLeave(*static_cast<const WebMouseEvent*>(&inputEvent));
+ break;
+
+ case WebInputEvent::MouseWheel:
+ mouseWheel(*static_cast<const WebMouseWheelEvent*>(&inputEvent));
+ break;
+
+ case WebInputEvent::MouseDown:
+ mouseDown(*static_cast<const WebMouseEvent*>(&inputEvent));
+ break;
+
+ case WebInputEvent::MouseUp:
+ mouseUp(*static_cast<const WebMouseEvent*>(&inputEvent));
+ break;
+
+ case WebInputEvent::RawKeyDown:
+ case WebInputEvent::KeyDown:
+ case WebInputEvent::KeyUp:
+ handled = keyEvent(*static_cast<const WebKeyboardEvent*>(&inputEvent));
+ break;
+
+ case WebInputEvent::Char:
+ handled = charEvent(*static_cast<const WebKeyboardEvent*>(&inputEvent));
+ break;
+
+ default:
+ handled = false;
+ }
+
+ m_currentInputEvent = 0;
+
+ return handled;
+}
+
+void WebViewImpl::mouseCaptureLost()
+{
+}
+
+void WebViewImpl::setFocus(bool enable)
+{
+ m_page->focusController()->setFocused(enable);
+ if (enable) {
+ // Note that we don't call setActive() when disabled as this cause extra
+ // focus/blur events to be dispatched.
+ m_page->focusController()->setActive(true);
+ RefPtr<Frame> focusedFrame = m_page->focusController()->focusedFrame();
+ if (focusedFrame) {
+ Node* focusedNode = focusedFrame->document()->focusedNode();
+ if (focusedNode && focusedNode->isElementNode()
+ && focusedFrame->selection()->selection().isNone()) {
+ // If the selection was cleared while the WebView was not
+ // focused, then the focus element shows with a focus ring but
+ // no caret and does respond to keyboard inputs.
+ Element* element = static_cast<Element*>(focusedNode);
+ if (element->isTextFormControl())
+ element->updateFocusAppearance(true);
+ else {
+ // updateFocusAppearance() selects all the text of
+ // contentseditable DIVs. So we set the selection explicitly
+ // instead. Note that this has the side effect of moving the
+ // caret back to the begining of the text.
+ Position position(focusedNode, 0,
+ Position::PositionIsOffsetInAnchor);
+ focusedFrame->selection()->setSelection(
+ VisibleSelection(position, SEL_DEFAULT_AFFINITY));
+ }
+ }
+ }
+ m_imeAcceptEvents = true;
+ } else {
+ hideAutoCompletePopup();
+
+ // Clear focus on the currently focused frame if any.
+ if (!m_page.get())
+ return;
+
+ Frame* frame = m_page->mainFrame();
+ if (!frame)
+ return;
+
+ RefPtr<Frame> focusedFrame = m_page->focusController()->focusedFrame();
+ if (focusedFrame.get()) {
+ // Finish an ongoing composition to delete the composition node.
+ Editor* editor = focusedFrame->editor();
+ if (editor && editor->hasComposition())
+ editor->confirmComposition();
+ m_imeAcceptEvents = false;
+ }
+ }
+}
+
+bool WebViewImpl::handleCompositionEvent(WebCompositionCommand command,
+ int cursorPosition,
+ int targetStart,
+ int targetEnd,
+ const WebString& imeString)
+{
+ Frame* focused = focusedWebCoreFrame();
+ if (!focused || !m_imeAcceptEvents)
+ return false;
+ Editor* editor = focused->editor();
+ if (!editor)
+ return false;
+ if (!editor->canEdit()) {
+ // The input focus has been moved to another WebWidget object.
+ // We should use this |editor| object only to complete the ongoing
+ // composition.
+ if (!editor->hasComposition())
+ return false;
+ }
+
+ // We should verify the parent node of this IME composition node are
+ // editable because JavaScript may delete a parent node of the composition
+ // node. In this case, WebKit crashes while deleting texts from the parent
+ // node, which doesn't exist any longer.
+ PassRefPtr<Range> range = editor->compositionRange();
+ if (range) {
+ const Node* node = range->startPosition().node();
+ if (!node || !node->isContentEditable())
+ return false;
+ }
+
+ if (command == WebCompositionCommandDiscard) {
+ // A browser process sent an IPC message which does not contain a valid
+ // string, which means an ongoing composition has been canceled.
+ // If the ongoing composition has been canceled, replace the ongoing
+ // composition string with an empty string and complete it.
+ String emptyString;
+ Vector<CompositionUnderline> emptyUnderlines;
+ editor->setComposition(emptyString, emptyUnderlines, 0, 0);
+ } else {
+ // A browser process sent an IPC message which contains a string to be
+ // displayed in this Editor object.
+ // To display the given string, set the given string to the
+ // m_compositionNode member of this Editor object and display it.
+ if (targetStart < 0)
+ targetStart = 0;
+ if (targetEnd < 0)
+ targetEnd = static_cast<int>(imeString.length());
+ String compositionString(imeString);
+ // Create custom underlines.
+ // To emphasize the selection, the selected region uses a solid black
+ // for its underline while other regions uses a pale gray for theirs.
+ Vector<CompositionUnderline> underlines(3);
+ underlines[0].startOffset = 0;
+ underlines[0].endOffset = targetStart;
+ underlines[0].thick = true;
+ underlines[0].color.setRGB(0xd3, 0xd3, 0xd3);
+ underlines[1].startOffset = targetStart;
+ underlines[1].endOffset = targetEnd;
+ underlines[1].thick = true;
+ underlines[1].color.setRGB(0x00, 0x00, 0x00);
+ underlines[2].startOffset = targetEnd;
+ underlines[2].endOffset = static_cast<int>(imeString.length());
+ underlines[2].thick = true;
+ underlines[2].color.setRGB(0xd3, 0xd3, 0xd3);
+ // When we use custom underlines, WebKit ("InlineTextBox.cpp" Line 282)
+ // prevents from writing a text in between 'selectionStart' and
+ // 'selectionEnd' somehow.
+ // Therefore, we use the 'cursorPosition' for these arguments so that
+ // there are not any characters in the above region.
+ editor->setComposition(compositionString, underlines,
+ cursorPosition, cursorPosition);
+ // The given string is a result string, which means the ongoing
+ // composition has been completed. I have to call the
+ // Editor::confirmCompletion() and complete this composition.
+ if (command == WebCompositionCommandConfirm)
+ editor->confirmComposition();
+ }
+
+ return editor->hasComposition();
+}
+
+bool WebViewImpl::queryCompositionStatus(bool* enableIME, WebRect* caretRect)
+{
+ // Store whether the selected node needs IME and the caret rectangle.
+ // This process consists of the following four steps:
+ // 1. Retrieve the selection controller of the focused frame;
+ // 2. Retrieve the caret rectangle from the controller;
+ // 3. Convert the rectangle, which is relative to the parent view, to the
+ // one relative to the client window, and;
+ // 4. Store the converted rectangle.
+ const Frame* focused = focusedWebCoreFrame();
+ if (!focused)
+ return false;
+
+ const Editor* editor = focused->editor();
+ if (!editor || !editor->canEdit())
+ return false;
+
+ SelectionController* controller = focused->selection();
+ if (!controller)
+ return false;
+
+ const Node* node = controller->start().node();
+ if (!node)
+ return false;
+
+ *enableIME = node->shouldUseInputMethod() && !controller->isInPasswordField();
+ const FrameView* view = node->document()->view();
+ if (!view)
+ return false;
+
+ *caretRect = view->contentsToWindow(controller->absoluteCaretBounds());
+ return true;
+}
+
+void WebViewImpl::setTextDirection(WebTextDirection direction)
+{
+ // The Editor::setBaseWritingDirection() function checks if we can change
+ // the text direction of the selected node and updates its DOM "dir"
+ // attribute and its CSS "direction" property.
+ // So, we just call the function as Safari does.
+ const Frame* focused = focusedWebCoreFrame();
+ if (!focused)
+ return;
+
+ Editor* editor = focused->editor();
+ if (!editor || !editor->canEdit())
+ return;
+
+ switch (direction) {
+ case WebTextDirectionDefault:
+ editor->setBaseWritingDirection(NaturalWritingDirection);
+ break;
+
+ case WebTextDirectionLeftToRight:
+ editor->setBaseWritingDirection(LeftToRightWritingDirection);
+ break;
+
+ case WebTextDirectionRightToLeft:
+ editor->setBaseWritingDirection(RightToLeftWritingDirection);
+ break;
+
+ default:
+ notImplemented();
+ break;
+ }
+}
+
+// WebView --------------------------------------------------------------------
+
+WebSettings* WebViewImpl::settings()
+{
+ if (!m_webSettings.get())
+ m_webSettings.set(new WebSettingsImpl(m_page->settings()));
+ ASSERT(m_webSettings.get());
+ return m_webSettings.get();
+}
+
+WebString WebViewImpl::pageEncoding() const
+{
+ if (!m_page.get())
+ return WebString();
+
+ return m_page->mainFrame()->loader()->encoding();
+}
+
+void WebViewImpl::setPageEncoding(const WebString& encodingName)
+{
+ if (!m_page.get())
+ return;
+
+ // Only change override encoding, don't change default encoding.
+ // Note that the new encoding must be 0 if it isn't supposed to be set.
+ String newEncodingName;
+ if (!encodingName.isEmpty())
+ newEncodingName = encodingName;
+ m_page->mainFrame()->loader()->reloadWithOverrideEncoding(newEncodingName);
+}
+
+bool WebViewImpl::dispatchBeforeUnloadEvent()
+{
+ // FIXME: This should really cause a recursive depth-first walk of all
+ // frames in the tree, calling each frame's onbeforeunload. At the moment,
+ // we're consistent with Safari 3.1, not IE/FF.
+ Frame* frame = m_page->focusController()->focusedOrMainFrame();
+ if (!frame)
+ return true;
+
+ return frame->shouldClose();
+}
+
+void WebViewImpl::dispatchUnloadEvent()
+{
+ // Run unload handlers.
+ m_page->mainFrame()->loader()->closeURL();
+}
+
+WebFrame* WebViewImpl::mainFrame()
+{
+ return mainFrameImpl();
+}
+
+WebFrame* WebViewImpl::findFrameByName(
+ const WebString& name, WebFrame* relativeToFrame)
+{
+ if (!relativeToFrame)
+ relativeToFrame = mainFrame();
+ Frame* frame = static_cast<WebFrameImpl*>(relativeToFrame)->frame();
+ frame = frame->tree()->find(name);
+ return WebFrameImpl::fromFrame(frame);
+}
+
+WebFrame* WebViewImpl::focusedFrame()
+{
+ return WebFrameImpl::fromFrame(focusedWebCoreFrame());
+}
+
+void WebViewImpl::setFocusedFrame(WebFrame* frame)
+{
+ if (!frame) {
+ // Clears the focused frame if any.
+ Frame* frame = focusedWebCoreFrame();
+ if (frame)
+ frame->selection()->setFocused(false);
+ return;
+ }
+ WebFrameImpl* frameImpl = static_cast<WebFrameImpl*>(frame);
+ Frame* webcoreFrame = frameImpl->frame();
+ webcoreFrame->page()->focusController()->setFocusedFrame(webcoreFrame);
+}
+
+void WebViewImpl::setInitialFocus(bool reverse)
+{
+ if (!m_page.get())
+ return;
+
+ // Since we don't have a keyboard event, we'll create one.
+ WebKeyboardEvent keyboardEvent;
+ keyboardEvent.type = WebInputEvent::RawKeyDown;
+ if (reverse)
+ keyboardEvent.modifiers = WebInputEvent::ShiftKey;
+
+ // VK_TAB which is only defined on Windows.
+ keyboardEvent.windowsKeyCode = 0x09;
+ PlatformKeyboardEventBuilder platformEvent(keyboardEvent);
+ RefPtr<KeyboardEvent> webkitEvent = KeyboardEvent::create(platformEvent, 0);
+ page()->focusController()->setInitialFocus(
+ reverse ? FocusDirectionBackward : FocusDirectionForward,
+ webkitEvent.get());
+}
+
+void WebViewImpl::clearFocusedNode()
+{
+ if (!m_page.get())
+ return;
+
+ RefPtr<Frame> frame = m_page->mainFrame();
+ if (!frame.get())
+ return;
+
+ RefPtr<Document> document = frame->document();
+ if (!document.get())
+ return;
+
+ RefPtr<Node> oldFocusedNode = document->focusedNode();
+
+ // Clear the focused node.
+ document->setFocusedNode(0);
+
+ if (!oldFocusedNode.get())
+ return;
+
+ // If a text field has focus, we need to make sure the selection controller
+ // knows to remove selection from it. Otherwise, the text field is still
+ // processing keyboard events even though focus has been moved to the page and
+ // keystrokes get eaten as a result.
+ if (oldFocusedNode->hasTagName(HTMLNames::textareaTag)
+ || (oldFocusedNode->hasTagName(HTMLNames::inputTag)
+ && static_cast<HTMLInputElement*>(oldFocusedNode.get())->isTextField())) {
+ // Clear the selection.
+ SelectionController* selection = frame->selection();
+ selection->clear();
+ }
+}
+
+void WebViewImpl::zoomIn(bool textOnly)
+{
+ Frame* frame = mainFrameImpl()->frame();
+ double multiplier = std::min(std::pow(textSizeMultiplierRatio, m_zoomLevel + 1),
+ maxTextSizeMultiplier);
+ float zoomFactor = static_cast<float>(multiplier);
+ if (zoomFactor != frame->zoomFactor()) {
+ ++m_zoomLevel;
+ frame->setZoomFactor(zoomFactor, textOnly);
+ }
+}
+
+void WebViewImpl::zoomOut(bool textOnly)
+{
+ Frame* frame = mainFrameImpl()->frame();
+ double multiplier = std::max(std::pow(textSizeMultiplierRatio, m_zoomLevel - 1),
+ minTextSizeMultiplier);
+ float zoomFactor = static_cast<float>(multiplier);
+ if (zoomFactor != frame->zoomFactor()) {
+ --m_zoomLevel;
+ frame->setZoomFactor(zoomFactor, textOnly);
+ }
+}
+
+void WebViewImpl::zoomDefault()
+{
+ // We don't change the zoom mode (text only vs. full page) here. We just want
+ // to reset whatever is already set.
+ m_zoomLevel = 0;
+ mainFrameImpl()->frame()->setZoomFactor(
+ 1.0f, mainFrameImpl()->frame()->isZoomFactorTextOnly());
+}
+
+void WebViewImpl::performMediaPlayerAction(const WebMediaPlayerAction& action,
+ const WebPoint& location)
+{
+ HitTestResult result =
+ hitTestResultForWindowPos(location);
+ RefPtr<Node> node = result.innerNonSharedNode();
+ if (!node->hasTagName(HTMLNames::videoTag) && !node->hasTagName(HTMLNames::audioTag))
+ return;
+
+ RefPtr<HTMLMediaElement> mediaElement =
+ static_pointer_cast<HTMLMediaElement>(node);
+ switch (action.type) {
+ case WebMediaPlayerAction::Play:
+ if (action.enable)
+ mediaElement->play();
+ else
+ mediaElement->pause();
+ break;
+ case WebMediaPlayerAction::Mute:
+ mediaElement->setMuted(action.enable);
+ break;
+ case WebMediaPlayerAction::Loop:
+ mediaElement->setLoop(action.enable);
+ break;
+ default:
+ ASSERT_NOT_REACHED();
+ }
+}
+
+void WebViewImpl::copyImageAt(const WebPoint& point)
+{
+ if (!m_page.get())
+ return;
+
+ HitTestResult result = hitTestResultForWindowPos(point);
+
+ if (result.absoluteImageURL().isEmpty()) {
+ // There isn't actually an image at these coordinates. Might be because
+ // the window scrolled while the context menu was open or because the page
+ // changed itself between when we thought there was an image here and when
+ // we actually tried to retreive the image.
+ //
+ // FIXME: implement a cache of the most recent HitTestResult to avoid having
+ // to do two hit tests.
+ return;
+ }
+
+ m_page->mainFrame()->editor()->copyImage(result);
+}
+
+void WebViewImpl::dragSourceEndedAt(
+ const WebPoint& clientPoint,
+ const WebPoint& screenPoint,
+ WebDragOperation operation)
+{
+ PlatformMouseEvent pme(clientPoint,
+ screenPoint,
+ LeftButton, MouseEventMoved, 0, false, false, false,
+ false, 0);
+ m_page->mainFrame()->eventHandler()->dragSourceEndedAt(pme,
+ static_cast<DragOperation>(operation));
+}
+
+void WebViewImpl::dragSourceMovedTo(
+ const WebPoint& clientPoint,
+ const WebPoint& screenPoint)
+{
+ PlatformMouseEvent pme(clientPoint,
+ screenPoint,
+ LeftButton, MouseEventMoved, 0, false, false, false,
+ false, 0);
+ m_page->mainFrame()->eventHandler()->dragSourceMovedTo(pme);
+}
+
+void WebViewImpl::dragSourceSystemDragEnded()
+{
+ // It's possible for us to get this callback while not doing a drag if
+ // it's from a previous page that got unloaded.
+ if (m_doingDragAndDrop) {
+ m_page->dragController()->dragEnded();
+ m_doingDragAndDrop = false;
+ }
+}
+
+WebDragOperation WebViewImpl::dragTargetDragEnter(
+ const WebDragData& webDragData, int identity,
+ const WebPoint& clientPoint,
+ const WebPoint& screenPoint,
+ WebDragOperationsMask operationsAllowed)
+{
+ ASSERT(!m_currentDragData.get());
+
+ m_currentDragData = webDragData;
+ m_dragIdentity = identity;
+ m_operationsAllowed = operationsAllowed;
+
+ DragData dragData(
+ m_currentDragData.get(),
+ clientPoint,
+ screenPoint,
+ static_cast<DragOperation>(operationsAllowed));
+
+ m_dropEffect = DropEffectDefault;
+ m_dragTargetDispatch = true;
+ DragOperation effect = m_page->dragController()->dragEntered(&dragData);
+ // Mask the operation against the drag source's allowed operations.
+ if ((effect & dragData.draggingSourceOperationMask()) != effect)
+ effect = DragOperationNone;
+ m_dragTargetDispatch = false;
+
+ if (m_dropEffect != DropEffectDefault) {
+ m_dragOperation = (m_dropEffect != DropEffectNone) ? WebDragOperationCopy
+ : WebDragOperationNone;
+ } else
+ m_dragOperation = static_cast<WebDragOperation>(effect);
+ return m_dragOperation;
+}
+
+WebDragOperation WebViewImpl::dragTargetDragOver(
+ const WebPoint& clientPoint,
+ const WebPoint& screenPoint,
+ WebDragOperationsMask operationsAllowed)
+{
+ ASSERT(m_currentDragData.get());
+
+ m_operationsAllowed = operationsAllowed;
+ DragData dragData(
+ m_currentDragData.get(),
+ clientPoint,
+ screenPoint,
+ static_cast<DragOperation>(operationsAllowed));
+
+ m_dropEffect = DropEffectDefault;
+ m_dragTargetDispatch = true;
+ DragOperation effect = m_page->dragController()->dragUpdated(&dragData);
+ // Mask the operation against the drag source's allowed operations.
+ if ((effect & dragData.draggingSourceOperationMask()) != effect)
+ effect = DragOperationNone;
+ m_dragTargetDispatch = false;
+
+ if (m_dropEffect != DropEffectDefault) {
+ m_dragOperation = (m_dropEffect != DropEffectNone) ? WebDragOperationCopy
+ : WebDragOperationNone;
+ } else
+ m_dragOperation = static_cast<WebDragOperation>(effect);
+ return m_dragOperation;
+}
+
+void WebViewImpl::dragTargetDragLeave()
+{
+ ASSERT(m_currentDragData.get());
+
+ DragData dragData(
+ m_currentDragData.get(),
+ IntPoint(),
+ IntPoint(),
+ static_cast<DragOperation>(m_operationsAllowed));
+
+ m_dragTargetDispatch = true;
+ m_page->dragController()->dragExited(&dragData);
+ m_dragTargetDispatch = false;
+
+ m_currentDragData = 0;
+ m_dropEffect = DropEffectDefault;
+ m_dragOperation = WebDragOperationNone;
+ m_dragIdentity = 0;
+}
+
+void WebViewImpl::dragTargetDrop(const WebPoint& clientPoint,
+ const WebPoint& screenPoint)
+{
+ ASSERT(m_currentDragData.get());
+
+ // If this webview transitions from the "drop accepting" state to the "not
+ // accepting" state, then our IPC message reply indicating that may be in-
+ // flight, or else delayed by javascript processing in this webview. If a
+ // drop happens before our IPC reply has reached the browser process, then
+ // the browser forwards the drop to this webview. So only allow a drop to
+ // proceed if our webview m_dragOperation state is not DragOperationNone.
+
+ if (m_dragOperation == WebDragOperationNone) { // IPC RACE CONDITION: do not allow this drop.
+ dragTargetDragLeave();
+ return;
+ }
+
+ DragData dragData(
+ m_currentDragData.get(),
+ clientPoint,
+ screenPoint,
+ static_cast<DragOperation>(m_operationsAllowed));
+
+ m_dragTargetDispatch = true;
+ m_page->dragController()->performDrag(&dragData);
+ m_dragTargetDispatch = false;
+
+ m_currentDragData = 0;
+ m_dropEffect = DropEffectDefault;
+ m_dragOperation = WebDragOperationNone;
+ m_dragIdentity = 0;
+}
+
+int WebViewImpl::dragIdentity()
+{
+ if (m_dragTargetDispatch)
+ return m_dragIdentity;
+ return 0;
+}
+
+void WebViewImpl::inspectElementAt(const WebPoint& point)
+{
+ if (!m_page.get())
+ return;
+
+ if (point.x == -1 || point.y == -1)
+ m_page->inspectorController()->inspect(0);
+ else {
+ HitTestResult result = hitTestResultForWindowPos(point);
+
+ if (!result.innerNonSharedNode())
+ return;
+
+ m_page->inspectorController()->inspect(result.innerNonSharedNode());
+ }
+}
+
+WebString WebViewImpl::inspectorSettings() const
+{
+ return m_inspectorSettings;
+}
+
+void WebViewImpl::setInspectorSettings(const WebString& settings)
+{
+ m_inspectorSettings = settings;
+}
+
+WebDevToolsAgent* WebViewImpl::devToolsAgent()
+{
+ return m_devToolsAgent.get();
+}
+
+void WebViewImpl::setDevToolsAgent(WebDevToolsAgent* devToolsAgent)
+{
+ ASSERT(!m_devToolsAgent.get()); // May only set once!
+ m_devToolsAgent.set(static_cast<WebDevToolsAgentPrivate*>(devToolsAgent));
+}
+
+WebAccessibilityObject WebViewImpl::accessibilityObject()
+{
+ if (!mainFrameImpl())
+ return WebAccessibilityObject();
+
+ Document* document = mainFrameImpl()->frame()->document();
+ return WebAccessibilityObject(
+ document->axObjectCache()->getOrCreate(document->renderer()));
+}
+
+void WebViewImpl::applyAutofillSuggestions(
+ const WebNode& node,
+ const WebVector<WebString>& suggestions,
+ int defaultSuggestionIndex)
+{
+ if (!m_page.get() || suggestions.isEmpty()) {
+ hideAutoCompletePopup();
+ return;
+ }
+
+ ASSERT(defaultSuggestionIndex < static_cast<int>(suggestions.size()));
+
+ if (RefPtr<Frame> focused = m_page->focusController()->focusedFrame()) {
+ RefPtr<Document> document = focused->document();
+ if (!document.get()) {
+ hideAutoCompletePopup();
+ return;
+ }
+
+ RefPtr<Node> focusedNode = document->focusedNode();
+ // If the node for which we queried the autofill suggestions is not the
+ // focused node, then we have nothing to do. FIXME: also check the
+ // carret is at the end and that the text has not changed.
+ if (!focusedNode.get() || focusedNode != PassRefPtr<Node>(node)) {
+ hideAutoCompletePopup();
+ return;
+ }
+
+ if (!focusedNode->hasTagName(HTMLNames::inputTag)) {
+ ASSERT_NOT_REACHED();
+ return;
+ }
+
+ HTMLInputElement* inputElem =
+ static_cast<HTMLInputElement*>(focusedNode.get());
+
+ // The first time the autocomplete is shown we'll create the client and the
+ // popup.
+ if (!m_autocompletePopupClient.get())
+ m_autocompletePopupClient.set(new AutocompletePopupMenuClient(this));
+ m_autocompletePopupClient->initialize(inputElem,
+ suggestions,
+ defaultSuggestionIndex);
+ if (!m_autocompletePopup.get()) {
+ m_autocompletePopup =
+ PopupContainer::create(m_autocompletePopupClient.get(),
+ autocompletePopupSettings);
+ }
+
+ if (m_autocompletePopupShowing) {
+ m_autocompletePopupClient->setSuggestions(suggestions);
+ refreshAutofillPopup();
+ } else {
+ m_autocompletePopup->show(focusedNode->getRect(),
+ focusedNode->ownerDocument()->view(), 0);
+ m_autocompletePopupShowing = true;
+ }
+ }
+}
+
+void WebViewImpl::hideAutofillPopup()
+{
+ hideAutoCompletePopup();
+}
+
+// WebView --------------------------------------------------------------------
+
+bool WebViewImpl::setDropEffect(bool accept)
+{
+ if (m_dragTargetDispatch) {
+ m_dropEffect = accept ? DropEffectCopy : DropEffectNone;
+ return true;
+ }
+ return false;
+}
+
+void WebViewImpl::setIsTransparent(bool isTransparent)
+{
+ // Set any existing frames to be transparent.
+ Frame* frame = m_page->mainFrame();
+ while (frame) {
+ frame->view()->setTransparent(isTransparent);
+ frame = frame->tree()->traverseNext();
+ }
+
+ // Future frames check this to know whether to be transparent.
+ m_isTransparent = isTransparent;
+}
+
+bool WebViewImpl::isTransparent() const
+{
+ return m_isTransparent;
+}
+
+void WebViewImpl::setIsActive(bool active)
+{
+ if (page() && page()->focusController())
+ page()->focusController()->setActive(active);
+}
+
+bool WebViewImpl::isActive() const
+{
+ return (page() && page()->focusController()) ? page()->focusController()->isActive() : false;
+}
+
+void WebViewImpl::didCommitLoad(bool* isNewNavigation)
+{
+ if (isNewNavigation)
+ *isNewNavigation = m_observedNewNavigation;
+
+#ifndef NDEBUG
+ ASSERT(!m_observedNewNavigation
+ || m_page->mainFrame()->loader()->documentLoader() == m_newNavigationLoader);
+ m_newNavigationLoader = 0;
+#endif
+ m_observedNewNavigation = false;
+}
+
+bool WebViewImpl::navigationPolicyFromMouseEvent(unsigned short button,
+ bool ctrl, bool shift,
+ bool alt, bool meta,
+ WebNavigationPolicy* policy)
+{
+#if PLATFORM(WIN_OS) || PLATFORM(LINUX) || PLATFORM(FREEBSD)
+ const bool newTabModifier = (button == 1) || ctrl;
+#elif PLATFORM(DARWIN)
+ const bool newTabModifier = (button == 1) || meta;
+#endif
+ if (!newTabModifier && !shift && !alt)
+ return false;
+
+ ASSERT(policy);
+ if (newTabModifier) {
+ if (shift)
+ *policy = WebNavigationPolicyNewForegroundTab;
+ else
+ *policy = WebNavigationPolicyNewBackgroundTab;
+ } else {
+ if (shift)
+ *policy = WebNavigationPolicyNewWindow;
+ else
+ *policy = WebNavigationPolicyDownload;
+ }
+ return true;
+}
+
+void WebViewImpl::startDragging(const WebPoint& eventPos,
+ const WebDragData& dragData,
+ WebDragOperationsMask mask)
+{
+ if (!m_client)
+ return;
+ ASSERT(!m_doingDragAndDrop);
+ m_doingDragAndDrop = true;
+ m_client->startDragging(eventPos, dragData, mask);
+}
+
+void WebViewImpl::setCurrentHistoryItem(HistoryItem* item)
+{
+ m_backForwardListClientImpl.setCurrentHistoryItem(item);
+}
+
+HistoryItem* WebViewImpl::previousHistoryItem()
+{
+ return m_backForwardListClientImpl.previousHistoryItem();
+}
+
+void WebViewImpl::observeNewNavigation()
+{
+ m_observedNewNavigation = true;
+#ifndef NDEBUG
+ m_newNavigationLoader = m_page->mainFrame()->loader()->documentLoader();
+#endif
+}
+
+void WebViewImpl::hideAutoCompletePopup()
+{
+ if (m_autocompletePopupShowing) {
+ m_autocompletePopup->hidePopup();
+ autoCompletePopupDidHide();
+ }
+}
+
+void WebViewImpl::autoCompletePopupDidHide()
+{
+ m_autocompletePopupShowing = false;
+}
+
+void WebViewImpl::setIgnoreInputEvents(bool newValue)
+{
+ ASSERT(m_ignoreInputEvents != newValue);
+ m_ignoreInputEvents = newValue;
+}
+
+#if ENABLE(NOTIFICATIONS)
+NotificationPresenterImpl* WebViewImpl::notificationPresenterImpl()
+{
+ if (!m_notificationPresenter.isInitialized() && m_client)
+ m_notificationPresenter.initialize(m_client->notificationPresenter());
+ return &m_notificationPresenter;
+}
+#endif
+
+void WebViewImpl::refreshAutofillPopup()
+{
+ ASSERT(m_autocompletePopupShowing);
+
+ // Hide the popup if it has become empty.
+ if (!m_autocompletePopupClient->listSize()) {
+ hideAutoCompletePopup();
+ return;
+ }
+
+ IntRect oldBounds = m_autocompletePopup->boundsRect();
+ m_autocompletePopup->refresh();
+ IntRect newBounds = m_autocompletePopup->boundsRect();
+ // Let's resize the backing window if necessary.
+ if (oldBounds != newBounds) {
+ WebPopupMenuImpl* popupMenu =
+ static_cast<WebPopupMenuImpl*>(m_autocompletePopup->client());
+ popupMenu->client()->setWindowRect(newBounds);
+ }
+}
+
+Node* WebViewImpl::focusedWebCoreNode()
+{
+ Frame* frame = m_page->focusController()->focusedFrame();
+ if (!frame)
+ return 0;
+
+ Document* document = frame->document();
+ if (!document)
+ return 0;
+
+ return document->focusedNode();
+}
+
+HitTestResult WebViewImpl::hitTestResultForWindowPos(const IntPoint& pos)
+{
+ IntPoint docPoint(m_page->mainFrame()->view()->windowToContents(pos));
+ return m_page->mainFrame()->eventHandler()->hitTestResultAtPoint(docPoint, false);
+}
+
+void WebViewImpl::setTabsToLinks(bool enable)
+{
+ m_tabsToLinks = enable;
+}
+
+bool WebViewImpl::tabsToLinks() const
+{
+ return m_tabsToLinks;
+}
+
+} // namespace WebKit
diff --git a/WebKit/chromium/src/WebViewImpl.h b/WebKit/chromium/src/WebViewImpl.h
new file mode 100644
index 0000000..0668904
--- /dev/null
+++ b/WebKit/chromium/src/WebViewImpl.h
@@ -0,0 +1,419 @@
+/*
+ * 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 WebViewImpl_h
+#define WebViewImpl_h
+
+// FIXME: Remove these relative paths once consumers from glue are removed.
+#include "../public/WebNavigationPolicy.h"
+#include "../public/WebPoint.h"
+#include "../public/WebSize.h"
+#include "../public/WebString.h"
+#include "../public/WebView.h"
+
+#include "BackForwardListClientImpl.h"
+#include "ChromeClientImpl.h"
+#include "ContextMenuClientImpl.h"
+#include "DragClientImpl.h"
+#include "EditorClientImpl.h"
+#include "InspectorClientImpl.h"
+#include "NotificationPresenterImpl.h"
+
+#include <wtf/OwnPtr.h>
+#include <wtf/RefCounted.h>
+
+namespace WebCore {
+class ChromiumDataObject;
+class Frame;
+class HistoryItem;
+class HitTestResult;
+class KeyboardEvent;
+class Page;
+class PlatformKeyboardEvent;
+class PopupContainer;
+class Range;
+class RenderTheme;
+class Widget;
+}
+
+namespace WebKit {
+class AutocompletePopupMenuClient;
+class ContextMenuClientImpl;
+class WebAccessibilityObject;
+class WebDevToolsAgentPrivate;
+class WebFrameImpl;
+class WebKeyboardEvent;
+class WebMouseEvent;
+class WebMouseWheelEvent;
+class WebSettingsImpl;
+
+class WebViewImpl : public WebView, public RefCounted<WebViewImpl> {
+public:
+ // WebWidget methods:
+ virtual void close();
+ virtual WebSize size() { return m_size; }
+ virtual void resize(const WebSize&);
+ virtual void layout();
+ virtual void paint(WebCanvas*, const WebRect&);
+ 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);
+
+ // WebView methods:
+ virtual void initializeMainFrame(WebFrameClient*);
+ virtual WebSettings* settings();
+ virtual WebString pageEncoding() const;
+ virtual void setPageEncoding(const WebString& encoding);
+ virtual bool isTransparent() const;
+ virtual void setIsTransparent(bool value);
+ virtual bool tabsToLinks() const;
+ virtual void setTabsToLinks(bool value);
+ virtual bool tabKeyCyclesThroughElements() const;
+ virtual void setTabKeyCyclesThroughElements(bool value);
+ virtual bool isActive() const;
+ virtual void setIsActive(bool value);
+ virtual bool dispatchBeforeUnloadEvent();
+ virtual void dispatchUnloadEvent();
+ virtual WebFrame* mainFrame();
+ virtual WebFrame* findFrameByName(
+ const WebString& name, WebFrame* relativeToFrame);
+ virtual WebFrame* focusedFrame();
+ virtual void setFocusedFrame(WebFrame* frame);
+ virtual void setInitialFocus(bool reverse);
+ virtual void clearFocusedNode();
+ virtual void zoomIn(bool textOnly);
+ virtual void zoomOut(bool textOnly);
+ virtual void zoomDefault();
+ virtual void performMediaPlayerAction(
+ const WebMediaPlayerAction& action,
+ const WebPoint& location);
+ virtual void copyImageAt(const WebPoint& point);
+ virtual void dragSourceEndedAt(
+ const WebPoint& clientPoint,
+ const WebPoint& screenPoint,
+ WebDragOperation operation);
+ virtual void dragSourceMovedTo(
+ const WebPoint& clientPoint,
+ const WebPoint& screenPoint);
+ virtual void dragSourceSystemDragEnded();
+ virtual WebDragOperation dragTargetDragEnter(
+ const WebDragData& dragData, int identity,
+ const WebPoint& clientPoint,
+ const WebPoint& screenPoint,
+ WebDragOperationsMask operationsAllowed);
+ virtual WebDragOperation dragTargetDragOver(
+ const WebPoint& clientPoint,
+ const WebPoint& screenPoint,
+ WebDragOperationsMask operationsAllowed);
+ virtual void dragTargetDragLeave();
+ virtual void dragTargetDrop(
+ const WebPoint& clientPoint,
+ const WebPoint& screenPoint);
+ virtual int dragIdentity();
+ virtual bool setDropEffect(bool accept);
+ virtual void inspectElementAt(const WebPoint& point);
+ virtual WebString inspectorSettings() const;
+ virtual void setInspectorSettings(const WebString& settings);
+ virtual WebDevToolsAgent* devToolsAgent();
+ virtual void setDevToolsAgent(WebDevToolsAgent*);
+ virtual WebAccessibilityObject accessibilityObject();
+ virtual void applyAutofillSuggestions(
+ const WebNode&,
+ const WebVector<WebString>& suggestions,
+ int defaultSuggestionIndex);
+ virtual void hideAutofillPopup();
+
+ // WebViewImpl
+
+ void setIgnoreInputEvents(bool newValue);
+ WebDevToolsAgentPrivate* devToolsAgentPrivate() { return m_devToolsAgent.get(); }
+
+ const WebPoint& lastMouseDownPoint() const
+ {
+ return m_lastMouseDownPoint;
+ }
+
+ WebCore::Frame* focusedWebCoreFrame();
+
+ // Returns the currently focused Node or null if no node has focus.
+ WebCore::Node* focusedWebCoreNode();
+
+ static WebViewImpl* fromPage(WebCore::Page*);
+
+ WebViewClient* client()
+ {
+ return m_client;
+ }
+
+ // Returns the page object associated with this view. This may be null when
+ // the page is shutting down, but will be valid at all other times.
+ WebCore::Page* page() const
+ {
+ return m_page.get();
+ }
+
+ WebCore::RenderTheme* theme() const;
+
+ // Returns the main frame associated with this view. This may be null when
+ // the page is shutting down, but will be valid at all other times.
+ WebFrameImpl* mainFrameImpl();
+
+ // History related methods:
+ void setCurrentHistoryItem(WebCore::HistoryItem*);
+ WebCore::HistoryItem* previousHistoryItem();
+ void observeNewNavigation();
+
+ // Event related methods:
+ void mouseMove(const WebMouseEvent&);
+ void mouseLeave(const WebMouseEvent&);
+ void mouseDown(const WebMouseEvent&);
+ void mouseUp(const WebMouseEvent&);
+ void mouseContextMenu(const WebMouseEvent&);
+ void mouseDoubleClick(const WebMouseEvent&);
+ void mouseWheel(const WebMouseWheelEvent&);
+ bool keyEvent(const WebKeyboardEvent&);
+ bool charEvent(const WebKeyboardEvent&);
+
+ // Handles context menu events orignated via the the keyboard. These
+ // include the VK_APPS virtual key and the Shift+F10 combine. Code is
+ // based on the Webkit function bool WebView::handleContextMenuEvent(WPARAM
+ // wParam, LPARAM lParam) in webkit\webkit\win\WebView.cpp. The only
+ // significant change in this function is the code to convert from a
+ // Keyboard event to the Right Mouse button down event.
+ bool sendContextMenuEvent(const WebKeyboardEvent&);
+
+ // Notifies the WebView that a load has been committed. isNewNavigation
+ // will be true if a new session history item should be created for that
+ // load.
+ void didCommitLoad(bool* isNewNavigation);
+
+ bool contextMenuAllowed() const
+ {
+ return m_contextMenuAllowed;
+ }
+
+ // Set the disposition for how this webview is to be initially shown.
+ void setInitialNavigationPolicy(WebNavigationPolicy policy)
+ {
+ m_initialNavigationPolicy = policy;
+ }
+ WebNavigationPolicy initialNavigationPolicy() const
+ {
+ return m_initialNavigationPolicy;
+ }
+
+ // Determines whether a page should e.g. be opened in a background tab.
+ // Returns false if it has no opinion, in which case it doesn't set *policy.
+ static bool navigationPolicyFromMouseEvent(
+ unsigned short button,
+ bool ctrl,
+ bool shift,
+ bool alt,
+ bool meta,
+ WebNavigationPolicy*);
+
+ // Start a system drag and drop operation.
+ void startDragging(
+ const WebPoint& eventPos,
+ const WebDragData& dragData,
+ WebDragOperationsMask dragSourceOperationMask);
+
+ // Hides the autocomplete popup if it is showing.
+ void hideAutoCompletePopup();
+ void autoCompletePopupDidHide();
+
+#if ENABLE(NOTIFICATIONS)
+ // Returns the provider of desktop notifications.
+ NotificationPresenterImpl* notificationPresenterImpl();
+#endif
+
+ // Tries to scroll a frame or any parent of a frame. Returns true if the view
+ // was scrolled.
+ bool propagateScroll(WebCore::ScrollDirection, WebCore::ScrollGranularity);
+
+ // HACK: currentInputEvent() is for ChromeClientImpl::show(), until we can
+ // fix WebKit to pass enough information up into ChromeClient::show() so we
+ // can decide if the window.open event was caused by a middle-mouse click
+ static const WebInputEvent* currentInputEvent()
+ {
+ return m_currentInputEvent;
+ }
+
+private:
+ friend class WebView; // So WebView::Create can call our constructor
+ friend class WTF::RefCounted<WebViewImpl>;
+
+ WebViewImpl(WebViewClient* client);
+ ~WebViewImpl();
+
+ // Returns true if the event was actually processed.
+ bool keyEventDefault(const WebKeyboardEvent&);
+
+ // Returns true if the autocomple has consumed the event.
+ bool autocompleteHandleKeyEvent(const WebKeyboardEvent&);
+
+ // Repaints the autofill popup. Should be called when the suggestions have
+ // changed. Note that this should only be called when the autofill popup is
+ // showing.
+ void refreshAutofillPopup();
+
+ // Returns true if the view was scrolled.
+ bool scrollViewWithKeyboard(int keyCode, int modifiers);
+
+ // Converts |pos| from window coordinates to contents coordinates and gets
+ // the HitTestResult for it.
+ WebCore::HitTestResult hitTestResultForWindowPos(const WebCore::IntPoint&);
+
+ WebViewClient* m_client;
+
+ BackForwardListClientImpl m_backForwardListClientImpl;
+ ChromeClientImpl m_chromeClientImpl;
+ ContextMenuClientImpl m_contextMenuClientImpl;
+ DragClientImpl m_dragClientImpl;
+ EditorClientImpl m_editorClientImpl;
+ InspectorClientImpl m_inspectorClientImpl;
+
+ WebSize m_size;
+
+ WebPoint m_lastMousePosition;
+ OwnPtr<WebCore::Page> m_page;
+
+ // This flag is set when a new navigation is detected. It is used to satisfy
+ // the corresponding argument to WebFrameClient::didCommitProvisionalLoad.
+ bool m_observedNewNavigation;
+#ifndef NDEBUG
+ // Used to assert that the new navigation we observed is the same navigation
+ // when we make use of m_observedNewNavigation.
+ const WebCore::DocumentLoader* m_newNavigationLoader;
+#endif
+
+ // An object that can be used to manipulate m_page->settings() without linking
+ // against WebCore. This is lazily allocated the first time GetWebSettings()
+ // is called.
+ OwnPtr<WebSettingsImpl> m_webSettings;
+
+ // A copy of the web drop data object we received from the browser.
+ RefPtr<WebCore::ChromiumDataObject> m_currentDragData;
+
+ // The point relative to the client area where the mouse was last pressed
+ // down. This is used by the drag client to determine what was under the
+ // mouse when the drag was initiated. We need to track this here in
+ // WebViewImpl since DragClient::startDrag does not pass the position the
+ // mouse was at when the drag was initiated, only the current point, which
+ // can be misleading as it is usually not over the element the user actually
+ // dragged by the time a drag is initiated.
+ WebPoint m_lastMouseDownPoint;
+
+ // Keeps track of the current text zoom level. 0 means no zoom, positive
+ // values mean larger text, negative numbers mean smaller.
+ int m_zoomLevel;
+
+ bool m_contextMenuAllowed;
+
+ bool m_doingDragAndDrop;
+
+ bool m_ignoreInputEvents;
+
+ // Webkit expects keyPress events to be suppressed if the associated keyDown
+ // event was handled. Safari implements this behavior by peeking out the
+ // associated WM_CHAR event if the keydown was handled. We emulate
+ // this behavior by setting this flag if the keyDown was handled.
+ bool m_suppressNextKeypressEvent;
+
+ // The policy for how this webview is to be initially shown.
+ WebNavigationPolicy m_initialNavigationPolicy;
+
+ // Represents whether or not this object should process incoming IME events.
+ bool m_imeAcceptEvents;
+
+ // True while dispatching system drag and drop events to drag/drop targets
+ // within this WebView.
+ bool m_dragTargetDispatch;
+
+ // Valid when m_dragTargetDispatch is true; the identity of the drag data
+ // copied from the WebDropData object sent from the browser process.
+ int m_dragIdentity;
+
+ // Valid when m_dragTargetDispatch is true. Used to override the default
+ // browser drop effect with the effects "none" or "copy".
+ enum DragTargetDropEffect {
+ DropEffectDefault = -1,
+ DropEffectNone,
+ DropEffectCopy
+ } m_dropEffect;
+
+ // The available drag operations (copy, move link...) allowed by the source.
+ WebDragOperation m_operationsAllowed;
+
+ // The current drag operation as negotiated by the source and destination.
+ // When not equal to DragOperationNone, the drag data can be dropped onto the
+ // current drop target in this WebView (the drop target can accept the drop).
+ WebDragOperation m_dragOperation;
+
+ // The autocomplete popup. Kept around and reused every-time new suggestions
+ // should be shown.
+ RefPtr<WebCore::PopupContainer> m_autocompletePopup;
+
+ // Whether the autocomplete popup is currently showing.
+ bool m_autocompletePopupShowing;
+
+ // The autocomplete client.
+ OwnPtr<AutocompletePopupMenuClient> m_autocompletePopupClient;
+
+ OwnPtr<WebDevToolsAgentPrivate> m_devToolsAgent;
+
+ // Whether the webview is rendering transparently.
+ bool m_isTransparent;
+
+ // Whether the user can press tab to focus links.
+ bool m_tabsToLinks;
+
+ // Inspector settings.
+ WebString m_inspectorSettings;
+
+#if ENABLE(NOTIFICATIONS)
+ // The provider of desktop notifications;
+ NotificationPresenterImpl m_notificationPresenter;
+#endif
+
+ static const WebInputEvent* m_currentInputEvent;
+};
+
+} // namespace WebKit
+
+#endif
--
WebKit Debian packaging
More information about the Pkg-webkit-commits
mailing list