~oif-team/ubuntu/natty/qt4-x11/xi2.1

« back to all changes in this revision

Viewing changes to src/3rdparty/webkit/WebCore/bindings/js/ScriptCachedFrameData.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Alessandro Ghersi
  • Date: 2009-11-02 18:30:08 UTC
  • mfrom: (1.2.2 upstream)
  • mto: (15.2.5 experimental)
  • mto: This revision was merged to the branch mainline in revision 88.
  • Revision ID: james.westby@ubuntu.com-20091102183008-b6a4gcs128mvfb3m
Tags: upstream-4.6.0~beta1
ImportĀ upstreamĀ versionĀ 4.6.0~beta1

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * Copyright (c) 2008, Google Inc. All rights reserved.
 
3
 * Copyright (C) 2008 Apple Inc. All Rights Reserved.
 
4
 * 
 
5
 * Redistribution and use in source and binary forms, with or without
 
6
 * modification, are permitted provided that the following conditions are
 
7
 * met:
 
8
 * 
 
9
 *     * Redistributions of source code must retain the above copyright
 
10
 * notice, this list of conditions and the following disclaimer.
 
11
 *     * Redistributions in binary form must reproduce the above
 
12
 * copyright notice, this list of conditions and the following disclaimer
 
13
 * in the documentation and/or other materials provided with the
 
14
 * distribution.
 
15
 *     * Neither the name of Google Inc. nor the names of its
 
16
 * contributors may be used to endorse or promote products derived from
 
17
 * this software without specific prior written permission.
 
18
 * 
 
19
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
 
20
 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
 
21
 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
 
22
 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
 
23
 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
 
24
 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
 
25
 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
 
26
 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
 
27
 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 
28
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
 
29
 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 
30
 */
 
31
 
 
32
#include "config.h"
 
33
#include "ScriptCachedFrameData.h"
 
34
 
 
35
#include "Frame.h"
 
36
#include "GCController.h"
 
37
#include "Page.h"
 
38
#include "PageGroup.h"
 
39
#include <runtime/JSLock.h>
 
40
#include "ScriptController.h"
 
41
 
 
42
using namespace JSC;
 
43
 
 
44
namespace WebCore {
 
45
 
 
46
ScriptCachedFrameData::ScriptCachedFrameData(Frame* frame)
 
47
{
 
48
    JSLock lock(SilenceAssertionsOnly);
 
49
 
 
50
    ScriptController* scriptController = frame->script();
 
51
    if (scriptController->haveWindowShell()) {
 
52
        m_window = scriptController->windowShell()->window();
 
53
        scriptController->attachDebugger(0);
 
54
    }
 
55
}
 
56
 
 
57
DOMWindow* ScriptCachedFrameData::domWindow() const {
 
58
    return m_window ? m_window->impl() : 0;
 
59
}
 
60
 
 
61
ScriptCachedFrameData::~ScriptCachedFrameData()
 
62
{
 
63
    clear();
 
64
}
 
65
 
 
66
void ScriptCachedFrameData::restore(Frame* frame)
 
67
{
 
68
    Page* page = frame->page();
 
69
 
 
70
    JSLock lock(SilenceAssertionsOnly);
 
71
 
 
72
    ScriptController* scriptController = frame->script();
 
73
    if (scriptController->haveWindowShell()) {
 
74
        JSDOMWindowShell* windowShell = scriptController->windowShell();
 
75
        if (m_window) {
 
76
            windowShell->setWindow(m_window.get());
 
77
        } else {
 
78
            windowShell->setWindow(frame->domWindow());
 
79
            scriptController->attachDebugger(page->debugger());
 
80
            windowShell->window()->setProfileGroup(page->group().identifier());
 
81
        }
 
82
    }
 
83
}
 
84
 
 
85
void ScriptCachedFrameData::clear()
 
86
{
 
87
    JSLock lock(SilenceAssertionsOnly);
 
88
 
 
89
    if (!m_window) {
 
90
        m_window = 0;
 
91
        gcController().garbageCollectSoon();
 
92
    }
 
93
}
 
94
 
 
95
} // namespace WebCore