- Source/JavaScriptCore/ChangeLog +15 lines
Lines 1-3 Source/JavaScriptCore/ChangeLog_sec1
1
2014-11-05  Michael Saboff  <msaboff@apple.com>
2
3
        REGRESSION (r174985-174986): Site display disappears 
4
        https://bugs.webkit.org/show_bug.cgi?id=138082
5
6
        Reviewed by NOBODY (OOPS!).
7
8
        In support of the change in WebCore, this adds a new functor class to unwind to our
9
        caller's frame possibly skipping of intermediate C++ frames.
10
11
        * interpreter/StackVisitor.h:
12
        (JSC::CallerFunctor::CallerFunctor):
13
        (JSC::CallerFunctor::callerFrame):
14
        (JSC::CallerFunctor::operator()):
15
1
2014-11-05  Gyuyoung Kim  <gyuyoung.kim@samsung.com>
16
2014-11-05  Gyuyoung Kim  <gyuyoung.kim@samsung.com>
2
17
3
        Use std::unique_ptr in JSClassRef and JSCallbackObject
18
        Use std::unique_ptr in JSClassRef and JSCallbackObject
- Source/JavaScriptCore/interpreter/StackVisitor.h +26 lines
Lines 150-155 private: Source/JavaScriptCore/interpreter/StackVisitor.h_sec1
150
    Frame m_frame;
150
    Frame m_frame;
151
};
151
};
152
152
153
class CallerFunctor {
154
public:
155
    CallerFunctor()
156
        : m_hasSkippedFirstFrame(false)
157
        , m_callerFrame(0)
158
    {
159
    }
160
161
    CallFrame* callerFrame() const { return m_callerFrame; }
162
163
    StackVisitor::Status operator()(StackVisitor& visitor)
164
    {
165
        if (!m_hasSkippedFirstFrame) {
166
            m_hasSkippedFirstFrame = true;
167
            return StackVisitor::Continue;
168
        }
169
170
        m_callerFrame = visitor->callFrame();
171
        return StackVisitor::Done;
172
    }
173
    
174
private:
175
    bool m_hasSkippedFirstFrame;
176
    CallFrame* m_callerFrame;
177
};
178
153
} // namespace JSC
179
} // namespace JSC
154
180
155
#endif // StackVisitor_h
181
#endif // StackVisitor_h
- Source/WebCore/ChangeLog +20 lines
Lines 1-3 Source/WebCore/ChangeLog_sec1
1
2014-11-05  Michael Saboff  <msaboff@apple.com>
2
3
        REGRESSION (r174985-174986): Site display disappears 
4
        https://bugs.webkit.org/show_bug.cgi?id=138082
5
6
        Reviewed by NOBODY (OOPS!).
7
8
        This effectively reverts to the behavior before r174985 by using the 
9
        lexical global object of the caller's frame to find the active document.
10
        Before r174985, native functions are invoked with the ScopeShain of their
11
        caller.  The lexical global object is accessed from the ScopeChain.
12
13
        * bindings/js/JSHTMLDocumentCustom.cpp:
14
        (WebCore::JSHTMLDocument::getOwnPropertySlot):
15
        (WebCore::findOwningDocument):
16
        (WebCore::documentWrite):
17
        (WebCore::JSHTMLDocument::write):
18
        (WebCore::JSHTMLDocument::writeln):
19
        * html/HTMLDocument.idl:
20
1
2014-11-05  Chris Dumez  <cdumez@apple.com>
21
2014-11-05  Chris Dumez  <cdumez@apple.com>
2
22
3
        Allow constructing a PassRef from a Ref
23
        Allow constructing a PassRef from a Ref
- Source/WebCore/bindings/js/JSHTMLDocumentCustom.cpp -12 / +17 lines
Lines 41-46 Source/WebCore/bindings/js/JSHTMLDocumentCustom.cpp_sec1
41
#include "JSMainThreadExecState.h"
41
#include "JSMainThreadExecState.h"
42
#include "SegmentedString.h"
42
#include "SegmentedString.h"
43
#include "DocumentParser.h"
43
#include "DocumentParser.h"
44
#include <interpreter/StackVisitor.h>
44
#include <runtime/Error.h>
45
#include <runtime/Error.h>
45
#include <runtime/JSCell.h>
46
#include <runtime/JSCell.h>
46
#include <wtf/unicode/CharacterNames.h>
47
#include <wtf/unicode/CharacterNames.h>
Lines 66-79 bool JSHTMLDocument::getOwnPropertySlot( Source/WebCore/bindings/js/JSHTMLDocumentCustom.cpp_sec2
66
        slot.setCustom(thisObject, ReadOnly | DontDelete | DontEnum, nonCachingStaticFunctionGetter<jsHTMLDocumentPrototypeFunctionOpen, 2>);
67
        slot.setCustom(thisObject, ReadOnly | DontDelete | DontEnum, nonCachingStaticFunctionGetter<jsHTMLDocumentPrototypeFunctionOpen, 2>);
67
        return true;
68
        return true;
68
    }
69
    }
