[SCM] WebKit Debian packaging branch, webkit-1.2, updated. upstream/1.1.90-6072-g9a69373
eric at webkit.org
eric at webkit.org
Thu Apr 8 02:03:00 UTC 2010
The following commit has been merged in the webkit-1.2 branch:
commit 74caff85e9f9487833268edc7c85f0dad1503114
Author: eric at webkit.org <eric at webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date: Sat Feb 27 06:06:02 2010 +0000
2010-02-26 Leandro Pereira <leandro at profusion.mobi>
Reviewed by NOBODY.
Add EFL port files to platform/efl.
http://webkit.org/b/35087
* platform/efl/ScrollbarEfl.cpp: Added.
* platform/efl/EventLoopEfl.cpp: Added.
* platform/efl/PlatformKeyboardEventEfl.cpp: Added.
* platform/efl/DragImageEfl.cpp: Added.
* platform/efl/PlatformMouseEventEfl.cpp: Added.
git-svn-id: http://svn.webkit.org/repository/webkit/trunk@55345 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/WebCore/ChangeLog b/WebCore/ChangeLog
index b06a43d..afc1ff0 100644
--- a/WebCore/ChangeLog
+++ b/WebCore/ChangeLog
@@ -5,6 +5,19 @@
Add EFL port files to platform/efl.
http://webkit.org/b/35087
+ * platform/efl/ScrollbarEfl.cpp: Added.
+ * platform/efl/EventLoopEfl.cpp: Added.
+ * platform/efl/PlatformKeyboardEventEfl.cpp: Added.
+ * platform/efl/DragImageEfl.cpp: Added.
+ * platform/efl/PlatformMouseEventEfl.cpp: Added.
+
+2010-02-26 Leandro Pereira <leandro at profusion.mobi>
+
+ Reviewed by NOBODY.
+
+ Add EFL port files to platform/efl.
+ http://webkit.org/b/35087
+
* platform/efl/CursorEfl.cpp: Added.
* platform/efl/LocalizedStringsEfl.cpp: Added.
* platform/efl/SearchPopupMenuEfl.cpp: Added.
diff --git a/WebCore/platform/efl/DragImageEfl.cpp b/WebCore/platform/efl/DragImageEfl.cpp
new file mode 100644
index 0000000..4b0f417
--- /dev/null
+++ b/WebCore/platform/efl/DragImageEfl.cpp
@@ -0,0 +1,65 @@
+/*
+ * Copyright (C) 2008 INdT - Instituto Nokia de Tecnologia
+ * Copyright (C) 2009-2010 ProFUSION embedded systems
+ * Copyright (C) 2009-2010 Samsung Electronics
+ *
+ * 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 "DragImage.h"
+
+#include "CachedImage.h"
+#include "Image.h"
+#include "NotImplemented.h"
+
+namespace WebCore {
+
+IntSize dragImageSize(DragImageRef)
+{
+ notImplemented();
+ return IntSize(0, 0);
+}
+
+void deleteDragImage(DragImageRef)
+{
+ notImplemented();
+}
+
+DragImageRef scaleDragImage(DragImageRef image, FloatSize)
+{
+ notImplemented();
+ return image;
+}
+
+DragImageRef dissolveDragImageToFraction(DragImageRef image, float)
+{
+ notImplemented();
+ return image;
+}
+
+DragImageRef createDragImageFromImage(Image*)
+{
+ notImplemented();
+ return 0;
+}
+
+DragImageRef createDragImageIconForCachedImage(CachedImage*)
+{
+ notImplemented();
+ return 0;
+}
+
+}
diff --git a/WebCore/platform/efl/EventLoopEfl.cpp b/WebCore/platform/efl/EventLoopEfl.cpp
new file mode 100644
index 0000000..533ffe9
--- /dev/null
+++ b/WebCore/platform/efl/EventLoopEfl.cpp
@@ -0,0 +1,35 @@
+/*
+ * Copyright (C) 2008 Nuanti Ltd.
+ * Copyright (C) 2008 INdT - Instituto Nokia de Tecnologia
+ * Copyright (C) 2009-2010 ProFUSION embedded systems
+ * Copyright (C) 2009-2010 Samsung Electronics
+ *
+ * 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.
+ */
+
+#include "config.h"
+#include "EventLoop.h"
+
+#include <Ecore.h>
+
+namespace WebCore {
+
+void EventLoop::cycle()
+{
+ ecore_main_loop_iterate();
+}
+
+} // namespace WebCore
diff --git a/WebCore/platform/efl/PlatformKeyboardEventEfl.cpp b/WebCore/platform/efl/PlatformKeyboardEventEfl.cpp
new file mode 100644
index 0000000..2cfe8e9
--- /dev/null
+++ b/WebCore/platform/efl/PlatformKeyboardEventEfl.cpp
@@ -0,0 +1,244 @@
+/*
+ * Copyright (C) 2006 Nikolas Zimmermann <zimmermann at kde.org>
+ * Copyright (C) 2008 Diego Hidalgo C. Gonzalez
+ * Copyright (C) 2009-2010 ProFUSION embedded systems
+ * Copyright (C) 2009-2010 Samsung Electronics
+ *
+ * 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 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 "PlatformKeyboardEvent.h"
+
+#include "CString.h"
+#include "KeyboardCodes.h"
+#include "NotImplemented.h"
+#include "StringHash.h"
+#include "TextEncoding.h"
+
+#include <stdio.h>
+#include <wtf/HashMap.h>
+
+namespace WebCore {
+
+typedef HashMap<String, String> KeyMap;
+typedef HashMap<String, int> WindowsKeyMap;
+
+static KeyMap gKeyMap;
+static WindowsKeyMap gWindowsKeyMap;
+
+static void createKeyMap()
+{
+ for (unsigned int i = 1; i < 25; i++) {
+ String key = String::format("F%d", i);
+ gKeyMap.set(key, key);
+ }
+ gKeyMap.set("Alt_L", "Alt");
+ gKeyMap.set("ISO_Level3_Shift", "Alt");
+ gKeyMap.set("Menu", "Alt");
+ gKeyMap.set("Shift_L", "Shift");
+ gKeyMap.set("Shift_R", "Shift");
+ gKeyMap.set("Down", "Down");
+ gKeyMap.set("End", "End");
+ gKeyMap.set("Return", "Enter");
+ gKeyMap.set("KP_Enter", "Enter");
+ gKeyMap.set("Home", "Home");
+ gKeyMap.set("Insert", "Insert");
+ gKeyMap.set("Left", "Left");
+ gKeyMap.set("Down", "Down");
+ gKeyMap.set("Next", "PageDown");
+ gKeyMap.set("Prior", "PageUp");
+ gKeyMap.set("Right", "Right");
+ gKeyMap.set("Up", "Up");
+ gKeyMap.set("Delete", "U+007F");
+ gKeyMap.set("Tab", "U+0009");
+ gKeyMap.set("ISO_Left_Tab", "U+0009");
+}
+
+static void createWindowsKeyMap()
+{
+ gWindowsKeyMap.set("Return", VK_RETURN);
+ gWindowsKeyMap.set("KP_Return", VK_RETURN);
+ gWindowsKeyMap.set("Alt_L", VK_MENU);
+ gWindowsKeyMap.set("ISO_Level3_Shift", VK_MENU);
+ gWindowsKeyMap.set("Menu", VK_MENU);
+ gWindowsKeyMap.set("Shift_L", VK_SHIFT);
+ gWindowsKeyMap.set("Shift_R", VK_SHIFT);
+ gWindowsKeyMap.set("Control_L", VK_CONTROL);
+ gWindowsKeyMap.set("Control_R", VK_CONTROL);
+ gWindowsKeyMap.set("Pause", VK_PAUSE);
+ gWindowsKeyMap.set("Break", VK_PAUSE);
+ gWindowsKeyMap.set("Caps_Lock", VK_CAPITAL);
+ gWindowsKeyMap.set("Scroll_Lock", VK_SCROLL);
+ gWindowsKeyMap.set("Num_Lock", VK_NUMLOCK);
+ gWindowsKeyMap.set("Escape", VK_ESCAPE);
+ gWindowsKeyMap.set("Tab", VK_TAB);
+ gWindowsKeyMap.set("ISO_Left_Tab", VK_TAB);
+ gWindowsKeyMap.set("BackSpace", VK_BACK);
+ gWindowsKeyMap.set("Space", VK_SPACE);
+ gWindowsKeyMap.set("Next", VK_NEXT);
+ gWindowsKeyMap.set("Prior", VK_PRIOR);
+ gWindowsKeyMap.set("Home", VK_HOME);
+ gWindowsKeyMap.set("End", VK_END);
+ gWindowsKeyMap.set("Right", VK_RIGHT);
+ gWindowsKeyMap.set("Left", VK_LEFT);
+ gWindowsKeyMap.set("Up", VK_UP);
+ gWindowsKeyMap.set("Down", VK_DOWN);
+ gWindowsKeyMap.set("Print", VK_PRINT);
+ gWindowsKeyMap.set("Insert", VK_INSERT);
+ gWindowsKeyMap.set("Delete", VK_DELETE);
+
+ gWindowsKeyMap.set("comma", VK_OEM_COMMA);
+ gWindowsKeyMap.set("less", VK_OEM_COMMA);
+ gWindowsKeyMap.set("period", VK_OEM_PERIOD);
+ gWindowsKeyMap.set("greater", VK_OEM_PERIOD);
+ gWindowsKeyMap.set("semicolon", VK_OEM_1);
+ gWindowsKeyMap.set("colon", VK_OEM_1);
+ gWindowsKeyMap.set("slash", VK_OEM_2);
+ gWindowsKeyMap.set("question", VK_OEM_2);
+ gWindowsKeyMap.set("grave", VK_OEM_3);
+ gWindowsKeyMap.set("asciitilde", VK_OEM_3);
+ gWindowsKeyMap.set("bracketleft", VK_OEM_4);
+ gWindowsKeyMap.set("braceleft", VK_OEM_4);
+ gWindowsKeyMap.set("backslash", VK_OEM_5);
+ gWindowsKeyMap.set("bar", VK_OEM_5);
+ gWindowsKeyMap.set("bracketright", VK_OEM_6);
+ gWindowsKeyMap.set("braceright", VK_OEM_6);
+ gWindowsKeyMap.set("apostrophe", VK_OEM_7);
+ gWindowsKeyMap.set("quotedbl", VK_OEM_7);
+
+ // Alphabet
+ String alphabet = "abcdefghijklmnopqrstuvwxyz";
+ for (unsigned int i = 0; i < 26; i++) {
+ String key = String::format("%c", alphabet[i]);
+ gWindowsKeyMap.set(key, VK_A + i);
+ }
+
+ // Digits
+ for (unsigned int i = 0; i < 10; i++) {
+ String key = String::format("%d", i);
+ gWindowsKeyMap.set(key, VK_0 + i);
+ }
+
+ // Shifted digits
+ gWindowsKeyMap.set("exclam", VK_1);
+ gWindowsKeyMap.set("at", VK_2);
+ gWindowsKeyMap.set("numbersign", VK_3);
+ gWindowsKeyMap.set("dollar", VK_4);
+ gWindowsKeyMap.set("percent", VK_5);
+ gWindowsKeyMap.set("asciicircum", VK_6);
+ gWindowsKeyMap.set("ampersand", VK_7);
+ gWindowsKeyMap.set("asterisk", VK_8);
+ gWindowsKeyMap.set("parenleft", VK_9);
+ gWindowsKeyMap.set("parenright", VK_0);
+ gWindowsKeyMap.set("minus", VK_OEM_MINUS);
+ gWindowsKeyMap.set("underscore", VK_OEM_MINUS);
+ gWindowsKeyMap.set("equal", VK_OEM_PLUS);
+ gWindowsKeyMap.set("plus", VK_OEM_PLUS);
+
+ // F_XX
+ for (unsigned int i = 1; i < 25; i++) {
+ String key = String::format("F%d", i);
+ gWindowsKeyMap.set(key, VK_F1 + i);
+ }
+}
+
+static String keyIdentifierForEvasKeyName(String& keyName)
+{
+ if (gKeyMap.isEmpty())
+ createKeyMap();
+
+ if (gKeyMap.contains(keyName))
+ return gKeyMap.get(keyName);
+
+ return keyName;
+}
+
+static int windowsKeyCodeForEvasKeyName(String& keyName)
+{
+ if (gWindowsKeyMap.isEmpty())
+ createWindowsKeyMap();
+
+ if (gWindowsKeyMap.contains(keyName))
+ return gWindowsKeyMap.get(keyName);
+
+ return 0;
+}
+
+PlatformKeyboardEvent::PlatformKeyboardEvent(const Evas_Event_Key_Down* ev)
+ : m_type(KeyDown)
+ , m_metaKey(evas_key_modifier_is_set(ev->modifiers, "Meta"))
+ , m_shiftKey(evas_key_modifier_is_set(ev->modifiers, "Shift"))
+ , m_ctrlKey(evas_key_modifier_is_set(ev->modifiers, "Control"))
+ , m_altKey(evas_key_modifier_is_set(ev->modifiers, "Alt"))
+ , m_text(String::fromUTF8(ev->string))
+{
+ String keyName = String(ev->key);
+ m_keyIdentifier = keyIdentifierForEvasKeyName(keyName);
+ m_windowsVirtualKeyCode = windowsKeyCodeForEvasKeyName(keyName);
+
+ // FIXME:
+ m_isKeypad = false;
+ m_autoRepeat = false;
+}
+
+PlatformKeyboardEvent::PlatformKeyboardEvent(const Evas_Event_Key_Up* ev)
+ : m_type(KeyUp)
+ , m_metaKey(evas_key_modifier_is_set(ev->modifiers, "Meta"))
+ , m_shiftKey(evas_key_modifier_is_set(ev->modifiers, "Shift"))
+ , m_ctrlKey(evas_key_modifier_is_set(ev->modifiers, "Control"))
+ , m_altKey(evas_key_modifier_is_set(ev->modifiers, "Alt"))
+ , m_text(String::fromUTF8(ev->string))
+{
+ String keyName = String(ev->key);
+ m_keyIdentifier = keyIdentifierForEvasKeyName(keyName);
+ m_windowsVirtualKeyCode = windowsKeyCodeForEvasKeyName(keyName);
+
+ // FIXME:
+ m_isKeypad = false;
+ m_autoRepeat = false;
+}
+
+void PlatformKeyboardEvent::disambiguateKeyDownEvent(Type type, bool)
+{
+ ASSERT(m_type == KeyDown);
+ m_type = type;
+
+ if (type == RawKeyDown) {
+ m_text = String();
+ m_unmodifiedText = String();
+ } else {
+ m_keyIdentifier = String();
+ m_windowsVirtualKeyCode = 0;
+ }
+}
+
+bool PlatformKeyboardEvent::currentCapsLockState()
+{
+ notImplemented();
+ return false;
+}
+
+}
diff --git a/WebCore/platform/efl/PlatformMouseEventEfl.cpp b/WebCore/platform/efl/PlatformMouseEventEfl.cpp
new file mode 100644
index 0000000..194e15a
--- /dev/null
+++ b/WebCore/platform/efl/PlatformMouseEventEfl.cpp
@@ -0,0 +1,92 @@
+/*
+ * Copyright (C) 2006 Zack Rusin <zack at kde.org>
+ * Copyright (C) 2008, 2009 INdT - Instituto Nokia de Tecnologia
+ * Copyright (C) 2009-2010 ProFUSION embedded systems
+ * Copyright (C) 2009-2010 Samsung Electronics
+ *
+ * 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 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 "PlatformMouseEvent.h"
+
+#include <Evas.h>
+#include <wtf/CurrentTime.h>
+
+namespace WebCore {
+
+void PlatformMouseEvent::setClickCount(Evas_Button_Flags flags)
+{
+ if (flags & EVAS_BUTTON_TRIPLE_CLICK)
+ m_clickCount = 3;
+ else if (flags & EVAS_BUTTON_DOUBLE_CLICK)
+ m_clickCount = 2;
+ else
+ m_clickCount = 1;
+}
+
+PlatformMouseEvent::PlatformMouseEvent(const Evas_Event_Mouse_Down* ev, IntPoint pos)
+ : m_timestamp(currentTime())
+ , m_shiftKey(evas_key_modifier_is_set(ev->modifiers, "Shift"))
+ , m_ctrlKey(evas_key_modifier_is_set(ev->modifiers, "Control"))
+ , m_altKey(evas_key_modifier_is_set(ev->modifiers, "Alt"))
+ , m_metaKey(evas_key_modifier_is_set(ev->modifiers, "Meta"))
+ , m_globalPosition(IntPoint(ev->canvas.x, ev->canvas.y))
+ , m_position(IntPoint(ev->canvas.x - pos.x(), ev->canvas.y - pos.y()))
+ , m_button(MouseButton(ev->button - 1))
+ , m_eventType(MouseEventPressed)
+{
+ setClickCount(ev->flags);
+}
+
+PlatformMouseEvent::PlatformMouseEvent(const Evas_Event_Mouse_Up* ev, IntPoint pos)
+ : m_timestamp(currentTime())
+ , m_shiftKey(evas_key_modifier_is_set(ev->modifiers, "Shift"))
+ , m_ctrlKey(evas_key_modifier_is_set(ev->modifiers, "Control"))
+ , m_altKey(evas_key_modifier_is_set(ev->modifiers, "Alt"))
+ , m_metaKey(evas_key_modifier_is_set(ev->modifiers, "Meta"))
+ , m_globalPosition(IntPoint(ev->canvas.x, ev->canvas.y))
+ , m_position(IntPoint(ev->canvas.x - pos.x(), ev->canvas.y - pos.y()))
+ , m_button(MouseButton(ev->button - 1))
+ , m_eventType(MouseEventReleased)
+{
+ setClickCount(ev->flags);
+}
+
+PlatformMouseEvent::PlatformMouseEvent(const Evas_Event_Mouse_Move* ev, IntPoint pos)
+ : m_timestamp(currentTime())
+ , m_shiftKey(evas_key_modifier_is_set(ev->modifiers, "Shift"))
+ , m_ctrlKey(evas_key_modifier_is_set(ev->modifiers, "Control"))
+ , m_altKey(evas_key_modifier_is_set(ev->modifiers, "Alt"))
+ , m_metaKey(evas_key_modifier_is_set(ev->modifiers, "Meta"))
+ , m_globalPosition(IntPoint(ev->cur.canvas.x, ev->cur.canvas.y))
+ , m_position(IntPoint(ev->cur.canvas.x - pos.x(), ev->cur.canvas.y - pos.y()))
+ , m_clickCount(0)
+ , m_button(MouseButton(ev->buttons - 1))
+ , m_eventType(MouseEventMoved)
+{
+}
+
+}
diff --git a/WebCore/platform/efl/ScrollbarEfl.cpp b/WebCore/platform/efl/ScrollbarEfl.cpp
new file mode 100644
index 0000000..28c5eb4
--- /dev/null
+++ b/WebCore/platform/efl/ScrollbarEfl.cpp
@@ -0,0 +1,215 @@
+/*
+ * Copyright (C) 2007 Holger Hans Peter Freyther zecke at selfish.org
+ * (C) 2009 Kenneth Rohde Christiansen
+ * (C) 2009 INdT, Instituto Nokia de Technologia
+ * (C) 2009-2010 ProFUSION embedded systems
+ * (C) 2009-2010 Samsung Electronics
+ *
+ * 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 "ScrollbarEfl.h"
+
+#include "CString.h"
+#include "ChromeClient.h"
+#include "Frame.h"
+#include "FrameView.h"
+#include "GraphicsContext.h"
+#include "HostWindow.h"
+#include "IntRect.h"
+#include "NotImplemented.h"
+#include "Page.h"
+#include "ScrollbarTheme.h"
+
+#include <Ecore.h>
+#include <Edje.h>
+#include <string>
+
+using namespace std;
+using namespace WebCore;
+
+PassRefPtr<Scrollbar> Scrollbar::createNativeScrollbar(ScrollbarClient* client, ScrollbarOrientation orientation, ScrollbarControlSize size)
+{
+ return adoptRef(new ScrollbarEfl(client, orientation, size));
+}
+
+ScrollbarEfl::ScrollbarEfl(ScrollbarClient* client, ScrollbarOrientation orientation, ScrollbarControlSize controlSize)
+ : Scrollbar(client, orientation, controlSize)
+ , m_lastPos(0)
+ , m_lastTotalSize(0)
+ , m_lastVisibleSize(0)
+{
+ Widget::setFrameRect(IntRect(0, 0, 0, 0));
+}
+
+ScrollbarEfl::~ScrollbarEfl()
+{
+ if (!evasObject())
+ return;
+ evas_object_del(evasObject());
+ setEvasObject(0);
+}
+
+static void scrollbarEflEdjeMessage(void* data, Evas_Object* o, Edje_Message_Type type, int id, void* msg)
+{
+ ScrollbarEfl::ScrollbarEfl* that = static_cast<ScrollbarEfl::ScrollbarEfl*>(data);
+ Edje_Message_Float* m;
+ int v;
+
+ if (!id) {
+ EINA_LOG_ERR("Unknown message id '%d' from scroll bar theme.", id);
+ return;
+ }
+
+ if (type != EDJE_MESSAGE_FLOAT) {
+ EINA_LOG_ERR("Message id '%d' of incorrect type from scroll bar theme. "
+ "Expected '%d', got '%d'.",
+ id, EDJE_MESSAGE_FLOAT, type);
+ return;
+ }
+
+ m = static_cast<Edje_Message_Float*>(msg);
+ v = m->val * (that->totalSize() - that->visibleSize());
+ that->setValue(v);
+}
+
+void ScrollbarEfl::setParent(ScrollView* view)
+{
+ Evas_Object* o = evasObject();
+ Evas_Coord w, h;
+
+ Widget::setParent(view);
+
+ if (!o) {
+ if (!view)
+ return;
+
+ o = edje_object_add(view->evas());
+ if (!o) {
+ EINA_LOG_ERR("Could not create edje object for view=%p (evas=%p)",
+ view, view->evas());
+ return;
+ }
+ edje_object_message_handler_set(o, scrollbarEflEdjeMessage, this);
+ setEvasObject(o);
+ } else if (!view) {
+ evas_object_hide(o);
+ return;
+ }
+
+ const char* group = (orientation() == HorizontalScrollbar)
+ ? "scrollbar.horizontal" : "scrollbar.vertical";
+ String theme(edjeThemeRecursive());
+
+ if (theme.isEmpty()) {
+ EINA_LOG_ERR("Could not load theme '%s': no theme path set.", group);
+ evas_object_hide(o);
+ return;
+ }
+
+ if (!edje_object_file_set(o, theme.utf8().data(), group)) {
+ int err = edje_object_load_error_get(o);
+ const char* errmsg = edje_load_error_str(err);
+ EINA_LOG_ERR("Could not load theme '%s' from file '%s': #%d '%s'",
+ theme.utf8().data(), group, err, errmsg);
+ return;
+ }
+
+ setPlatformWidget(o);
+ evas_object_smart_member_add(o, view->evasObject());
+ evas_object_show(o);
+
+ edje_object_size_min_get(o, &w, &h);
+
+ IntRect rect = frameRect();
+ rect.setSize(IntSize(w, h));
+ setFrameRect(rect);
+}
+
+void ScrollbarEfl::updateThumbPosition()
+{
+ updateThumbPositionAndProportion();
+}
+
+void ScrollbarEfl::updateThumbProportion()
+{
+ updateThumbPositionAndProportion();
+}
+
+void ScrollbarEfl::updateThumbPositionAndProportion()
+{
+ if (!platformWidget())
+ return;
+
+ int pos = currentPos();
+ int tSize = totalSize();
+ int vSize = visibleSize();
+
+ if (m_lastPos == pos
+ && m_lastTotalSize == tSize
+ && m_lastVisibleSize == vSize)
+ return;
+
+ m_lastPos = pos;
+ m_lastTotalSize = tSize;
+ m_lastVisibleSize = vSize;
+
+ Edje_Message_Float_Set* msg = static_cast<Edje_Message_Float_Set*>
+ (alloca(sizeof(Edje_Message_Float_Set) + sizeof(float)));
+ msg->count = 2;
+
+ if (tSize - vSize > 0)
+ msg->val[0] = pos / (float)(tSize - vSize);
+ else
+ msg->val[0] = 0.0;
+
+ if (tSize > 0)
+ msg->val[1] = vSize / (float)tSize;
+ else
+ msg->val[1] = 0.0;
+
+ edje_object_message_send(platformWidget(), EDJE_MESSAGE_FLOAT_SET, 0, msg);
+}
+
+void ScrollbarEfl::setFrameRect(const IntRect& rect)
+{
+ Widget::setFrameRect(rect);
+ frameRectsChanged();
+}
+
+void ScrollbarEfl::frameRectsChanged()
+{
+ Evas_Object* o = platformWidget();
+ Evas_Coord x, y;
+
+ if (!parent() || !o)
+ return;
+
+ IntRect rect = frameRect();
+ if (parent()->isScrollViewScrollbar(this))
+ rect.setLocation(parent()->convertToContainingWindow(rect.location()));
+ else
+ rect.setLocation(parent()->contentsToWindow(rect.location()));
+
+ evas_object_geometry_get(root()->evasObject(), &x, &y, 0, 0);
+ evas_object_move(o, x + rect.x(), y + rect.y());
+ evas_object_resize(o, rect.width(), rect.height());
+}
+
+void ScrollbarEfl::paint(GraphicsContext* context, const IntRect& rect)
+{
+}
+
--
WebKit Debian packaging
More information about the Pkg-webkit-commits
mailing list