[SCM] WebKit Debian packaging branch, webkit-1.2, updated. upstream/1.1.90-6072-g9a69373

eric at webkit.org eric at webkit.org
Wed Apr 7 23:28:31 UTC 2010


The following commit has been merged in the webkit-1.2 branch:
commit 9a49e187c7f5cdddd749ab496f25b8da4293212b
Author: eric at webkit.org <eric at webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date:   Tue Nov 10 08:09:07 2009 +0000

    2009-11-10  Yaar Schnitman  <yaar at chromium.org>
    
            Reviewed by Dimitri Glazkov.
    
            Up-streaming Chromium API src files: WebPasswordFormData...WebRuntimeFeatures
    
            https://bugs.webkit.org/show_bug.cgi?id=31276
    
            * src/WebPasswordFormData.cpp: Added.
            (WebKit::):
            (WebKit::WebPasswordFormData::WebPasswordFormData):
            * src/WebPasswordFormUtils.cpp: Added.
            (WebKit::findPasswordFormFields):
            * src/WebPasswordFormUtils.h: Added.
            (WebKit::PasswordFormFields::PasswordFormFields):
            * src/WebPluginContainerImpl.cpp: Added.
            (WebKit::WebPluginContainerImpl::setFrameRect):
            (WebKit::WebPluginContainerImpl::paint):
            (WebKit::WebPluginContainerImpl::invalidateRect):
            (WebKit::WebPluginContainerImpl::setFocus):
            (WebKit::WebPluginContainerImpl::show):
            (WebKit::WebPluginContainerImpl::hide):
            (WebKit::WebPluginContainerImpl::handleEvent):
            (WebKit::WebPluginContainerImpl::frameRectsChanged):
            (WebKit::WebPluginContainerImpl::setParentVisible):
            (WebKit::WebPluginContainerImpl::setParent):
            (WebKit::WebPluginContainerImpl::invalidate):
            (WebKit::WebPluginContainerImpl::reportGeometry):
            (WebKit::WebPluginContainerImpl::clearScriptObjects):
            (WebKit::WebPluginContainerImpl::scriptableObjectForElement):
            (WebKit::WebPluginContainerImpl::executeScriptURL):
            (WebKit::WebPluginContainerImpl::loadFrameRequest):
            (WebKit::WebPluginContainerImpl::didReceiveResponse):
            (WebKit::WebPluginContainerImpl::didReceiveData):
            (WebKit::WebPluginContainerImpl::didFinishLoading):
            (WebKit::WebPluginContainerImpl::didFailLoading):
            (WebKit::WebPluginContainerImpl::scriptableObject):
            (WebKit::WebPluginContainerImpl::willDestroyPluginLoadObserver):
            (WebKit::WebPluginContainerImpl::~WebPluginContainerImpl):
            (WebKit::WebPluginContainerImpl::handleMouseEvent):
            (WebKit::WebPluginContainerImpl::handleKeyboardEvent):
            (WebKit::WebPluginContainerImpl::calculateGeometry):
            (WebKit::WebPluginContainerImpl::windowClipRect):
            (WebKit::getObjectStack):
            (WebKit::checkStackOnTop):
            (WebKit::WebPluginContainerImpl::windowCutOutRects):
            * src/WebPluginContainerImpl.h: Added.
            (WebKit::WebPluginContainerImpl::create):
            (WebKit::WebPluginContainerImpl::plugin):
            (WebKit::WebPluginContainerImpl::WebPluginContainerImpl):
            * src/WebPluginListBuilderImpl.cpp: Added.
            (WebKit::WebPluginListBuilderImpl::addPlugin):
            (WebKit::WebPluginListBuilderImpl::addMediaTypeToLastPlugin):
            (WebKit::WebPluginListBuilderImpl::addFileExtensionToLastMediaType):
            * src/WebPluginListBuilderImpl.h: Added.
            (WebKit::WebPluginListBuilderImpl::WebPluginListBuilderImpl):
            * src/WebPluginLoadObserver.cpp: Added.
            (WebKit::WebPluginLoadObserver::~WebPluginLoadObserver):
            (WebKit::WebPluginLoadObserver::didFinishLoading):
            (WebKit::WebPluginLoadObserver::didFailLoading):
            * src/WebPluginLoadObserver.h: Added.
            (WebKit::WebPluginLoadObserver::WebPluginLoadObserver):
            (WebKit::WebPluginLoadObserver::url):
            (WebKit::WebPluginLoadObserver::clearPluginContainer):
            * src/WebPopupMenuImpl.cpp: Added.
            (WebKit::WebPopupMenu::create):
            (WebKit::WebPopupMenuImpl::WebPopupMenuImpl):
            (WebKit::WebPopupMenuImpl::~WebPopupMenuImpl):
            (WebKit::WebPopupMenuImpl::Init):
            (WebKit::WebPopupMenuImpl::MouseMove):
            (WebKit::WebPopupMenuImpl::MouseLeave):
            (WebKit::WebPopupMenuImpl::MouseDown):
            (WebKit::WebPopupMenuImpl::MouseUp):
            (WebKit::WebPopupMenuImpl::MouseWheel):
            (WebKit::WebPopupMenuImpl::KeyEvent):
            (WebKit::WebPopupMenuImpl::close):
            (WebKit::WebPopupMenuImpl::resize):
            (WebKit::WebPopupMenuImpl::layout):
            (WebKit::WebPopupMenuImpl::paint):
            (WebKit::WebPopupMenuImpl::handleInputEvent):
            (WebKit::WebPopupMenuImpl::mouseCaptureLost):
            (WebKit::WebPopupMenuImpl::setFocus):
            (WebKit::WebPopupMenuImpl::handleCompositionEvent):
            (WebKit::WebPopupMenuImpl::queryCompositionStatus):
            (WebKit::WebPopupMenuImpl::setTextDirection):
            (WebKit::WebPopupMenuImpl::repaint):
            (WebKit::WebPopupMenuImpl::scroll):
            (WebKit::WebPopupMenuImpl::screenToWindow):
            (WebKit::WebPopupMenuImpl::windowToScreen):
            (WebKit::WebPopupMenuImpl::scrollRectIntoView):
            (WebKit::WebPopupMenuImpl::scrollbarsModeDidChange):
            (WebKit::WebPopupMenuImpl::popupClosed):
            * src/WebPopupMenuImpl.h: Added.
            (WebKit::WebPopupMenuImpl::size):
            (WebKit::WebPopupMenuImpl::client):
            (WebKit::WebPopupMenuImpl::platformPageClient):
            * src/WebRange.cpp: Added.
            (WebKit::WebRange::reset):
            (WebKit::WebRange::assign):
            (WebKit::WebRange::startOffset):
            (WebKit::WebRange::endOffset):
            (WebKit::WebRange::startContainer):
            (WebKit::WebRange::endContainer):
            (WebKit::WebRange::toHTMLText):
            (WebKit::WebRange::toPlainText):
            (WebKit::WebRange::WebRange):
            (WebKit::WebRange::operator=):
            (WebKit::WebRange::operator WTF::PassRefPtr<WebCore::Range>):
            * src/WebRuntimeFeatures.cpp: Added.
            (WebKit::WebRuntimeFeatures::enableDatabase):
            (WebKit::WebRuntimeFeatures::isDatabaseEnabled):
            (WebKit::WebRuntimeFeatures::enableLocalStorage):
            (WebKit::WebRuntimeFeatures::isLocalStorageEnabled):
            (WebKit::WebRuntimeFeatures::enableSessionStorage):
            (WebKit::WebRuntimeFeatures::isSessionStorageEnabled):
            (WebKit::WebRuntimeFeatures::enableMediaPlayer):
            (WebKit::WebRuntimeFeatures::isMediaPlayerEnabled):
            (WebKit::WebRuntimeFeatures::enableSockets):
            (WebKit::WebRuntimeFeatures::isSocketsEnabled):
            (WebKit::WebRuntimeFeatures::enableNotifications):
            (WebKit::WebRuntimeFeatures::isNotificationsEnabled):
            (WebKit::WebRuntimeFeatures::enableApplicationCache):
            (WebKit::WebRuntimeFeatures::isApplicationCacheEnabled):
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@50722 268f45cc-cd09-0410-ab3c-d52691b4dbfc

