static inline void documentWrite(ExecState& state, JSHTMLDocument* thisDocument, NewlineRequirement addNewline) { HTMLDocument* document = &thisDocument->wrapped(); // DOM only specifies single string argument, but browsers allow multiple or no arguments. size_t size = state.argumentCount(); String firstString = state.argument(0).toString(&state)->value(&state); SegmentedString segmentedString = firstString; if (size != 1) { if (!size) segmentedString.clear(); else { for (size_t i = 1; i < size; ++i) { String subsequentString = state.uncheckedArgument(i).toString(&state)->value(&state); segmentedString.append(SegmentedString(subsequentString)); } } } if (addNewline) segmentedString.append(SegmentedString(String(&newlineCharacter, 1))); Document* activeDocument = findCallingDocument(state); document->write(segmentedString, activeDocument); }
HTMLDocument* DOMImplementation::createHTMLDocument(const String& title) { DocumentInit init = DocumentInit::fromContext(document().contextDocument()) .withRegistrationContext(document().registrationContext()); HTMLDocument* d = HTMLDocument::create(init); d->open(); d->write("<!doctype html><html><head></head><body></body></html>"); if (!title.isNull()) { HTMLHeadElement* headElement = d->head(); DCHECK(headElement); HTMLTitleElement* titleElement = HTMLTitleElement::create(*d); headElement->appendChild(titleElement); titleElement->appendChild(d->createTextNode(title), ASSERT_NO_EXCEPTION); } d->setSecurityOrigin(document().getSecurityOrigin()); d->setContextFeatures(document().contextFeatures()); return d; }
void V8HTMLDocument::writeMethodCustom(const v8::FunctionCallbackInfo<v8::Value>& args) { HTMLDocument* htmlDocument = V8HTMLDocument::toNative(args.Holder()); htmlDocument->write(writeHelperGetString(args), activeDOMWindow()->document()); }
v8::Handle<v8::Value> V8HTMLDocument::writeMethodCustom(const v8::Arguments& args) { HTMLDocument* htmlDocument = V8HTMLDocument::toNative(args.Holder()); htmlDocument->write(writeHelperGetString(args), activeDOMWindow()->document()); return v8::Undefined(); }