|
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 |
|