summaryrefslogtreecommitdiffstats
path: root/WebCore/platform
diff options
context:
space:
mode:
Diffstat (limited to 'WebCore/platform')
-rw-r--r--WebCore/platform/MIMETypeRegistry.cpp6
-rw-r--r--WebCore/platform/PlatformStrategies.h15
-rw-r--r--WebCore/platform/PopupMenu.h176
-rw-r--r--WebCore/platform/SearchPopupMenu.h21
-rw-r--r--WebCore/platform/SharedBuffer.cpp2
-rw-r--r--WebCore/platform/brew/PopupMenuBrew.cpp30
-rw-r--r--WebCore/platform/brew/PopupMenuBrew.h53
-rw-r--r--WebCore/platform/brew/SearchPopupMenuBrew.cpp18
-rw-r--r--WebCore/platform/brew/SearchPopupMenuBrew.h44
-rw-r--r--WebCore/platform/chromium/ChromiumBridge.h4
-rw-r--r--WebCore/platform/chromium/PopupMenuChromium.cpp23
-rw-r--r--WebCore/platform/chromium/PopupMenuChromium.h19
-rw-r--r--WebCore/platform/chromium/SearchPopupMenuChromium.cpp18
-rw-r--r--WebCore/platform/chromium/SearchPopupMenuChromium.h44
-rw-r--r--WebCore/platform/efl/PopupMenuEfl.cpp18
-rw-r--r--WebCore/platform/efl/PopupMenuEfl.h53
-rw-r--r--WebCore/platform/efl/SearchPopupMenuEfl.cpp18
-rw-r--r--WebCore/platform/efl/SearchPopupMenuEfl.h44
-rw-r--r--WebCore/platform/graphics/FloatRect.cpp24
-rw-r--r--WebCore/platform/graphics/WOFFFileFormat.cpp258
-rw-r--r--WebCore/platform/graphics/WOFFFileFormat.h48
-rw-r--r--WebCore/platform/graphics/cairo/CairoPath.h35
-rw-r--r--WebCore/platform/graphics/cairo/FontCustomPlatformData.cpp7
-rw-r--r--WebCore/platform/graphics/cairo/FontCustomPlatformData.h3
-rw-r--r--WebCore/platform/graphics/cairo/GraphicsContextCairo.cpp126
-rw-r--r--WebCore/platform/graphics/cairo/GraphicsContextPlatformPrivateCairo.h1
-rw-r--r--WebCore/platform/graphics/cairo/ImageBufferCairo.cpp2
-rw-r--r--WebCore/platform/graphics/cairo/PathCairo.cpp50
-rw-r--r--WebCore/platform/graphics/chromium/FontCustomPlatformData.cpp9
-rw-r--r--WebCore/platform/graphics/chromium/FontCustomPlatformData.h3
-rw-r--r--WebCore/platform/graphics/chromium/GLES2Canvas.cpp4
-rw-r--r--WebCore/platform/graphics/chromium/GLES2Canvas.h1
-rw-r--r--WebCore/platform/graphics/gtk/CairoUtilities.cpp94
-rw-r--r--WebCore/platform/graphics/gtk/CairoUtilities.h33
-rw-r--r--WebCore/platform/graphics/gtk/FontCustomPlatformDataPango.cpp5
-rw-r--r--WebCore/platform/graphics/gtk/ImageBufferGtk.cpp73
-rw-r--r--WebCore/platform/graphics/gtk/ImageGtk.cpp61
-rw-r--r--WebCore/platform/graphics/haiku/FontCustomPlatformData.cpp5
-rw-r--r--WebCore/platform/graphics/haiku/FontCustomPlatformData.h3
-rw-r--r--WebCore/platform/graphics/mac/FontCustomPlatformData.cpp24
-rw-r--r--WebCore/platform/graphics/mac/FontCustomPlatformData.h3
-rw-r--r--WebCore/platform/graphics/qt/FontCustomPlatformData.h5
-rw-r--r--WebCore/platform/graphics/qt/FontCustomPlatformDataQt.cpp4
-rw-r--r--WebCore/platform/graphics/skia/ImageBufferSkia.cpp2
-rw-r--r--WebCore/platform/graphics/skia/ImageSkia.cpp44
-rw-r--r--WebCore/platform/graphics/win/FontCustomPlatformData.cpp18
-rw-r--r--WebCore/platform/graphics/win/FontCustomPlatformData.h3
-rw-r--r--WebCore/platform/graphics/win/FontCustomPlatformDataCairo.cpp5
-rw-r--r--WebCore/platform/graphics/win/FontCustomPlatformDataCairo.h3
-rw-r--r--WebCore/platform/graphics/win/WKCACFLayer.cpp14
-rw-r--r--WebCore/platform/graphics/win/WKCACFLayer.h11
-rw-r--r--WebCore/platform/graphics/win/WKCACFLayerRenderer.cpp8
-rw-r--r--WebCore/platform/graphics/win/WKCACFLayerRenderer.h1
-rw-r--r--WebCore/platform/graphics/wince/FontCustomPlatformData.cpp5
-rw-r--r--WebCore/platform/graphics/wince/FontCustomPlatformData.h3
-rw-r--r--WebCore/platform/gtk/KeyEventGtk.cpp7
-rw-r--r--WebCore/platform/gtk/PopupMenuGtk.cpp25
-rw-r--r--WebCore/platform/gtk/PopupMenuGtk.h67
-rw-r--r--WebCore/platform/gtk/SearchPopupMenuGtk.cpp19
-rw-r--r--WebCore/platform/gtk/SearchPopupMenuGtk.h44
-rw-r--r--WebCore/platform/haiku/PopupMenuHaiku.cpp31
-rw-r--r--WebCore/platform/haiku/PopupMenuHaiku.h55
-rw-r--r--WebCore/platform/haiku/SearchPopupMenuHaiku.cpp18
-rw-r--r--WebCore/platform/haiku/SearchPopupMenuHaiku.h44
-rw-r--r--WebCore/platform/mac/PopupMenuMac.h58
-rw-r--r--WebCore/platform/mac/PopupMenuMac.mm24
-rw-r--r--WebCore/platform/mac/SearchPopupMenuMac.h44
-rw-r--r--WebCore/platform/mac/SearchPopupMenuMac.mm18
-rw-r--r--WebCore/platform/mock/DeviceOrientationClientMock.cpp71
-rw-r--r--WebCore/platform/mock/DeviceOrientationClientMock.h66
-rw-r--r--WebCore/platform/mock/SpeechInputClientMock.cpp95
-rw-r--r--WebCore/platform/mock/SpeechInputClientMock.h69
-rw-r--r--WebCore/platform/qt/PopupMenuQt.cpp25
-rw-r--r--WebCore/platform/qt/PopupMenuQt.h49
-rw-r--r--WebCore/platform/qt/QtAbstractWebPopup.h2
-rw-r--r--WebCore/platform/qt/SearchPopupMenuQt.cpp20
-rw-r--r--WebCore/platform/qt/SearchPopupMenuQt.h44
-rw-r--r--WebCore/platform/sql/SQLiteDatabase.cpp43
-rw-r--r--WebCore/platform/sql/SQLiteDatabase.h11
-rw-r--r--WebCore/platform/sql/SQLiteStatement.cpp10
-rw-r--r--WebCore/platform/win/PopupMenuWin.cpp67
-rw-r--r--WebCore/platform/win/PopupMenuWin.h123
-rw-r--r--WebCore/platform/win/SearchPopupMenuWin.cpp18
-rw-r--r--WebCore/platform/win/SearchPopupMenuWin.h44
-rw-r--r--WebCore/platform/wx/PopupMenuWx.cpp29
-rw-r--r--WebCore/platform/wx/PopupMenuWx.h62
-rw-r--r--WebCore/platform/wx/SearchPopupMenuWx.cpp18
-rw-r--r--WebCore/platform/wx/SearchPopupMenuWx.h44
88 files changed, 2399 insertions, 569 deletions
diff --git a/WebCore/platform/MIMETypeRegistry.cpp b/WebCore/platform/MIMETypeRegistry.cpp
index e6eb209..e9e5dd3 100644
--- a/WebCore/platform/MIMETypeRegistry.cpp
+++ b/WebCore/platform/MIMETypeRegistry.cpp
@@ -180,6 +180,12 @@ static void initializeSupportedImageMIMETypesForEncoding()
}
supportedImageMIMETypesForEncoding->remove("application/octet-stream");
+#elif PLATFORM(GTK)
+ supportedImageMIMETypesForEncoding->add("image/png");
+ supportedImageMIMETypesForEncoding->add("image/jpeg");
+ supportedImageMIMETypesForEncoding->add("image/tiff");
+ supportedImageMIMETypesForEncoding->add("image/bmp");
+ supportedImageMIMETypesForEncoding->add("image/ico");
#elif PLATFORM(CAIRO)
supportedImageMIMETypesForEncoding->add("image/png");
#endif
diff --git a/WebCore/platform/PlatformStrategies.h b/WebCore/platform/PlatformStrategies.h
index f585202..c02ce00 100644
--- a/WebCore/platform/PlatformStrategies.h
+++ b/WebCore/platform/PlatformStrategies.h
@@ -32,6 +32,7 @@ namespace WebCore {
class PluginStrategy;
class LocalizationStrategy;
+class VisitedLinkStrategy;
class PlatformStrategies {
public:
@@ -49,10 +50,18 @@ public:
return m_localizationStrategy;
}
+ VisitedLinkStrategy* visitedLinkStrategy()
+ {
+ if (!m_visitedLinkStrategy)
+ m_visitedLinkStrategy = createVisitedLinkStrategy();
+ return m_visitedLinkStrategy;
+ }
+
protected:
PlatformStrategies()
- : m_pluginStrategy(0),
- m_localizationStrategy(0)
+ : m_pluginStrategy(0)
+ , m_localizationStrategy(0)
+ , m_visitedLinkStrategy(0)
{
}
@@ -63,9 +72,11 @@ protected:
private:
virtual PluginStrategy* createPluginStrategy() = 0;
virtual LocalizationStrategy* createLocalizationStrategy() = 0;
+ virtual VisitedLinkStrategy* createVisitedLinkStrategy() = 0;
PluginStrategy* m_pluginStrategy;
LocalizationStrategy* m_localizationStrategy;
+ VisitedLinkStrategy* m_visitedLinkStrategy;
};
PlatformStrategies* platformStrategies();
diff --git a/WebCore/platform/PopupMenu.h b/WebCore/platform/PopupMenu.h
index d9d2740..8ebba03 100644
--- a/WebCore/platform/PopupMenu.h
+++ b/WebCore/platform/PopupMenu.h
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2006, 2008 Apple Inc. All rights reserved.
+ * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
@@ -21,180 +21,22 @@
#ifndef PopupMenu_h
#define PopupMenu_h
-#include "IntRect.h"
-#include "PopupMenuClient.h"
-#include <wtf/PassRefPtr.h>
#include <wtf/RefCounted.h>
-#if PLATFORM(MAC)
-#include <wtf/RetainPtr.h>
-#ifdef __OBJC__
-@class NSPopUpButtonCell;
-#else
-class NSPopUpButtonCell;
-#endif
-#elif PLATFORM(WIN)
-#include "Scrollbar.h"
-#include "ScrollbarClient.h"
-#include <wtf/RefPtr.h>
-typedef struct HWND__* HWND;
-typedef struct HDC__* HDC;
-typedef struct HBITMAP__* HBITMAP;
-#elif PLATFORM(QT)
-namespace WebCore {
-class QtAbstractWebPopup;
-}
-#elif PLATFORM(GTK)
-typedef struct _GtkMenu GtkMenu;
-typedef struct _GtkMenuItem GtkMenuItem;
-typedef struct _GtkWidget GtkWidget;
-#include "GRefPtrGtk.h"
-#include <wtf/HashMap.h>
-#include <glib.h>
-#elif PLATFORM(WX)
-#ifdef __WXMSW__
-#include <wx/msw/winundef.h>
-#endif
-class wxMenu;
-#include <wx/defs.h>
-#include <wx/event.h>
-#elif PLATFORM(CHROMIUM)
-#include "PopupMenuPrivate.h"
-#elif PLATFORM(HAIKU)
-namespace WebCore {
-class PopupMenuHaiku;
-}
-#endif
-
namespace WebCore {
class FrameView;
-class Scrollbar;
+class IntRect;
-class PopupMenu : public RefCounted<PopupMenu>
-#if PLATFORM(WIN)
- , private ScrollbarClient
-#endif
-#if PLATFORM(WX)
- , public wxEvtHandler
-#endif
-{
+class PopupMenu : public RefCounted<PopupMenu> {
public:
- static PassRefPtr<PopupMenu> create(PopupMenuClient* client) { return adoptRef(new PopupMenu(client)); }
- ~PopupMenu();
-
- void disconnectClient() { m_popupClient = 0; }
-
- void show(const IntRect&, FrameView*, int index);
- void hide();
-
- void updateFromElement();
-
- PopupMenuClient* client() const { return m_popupClient; }
-
- static bool itemWritingDirectionIsNatural();
-
-#if PLATFORM(WIN)
- Scrollbar* scrollbar() const { return m_scrollbar.get(); }
-
- static LPCTSTR popupClassName();
-
- bool up(unsigned lines = 1);
- bool down(unsigned lines = 1);
-
- int itemHeight() const { return m_itemHeight; }
- const IntRect& windowRect() const { return m_windowRect; }
- IntRect clientRect() const;
-
- int visibleItems() const;
-
- int listIndexAtPoint(const IntPoint&) const;
-
- bool setFocusedIndex(int index, bool hotTracking = false);
- int focusedIndex() const;
- void focusFirst();
- void focusLast();
-
- void paint(const IntRect& damageRect, HDC = 0);
-
- HWND popupHandle() const { return m_popup; }
-
- void setWasClicked(bool b = true) { m_wasClicked = b; }
- bool wasClicked() const { return m_wasClicked; }
-
- void setScrollOffset(int offset) { m_scrollOffset = offset; }
- int scrollOffset() const { return m_scrollOffset; }
-
- bool scrollToRevealSelection();
-
- void incrementWheelDelta(int delta);
- void reduceWheelDelta(int delta);
- int wheelDelta() const { return m_wheelDelta; }
-
- bool scrollbarCapturingMouse() const { return m_scrollbarCapturingMouse; }
- void setScrollbarCapturingMouse(bool b) { m_scrollbarCapturingMouse = b; }
-#endif
-
-protected:
- PopupMenu(PopupMenuClient*);
-
-private:
- PopupMenuClient* m_popupClient;
-
-#if PLATFORM(MAC)
- void clear();
- void populate();
-
- RetainPtr<NSPopUpButtonCell> m_popup;
-#elif PLATFORM(QT)
- QtAbstractWebPopup* m_popup;
-#elif PLATFORM(WIN)
- // ScrollBarClient
- virtual void valueChanged(Scrollbar*);
- virtual void invalidateScrollbarRect(Scrollbar*, const IntRect&);
- virtual bool isActive() const { return true; }
- virtual bool scrollbarCornerPresent() const { return false; }
-
- void calculatePositionAndSize(const IntRect&, FrameView*);
- void invalidateItem(int index);
-
- static LRESULT CALLBACK PopupMenuWndProc(HWND, UINT, WPARAM, LPARAM);
- LRESULT wndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam);
- static void registerClass();
-
- RefPtr<Scrollbar> m_scrollbar;
- HWND m_popup;
- HDC m_DC;
- HBITMAP m_bmp;
- bool m_wasClicked;
- IntRect m_windowRect;
- int m_itemHeight;
- int m_scrollOffset;
- int m_wheelDelta;
- int m_focusedIndex;
- bool m_scrollbarCapturingMouse;
- bool m_showPopup;
-#elif PLATFORM(GTK)
- IntPoint m_menuPosition;
- GRefPtr<GtkMenu> m_popup;
- HashMap<GtkWidget*, int> m_indexMap;
- static void menuItemActivated(GtkMenuItem* item, PopupMenu*);
- static void menuUnmapped(GtkWidget*, PopupMenu*);
- static void menuPositionFunction(GtkMenu*, gint*, gint*, gboolean*, PopupMenu*);
- static void menuRemoveItem(GtkWidget*, PopupMenu*);
-#elif PLATFORM(EFL) || PLATFORM(BREWMP)
- FrameView* m_view;
-#elif PLATFORM(WX)
- wxMenu* m_menu;
- void OnMenuItemSelected(wxCommandEvent&);
-#elif PLATFORM(CHROMIUM)
- PopupMenuPrivate p;
-#elif PLATFORM(HAIKU)
- PopupMenuHaiku* m_menu;
-#endif
-
+ virtual ~PopupMenu() {}
+ virtual void show(const IntRect&, FrameView*, int index) = 0;
+ virtual void hide() = 0;
+ virtual void updateFromElement() = 0;
+ virtual void disconnectClient() = 0;
};
}
-#endif
+#endif // PopupMenu_h
diff --git a/WebCore/platform/SearchPopupMenu.h b/WebCore/platform/SearchPopupMenu.h
index 4285cdf..d1ecd0f 100644
--- a/WebCore/platform/SearchPopupMenu.h
+++ b/WebCore/platform/SearchPopupMenu.h
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2006, 2008 Apple Inc. All rights reserved.
+ * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
@@ -23,24 +23,21 @@
#include "PopupMenu.h"
#include <wtf/Vector.h>
+#include <wtf/text/WTFString.h>
namespace WebCore {
class AtomicString;
-class SearchPopupMenu : public PopupMenu {
+class SearchPopupMenu : public RefCounted<SearchPopupMenu> {
public:
- static PassRefPtr<SearchPopupMenu> create(PopupMenuClient* client) { return adoptRef(new SearchPopupMenu(client)); }
-
- void saveRecentSearches(const AtomicString& name, const Vector<String>& searchItems);
- void loadRecentSearches(const AtomicString& name, Vector<String>& searchItems);
-
- bool enabled();
-
-private:
- SearchPopupMenu(PopupMenuClient*);
+ virtual ~SearchPopupMenu() {}
+ virtual PopupMenu* popupMenu() = 0;
+ virtual void saveRecentSearches(const AtomicString& name, const Vector<String>& searchItems) = 0;
+ virtual void loadRecentSearches(const AtomicString& name, Vector<String>& searchItems) = 0;
+ virtual bool enabled() = 0;
};
}
-#endif
+#endif // SearchPopupMenu_h
diff --git a/WebCore/platform/SharedBuffer.cpp b/WebCore/platform/SharedBuffer.cpp
index 6cf1131..35a7b7c 100644
--- a/WebCore/platform/SharedBuffer.cpp
+++ b/WebCore/platform/SharedBuffer.cpp
@@ -239,7 +239,7 @@ unsigned SharedBuffer::getSomeData(const char*& someData, unsigned position) con
return segment == segments - 1 ? segmentedSize - position : segmentSize - positionInSegment;
}
-#if !PLATFORM(CF)
+#if !PLATFORM(CF) || PLATFORM(QT)
inline void SharedBuffer::clearPlatformData()
{
diff --git a/WebCore/platform/brew/PopupMenuBrew.cpp b/WebCore/platform/brew/PopupMenuBrew.cpp
index eb03c66..18b2b45 100644
--- a/WebCore/platform/brew/PopupMenuBrew.cpp
+++ b/WebCore/platform/brew/PopupMenuBrew.cpp
@@ -4,6 +4,7 @@
* Copyright (C) 2009-2010 ProFUSION embedded systems
* Copyright (C) 2009-2010 Samsung Electronics
* Copyright (C) 2010 Company 100, Inc.
+ * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
@@ -23,7 +24,7 @@
*/
#include "config.h"
-#include "PopupMenu.h"
+#include "PopupMenuBrew.h"
#include "Chrome.h"
#include "ChromeClientBrew.h"
@@ -32,20 +33,25 @@
namespace WebCore {
-PopupMenu::PopupMenu(PopupMenuClient* menuList)
+PopupMenuBrew::PopupMenuBrew(PopupMenuClient* menuList)
: m_popupClient(menuList)
, m_view(0)
{
}
-PopupMenu::~PopupMenu()
+PopupMenuBrew::~PopupMenuBrew()
{
// Tell client to destroy data related to this popup since this object is
// going away.
hide();
}
-void PopupMenu::show(const IntRect& rect, FrameView* view, int index)
+void PopupMenuBrew::disconnectClient()
+{
+ m_popupClient = 0;
+}
+
+void PopupMenuBrew::show(const IntRect& rect, FrameView* view, int index)
{
ASSERT(m_popupClient);
ChromeClientBrew* chromeClient = static_cast<ChromeClientBrew*>(view->frame()->page()->chrome()->client());
@@ -55,7 +61,7 @@ void PopupMenu::show(const IntRect& rect, FrameView* view, int index)
chromeClient->createSelectPopup(m_popupClient, index, rect);
}
-void PopupMenu::hide()
+void PopupMenuBrew::hide()
{
ASSERT(m_view);
ChromeClientBrew* chromeClient = static_cast<ChromeClientBrew*>(m_view->frame()->page()->chrome()->client());
@@ -64,14 +70,18 @@ void PopupMenu::hide()
chromeClient->destroySelectPopup();
}
-void PopupMenu::updateFromElement()
+void PopupMenuBrew::updateFromElement()
{
client()->setTextFromItem(client()->selectedIndex());
}
-bool PopupMenu::itemWritingDirectionIsNatural()
-{
- return true;
-}
+// This code must be moved to the concrete brew ChromeClient that is not in repository.
+// I kept this code commented out here to prevent loosing the information of what
+// must be the return value for brew.
+
+// bool PopupMenuBrew::itemWritingDirectionIsNatural()
+// {
+// return true;
+// }
} // namespace WebCore
diff --git a/WebCore/platform/brew/PopupMenuBrew.h b/WebCore/platform/brew/PopupMenuBrew.h
new file mode 100644
index 0000000..0c171df
--- /dev/null
+++ b/WebCore/platform/brew/PopupMenuBrew.h
@@ -0,0 +1,53 @@
+/*
+ * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see the file COPYING.LIB. If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#ifndef PopupMenuBrew_h
+#define PopupMenuBrew_h
+
+#include "IntRect.h"
+#include "PopupMenu.h"
+#include "PopupMenuClient.h"
+#include <wtf/PassRefPtr.h>
+#include <wtf/RefCounted.h>
+
+namespace WebCore {
+
+class FrameView;
+class Scrollbar;
+
+class PopupMenuBrew : public PopupMenu {
+public:
+ PopupMenuBrew(PopupMenuClient*);
+ ~PopupMenuBrew();
+
+ virtual void show(const IntRect&, FrameView*, int index);
+ virtual void hide();
+ virtual void updateFromElement();
+ virtual void disconnectClient();
+
+private:
+ PopupMenuClient* client() const { return m_popupClient; }
+
+ PopupMenuClient* m_popupClient;
+ FrameView* m_view;
+};
+
+}
+
+#endif // PopupMenuBrew_h
diff --git a/WebCore/platform/brew/SearchPopupMenuBrew.cpp b/WebCore/platform/brew/SearchPopupMenuBrew.cpp
index 780c7e5..81ca624 100644
--- a/WebCore/platform/brew/SearchPopupMenuBrew.cpp
+++ b/WebCore/platform/brew/SearchPopupMenuBrew.cpp
@@ -1,5 +1,6 @@
/*
* Copyright (C) 2010 Company 100, Inc. All rights reserved.
+ * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -24,29 +25,34 @@
*/
#include "config.h"
-#include "SearchPopupMenu.h"
+#include "SearchPopupMenuBrew.h"
namespace WebCore {
// Save the past searches stored in 'searchItems' to a database associated with 'name'
-void SearchPopupMenu::saveRecentSearches(const AtomicString& name, const Vector<String>& searchItems)
+void SearchPopupMenuBrew::saveRecentSearches(const AtomicString& name, const Vector<String>& searchItems)
{
}
// Load past searches associated with 'name' from the database to 'searchItems'
-void SearchPopupMenu::loadRecentSearches(const AtomicString& name, Vector<String>& searchItems)
+void SearchPopupMenuBrew::loadRecentSearches(const AtomicString& name, Vector<String>& searchItems)
{
}
// Create a search popup menu - not sure what else we have to do here
-SearchPopupMenu::SearchPopupMenu(PopupMenuClient* client)
- : PopupMenu(client)
+SearchPopupMenuBrew::SearchPopupMenuBrew(PopupMenuClient* client)
+ : m_popup(adoptRef(new PopupMenuBrew(client)))
{
}
-bool SearchPopupMenu::enabled()
+bool SearchPopupMenuBrew::enabled()
{
return false;
}
+PopupMenu* SearchPopupMenuBrew::popupMenu()
+{
+ return m_popup.get();
+}
+
} // namespace WebCore
diff --git a/WebCore/platform/brew/SearchPopupMenuBrew.h b/WebCore/platform/brew/SearchPopupMenuBrew.h
new file mode 100644
index 0000000..4ce7005
--- /dev/null
+++ b/WebCore/platform/brew/SearchPopupMenuBrew.h
@@ -0,0 +1,44 @@
+/*
+ * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see the file COPYING.LIB. If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ *
+ */
+
+#ifndef SearchPopupMenuBrew_h
+#define SearchPopupMenuBrew_h
+
+#include "PopupMenuBrew.h"
+#include "SearchPopupMenu.h"
+
+namespace WebCore {
+
+class SearchPopupMenuBrew : public SearchPopupMenu {
+public:
+ SearchPopupMenuBrew(PopupMenuClient*);
+
+ virtual PopupMenu* popupMenu();
+ virtual void saveRecentSearches(const AtomicString& name, const Vector<String>& searchItems);
+ virtual void loadRecentSearches(const AtomicString& name, Vector<String>& searchItems);
+ virtual bool enabled();
+
+private:
+ RefPtr<PopupMenuBrew> m_popup;
+};
+
+}
+
+#endif // SearchPopupMenuBrew_h
diff --git a/WebCore/platform/chromium/ChromiumBridge.h b/WebCore/platform/chromium/ChromiumBridge.h
index 711c728..acfefe1 100644
--- a/WebCore/platform/chromium/ChromiumBridge.h
+++ b/WebCore/platform/chromium/ChromiumBridge.h
@@ -70,7 +70,7 @@ namespace WebCore {
class GeolocationServiceChromium;
class GraphicsContext;
class Image;
- class IndexedDatabase;
+ class IDBFactoryBackendInterface;
class IntRect;
class KURL;
class String;
@@ -166,7 +166,7 @@ namespace WebCore {
static long long databaseGetFileSize(const String& vfsFileName);
// IndexedDB ----------------------------------------------------------
- static PassRefPtr<IndexedDatabase> indexedDatabase();
+ static PassRefPtr<IDBFactoryBackendInterface> idbFactory();
// JavaScript ---------------------------------------------------------
static void notifyJSOutOfMemory(Frame*);
diff --git a/WebCore/platform/chromium/PopupMenuChromium.cpp b/WebCore/platform/chromium/PopupMenuChromium.cpp
index d07ba2e..9c73a9c 100644
--- a/WebCore/platform/chromium/PopupMenuChromium.cpp
+++ b/WebCore/platform/chromium/PopupMenuChromium.cpp
@@ -1,5 +1,6 @@
/*
* Copyright (c) 2008, 2009, Google Inc. All rights reserved.
+ * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
@@ -48,7 +49,6 @@
#include "PlatformMouseEvent.h"
#include "PlatformScreen.h"
#include "PlatformWheelEvent.h"
-#include "PopupMenu.h"
#include "RenderTheme.h"
#include "ScrollbarTheme.h"
#include "StringTruncator.h"
@@ -1340,20 +1340,20 @@ bool PopupListBox::isPointInBounds(const IntPoint& point)
}
///////////////////////////////////////////////////////////////////////////////
-// PopupMenu implementation
+// PopupMenuChromium implementation
//
// Note: you cannot add methods to this class, since it is defined above the
// portability layer. To access methods and properties on the
// popup widgets, use |popupWindow| above.
-PopupMenu::PopupMenu(PopupMenuClient* client)
+PopupMenuChromium::PopupMenuChromium(PopupMenuClient* client)
: m_popupClient(client)
{
}
-PopupMenu::~PopupMenu()
+PopupMenuChromium::~PopupMenuChromium()
{
- // When the PopupMenu is destroyed, the client could already have been
+ // When the PopupMenuChromium is destroyed, the client could already have been
// deleted.
if (p.popup)
p.popup->listBox()->disconnectClient();
@@ -1364,7 +1364,7 @@ PopupMenu::~PopupMenu()
// to display, handle the input tracking and menu item selection for the popup.
// Windows and Linux Chromium let our WebKit port handle the display, while
// another process manages the popup window and input handling.
-void PopupMenu::show(const IntRect& r, FrameView* v, int index)
+void PopupMenuChromium::show(const IntRect& r, FrameView* v, int index)
{
if (!p.popup)
p.popup = PopupContainer::create(client(), PopupContainer::Select, dropDownSettings);
@@ -1375,20 +1375,21 @@ void PopupMenu::show(const IntRect& r, FrameView* v, int index)
#endif
}
-void PopupMenu::hide()
+void PopupMenuChromium::hide()
{
if (p.popup)
p.popup->hide();
}
-void PopupMenu::updateFromElement()
+void PopupMenuChromium::updateFromElement()
{
p.popup->listBox()->updateFromElement();
}
-bool PopupMenu::itemWritingDirectionIsNatural()
-{
- return false;
+
+void PopupMenuChromium::disconnectClient()
+{
+ m_popupClient = 0;
}
} // namespace WebCore
diff --git a/WebCore/platform/chromium/PopupMenuChromium.h b/WebCore/platform/chromium/PopupMenuChromium.h
index a85cf49..0d0e23c 100644
--- a/WebCore/platform/chromium/PopupMenuChromium.h
+++ b/WebCore/platform/chromium/PopupMenuChromium.h
@@ -36,6 +36,8 @@
#include "FramelessScrollView.h"
#include "IntRect.h"
+#include "PopupMenu.h"
+#include "PopupMenuPrivate.h"
namespace WebCore {
@@ -201,6 +203,23 @@ private:
bool m_popupOpen;
};
+class PopupMenuChromium : public PopupMenu {
+public:
+ PopupMenuChromium(PopupMenuClient*);
+ ~PopupMenuChromium();
+
+ virtual void show(const IntRect&, FrameView*, int index);
+ virtual void hide();
+ virtual void updateFromElement();
+ virtual void disconnectClient();
+
+private:
+ PopupMenuClient* client() const { return m_popupClient; }
+
+ PopupMenuClient* m_popupClient;
+ PopupMenuPrivate p;
+};
+
} // namespace WebCore
#endif
diff --git a/WebCore/platform/chromium/SearchPopupMenuChromium.cpp b/WebCore/platform/chromium/SearchPopupMenuChromium.cpp
index 89bfddd..d4d4ff5 100644
--- a/WebCore/platform/chromium/SearchPopupMenuChromium.cpp
+++ b/WebCore/platform/chromium/SearchPopupMenuChromium.cpp
@@ -1,5 +1,6 @@
/*
* Copyright (c) 2008, 2009, Google Inc. All rights reserved.
+ * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
@@ -29,29 +30,34 @@
*/
#include "config.h"
-#include "SearchPopupMenu.h"
+#include "SearchPopupMenuChromium.h"
#include "AtomicString.h"
#include "NotImplemented.h"
namespace WebCore {
-SearchPopupMenu::SearchPopupMenu(PopupMenuClient* client)
- : PopupMenu(client)
+SearchPopupMenuChromium::SearchPopupMenuChromium(PopupMenuClient* client)
+ : m_popup(adoptRef(new PopupMenuChromium(client)))
{
}
-bool SearchPopupMenu::enabled()
+PopupMenu* SearchPopupMenuChromium::popupMenu()
+{
+ return m_popup.get();
+}
+
+bool SearchPopupMenuChromium::enabled()
{
return false;
}
-void SearchPopupMenu::saveRecentSearches(const AtomicString& name, const Vector<String>& searchItems)
+void SearchPopupMenuChromium::saveRecentSearches(const AtomicString& name, const Vector<String>& searchItems)
{
notImplemented();
}
-void SearchPopupMenu::loadRecentSearches(const AtomicString& name, Vector<String>& searchItems)
+void SearchPopupMenuChromium::loadRecentSearches(const AtomicString& name, Vector<String>& searchItems)
{
notImplemented();
}
diff --git a/WebCore/platform/chromium/SearchPopupMenuChromium.h b/WebCore/platform/chromium/SearchPopupMenuChromium.h
new file mode 100644
index 0000000..827ff66
--- /dev/null
+++ b/WebCore/platform/chromium/SearchPopupMenuChromium.h
@@ -0,0 +1,44 @@
+/*
+ * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see the file COPYING.LIB. If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ *
+ */
+
+#ifndef SearchPopupMenuChromium_h
+#define SearchPopupMenuChromium_h
+
+#include "PopupMenuChromium.h"
+#include "SearchPopupMenu.h"
+
+namespace WebCore {
+
+class SearchPopupMenuChromium : public SearchPopupMenu {
+public:
+ SearchPopupMenuChromium(PopupMenuClient*);
+
+ virtual PopupMenu* popupMenu();
+ virtual void saveRecentSearches(const AtomicString& name, const Vector<String>& searchItems);
+ virtual void loadRecentSearches(const AtomicString& name, Vector<String>& searchItems);
+ virtual bool enabled();
+
+private:
+ RefPtr<PopupMenuChromium> m_popup;
+};
+
+}
+
+#endif // SearchPopupMenuChromium_h
diff --git a/WebCore/platform/efl/PopupMenuEfl.cpp b/WebCore/platform/efl/PopupMenuEfl.cpp
index 9dc6986..401f24f 100644
--- a/WebCore/platform/efl/PopupMenuEfl.cpp
+++ b/WebCore/platform/efl/PopupMenuEfl.cpp
@@ -3,6 +3,7 @@
* Copyright (C) 2008 INdT - Instituto Nokia de Tecnologia
* Copyright (C) 2009-2010 ProFUSION embedded systems
* Copyright (C) 2009-2010 Samsung Electronics
+ * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
@@ -22,29 +23,30 @@
*/
#include "config.h"
-#include "PopupMenu.h"
+#include "PopupMenuEfl.h"
#include "Chrome.h"
#include "ChromeClientEfl.h"
#include "FrameView.h"
#include "NotImplemented.h"
+#include "PopupMenuClient.h"
namespace WebCore {
-PopupMenu::PopupMenu(PopupMenuClient* client)
+PopupMenuEfl::PopupMenuEfl(PopupMenuClient* client)
: m_popupClient(client)
, m_view(0)
{
}
-PopupMenu::~PopupMenu()
+PopupMenuEfl::~PopupMenuEfl()
{
// Tell client to destroy data related to this popup since this object is
// going away.
hide();
}
-void PopupMenu::show(const IntRect& rect, FrameView* view, int index)
+void PopupMenuEfl::show(const IntRect& rect, FrameView* view, int index)
{
ASSERT(m_popupClient);
ChromeClientEfl* chromeClient = static_cast<ChromeClientEfl*>(view->frame()->page()->chrome()->client());
@@ -54,7 +56,7 @@ void PopupMenu::show(const IntRect& rect, FrameView* view, int index)
chromeClient->createSelectPopup(m_popupClient, index, rect);
}
-void PopupMenu::hide()
+void PopupMenuEfl::hide()
{
ASSERT(m_view);
ChromeClientEfl* chromeClient = static_cast<ChromeClientEfl*>(m_view->frame()->page()->chrome()->client());
@@ -63,14 +65,14 @@ void PopupMenu::hide()
chromeClient->destroySelectPopup();
}
-void PopupMenu::updateFromElement()
+void PopupMenuEfl::updateFromElement()
{
client()->setTextFromItem(client()->selectedIndex());
}
-bool PopupMenu::itemWritingDirectionIsNatural()
+void PopupMenuEfl::disconnectClient()
{
- return true;
+ m_popupClient = 0;
}
}
diff --git a/WebCore/platform/efl/PopupMenuEfl.h b/WebCore/platform/efl/PopupMenuEfl.h
new file mode 100644
index 0000000..4a2dbfc
--- /dev/null
+++ b/WebCore/platform/efl/PopupMenuEfl.h
@@ -0,0 +1,53 @@
+/*
+ * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see the file COPYING.LIB. If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#ifndef PopupMenuEfl_h
+#define PopupMenuEfl_h
+
+#include "IntRect.h"
+#include "PopupMenu.h"
+#include <wtf/PassRefPtr.h>
+#include <wtf/RefCounted.h>
+
+namespace WebCore {
+
+class FrameView;
+class Scrollbar;
+class PopupMenuClient;
+
+class PopupMenuEfl : public PopupMenu {
+public:
+ PopupMenuEfl(PopupMenuClient*);
+ ~PopupMenuEfl();
+
+ virtual void show(const IntRect&, FrameView*, int index);
+ virtual void hide();
+ virtual void updateFromElement();
+ virtual void disconnectClient();
+
+private:
+ PopupMenuClient* client() const { return m_popupClient; }
+
+ PopupMenuClient* m_popupClient;
+ FrameView* m_view;
+};
+
+}
+
+#endif // PopupMenuEfl_h
diff --git a/WebCore/platform/efl/SearchPopupMenuEfl.cpp b/WebCore/platform/efl/SearchPopupMenuEfl.cpp
index d18174f..20ecb09 100644
--- a/WebCore/platform/efl/SearchPopupMenuEfl.cpp
+++ b/WebCore/platform/efl/SearchPopupMenuEfl.cpp
@@ -2,6 +2,7 @@
* Copyright (C) 2008 INdT - Instituto Nokia de Tecnologia
* Copyright (C) 2009-2010 ProFUSION embedded systems
* Copyright (C) 2009-2010 Samsung Electronics
+ * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@@ -19,29 +20,34 @@
*/
#include "config.h"
-#include "SearchPopupMenu.h"
+#include "SearchPopupMenuEfl.h"
#include "NotImplemented.h"
namespace WebCore {
-SearchPopupMenu::SearchPopupMenu(PopupMenuClient* client)
- : PopupMenu(client)
+SearchPopupMenuEfl::SearchPopupMenuEfl(PopupMenuClient* client)
+ : m_popup(adoptRef(new PopupMenuEfl(client)))
{
notImplemented();
}
-void SearchPopupMenu::saveRecentSearches(const AtomicString&, const Vector<String>&)
+PopupMenu* SearchPopupMenuEfl::popupMenu()
+{
+ return m_popup.get();
+}
+
+void SearchPopupMenuEfl::saveRecentSearches(const AtomicString&, const Vector<String>&)
{
notImplemented();
}
-void SearchPopupMenu::loadRecentSearches(const AtomicString&, Vector<String>&)
+void SearchPopupMenuEfl::loadRecentSearches(const AtomicString&, Vector<String>&)
{
notImplemented();
}
-bool SearchPopupMenu::enabled()
+bool SearchPopupMenuEfl::enabled()
{
notImplemented();
return true;
diff --git a/WebCore/platform/efl/SearchPopupMenuEfl.h b/WebCore/platform/efl/SearchPopupMenuEfl.h
new file mode 100644
index 0000000..4ffb62e
--- /dev/null
+++ b/WebCore/platform/efl/SearchPopupMenuEfl.h
@@ -0,0 +1,44 @@
+/*
+ * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see the file COPYING.LIB. If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ *
+ */
+
+#ifndef SearchPopupMenuEfl_h
+#define SearchPopupMenuEfl_h
+
+#include "PopupMenuEfl.h"
+#include "SearchPopupMenu.h"
+
+namespace WebCore {
+
+class SearchPopupMenuEfl : public SearchPopupMenu {
+public:
+ SearchPopupMenuEfl(PopupMenuClient*);
+
+ virtual PopupMenu* popupMenu();
+ virtual void saveRecentSearches(const AtomicString& name, const Vector<String>& searchItems);
+ virtual void loadRecentSearches(const AtomicString& name, Vector<String>& searchItems);
+ virtual bool enabled();
+
+private:
+ RefPtr<PopupMenuEfl> m_popup;
+};
+
+}
+
+#endif // SearchPopupMenuEfl_h
diff --git a/WebCore/platform/graphics/FloatRect.cpp b/WebCore/platform/graphics/FloatRect.cpp
index 7a54f21..6dfa808 100644
--- a/WebCore/platform/graphics/FloatRect.cpp
+++ b/WebCore/platform/graphics/FloatRect.cpp
@@ -30,6 +30,7 @@
#include "FloatConversion.h"
#include "IntRect.h"
#include <algorithm>
+#include <limits>
#include <math.h>
using std::max;
@@ -110,13 +111,26 @@ void FloatRect::scale(float sx, float sy)
m_size.setHeight(height() * sy);
}
+static inline int safeFloatToInt(float x)
+{
+ static const int s_intMax = std::numeric_limits<int>::max();
+ static const int s_intMin = std::numeric_limits<int>::min();
+
+ if (x >= static_cast<float>(s_intMax))
+ return s_intMax;
+ if (x < static_cast<float>(s_intMin))
+ return s_intMin;
+ return static_cast<int>(x);
+}
+
IntRect enclosingIntRect(const FloatRect& rect)
{
- int l = static_cast<int>(floorf(rect.x()));
- int t = static_cast<int>(floorf(rect.y()));
- int r = static_cast<int>(ceilf(rect.right()));
- int b = static_cast<int>(ceilf(rect.bottom()));
- return IntRect(l, t, r - l, b - t);
+ float left = floorf(rect.x());
+ float top = floorf(rect.y());
+ float width = ceilf(rect.right()) - left;
+ float height = ceilf(rect.bottom()) - top;
+ return IntRect(safeFloatToInt(left), safeFloatToInt(top),
+ safeFloatToInt(width), safeFloatToInt(height));
}
FloatRect mapRect(const FloatRect& r, const FloatRect& srcRect, const FloatRect& destRect)
diff --git a/WebCore/platform/graphics/WOFFFileFormat.cpp b/WebCore/platform/graphics/WOFFFileFormat.cpp
new file mode 100644
index 0000000..dc73603
--- /dev/null
+++ b/WebCore/platform/graphics/WOFFFileFormat.cpp
@@ -0,0 +1,258 @@
+/*
+ * Copyright (C) 2010 Apple 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:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. 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.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS 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 APPLE INC. OR ITS 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 "WOFFFileFormat.h"
+
+#if !ENABLE(OPENTYPE_SANITIZER)
+
+#include "SharedBuffer.h"
+
+#if !PLATFORM(WIN)
+#include <zlib.h>
+#else
+#include "SoftLinking.h"
+
+typedef unsigned char Bytef;
+typedef unsigned long uLong;
+typedef unsigned long uLongf;
+#define Z_OK 0
+
+SOFT_LINK_LIBRARY(zlib1);
+SOFT_LINK(zlib1, uncompress, int, __cdecl, (Bytef *dest, uLongf *destLen, const Bytef *source, uLong sourceLen), (dest, destLen, source, sourceLen));
+
+#if CPU(BIG_ENDIAN)
+#define ntohs(x) ((uint16_t)(x))
+#define htons(x) ((uint16_t)(x))
+#define ntohl(x) ((uint32_t)(x))
+#define htonl(x) ((uint32_t)(x))
+#elif CPU(MIDDLE_ENDIAN)
+#define ntohs(x) ((unit16_t)(x))
+#define htons(x) ((uint16_t)(x))
+#define ntohl(x) ((uint32_t)((((uint32_t)(x) & 0xffff0000) >> 16) | (((uint32_t)(x) & 0xffff) << 16))
+#define htonl(x) ntohl(x)
+#else
+#define ntohs(x) ((uint16_t)((((uint16_t)(x) & 0xff00) >> 8) | (((uint16_t)(x) & 0x00ff) << 8)))
+#define htons(x) ntohs(x)
+#define ntohl(x) ((uint32_t)((((uint32_t)(x) & 0xff000000) >> 24) | (((uint32_t)(x) & 0x00ff0000) >> 8) | \
+ (((uint32_t)(x) & 0x0000ff00) << 8) | (((uint32_t)(x) & 0x000000ff) << 24)))
+#define htonl(x) ntohl(x)
+#endif
+
+#endif // PLATFORM(WIN)
+
+namespace WebCore {
+
+static bool readUInt32(SharedBuffer* buffer, size_t& offset, uint32_t& value)
+{
+ ASSERT_ARG(offset, offset <= buffer->size());
+ if (buffer->size() - offset < sizeof(value))
+ return false;
+
+ value = ntohl(*reinterpret_cast<const uint32_t*>(buffer->data() + offset));
+ offset += sizeof(value);
+
+ return true;
+}
+
+static bool readUInt16(SharedBuffer* buffer, size_t& offset, uint16_t& value)
+{
+ ASSERT_ARG(offset, offset <= buffer->size());
+ if (buffer->size() - offset < sizeof(value))
+ return false;
+
+ value = ntohs(*reinterpret_cast<const uint16_t*>(buffer->data() + offset));
+ offset += sizeof(value);
+
+ return true;
+}
+
+static bool writeUInt32(Vector<char>& vector, uint32_t value)
+{
+ uint32_t bigEndianValue = htonl(value);
+ return vector.tryAppend(reinterpret_cast<char*>(&bigEndianValue), sizeof(bigEndianValue));
+}
+
+static bool writeUInt16(Vector<char>& vector, uint16_t value)
+{
+ uint16_t bigEndianValue = htons(value);
+ return vector.tryAppend(reinterpret_cast<char*>(&bigEndianValue), sizeof(bigEndianValue));
+}
+
+static const uint32_t woffSignature = 0x774f4646; /* 'wOFF' */
+
+bool isWOFF(SharedBuffer* buffer)
+{
+ size_t offset = 0;
+ uint32_t signature;
+
+ return readUInt32(buffer, offset, signature) && signature == woffSignature;
+}
+
+bool convertWOFFToSfnt(SharedBuffer* woff, Vector<char>& sfnt)
+{
+#if PLATFORM(WINDOWS)
+ if (!zlib1Library())
+ return false;
+#endif
+ ASSERT_ARG(sfnt, sfnt.isEmpty());
+
+ size_t offset = 0;
+
+ // Read the WOFF header.
+ uint32_t signature;
+ if (!readUInt32(woff, offset, signature) || signature != woffSignature) {
+ ASSERT_NOT_REACHED();
+ return false;
+ }
+
+ uint32_t flavor;
+ if (!readUInt32(woff, offset, flavor))
+ return false;
+
+ uint32_t length;
+ if (!readUInt32(woff, offset, length) || length != woff->size())
+ return false;
+
+ uint16_t numTables;
+ if (!readUInt16(woff, offset, numTables))
+ return false;
+
+ if (!numTables || numTables > 0x0fff)
+ return false;
+
+ uint16_t reserved;
+ if (!readUInt16(woff, offset, reserved) || reserved)
+ return false;
+
+ uint32_t totalSfntSize;
+ if (!readUInt32(woff, offset, totalSfntSize))
+ return false;
+
+ if (woff->size() - offset < sizeof(uint16_t) + sizeof(uint16_t) + sizeof(uint32_t) + sizeof(uint32_t) + sizeof(uint32_t) + sizeof(uint32_t) + sizeof(uint32_t))
+ return false;
+
+ offset += sizeof(uint16_t); // majorVersion
+ offset += sizeof(uint16_t); // minorVersion
+ offset += sizeof(uint32_t); // metaOffset
+ offset += sizeof(uint32_t); // metaLength
+ offset += sizeof(uint32_t); // metaOrigLength
+ offset += sizeof(uint32_t); // privOffset
+ offset += sizeof(uint32_t); // privLength
+
+ // Check if the WOFF can supply as many tables as it claims it has.
+ if (woff->size() - offset < numTables * 5 * sizeof(uint32_t))
+ return false;
+
+ // Write the sfnt offset subtable.
+ uint16_t entrySelector = 0;
+ uint16_t searchRange = 1;
+ while (searchRange < numTables >> 1) {
+ entrySelector++;
+ searchRange <<= 1;
+ }
+ searchRange <<= 4;
+ uint16_t rangeShift = (numTables << 4) - searchRange;
+
+ if (!writeUInt32(sfnt, flavor)
+ || !writeUInt16(sfnt, numTables)
+ || !writeUInt16(sfnt, searchRange)
+ || !writeUInt16(sfnt, entrySelector)
+ || !writeUInt16(sfnt, rangeShift))
+ return false;
+
+ if (sfnt.size() > totalSfntSize)
+ return false;
+
+ if (totalSfntSize - sfnt.size() < numTables * 4 * sizeof(uint32_t))
+ return false;
+
+ size_t sfntTableDirectoryCursor = sfnt.size();
+ sfnt.grow(sfnt.size() + numTables * 4 * sizeof(uint32_t));
+
+ // Process tables.
+ for (uint16_t i = 0; i < numTables; ++i) {
+ // Read a WOFF table directory entry.
+ uint32_t tableTag;
+ if (!readUInt32(woff, offset, tableTag))
+ return false;
+
+ uint32_t tableOffset;
+ if (!readUInt32(woff, offset, tableOffset))
+ return false;
+
+ uint32_t tableCompLength;
+ if (!readUInt32(woff, offset, tableCompLength))
+ return false;
+
+ if (tableOffset > woff->size() || tableCompLength > woff->size() - tableOffset)
+ return false;
+
+ uint32_t tableOrigLength;
+ if (!readUInt32(woff, offset, tableOrigLength) || tableCompLength > tableOrigLength)
+ return false;
+
+ if (tableOrigLength > totalSfntSize || sfnt.size() > totalSfntSize - tableOrigLength)
+ return false;
+
+ uint32_t tableOrigChecksum;
+ if (!readUInt32(woff, offset, tableOrigChecksum))
+ return false;
+
+ // Write an sfnt table directory entry.
+ uint32_t* sfntTableDirectoryPtr = reinterpret_cast<uint32_t*>(sfnt.data() + sfntTableDirectoryCursor);
+ *sfntTableDirectoryPtr++ = htonl(tableTag);
+ *sfntTableDirectoryPtr++ = htonl(tableOrigChecksum);
+ *sfntTableDirectoryPtr++ = htonl(sfnt.size());
+ *sfntTableDirectoryPtr++ = htonl(tableOrigLength);
+ sfntTableDirectoryCursor += 4 * sizeof(uint32_t);
+
+ if (tableCompLength == tableOrigLength) {
+ // The table is not compressed.
+ if (!sfnt.tryAppend(woff->data() + tableOffset, tableCompLength))
+ return false;
+ } else {
+ uLongf destLen = tableOrigLength;
+ if (!sfnt.tryReserveCapacity(sfnt.size() + tableOrigLength))
+ return false;
+ Bytef* dest = reinterpret_cast<Bytef*>(sfnt.end());
+ sfnt.grow(sfnt.size() + tableOrigLength);
+ if (uncompress(dest, &destLen, reinterpret_cast<const Bytef*>(woff->data() + tableOffset), tableCompLength) != Z_OK)
+ return false;
+ if (destLen != tableOrigLength)
+ return false;
+ }
+
+ // Pad to a multiple of 4 bytes.
+ while (sfnt.size() % 4)
+ sfnt.append(0);
+ }
+
+ return sfnt.size() == totalSfntSize;
+}
+
+#endif // !ENABLE(OPENTYPE_SANITIZER)
+
+} // namespace WebCore
diff --git a/WebCore/platform/graphics/WOFFFileFormat.h b/WebCore/platform/graphics/WOFFFileFormat.h
new file mode 100644
index 0000000..9351d0e
--- /dev/null
+++ b/WebCore/platform/graphics/WOFFFileFormat.h
@@ -0,0 +1,48 @@
+/*
+ * Copyright (C) 2010 Apple 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:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. 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.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS 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 APPLE INC. OR ITS 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 WOFFFileFormat_h
+#define WOFFFileFormat_h
+
+#if !ENABLE(OPENTYPE_SANITIZER)
+
+#include <wtf/Vector.h>
+
+namespace WebCore {
+
+class SharedBuffer;
+
+// Returns whether the buffer is a WOFF file.
+bool isWOFF(SharedBuffer* buffer);
+
+// Returns false if the WOFF file woff is invalid or could not be converted to sfnt (for example,
+// if conversion ran out of memory). Otherwise returns true and writes the sfnt payload into sfnt.
+bool convertWOFFToSfnt(SharedBuffer* woff, Vector<char>& sfnt);
+
+} // namespace WebCore
+
+#endif // !ENABLE(OPENTYPE_SANITIZER)
+
+#endif // WOFFFileFormat_h
diff --git a/WebCore/platform/graphics/cairo/CairoPath.h b/WebCore/platform/graphics/cairo/CairoPath.h
index b761ce6..da7affb 100644
--- a/WebCore/platform/graphics/cairo/CairoPath.h
+++ b/WebCore/platform/graphics/cairo/CairoPath.h
@@ -1,5 +1,6 @@
/*
Copyright (C) 2007 Alp Toker <alp.toker@collabora.co.uk>
+ Copyright (C) 2010 Igalia S.L.
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
@@ -24,21 +25,25 @@
namespace WebCore {
- // This is necessary since cairo_path_fixed_t isn't exposed in Cairo's public API.
- struct CairoPath {
- cairo_t* m_cr;
-
- CairoPath()
- {
- static cairo_surface_t* pathSurface = cairo_image_surface_create(CAIRO_FORMAT_A8, 1, 1);
- m_cr = cairo_create(pathSurface);
- }
-
- ~CairoPath()
- {
- cairo_destroy(m_cr);
- }
- };
+// This is necessary since cairo_path_fixed_t isn't exposed in Cairo's public API.
+class CairoPath {
+public:
+ CairoPath()
+ {
+ static cairo_surface_t* pathSurface = cairo_image_surface_create(CAIRO_FORMAT_A8, 1, 1);
+ m_cr = cairo_create(pathSurface);
+ }
+
+ ~CairoPath()
+ {
+ cairo_destroy(m_cr);
+ }
+
+ cairo_t* context() { return m_cr; }
+
+private:
+ cairo_t* m_cr;
+};
} // namespace WebCore
diff --git a/WebCore/platform/graphics/cairo/FontCustomPlatformData.cpp b/WebCore/platform/graphics/cairo/FontCustomPlatformData.cpp
index bb2e064..6b76c2a 100644
--- a/WebCore/platform/graphics/cairo/FontCustomPlatformData.cpp
+++ b/WebCore/platform/graphics/cairo/FontCustomPlatformData.cpp
@@ -21,8 +21,8 @@
#include "config.h"
#include "FontCustomPlatformData.h"
-#include "SharedBuffer.h"
#include "FontPlatformData.h"
+#include "SharedBuffer.h"
namespace WebCore {
@@ -70,4 +70,9 @@ FontCustomPlatformData* createFontCustomPlatformData(SharedBuffer* buffer)
return new FontCustomPlatformData(fontFace);
}
+bool FontCustomPlatformData::supportsFormat(const String& format)
+{
+ return equalIgnoringCase(format, "truetype") || equalIgnoringCase(format, "opentype");
+}
+
}
diff --git a/WebCore/platform/graphics/cairo/FontCustomPlatformData.h b/WebCore/platform/graphics/cairo/FontCustomPlatformData.h
index b36cc79..2816427 100644
--- a/WebCore/platform/graphics/cairo/FontCustomPlatformData.h
+++ b/WebCore/platform/graphics/cairo/FontCustomPlatformData.h
@@ -30,6 +30,7 @@ namespace WebCore {
class FontPlatformData;
class SharedBuffer;
+class String;
struct FontCustomPlatformData : Noncopyable {
FontCustomPlatformData(cairo_font_face_t* fontFace)
@@ -40,6 +41,8 @@ struct FontCustomPlatformData : Noncopyable {
FontPlatformData fontPlatformData(int size, bool bold, bool italic, FontRenderingMode = NormalRenderingMode);
+ static bool supportsFormat(const String&);
+
cairo_font_face_t* m_fontFace;
};
diff --git a/WebCore/platform/graphics/cairo/GraphicsContextCairo.cpp b/WebCore/platform/graphics/cairo/GraphicsContextCairo.cpp
index 96cd4ee..f3fc943 100644
--- a/WebCore/platform/graphics/cairo/GraphicsContextCairo.cpp
+++ b/WebCore/platform/graphics/cairo/GraphicsContextCairo.cpp
@@ -4,6 +4,7 @@
* Copyright (C) 2008, 2009 Dirk Schulze <krit@webkit.org>
* Copyright (C) 2008 Nuanti Ltd.
* Copyright (C) 2009 Brent Fulgham <bfulgham@webkit.org>
+ * Copyright (C) 2010 Igalia S.L.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -143,6 +144,35 @@ static inline void copyContextProperties(cairo_t* srcCr, cairo_t* dstCr)
cairo_set_fill_rule(dstCr, cairo_get_fill_rule(srcCr));
}
+static void appendPathToCairoContext(cairo_t* to, cairo_t* from)
+{
+ cairo_path_t* cairoPath = cairo_copy_path(from);
+ cairo_append_path(to, cairoPath);
+ cairo_path_destroy(cairoPath);
+}
+
+// We apply the pending path built via addPath to the Cairo context
+// lazily. This prevents interaction between the path and other routines
+// such as fillRect.
+static void setPathOnCairoContext(cairo_t* to, cairo_t* from)
+{
+ cairo_new_path(to);
+ appendPathToCairoContext(to, from);
+}
+
+static void appendWebCorePathToCairoContext(cairo_t* context, const Path& path)
+{
+ appendPathToCairoContext(context, path.platformPath()->context());
+}
+
+static void addConvexPolygonToContext(cairo_t* context, size_t numPoints, const FloatPoint* points)
+{
+ cairo_move_to(context, points[0].x(), points[0].y());
+ for (size_t i = 1; i < numPoints; i++)
+ cairo_line_to(context, points[i].x(), points[i].y());
+ cairo_close_path(context);
+}
+
void GraphicsContext::calculateShadowBufferDimensions(IntSize& shadowBufferSize, FloatRect& shadowRect, float& kernelSize, const FloatRect& sourceRect, const FloatSize& shadowSize, float shadowBlur)
{
#if ENABLE(FILTERS)
@@ -201,6 +231,22 @@ static inline void drawPathShadow(GraphicsContext* context, GraphicsContextPriva
#endif
}
+static void fillCurrentCairoPath(GraphicsContext* context, GraphicsContextPrivate* gcp, cairo_t* cairoContext)
+{
+ cairo_set_fill_rule(cairoContext, context->fillRule() == RULE_EVENODD ? CAIRO_FILL_RULE_EVEN_ODD : CAIRO_FILL_RULE_WINDING);
+ drawPathShadow(context, gcp, true, false);
+
+ setPlatformFill(context, cairoContext, gcp);
+ cairo_new_path(cairoContext);
+}
+
+static void strokeCurrentCairoPath(GraphicsContext* context, GraphicsContextPrivate* gcp, cairo_t* cairoContext)
+{
+ drawPathShadow(context, gcp, false, true);
+ setPlatformStroke(context, cairoContext, gcp);
+ cairo_new_path(cairoContext);
+}
+
GraphicsContext::GraphicsContext(PlatformGraphicsContext* cr)
: m_common(createGraphicsContextPrivate())
, m_data(new GraphicsContextPlatformPrivate)
@@ -380,9 +426,8 @@ void GraphicsContext::drawEllipse(const IntRect& rect)
setColor(cr, strokeColor());
cairo_set_line_width(cr, strokeThickness());
cairo_stroke(cr);
- }
-
- cairo_new_path(cr);
+ } else
+ cairo_new_path(cr);
}
void GraphicsContext::strokeArc(const IntRect& rect, int startAngle, int angleSpan)
@@ -483,10 +528,7 @@ void GraphicsContext::drawConvexPolygon(size_t npoints, const FloatPoint* points
cairo_save(cr);
cairo_set_antialias(cr, shouldAntialias ? CAIRO_ANTIALIAS_DEFAULT : CAIRO_ANTIALIAS_NONE);
- cairo_move_to(cr, points[0].x(), points[0].y());
- for (size_t i = 1; i < npoints; i++)
- cairo_line_to(cr, points[i].x(), points[i].y());
- cairo_close_path(cr);
+ addConvexPolygonToContext(cr, npoints, points);
if (fillColor().alpha()) {
setColor(cr, fillColor());
@@ -498,9 +540,9 @@ void GraphicsContext::drawConvexPolygon(size_t npoints, const FloatPoint* points
setColor(cr, strokeColor());
cairo_set_line_width(cr, strokeThickness());
cairo_stroke(cr);
- }
+ } else
+ cairo_new_path(cr);
- cairo_new_path(cr);
cairo_restore(cr);
}
@@ -511,8 +553,20 @@ void GraphicsContext::clipConvexPolygon(size_t numPoints, const FloatPoint* poin
if (numPoints <= 1)
return;
-
- // FIXME: IMPLEMENT!
+
+ cairo_t* cr = m_data->cr;
+
+ cairo_new_path(cr);
+ cairo_fill_rule_t savedFillRule = cairo_get_fill_rule(cr);
+ cairo_antialias_t savedAntialiasRule = cairo_get_antialias(cr);
+
+ cairo_set_antialias(cr, CAIRO_ANTIALIAS_DEFAULT);
+ cairo_set_fill_rule(cr, CAIRO_FILL_RULE_WINDING);
+ addConvexPolygonToContext(cr, numPoints, points);
+ cairo_clip(cr);
+
+ cairo_set_antialias(cr, savedAntialiasRule);
+ cairo_set_fill_rule(cr, savedFillRule);
}
void GraphicsContext::fillPath()
@@ -522,11 +576,8 @@ void GraphicsContext::fillPath()
cairo_t* cr = m_data->cr;
- cairo_set_fill_rule(cr, fillRule() == RULE_EVENODD ? CAIRO_FILL_RULE_EVEN_ODD : CAIRO_FILL_RULE_WINDING);
- drawPathShadow(this, m_common, true, false);
-
- setPlatformFill(this, cr, m_common);
- cairo_new_path(cr);
+ setPathOnCairoContext(cr, m_data->m_pendingPath.context());
+ fillCurrentCairoPath(this, m_common, cr);
}
void GraphicsContext::strokePath()
@@ -535,11 +586,8 @@ void GraphicsContext::strokePath()
return;
cairo_t* cr = m_data->cr;
- drawPathShadow(this, m_common, false, true);
-
- setPlatformStroke(this, cr, m_common);
- cairo_new_path(cr);
-
+ setPathOnCairoContext(cr, m_data->m_pendingPath.context());
+ strokeCurrentCairoPath(this, m_common, cr);
}
void GraphicsContext::drawPath()
@@ -549,6 +597,8 @@ void GraphicsContext::drawPath()
cairo_t* cr = m_data->cr;
+ setPathOnCairoContext(cr, m_data->m_pendingPath.context());
+
cairo_set_fill_rule(cr, fillRule() == RULE_EVENODD ? CAIRO_FILL_RULE_EVEN_ODD : CAIRO_FILL_RULE_WINDING);
drawPathShadow(this, m_common, true, true);
@@ -565,7 +615,7 @@ void GraphicsContext::fillRect(const FloatRect& rect)
cairo_t* cr = m_data->cr;
cairo_save(cr);
cairo_rectangle(cr, rect.x(), rect.y(), rect.width(), rect.height());
- fillPath();
+ fillCurrentCairoPath(this, m_common, cr);
cairo_restore(cr);
}
@@ -673,7 +723,7 @@ void GraphicsContext::drawFocusRing(const Vector<IntRect>& rects, int width, int
#else
int radius = (width - 1) / 2;
for (unsigned i = 0; i < rectCount; i++)
- addPath(Path::createRoundedRectangle(rects[i], FloatSize(radius, radius)));
+ appendWebCorePathToCairoContext(cr, Path::createRoundedRectangle(rects[i], FloatSize(radius, radius)));
// Force the alpha to 50%. This matches what the Mac does with outline rings.
Color ringColor(color.red(), color.green(), color.blue(), 127);
@@ -700,14 +750,8 @@ void GraphicsContext::drawLineForText(const IntPoint& origin, int width, bool pr
if (paintingDisabled())
return;
- // This is a workaround for http://bugs.webkit.org/show_bug.cgi?id=15659
- StrokeStyle savedStrokeStyle = strokeStyle();
- setStrokeStyle(SolidStroke);
-
IntPoint endPoint = origin + IntSize(width, 0);
drawLine(origin, endPoint);
-
- setStrokeStyle(savedStrokeStyle);
}
#if !PLATFORM(GTK)
@@ -846,6 +890,7 @@ void GraphicsContext::addInnerRoundedRectClip(const IntRect& rect, int thickness
if (paintingDisabled())
return;
+ cairo_t* cr = m_data->cr;
clip(rect);
Path p;
@@ -855,9 +900,8 @@ void GraphicsContext::addInnerRoundedRectClip(const IntRect& rect, int thickness
// Add inner ellipse
r.inflate(-thickness);
p.addEllipse(r);
- addPath(p);
+ appendWebCorePathToCairoContext(cr, p);
- cairo_t* cr = m_data->cr;
cairo_fill_rule_t savedFillRule = cairo_get_fill_rule(cr);
cairo_set_fill_rule(cr, CAIRO_FILL_RULE_EVEN_ODD);
cairo_clip(cr);
@@ -968,7 +1012,7 @@ void GraphicsContext::strokeRect(const FloatRect& rect, float width)
cairo_save(cr);
cairo_rectangle(cr, rect.x(), rect.y(), rect.width(), rect.height());
cairo_set_line_width(cr, width);
- strokePath();
+ strokeCurrentCairoPath(this, m_common, cr);
cairo_restore(cr);
}
@@ -1085,8 +1129,7 @@ void GraphicsContext::beginPath()
if (paintingDisabled())
return;
- cairo_t* cr = m_data->cr;
- cairo_new_path(cr);
+ cairo_new_path(m_data->m_pendingPath.context());
}
void GraphicsContext::addPath(const Path& path)
@@ -1094,10 +1137,10 @@ void GraphicsContext::addPath(const Path& path)
if (paintingDisabled())
return;
- cairo_t* cr = m_data->cr;
- cairo_path_t* p = cairo_copy_path(path.platformPath()->m_cr);
- cairo_append_path(cr, p);
- cairo_path_destroy(p);
+ cairo_matrix_t currentMatrix;
+ cairo_get_matrix(m_data->cr, &currentMatrix);
+ cairo_set_matrix(m_data->m_pendingPath.context(), &currentMatrix);
+ appendWebCorePathToCairoContext(m_data->m_pendingPath.context(), path);
}
void GraphicsContext::clip(const Path& path)
@@ -1106,7 +1149,7 @@ void GraphicsContext::clip(const Path& path)
return;
cairo_t* cr = m_data->cr;
- cairo_path_t* p = cairo_copy_path(path.platformPath()->m_cr);
+ cairo_path_t* p = cairo_copy_path(path.platformPath()->context());
cairo_append_path(cr, p);
cairo_path_destroy(p);
cairo_fill_rule_t savedFillRule = cairo_get_fill_rule(cr);
@@ -1130,7 +1173,7 @@ void GraphicsContext::clipOut(const Path& path)
double x1, y1, x2, y2;
cairo_clip_extents(cr, &x1, &y1, &x2, &y2);
cairo_rectangle(cr, x1, y1, x2 - x1, y2 - y1);
- addPath(path);
+ appendWebCorePathToCairoContext(cr, path);
cairo_fill_rule_t savedFillRule = cairo_get_fill_rule(cr);
cairo_set_fill_rule(cr, CAIRO_FILL_RULE_EVEN_ODD);
@@ -1189,8 +1232,7 @@ void GraphicsContext::fillRoundedRect(const IntRect& r, const IntSize& topLeft,
cairo_t* cr = m_data->cr;
cairo_save(cr);
- beginPath();
- addPath(Path::createRoundedRectangle(r, topLeft, topRight, bottomLeft, bottomRight));
+ appendWebCorePathToCairoContext(cr, Path::createRoundedRectangle(r, topLeft, topRight, bottomLeft, bottomRight));
setColor(cr, color);
drawPathShadow(this, m_common, true, false);
cairo_fill(cr);
diff --git a/WebCore/platform/graphics/cairo/GraphicsContextPlatformPrivateCairo.h b/WebCore/platform/graphics/cairo/GraphicsContextPlatformPrivateCairo.h
index 5e38832..97e7e07 100644
--- a/WebCore/platform/graphics/cairo/GraphicsContextPlatformPrivateCairo.h
+++ b/WebCore/platform/graphics/cairo/GraphicsContextPlatformPrivateCairo.h
@@ -95,6 +95,7 @@ public:
cairo_t* cr;
Vector<float> layers;
+ CairoPath m_pendingPath;
#if PLATFORM(GTK)
GdkEventExpose* expose;
diff --git a/WebCore/platform/graphics/cairo/ImageBufferCairo.cpp b/WebCore/platform/graphics/cairo/ImageBufferCairo.cpp
index c298e18..1a43e54 100644
--- a/WebCore/platform/graphics/cairo/ImageBufferCairo.cpp
+++ b/WebCore/platform/graphics/cairo/ImageBufferCairo.cpp
@@ -277,6 +277,7 @@ void ImageBuffer::putPremultipliedImageData(ImageData* source, const IntRect& so
putImageData<Premultiplied>(source, sourceRect, destPoint, m_data, m_size);
}
+#if !PLATFORM(GTK)
static cairo_status_t writeFunction(void* closure, const unsigned char* data, unsigned int length)
{
Vector<char>* in = reinterpret_cast<Vector<char>*>(closure);
@@ -303,5 +304,6 @@ String ImageBuffer::toDataURL(const String& mimeType, const double*) const
return "data:" + actualMimeType + ";base64," + String(out.data(), out.size());
}
+#endif
} // namespace WebCore
diff --git a/WebCore/platform/graphics/cairo/PathCairo.cpp b/WebCore/platform/graphics/cairo/PathCairo.cpp
index d880626..05c6952 100644
--- a/WebCore/platform/graphics/cairo/PathCairo.cpp
+++ b/WebCore/platform/graphics/cairo/PathCairo.cpp
@@ -51,8 +51,8 @@ Path::~Path()
Path::Path(const Path& other)
: m_path(new CairoPath())
{
- cairo_t* cr = platformPath()->m_cr;
- cairo_path_t* p = cairo_copy_path(other.platformPath()->m_cr);
+ cairo_t* cr = platformPath()->context();
+ cairo_path_t* p = cairo_copy_path(other.platformPath()->context());
cairo_append_path(cr, p);
cairo_path_destroy(p);
}
@@ -63,8 +63,8 @@ Path& Path::operator=(const Path& other)
return *this;
clear();
- cairo_t* cr = platformPath()->m_cr;
- cairo_path_t* p = cairo_copy_path(other.platformPath()->m_cr);
+ cairo_t* cr = platformPath()->context();
+ cairo_path_t* p = cairo_copy_path(other.platformPath()->context());
cairo_append_path(cr, p);
cairo_path_destroy(p);
return *this;
@@ -72,13 +72,13 @@ Path& Path::operator=(const Path& other)
void Path::clear()
{
- cairo_t* cr = platformPath()->m_cr;
+ cairo_t* cr = platformPath()->context();
cairo_new_path(cr);
}
bool Path::isEmpty() const
{
- return !cairo_has_current_point(platformPath()->m_cr);
+ return !cairo_has_current_point(platformPath()->context());
}
bool Path::hasCurrentPoint() const
@@ -91,31 +91,31 @@ FloatPoint Path::currentPoint() const
// FIXME: Is this the correct way?
double x;
double y;
- cairo_get_current_point(platformPath()->m_cr, &x, &y);
+ cairo_get_current_point(platformPath()->context(), &x, &y);
return FloatPoint(x, y);
}
void Path::translate(const FloatSize& p)
{
- cairo_t* cr = platformPath()->m_cr;
+ cairo_t* cr = platformPath()->context();
cairo_translate(cr, -p.width(), -p.height());
}
void Path::moveTo(const FloatPoint& p)
{
- cairo_t* cr = platformPath()->m_cr;
+ cairo_t* cr = platformPath()->context();
cairo_move_to(cr, p.x(), p.y());
}
void Path::addLineTo(const FloatPoint& p)
{
- cairo_t* cr = platformPath()->m_cr;
+ cairo_t* cr = platformPath()->context();
cairo_line_to(cr, p.x(), p.y());
}
void Path::addRect(const FloatRect& rect)
{
- cairo_t* cr = platformPath()->m_cr;
+ cairo_t* cr = platformPath()->context();
cairo_rectangle(cr, rect.x(), rect.y(), rect.width(), rect.height());
}
@@ -124,7 +124,7 @@ void Path::addRect(const FloatRect& rect)
*/
void Path::addQuadCurveTo(const FloatPoint& controlPoint, const FloatPoint& point)
{
- cairo_t* cr = platformPath()->m_cr;
+ cairo_t* cr = platformPath()->context();
double x, y;
double x1 = controlPoint.x();
double y1 = controlPoint.y();
@@ -139,7 +139,7 @@ void Path::addQuadCurveTo(const FloatPoint& controlPoint, const FloatPoint& poin
void Path::addBezierCurveTo(const FloatPoint& controlPoint1, const FloatPoint& controlPoint2, const FloatPoint& controlPoint3)
{
- cairo_t* cr = platformPath()->m_cr;
+ cairo_t* cr = platformPath()->context();
cairo_curve_to(cr, controlPoint1.x(), controlPoint1.y(),
controlPoint2.x(), controlPoint2.y(),
controlPoint3.x(), controlPoint3.y());
@@ -152,7 +152,7 @@ void Path::addArc(const FloatPoint& p, float r, float sa, float ea, bool anticlo
if (!isfinite(r) || !isfinite(sa) || !isfinite(ea))
return;
- cairo_t* cr = platformPath()->m_cr;
+ cairo_t* cr = platformPath()->context();
if (anticlockwise)
cairo_arc_negative(cr, p.x(), p.y(), r, sa, ea);
else
@@ -164,7 +164,7 @@ void Path::addArcTo(const FloatPoint& p1, const FloatPoint& p2, float radius)
if (isEmpty())
return;
- cairo_t* cr = platformPath()->m_cr;
+ cairo_t* cr = platformPath()->context();
double x0, y0;
cairo_get_current_point(cr, &x0, &y0);
@@ -237,7 +237,7 @@ void Path::addArcTo(const FloatPoint& p1, const FloatPoint& p2, float radius)
void Path::addEllipse(const FloatRect& rect)
{
- cairo_t* cr = platformPath()->m_cr;
+ cairo_t* cr = platformPath()->context();
cairo_save(cr);
float yRadius = .5 * rect.height();
float xRadius = .5 * rect.width();
@@ -249,13 +249,13 @@ void Path::addEllipse(const FloatRect& rect)
void Path::closeSubpath()
{
- cairo_t* cr = platformPath()->m_cr;
+ cairo_t* cr = platformPath()->context();
cairo_close_path(cr);
}
FloatRect Path::boundingRect() const
{
- cairo_t* cr = platformPath()->m_cr;
+ cairo_t* cr = platformPath()->context();
double x0, x1, y0, y1;
cairo_path_extents(cr, &x0, &y0, &x1, &y1);
return FloatRect(x0, y0, x1 - x0, y1 - y0);
@@ -263,7 +263,7 @@ FloatRect Path::boundingRect() const
FloatRect Path::strokeBoundingRect(StrokeStyleApplier* applier)
{
- cairo_t* cr = platformPath()->m_cr;
+ cairo_t* cr = platformPath()->context();
if (applier) {
GraphicsContext gc(cr);
applier->strokeStyle(&gc);
@@ -276,7 +276,7 @@ FloatRect Path::strokeBoundingRect(StrokeStyleApplier* applier)
bool Path::contains(const FloatPoint& point, WindRule rule) const
{
- cairo_t* cr = platformPath()->m_cr;
+ cairo_t* cr = platformPath()->context();
cairo_fill_rule_t cur = cairo_get_fill_rule(cr);
cairo_set_fill_rule(cr, rule == RULE_EVENODD ? CAIRO_FILL_RULE_EVEN_ODD : CAIRO_FILL_RULE_WINDING);
bool contains = cairo_in_fill(cr, point.x(), point.y());
@@ -287,7 +287,7 @@ bool Path::contains(const FloatPoint& point, WindRule rule) const
bool Path::strokeContains(StrokeStyleApplier* applier, const FloatPoint& point) const
{
ASSERT(applier);
- cairo_t* cr = platformPath()->m_cr;
+ cairo_t* cr = platformPath()->context();
GraphicsContext gc(cr);
applier->strokeStyle(&gc);
@@ -296,7 +296,7 @@ bool Path::strokeContains(StrokeStyleApplier* applier, const FloatPoint& point)
void Path::apply(void* info, PathApplierFunction function) const
{
- cairo_t* cr = platformPath()->m_cr;
+ cairo_t* cr = platformPath()->context();
cairo_path_t* path = cairo_copy_path(cr);
cairo_path_data_t* data;
PathElement pelement;
@@ -334,10 +334,10 @@ void Path::apply(void* info, PathApplierFunction function) const
void Path::transform(const AffineTransform& trans)
{
- cairo_t* m_cr = platformPath()->m_cr;
+ cairo_t* cr = platformPath()->context();
cairo_matrix_t c_matrix = cairo_matrix_t(trans);
cairo_matrix_invert(&c_matrix);
- cairo_transform(m_cr, &c_matrix);
+ cairo_transform(cr, &c_matrix);
}
String Path::debugString() const
@@ -346,7 +346,7 @@ String Path::debugString() const
return String();
String pathString;
- cairo_path_t* path = cairo_copy_path(platformPath()->m_cr);
+ cairo_path_t* path = cairo_copy_path(platformPath()->context());
cairo_path_data_t* data;
for (int i = 0; i < path->num_data; i += path->data[i].header.length) {
diff --git a/WebCore/platform/graphics/chromium/FontCustomPlatformData.cpp b/WebCore/platform/graphics/chromium/FontCustomPlatformData.cpp
index 74f1e26..b6d6e65 100644
--- a/WebCore/platform/graphics/chromium/FontCustomPlatformData.cpp
+++ b/WebCore/platform/graphics/chromium/FontCustomPlatformData.cpp
@@ -201,4 +201,13 @@ FontCustomPlatformData* createFontCustomPlatformData(SharedBuffer* buffer)
#endif
}
+bool FontCustomPlatformData::supportsFormat(const String& format)
+{
+ return equalIgnoringCase(format, "truetype") || equalIgnoringCase(format, "opentype")
+#if ENABLE(OPENTYPE_SANITIZER)
+ || equalIgnoringCase(format, "woff")
+#endif
+ ;
+}
+
}
diff --git a/WebCore/platform/graphics/chromium/FontCustomPlatformData.h b/WebCore/platform/graphics/chromium/FontCustomPlatformData.h
index e1fbd48..03e1b8c 100644
--- a/WebCore/platform/graphics/chromium/FontCustomPlatformData.h
+++ b/WebCore/platform/graphics/chromium/FontCustomPlatformData.h
@@ -46,6 +46,7 @@ namespace WebCore {
class FontPlatformData;
class SharedBuffer;
+class String;
struct FontCustomPlatformData : Noncopyable {
#if OS(WINDOWS)
@@ -64,6 +65,8 @@ struct FontCustomPlatformData : Noncopyable {
FontPlatformData fontPlatformData(int size, bool bold, bool italic,
FontRenderingMode = NormalRenderingMode);
+ static bool supportsFormat(const String&);
+
#if OS(WINDOWS)
HANDLE m_fontReference;
String m_name;
diff --git a/WebCore/platform/graphics/chromium/GLES2Canvas.cpp b/WebCore/platform/graphics/chromium/GLES2Canvas.cpp
index ec188c8..9fc8917 100644
--- a/WebCore/platform/graphics/chromium/GLES2Canvas.cpp
+++ b/WebCore/platform/graphics/chromium/GLES2Canvas.cpp
@@ -99,6 +99,10 @@ GLES2Canvas::GLES2Canvas(GLES2Context* context, const IntSize& size)
m_stateStack.append(State());
m_state = &m_stateStack.last();
+
+ // Force the source over composite mode to be applied.
+ m_lastCompositeOp = CompositeClear;
+ applyCompositeOperator(CompositeSourceOver);
}
GLES2Canvas::~GLES2Canvas()
diff --git a/WebCore/platform/graphics/chromium/GLES2Canvas.h b/WebCore/platform/graphics/chromium/GLES2Canvas.h
index e3a7a3b..4e500be 100644
--- a/WebCore/platform/graphics/chromium/GLES2Canvas.h
+++ b/WebCore/platform/graphics/chromium/GLES2Canvas.h
@@ -42,6 +42,7 @@
#include <wtf/HashMap.h>
#include <wtf/Noncopyable.h>
+#include <wtf/Vector.h>
namespace WebCore {
diff --git a/WebCore/platform/graphics/gtk/CairoUtilities.cpp b/WebCore/platform/graphics/gtk/CairoUtilities.cpp
new file mode 100644
index 0000000..81e00f0
--- /dev/null
+++ b/WebCore/platform/graphics/gtk/CairoUtilities.cpp
@@ -0,0 +1,94 @@
+/*
+ * Copyright (C) 2010 Igalia S.L.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. 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.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``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 APPLE COMPUTER, INC. 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 "CairoUtilities.h"
+
+#include <cairo.h>
+#include <gtk/gtk.h>
+
+static inline unsigned char* getCairoSurfacePixel(unsigned char* data, unsigned x, unsigned y, unsigned rowStride)
+{
+ return data + (y * rowStride) + x * 4;
+}
+
+static inline guchar* getGdkPixbufPixel(guchar* data, unsigned x, unsigned y, unsigned rowStride)
+{
+ return data + (y * rowStride) + x * 4;
+}
+
+GdkPixbuf* cairoImageSurfaceToGdkPixbuf(cairo_surface_t* surface)
+{
+ int width = cairo_image_surface_get_width(surface);
+ int height = cairo_image_surface_get_height(surface);
+ unsigned char* surfaceData = cairo_image_surface_get_data(surface);
+ int surfaceRowStride = cairo_image_surface_get_stride(surface);
+
+ GdkPixbuf* dest = gdk_pixbuf_new(GDK_COLORSPACE_RGB, TRUE, 8, width, height);
+ if (!dest)
+ return 0;
+
+ guchar* pixbufData = gdk_pixbuf_get_pixels(dest);
+ int pixbufRowStride = gdk_pixbuf_get_rowstride(dest);
+
+ /* From: http://cairographics.org/manual/cairo-image-surface.html#cairo-format-t
+ * "CAIRO_FORMAT_ARGB32: each pixel is a 32-bit quantity, with alpha in
+ * the upper 8 bits, then red, then green, then blue. The 32-bit
+ * quantities are stored native-endian. Pre-multiplied alpha is used.
+ * (That is, 50% transparent red is 0x80800000, not 0x80ff0000.)"
+ *
+ * See http://developer.gimp.org/api/2.0/gdk-pixbuf/gdk-pixbuf-gdk-pixbuf.html#GdkPixbuf
+ * for information on the structure of GdkPixbufs stored with GDK_COLORSPACE_RGB.
+ *
+ * RGB color channels in CAIRO_FORMAT_ARGB32 are stored based on the
+ * endianness of the machine and are also multiplied by the alpha channel.
+ * To properly transfer the data from the Cairo surface we must divide each
+ * of the RGB channels by the alpha channel and then reorder all channels
+ * if this machine is little-endian.
+ */
+ for (int y = 0; y < height; y++) {
+ for (int x = 0; x < width; x++) {
+ unsigned char* source = getCairoSurfacePixel(surfaceData, x, y, surfaceRowStride);
+ guchar* dest = getGdkPixbufPixel(pixbufData, x, y, pixbufRowStride);
+
+#if G_BYTE_ORDER == G_LITTLE_ENDIAN
+ guchar alpha = source[3];
+ dest[0] = alpha ? ((source[2] * 255) / alpha) : 0;
+ dest[1] = alpha ? ((source[1] * 255) / alpha) : 0;
+ dest[2] = alpha ? ((source[0] * 255) / alpha) : 0;
+ dest[3] = alpha;
+#else
+ guchar alpha = source[0];
+ dest[0] = alpha ? ((source[1] * 255) / alpha) : 0;
+ dest[1] = alpha ? ((source[2] * 255) / alpha) : 0;
+ dest[2] = alpha ? ((source[3] * 255) / alpha) : 0;
+ dest[3] = alpha;
+#endif
+ }
+ }
+
+ return dest;
+}
+
diff --git a/WebCore/platform/graphics/gtk/CairoUtilities.h b/WebCore/platform/graphics/gtk/CairoUtilities.h
new file mode 100644
index 0000000..89eb458
--- /dev/null
+++ b/WebCore/platform/graphics/gtk/CairoUtilities.h
@@ -0,0 +1,33 @@
+/*
+ * Copyright (C) 2010 Igalia S.L.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. 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.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``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 APPLE COMPUTER, INC. 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 CairoUtilities_h
+#define CairoUtilities_h
+
+typedef struct _cairo_surface cairo_surface_t;
+typedef struct _GdkPixbuf GdkPixbuf;
+GdkPixbuf* cairoImageSurfaceToGdkPixbuf(cairo_surface_t* surface);
+
+#endif // CairoUtilities_h
diff --git a/WebCore/platform/graphics/gtk/FontCustomPlatformDataPango.cpp b/WebCore/platform/graphics/gtk/FontCustomPlatformDataPango.cpp
index 4f2f2bb..d5f3173 100644
--- a/WebCore/platform/graphics/gtk/FontCustomPlatformDataPango.cpp
+++ b/WebCore/platform/graphics/gtk/FontCustomPlatformDataPango.cpp
@@ -46,4 +46,9 @@ FontCustomPlatformData* createFontCustomPlatformData(SharedBuffer* buffer)
return 0;
}
+bool FontCustomPlatformData::supportsFormat(const String& /* format */)
+{
+ return false;
+}
+
}
diff --git a/WebCore/platform/graphics/gtk/ImageBufferGtk.cpp b/WebCore/platform/graphics/gtk/ImageBufferGtk.cpp
new file mode 100644
index 0000000..d0b0274
--- /dev/null
+++ b/WebCore/platform/graphics/gtk/ImageBufferGtk.cpp
@@ -0,0 +1,73 @@
+/*
+ * Copyright (C) 2010 Igalia S.L.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+
+#include "config.h"
+#include "ImageBuffer.h"
+
+#include "Base64.h"
+#include "CairoUtilities.h"
+#include "GOwnPtr.h"
+#include "GRefPtrGtk.h"
+#include "MIMETypeRegistry.h"
+#include <cairo.h>
+#include <gtk/gtk.h>
+#include <wtf/text/CString.h>
+
+namespace WebCore {
+
+String ImageBuffer::toDataURL(const String& mimeType, const double* quality) const
+{
+ ASSERT(MIMETypeRegistry::isSupportedImageMIMETypeForEncoding(mimeType));
+
+ if (!mimeType.startsWith("image/"))
+ return "data:,";
+
+ // List of supported image types comes from the GdkPixbuf documentation.
+ // http://library.gnome.org/devel/gdk-pixbuf/stable/gdk-pixbuf-file-saving.html#gdk-pixbuf-save-to-bufferv
+ String type = mimeType.substring(sizeof "image");
+ if (type != "jpeg" && type != "png" && type != "tiff" && type != "ico" && type != "bmp")
+ return "data:,";
+
+ GRefPtr<GdkPixbuf> pixbuf = cairoImageSurfaceToGdkPixbuf(m_data.m_surface);
+ if (!pixbuf)
+ return "data:,";
+
+ GOwnPtr<gchar> buffer(0);
+ gsize bufferSize;
+ GError* error = 0;
+ gboolean success = FALSE;
+ if (type == "jpeg" && quality && *quality >= 0.0 && *quality <= 1.0) {
+ String qualityString = String::format("%f", *quality);
+ success = gdk_pixbuf_save_to_buffer(pixbuf.get(), &buffer.outPtr(), &bufferSize,
+ type.utf8().data(), &error, "quality", qualityString.utf8().data(), NULL);
+ } else {
+ success = gdk_pixbuf_save_to_buffer(pixbuf.get(), &buffer.outPtr(), &bufferSize, type.utf8().data(), &error, NULL);
+ }
+
+ if (!success)
+ return "data:,";
+
+ Vector<char> out;
+ base64Encode(reinterpret_cast<const char*>(buffer.get()), bufferSize, out);
+ out.append('\0');
+
+ return String::format("data:%s;base64,%s", mimeType.utf8().data(), out.data());
+}
+
+}
diff --git a/WebCore/platform/graphics/gtk/ImageGtk.cpp b/WebCore/platform/graphics/gtk/ImageGtk.cpp
index 3de8495..30db6d7 100644
--- a/WebCore/platform/graphics/gtk/ImageGtk.cpp
+++ b/WebCore/platform/graphics/gtk/ImageGtk.cpp
@@ -26,6 +26,7 @@
#include "config.h"
#include "BitmapImage.h"
+#include "CairoUtilities.h"
#include "GOwnPtr.h"
#include "SharedBuffer.h"
#include <wtf/text/CString.h>
@@ -172,67 +173,9 @@ PassRefPtr<Image> Image::loadPlatformThemeIcon(const char* name, int size)
return loadImageFromFile(getThemeIconFileName(name, size));
}
-static inline unsigned char* getCairoSurfacePixel(unsigned char* data, unsigned x, unsigned y, unsigned rowStride)
-{
- return data + (y * rowStride) + x * 4;
-}
-
-static inline guchar* getGdkPixbufPixel(guchar* data, unsigned x, unsigned y, unsigned rowStride)
-{
- return data + (y * rowStride) + x * 4;
-}
-
GdkPixbuf* BitmapImage::getGdkPixbuf()
{
- int width = cairo_image_surface_get_width(frameAtIndex(currentFrame()));
- int height = cairo_image_surface_get_height(frameAtIndex(currentFrame()));
- unsigned char* surfaceData = cairo_image_surface_get_data(frameAtIndex(currentFrame()));
- int surfaceRowStride = cairo_image_surface_get_stride(frameAtIndex(currentFrame()));
-
- GdkPixbuf* dest = gdk_pixbuf_new(GDK_COLORSPACE_RGB, TRUE, 8, width, height);
- if (!dest)
- return 0;
-
- guchar* pixbufData = gdk_pixbuf_get_pixels(dest);
- int pixbufRowStride = gdk_pixbuf_get_rowstride(dest);
-
- /* From: http://cairographics.org/manual/cairo-image-surface.html#cairo-format-t
- * "CAIRO_FORMAT_ARGB32: each pixel is a 32-bit quantity, with alpha in
- * the upper 8 bits, then red, then green, then blue. The 32-bit
- * quantities are stored native-endian. Pre-multiplied alpha is used.
- * (That is, 50% transparent red is 0x80800000, not 0x80ff0000.)"
- *
- * See http://developer.gimp.org/api/2.0/gdk-pixbuf/gdk-pixbuf-gdk-pixbuf.html#GdkPixbuf
- * for information on the structure of GdkPixbufs stored with GDK_COLORSPACE_RGB.
- *
- * RGB color channels in CAIRO_FORMAT_ARGB32 are stored based on the
- * endianness of the machine and are also multiplied by the alpha channel.
- * To properly transfer the data from the Cairo surface we must divide each
- * of the RGB channels by the alpha channel and then reorder all channels
- * if this machine is little-endian.
- */
- for (int y = 0; y < height; y++) {
- for (int x = 0; x < width; x++) {
- unsigned char* source = getCairoSurfacePixel(surfaceData, x, y, surfaceRowStride);
- guchar* dest = getGdkPixbufPixel(pixbufData, x, y, pixbufRowStride);
-
-#if G_BYTE_ORDER == G_LITTLE_ENDIAN
- guchar alpha = source[3];
- dest[0] = alpha ? ((source[2] * 255) / alpha) : 0;
- dest[1] = alpha ? ((source[1] * 255) / alpha) : 0;
- dest[2] = alpha ? ((source[0] * 255) / alpha) : 0;
- dest[3] = alpha;
-#else
- guchar alpha = source[0];
- dest[0] = alpha ? ((source[1] * 255) / alpha) : 0;
- dest[1] = alpha ? ((source[2] * 255) / alpha) : 0;
- dest[2] = alpha ? ((source[3] * 255) / alpha) : 0;
- dest[3] = alpha;
-#endif
- }
- }
-
- return dest;
+ return cairoImageSurfaceToGdkPixbuf(frameAtIndex(currentFrame()));
}
}
diff --git a/WebCore/platform/graphics/haiku/FontCustomPlatformData.cpp b/WebCore/platform/graphics/haiku/FontCustomPlatformData.cpp
index 6008bb1..4b39fdd 100644
--- a/WebCore/platform/graphics/haiku/FontCustomPlatformData.cpp
+++ b/WebCore/platform/graphics/haiku/FontCustomPlatformData.cpp
@@ -42,4 +42,9 @@ FontCustomPlatformData* createFontCustomPlatformData(SharedBuffer* buffer)
return 0;
}
+bool FontCustomPlatformData::supportsFormat(const String& /* format */)
+{
+ return false;
+}
+
}
diff --git a/WebCore/platform/graphics/haiku/FontCustomPlatformData.h b/WebCore/platform/graphics/haiku/FontCustomPlatformData.h
index c5a814e..9db6cc6 100644
--- a/WebCore/platform/graphics/haiku/FontCustomPlatformData.h
+++ b/WebCore/platform/graphics/haiku/FontCustomPlatformData.h
@@ -28,12 +28,15 @@ namespace WebCore {
class FontPlatformData;
class SharedBuffer;
+ class String;
struct FontCustomPlatformData : Noncopyable {
public:
FontCustomPlatformData() { }
~FontCustomPlatformData();
+ static bool supportsFormat(const String&);
+
FontPlatformData fontPlatformData(int size, bool bold, bool italic, FontRenderingMode = NormalRenderingMode);
};
diff --git a/WebCore/platform/graphics/mac/FontCustomPlatformData.cpp b/WebCore/platform/graphics/mac/FontCustomPlatformData.cpp
index 256b5a4..c591ddc 100644
--- a/WebCore/platform/graphics/mac/FontCustomPlatformData.cpp
+++ b/WebCore/platform/graphics/mac/FontCustomPlatformData.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2007 Apple Computer, Inc.
+ * Copyright (C) 2007, 2008, 2010 Apple Inc. All rights reserved.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
@@ -21,10 +21,11 @@
#include "config.h"
#include "FontCustomPlatformData.h"
-#include <ApplicationServices/ApplicationServices.h>
-#include "SharedBuffer.h"
#include "FontPlatformData.h"
#include "OpenTypeSanitizer.h"
+#include "SharedBuffer.h"
+#include "WOFFFileFormat.h"
+#include <ApplicationServices/ApplicationServices.h>
namespace WebCore {
@@ -50,6 +51,16 @@ FontCustomPlatformData* createFontCustomPlatformData(SharedBuffer* buffer)
if (!transcodeBuffer)
return 0; // validation failed.
buffer = transcodeBuffer.get();
+#else
+ RefPtr<SharedBuffer> sfntBuffer;
+ if (isWOFF(buffer)) {
+ Vector<char> sfnt;
+ if (!convertWOFFToSfnt(buffer, sfnt))
+ return 0;
+
+ sfntBuffer = SharedBuffer::adoptVector(sfnt);
+ buffer = sfntBuffer.get();
+ }
#endif
ATSFontContainerRef containerRef = 0;
@@ -60,7 +71,7 @@ FontCustomPlatformData* createFontCustomPlatformData(SharedBuffer* buffer)
#if !defined(BUILDING_ON_TIGER) && !defined(BUILDING_ON_LEOPARD)
RetainPtr<CFDataRef> bufferData(AdoptCF, buffer->createCFData());
RetainPtr<CGDataProviderRef> dataProvider(AdoptCF, CGDataProviderCreateWithCFData(bufferData.get()));
-
+
cgFontRef.adoptCF(CGFontCreateWithDataProvider(dataProvider.get()));
if (!cgFontRef)
return 0;
@@ -101,4 +112,9 @@ FontCustomPlatformData* createFontCustomPlatformData(SharedBuffer* buffer)
return new FontCustomPlatformData(containerRef, fontRef, cgFontRef.releaseRef());
}
+bool FontCustomPlatformData::supportsFormat(const String& format)
+{
+ return equalIgnoringCase(format, "truetype") || equalIgnoringCase(format, "opentype") || equalIgnoringCase(format, "woff");
+}
+
}
diff --git a/WebCore/platform/graphics/mac/FontCustomPlatformData.h b/WebCore/platform/graphics/mac/FontCustomPlatformData.h
index 2c1222f..f2cd2cc 100644
--- a/WebCore/platform/graphics/mac/FontCustomPlatformData.h
+++ b/WebCore/platform/graphics/mac/FontCustomPlatformData.h
@@ -33,6 +33,7 @@ namespace WebCore {
class FontPlatformData;
class SharedBuffer;
+class String;
struct FontCustomPlatformData : Noncopyable {
FontCustomPlatformData(ATSFontContainerRef container, ATSFontRef atsFont, CGFontRef cgFont)
@@ -42,6 +43,8 @@ struct FontCustomPlatformData : Noncopyable {
FontPlatformData fontPlatformData(int size, bool bold, bool italic, FontRenderingMode = NormalRenderingMode);
+ static bool supportsFormat(const String&);
+
ATSFontContainerRef m_atsContainer;
ATSFontRef m_atsFont;
CGFontRef m_cgFont;
diff --git a/WebCore/platform/graphics/qt/FontCustomPlatformData.h b/WebCore/platform/graphics/qt/FontCustomPlatformData.h
index 0f2a6ce..6837059 100644
--- a/WebCore/platform/graphics/qt/FontCustomPlatformData.h
+++ b/WebCore/platform/graphics/qt/FontCustomPlatformData.h
@@ -27,8 +27,9 @@
namespace WebCore {
-class SharedBuffer;
class FontPlatformData;
+class SharedBuffer;
+class String;
struct FontCustomPlatformData : Noncopyable {
~FontCustomPlatformData();
@@ -37,6 +38,8 @@ struct FontCustomPlatformData : Noncopyable {
int m_handle;
FontPlatformData fontPlatformData(int size, bool bold, bool italic, FontRenderingMode = NormalRenderingMode);
+
+ static bool supportsFormat(const String&);
};
FontCustomPlatformData* createFontCustomPlatformData(SharedBuffer* buffer);
diff --git a/WebCore/platform/graphics/qt/FontCustomPlatformDataQt.cpp b/WebCore/platform/graphics/qt/FontCustomPlatformDataQt.cpp
index 6e9d053..dbf0b16 100644
--- a/WebCore/platform/graphics/qt/FontCustomPlatformDataQt.cpp
+++ b/WebCore/platform/graphics/qt/FontCustomPlatformDataQt.cpp
@@ -61,5 +61,9 @@ FontCustomPlatformData* createFontCustomPlatformData(SharedBuffer* buffer)
return data;
}
+bool FontCustomPlatformData::supportsFormat(const String& format)
+{
+ return equalIgnoringCase(format, "truetype") || equalIgnoringCase(format, "opentype");
}
+}
diff --git a/WebCore/platform/graphics/skia/ImageBufferSkia.cpp b/WebCore/platform/graphics/skia/ImageBufferSkia.cpp
index 26c44f2..3eb033d 100644
--- a/WebCore/platform/graphics/skia/ImageBufferSkia.cpp
+++ b/WebCore/platform/graphics/skia/ImageBufferSkia.cpp
@@ -198,11 +198,13 @@ PassRefPtr<ImageData> getImageData(const IntRect& rect, const SkBitmap& bitmap,
PassRefPtr<ImageData> ImageBuffer::getUnmultipliedImageData(const IntRect& rect) const
{
+ context()->platformContext()->syncSoftwareCanvas();
return getImageData<Unmultiplied>(rect, *context()->platformContext()->bitmap(), m_size);
}
PassRefPtr<ImageData> ImageBuffer::getPremultipliedImageData(const IntRect& rect) const
{
+ context()->platformContext()->syncSoftwareCanvas();
return getImageData<Premultiplied>(rect, *context()->platformContext()->bitmap(), m_size);
}
diff --git a/WebCore/platform/graphics/skia/ImageSkia.cpp b/WebCore/platform/graphics/skia/ImageSkia.cpp
index d1d1692..a2485e6 100644
--- a/WebCore/platform/graphics/skia/ImageSkia.cpp
+++ b/WebCore/platform/graphics/skia/ImageSkia.cpp
@@ -47,6 +47,11 @@
#include "skia/ext/image_operations.h"
#include "skia/ext/platform_canvas.h"
+#if USE(GLES2_RENDERING)
+#include "GLES2Canvas.h"
+#include "GLES2Context.h"
+#include "SkPixelRef.h"
+#endif
namespace WebCore {
@@ -404,6 +409,24 @@ void Image::drawPattern(GraphicsContext* context,
context->platformContext()->paintSkPaint(destRect, paint);
}
+#if USE(GLES2_RENDERING)
+static void drawBitmapGLES2(GraphicsContext* ctxt, NativeImageSkia* bitmap, const FloatRect& srcRect, const FloatRect& dstRect, ColorSpace styleColorSpace, CompositeOperator compositeOp)
+{
+ ctxt->platformContext()->prepareForHardwareDraw();
+ GLES2Canvas* gpuCanvas = ctxt->platformContext()->gpuCanvas();
+ gpuCanvas->gles2Context()->makeCurrent();
+ GLES2Texture* texture = gpuCanvas->getTexture(bitmap);
+ if (!texture) {
+ ASSERT(bitmap->config() == SkBitmap::kARGB_8888_Config);
+ ASSERT(bitmap->rowBytes() == bitmap->width() * 4);
+ texture = gpuCanvas->createTexture(bitmap, GLES2Texture::BGRA8, bitmap->width(), bitmap->height());
+ ASSERT(bitmap->pixelRef());
+ texture->load(bitmap->pixelRef()->pixels());
+ }
+ gpuCanvas->drawTexturedRect(texture, srcRect, dstRect, styleColorSpace, compositeOp);
+}
+#endif
+
// ================================================
// BitmapImage Class
// ================================================
@@ -429,7 +452,7 @@ void BitmapImage::checkForSolidColor()
}
void BitmapImage::draw(GraphicsContext* ctxt, const FloatRect& dstRect,
- const FloatRect& srcRect, ColorSpace, CompositeOperator compositeOp)
+ const FloatRect& srcRect, ColorSpace colorSpace, CompositeOperator compositeOp)
{
if (!m_source.initialized())
return;
@@ -439,16 +462,24 @@ void BitmapImage::draw(GraphicsContext* ctxt, const FloatRect& dstRect,
// causing flicker and wasting CPU.
startAnimation();
- const NativeImageSkia* bm = nativeImageForCurrentFrame();
+ NativeImageSkia* bm = nativeImageForCurrentFrame();
if (!bm)
return; // It's too early and we don't have an image yet.
+#if USE(GLES2_RENDERING)
+ if (ctxt->platformContext()->useGPU()) {
+ drawBitmapGLES2(ctxt, bm, srcRect, dstRect, colorSpace, compositeOp);
+ return;
+ }
+#endif
FloatRect normDstRect = normalizeRect(dstRect);
FloatRect normSrcRect = normalizeRect(srcRect);
if (normSrcRect.isEmpty() || normDstRect.isEmpty())
return; // Nothing to draw.
+ ctxt->platformContext()->prepareForSoftwareDraw();
+
paintSkBitmap(ctxt->platformContext(),
*bm,
enclosingIntRect(normSrcRect),
@@ -470,6 +501,15 @@ void BitmapImageSingleFrameSkia::draw(GraphicsContext* ctxt,
if (normSrcRect.isEmpty() || normDstRect.isEmpty())
return; // Nothing to draw.
+#if USE(GLES2_RENDERING)
+ if (ctxt->platformContext()->useGPU()) {
+ drawBitmapGLES2(ctxt, &m_nativeImage, srcRect, dstRect, styleColorSpace, compositeOp);
+ return;
+ }
+#endif
+
+ ctxt->platformContext()->prepareForSoftwareDraw();
+
paintSkBitmap(ctxt->platformContext(),
m_nativeImage,
enclosingIntRect(normSrcRect),
diff --git a/WebCore/platform/graphics/win/FontCustomPlatformData.cpp b/WebCore/platform/graphics/win/FontCustomPlatformData.cpp
index e9f83ab..6e59ad7 100644
--- a/WebCore/platform/graphics/win/FontCustomPlatformData.cpp
+++ b/WebCore/platform/graphics/win/FontCustomPlatformData.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2007, 2008, 2009 Apple Inc. All rights reserved.
+ * Copyright (C) 2007, 2008, 2009, 2010 Apple Inc. All rights reserved.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
@@ -26,6 +26,7 @@
#include "OpenTypeUtilities.h"
#include "SharedBuffer.h"
#include "SoftLinking.h"
+#include "WOFFFileFormat.h"
#include <ApplicationServices/ApplicationServices.h>
#include <WebKitSystemInterface/WebKitSystemInterface.h>
#include <wtf/RetainPtr.h>
@@ -167,6 +168,16 @@ FontCustomPlatformData* createFontCustomPlatformData(SharedBuffer* buffer)
ASSERT_ARG(buffer, buffer);
ASSERT(T2embedLibrary());
+ RefPtr<SharedBuffer> sfntBuffer;
+ if (isWOFF(buffer)) {
+ Vector<char> sfnt;
+ if (!convertWOFFToSfnt(buffer, sfnt))
+ return 0;
+
+ sfntBuffer = SharedBuffer::adoptVector(sfnt);
+ buffer = sfntBuffer.get();
+ }
+
// Introduce the font to GDI. AddFontMemResourceEx cannot be used, because it will pollute the process's
// font namespace (Windows has no API for creating an HFONT from data without exposing the font to the
// entire process first). TTLoadEmbeddedFont lets us override the font family name, so using a unique name
@@ -200,4 +211,9 @@ FontCustomPlatformData* createFontCustomPlatformData(SharedBuffer* buffer)
return new FontCustomPlatformData(fontReference, fontName);
}
+bool FontCustomPlatformData::supportsFormat(const String& format)
+{
+ return equalIgnoringCase(format, "truetype") || equalIgnoringCase(format, "opentype") || equalIgnoringCase(format, "woff");
+}
+
}
diff --git a/WebCore/platform/graphics/win/FontCustomPlatformData.h b/WebCore/platform/graphics/win/FontCustomPlatformData.h
index f75f12a..46ddbb5 100644
--- a/WebCore/platform/graphics/win/FontCustomPlatformData.h
+++ b/WebCore/platform/graphics/win/FontCustomPlatformData.h
@@ -31,6 +31,7 @@ namespace WebCore {
class FontPlatformData;
class SharedBuffer;
+class String;
struct FontCustomPlatformData : Noncopyable {
FontCustomPlatformData(HANDLE fontReference, const String& name)
@@ -43,6 +44,8 @@ struct FontCustomPlatformData : Noncopyable {
FontPlatformData fontPlatformData(int size, bool bold, bool italic, FontRenderingMode = NormalRenderingMode);
+ static bool supportsFormat(const String&);
+
HANDLE m_fontReference;
String m_name;
};
diff --git a/WebCore/platform/graphics/win/FontCustomPlatformDataCairo.cpp b/WebCore/platform/graphics/win/FontCustomPlatformDataCairo.cpp
index e54d85a..35839f5 100644
--- a/WebCore/platform/graphics/win/FontCustomPlatformDataCairo.cpp
+++ b/WebCore/platform/graphics/win/FontCustomPlatformDataCairo.cpp
@@ -58,4 +58,9 @@ FontCustomPlatformDataCairo* createFontCustomPlatformData(SharedBuffer* buffer)
return new FontCustomPlatformDataCairo(fontFace);
}
+bool FontCustomPlatformData::supportsFormat(const String& format)
+{
+ return equalIgnoringCase(format, "truetype") || equalIgnoringCase(format, "opentype");
+}
+
}
diff --git a/WebCore/platform/graphics/win/FontCustomPlatformDataCairo.h b/WebCore/platform/graphics/win/FontCustomPlatformDataCairo.h
index 87794b5..75fe3d1 100644
--- a/WebCore/platform/graphics/win/FontCustomPlatformDataCairo.h
+++ b/WebCore/platform/graphics/win/FontCustomPlatformDataCairo.h
@@ -29,6 +29,7 @@ namespace WebCore {
class FontPlatformData;
class SharedBuffer;
+class String;
struct FontCustomPlatformDataCairo : Noncopyable {
FontCustomPlatformDataCairo(cairo_font_face_t* fontFace)
@@ -39,6 +40,8 @@ struct FontCustomPlatformDataCairo : Noncopyable {
FontPlatformData fontPlatformData(int size, bool bold, bool italic);
+ static bool supportsFormat(const String&);
+
cairo_font_face_t* m_fontFace;
};
diff --git a/WebCore/platform/graphics/win/WKCACFLayer.cpp b/WebCore/platform/graphics/win/WKCACFLayer.cpp
index d3928f1..b5f3427 100644
--- a/WebCore/platform/graphics/win/WKCACFLayer.cpp
+++ b/WebCore/platform/graphics/win/WKCACFLayer.cpp
@@ -29,7 +29,6 @@
#include "WKCACFLayer.h"
-#include "WKCACFContextFlusher.h"
#include "WKCACFLayerRenderer.h"
#include <wtf/text/CString.h>
@@ -123,7 +122,6 @@ static CFStringRef toCACFFilterType(WKCACFLayer::FilterType type)
case WKCACFLayer::Linear: return kCACFFilterLinear;
case WKCACFLayer::Nearest: return kCACFFilterNearest;
case WKCACFLayer::Trilinear: return kCACFFilterTrilinear;
- case WKCACFLayer::Lanczos: return kCACFFilterLanczos;
default: return 0;
}
}
@@ -136,9 +134,6 @@ static WKCACFLayer::FilterType fromCACFFilterType(CFStringRef string)
if (CFEqual(string, kCACFFilterTrilinear))
return WKCACFLayer::Trilinear;
- if (CFEqual(string, kCACFFilterLanczos))
- return WKCACFLayer::Lanczos;
-
return WKCACFLayer::Linear;
}
@@ -180,15 +175,6 @@ void WKCACFLayer::setNeedsCommit()
{
WKCACFLayer* root = rootLayer();
- CACFContextRef context = CACFLayerGetContext(root->layer());
-
- // The context might now be set yet. This happens if a property gets set
- // before placing the layer in the tree. In this case we don't need to
- // worry about remembering the context because we will when the layer is
- // added to the tree.
- if (context)
- WKCACFContextFlusher::shared().addContext(context);
-
// Call setNeedsRender on the root layer, which will cause a render to
// happen in WKCACFLayerRenderer
root->setNeedsRender();
diff --git a/WebCore/platform/graphics/win/WKCACFLayer.h b/WebCore/platform/graphics/win/WKCACFLayer.h
index 5e8eb05..ed39297 100644
--- a/WebCore/platform/graphics/win/WKCACFLayer.h
+++ b/WebCore/platform/graphics/win/WKCACFLayer.h
@@ -56,7 +56,7 @@ protected:
class WKCACFLayer : public RefCounted<WKCACFLayer> {
public:
enum LayerType { Layer, TransformLayer };
- enum FilterType { Linear, Nearest, Trilinear, Lanczos };
+ enum FilterType { Linear, Nearest, Trilinear };
enum ContentsGravityType { Center, Top, Bottom, Left, Right, TopLeft, TopRight,
BottomLeft, BottomRight, Resize, ResizeAspect, ResizeAspectFill };
@@ -162,9 +162,6 @@ public:
virtual void setBounds(const CGRect&);
CGRect bounds() const { return CACFLayerGetBounds(layer()); }
- void setClearsContext(bool clears) { CACFLayerSetClearsContext(layer(), clears); setNeedsCommit(); }
- bool clearsContext() const { return CACFLayerGetClearsContext(layer()); }
-
void setContents(CFTypeRef contents) { CACFLayerSetContents(layer(), contents); setNeedsCommit(); }
CFTypeRef contents() const { return CACFLayerGetContents(layer()); }
@@ -180,9 +177,6 @@ public:
void setEdgeAntialiasingMask(uint32_t mask) { CACFLayerSetEdgeAntialiasingMask(layer(), mask); setNeedsCommit(); }
uint32_t edgeAntialiasingMask() const { return CACFLayerGetEdgeAntialiasingMask(layer()); }
- void setFilters(CFArrayRef filters) { CACFLayerSetFilters(layer(), filters); setNeedsCommit(); }
- CFArrayRef filters() const { return CACFLayerGetFilters(layer()); }
-
virtual void setFrame(const CGRect&);
CGRect frame() const { return CACFLayerGetFrame(layer()); }
@@ -226,9 +220,6 @@ public:
WKCACFLayer* rootLayer() const;
- void setSortsSublayers(bool sorts) { CACFLayerSetSortsSublayers(layer(), sorts); setNeedsCommit(); }
- bool sortsSublayers() const { return CACFLayerGetSortsSublayers(layer()); }
-
void setSublayerTransform(const CATransform3D& transform) { CACFLayerSetSublayerTransform(layer(), transform); setNeedsCommit(); }
CATransform3D sublayerTransform() const { return CACFLayerGetSublayerTransform(layer()); }
diff --git a/WebCore/platform/graphics/win/WKCACFLayerRenderer.cpp b/WebCore/platform/graphics/win/WKCACFLayerRenderer.cpp
index 0ee61f3..2a355c2 100644
--- a/WebCore/platform/graphics/win/WKCACFLayerRenderer.cpp
+++ b/WebCore/platform/graphics/win/WKCACFLayerRenderer.cpp
@@ -98,7 +98,7 @@ public:
return adoptRef(new WKCACFRootLayer(renderer));
}
- virtual void setNeedsRender() { m_renderer->renderSoon(); }
+ virtual void setNeedsRender() { m_renderer->layerTreeDidChange(); }
// Overload this to avoid calling setNeedsDisplay on the layer, which would override the contents
// we have placed on the root layer.
@@ -333,6 +333,12 @@ void WKCACFLayerRenderer::setRootChildLayer(WKCACFLayer* layer)
}
}
+void WKCACFLayerRenderer::layerTreeDidChange()
+{
+ WKCACFContextFlusher::shared().addContext(m_context.get());
+ renderSoon();
+}
+
void WKCACFLayerRenderer::setNeedsDisplay()
{
ASSERT(m_rootLayer);
diff --git a/WebCore/platform/graphics/win/WKCACFLayerRenderer.h b/WebCore/platform/graphics/win/WKCACFLayerRenderer.h
index 1ff955a..2647c5f 100644
--- a/WebCore/platform/graphics/win/WKCACFLayerRenderer.h
+++ b/WebCore/platform/graphics/win/WKCACFLayerRenderer.h
@@ -70,6 +70,7 @@ public:
void setRootContents(CGImageRef);
void setRootContentsAndDisplay(CGImageRef);
void setRootChildLayer(WKCACFLayer* layer);
+ void layerTreeDidChange();
void setNeedsDisplay();
void setHostWindow(HWND window) { m_hostWindow = window; }
void setBackingStoreDirty(bool dirty) { m_backingStoreDirty = dirty; }
diff --git a/WebCore/platform/graphics/wince/FontCustomPlatformData.cpp b/WebCore/platform/graphics/wince/FontCustomPlatformData.cpp
index f8a1e26..3605c72 100644
--- a/WebCore/platform/graphics/wince/FontCustomPlatformData.cpp
+++ b/WebCore/platform/graphics/wince/FontCustomPlatformData.cpp
@@ -83,4 +83,9 @@ FontCustomPlatformData* createFontCustomPlatformData(const SharedBuffer* buffer)
return 0;
}
+bool FontCustomPlatformData::supportsFormat(const String& format)
+{
+ return equalIgnoringCase(format, "truetype") || equalIgnoringCase(format, "opentype");
+}
+
}
diff --git a/WebCore/platform/graphics/wince/FontCustomPlatformData.h b/WebCore/platform/graphics/wince/FontCustomPlatformData.h
index 89d1fdd..5ce0ea6 100644
--- a/WebCore/platform/graphics/wince/FontCustomPlatformData.h
+++ b/WebCore/platform/graphics/wince/FontCustomPlatformData.h
@@ -45,6 +45,9 @@ namespace WebCore {
~FontCustomPlatformData();
FontPlatformData fontPlatformData(int size, bool bold, bool italic, FontRenderingMode = NormalRenderingMode);
+
+ static bool supportsFormat(const String&);
+
String m_name;
};
diff --git a/WebCore/platform/gtk/KeyEventGtk.cpp b/WebCore/platform/gtk/KeyEventGtk.cpp
index 193b7e5..e9756d8 100644
--- a/WebCore/platform/gtk/KeyEventGtk.cpp
+++ b/WebCore/platform/gtk/KeyEventGtk.cpp
@@ -264,15 +264,14 @@ static int windowsKeyCodeForKeyEvent(unsigned int keycode)
case GDK_Select:
return VK_SELECT; // (29) SELECT key
case GDK_Print:
- return VK_PRINT; // (2A) PRINT key
+ return VK_SNAPSHOT; // (2C) PRINT SCREEN key
case GDK_Execute:
return VK_EXECUTE;// (2B) EXECUTE key
- //dunno on this
- //case GDK_PrintScreen:
- // return VK_SNAPSHOT; // (2C) PRINT SCREEN key
case GDK_Insert:
+ case GDK_KP_Insert:
return VK_INSERT; // (2D) INS key
case GDK_Delete:
+ case GDK_KP_Delete:
return VK_DELETE; // (2E) DEL key
case GDK_Help:
return VK_HELP; // (2F) HELP key
diff --git a/WebCore/platform/gtk/PopupMenuGtk.cpp b/WebCore/platform/gtk/PopupMenuGtk.cpp
index bf8cfb4..ca067d9 100644
--- a/WebCore/platform/gtk/PopupMenuGtk.cpp
+++ b/WebCore/platform/gtk/PopupMenuGtk.cpp
@@ -4,6 +4,7 @@
* Copyright (C) 2006, 2007, 2008 Apple Inc. All rights reserved.
* Copyright (C) 2006 Michael Emmel mike.emmel@gmail.com
* Copyright (C) 2008 Collabora Ltd.
+ * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
@@ -23,7 +24,7 @@
*/
#include "config.h"
-#include "PopupMenu.h"
+#include "PopupMenuGtk.h"
#include "FrameView.h"
#include "GtkVersioning.h"
@@ -34,12 +35,12 @@
namespace WebCore {
-PopupMenu::PopupMenu(PopupMenuClient* client)
+PopupMenuGtk::PopupMenuGtk(PopupMenuClient* client)
: m_popupClient(client)
{
}
-PopupMenu::~PopupMenu()
+PopupMenuGtk::~PopupMenuGtk()
{
if (m_popup) {
g_signal_handlers_disconnect_matched(m_popup.get(), G_SIGNAL_MATCH_DATA, 0, 0, 0, 0, this);
@@ -47,7 +48,7 @@ PopupMenu::~PopupMenu()
}
}
-void PopupMenu::show(const IntRect& rect, FrameView* view, int index)
+void PopupMenuGtk::show(const IntRect& rect, FrameView* view, int index)
{
ASSERT(client());
@@ -110,43 +111,43 @@ void PopupMenu::show(const IntRect& rect, FrameView* view, int index)
gtk_menu_popup(m_popup.get(), 0, 0, reinterpret_cast<GtkMenuPositionFunc>(menuPositionFunction), this, 0, gtk_get_current_event_time());
}
-void PopupMenu::hide()
+void PopupMenuGtk::hide()
{
ASSERT(m_popup);
gtk_menu_popdown(m_popup.get());
}
-void PopupMenu::updateFromElement()
+void PopupMenuGtk::updateFromElement()
{
client()->setTextFromItem(client()->selectedIndex());
}
-bool PopupMenu::itemWritingDirectionIsNatural()
+void PopupMenuGtk::disconnectClient()
{
- return true;
+ m_popupClient = 0;
}
-void PopupMenu::menuItemActivated(GtkMenuItem* item, PopupMenu* that)
+void PopupMenuGtk::menuItemActivated(GtkMenuItem* item, PopupMenuGtk* that)
{
ASSERT(that->client());
ASSERT(that->m_indexMap.contains(GTK_WIDGET(item)));
that->client()->valueChanged(that->m_indexMap.get(GTK_WIDGET(item)));
}
-void PopupMenu::menuUnmapped(GtkWidget*, PopupMenu* that)
+void PopupMenuGtk::menuUnmapped(GtkWidget*, PopupMenuGtk* that)
{
ASSERT(that->client());
that->client()->popupDidHide();
}
-void PopupMenu::menuPositionFunction(GtkMenu*, gint* x, gint* y, gboolean* pushIn, PopupMenu* that)
+void PopupMenuGtk::menuPositionFunction(GtkMenu*, gint* x, gint* y, gboolean* pushIn, PopupMenuGtk* that)
{
*x = that->m_menuPosition.x();
*y = that->m_menuPosition.y();
*pushIn = true;
}
-void PopupMenu::menuRemoveItem(GtkWidget* widget, PopupMenu* that)
+void PopupMenuGtk::menuRemoveItem(GtkWidget* widget, PopupMenuGtk* that)
{
ASSERT(that->m_popup);
gtk_container_remove(GTK_CONTAINER(that->m_popup.get()), widget);
diff --git a/WebCore/platform/gtk/PopupMenuGtk.h b/WebCore/platform/gtk/PopupMenuGtk.h
new file mode 100644
index 0000000..fb4e7dd
--- /dev/null
+++ b/WebCore/platform/gtk/PopupMenuGtk.h
@@ -0,0 +1,67 @@
+/*
+ * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see the file COPYING.LIB. If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#ifndef PopupMenuGtk_h
+#define PopupMenuGtk_h
+
+#include "GRefPtrGtk.h"
+#include "IntRect.h"
+#include "PopupMenu.h"
+#include "PopupMenuClient.h"
+#include <glib.h>
+#include <wtf/HashMap.h>
+#include <wtf/PassRefPtr.h>
+#include <wtf/RefCounted.h>
+
+typedef struct _GtkMenu GtkMenu;
+typedef struct _GtkMenuItem GtkMenuItem;
+typedef struct _GtkWidget GtkWidget;
+
+namespace WebCore {
+
+class FrameView;
+class Scrollbar;
+
+class PopupMenuGtk : public PopupMenu {
+public:
+ PopupMenuGtk(PopupMenuClient*);
+ ~PopupMenuGtk();
+
+ virtual void show(const IntRect&, FrameView*, int index);
+ virtual void hide();
+ virtual void updateFromElement();
+ virtual void disconnectClient();
+
+private:
+ PopupMenuClient* client() const { return m_popupClient; }
+
+ static void menuItemActivated(GtkMenuItem* item, PopupMenuGtk*);
+ static void menuUnmapped(GtkWidget*, PopupMenuGtk*);
+ static void menuPositionFunction(GtkMenu*, gint*, gint*, gboolean*, PopupMenuGtk*);
+ static void menuRemoveItem(GtkWidget*, PopupMenuGtk*);
+
+ PopupMenuClient* m_popupClient;
+ IntPoint m_menuPosition;
+ GRefPtr<GtkMenu> m_popup;
+ HashMap<GtkWidget*, int> m_indexMap;
+};
+
+}
+
+#endif // PopupMenuGtk_h
diff --git a/WebCore/platform/gtk/SearchPopupMenuGtk.cpp b/WebCore/platform/gtk/SearchPopupMenuGtk.cpp
index fbaa527..2413773 100644
--- a/WebCore/platform/gtk/SearchPopupMenuGtk.cpp
+++ b/WebCore/platform/gtk/SearchPopupMenuGtk.cpp
@@ -1,4 +1,6 @@
/*
+ * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+ *
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
@@ -15,29 +17,34 @@
*/
#include "config.h"
-#include "SearchPopupMenu.h"
+#include "SearchPopupMenuGtk.h"
#include "NotImplemented.h"
namespace WebCore {
-SearchPopupMenu::SearchPopupMenu(PopupMenuClient* client)
- : PopupMenu(client)
+SearchPopupMenuGtk::SearchPopupMenuGtk(PopupMenuClient* client)
+ : m_popup(adoptRef(new PopupMenuGtk(client)))
{
notImplemented();
}
-void SearchPopupMenu::saveRecentSearches(const AtomicString&, const Vector<String>&)
+PopupMenu* SearchPopupMenuGtk::popupMenu()
+{
+ return m_popup.get();
+}
+
+void SearchPopupMenuGtk::saveRecentSearches(const AtomicString&, const Vector<String>&)
{
notImplemented();
}
-void SearchPopupMenu::loadRecentSearches(const AtomicString&, Vector<String>&)
+void SearchPopupMenuGtk::loadRecentSearches(const AtomicString&, Vector<String>&)
{
notImplemented();
}
-bool SearchPopupMenu::enabled()
+bool SearchPopupMenuGtk::enabled()
{
notImplemented();
return false;
diff --git a/WebCore/platform/gtk/SearchPopupMenuGtk.h b/WebCore/platform/gtk/SearchPopupMenuGtk.h
new file mode 100644
index 0000000..453c63d
--- /dev/null
+++ b/WebCore/platform/gtk/SearchPopupMenuGtk.h
@@ -0,0 +1,44 @@
+/*
+ * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see the file COPYING.LIB. If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ *
+ */
+
+#ifndef SearchPopupMenuGtk_h
+#define SearchPopupMenuGtk_h
+
+#include "PopupMenuGtk.h"
+#include "SearchPopupMenu.h"
+
+namespace WebCore {
+
+class SearchPopupMenuGtk : public SearchPopupMenu {
+public:
+ SearchPopupMenuGtk(PopupMenuClient*);
+
+ virtual PopupMenu* popupMenu();
+ virtual void saveRecentSearches(const AtomicString& name, const Vector<String>& searchItems);
+ virtual void loadRecentSearches(const AtomicString& name, Vector<String>& searchItems);
+ virtual bool enabled();
+
+private:
+ RefPtr<PopupMenuGtk> m_popup;
+};
+
+}
+
+#endif // SearchPopupMenuGtk_h
diff --git a/WebCore/platform/haiku/PopupMenuHaiku.cpp b/WebCore/platform/haiku/PopupMenuHaiku.cpp
index 5adbc66..e3edb83 100644
--- a/WebCore/platform/haiku/PopupMenuHaiku.cpp
+++ b/WebCore/platform/haiku/PopupMenuHaiku.cpp
@@ -2,6 +2,7 @@
* This file is part of the popup menu implementation for <select> elements in WebCore.
*
* Copyright (C) 2010 Stephan Aßmus <superstippi@gmx.de>
+ * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
@@ -21,7 +22,7 @@
*/
#include "config.h"
-#include "PopupMenu.h"
+#include "PopupMenuHaiku.h"
#include "FrameView.h"
@@ -72,9 +73,9 @@ private:
PopupMenuClient* m_popupClient;
};
-class PopupMenuHaiku : public BPopUpMenu {
+class HaikuPopup : public BPopUpMenu {
public:
- PopupMenuHaiku(PopupMenuClient* popupClient)
+ HaikuPopup(PopupMenuClient* popupClient)
: BPopUpMenu("WebCore Popup", true, false)
, m_popupClient(popupClient)
, m_Handler(popupClient)
@@ -86,7 +87,7 @@ public:
SetAsyncAutoDestruct(false);
}
- virtual ~PopupMenuHaiku()
+ virtual ~HaikuPopup()
{
if (be_app->Lock()) {
be_app->RemoveHandler(&m_Handler);
@@ -153,39 +154,39 @@ private:
PopupMenuHandler m_Handler;
};
-PopupMenu::PopupMenu(PopupMenuClient* client)
+PopupMenuHaiku::PopupMenuHaiku(PopupMenuClient* client)
: m_popupClient(client)
- , m_menu(new PopupMenuHaiku(client))
+ , m_menu(new HaikuPopup(client))
{
// We don't need additional references to the client, since we completely
// control any sub-objects we create that need it as well.
}
-PopupMenu::~PopupMenu()
+PopupMenuHaiku::~PopupMenuHaiku()
{
delete m_menu;
}
-void PopupMenu::show(const IntRect& rect, FrameView* view, int index)
+void PopupMenuHaiku::disconnectClient()
+{
+ m_popupClient = 0;
+}
+
+void PopupMenuHaiku::show(const IntRect& rect, FrameView* view, int index)
{
// The menu will update itself from the PopupMenuClient before showing.
m_menu->show(rect, view, index);
}
-void PopupMenu::hide()
+void PopupMenuHaiku::hide()
{
m_menu->hide();
}
-void PopupMenu::updateFromElement()
+void PopupMenuHaiku::updateFromElement()
{
client()->setTextFromItem(m_popupClient->selectedIndex());
}
-bool PopupMenu::itemWritingDirectionIsNatural()
-{
- return false;
-}
-
} // namespace WebCore
diff --git a/WebCore/platform/haiku/PopupMenuHaiku.h b/WebCore/platform/haiku/PopupMenuHaiku.h
new file mode 100644
index 0000000..9207923
--- /dev/null
+++ b/WebCore/platform/haiku/PopupMenuHaiku.h
@@ -0,0 +1,55 @@
+/*
+ * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see the file COPYING.LIB. If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ *
+ */
+
+#ifndef PopupMenuHaiku_h
+#define PopupMenuHaiku_h
+
+#include "IntRect.h"
+#include "PopupMenu.h"
+#include "PopupMenuClient.h"
+#include <wtf/PassRefPtr.h>
+#include <wtf/RefCounted.h>
+
+namespace WebCore {
+
+class FrameView;
+class HaikuPopup;
+class Scrollbar;
+
+class PopupMenuHaiku : public PopupMenu {
+public:
+ PopupMenuHaiku(PopupMenuClient*);
+ ~PopupMenuHaiku();
+
+ virtual void show(const IntRect&, FrameView*, int index);
+ virtual void hide();
+ virtual void updateFromElement();
+ virtual void disconnectClient();
+
+private:
+ PopupMenuClient* client() const { return m_popupClient; }
+
+ PopupMenuClient* m_popupClient;
+ HaikuPopup* m_menu;
+};
+
+}
+
+#endif // PopupMenuHaiku_h
diff --git a/WebCore/platform/haiku/SearchPopupMenuHaiku.cpp b/WebCore/platform/haiku/SearchPopupMenuHaiku.cpp
index fd5d96c..109409a 100644
--- a/WebCore/platform/haiku/SearchPopupMenuHaiku.cpp
+++ b/WebCore/platform/haiku/SearchPopupMenuHaiku.cpp
@@ -1,5 +1,6 @@
/*
* Copyright (C) 2007 Ryan Leavengood <leavengood@gmail.com>
+ * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
@@ -18,7 +19,7 @@
*/
#include "config.h"
-#include "SearchPopupMenu.h"
+#include "SearchPopupMenuHaiku.h"
#include "AtomicString.h"
#include "NotImplemented.h"
@@ -26,26 +27,31 @@
namespace WebCore {
-SearchPopupMenu::SearchPopupMenu(PopupMenuClient* client)
- : PopupMenu(client)
+SearchPopupMenuHaiku::SearchPopupMenuHaiku(PopupMenuClient* client)
+ : m_popup(adoptRef(new PopupMenuHaiku(client)))
{
}
-void SearchPopupMenu::saveRecentSearches(const AtomicString& name, const Vector<String>& searchItems)
+void SearchPopupMenuHaiku::saveRecentSearches(const AtomicString& name, const Vector<String>& searchItems)
{
notImplemented();
}
-void SearchPopupMenu::loadRecentSearches(const AtomicString& name, Vector<String>& searchItems)
+void SearchPopupMenuHaiku::loadRecentSearches(const AtomicString& name, Vector<String>& searchItems)
{
notImplemented();
}
-bool SearchPopupMenu::enabled()
+bool SearchPopupMenuHaiku::enabled()
{
notImplemented();
return false;
}
+PopupMenu* SearchPopupMenuHaiku::popupMenu()
+{
+ return m_popup.get();
+}
+
} // namespace WebCore
diff --git a/WebCore/platform/haiku/SearchPopupMenuHaiku.h b/WebCore/platform/haiku/SearchPopupMenuHaiku.h
new file mode 100644
index 0000000..a9e8e8d
--- /dev/null
+++ b/WebCore/platform/haiku/SearchPopupMenuHaiku.h
@@ -0,0 +1,44 @@
+/*
+ * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see the file COPYING.LIB. If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ *
+ */
+
+#ifndef SearchPopupMenuHaiku_h
+#define SearchPopupMenuHaiku_h
+
+#include "PopupMenuHaiku.h"
+#include "SearchPopupMenu.h"
+
+namespace WebCore {
+
+class SearchPopupMenuHaiku : public SearchPopupMenu {
+public:
+ SearchPopupMenuHaiku(PopupMenuClient*);
+
+ virtual PopupMenu* popupMenu();
+ virtual void saveRecentSearches(const AtomicString& name, const Vector<String>& searchItems);
+ virtual void loadRecentSearches(const AtomicString& name, Vector<String>& searchItems);
+ virtual bool enabled();
+
+private:
+ RefPtr<PopupMenuHaiku> m_popup;
+};
+
+}
+
+#endif // SearchPopupMenuHaiku_h
diff --git a/WebCore/platform/mac/PopupMenuMac.h b/WebCore/platform/mac/PopupMenuMac.h
new file mode 100644
index 0000000..e969fff
--- /dev/null
+++ b/WebCore/platform/mac/PopupMenuMac.h
@@ -0,0 +1,58 @@
+/*
+ * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see the file COPYING.LIB. If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#ifndef PopupMenuMac_h
+#define PopupMenuMac_h
+
+#include "IntRect.h"
+#include "PopupMenu.h"
+#include <wtf/PassRefPtr.h>
+#include <wtf/RefCounted.h>
+#include <wtf/RetainPtr.h>
+
+class NSPopUpButtonCell;
+
+namespace WebCore {
+
+class PopupMenuClient;
+class FrameView;
+class Scrollbar;
+
+class PopupMenuMac : public PopupMenu {
+public:
+ PopupMenuMac(PopupMenuClient*);
+ ~PopupMenuMac();
+
+ virtual void show(const IntRect&, FrameView*, int index);
+ virtual void hide();
+ virtual void updateFromElement();
+ virtual void disconnectClient();
+
+private:
+ void clear();
+ void populate();
+ PopupMenuClient* client() const { return m_popupClient; }
+
+ PopupMenuClient* m_popupClient;
+ RetainPtr<NSPopUpButtonCell> m_popup;
+};
+
+}
+
+#endif // PopupMenuMac_h
diff --git a/WebCore/platform/mac/PopupMenuMac.mm b/WebCore/platform/mac/PopupMenuMac.mm
index 6c067b9..1bf500b 100644
--- a/WebCore/platform/mac/PopupMenuMac.mm
+++ b/WebCore/platform/mac/PopupMenuMac.mm
@@ -1,5 +1,6 @@
/*
* Copyright (C) 2006, 2008 Apple Inc. All rights reserved.
+ * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
@@ -18,7 +19,7 @@
*/
#import "config.h"
-#import "PopupMenu.h"
+#import "PopupMenuMac.h"
#import "AXObjectCache.h"
#import "Chrome.h"
@@ -31,6 +32,7 @@
#import "HTMLOptionElement.h"
#import "HTMLSelectElement.h"
#import "Page.h"
+#import "PopupMenuClient.h"
#import "SimpleFontData.h"
#import "WebCoreSystemInterface.h"
@@ -38,24 +40,24 @@ namespace WebCore {
using namespace HTMLNames;
-PopupMenu::PopupMenu(PopupMenuClient* client)
+PopupMenuMac::PopupMenuMac(PopupMenuClient* client)
: m_popupClient(client)
{
}
-PopupMenu::~PopupMenu()
+PopupMenuMac::~PopupMenuMac()
{
if (m_popup)
[m_popup.get() setControlView:nil];
}
-void PopupMenu::clear()
+void PopupMenuMac::clear()
{
if (m_popup)
[m_popup.get() removeAllItems];
}
-void PopupMenu::populate()
+void PopupMenuMac::populate()
{
if (m_popup)
clear();
@@ -114,7 +116,7 @@ void PopupMenu::populate()
[[m_popup.get() menu] setMenuChangedMessagesEnabled:messagesEnabled];
}
-void PopupMenu::show(const IntRect& r, FrameView* v, int index)
+void PopupMenuMac::show(const IntRect& r, FrameView* v, int index)
{
populate();
int numItems = [m_popup.get() numberOfItems];
@@ -162,7 +164,7 @@ void PopupMenu::show(const IntRect& r, FrameView* v, int index)
RefPtr<Frame> frame = v->frame();
NSEvent* event = [frame->eventHandler()->currentNSEvent() retain];
- RefPtr<PopupMenu> protector(this);
+ RefPtr<PopupMenuMac> protector(this);
RetainPtr<NSView> dummyView(AdoptNS, [[NSView alloc] initWithFrame:r]);
[view addSubview:dummyView.get()];
@@ -194,18 +196,18 @@ void PopupMenu::show(const IntRect& r, FrameView* v, int index)
[event release];
}
-void PopupMenu::hide()
+void PopupMenuMac::hide()
{
[m_popup.get() dismissPopUp];
}
-void PopupMenu::updateFromElement()
+void PopupMenuMac::updateFromElement()
{
}
-bool PopupMenu::itemWritingDirectionIsNatural()
+void PopupMenuMac::disconnectClient()
{
- return true;
+ m_popupClient = 0;
}
}
diff --git a/WebCore/platform/mac/SearchPopupMenuMac.h b/WebCore/platform/mac/SearchPopupMenuMac.h
new file mode 100644
index 0000000..828b07f
--- /dev/null
+++ b/WebCore/platform/mac/SearchPopupMenuMac.h
@@ -0,0 +1,44 @@
+/*
+ * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see the file COPYING.LIB. If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ *
+ */
+
+#ifndef SearchPopupMenuMac_h
+#define SearchPopupMenuMac_h
+
+#include "PopupMenuMac.h"
+#include "SearchPopupMenu.h"
+
+namespace WebCore {
+
+class SearchPopupMenuMac : public SearchPopupMenu {
+public:
+ SearchPopupMenuMac(PopupMenuClient*);
+
+ virtual PopupMenu* popupMenu();
+ virtual void saveRecentSearches(const AtomicString& name, const Vector<String>& searchItems);
+ virtual void loadRecentSearches(const AtomicString& name, Vector<String>& searchItems);
+ virtual bool enabled();
+
+private:
+ RefPtr<PopupMenuMac> m_popup;
+};
+
+}
+
+#endif // SearchPopupMenuMac_h
diff --git a/WebCore/platform/mac/SearchPopupMenuMac.mm b/WebCore/platform/mac/SearchPopupMenuMac.mm
index 262734d..69018ee 100644
--- a/WebCore/platform/mac/SearchPopupMenuMac.mm
+++ b/WebCore/platform/mac/SearchPopupMenuMac.mm
@@ -1,5 +1,6 @@
/*
* Copyright (C) 2006 Apple Computer, Inc.
+ * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
@@ -18,14 +19,14 @@
*/
#import "config.h"
-#import "SearchPopupMenu.h"
+#import "SearchPopupMenuMac.h"
#import "AtomicString.h"
namespace WebCore {
-SearchPopupMenu::SearchPopupMenu(PopupMenuClient* client)
- : PopupMenu(client)
+SearchPopupMenuMac::SearchPopupMenuMac(PopupMenuClient* client)
+ : m_popup(adoptRef(new PopupMenuMac(client)))
{
}
@@ -34,12 +35,17 @@ static NSString* autosaveKey(const String& name)
return [@"com.apple.WebKit.searchField:" stringByAppendingString:name];
}
-bool SearchPopupMenu::enabled()
+PopupMenu* SearchPopupMenuMac::popupMenu()
+{
+ return m_popup.get();
+}
+
+bool SearchPopupMenuMac::enabled()
{
return true;
}
-void SearchPopupMenu::saveRecentSearches(const AtomicString& name, const Vector<String>& searchItems)
+void SearchPopupMenuMac::saveRecentSearches(const AtomicString& name, const Vector<String>& searchItems)
{
if (name.isEmpty())
return;
@@ -56,7 +62,7 @@ void SearchPopupMenu::saveRecentSearches(const AtomicString& name, const Vector<
}
}
-void SearchPopupMenu::loadRecentSearches(const AtomicString& name, Vector<String>& searchItems)
+void SearchPopupMenuMac::loadRecentSearches(const AtomicString& name, Vector<String>& searchItems)
{
if (name.isEmpty())
return;
diff --git a/WebCore/platform/mock/DeviceOrientationClientMock.cpp b/WebCore/platform/mock/DeviceOrientationClientMock.cpp
new file mode 100644
index 0000000..c2c9316
--- /dev/null
+++ b/WebCore/platform/mock/DeviceOrientationClientMock.cpp
@@ -0,0 +1,71 @@
+/*
+ * 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.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``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 "DeviceOrientationClientMock.h"
+
+#include "DeviceOrientationController.h"
+
+namespace WebCore {
+
+DeviceOrientationClientMock::DeviceOrientationClientMock()
+ : m_controller(0)
+ , m_timer(this, &DeviceOrientationClientMock::timerFired)
+ , m_isUpdating(false)
+{
+}
+
+void DeviceOrientationClientMock::setController(DeviceOrientationController* controller)
+{
+ m_controller = controller;
+ ASSERT(m_controller);
+}
+
+void DeviceOrientationClientMock::startUpdating()
+{
+ m_isUpdating = true;
+}
+
+void DeviceOrientationClientMock::stopUpdating()
+{
+ m_isUpdating = false;
+ m_timer.stop();
+}
+
+void DeviceOrientationClientMock::setOrientation(PassRefPtr<DeviceOrientation> orientation)
+{
+ m_orientation = orientation;
+ if (m_isUpdating && !m_timer.isActive())
+ m_timer.startOneShot(0);
+}
+
+void DeviceOrientationClientMock::timerFired(Timer<DeviceOrientationClientMock>* timer)
+{
+ ASSERT_UNUSED(timer, timer == &m_timer);
+ m_timer.stop();
+ m_controller->didChangeDeviceOrientation(m_orientation.get());
+}
+
+} // namespace WebCore
diff --git a/WebCore/platform/mock/DeviceOrientationClientMock.h b/WebCore/platform/mock/DeviceOrientationClientMock.h
new file mode 100644
index 0000000..6691130
--- /dev/null
+++ b/WebCore/platform/mock/DeviceOrientationClientMock.h
@@ -0,0 +1,66 @@
+/*
+ * 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.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``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 DeviceOrientationClientMock_h
+#define DeviceOrientationClientMock_h
+
+#include "DeviceOrientation.h"
+#include "DeviceOrientationClient.h"
+#include "Timer.h"
+
+#include <wtf/PassRefPtr.h>
+#include <wtf/RefPtr.h>
+
+namespace WebCore {
+
+class DeviceOrientationController;
+
+// A mock implementation of DeviceOrientationClient used to test the feature in
+// DumpRenderTree. Embedders should should configure the Page object to use this
+// client when running DumpRenderTree.
+class DeviceOrientationClientMock : public DeviceOrientationClient {
+public:
+ DeviceOrientationClientMock();
+
+ // DeviceOrientationClient
+ virtual void setController(DeviceOrientationController*);
+ virtual void startUpdating();
+ virtual void stopUpdating();
+ virtual DeviceOrientation* lastOrientation() const { return m_orientation.get(); }
+
+ void setOrientation(PassRefPtr<DeviceOrientation>);
+
+private:
+ void timerFired(Timer<DeviceOrientationClientMock>*);
+
+ RefPtr<DeviceOrientation> m_orientation;
+ DeviceOrientationController* m_controller;
+ Timer<DeviceOrientationClientMock> m_timer;
+ bool m_isUpdating;
+};
+
+} // namespace WebCore
+
+#endif // DeviceOrientationClientMock_h
diff --git a/WebCore/platform/mock/SpeechInputClientMock.cpp b/WebCore/platform/mock/SpeechInputClientMock.cpp
new file mode 100644
index 0000000..74a3151
--- /dev/null
+++ b/WebCore/platform/mock/SpeechInputClientMock.cpp
@@ -0,0 +1,95 @@
+/*
+ * 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 "SpeechInputClientMock.h"
+
+#if ENABLE(INPUT_SPEECH)
+
+#include "SpeechInputListener.h"
+
+namespace WebCore {
+
+SpeechInputClientMock::SpeechInputClientMock()
+ : m_recording(false)
+ , m_timer(this, &SpeechInputClientMock::timerFired)
+ , m_listener(0)
+{
+}
+
+bool SpeechInputClientMock::startRecognition(SpeechInputListener* listener)
+{
+ if (m_timer.isActive())
+ return false;
+ m_listener = listener;
+ m_recording = true;
+ m_timer.startOneShot(0);
+ return true;
+}
+
+void SpeechInputClientMock::stopRecording()
+{
+ if (m_timer.isActive() && m_recording) {
+ m_timer.stop();
+ timerFired(&m_timer);
+ }
+}
+
+void SpeechInputClientMock::cancelRecognition()
+{
+ if (m_timer.isActive()) {
+ m_timer.stop();
+ m_recording = false;
+ m_listener->didCompleteRecognition();
+ m_listener = 0;
+ }
+}
+
+void SpeechInputClientMock::setRecognitionResult(const String& result)
+{
+ m_recognitionResult = result;
+}
+
+void SpeechInputClientMock::timerFired(WebCore::Timer<SpeechInputClientMock>*)
+{
+ if (m_recording) {
+ m_recording = false;
+ m_listener->didCompleteRecording();
+ m_timer.startOneShot(0);
+ } else {
+ m_listener->setRecognitionResult(m_recognitionResult);
+ m_listener->didCompleteRecognition();
+ m_listener = 0;
+ }
+}
+
+} // namespace WebCore
+
+#endif // ENABLE(INPUT_SPEECH)
diff --git a/WebCore/platform/mock/SpeechInputClientMock.h b/WebCore/platform/mock/SpeechInputClientMock.h
new file mode 100644
index 0000000..faca444
--- /dev/null
+++ b/WebCore/platform/mock/SpeechInputClientMock.h
@@ -0,0 +1,69 @@
+/*
+ * 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 SpeechInputClientMock_h
+#define SpeechInputClientMock_h
+
+#include "PlatformString.h"
+#include "SpeechInputClient.h"
+#include "Timer.h"
+
+#if ENABLE(INPUT_SPEECH)
+
+namespace WebCore {
+
+class SpeechInputListener;
+
+// Provides a mock object for the speech input embedder API called by WebCore.
+class SpeechInputClientMock : public SpeechInputClient {
+public:
+ SpeechInputClientMock();
+
+ void setRecognitionResult(const String& result);
+
+ // SpeechInputClient methods.
+ bool startRecognition(SpeechInputListener*);
+ void stopRecording();
+ void cancelRecognition();
+
+private:
+ void timerFired(Timer<SpeechInputClientMock>*);
+
+ bool m_recording;
+ Timer<SpeechInputClientMock> m_timer;
+ SpeechInputListener* m_listener;
+ String m_recognitionResult;
+};
+
+} // namespace WebCore
+
+#endif // ENABLE(INPUT_SPEECH)
+
+#endif // SpeechInputClientMock_h
diff --git a/WebCore/platform/qt/PopupMenuQt.cpp b/WebCore/platform/qt/PopupMenuQt.cpp
index 315b891..5590556 100644
--- a/WebCore/platform/qt/PopupMenuQt.cpp
+++ b/WebCore/platform/qt/PopupMenuQt.cpp
@@ -24,7 +24,7 @@
*/
#include "config.h"
-#include "PopupMenu.h"
+#include "PopupMenuQt.h"
#include "Chrome.h"
#include "ChromeClientQt.h"
@@ -35,18 +35,24 @@
namespace WebCore {
-PopupMenu::PopupMenu(PopupMenuClient* client)
+PopupMenuQt::PopupMenuQt(PopupMenuClient* client)
: m_popupClient(client)
, m_popup(0)
{
}
-PopupMenu::~PopupMenu()
+PopupMenuQt::~PopupMenuQt()
{
delete m_popup;
}
-void PopupMenu::show(const IntRect& rect, FrameView* view, int index)
+
+void PopupMenuQt::disconnectClient()
+{
+ m_popupClient = 0;
+}
+
+void PopupMenuQt::show(const IntRect& rect, FrameView* view, int index)
{
ChromeClientQt* chromeClient = static_cast<ChromeClientQt*>(
view->frame()->page()->chrome()->client());
@@ -67,19 +73,14 @@ void PopupMenu::show(const IntRect& rect, FrameView* view, int index)
}
-void PopupMenu::hide()
+void PopupMenuQt::hide()
{
m_popup->hide();
}
-void PopupMenu::updateFromElement()
-{
- client()->setTextFromItem(m_popupClient->selectedIndex());
-}
-
-bool PopupMenu::itemWritingDirectionIsNatural()
+void PopupMenuQt::updateFromElement()
{
- return false;
+ m_popupClient->setTextFromItem(m_popupClient->selectedIndex());
}
}
diff --git a/WebCore/platform/qt/PopupMenuQt.h b/WebCore/platform/qt/PopupMenuQt.h
new file mode 100644
index 0000000..25a9f76
--- /dev/null
+++ b/WebCore/platform/qt/PopupMenuQt.h
@@ -0,0 +1,49 @@
+/*
+ * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see the file COPYING.LIB. If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#ifndef PopupMenuQt_h
+#define PopupMenuQt_h
+
+#include "PopupMenu.h"
+
+namespace WebCore {
+
+class FrameView;
+class QtAbstractWebPopup;
+class Scrollbar;
+class PopupMenuClient;
+
+class PopupMenuQt : public PopupMenu {
+public:
+ PopupMenuQt(PopupMenuClient*);
+ ~PopupMenuQt();
+
+ virtual void show(const IntRect&, FrameView*, int index);
+ virtual void hide();
+ virtual void updateFromElement();
+ virtual void disconnectClient();
+
+private:
+ PopupMenuClient* m_popupClient;
+ QtAbstractWebPopup* m_popup;
+};
+
+}
+
+#endif // PopupMenuQt_h
diff --git a/WebCore/platform/qt/QtAbstractWebPopup.h b/WebCore/platform/qt/QtAbstractWebPopup.h
index dad4997..5f6f619 100644
--- a/WebCore/platform/qt/QtAbstractWebPopup.h
+++ b/WebCore/platform/qt/QtAbstractWebPopup.h
@@ -63,7 +63,7 @@ public:
QFont font() { return m_popupClient->menuStyle().font().font(); }
private:
- friend class PopupMenu;
+ friend class PopupMenuQt;
PopupMenuClient* m_popupClient;
QWebPageClient* m_pageClient;
int m_currentIndex;
diff --git a/WebCore/platform/qt/SearchPopupMenuQt.cpp b/WebCore/platform/qt/SearchPopupMenuQt.cpp
index 187a5de..a05d08a 100644
--- a/WebCore/platform/qt/SearchPopupMenuQt.cpp
+++ b/WebCore/platform/qt/SearchPopupMenuQt.cpp
@@ -1,5 +1,6 @@
/*
* Copyright C 2006 Zack Rusin <zack@kde.org>
+ * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
@@ -18,26 +19,29 @@
*/
#include "config.h"
-#include "SearchPopupMenu.h"
-
-#include "AtomicString.h"
+#include "SearchPopupMenuQt.h"
namespace WebCore {
-SearchPopupMenu::SearchPopupMenu(PopupMenuClient* client)
- : PopupMenu(client)
+SearchPopupMenuQt::SearchPopupMenuQt(PopupMenuClient* client)
+ : m_popup(adoptRef(new PopupMenuQt(client)))
+{
+}
+
+PopupMenu* SearchPopupMenuQt::popupMenu()
{
+ return m_popup.get();
}
-void SearchPopupMenu::saveRecentSearches(const AtomicString&, const Vector<String>&)
+void SearchPopupMenuQt::saveRecentSearches(const AtomicString&, const Vector<String>&)
{
}
-void SearchPopupMenu::loadRecentSearches(const AtomicString&, Vector<String>&)
+void SearchPopupMenuQt::loadRecentSearches(const AtomicString&, Vector<String>&)
{
}
-bool SearchPopupMenu::enabled()
+bool SearchPopupMenuQt::enabled()
{
return true;
}
diff --git a/WebCore/platform/qt/SearchPopupMenuQt.h b/WebCore/platform/qt/SearchPopupMenuQt.h
new file mode 100644
index 0000000..0fbeafd
--- /dev/null
+++ b/WebCore/platform/qt/SearchPopupMenuQt.h
@@ -0,0 +1,44 @@
+/*
+ * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see the file COPYING.LIB. If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ *
+ */
+
+#ifndef SearchPopupMenuQt_h
+#define SearchPopupMenuQt_h
+
+#include "PopupMenuQt.h"
+#include "SearchPopupMenu.h"
+
+namespace WebCore {
+
+class SearchPopupMenuQt : public SearchPopupMenu {
+public:
+ SearchPopupMenuQt(PopupMenuClient*);
+
+ virtual PopupMenu* popupMenu();
+ virtual void saveRecentSearches(const AtomicString& name, const Vector<String>& searchItems);
+ virtual void loadRecentSearches(const AtomicString& name, Vector<String>& searchItems);
+ virtual bool enabled();
+
+private:
+ RefPtr<PopupMenuQt> m_popup;
+};
+
+}
+
+#endif // SearchPopupMenuQt_h
diff --git a/WebCore/platform/sql/SQLiteDatabase.cpp b/WebCore/platform/sql/SQLiteDatabase.cpp
index 75fc032..05a2a22 100644
--- a/WebCore/platform/sql/SQLiteDatabase.cpp
+++ b/WebCore/platform/sql/SQLiteDatabase.cpp
@@ -31,8 +31,8 @@
#include "Logging.h"
#include "SQLiteFileSystem.h"
#include "SQLiteStatement.h"
-
#include <sqlite3.h>
+#include <wtf/Threading.h>
namespace WebCore {
@@ -42,7 +42,7 @@ const int SQLResultOk = SQLITE_OK;
const int SQLResultRow = SQLITE_ROW;
const int SQLResultSchema = SQLITE_SCHEMA;
const int SQLResultFull = SQLITE_FULL;
-
+const int SQLResultInterrupt = SQLITE_INTERRUPT;
SQLiteDatabase::SQLiteDatabase()
: m_db(0)
@@ -50,6 +50,7 @@ SQLiteDatabase::SQLiteDatabase()
, m_transactionInProgress(false)
, m_sharable(false)
, m_openingThread(0)
+ , m_interrupted(false)
{
}
@@ -85,13 +86,37 @@ void SQLiteDatabase::close()
if (m_db) {
// FIXME: This is being called on themain thread during JS GC. <rdar://problem/5739818>
// ASSERT(currentThread() == m_openingThread);
- sqlite3_close(m_db);
- m_db = 0;
+ sqlite3* db = m_db;
+ {
+ MutexLocker locker(m_databaseClosingMutex);
+ m_db = 0;
+ }
+ sqlite3_close(db);
}
m_openingThread = 0;
}
+void SQLiteDatabase::interrupt()
+{
+ m_interrupted = true;
+ while (!m_lockingMutex.tryLock()) {
+ MutexLocker locker(m_databaseClosingMutex);
+ if (!m_db)
+ return;
+ sqlite3_interrupt(m_db);
+ yield();
+ }
+
+ m_lockingMutex.unlock();
+}
+
+bool SQLiteDatabase::isInterrupted()
+{
+ ASSERT(!m_lockingMutex.tryLock());
+ return m_interrupted;
+}
+
void SQLiteDatabase::setFullsync(bool fsync)
{
if (fsync)
@@ -397,16 +422,6 @@ void SQLiteDatabase::enableAuthorizer(bool enable)
sqlite3_set_authorizer(m_db, NULL, 0);
}
-void SQLiteDatabase::lock()
-{
- m_lockingMutex.lock();
-}
-
-void SQLiteDatabase::unlock()
-{
- m_lockingMutex.unlock();
-}
-
bool SQLiteDatabase::isAutoCommitOn() const
{
return sqlite3_get_autocommit(m_db);
diff --git a/WebCore/platform/sql/SQLiteDatabase.h b/WebCore/platform/sql/SQLiteDatabase.h
index c5924c0..8151380 100644
--- a/WebCore/platform/sql/SQLiteDatabase.h
+++ b/WebCore/platform/sql/SQLiteDatabase.h
@@ -48,6 +48,7 @@ extern const int SQLResultOk;
extern const int SQLResultRow;
extern const int SQLResultSchema;
extern const int SQLResultFull;
+extern const int SQLResultInterrupt;
class SQLiteDatabase : public Noncopyable {
friend class SQLiteTransaction;
@@ -58,6 +59,8 @@ public:
bool open(const String& filename, bool forWebSQLDatabase = false);
bool isOpen() const { return m_db; }
void close();
+ void interrupt();
+ bool isInterrupted();
bool executeCommand(const String&);
bool returnsAtLeastOneResult(const String&);
@@ -105,9 +108,7 @@ public:
void setAuthorizer(PassRefPtr<DatabaseAuthorizer>);
- // (un)locks the database like a mutex
- void lock();
- void unlock();
+ Mutex& databaseMutex() { return m_lockingMutex; }
bool isAutoCommitOn() const;
// The SQLite AUTO_VACUUM pragma can be either NONE, FULL, or INCREMENTAL.
@@ -149,7 +150,9 @@ private:
Mutex m_lockingMutex;
ThreadIdentifier m_openingThread;
-
+
+ Mutex m_databaseClosingMutex;
+ bool m_interrupted;
}; // class SQLiteDatabase
} // namespace WebCore
diff --git a/WebCore/platform/sql/SQLiteStatement.cpp b/WebCore/platform/sql/SQLiteStatement.cpp
index 78bbfeb..ac467a6 100644
--- a/WebCore/platform/sql/SQLiteStatement.cpp
+++ b/WebCore/platform/sql/SQLiteStatement.cpp
@@ -61,6 +61,11 @@ SQLiteStatement::~SQLiteStatement()
int SQLiteStatement::prepare()
{
ASSERT(!m_isPrepared);
+
+ MutexLocker databaseLock(m_database.databaseMutex());
+ if (m_database.isInterrupted())
+ return SQLITE_INTERRUPT;
+
const void* tail = 0;
LOG(SQLDatabase, "SQL - prepare - %s", m_query.ascii().data());
String strippedQuery = m_query.stripWhiteSpace();
@@ -88,6 +93,11 @@ int SQLiteStatement::prepare()
int SQLiteStatement::step()
{
ASSERT(m_isPrepared);
+
+ MutexLocker databaseLock(m_database.databaseMutex());
+ if (m_database.isInterrupted())
+ return SQLITE_INTERRUPT;
+
if (!m_statement)
return SQLITE_OK;
LOG(SQLDatabase, "SQL - step - %s", m_query.ascii().data());
diff --git a/WebCore/platform/win/PopupMenuWin.cpp b/WebCore/platform/win/PopupMenuWin.cpp
index 4bc6dc7..aaadc53 100644
--- a/WebCore/platform/win/PopupMenuWin.cpp
+++ b/WebCore/platform/win/PopupMenuWin.cpp
@@ -1,6 +1,7 @@
/*
* Copyright (C) 2006, 2007, 2008 Apple Inc. All rights reserved.
* Copyright (C) 2007-2009 Torch Mobile Inc.
+ * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
@@ -20,7 +21,7 @@
*/
#include "config.h"
-#include "PopupMenu.h"
+#include "PopupMenuWin.h"
#include "BitmapInfo.h"
#include "Document.h"
@@ -86,7 +87,7 @@ static void translatePoint(LPARAM& lParam, HWND from, HWND to)
lParam = MAKELPARAM(pt.x, pt.y);
}
-PopupMenu::PopupMenu(PopupMenuClient* client)
+PopupMenuWin::PopupMenuWin(PopupMenuClient* client)
: m_popupClient(client)
, m_scrollbar(0)
, m_popup(0)
@@ -102,7 +103,7 @@ PopupMenu::PopupMenu(PopupMenuClient* client)
{
}
-PopupMenu::~PopupMenu()
+PopupMenuWin::~PopupMenuWin()
{
if (m_bmp)
::DeleteObject(m_bmp);
@@ -114,12 +115,17 @@ PopupMenu::~PopupMenu()
m_scrollbar->setParent(0);
}
-LPCTSTR PopupMenu::popupClassName()
+void PopupMenuWin::disconnectClient()
+{
+ m_popupClient = 0;
+}
+
+LPCTSTR PopupMenuWin::popupClassName()
{
return kPopupWindowClassName;
}
-void PopupMenu::show(const IntRect& r, FrameView* view, int index)
+void PopupMenuWin::show(const IntRect& r, FrameView* view, int index)
{
calculatePositionAndSize(r, view);
if (clientRect().isEmpty())
@@ -267,7 +273,7 @@ void PopupMenu::show(const IntRect& r, FrameView* view, int index)
hide();
}
-void PopupMenu::hide()
+void PopupMenuWin::hide()
{
if (!m_showPopup)
return;
@@ -283,7 +289,7 @@ void PopupMenu::hide()
::PostMessage(m_popup, WM_NULL, 0, 0);
}
-void PopupMenu::calculatePositionAndSize(const IntRect& r, FrameView* v)
+void PopupMenuWin::calculatePositionAndSize(const IntRect& r, FrameView* v)
{
// r is in absolute document coordinates, but we want to be in screen coordinates
@@ -373,7 +379,7 @@ void PopupMenu::calculatePositionAndSize(const IntRect& r, FrameView* v)
return;
}
-bool PopupMenu::setFocusedIndex(int i, bool hotTracking)
+bool PopupMenuWin::setFocusedIndex(int i, bool hotTracking)
{
if (i < 0 || i >= client()->listSize() || i == focusedIndex())
return false;
@@ -395,22 +401,22 @@ bool PopupMenu::setFocusedIndex(int i, bool hotTracking)
return true;
}
-int PopupMenu::visibleItems() const
+int PopupMenuWin::visibleItems() const
{
return clientRect().height() / m_itemHeight;
}
-int PopupMenu::listIndexAtPoint(const IntPoint& point) const
+int PopupMenuWin::listIndexAtPoint(const IntPoint& point) const
{
return m_scrollOffset + point.y() / m_itemHeight;
}
-int PopupMenu::focusedIndex() const
+int PopupMenuWin::focusedIndex() const
{
return m_focusedIndex;
}
-void PopupMenu::focusFirst()
+void PopupMenuWin::focusFirst()
{
if (!client())
return;
@@ -424,7 +430,7 @@ void PopupMenu::focusFirst()
}
}
-void PopupMenu::focusLast()
+void PopupMenuWin::focusLast()
{
if (!client())
return;
@@ -438,7 +444,7 @@ void PopupMenu::focusLast()
}
}
-bool PopupMenu::down(unsigned lines)
+bool PopupMenuWin::down(unsigned lines)
{
if (!client())
return false;
@@ -457,7 +463,7 @@ bool PopupMenu::down(unsigned lines)
return setFocusedIndex(lastSelectableIndex);
}
-bool PopupMenu::up(unsigned lines)
+bool PopupMenuWin::up(unsigned lines)
{
if (!client())
return false;
@@ -476,7 +482,7 @@ bool PopupMenu::up(unsigned lines)
return setFocusedIndex(lastSelectableIndex);
}
-void PopupMenu::invalidateItem(int index)
+void PopupMenuWin::invalidateItem(int index)
{
if (!m_popup)
return;
@@ -491,7 +497,7 @@ void PopupMenu::invalidateItem(int index)
::InvalidateRect(m_popup, &r, TRUE);
}
-IntRect PopupMenu::clientRect() const
+IntRect PopupMenuWin::clientRect() const
{
IntRect clientRect = m_windowRect;
clientRect.inflate(-popupWindowBorderWidth);
@@ -499,12 +505,12 @@ IntRect PopupMenu::clientRect() const
return clientRect;
}
-void PopupMenu::incrementWheelDelta(int delta)
+void PopupMenuWin::incrementWheelDelta(int delta)
{
m_wheelDelta += delta;
}
-void PopupMenu::reduceWheelDelta(int delta)
+void PopupMenuWin::reduceWheelDelta(int delta)
{
ASSERT(delta >= 0);
ASSERT(delta <= abs(m_wheelDelta));
@@ -517,7 +523,7 @@ void PopupMenu::reduceWheelDelta(int delta)
return;
}
-bool PopupMenu::scrollToRevealSelection()
+bool PopupMenuWin::scrollToRevealSelection()
{
if (!m_scrollbar)
return false;
@@ -537,7 +543,7 @@ bool PopupMenu::scrollToRevealSelection()
return false;
}
-void PopupMenu::updateFromElement()
+void PopupMenuWin::updateFromElement()
{
if (!m_popup)
return;
@@ -549,14 +555,9 @@ void PopupMenu::updateFromElement()
::UpdateWindow(m_popup);
}
-bool PopupMenu::itemWritingDirectionIsNatural()
-{
- return true;
-}
-
const int separatorPadding = 4;
const int separatorHeight = 1;
-void PopupMenu::paint(const IntRect& damageRect, HDC hdc)
+void PopupMenuWin::paint(const IntRect& damageRect, HDC hdc)
{
if (!m_popup)
return;
@@ -663,7 +664,7 @@ void PopupMenu::paint(const IntRect& damageRect, HDC hdc)
::ReleaseDC(m_popup, localDC);
}
-void PopupMenu::valueChanged(Scrollbar* scrollBar)
+void PopupMenuWin::valueChanged(Scrollbar* scrollBar)
{
ASSERT(m_scrollbar);
@@ -699,7 +700,7 @@ void PopupMenu::valueChanged(Scrollbar* scrollBar)
::UpdateWindow(m_popup);
}
-void PopupMenu::invalidateScrollbarRect(Scrollbar* scrollbar, const IntRect& rect)
+void PopupMenuWin::invalidateScrollbarRect(Scrollbar* scrollbar, const IntRect& rect)
{
IntRect scrollRect = rect;
scrollRect.move(scrollbar->x(), scrollbar->y());
@@ -707,7 +708,7 @@ void PopupMenu::invalidateScrollbarRect(Scrollbar* scrollbar, const IntRect& rec
::InvalidateRect(m_popup, &r, false);
}
-void PopupMenu::registerClass()
+void PopupMenuWin::registerClass()
{
static bool haveRegisteredWindowClass = false;
@@ -743,7 +744,7 @@ void PopupMenu::registerClass()
}
-LRESULT CALLBACK PopupMenu::PopupMenuWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
+LRESULT CALLBACK PopupMenuWin::PopupMenuWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
#if OS(WINCE)
LONG longPtr = GetWindowLong(hWnd, 0);
@@ -751,7 +752,7 @@ LRESULT CALLBACK PopupMenu::PopupMenuWndProc(HWND hWnd, UINT message, WPARAM wPa
LONG_PTR longPtr = GetWindowLongPtr(hWnd, 0);
#endif
- if (PopupMenu* popup = reinterpret_cast<PopupMenu*>(longPtr))
+ if (PopupMenuWin* popup = reinterpret_cast<PopupMenuWin*>(longPtr))
return popup->wndProc(hWnd, message, wParam, lParam);
if (message == WM_CREATE) {
@@ -771,7 +772,7 @@ LRESULT CALLBACK PopupMenu::PopupMenuWndProc(HWND hWnd, UINT message, WPARAM wPa
const int smoothScrollAnimationDuration = 5000;
-LRESULT PopupMenu::wndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
+LRESULT PopupMenuWin::wndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
LRESULT lResult = 0;
diff --git a/WebCore/platform/win/PopupMenuWin.h b/WebCore/platform/win/PopupMenuWin.h
new file mode 100644
index 0000000..d4a4255
--- /dev/null
+++ b/WebCore/platform/win/PopupMenuWin.h
@@ -0,0 +1,123 @@
+/*
+ * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see the file COPYING.LIB. If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#ifndef PopupMenuWin_h
+#define PopupMenuWin_h
+
+#include "IntRect.h"
+#include "PopupMenu.h"
+#include "PopupMenuClient.h"
+#include "Scrollbar.h"
+#include "ScrollbarClient.h"
+#include <wtf/PassRefPtr.h>
+#include <wtf/RefCounted.h>
+#include <wtf/RefPtr.h>
+
+typedef struct HWND__* HWND;
+typedef struct HDC__* HDC;
+typedef struct HBITMAP__* HBITMAP;
+
+namespace WebCore {
+
+class FrameView;
+class Scrollbar;
+
+class PopupMenuWin : public PopupMenu, private ScrollbarClient {
+public:
+ PopupMenuWin(PopupMenuClient*);
+ ~PopupMenuWin();
+
+ virtual void show(const IntRect&, FrameView*, int index);
+ virtual void hide();
+ virtual void updateFromElement();
+ virtual void disconnectClient();
+
+ static LPCTSTR popupClassName();
+
+private:
+ PopupMenuClient* client() const { return m_popupClient; }
+
+ Scrollbar* scrollbar() const { return m_scrollbar.get(); }
+
+ bool up(unsigned lines = 1);
+ bool down(unsigned lines = 1);
+
+ int itemHeight() const { return m_itemHeight; }
+ const IntRect& windowRect() const { return m_windowRect; }
+ IntRect clientRect() const;
+
+ int visibleItems() const;
+
+ int listIndexAtPoint(const IntPoint&) const;
+
+ bool setFocusedIndex(int index, bool hotTracking = false);
+ int focusedIndex() const;
+ void focusFirst();
+ void focusLast();
+
+ void paint(const IntRect& damageRect, HDC = 0);
+
+ HWND popupHandle() const { return m_popup; }
+
+ void setWasClicked(bool b = true) { m_wasClicked = b; }
+ bool wasClicked() const { return m_wasClicked; }
+
+ void setScrollOffset(int offset) { m_scrollOffset = offset; }
+ int scrollOffset() const { return m_scrollOffset; }
+
+ bool scrollToRevealSelection();
+
+ void incrementWheelDelta(int delta);
+ void reduceWheelDelta(int delta);
+ int wheelDelta() const { return m_wheelDelta; }
+
+ bool scrollbarCapturingMouse() const { return m_scrollbarCapturingMouse; }
+ void setScrollbarCapturingMouse(bool b) { m_scrollbarCapturingMouse = b; }
+
+ // ScrollBarClient
+ virtual void valueChanged(Scrollbar*);
+ virtual void invalidateScrollbarRect(Scrollbar*, const IntRect&);
+ virtual bool isActive() const { return true; }
+ virtual bool scrollbarCornerPresent() const { return false; }
+
+ void calculatePositionAndSize(const IntRect&, FrameView*);
+ void invalidateItem(int index);
+
+ static LRESULT CALLBACK PopupMenuWndProc(HWND, UINT, WPARAM, LPARAM);
+ LRESULT wndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam);
+ static void registerClass();
+
+ PopupMenuClient* m_popupClient;
+ RefPtr<Scrollbar> m_scrollbar;
+ HWND m_popup;
+ HDC m_DC;
+ HBITMAP m_bmp;
+ bool m_wasClicked;
+ IntRect m_windowRect;
+ int m_itemHeight;
+ int m_scrollOffset;
+ int m_wheelDelta;
+ int m_focusedIndex;
+ bool m_scrollbarCapturingMouse;
+ bool m_showPopup;
+};
+
+}
+
+#endif // PopupMenuWin_h
diff --git a/WebCore/platform/win/SearchPopupMenuWin.cpp b/WebCore/platform/win/SearchPopupMenuWin.cpp
index f2709bb..e1bbe68 100644
--- a/WebCore/platform/win/SearchPopupMenuWin.cpp
+++ b/WebCore/platform/win/SearchPopupMenuWin.cpp
@@ -1,5 +1,6 @@
/*
* Copyright (C) 2006, 2007 Apple Inc.
+ * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
@@ -18,19 +19,24 @@
*/
#include "config.h"
-#include "SearchPopupMenu.h"
+#include "SearchPopupMenuWin.h"
#include "AtomicString.h"
#include <wtf/RetainPtr.h>
namespace WebCore {
-SearchPopupMenu::SearchPopupMenu(PopupMenuClient* client)
- : PopupMenu(client)
+SearchPopupMenuWin::SearchPopupMenuWin(PopupMenuClient* client)
+ : m_popup(adoptRef(new PopupMenuWin(client)))
{
}
-bool SearchPopupMenu::enabled()
+PopupMenu* SearchPopupMenuWin::popupMenu()
+{
+ return m_popup.get();
+}
+
+bool SearchPopupMenuWin::enabled()
{
return true;
}
@@ -41,7 +47,7 @@ static RetainPtr<CFStringRef> autosaveKey(const String& name)
return RetainPtr<CFStringRef>(AdoptCF, key.createCFString());
}
-void SearchPopupMenu::saveRecentSearches(const AtomicString& name, const Vector<String>& searchItems)
+void SearchPopupMenuWin::saveRecentSearches(const AtomicString& name, const Vector<String>& searchItems)
{
if (name.isEmpty())
return;
@@ -61,7 +67,7 @@ void SearchPopupMenu::saveRecentSearches(const AtomicString& name, const Vector<
CFPreferencesAppSynchronize(kCFPreferencesCurrentApplication);
}
-void SearchPopupMenu::loadRecentSearches(const AtomicString& name, Vector<String>& searchItems)
+void SearchPopupMenuWin::loadRecentSearches(const AtomicString& name, Vector<String>& searchItems)
{
if (name.isEmpty())
return;
diff --git a/WebCore/platform/win/SearchPopupMenuWin.h b/WebCore/platform/win/SearchPopupMenuWin.h
new file mode 100644
index 0000000..299a133
--- /dev/null
+++ b/WebCore/platform/win/SearchPopupMenuWin.h
@@ -0,0 +1,44 @@
+/*
+ * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see the file COPYING.LIB. If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ *
+ */
+
+#ifndef SearchPopupMenuWin_h
+#define SearchPopupMenuWin_h
+
+#include "PopupMenuWin.h"
+#include "SearchPopupMenu.h"
+
+namespace WebCore {
+
+class SearchPopupMenuWin : public SearchPopupMenu {
+public:
+ SearchPopupMenuWin(PopupMenuClient*);
+
+ virtual PopupMenu* popupMenu();
+ virtual void saveRecentSearches(const AtomicString& name, const Vector<String>& searchItems);
+ virtual void loadRecentSearches(const AtomicString& name, Vector<String>& searchItems);
+ virtual bool enabled();
+
+private:
+ RefPtr<PopupMenuWin> m_popup;
+};
+
+}
+
+#endif // SearchPopupMenuWin_h
diff --git a/WebCore/platform/wx/PopupMenuWx.cpp b/WebCore/platform/wx/PopupMenuWx.cpp
index 9b0deba..e88d1e5 100644
--- a/WebCore/platform/wx/PopupMenuWx.cpp
+++ b/WebCore/platform/wx/PopupMenuWx.cpp
@@ -2,6 +2,7 @@
* This file is part of the popup menu implementation for <select> elements in WebCore.
*
* Copyright (C) 2008 Apple Computer, Inc.
+ * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
@@ -21,7 +22,7 @@
*/
#include "config.h"
-#include "PopupMenu.h"
+#include "PopupMenuWx.h"
#include "Frame.h"
#include "FrameView.h"
@@ -41,18 +42,23 @@ static int s_menuStartId = wxNewId();
namespace WebCore {
-PopupMenu::PopupMenu(PopupMenuClient* client)
+PopupMenuWx::PopupMenuWx(PopupMenuClient* client)
: m_popupClient(client)
, m_menu(NULL)
{
}
-PopupMenu::~PopupMenu()
+PopupMenuWx::~PopupMenuWx()
{
delete m_menu;
}
-void PopupMenu::show(const IntRect& r, FrameView* v, int index)
+void PopupMenuWx::disconnectClient()
+{
+ m_popupClient = 0;
+}
+
+void PopupMenuWx::show(const IntRect& r, FrameView* v, int index)
{
// just delete and recreate
delete m_menu;
@@ -78,13 +84,13 @@ void PopupMenu::show(const IntRect& r, FrameView* v, int index)
m_menu->Append(s_menuStartId + i, client()->itemText(i));
}
}
- nativeWin->Connect(s_menuStartId, s_menuStartId + (size-1), wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler(PopupMenu::OnMenuItemSelected), NULL, this);
+ nativeWin->Connect(s_menuStartId, s_menuStartId + (size-1), wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler(PopupMenuWx::OnMenuItemSelected), 0, this);
nativeWin->PopupMenu(m_menu, r.x() - v->scrollX(), r.y() - v->scrollY());
- nativeWin->Disconnect(s_menuStartId, s_menuStartId + (size-1), wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler(PopupMenu::OnMenuItemSelected), NULL, this);
+ nativeWin->Disconnect(s_menuStartId, s_menuStartId + (size-1), wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler(PopupMenuWx::OnMenuItemSelected), 0, this);
}
}
-void PopupMenu::OnMenuItemSelected(wxCommandEvent& event)
+void PopupMenuWx::OnMenuItemSelected(wxCommandEvent& event)
{
if (client()) {
client()->valueChanged(event.GetId() - s_menuStartId);
@@ -93,20 +99,15 @@ void PopupMenu::OnMenuItemSelected(wxCommandEvent& event)
// TODO: Do we need to call Disconnect here? Do we have a ref to the native window still?
}
-void PopupMenu::hide()
+void PopupMenuWx::hide()
{
// we don't need to do anything here, the native control only exists during the time
// show is called
}
-void PopupMenu::updateFromElement()
+void PopupMenuWx::updateFromElement()
{
client()->setTextFromItem(m_popupClient->selectedIndex());
}
-bool PopupMenu::itemWritingDirectionIsNatural()
-{
- return false;
-}
-
}
diff --git a/WebCore/platform/wx/PopupMenuWx.h b/WebCore/platform/wx/PopupMenuWx.h
new file mode 100644
index 0000000..c2573fc
--- /dev/null
+++ b/WebCore/platform/wx/PopupMenuWx.h
@@ -0,0 +1,62 @@
+/*
+ * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see the file COPYING.LIB. If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ *
+ */
+
+#ifndef PopupMenuWx_h
+#define PopupMenuWx_h
+
+#include "IntRect.h"
+#include "PopupMenu.h"
+#include "PopupMenuClient.h"
+#include <wtf/PassRefPtr.h>
+#include <wtf/RefCounted.h>
+
+#ifdef __WXMSW__
+#include <wx/msw/winundef.h>
+#endif
+class wxMenu;
+#include <wx/defs.h>
+#include <wx/event.h>
+
+namespace WebCore {
+
+class FrameView;
+class Scrollbar;
+
+class PopupMenuWx : public PopupMenu, public wxEvtHandler {
+public:
+ PopupMenuWx(PopupMenuClient*);
+ ~PopupMenuWx();
+
+ virtual void show(const IntRect&, FrameView*, int index);
+ virtual void hide();
+ virtual void updateFromElement();
+ virtual void disconnectClient();
+
+private:
+ void OnMenuItemSelected(wxCommandEvent&);
+ PopupMenuClient* client() const { return m_popupClient; }
+
+ PopupMenuClient* m_popupClient;
+ wxMenu* m_menu;
+};
+
+}
+
+#endif // PopupMenuWx_h
diff --git a/WebCore/platform/wx/SearchPopupMenuWx.cpp b/WebCore/platform/wx/SearchPopupMenuWx.cpp
index dbbe339..b724cf1 100644
--- a/WebCore/platform/wx/SearchPopupMenuWx.cpp
+++ b/WebCore/platform/wx/SearchPopupMenuWx.cpp
@@ -1,5 +1,6 @@
/*
* Copyright (C) 2009 Apple Inc. All Rights Reserved.
+ * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -24,32 +25,37 @@
*/
#include "config.h"
-#include "SearchPopupMenu.h"
+#include "SearchPopupMenuWx.h"
#include "NotImplemented.h"
namespace WebCore {
-SearchPopupMenu::SearchPopupMenu(PopupMenuClient* client)
- : PopupMenu(client)
+SearchPopupMenuWx::SearchPopupMenuWx(PopupMenuClient* client)
+ : m_popup(adoptRef(new PopupMenuWx(client)))
{
notImplemented();
}
-void SearchPopupMenu::saveRecentSearches(const AtomicString& name, const Vector<String>& searchItems)
+void SearchPopupMenuWx::saveRecentSearches(const AtomicString& name, const Vector<String>& searchItems)
{
notImplemented();
}
-void SearchPopupMenu::loadRecentSearches(const AtomicString& name, Vector<String>& searchItems)
+void SearchPopupMenuWx::loadRecentSearches(const AtomicString& name, Vector<String>& searchItems)
{
notImplemented();
}
-bool SearchPopupMenu::enabled()
+bool SearchPopupMenuWx::enabled()
{
return true;
}
+PopupMenu* SearchPopupMenuWx::popupMenu()
+{
+ return m_popup.get();
+}
+
}
diff --git a/WebCore/platform/wx/SearchPopupMenuWx.h b/WebCore/platform/wx/SearchPopupMenuWx.h
new file mode 100644
index 0000000..552a8fe
--- /dev/null
+++ b/WebCore/platform/wx/SearchPopupMenuWx.h
@@ -0,0 +1,44 @@
+/*
+ * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see the file COPYING.LIB. If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ *
+ */
+
+#ifndef SearchPopupMenuWx_h
+#define SearchPopupMenuWx_h
+
+#include "PopupMenuWx.h"
+#include "SearchPopupMenu.h"
+
+namespace WebCore {
+
+class SearchPopupMenuWx : public SearchPopupMenu {
+public:
+ SearchPopupMenuWx(PopupMenuClient*);
+
+ virtual PopupMenu* popupMenu();
+ virtual void saveRecentSearches(const AtomicString& name, const Vector<String>& searchItems);
+ virtual void loadRecentSearches(const AtomicString& name, Vector<String>& searchItems);
+ virtual bool enabled();
+
+private:
+ RefPtr<PopupMenuWx> m_popup;
+};
+
+}
+
+#endif // SearchPopupMenuWx_h