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

« back to all changes in this revision

Viewing changes to src/3rdparty/webkit/WebCore/bindings/js/JSStyleSheetCustom.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
1
/*
2
 
 * Copyright (C) 2007, 2008 Apple Inc. All rights reserved.
 
2
 * Copyright (C) 2007, 2008, 2009 Apple Inc. All rights reserved.
3
3
 *
4
4
 * Redistribution and use in source and binary forms, with or without
5
5
 * modification, are permitted provided that the following conditions
27
27
#include "JSStyleSheet.h"
28
28
 
29
29
#include "CSSStyleSheet.h"
 
30
#include "Node.h"
30
31
#include "JSCSSStyleSheet.h"
31
32
#include "JSNode.h"
32
33
 
34
35
 
35
36
namespace WebCore {
36
37
 
37
 
JSValuePtr toJS(ExecState* exec, StyleSheet* styleSheet)
 
38
JSValue toJS(ExecState* exec, JSDOMGlobalObject* globalObject, StyleSheet* styleSheet)
38
39
{
39
40
    if (!styleSheet)
40
41
        return jsNull();
44
45
        return wrapper;
45
46
 
46
47
    if (styleSheet->isCSSStyleSheet())
47
 
        wrapper = CREATE_DOM_OBJECT_WRAPPER(exec, CSSStyleSheet, styleSheet);
 
48
        wrapper = CREATE_DOM_OBJECT_WRAPPER(exec, globalObject, CSSStyleSheet, styleSheet);
48
49
    else
49
 
        wrapper = CREATE_DOM_OBJECT_WRAPPER(exec, StyleSheet, styleSheet);
 
50
        wrapper = CREATE_DOM_OBJECT_WRAPPER(exec, globalObject, StyleSheet, styleSheet);
50
51
 
51
52
    return wrapper;
52
53
}
53
54
 
54
 
void JSStyleSheet::mark()
 
55
void JSStyleSheet::markChildren(MarkStack& markStack)
55
56
{
56
 
    Base::mark();
 
57
    Base::markChildren(markStack);
 
58
 
 
59
    StyleSheet* sheet = impl();
 
60
    JSGlobalData& globalData = *Heap::heap(this)->globalData();
 
61
 
 
62
    unsigned length = sheet->length();
 
63
    for (unsigned i = 0; i < length; ++i)
 
64
        markDOMObjectWrapper(markStack, globalData, sheet->item(i));
57
65
 
58
66
    // This prevents us from having a style sheet with a dangling ownerNode pointer.
59
67
    // A better solution would be to handle this on the DOM side -- if the style sheet
60
68
    // is kept around, then we want the node to stay around too. One possibility would
61
69
    // be to make ref/deref on the style sheet ref/deref the node instead, but there's
62
70
    // a lot of disentangling of the CSS DOM objects that would need to happen first.
63
 
    if (Node* ownerNode = impl()->ownerNode()) {
64
 
        if (JSNode* ownerNodeWrapper = getCachedDOMNodeWrapper(ownerNode->document(), ownerNode)) {
65
 
            if (!ownerNodeWrapper->marked())
66
 
                ownerNodeWrapper->mark();
67
 
        }
 
71
    if (Node* ownerNode = sheet->ownerNode()) {
 
72
        if (JSNode* ownerNodeWrapper = getCachedDOMNodeWrapper(ownerNode->document(), ownerNode))
 
73
            markStack.append(ownerNodeWrapper);
68
74
    }
69
75
}
70
76