~ubuntu-branches/ubuntu/raring/qtwebkit-source/raring-proposed

« back to all changes in this revision

Viewing changes to Tools/DumpRenderTree/blackberry/WorkQueueItemBlackBerry.cpp

  • Committer: Package Import Robot
  • Author(s): Jonathan Riddell
  • Date: 2013-02-18 14:24:18 UTC
  • Revision ID: package-import@ubuntu.com-20130218142418-eon0jmjg3nj438uy
Tags: upstream-2.3
ImportĀ upstreamĀ versionĀ 2.3

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * Copyright (C) 2009, 2010, 2012 Research In Motion Limited. All rights reserved.
 
3
 *
 
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.
 
8
 *
 
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.
 
13
 *
 
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
 
17
 */
 
18
 
 
19
#include "config.h"
 
20
#include "WorkQueueItem.h"
 
21
 
 
22
#include "DumpRenderTreeBlackBerry.h"
 
23
#include "Frame.h"
 
24
#include "KURL.h"
 
25
#include "WebPage.h"
 
26
#include <wtf/OwnArrayPtr.h>
 
27
 
 
28
using namespace WebCore;
 
29
 
 
30
bool LoadItem::invoke() const
 
31
{
 
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);
 
38
 
 
39
    Frame* frame;
 
40
    if (target && targetLen)
 
41
        frame = mainFrame->tree()->find(target.get());
 
42
    else
 
43
        frame = mainFrame;
 
44
 
 
45
    if (!frame)
 
46
        return false;
 
47
 
 
48
    KURL kurl = KURL(KURL(), url.get());
 
49
    frame->loader()->load(kurl, false);
 
50
    return true;
 
51
}
 
52
 
 
53
bool LoadHTMLStringItem::invoke() const
 
54
{
 
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() : "");
 
65
    return true;
 
66
}
 
67
 
 
68
bool ReloadItem::invoke() const
 
69
{
 
70
    mainFrame->loader()->reload(true);
 
71
    return true;
 
72
}
 
73
 
 
74
bool ScriptItem::invoke() const
 
75
{
 
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);
 
82
    return true;
 
83
}
 
84
 
 
85
bool BackForwardItem::invoke() const
 
86
{
 
87
    return BlackBerry::WebKit::DumpRenderTree::currentInstance()->page()->goBackOrForward(m_howFar);
 
88
}
 
89