summaryrefslogtreecommitdiffstats
path: root/Source/WebCore/platform/chromium
diff options
context:
space:
mode:
authorBen Murdoch <benm@google.com>2011-05-13 16:23:25 +0100
committerBen Murdoch <benm@google.com>2011-05-16 11:35:02 +0100
commit65f03d4f644ce73618e5f4f50dd694b26f55ae12 (patch)
treef478babb801e720de7bfaee23443ffe029f58731 /Source/WebCore/platform/chromium
parent47de4a2fb7262c7ebdb9cd133ad2c54c187454d0 (diff)
downloadexternal_webkit-65f03d4f644ce73618e5f4f50dd694b26f55ae12.zip
external_webkit-65f03d4f644ce73618e5f4f50dd694b26f55ae12.tar.gz
external_webkit-65f03d4f644ce73618e5f4f50dd694b26f55ae12.tar.bz2
Merge WebKit at r75993: Initial merge by git.
Change-Id: I602bbdc3974787a3b0450456a30a7868286921c3
Diffstat (limited to 'Source/WebCore/platform/chromium')
-rw-r--r--Source/WebCore/platform/chromium/ChromiumBridge.h4
-rw-r--r--Source/WebCore/platform/chromium/ClipboardUtilitiesChromium.h5
-rw-r--r--Source/WebCore/platform/chromium/DragDataChromium.cpp13
-rw-r--r--Source/WebCore/platform/chromium/GeolocationServiceChromium.cpp114
-rw-r--r--Source/WebCore/platform/chromium/GeolocationServiceChromium.h87
-rw-r--r--Source/WebCore/platform/chromium/PopupMenuChromium.cpp54
-rw-r--r--Source/WebCore/platform/chromium/PopupMenuChromium.h5
7 files changed, 53 insertions, 229 deletions
diff --git a/Source/WebCore/platform/chromium/ChromiumBridge.h b/Source/WebCore/platform/chromium/ChromiumBridge.h
index 56969ef..d3b8528 100644
--- a/Source/WebCore/platform/chromium/ChromiumBridge.h
+++ b/Source/WebCore/platform/chromium/ChromiumBridge.h
@@ -159,10 +159,6 @@ namespace WebCore {
// Forms --------------------------------------------------------------
static void notifyFormStateChanged(const Document*);
-#if !ENABLE(CLIENT_BASED_GEOLOCATION)
- // Geolocation --------------------------------------------------------
- static GeolocationServiceBridge* createGeolocationServiceBridge(GeolocationServiceChromium*);
-#endif
// Databases ----------------------------------------------------------
// Returns a handle to the DB file and ooptionally a handle to its containing directory
static PlatformFileHandle databaseOpenFile(const String& vfsFleName, int desiredFlags);
diff --git a/Source/WebCore/platform/chromium/ClipboardUtilitiesChromium.h b/Source/WebCore/platform/chromium/ClipboardUtilitiesChromium.h
index 9fdad42..3e6f92a 100644
--- a/Source/WebCore/platform/chromium/ClipboardUtilitiesChromium.h
+++ b/Source/WebCore/platform/chromium/ClipboardUtilitiesChromium.h
@@ -28,6 +28,9 @@
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
+#ifndef ClipboardUtilitiesChromium_h
+#define ClipboardUtilitiesChromium_h
+
#include <wtf/Forward.h>
namespace WebCore {
@@ -40,3 +43,5 @@ void replaceNewlinesWithWindowsStyleNewlines(String&);
void replaceNBSPWithSpace(String&);
} // namespace WebCore
+
+#endif // ClipboardUtilitiesChromium_h
diff --git a/Source/WebCore/platform/chromium/DragDataChromium.cpp b/Source/WebCore/platform/chromium/DragDataChromium.cpp
index 2b04523..8c20a00 100644
--- a/Source/WebCore/platform/chromium/DragDataChromium.cpp
+++ b/Source/WebCore/platform/chromium/DragDataChromium.cpp
@@ -35,6 +35,7 @@
#include "ClipboardMimeTypes.h"
#include "DocumentFragment.h"
#include "FileSystem.h"
+#include "Frame.h"
#include "KURL.h"
#include "markup.h"
#include "NotImplemented.h"
@@ -47,13 +48,13 @@ static bool containsHTML(const ChromiumDataObject* dropData)
return dropData->types().contains(mimeTypeTextHTML);
}
-bool DragData::containsURL(FilenameConversionPolicy filenamePolicy) const
+bool DragData::containsURL(Frame*, FilenameConversionPolicy filenamePolicy) const
{
return m_platformDragData->types().contains(mimeTypeURL)
|| (filenamePolicy == ConvertFilenames && m_platformDragData->containsFilenames());
}
-String DragData::asURL(FilenameConversionPolicy filenamePolicy, String* title) const
+String DragData::asURL(Frame*, FilenameConversionPolicy filenamePolicy, String* title) const
{
String url;
if (m_platformDragData->types().contains(mimeTypeURL)) {
@@ -84,7 +85,7 @@ bool DragData::containsPlainText() const
return m_platformDragData->types().contains(mimeTypeTextPlain);
}
-String DragData::asPlainText() const
+String DragData::asPlainText(Frame*) const
{
bool ignoredSuccess;
return m_platformDragData->getData(mimeTypeTextPlain, ignoredSuccess);
@@ -109,13 +110,13 @@ bool DragData::canSmartReplace() const
bool DragData::containsCompatibleContent() const
{
return containsPlainText()
- || containsURL()
+ || containsURL(0)
|| containsHTML(m_platformDragData)
|| containsColor()
|| containsFiles();
}
-PassRefPtr<DocumentFragment> DragData::asFragment(Document* doc) const
+PassRefPtr<DocumentFragment> DragData::asFragment(Frame* frame, PassRefPtr<Range>, bool, bool&) const
{
/*
* Order is richest format first. On OSX this is:
@@ -137,7 +138,7 @@ PassRefPtr<DocumentFragment> DragData::asFragment(Document* doc) const
if (m_platformDragData->types().contains(mimeTypeTextHTML)) {
bool ignoredSuccess;
- RefPtr<DocumentFragment> fragment = createFragmentFromMarkup(doc,
+ RefPtr<DocumentFragment> fragment = createFragmentFromMarkup(frame->document(),
m_platformDragData->getData(mimeTypeTextHTML, ignoredSuccess), m_platformDragData->htmlBaseUrl(), FragmentScriptingNotAllowed);
return fragment.release();
}
diff --git a/Source/WebCore/platform/chromium/GeolocationServiceChromium.cpp b/Source/WebCore/platform/chromium/GeolocationServiceChromium.cpp
deleted file mode 100644
index c5e73ae..0000000
--- a/Source/WebCore/platform/chromium/GeolocationServiceChromium.cpp
+++ /dev/null
@@ -1,114 +0,0 @@
-/*
- * Copyright (c) 2010, 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 "GeolocationServiceChromium.h"
-
-#include "ChromiumBridge.h"
-
-#if ENABLE(CLIENT_BASED_GEOLOCATION)
-#error "This file should not be compiled when ENABLE(CLIENT_BASED_GEOLOCATION)"
-#endif // ENABLE(CLIENT_BASED_GEOLOCATION)
-
-namespace WebCore {
-
-GeolocationServiceBridge::~GeolocationServiceBridge()
-{
-}
-
-GeolocationServiceChromium::GeolocationServiceChromium(GeolocationServiceClient* c)
- : GeolocationService(c),
- m_geolocation(static_cast<Geolocation*>(c)),
- m_geolocationServiceBridge(ChromiumBridge::createGeolocationServiceBridge(this)),
- m_lastError(PositionError::create(PositionError::POSITION_UNAVAILABLE, ""))
-{
-}
-
-void GeolocationServiceChromium::setIsAllowed(bool allowed)
-{
- m_geolocation->setIsAllowed(allowed);
-}
-
-void GeolocationServiceChromium::setLastPosition(PassRefPtr<Geoposition> geoposition)
-{
- m_lastPosition = geoposition;
- positionChanged();
-}
-
-void GeolocationServiceChromium::setLastError(int errorCode, const String& message)
-{
- m_lastError = PositionError::create(static_cast<PositionError::ErrorCode>(errorCode), message);
- errorOccurred();
-}
-
-Frame* GeolocationServiceChromium::frame()
-{
- return m_geolocation->frame();
-}
-
-bool GeolocationServiceChromium::startUpdating(PositionOptions* options)
-{
- return m_geolocationServiceBridge->startUpdating(options);
-}
-
-void GeolocationServiceChromium::stopUpdating()
-{
- return m_geolocationServiceBridge->stopUpdating();
-}
-
-void GeolocationServiceChromium::suspend()
-{
- return m_geolocationServiceBridge->suspend();
-}
-
-void GeolocationServiceChromium::resume()
-{
- return m_geolocationServiceBridge->resume();
-}
-
-Geoposition* GeolocationServiceChromium::lastPosition() const
-{
- return m_lastPosition.get();
-}
-
-PositionError* GeolocationServiceChromium::lastError() const
-{
- return m_lastError.get();
-}
-
-static GeolocationService* createGeolocationServiceChromium(GeolocationServiceClient* c)
-{
- return new GeolocationServiceChromium(c);
-}
-
-// Sets up the factory function for GeolocationService.
-GeolocationService::FactoryFunction* GeolocationService::s_factoryFunction = &createGeolocationServiceChromium;
-
-} // namespace WebCore
diff --git a/Source/WebCore/platform/chromium/GeolocationServiceChromium.h b/Source/WebCore/platform/chromium/GeolocationServiceChromium.h
deleted file mode 100644
index 7e6f633..0000000
--- a/Source/WebCore/platform/chromium/GeolocationServiceChromium.h
+++ /dev/null
@@ -1,87 +0,0 @@
-/*
- * Copyright (c) 2010, 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 GeolocationServiceChromium_h
-#define GeolocationServiceChromium_h
-
-#include "Geolocation.h"
-#include "GeolocationService.h"
-#include "Geoposition.h"
-#include "PlatformString.h"
-#include "PositionError.h"
-
-namespace WebCore {
-
-// Provides an interface for GeolocationServiceChromium to call into the embedder.
-class GeolocationServiceBridge {
-public:
- virtual ~GeolocationServiceBridge();
- // Called by GeolocationServiceChromium.
- virtual bool startUpdating(PositionOptions*) = 0;
- virtual void stopUpdating() = 0;
- virtual void suspend() = 0;
- virtual void resume() = 0;
-
- // Called by the embedder, to identify this bridge.
- virtual int getBridgeId() const = 0;
- virtual void attachBridgeIfNeeded() = 0;
-};
-
-// This class extends GeolocationService, and uses GeolocationServiceBridge to
-// call into the embedder, as well as provides a few extra methods so that the
-// embedder can notify permission, position, error, etc.
-class GeolocationServiceChromium : public GeolocationService {
-public:
- explicit GeolocationServiceChromium(GeolocationServiceClient*);
-
- GeolocationServiceBridge* geolocationServiceBridge() const { return m_geolocationServiceBridge.get(); }
- void setIsAllowed(bool allowed);
- void setLastPosition(PassRefPtr<Geoposition>);
- void setLastError(int errorCode, const String& message);
- Frame* frame();
-
- // From GeolocationService.
- virtual bool startUpdating(PositionOptions*);
- virtual void stopUpdating();
- virtual void suspend();
- virtual void resume();
- virtual Geoposition* lastPosition() const;
- virtual PositionError* lastError() const;
-
-private:
- Geolocation* m_geolocation;
- OwnPtr<GeolocationServiceBridge> m_geolocationServiceBridge;
- RefPtr<Geoposition> m_lastPosition;
- RefPtr<PositionError> m_lastError;
-};
-
-} // namespace WebCore
-
-#endif // GeolocationServiceChromium_h
diff --git a/Source/WebCore/platform/chromium/PopupMenuChromium.cpp b/Source/WebCore/platform/chromium/PopupMenuChromium.cpp
index 04eeb93..bb45e79 100644
--- a/Source/WebCore/platform/chromium/PopupMenuChromium.cpp
+++ b/Source/WebCore/platform/chromium/PopupMenuChromium.cpp
@@ -329,11 +329,8 @@ PopupContainer::~PopupContainer()
removeChild(m_listBox.get());
}
-void PopupContainer::showPopup(FrameView* view)
+IntRect PopupContainer::layoutAndCalculateWidgetRect(int targetControlHeight, const IntPoint& popupInitialCoordinate)
{
- // Pre-layout, our size matches the <select> dropdown control.
- int selectHeight = frameRect().height();
-
// Reset the max height to its default value, it will be recomputed below
// if necessary.
m_listBox->setMaxHeight(kMaxHeight);
@@ -341,23 +338,26 @@ void PopupContainer::showPopup(FrameView* view)
// Lay everything out to figure out our preferred size, then tell the view's
// WidgetClient about it. It should assign us a client.
layout();
+
+ // Assume m_listBox size is already calculated.
+ IntSize targetSize(m_listBox->width() + kBorderSize * 2,
+ m_listBox->height() + kBorderSize * 2);
- m_frameView = view;
+ IntRect widgetRect;
ChromeClientChromium* chromeClient = chromeClientChromium();
if (chromeClient) {
// If the popup would extend past the bottom of the screen, open upwards
// instead.
- FloatRect screen = screenAvailableRect(view);
- IntRect widgetRect = chromeClient->windowToScreen(frameRect());
-
+ FloatRect screen = screenAvailableRect(m_frameView.get());
+ widgetRect = chromeClient->windowToScreen(IntRect(popupInitialCoordinate, targetSize));
if (widgetRect.bottom() > static_cast<int>(screen.bottom())) {
- if (widgetRect.y() - widgetRect.height() - selectHeight > 0) {
+ if (widgetRect.y() - widgetRect.height() - targetControlHeight > 0) {
// There is enough room to open upwards.
- widgetRect.move(0, -(widgetRect.height() + selectHeight));
+ widgetRect.move(0, -(widgetRect.height() + targetControlHeight));
} else {
// Figure whether upwards or downwards has more room and set the
// maximum number of items.
- int spaceAbove = widgetRect.y() - selectHeight;
+ int spaceAbove = widgetRect.y() - targetControlHeight;
int spaceBelow = screen.bottom() - widgetRect.y();
if (spaceAbove > spaceBelow)
m_listBox->setMaxHeight(spaceAbove);
@@ -368,10 +368,21 @@ void PopupContainer::showPopup(FrameView* view)
widgetRect = chromeClient->windowToScreen(frameRect());
// And move upwards if necessary.
if (spaceAbove > spaceBelow)
- widgetRect.move(0, -(widgetRect.height() + selectHeight));
+ widgetRect.move(0, -(widgetRect.height() + targetControlHeight));
}
}
- chromeClient->popupOpened(this, widgetRect, false);
+ }
+ return widgetRect;
+}
+
+void PopupContainer::showPopup(FrameView* view)
+{
+ m_frameView = view;
+
+ ChromeClientChromium* chromeClient = chromeClientChromium();
+ if (chromeClient) {
+ IntRect popupRect = frameRect();
+ chromeClient->popupOpened(this, layoutAndCalculateWidgetRect(popupRect.height(), popupRect.location()), false);
m_popupOpen = true;
}
@@ -556,15 +567,24 @@ void PopupContainer::show(const IntRect& r, FrameView* v, int index)
// Move it below the select widget.
location.move(0, r.height());
- IntRect popupRect(location, r.size());
- setFrameRect(popupRect);
+ setFrameRect(IntRect(location, r.size()));
showPopup(v);
}
-void PopupContainer::refresh()
+void PopupContainer::refresh(const IntRect& targetControlRect)
{
+ IntPoint location = m_frameView->contentsToWindow(targetControlRect.location());
+ // Move it below the select widget.
+ location.move(0, targetControlRect.height());
+
listBox()->updateFromElement();
- layout();
+ // Store the original height to check if we need to request the location.
+ int originalHeight = height();
+ IntRect widgetRect = layoutAndCalculateWidgetRect(targetControlRect.height(), location);
+ if (originalHeight != widgetRect.height())
+ setFrameRect(widgetRect);
+
+ invalidate();
}
int PopupContainer::selectedIndex() const
diff --git a/Source/WebCore/platform/chromium/PopupMenuChromium.h b/Source/WebCore/platform/chromium/PopupMenuChromium.h
index ca47ccf..f326b48 100644
--- a/Source/WebCore/platform/chromium/PopupMenuChromium.h
+++ b/Source/WebCore/platform/chromium/PopupMenuChromium.h
@@ -168,7 +168,7 @@ public:
int selectedIndex() const;
// Refresh the popup values from the PopupMenuClient.
- void refresh();
+ void refresh(const IntRect& targetControlRect);
// The menu per-item data.
const WTF::Vector<PopupItem*>& popupData() const;
@@ -193,6 +193,9 @@ private:
// Paint the border.
void paintBorder(GraphicsContext*, const IntRect&);
+ // Layout and calculate popup widget size and location and returns it as IntRect.
+ IntRect layoutAndCalculateWidgetRect(int targetControlHeight, const IntPoint& popupInitialCoordinate);
+
// Returns the ChromeClient of the page this popup is associated with.
ChromeClientChromium* chromeClientChromium();