initial import
[vuplus_webkit] / Tools / DumpRenderTree / efl / WorkQueueItemEfl.cpp
1 /*
2  * Copyright (C) 2007 Alp Toker <alp@atoker.com>
3  * Copyright (C) 2011 ProFUSION Embedded Systems
4  * Copyright (C) 2011 Samsung Electronics
5  *
6  * This library is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Library General Public
8  * License as published by the Free Software Foundation; either
9  * version 2 of the License, or (at your option) any later version.
10  *
11  * This library is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14  * Library General Public License for more details.
15  *
16  * You should have received a copy of the GNU Library General Public License
17  * along with this library; see the file COPYING.LIB.  If not, write to
18  * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
19  * Boston, MA 02110-1301, USA.
20  */
21
22 #include "config.h"
23 #include "WorkQueueItem.h"
24
25 #include "DumpRenderTree.h"
26
27 #include <EWebKit.h>
28 #include <JavaScriptCore/JSStringRef.h>
29 #include <JavaScriptCore/OpaqueJSString.h>
30 #include <JavaScriptCore/runtime/UString.h>
31 #include <JavaScriptCore/wtf/text/CString.h>
32
33 bool LoadItem::invoke() const
34 {
35     Evas_Object* targetFrame;
36
37     if (!m_target->length())
38         targetFrame = mainFrame;
39     else
40         targetFrame = ewk_frame_child_find(mainFrame, m_target->ustring().utf8().data());
41
42     ewk_frame_uri_set(targetFrame, m_url->ustring().utf8().data());
43
44     return true;
45 }
46
47 bool LoadHTMLStringItem::invoke() const
48 {
49     if (!m_unreachableURL->length())
50         ewk_frame_contents_set(mainFrame, m_content->ustring().utf8().data(), 0, 0, 0, m_baseURL->ustring().utf8().data());
51     else
52         ewk_frame_contents_alternate_set(mainFrame, m_content->ustring().utf8().data(), 0, 0, 0, m_baseURL->ustring().utf8().data(), m_unreachableURL->ustring().utf8().data());
53
54     return true;
55 }
56
57 bool ReloadItem::invoke() const
58 {
59     ewk_view_reload(browser);
60     return true;
61 }
62
63 bool ScriptItem::invoke() const
64 {
65     return ewk_frame_script_execute(mainFrame, m_script->ustring().utf8().data());
66 }
67
68 bool BackForwardItem::invoke() const
69 {
70     Ewk_History* history = ewk_view_history_get(browser);
71
72     if (m_howFar == 1)
73         ewk_history_forward(history);
74     else if (m_howFar == -1)
75         ewk_history_back(history);
76     else {
77         const Ewk_History_Item* item = ewk_history_history_item_nth_get(history, m_howFar);
78         ewk_history_history_item_set(history, item);
79     }
80
81     return true;
82 }