diff --git a/WebKit/chromium/ChangeLog b/WebKit/chromium/ChangeLog
index 5e4c81c..8536713 100644
--- a/WebKit/chromium/ChangeLog
+++ b/WebKit/chromium/ChangeLog
@@ -1,3 +1,127 @@
+2009-11-10  Yaar Schnitman  <yaar at chromium.org>
+
+        Reviewed by Dimitri Glazkov.
+
+        Up-streaming Chromium API src files: WebPasswordFormData...WebRuntimeFeatures
+
+        https://bugs.webkit.org/show_bug.cgi?id=31276
+
+        * src/WebPasswordFormData.cpp: Added.
+        (WebKit::):
+        (WebKit::WebPasswordFormData::WebPasswordFormData):
+        * src/WebPasswordFormUtils.cpp: Added.
+        (WebKit::findPasswordFormFields):
+        * src/WebPasswordFormUtils.h: Added.
+        (WebKit::PasswordFormFields::PasswordFormFields):
+        * src/WebPluginContainerImpl.cpp: Added.
+        (WebKit::WebPluginContainerImpl::setFrameRect):
+        (WebKit::WebPluginContainerImpl::paint):
+        (WebKit::WebPluginContainerImpl::invalidateRect):
+        (WebKit::WebPluginContainerImpl::setFocus):
+        (WebKit::WebPluginContainerImpl::show):
+        (WebKit::WebPluginContainerImpl::hide):
+        (WebKit::WebPluginContainerImpl::handleEvent):
+        (WebKit::WebPluginContainerImpl::frameRectsChanged):
+        (WebKit::WebPluginContainerImpl::setParentVisible):
+        (WebKit::WebPluginContainerImpl::setParent):
+        (WebKit::WebPluginContainerImpl::invalidate):
+        (WebKit::WebPluginContainerImpl::reportGeometry):
+        (WebKit::WebPluginContainerImpl::clearScriptObjects):
+        (WebKit::WebPluginContainerImpl::scriptableObjectForElement):
+        (WebKit::WebPluginContainerImpl::executeScriptURL):
+        (WebKit::WebPluginContainerImpl::loadFrameRequest):
+        (WebKit::WebPluginContainerImpl::didReceiveResponse):
+        (WebKit::WebPluginContainerImpl::didReceiveData):
+        (WebKit::WebPluginContainerImpl::didFinishLoading):
+        (WebKit::WebPluginContainerImpl::didFailLoading):
+        (WebKit::WebPluginContainerImpl::scriptableObject):
+        (WebKit::WebPluginContainerImpl::willDestroyPluginLoadObserver):
+        (WebKit::WebPluginContainerImpl::~WebPluginContainerImpl):
+        (WebKit::WebPluginContainerImpl::handleMouseEvent):
+        (WebKit::WebPluginContainerImpl::handleKeyboardEvent):
+        (WebKit::WebPluginContainerImpl::calculateGeometry):
+        (WebKit::WebPluginContainerImpl::windowClipRect):
+        (WebKit::getObjectStack):
+        (WebKit::checkStackOnTop):
+        (WebKit::WebPluginContainerImpl::windowCutOutRects):
+        * src/WebPluginContainerImpl.h: Added.
+        (WebKit::WebPluginContainerImpl::create):
+        (WebKit::WebPluginContainerImpl::plugin):
+        (WebKit::WebPluginContainerImpl::WebPluginContainerImpl):
+        * src/WebPluginListBuilderImpl.cpp: Added.
+        (WebKit::WebPluginListBuilderImpl::addPlugin):
+        (WebKit::WebPluginListBuilderImpl::addMediaTypeToLastPlugin):
+        (WebKit::WebPluginListBuilderImpl::addFileExtensionToLastMediaType):
+        * src/WebPluginListBuilderImpl.h: Added.
+        (WebKit::WebPluginListBuilderImpl::WebPluginListBuilderImpl):
+        * src/WebPluginLoadObserver.cpp: Added.
+        (WebKit::WebPluginLoadObserver::~WebPluginLoadObserver):
+        (WebKit::WebPluginLoadObserver::didFinishLoading):
+        (WebKit::WebPluginLoadObserver::didFailLoading):
+        * src/WebPluginLoadObserver.h: Added.
+        (WebKit::WebPluginLoadObserver::WebPluginLoadObserver):
+        (WebKit::WebPluginLoadObserver::url):
+        (WebKit::WebPluginLoadObserver::clearPluginContainer):
+        * src/WebPopupMenuImpl.cpp: Added.
+        (WebKit::WebPopupMenu::create):
+        (WebKit::WebPopupMenuImpl::WebPopupMenuImpl):
+        (WebKit::WebPopupMenuImpl::~WebPopupMenuImpl):
+        (WebKit::WebPopupMenuImpl::Init):
+        (WebKit::WebPopupMenuImpl::MouseMove):
+        (WebKit::WebPopupMenuImpl::MouseLeave):
+        (WebKit::WebPopupMenuImpl::MouseDown):
+        (WebKit::WebPopupMenuImpl::MouseUp):
+        (WebKit::WebPopupMenuImpl::MouseWheel):
+        (WebKit::WebPopupMenuImpl::KeyEvent):
+        (WebKit::WebPopupMenuImpl::close):
+        (WebKit::WebPopupMenuImpl::resize):
+        (WebKit::WebPopupMenuImpl::layout):
+        (WebKit::WebPopupMenuImpl::paint):
+        (WebKit::WebPopupMenuImpl::handleInputEvent):
+        (WebKit::WebPopupMenuImpl::mouseCaptureLost):
+        (WebKit::WebPopupMenuImpl::setFocus):
+        (WebKit::WebPopupMenuImpl::handleCompositionEvent):
+        (WebKit::WebPopupMenuImpl::queryCompositionStatus):
+        (WebKit::WebPopupMenuImpl::setTextDirection):
+        (WebKit::WebPopupMenuImpl::repaint):
+        (WebKit::WebPopupMenuImpl::scroll):
+        (WebKit::WebPopupMenuImpl::screenToWindow):
+        (WebKit::WebPopupMenuImpl::windowToScreen):
+        (WebKit::WebPopupMenuImpl::scrollRectIntoView):
+        (WebKit::WebPopupMenuImpl::scrollbarsModeDidChange):
+        (WebKit::WebPopupMenuImpl::popupClosed):
+        * src/WebPopupMenuImpl.h: Added.
+        (WebKit::WebPopupMenuImpl::size):
+        (WebKit::WebPopupMenuImpl::client):
+        (WebKit::WebPopupMenuImpl::platformPageClient):
+        * src/WebRange.cpp: Added.
+        (WebKit::WebRange::reset):
+        (WebKit::WebRange::assign):
+        (WebKit::WebRange::startOffset):
+        (WebKit::WebRange::endOffset):
+        (WebKit::WebRange::startContainer):
+        (WebKit::WebRange::endContainer):
+        (WebKit::WebRange::toHTMLText):
+        (WebKit::WebRange::toPlainText):
+        (WebKit::WebRange::WebRange):
+        (WebKit::WebRange::operator=):
+        (WebKit::WebRange::operator WTF::PassRefPtr<WebCore::Range>):
+        * src/WebRuntimeFeatures.cpp: Added.
+        (WebKit::WebRuntimeFeatures::enableDatabase):
+        (WebKit::WebRuntimeFeatures::isDatabaseEnabled):
+        (WebKit::WebRuntimeFeatures::enableLocalStorage):
+        (WebKit::WebRuntimeFeatures::isLocalStorageEnabled):
+        (WebKit::WebRuntimeFeatures::enableSessionStorage):
+        (WebKit::WebRuntimeFeatures::isSessionStorageEnabled):
+        (WebKit::WebRuntimeFeatures::enableMediaPlayer):
+        (WebKit::WebRuntimeFeatures::isMediaPlayerEnabled):
+        (WebKit::WebRuntimeFeatures::enableSockets):
+        (WebKit::WebRuntimeFeatures::isSocketsEnabled):
+        (WebKit::WebRuntimeFeatures::enableNotifications):
+        (WebKit::WebRuntimeFeatures::isNotificationsEnabled):
+        (WebKit::WebRuntimeFeatures::enableApplicationCache):
+        (WebKit::WebRuntimeFeatures::isApplicationCacheEnabled):
+
 2009-11-09  Yaar Schnitman  <yaar at chromium.org>
 
         Reviewed by Dimitri Glazkov.