69
    if (propertyName == "write") {
70
        slot.setCustom(thisObject, ReadOnly | DontDelete | DontEnum, nonCachingStaticFunctionGetter<jsHTMLDocumentPrototypeFunctionWrite, 1>);
71
        return true;
72
    }
73
    if (propertyName == "writeln") {
74
        slot.setCustom(thisObject, ReadOnly | DontDelete | DontEnum, nonCachingStaticFunctionGetter<jsHTMLDocumentPrototypeFunctionWriteln, 1>);
75
        return true;
76
    }
77
70
78
    if (canGetItemsForName(exec, &thisObject->impl(), propertyName)) {
71
    if (canGetItemsForName(exec, &thisObject->impl(), propertyName)) {
79
        slot.setCustom(thisObject, ReadOnly | DontDelete | DontEnum, thisObject->nameGetter);
72
        slot.setCustom(thisObject, ReadOnly | DontDelete | DontEnum, thisObject->nameGetter);
Lines 130-135 void JSHTMLDocument::setAll(ExecState* e Source/WebCore/bindings/js/JSHTMLDocumentCustom.cpp_sec3
130
    putDirect(exec->vm(), Identifier(exec, "all"), value);
123
    putDirect(exec->vm(), Identifier(exec, "all"), value);
131
}
124
}
132
125
126
static Document* findOwningDocument(ExecState* exec)
127
{
128
    CallerFunctor functor;
129
    exec->iterate(functor);
130
    CallFrame* callerFrame = functor.callerFrame();
131
    if (!callerFrame)
132
        return nullptr;
133
134
    return asJSDOMWindow(functor.callerFrame()->lexicalGlobalObject())->impl().document();
135
}
136
133
// Custom functions
137
// Custom functions
134
138
135
JSValue JSHTMLDocument::open(ExecState* exec)
139
JSValue JSHTMLDocument::open(ExecState* exec)
Lines 161-168 JSValue JSHTMLDocument::open(ExecState* Source/WebCore/bindings/js/JSHTMLDocumentCustom.cpp_sec4
161
165
162
enum NewlineRequirement { DoNotAddNewline, DoAddNewline };
166
enum NewlineRequirement { DoNotAddNewline, DoAddNewline };
163
167
164
static inline void documentWrite(ExecState* exec, HTMLDocument* document, NewlineRequirement addNewline)
168
static inline void documentWrite(ExecState* exec, JSHTMLDocument* thisDocument, NewlineRequirement addNewline)
165
{
169
{
170
    HTMLDocument* document = &thisDocument->impl();
166
    // DOM only specifies single string argument, but browsers allow multiple or no arguments.
171
    // DOM only specifies single string argument, but browsers allow multiple or no arguments.
167
172
168
    size_t size = exec->argumentCount();
173
    size_t size = exec->argumentCount();
Lines 182-200 static inline void documentWrite(ExecSta Source/WebCore/bindings/js/JSHTMLDocumentCustom.cpp_sec5
182
    if (addNewline)
187
    if (addNewline)
183
        segmentedString.append(SegmentedString(String(&newlineCharacter, 1)));
188
        segmentedString.append(SegmentedString(String(&newlineCharacter, 1)));
184
189
185
    Document* activeDocument = asJSDOMWindow(exec->lexicalGlobalObject())->impl().document();
190
    Document* activeDocument = findOwningDocument(exec);
186
    document->write(segmentedString, activeDocument);
191
    document->write(segmentedString, activeDocument);
187
}
192
}
188
193
189
JSValue JSHTMLDocument::write(ExecState* exec)
194
JSValue JSHTMLDocument::write(ExecState* exec)
190
{
195
{
191
    documentWrite(exec, &impl(), DoNotAddNewline);
196
    documentWrite(exec, this, DoNotAddNewline);
192
    return jsUndefined();
197
    return jsUndefined();
193
}
198
}
194
199
195
JSValue JSHTMLDocument::writeln(ExecState* exec)
200
JSValue JSHTMLDocument::writeln(ExecState* exec)
196
{
201
{
197
    documentWrite(exec, &impl(), DoAddNewline);
202
    documentWrite(exec, this, DoAddNewline);
198
    return jsUndefined();
203
    return jsUndefined();
199
}
204
}
200
205
- Source/WebCore/html/HTMLDocument.idl -2 / +2 lines
Lines 25-32 Source/WebCore/html/HTMLDocument.idl_sec1
25
] interface HTMLDocument : Document {
25
] interface HTMLDocument : Document {
26
    [Custom, ForwardDeclareInHeader] void open();
26
    [Custom, ForwardDeclareInHeader] void open();
27
    void close();
27
    void close();
28
    [Custom, ForwardDeclareInHeader] void write([Default=Undefined] optional DOMString text);
28
    [Custom] void write([Default=Undefined] optional DOMString text);
29
    [Custom, ForwardDeclareInHeader] void writeln([Default=Undefined] optional DOMString text);
29
    [Custom] void writeln([Default=Undefined] optional DOMString text);
30
30
31
    readonly attribute HTMLCollection embeds;
31
    readonly attribute HTMLCollection embeds;
32
    readonly attribute HTMLCollection plugins;
32
    readonly attribute HTMLCollection plugins;

Return to Bug 138082