本文整理汇总了C++中HTMLDocument::open方法的典型用法代码示例。如果您正苦于以下问题:C++ HTMLDocument::open方法的具体用法?C++ HTMLDocument::open怎么用?C++ HTMLDocument::open使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类HTMLDocument
的用法示例。
在下文中一共展示了HTMLDocument::open方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: throwTypeError
void V8HTMLDocument::openMethodCustom(const v8::FunctionCallbackInfo<v8::Value>& args)
{
HTMLDocument* htmlDocument = V8HTMLDocument::toNative(args.Holder());
if (args.Length() > 2) {
if (RefPtr<Frame> frame = htmlDocument->frame()) {
// Fetch the global object for the frame.
v8::Local<v8::Context> context = frame->script()->currentWorldContext();
// Bail out if we cannot get the context.
if (context.IsEmpty())
return;
v8::Local<v8::Object> global = context->Global();
// Get the open property of the global object.
v8::Local<v8::Value> function = global->Get(v8::String::NewSymbol("open"));
// If the open property is not a function throw a type error.
if (!function->IsFunction()) {
throwTypeError("open is not a function", args.GetIsolate());
return;
}
// Wrap up the arguments and call the function.
OwnArrayPtr<v8::Local<v8::Value> > params = adoptArrayPtr(new v8::Local<v8::Value>[args.Length()]);
for (int i = 0; i < args.Length(); i++)
params[i] = args[i];
v8SetReturnValue(args, frame->script()->callFunction(v8::Local<v8::Function>::Cast(function), global, args.Length(), params.get()));
return;
}
}
htmlDocument->open(activeDOMWindow()->document());
v8SetReturnValue(args, args.Holder());
}
示例2: createHTMLDocument
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;
}
示例3: exceptionState
void V8HTMLDocument::openMethodCustom(const v8::FunctionCallbackInfo<v8::Value>& info)
{
HTMLDocument* htmlDocument = V8HTMLDocument::toNative(info.Holder());
if (info.Length() > 2) {
if (RefPtr<LocalFrame> frame = htmlDocument->frame()) {
// Fetch the global object for the frame.
v8::Local<v8::Context> context = toV8Context(info.GetIsolate(), frame.get(), DOMWrapperWorld::current(info.GetIsolate()));
// Bail out if we cannot get the context.
if (context.IsEmpty())
return;
v8::Local<v8::Object> global = context->Global();
// Get the open property of the global object.
v8::Local<v8::Value> function = global->Get(v8AtomicString(info.GetIsolate(), "open"));
// Failed; return without throwing (new) exception.
if (function.IsEmpty())
return;
// If the open property is not a function throw a type error.
if (!function->IsFunction()) {
throwTypeError("open is not a function", info.GetIsolate());
return;
}
// Wrap up the arguments and call the function.
OwnPtr<v8::Local<v8::Value>[]> params = adoptArrayPtr(new v8::Local<v8::Value>[info.Length()]);
for (int i = 0; i < info.Length(); i++)
params[i] = info[i];
v8SetReturnValue(info, frame->script().callFunction(v8::Local<v8::Function>::Cast(function), global, info.Length(), params.get()));
return;
}
}
ExceptionState exceptionState(ExceptionState::ExecutionContext, "open", "Document", info.Holder(), info.GetIsolate());
htmlDocument->open(callingDOMWindow(info.GetIsolate())->document(), exceptionState);
if (exceptionState.throwIfNeeded())
return;
v8SetReturnValue(info, info.Holder());
}