diff --git a/WebKit/chromium/src/WebPasswordFormData.cpp b/WebKit/chromium/src/WebPasswordFormData.cpp
new file mode 100644
index 0000000..64b1754
--- /dev/null
+++ b/WebKit/chromium/src/WebPasswordFormData.cpp
@@ -0,0 +1,180 @@
+/*
+ * 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 "WebPasswordFormData.h"
+
+#include "Document.h"
+#include "DocumentLoader.h"
+#include "Frame.h"
+#include "FrameLoader.h"
+#include "HTMLFormElement.h"
+#include "HTMLInputElement.h"
+#include "HTMLNames.h"
+#include "KURL.h"
+
+#include "DOMUtilitiesPrivate.h"
+#include "WebPasswordFormUtils.h"
+
+using namespace WebCore;
+
+namespace WebKit {
+
+namespace {
+
+// Helper to determine which password is the main one, and which is
+// an old password (e.g on a "make new password" form), if any.
+bool locateSpecificPasswords(PasswordFormFields* fields,
+                             HTMLInputElement** password,
+                             HTMLInputElement** oldPassword)
+{
+    ASSERT(fields);
+    ASSERT(password);
+    ASSERT(oldPassword);
+    switch (fields->passwords.size()) {
+    case 1:
+        // Single password, easy.
+        *password = fields->passwords[0];
+        break;
+    case 2:
+        if (fields->passwords[0]->value() == fields->passwords[1]->value())
+            // Treat two identical passwords as a single password.
+            *password = fields->passwords[0];
+        else {
+            // Assume first is old password, second is new (no choice but to guess).
+            *oldPassword = fields->passwords[0];
+            *password = fields->passwords[1];
+        }
+        break;
+    case 3:
+        if (fields->passwords[0]->value() == fields->passwords[1]->value()
+            && fields->passwords[0]->value() == fields->passwords[2]->value()) {
+            // All three passwords the same? Just treat as one and hope.
+            *password = fields->passwords[0];
+        } else if (fields->passwords[0]->value() == fields->passwords[1]->value()) {
+            // Two the same and one different -> old password is duplicated one.
+            *oldPassword = fields->passwords[0];
+            *password = fields->passwords[2];
+        } else if (fields->passwords[1]->value() == fields->passwords[2]->value()) {
+            *oldPassword = fields->passwords[0];
+            *password = fields->passwords[1];
+        } else {
+            // Three different passwords, or first and last match with middle
+            // different. No idea which is which, so no luck.
+            return false;
+        }
+        break;
+    default:
+        return false;
+    }
+    return true;
+}
+
+// Helped method to clear url of unneeded parts.
+KURL stripURL(const KURL& url)
+{
+    KURL strippedURL = url;
+    strippedURL.setUser(String());
+    strippedURL.setPass(String());
+    strippedURL.setQuery(String());
+    strippedURL.setFragmentIdentifier(String());
+    return strippedURL;
+}
+
+// Helper to gather up the final form data and create a PasswordForm.
+void assemblePasswordFormResult(const KURL& fullOrigin,
+                                const KURL& fullAction,
+                                HTMLFormControlElement* submit,
+                                HTMLInputElement* userName,
+                                HTMLInputElement* oldPassword,
+                                HTMLInputElement* password,
+                                WebPasswordFormData* result)
+{
+    // We want to keep the path but strip any authentication data, as well as
+    // query and ref portions of URL, for the form action and form origin.
+    result->action = stripURL(fullAction);
+    result->origin = stripURL(fullOrigin);
+
+    // Naming is confusing here because we have both the HTML form origin URL
+    // the page where the form was seen), and the "origin" components of the url
+    // (scheme, host, and port).
+    KURL signonRealmURL = stripURL(fullOrigin);
+    signonRealmURL.setPath("");
+    result->signonRealm = signonRealmURL;
+
+    if (submit)
+        result->submitElement = submit->name();
+    if (userName) {
+        result->userNameElement = userName->name();
+        result->userNameValue = userName->value();
+    }
+    if (password) {
+        result->passwordElement = password->name();
+        result->passwordValue = password->value();
+    }
+    if (oldPassword) {
+        result->oldPasswordElement = oldPassword->name();
+        result->oldPasswordValue = oldPassword->value();
+    }
+}
+
+} // namespace
+
+WebPasswordFormData::WebPasswordFormData(const WebFormElement& webForm)
+{
+    RefPtr<HTMLFormElement> form = webForm.operator PassRefPtr<HTMLFormElement>();
+
+    Frame* frame = form->document()->frame();
+    if (!frame)
+        return;
+
+    PasswordFormFields fields;
+    findPasswordFormFields(form.get(), &fields);
+
+    // Get the document URL
+    KURL fullOrigin(ParsedURLString, form->document()->documentURI());
+
+    // Calculate the canonical action URL
+    KURL fullAction = frame->loader()->completeURL(form->action());
+    if (!fullAction.isValid())
+        return;
+
+    // Determine the types of the password fields
+    HTMLInputElement* password = 0;
+    HTMLInputElement* oldPassword = 0;
+    if (!locateSpecificPasswords(&fields, &password, &oldPassword))
+        return;
+
+    assemblePasswordFormResult(fullOrigin, fullAction,
+                               fields.submit, fields.userName,
+                               oldPassword, password, this);
+}
+
+} // namespace WebKit
diff --git a/WebKit/chromium/src/WebPasswordFormUtils.cpp b/WebKit/chromium/src/WebPasswordFormUtils.cpp
new file mode 100644
index 0000000..766dc63
--- /dev/null
+++ b/WebKit/chromium/src/WebPasswordFormUtils.cpp
@@ -0,0 +1,110 @@
+/* ***** BEGIN LICENSE BLOCK *****
+* Version: MPL 1.1/GPL 2.0/LGPL 2.1
+*
+* The contents of this file are subject to the Mozilla Public License Version
+* 1.1 (the "License"); you may not use this file except in compliance with
+* the License. You may obtain a copy of the License at
+* http://www.mozilla.org/MPL/
+*
+* Software distributed under the License is distributed on an "AS IS" basis,
+* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+* for the specific language governing rights and limitations under the
+* License.
+*
+* The Original Code is Mozilla Password Manager.
+*
+* The Initial Developer of the Original Code is
+* Brian Ryner.
+* Portions created by the Initial Developer are Copyright (C) 2003
+* the Initial Developer. All Rights Reserved.
+*
+* Contributor(s):
+*  Brian Ryner <bryner at brianryner.com>
+*
+* Alternatively, the contents of this file may be used under the terms of
+* either the GNU General Public License Version 2 or later (the "GPL"), or
+* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
+* in which case the provisions of the GPL or the LGPL are applicable instead
+* of those above. If you wish to allow use of your version of this file only
+* under the terms of either the GPL or the LGPL, and not to allow others to
+* use your version of this file under the terms of the MPL, indicate your
+* decision by deleting the provisions above and replace them with the notice
+* and other provisions required by the GPL or the LGPL. If you do not delete
+* the provisions above, a recipient may use your version of this file under
+* the terms of any one of the MPL, the GPL or the LGPL.
+*
+* ***** END LICENSE BLOCK ***** */
+
+// Helper to WebPasswordFormData to do the locating of username/password
+// fields.
+// This method based on Firefox2 code in
+//   toolkit/components/passwordmgr/base/nsPasswordManager.cpp
+
+#include "config.h"
+#include "WebPasswordFormUtils.h"
+
+#include "HTMLFormElement.h"
+#include "HTMLInputElement.h"
+#include "HTMLNames.h"
+#include "KURL.h"
+
+#include "DOMUtilitiesPrivate.h"
+
+using namespace WebCore;
+
+namespace WebKit {
+
+// Maximum number of password fields we will observe before throwing our
+// hands in the air and giving up with a given form.
+static const size_t maxPasswords = 3;
+
+void findPasswordFormFields(HTMLFormElement* form, PasswordFormFields* fields)
+{
+    ASSERT(form);
+    ASSERT(fields);
+
+    int firstPasswordIndex = 0;
+    // First, find the password fields and activated submit button
+    const Vector<HTMLFormControlElement*>& formElements = form->formElements;
+    for (size_t i = 0; i < formElements.size(); i++) {
+        HTMLFormControlElement* formElement = formElements[i];
+        if (formElement->isActivatedSubmit())
+            fields->submit = formElement;
+
+        if (!formElement->hasLocalName(HTMLNames::inputTag))
+            continue;
+
+        HTMLInputElement* inputElement = toHTMLInputElement(formElement);
+        if (!inputElement->isEnabledFormControl())
+            continue;
+
+        if ((fields->passwords.size() < maxPasswords)
+            && (inputElement->inputType() == HTMLInputElement::PASSWORD)
+            && (inputElement->autoComplete())) {
+            if (fields->passwords.isEmpty())
+                firstPasswordIndex = i;
+            fields->passwords.append(inputElement);
+        }
+    }
+
+    if (!fields->passwords.isEmpty()) {
+        // Then, search backwards for the username field
+        for (int i = firstPasswordIndex - 1; i >= 0; i--) {
+            HTMLFormControlElement* formElement = formElements[i];
+            if (!formElement->hasLocalName(HTMLNames::inputTag))
+                continue;
+
+            HTMLInputElement* inputElement = toHTMLInputElement(formElement);
+            if (!inputElement->isEnabledFormControl())
+                continue;
+
+            if ((inputElement->inputType() == HTMLInputElement::TEXT)
+                && (inputElement->autoComplete())) {
+                fields->userName = inputElement;
+                break;
+            }
+        }
+    }
+}
+
+} // namespace WebKit
diff --git a/WebKit/chromium/src/WebPasswordFormUtils.h b/WebKit/chromium/src/WebPasswordFormUtils.h
new file mode 100644
index 0000000..fd503b4
--- /dev/null
+++ b/WebKit/chromium/src/WebPasswordFormUtils.h
@@ -0,0 +1,57 @@
+/*
+ * 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 WebPasswordFormUtils_h
+#define WebPasswordFormUtils_h
+
+#include <wtf/Vector.h>
+
+namespace WebCore {
+class HTMLInputElement;
+class HTMLFormControlElement;
+class HTMLFormElement;
+}
+
+namespace WebKit {
+
+// Helper structure to locate username, passwords and submit fields.
+struct PasswordFormFields {
+    WebCore::HTMLInputElement* userName;
+    Vector<WebCore::HTMLInputElement*> passwords;
+    WebCore::HTMLFormControlElement* submit;
+    PasswordFormFields() : userName(0), submit(0) { }
+};
+
+void findPasswordFormFields(WebCore::HTMLFormElement* form,
+                            PasswordFormFields* fields);
+
+} // namespace WebKit
+
+#endif
diff --git a/WebKit/chromium/src/WebPluginContainerImpl.cpp b/WebKit/chromium/src/WebPluginContainerImpl.cpp
new file mode 100644
index 0000000..43f3cef
--- /dev/null
+++ b/WebKit/chromium/src/WebPluginContainerImpl.cpp
@@ -0,0 +1,556 @@
+/*
+ * 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 "WebPluginContainerImpl.h"
+
+#include "ChromeClientImpl.h"
+#include "WebCursorInfo.h"
+#include "WebDataSourceImpl.h"
+#include "WebInputEvent.h"
+#include "WebInputEventConversion.h"
+#include "WebKit.h"
+#include "WebPlugin.h"
+#include "WebRect.h"
+#include "WebURLError.h"
+#include "WebURLRequest.h"
+#include "WebVector.h"
+#include "WrappedResourceResponse.h"
+
+#include "EventNames.h"
+#include "FocusController.h"
+#include "FormState.h"
+#include "Frame.h"
+#include "FrameLoadRequest.h"
+#include "FrameView.h"
+#include "GraphicsContext.h"
+#include "HostWindow.h"
+#include "HTMLFormElement.h"
+#include "HTMLNames.h"
+#include "HTMLPlugInElement.h"
+#include "KeyboardEvent.h"
+#include "MouseEvent.h"
+#include "Page.h"
+#include "ScrollView.h"
+
+#if WEBKIT_USING_SKIA
+#include "PlatformContextSkia.h"
+#endif
+
+using namespace WebCore;
+
+namespace WebKit {
+
+// Public methods --------------------------------------------------------------
+
+void WebPluginContainerImpl::setFrameRect(const IntRect& frameRect)
+{
+    Widget::setFrameRect(frameRect);
+    reportGeometry();
+}
+
+void WebPluginContainerImpl::paint(GraphicsContext* gc, const IntRect& damageRect)
+{
+    if (gc->paintingDisabled())
+        return;
+
+    if (!parent())
+        return;
+
+    // Don't paint anything if the plugin doesn't intersect the damage rect.
+    if (!frameRect().intersects(damageRect))
+        return;
+
+    gc->save();
+
+    ASSERT(parent()->isFrameView());
+    ScrollView* view = parent();
+
+    // The plugin is positioned in window coordinates, so it needs to be painted
+    // in window coordinates.
+    IntPoint origin = view->windowToContents(IntPoint(0, 0));
+    gc->translate(static_cast<float>(origin.x()), static_cast<float>(origin.y()));
+
+#if WEBKIT_USING_SKIA
+    WebCanvas* canvas = gc->platformContext()->canvas();
+#elif WEBKIT_USING_CG
+    WebCanvas* canvas = gc->platformContext();
+#endif
+
+    IntRect windowRect =
+        IntRect(view->contentsToWindow(damageRect.location()), damageRect.size());
+    m_webPlugin->paint(canvas, windowRect);
+
+    gc->restore();
+}
+
+void WebPluginContainerImpl::invalidateRect(const IntRect& rect)
+{
+    if (!parent())
+        return;
+
+    IntRect damageRect = convertToContainingWindow(rect);
+
+    // Get our clip rect and intersect with it to ensure we don't invalidate
+    // too much.
+    IntRect clipRect = parent()->windowClipRect();
+    damageRect.intersect(clipRect);
+
+    parent()->hostWindow()->repaint(damageRect, true);
+}
+
+void WebPluginContainerImpl::setFocus()
+{
+    Widget::setFocus();
+    m_webPlugin->updateFocus(true);
+}
+
+void WebPluginContainerImpl::show()
+{
+    setSelfVisible(true);
+    m_webPlugin->updateVisibility(true);
+
+    Widget::show();
+}
+
+void WebPluginContainerImpl::hide()
+{
+    setSelfVisible(false);
+    m_webPlugin->updateVisibility(false);
+
+    Widget::hide();
+}
+
+void WebPluginContainerImpl::handleEvent(Event* event)
+{
+    if (!m_webPlugin->acceptsInputEvents())
+        return;
+
+    // The events we pass are defined at:
+    //    http://devedge-temp.mozilla.org/library/manuals/2002/plugin/1.0/structures5.html#1000000
+    // Don't take the documentation as truth, however.  There are many cases
+    // where mozilla behaves differently than the spec.
+    if (event->isMouseEvent())
+        handleMouseEvent(static_cast<MouseEvent*>(event));
+    else if (event->isKeyboardEvent())
+        handleKeyboardEvent(static_cast<KeyboardEvent*>(event));
+}
+
+void WebPluginContainerImpl::frameRectsChanged()
+{
+    Widget::frameRectsChanged();
+    reportGeometry();
+}
+
+void WebPluginContainerImpl::setParentVisible(bool parentVisible)
+{
+    // We override this function to make sure that geometry updates are sent
+    // over to the plugin. For e.g. when a plugin is instantiated it does not
+    // have a valid parent. As a result the first geometry update from webkit
+    // is ignored. This function is called when the plugin eventually gets a
+    // parent.
+
+    if (isParentVisible() == parentVisible)
+        return;  // No change.
+
+    Widget::setParentVisible(parentVisible);
+    if (!isSelfVisible())
+        return;  // This widget has explicitely been marked as not visible.
+
+    m_webPlugin->updateVisibility(isVisible());
+}
+
+void WebPluginContainerImpl::setParent(ScrollView* view)
+{
+    // We override this function so that if the plugin is windowed, we can call
+    // NPP_SetWindow at the first possible moment.  This ensures that
+    // NPP_SetWindow is called before the manual load data is sent to a plugin.
+    // If this order is reversed, Flash won't load videos.
+
+    Widget::setParent(view);
+    if (view)
+        reportGeometry();
+}
+
+void WebPluginContainerImpl::invalidate()
+{
+    Widget::invalidate();
+}
+
+void WebPluginContainerImpl::invalidateRect(const WebRect& rect)
+{
+    invalidateRect(static_cast<IntRect>(rect));
+}
+
+void WebPluginContainerImpl::reportGeometry()
+{
+    if (!parent())
+        return;
+
+    IntRect windowRect, clipRect;
+    Vector<IntRect> cutOutRects;
+    calculateGeometry(frameRect(), windowRect, clipRect, cutOutRects);
+
+    m_webPlugin->updateGeometry(windowRect, clipRect, cutOutRects, isVisible());
+}
+
+void WebPluginContainerImpl::clearScriptObjects()
+{
+    Frame* frame = m_element->document()->frame();
+    if (!frame)
+        return;
+    frame->script()->cleanupScriptObjectsForPlugin(this);
+}
+
+NPObject* WebPluginContainerImpl::scriptableObjectForElement()
+{
+    return m_element->getNPObject();
+}
+
+WebString WebPluginContainerImpl::executeScriptURL(const WebURL& url, bool popupsAllowed)
+{
+    Frame* frame = m_element->document()->frame();
+    if (!frame)
+        return WebString();
+
+    const KURL& kurl = url;
+    ASSERT(kurl.protocolIs("javascript"));
+
+    String script = decodeURLEscapeSequences(
+        kurl.string().substring(strlen("javascript:")));
+
+    ScriptValue result = frame->script()->executeScript(script, popupsAllowed);
+
+    // Failure is reported as a null string.
+    String resultStr;
+    result.getString(resultStr);
+    return resultStr;
+}
+
+void WebPluginContainerImpl::loadFrameRequest(
+    const WebURLRequest& request, const WebString& target, bool notifyNeeded, void* notifyData)
+{
+    Frame* frame = m_element->document()->frame();
+    if (!frame)
+        return;  // FIXME: send a notification in this case?
+
+    if (notifyNeeded) {
+        // FIXME: This is a bit of hack to allow us to observe completion of
+        // our frame request.  It would be better to evolve FrameLoader to
+        // support a completion callback instead.
+        WebPluginLoadObserver* observer =
+            new WebPluginLoadObserver(this, request.url(), notifyData);
+        m_pluginLoadObservers.append(observer);
+        WebDataSourceImpl::setNextPluginLoadObserver(observer);
+    }
+
+    FrameLoadRequest frameRequest(request.toResourceRequest());
+    frameRequest.setFrameName(target);
+
+    frame->loader()->loadFrameRequest(
+        frameRequest,
+        false,  // lock history
+        false,  // lock back forward list
+        0,      // event
+        0,     // form state
+        SendReferrer);
+}
+
+void WebPluginContainerImpl::didReceiveResponse(const ResourceResponse& response)
+{
+    // Make sure that the plugin receives window geometry before data, or else
+    // plugins misbehave.
+    frameRectsChanged();
+
+    WrappedResourceResponse urlResponse(response);
+    m_webPlugin->didReceiveResponse(urlResponse);
+}
+
+void WebPluginContainerImpl::didReceiveData(const char *data, int dataLength)
+{
+    m_webPlugin->didReceiveData(data, dataLength);
+}
+
+void WebPluginContainerImpl::didFinishLoading()
+{
+    m_webPlugin->didFinishLoading();
+}
+
+void WebPluginContainerImpl::didFailLoading(const ResourceError& error)
+{
+    m_webPlugin->didFailLoading(error);
+}
+
+NPObject* WebPluginContainerImpl::scriptableObject()
+{
+    return m_webPlugin->scriptableObject();
+}
+
+void WebPluginContainerImpl::willDestroyPluginLoadObserver(WebPluginLoadObserver* observer)
+{
+    size_t pos = m_pluginLoadObservers.find(observer);
+    if (pos == notFound)
+        return;
+    m_pluginLoadObservers.remove(pos);
+}
+
+// Private methods -------------------------------------------------------------
+
+WebPluginContainerImpl::~WebPluginContainerImpl()
+{
+    for (size_t i = 0; i < m_pluginLoadObservers.size(); ++i)
+        m_pluginLoadObservers[i]->clearPluginContainer();
+    m_webPlugin->destroy();
+}
+
+void WebPluginContainerImpl::handleMouseEvent(MouseEvent* event)
+{
+    ASSERT(parent()->isFrameView());
+
+    // We cache the parent FrameView here as the plugin widget could be deleted
+    // in the call to HandleEvent. See http://b/issue?id=1362948
+    FrameView* parentView = static_cast<FrameView*>(parent());
+
+    WebMouseEventBuilder webEvent(parentView, *event);
+    if (webEvent.type == WebInputEvent::Undefined)
+        return;
+
+    if (event->type() == eventNames().mousedownEvent) {
+        // Ensure that the frame containing the plugin has focus.
+        Frame* containingFrame = parentView->frame();
+        if (Page* currentPage = containingFrame->page())
+            currentPage->focusController()->setFocusedFrame(containingFrame);
+        // Give focus to our containing HTMLPluginElement.
+        containingFrame->document()->setFocusedNode(m_element);
+    }
+
+    WebCursorInfo cursorInfo;
+    bool handled = m_webPlugin->handleInputEvent(webEvent, cursorInfo);
+#if !PLATFORM(DARWIN)
+    // TODO(pkasting): http://b/1119691 This conditional seems exactly
+    // backwards, but if I reverse it, giving focus to a transparent
+    // (windowless) plugin fails.
+    handled = !handled;
+    // TODO(awalker): oddly, the above is not true in Mac builds.  Looking
+    // at Apple's corresponding code for Mac and Windows (PluginViewMac and
+    // PluginViewWin), setDefaultHandled() gets called when handleInputEvent()
+    // returns true, which then indicates to WebCore that the plugin wants to
+    // swallow the event--which is what we want.  Calling setDefaultHandled()
+    // fixes several Mac Chromium bugs, but does indeed prevent windowless plugins
+    // from getting focus in Windows builds, as pkasting notes above.  So for
+    // now, we only do so in Mac builds.
+#endif
+    if (handled)
+        event->setDefaultHandled();
+
+    // A windowless plugin can change the cursor in response to a mouse move
+    // event.  We need to reflect the changed cursor in the frame view as the
+    // mouse is moved in the boundaries of the windowless plugin.
+    Page* page = parentView->frame()->page();
+    if (!page)
+        return;
+    ChromeClientImpl* chromeClient =
+        static_cast<ChromeClientImpl*>(page->chrome()->client());
+    chromeClient->setCursorForPlugin(cursorInfo);
+}
+
+void WebPluginContainerImpl::handleKeyboardEvent(KeyboardEvent* event)
+{
+    WebKeyboardEventBuilder webEvent(*event);
+    if (webEvent.type == WebInputEvent::Undefined)
+        return;
+
+    WebCursorInfo cursor_info;
+    bool handled = m_webPlugin->handleInputEvent(webEvent, cursor_info);
+#if !PLATFORM(DARWIN)
+    // TODO(pkasting): http://b/1119691 See above.
+    handled = !handled;
+#endif
+    if (handled)
+        event->setDefaultHandled();
+}
+
+void WebPluginContainerImpl::calculateGeometry(const IntRect& frameRect,
+                                               IntRect& windowRect,
+                                               IntRect& clipRect,
+                                               Vector<IntRect>& cutOutRects)
+{
+    windowRect = IntRect(
+        parent()->contentsToWindow(frameRect.location()), frameRect.size());
+
+    // Calculate a clip-rect so that we don't overlap the scrollbars, etc.
+    clipRect = windowClipRect();
+    clipRect.move(-windowRect.x(), -windowRect.y());
+
+    windowCutOutRects(frameRect, cutOutRects);
+    // Convert to the plugin position.
+    for (size_t i = 0; i < cutOutRects.size(); i++)
+        cutOutRects[i].move(-frameRect.x(), -frameRect.y());
+}
+
+WebCore::IntRect WebPluginContainerImpl::windowClipRect() const
+{
+    // Start by clipping to our bounds.
+    IntRect clipRect =
+        convertToContainingWindow(IntRect(0, 0, width(), height()));
+
+    // document()->renderer() can be 0 when we receive messages from the
+    // plugins while we are destroying a frame.
+    if (m_element->renderer()->document()->renderer()) {
+        // Take our element and get the clip rect from the enclosing layer and
+        // frame view.
+        RenderLayer* layer = m_element->renderer()->enclosingLayer();
+        clipRect.intersect(
+            m_element->document()->view()->windowClipRectForLayer(layer, true));
+    }
+
+    return clipRect;
+}
+
+static void getObjectStack(const RenderObject* ro,
+                           Vector<const RenderObject*>* roStack)
+{
+    roStack->clear();
+    while (ro) {
+        roStack->append(ro);
+        ro = ro->parent();
+    }
+}
+
+// Returns true if stack1 is at or above stack2
+static bool checkStackOnTop(
+        const Vector<const RenderObject*>& iframeZstack,
+        const Vector<const RenderObject*>& pluginZstack)
+{
+    for (size_t i1 = 0, i2 = 0;
+         i1 < iframeZstack.size() && i2 < pluginZstack.size();
+         i1++, i2++) {
+        // The root is at the end of these stacks.  We want to iterate
+        // root-downwards so we index backwards from the end.
+        const RenderObject* ro1 = iframeZstack[iframeZstack.size() - 1 - i1];
+        const RenderObject* ro2 = pluginZstack[pluginZstack.size() - 1 - i2];
+
+        if (ro1 != ro2) {
+            // When we find nodes in the stack that are not the same, then
+            // we've found the nodes just below the lowest comment ancestor.
+            // Determine which should be on top.
+
+            // See if z-index determines an order.
+            if (ro1->style() && ro2->style()) {
+                int z1 = ro1->style()->zIndex();
+                int z2 = ro2->style()->zIndex();
+                if (z1 > z2)
+                    return true;
+                if (z1 < z2)
+                    return false;
+            }
+
+            // For compatibility with IE: when the plugin is not positioned,
+            // it stacks behind the iframe, even if it's later in the
+            // document order.
+            if (ro2->style()->position() == StaticPosition)
+                return true;
+
+            // Inspect the document order.  Later order means higher
+            // stacking.
+            const RenderObject* parent = ro1->parent();
+            if (!parent)
+                return false;
+            ASSERT(parent == ro2->parent());
+
+            for (const RenderObject* ro = parent->firstChild(); ro; ro = ro->nextSibling()) {
+                if (ro == ro1)
+                    return false;
+                if (ro == ro2)
+                    return true;
+            }
+            ASSERT(false);  // We should have seen ro1 and ro2 by now.
+            return false;
+        }
+    }
+    return true;
+}
+
+// Return a set of rectangles that should not be overdrawn by the
+// plugin ("cutouts").  This helps implement the "iframe shim"
+// technique of overlaying a windowed plugin with content from the
+// page.  In a nutshell, iframe elements should occlude plugins when
+// they occur higher in the stacking order.
+void WebPluginContainerImpl::windowCutOutRects(const IntRect& frameRect,
+                                               Vector<IntRect>& cutOutRects)
+{
+    RenderObject* pluginNode = m_element->renderer();
+    ASSERT(pluginNode);
+    if (!pluginNode->style())
+        return;
+    Vector<const RenderObject*> pluginZstack;
+    Vector<const RenderObject*> iframeZstack;
+    getObjectStack(pluginNode, &pluginZstack);
+
+    // Get the parent widget
+    Widget* parentWidget = this->parent();
+    if (!parentWidget->isFrameView())
+        return;
+
+    FrameView* parentFrameView = static_cast<FrameView*>(parentWidget);
+
+    const HashSet<RefPtr<Widget> >* children = parentFrameView->children();
+    for (HashSet<RefPtr<Widget> >::const_iterator it = children->begin(); it != children->end(); ++it) {
+        // We only care about FrameView's because iframes show up as FrameViews.
+        if (!(*it)->isFrameView())
+            continue;
+
+        const FrameView* frameView =
+            static_cast<const FrameView*>((*it).get());
+        // Check to make sure we can get both the element and the RenderObject
+        // for this FrameView, if we can't just move on to the next object.
+        if (!frameView->frame() || !frameView->frame()->ownerElement()
+            || !frameView->frame()->ownerElement()->renderer())
+            continue;
+
+        HTMLElement* element = frameView->frame()->ownerElement();
+        RenderObject* iframeRenderer = element->renderer();
+
+        if (element->hasTagName(HTMLNames::iframeTag)
+            && iframeRenderer->absoluteBoundingBoxRect().intersects(frameRect)
+            && (!iframeRenderer->style() || iframeRenderer->style()->visibility() == VISIBLE)) {
+            getObjectStack(iframeRenderer, &iframeZstack);
+            if (checkStackOnTop(iframeZstack, pluginZstack)) {
+                IntPoint point =
+                    roundedIntPoint(iframeRenderer->localToAbsolute());
+                RenderBox* rbox = toRenderBox(iframeRenderer);
+                IntSize size(rbox->width(), rbox->height());
+                cutOutRects.append(IntRect(point, size));
+            }
+        }
+    }
+}
+
+} // namespace WebKit
diff --git a/WebKit/chromium/src/WebPluginContainerImpl.h b/WebKit/chromium/src/WebPluginContainerImpl.h
new file mode 100644
index 0000000..00450bb
--- /dev/null
+++ b/WebKit/chromium/src/WebPluginContainerImpl.h
@@ -0,0 +1,123 @@
+/*
+ * 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 WebPluginContainerImpl_h
+#define WebPluginContainerImpl_h
+
+// FIXME: This relative path is a temporary hack to support using this
+// header from webkit/glue.
+#include "../public/WebPluginContainer.h"
+
+#include "Widget.h"
+#include <wtf/PassRefPtr.h>
+#include <wtf/Vector.h>
+
+struct NPObject;
+
+namespace WebCore {
+class HTMLPlugInElement;
+class IntRect;
+class KeyboardEvent;
+class MouseEvent;
+class ResourceError;
+class ResourceResponse;
+}
+
+namespace WebKit {
+
+class WebPlugin;
+class WebPluginLoadObserver;
+
+class WebPluginContainerImpl : public WebCore::Widget, public WebPluginContainer {
+public:
+    static PassRefPtr<WebPluginContainerImpl> create(WebCore::HTMLPlugInElement* element, WebPlugin* webPlugin)
+    {
+        return adoptRef(new WebPluginContainerImpl(element, webPlugin));
+    }
+
+    // Widget methods
+    virtual void setFrameRect(const WebCore::IntRect&);
+    virtual void paint(WebCore::GraphicsContext*, const WebCore::IntRect&);
+    virtual void invalidateRect(const WebCore::IntRect&);
+    virtual void setFocus();
+    virtual void show();
+    virtual void hide();
+    virtual void handleEvent(WebCore::Event*);
+    virtual void frameRectsChanged();
+    virtual void setParentVisible(bool);
+    virtual void setParent(WebCore::ScrollView*);
+
+    // WebPluginContainer methods
+    virtual void invalidate();
+    virtual void invalidateRect(const WebRect&);
+    virtual void reportGeometry();
+    virtual void clearScriptObjects();
+    virtual NPObject* scriptableObjectForElement();
+    virtual WebString executeScriptURL(const WebURL&, bool popupsAllowed);
+    virtual void loadFrameRequest(const WebURLRequest&, const WebString& target, bool notifyNeeded, void* notifyData);
+
+    // Resource load events for the plugin's source data:
+    void didReceiveResponse(const WebCore::ResourceResponse&);
+    void didReceiveData(const char *data, int dataLength);
+    void didFinishLoading();
+    void didFailLoading(const WebCore::ResourceError&);
+
+    NPObject* scriptableObject();
+
+    // This cannot be null.
+    WebPlugin* plugin() { return m_webPlugin; }
+
+    void willDestroyPluginLoadObserver(WebPluginLoadObserver*);
+
+private:
+    WebPluginContainerImpl(WebCore::HTMLPlugInElement* element, WebPlugin* webPlugin)
+        : m_element(element)
+        , m_webPlugin(webPlugin) { }
+    ~WebPluginContainerImpl();
+
+    void handleMouseEvent(WebCore::MouseEvent*);
+    void handleKeyboardEvent(WebCore::KeyboardEvent*);
+
+    void calculateGeometry(const WebCore::IntRect& frameRect,
+                           WebCore::IntRect& windowRect,
+                           WebCore::IntRect& clipRect,
+                           Vector<WebCore::IntRect>& cutOutRects);
+    WebCore::IntRect windowClipRect() const;
+    void windowCutOutRects(const WebCore::IntRect& frameRect,
+                           Vector<WebCore::IntRect>& cutOutRects);
+
+    WebCore::HTMLPlugInElement* m_element;
+    WebPlugin* m_webPlugin;
+    Vector<WebPluginLoadObserver*> m_pluginLoadObservers;
+};
+
+} // namespace WebKit
+
+#endif
diff --git a/WebKit/chromium/src/WebPluginListBuilderImpl.cpp b/WebKit/chromium/src/WebPluginListBuilderImpl.cpp
new file mode 100644
index 0000000..6926a2d
--- /dev/null
+++ b/WebKit/chromium/src/WebPluginListBuilderImpl.cpp
@@ -0,0 +1,67 @@
+/*
+ * 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 "WebPluginListBuilderImpl.h"
+
+#include "PluginData.h"
+#include "WebString.h"
+#include <wtf/Vector.h>
+
+using namespace WebCore;
+
+namespace WebKit {
+
+void WebPluginListBuilderImpl::addPlugin(const WebString& name, const WebString& description, const WebString& fileName)
+{
+    PluginInfo* info = new PluginInfo();
+    info->name = name;
+    info->desc = description;
+    info->file = fileName;
+    m_results->append(info);
+}
+
+void WebPluginListBuilderImpl::addMediaTypeToLastPlugin(const WebString& name, const WebString& description)
+{
+    MimeClassInfo* info = new MimeClassInfo();
+    info->type = name;
+    info->desc = description;
+    m_results->last()->mimes.append(info);
+}
+
+void WebPluginListBuilderImpl::addFileExtensionToLastMediaType(const WebString& extension)
+{
+    MimeClassInfo* info = m_results->last()->mimes.last();
+    if (!info->suffixes.isEmpty())
+        info->suffixes.append(',');
+    info->suffixes.append(extension);
+}
+
+} // namespace WebKit
diff --git a/WebKit/chromium/src/WebPluginListBuilderImpl.h b/WebKit/chromium/src/WebPluginListBuilderImpl.h
new file mode 100644
index 0000000..7a8a497
--- /dev/null
+++ b/WebKit/chromium/src/WebPluginListBuilderImpl.h
@@ -0,0 +1,56 @@
+/*
+ * 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 WebPluginListBuilderImpl_h
+#define WebPluginListBuilderImpl_h
+
+#include "WebPluginListBuilder.h"
+
+#include "PluginData.h"
+#include <wtf/Vector.h>
+
+namespace WebKit {
+
+class WebPluginListBuilderImpl : public WebPluginListBuilder {
+public:
+    WebPluginListBuilderImpl(Vector<WebCore::PluginInfo*>* results) : m_results(results) { }
+
+    // WebPluginListBuilder methods:
+    virtual void addPlugin(const WebString& name, const WebString& description, const WebString& fileName);
+    virtual void addMediaTypeToLastPlugin(const WebString& name, const WebString& description);
+    virtual void addFileExtensionToLastMediaType(const WebString& extension);
+
+private:
+    Vector<WebCore::PluginInfo*>* m_results;
+};
+
+} // namespace WebKit
+
+#endif
diff --git a/WebKit/chromium/src/WebPluginLoadObserver.cpp b/WebKit/chromium/src/WebPluginLoadObserver.cpp
new file mode 100644
index 0000000..5ec59a6
--- /dev/null
+++ b/WebKit/chromium/src/WebPluginLoadObserver.cpp
@@ -0,0 +1,57 @@
+/*
+ * 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 "WebPluginLoadObserver.h"
+
+#include "WebPlugin.h"
+#include "WebPluginContainerImpl.h"
+
+namespace WebKit {
+
+WebPluginLoadObserver::~WebPluginLoadObserver()
+{
+    if (m_pluginContainer)
+        m_pluginContainer->willDestroyPluginLoadObserver(this);
+}
+
+void WebPluginLoadObserver::didFinishLoading()
+{
+    if (m_pluginContainer)
+        m_pluginContainer->plugin()->didFinishLoadingFrameRequest(m_notifyURL, m_notifyData);
+}
+
+void WebPluginLoadObserver::didFailLoading(const WebURLError& error)
+{
+    if (m_pluginContainer)
+        m_pluginContainer->plugin()->didFailLoadingFrameRequest(m_notifyURL, m_notifyData, error);
+}
+
+} // namespace WebKit
diff --git a/WebKit/chromium/src/WebPluginLoadObserver.h b/WebKit/chromium/src/WebPluginLoadObserver.h
new file mode 100644
index 0000000..097d08d
--- /dev/null
+++ b/WebKit/chromium/src/WebPluginLoadObserver.h
@@ -0,0 +1,67 @@
+/*
+ * 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 WebPluginLoadObserver_h
+#define WebPluginLoadObserver_h
+
+#include "../public/WebURL.h"
+
+namespace WebKit {
+
+class WebPluginContainerImpl;
+struct WebURLError;
+
+class WebPluginLoadObserver {
+public:
+    WebPluginLoadObserver(WebPluginContainerImpl* pluginContainer,
+                          const WebURL& notifyURL, void* notifyData)
+        : m_pluginContainer(pluginContainer)
+        , m_notifyURL(notifyURL)
+        , m_notifyData(notifyData)
+    {
+    }
+
+    ~WebPluginLoadObserver();
+
+    const WebURL& url() const { return m_notifyURL; }
+
+    void clearPluginContainer() { m_pluginContainer = 0; }
+    void didFinishLoading();
+    void didFailLoading(const WebURLError&);
+
+private:
+    WebPluginContainerImpl* m_pluginContainer;
+    WebURL m_notifyURL;
+    void* m_notifyData;
+};
+
+} // namespace WebKit
+
+#endif
diff --git a/WebKit/chromium/src/WebPopupMenuImpl.cpp b/WebKit/chromium/src/WebPopupMenuImpl.cpp
new file mode 100644
index 0000000..f6d360e
--- /dev/null
+++ b/WebKit/chromium/src/WebPopupMenuImpl.cpp
@@ -0,0 +1,312 @@
+/*
+ * Copyright (C) 2009 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ *     * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *     * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ *     * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "WebPopupMenuImpl.h"
+
+#include "Cursor.h"
+#include "FramelessScrollView.h"
+#include "FrameView.h"
+#include "IntRect.h"
+#include "PlatformContextSkia.h"
+#include "PlatformKeyboardEvent.h"
+#include "PlatformMouseEvent.h"
+#include "PlatformWheelEvent.h"
+#include "SkiaUtils.h"
+
+#include "WebInputEvent.h"
+#include "WebInputEventConversion.h"
+#include "WebRect.h"
+#include "WebWidgetClient.h"
+
+#include <skia/ext/platform_canvas.h>
+
+using namespace WebCore;
+
+namespace WebKit {
+
+// WebPopupMenu ---------------------------------------------------------------
+
+WebPopupMenu* WebPopupMenu::create(WebWidgetClient* client)
+{
+    return new WebPopupMenuImpl(client);
+}
+
+// WebWidget ------------------------------------------------------------------
+
+WebPopupMenuImpl::WebPopupMenuImpl(WebWidgetClient* client)
+    : m_client(client)
+    , m_widget(0)
+{
+    // set to impossible point so we always get the first mouse pos
+    m_lastMousePosition = WebPoint(-1, -1);
+}
+
+WebPopupMenuImpl::~WebPopupMenuImpl()
+{
+    if (m_widget)
+        m_widget->setClient(0);
+}
+
+void WebPopupMenuImpl::Init(FramelessScrollView* widget, const WebRect& bounds)
+{
+    m_widget = widget;
+    m_widget->setClient(this);
+
+    if (m_client) {
+        m_client->setWindowRect(bounds);
+        m_client->show(WebNavigationPolicy());  // Policy is ignored
+    }
+}
+
+void WebPopupMenuImpl::MouseMove(const WebMouseEvent& event)
+{
+    // don't send mouse move messages if the mouse hasn't moved.
+    if (event.x != m_lastMousePosition.x || event.y != m_lastMousePosition.y) {
+        m_lastMousePosition = WebPoint(event.x, event.y);
+        m_widget->handleMouseMoveEvent(PlatformMouseEventBuilder(m_widget, event));
+    }
+}
+
+void WebPopupMenuImpl::MouseLeave(const WebMouseEvent& event)
+{
+    m_widget->handleMouseMoveEvent(PlatformMouseEventBuilder(m_widget, event));
+}
+
+void WebPopupMenuImpl::MouseDown(const WebMouseEvent& event)
+{
+    m_widget->handleMouseDownEvent(PlatformMouseEventBuilder(m_widget, event));
+}
+
+void WebPopupMenuImpl::MouseUp(const WebMouseEvent& event)
+{
+    mouseCaptureLost();
+    m_widget->handleMouseReleaseEvent(PlatformMouseEventBuilder(m_widget, event));
+}
+
+void WebPopupMenuImpl::MouseWheel(const WebMouseWheelEvent& event)
+{
+    m_widget->handleWheelEvent(PlatformWheelEventBuilder(m_widget, event));
+}
+
+bool WebPopupMenuImpl::KeyEvent(const WebKeyboardEvent& event)
+{
+    return m_widget->handleKeyEvent(PlatformKeyboardEventBuilder(event));
+}
+
+// WebWidget -------------------------------------------------------------------
+
+void WebPopupMenuImpl::close()
+{
+    if (m_widget)
+        m_widget->hide();
+
+    m_client = 0;
+
+    deref();  // Balances ref() from WebWidget::Create
+}
+
+void WebPopupMenuImpl::resize(const WebSize& newSize)
+{
+    if (m_size == newSize)
+        return;
+    m_size = newSize;
+
+    if (m_widget) {
+      IntRect newGeometry(0, 0, m_size.width, m_size.height);
+      m_widget->setFrameRect(newGeometry);
+    }
+
+    if (m_client) {
+      WebRect damagedRect(0, 0, m_size.width, m_size.height);
+      m_client->didInvalidateRect(damagedRect);
+    }
+}
+
+void WebPopupMenuImpl::layout()
+{
+}
+
+void WebPopupMenuImpl::paint(WebCanvas* canvas, const WebRect& rect)
+{
+    if (!m_widget)
+        return;
+
+    if (!rect.isEmpty()) {
+#if WEBKIT_USING_CG
+        GraphicsContext gc(canvas);
+#elif WEBKIT_USING_SKIA
+        PlatformContextSkia context(canvas);
+        // PlatformGraphicsContext is actually a pointer to PlatformContextSkia.
+        GraphicsContext gc(reinterpret_cast<PlatformGraphicsContext*>(&context));
+#else
+        notImplemented();
+#endif
+        m_widget->paint(&gc, rect);
+    }
+}
+
+bool WebPopupMenuImpl::handleInputEvent(const WebInputEvent& inputEvent)
+{
+    if (!m_widget)
+        return false;
+
+    // TODO (jcampan): WebKit seems to always return false on mouse events
+    // methods. For now we'll assume it has processed them (as we are only
+    // interested in whether keyboard events are processed).
+    switch (inputEvent.type) {
+    case WebInputEvent::MouseMove:
+        MouseMove(*static_cast<const WebMouseEvent*>(&inputEvent));
+        return true;
+
+    case WebInputEvent::MouseLeave:
+        MouseLeave(*static_cast<const WebMouseEvent*>(&inputEvent));
+        return true;
+
+    case WebInputEvent::MouseWheel:
+        MouseWheel(*static_cast<const WebMouseWheelEvent*>(&inputEvent));
+        return true;
+
+    case WebInputEvent::MouseDown:
+        MouseDown(*static_cast<const WebMouseEvent*>(&inputEvent));
+        return true;
+
+    case WebInputEvent::MouseUp:
+        MouseUp(*static_cast<const WebMouseEvent*>(&inputEvent));
+        return true;
+
+    // In Windows, RawKeyDown only has information about the physical key, but
+    // for "selection", we need the information about the character the key
+    // translated into. For English, the physical key value and the character
+    // value are the same, hence, "selection" works for English. But for other
+    // languages, such as Hebrew, the character value is different from the
+    // physical key value. Thus, without accepting Char event type which
+    // contains the key's character value, the "selection" won't work for
+    // non-English languages, such as Hebrew.
+    case WebInputEvent::RawKeyDown:
+    case WebInputEvent::KeyDown:
+    case WebInputEvent::KeyUp:
+    case WebInputEvent::Char:
+        return KeyEvent(*static_cast<const WebKeyboardEvent*>(&inputEvent));
+
+    default:
+        break;
+    }
+    return false;
+}
+
+void WebPopupMenuImpl::mouseCaptureLost()
+{
+}
+
+void WebPopupMenuImpl::setFocus(bool enable)
+{
+}
+
+bool WebPopupMenuImpl::handleCompositionEvent(
+    WebCompositionCommand command, int cursorPosition, int targetStart,
+    int targetEnd, const WebString& imeString)
+{
+    return false;
+}
+
+bool WebPopupMenuImpl::queryCompositionStatus(bool* enabled, WebRect* caretRect)
+{
+    return false;
+}
+
+void WebPopupMenuImpl::setTextDirection(WebTextDirection direction)
+{
+}
+
+
+//-----------------------------------------------------------------------------
+// WebCore::HostWindow
+
+void WebPopupMenuImpl::repaint(const IntRect& paintRect,
+                               bool contentChanged,
+                               bool immediate,
+                               bool repaintContentOnly)
+{
+    // Ignore spurious calls.
+    if (!contentChanged || paintRect.isEmpty())
+        return;
+    if (m_client)
+        m_client->didInvalidateRect(paintRect);
+}
+
+void WebPopupMenuImpl::scroll(const IntSize& scrollDelta,
+                              const IntRect& scrollRect,
+                              const IntRect& clipRect)
+{
+    if (m_client) {
+        int dx = scrollDelta.width();
+        int dy = scrollDelta.height();
+        m_client->didScrollRect(dx, dy, clipRect);
+    }
+}
+
+IntPoint WebPopupMenuImpl::screenToWindow(const IntPoint& point) const
+{
+    notImplemented();
+    return IntPoint();
+}
+
+IntRect WebPopupMenuImpl::windowToScreen(const IntRect& rect) const
+{
+    notImplemented();
+    return IntRect();
+}
+
+void WebPopupMenuImpl::scrollRectIntoView(const IntRect&, const ScrollView*) const
+{
+    // Nothing to be done here since we do not have the concept of a container
+    // that implements its own scrolling.
+}
+
+void WebPopupMenuImpl::scrollbarsModeDidChange() const
+{
+    // Nothing to be done since we have no concept of different scrollbar modes.
+}
+
+//-----------------------------------------------------------------------------
+// WebCore::FramelessScrollViewClient
+
+void WebPopupMenuImpl::popupClosed(FramelessScrollView* widget)
+{
+    ASSERT(widget == m_widget);
+    if (m_widget) {
+        m_widget->setClient(0);
+        m_widget = 0;
+    }
+    m_client->closeWidgetSoon();
+}
+
+} // namespace WebKit
diff --git a/WebKit/chromium/src/WebPopupMenuImpl.h b/WebKit/chromium/src/WebPopupMenuImpl.h
new file mode 100644
index 0000000..13eb674
--- /dev/null
+++ b/WebKit/chromium/src/WebPopupMenuImpl.h
@@ -0,0 +1,128 @@
+/*
+ * Copyright (C) 2009 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ *     * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *     * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ *     * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef WebPopupMenuImpl_h
+#define WebPopupMenuImpl_h
+
+// FIXME: Add this to FramelessScrollViewClient.h
+namespace WebCore { class FramelessScrollView; }
+
+#include "FramelessScrollViewClient.h"
+// FIXME: remove the relative paths once glue/ consumers are removed.
+#include "../public/WebPoint.h"
+#include "../public/WebPopupMenu.h"
+#include "../public/WebSize.h"
+#include <wtf/RefCounted.h>
+
+namespace WebCore {
+class Frame;
+class FramelessScrollView;
+class KeyboardEvent;
+class Page;
+class PlatformKeyboardEvent;
+class Range;
+class Widget;
+}
+
+namespace WebKit {
+class WebKeyboardEvent;
+class WebMouseEvent;
+class WebMouseWheelEvent;
+struct WebRect;
+
+class WebPopupMenuImpl : public WebPopupMenu,
+                         public WebCore::FramelessScrollViewClient,
+                         public RefCounted<WebPopupMenuImpl> {
+public:
+    // WebWidget
+    virtual void close();
+    virtual WebSize size() { return m_size; }
+    virtual void resize(const WebSize&);
+    virtual void layout();
+    virtual void paint(WebCanvas* canvas, const WebRect& rect);
+    virtual bool handleInputEvent(const WebInputEvent&);
+    virtual void mouseCaptureLost();
+    virtual void setFocus(bool enable);
+    virtual bool handleCompositionEvent(
+        WebCompositionCommand command, int cursorPosition,
+        int targetStart, int targetEnd, const WebString& text);
+    virtual bool queryCompositionStatus(bool* enabled, WebRect* caretRect);
+    virtual void setTextDirection(WebTextDirection direction);
+
+    // WebPopupMenuImpl
+    void Init(WebCore::FramelessScrollView* widget,
+              const WebRect& bounds);
+
+    WebWidgetClient* client() { return m_client; }
+
+    void MouseMove(const WebMouseEvent&);
+    void MouseLeave(const WebMouseEvent&);
+    void MouseDown(const WebMouseEvent&);
+    void MouseUp(const WebMouseEvent&);
+    void MouseDoubleClick(const WebMouseEvent&);
+    void MouseWheel(const WebMouseWheelEvent&);
+    bool KeyEvent(const WebKeyboardEvent&);
+
+   protected:
+    friend class WebPopupMenu;  // For WebPopupMenu::create
+    friend class WTF::RefCounted<WebPopupMenuImpl>;
+
+    WebPopupMenuImpl(WebWidgetClient* client);
+    ~WebPopupMenuImpl();
+
+    // WebCore::HostWindow methods:
+    virtual void repaint(
+        const WebCore::IntRect&, bool contentChanged, bool immediate = false,
+        bool repaintContentOnly = false);
+    virtual void scroll(
+        const WebCore::IntSize& scrollDelta, const WebCore::IntRect& scrollRect,
+        const WebCore::IntRect& clipRect);
+    virtual WebCore::IntPoint screenToWindow(const WebCore::IntPoint&) const;
+    virtual WebCore::IntRect windowToScreen(const WebCore::IntRect&) const;
+    virtual PlatformPageClient platformPageClient() const { return 0; }
+    virtual void scrollRectIntoView(const WebCore::IntRect&, const WebCore::ScrollView*) const;
+    virtual void scrollbarsModeDidChange() const;
+
+    // WebCore::FramelessScrollViewClient methods:
+    virtual void popupClosed(WebCore::FramelessScrollView*);
+
+    WebWidgetClient* m_client;
+    WebSize m_size;
+
+    WebPoint m_lastMousePosition;
+
+    // This is a non-owning ref.  The popup will notify us via popupClosed()
+    // before it is destroyed.
+    WebCore::FramelessScrollView* m_widget;
+};
+
+} // namespace WebKit
+
+#endif
diff --git a/WebKit/chromium/src/WebRange.cpp b/WebKit/chromium/src/WebRange.cpp
new file mode 100644
index 0000000..3dd000d
--- /dev/null
+++ b/WebKit/chromium/src/WebRange.cpp
@@ -0,0 +1,113 @@
+/*
+ * 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 "WebRange.h"
+
+#include "Range.h"
+#include "WebNode.h"
+#include "WebString.h"
+#include <wtf/PassRefPtr.h>
+
+using namespace WebCore;
+
+namespace WebKit {
+
+class WebRangePrivate : public Range {
+};
+
+void WebRange::reset()
+{
+    assign(0);
+}
+
+void WebRange::assign(const WebRange& other)
+{
+    WebRangePrivate* p = const_cast<WebRangePrivate*>(other.m_private);
+    if (p)
+        p->ref();
+    assign(p);
+}
+
+int WebRange::startOffset() const
+{
+    return m_private->startOffset();
+}
+
+int WebRange::endOffset() const
+{
+    return m_private->endOffset();
+}
+
+WebNode WebRange::startContainer(int& exceptionCode) const
+{
+    return PassRefPtr<Node>(m_private->startContainer(exceptionCode));
+}
+
+WebNode WebRange::endContainer(int& exceptionCode) const
+{
+    return PassRefPtr<Node>(m_private->endContainer(exceptionCode));
+}
+
+WebString WebRange::toHTMLText() const
+{
+    return m_private->toHTML();
+}
+
+WebString WebRange::toPlainText() const
+{
+    return m_private->text();
+}
+
+WebRange::WebRange(const WTF::PassRefPtr<WebCore::Range>& range)
+    : m_private(static_cast<WebRangePrivate*>(range.releaseRef()))
+{
+}
+
+WebRange& WebRange::operator=(const WTF::PassRefPtr<WebCore::Range>& range)
+{
+    assign(static_cast<WebRangePrivate*>(range.releaseRef()));
+    return *this;
+}
+
+WebRange::operator WTF::PassRefPtr<WebCore::Range>() const
+{
+    return PassRefPtr<Range>(const_cast<WebRangePrivate*>(m_private));
+}
+
+void WebRange::assign(WebRangePrivate* p)
+{
+    // p is already ref'd for us by the caller
+    if (m_private)
+        m_private->deref();
+    m_private = p;
+}
+
+} // namespace WebKit
diff --git a/WebKit/chromium/src/WebRuntimeFeatures.cpp b/WebKit/chromium/src/WebRuntimeFeatures.cpp
new file mode 100644
index 0000000..b630a09
--- /dev/null
+++ b/WebKit/chromium/src/WebRuntimeFeatures.cpp
@@ -0,0 +1,154 @@
+/*
+ * 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 "WebRuntimeFeatures.h"
+
+#include "RuntimeEnabledFeatures.h"
+#include "WebMediaPlayerClientImpl.h"
+#include "WebSocket.h"
+
+using namespace WebCore;
+
+namespace WebKit {
+
+void WebRuntimeFeatures::enableDatabase(bool enable)
+{
+#if ENABLE(DATABASE)
+    RuntimeEnabledFeatures::setDatabaseEnabled(enable);
+#endif
+}
+
+bool WebRuntimeFeatures::isDatabaseEnabled()
+{
+#if ENABLE(DATABASE)
+    return RuntimeEnabledFeatures::databaseEnabled();
+#else
+    return false;
+#endif
+}
+
+void WebRuntimeFeatures::enableLocalStorage(bool enable)
+{
+#if ENABLE(DOM_STORAGE)
+    RuntimeEnabledFeatures::setLocalStorageEnabled(enable);
+#endif
+}
+
+bool WebRuntimeFeatures::isLocalStorageEnabled()
+{
+#if ENABLE(DOM_STORAGE)
+    return RuntimeEnabledFeatures::localStorageEnabled();
+#else
+    return false;
+#endif
+}
+
+void WebRuntimeFeatures::enableSessionStorage(bool enable)
+{
+#if ENABLE(DOM_STORAGE)
+    RuntimeEnabledFeatures::setSessionStorageEnabled(enable);
+#endif
+}
+
+bool WebRuntimeFeatures::isSessionStorageEnabled()
+{
+#if ENABLE(DOM_STORAGE)
+    return RuntimeEnabledFeatures::sessionStorageEnabled();
+#else
+    return false;
+#endif
+}
+
+void WebRuntimeFeatures::enableMediaPlayer(bool enable)
+{
+#if ENABLE(VIDEO)
+    WebMediaPlayerClientImpl::setIsEnabled(enable);
+#endif
+}
+
+bool WebRuntimeFeatures::isMediaPlayerEnabled()
+{
+#if ENABLE(VIDEO)
+    return WebMediaPlayerClientImpl::isEnabled();
+#else
+    return false;
+#endif
+}
+
+void WebRuntimeFeatures::enableSockets(bool enable)
+{
+#if ENABLE(WEB_SOCKETS)
+    WebSocket::setIsAvailable(enable);
+#endif
+}
+
+bool WebRuntimeFeatures::isSocketsEnabled()
+{
+#if ENABLE(WEB_SOCKETS)
+    return WebSocket::isAvailable();
+#else
+    return false;
+#endif
+}
+
+void WebRuntimeFeatures::enableNotifications(bool enable)
+{
+#if ENABLE(NOTIFICATIONS)
+    RuntimeEnabledFeatures::setNotificationsEnabled(enable);
+#endif
+}
+
+bool WebRuntimeFeatures::isNotificationsEnabled()
+{
+#if ENABLE(NOTIFICATIONS)
+    return RuntimeEnabledFeatures::notificationsEnabled();
+#else
+    return false;
+#endif
+}
+
+void WebRuntimeFeatures::enableApplicationCache(bool enable)
+{
+#if ENABLE(OFFLINE_WEB_APPLICATIONS)
+    RuntimeEnabledFeatures::setApplicationCacheEnabled(enable);
+#endif
+}
+
+bool WebRuntimeFeatures::isApplicationCacheEnabled()
+{
+#if ENABLE(OFFLINE_WEB_APPLICATIONS)
+    return RuntimeEnabledFeatures::applicationCacheEnabled();
+#else
+    return false;
+#endif
+}
+
+} // namespace WebKit

-- 
WebKit Debian packaging



More information about the Pkg-webkit-commits mailing list