2 * Copyright (C) 2009, 2010, 2012 Research In Motion Limited. All rights reserved.
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20 #include "WorkQueueItem.h"
22 #include "DumpRenderTreeBlackBerry.h"
26 #include <wtf/OwnArrayPtr.h>
28 using namespace WebCore;
30 bool LoadItem::invoke() const
32 size_t targetArrSize = JSStringGetMaximumUTF8CStringSize(m_target.get());
33 size_t urlArrSize = JSStringGetMaximumUTF8CStringSize(m_url.get());
34 OwnArrayPtr<char> target = adoptArrayPtr(new char[targetArrSize]);
35 OwnArrayPtr<char> url = adoptArrayPtr(new char[urlArrSize]);
36 size_t targetLen = JSStringGetUTF8CString(m_target.get(), target.get(), targetArrSize) - 1;
37 JSStringGetUTF8CString(m_url.get(), url.get(), urlArrSize);
40 if (target && targetLen)
41 frame = mainFrame->tree()->find(target.get());
48 KURL kurl = KURL(KURL(), url.get());
49 frame->loader()->load(kurl, false);
53 bool LoadHTMLStringItem::invoke() const
55 size_t contentSize = JSStringGetMaximumUTF8CStringSize(m_content.get());
56 size_t baseURLSize = JSStringGetMaximumUTF8CStringSize(m_baseURL.get());
57 size_t unreachableURLSize = JSStringGetMaximumUTF8CStringSize(m_unreachableURL.get());
58 OwnArrayPtr<char> content = adoptArrayPtr(new char[contentSize]);
59 OwnArrayPtr<char> baseURL = adoptArrayPtr(new char[baseURLSize]);
60 OwnArrayPtr<char> unreachableURL = adoptArrayPtr(new char[unreachableURLSize]);
61 JSStringGetUTF8CString(m_content.get(), content.get(), contentSize);
62 JSStringGetUTF8CString(m_baseURL.get(), baseURL.get(), baseURLSize);
63 JSStringGetUTF8CString(m_unreachableURL.get(), unreachableURL.get(), unreachableURLSize);
64 BlackBerry::WebKit::DumpRenderTree::currentInstance()->page()->loadString(content.get(), baseURL.get(), "text/html", unreachableURLSize ? unreachableURL.get() : "");
68 bool ReloadItem::invoke() const
70 mainFrame->loader()->reload(true);
74 bool ScriptItem::invoke() const
76 BlackBerry::WebKit::JavaScriptDataType type;
77 BlackBerry::Platform::String result;
78 size_t scriptArrSize = JSStringGetMaximumUTF8CStringSize(m_script.get());
79 OwnArrayPtr<char> script = adoptArrayPtr(new char[scriptArrSize]);
80 JSStringGetUTF8CString(m_script.get(), script.get(), scriptArrSize);
81 BlackBerry::WebKit::DumpRenderTree::currentInstance()->page()->executeJavaScript(BlackBerry::Platform::String::fromRawData(script.get(), scriptArrSize), type, result);
85 bool BackForwardItem::invoke() const
87 return BlackBerry::WebKit::DumpRenderTree::currentInstance()->page()->goBackOrForward(m_howFar);