void HTMLPlugInImageElement::didAddUserAgentShadowRoot(ShadowRoot* root) { HTMLPlugInElement::didAddUserAgentShadowRoot(root); if (displayState() >= PreparingPluginReplacement) return; Page* page = document().page(); if (!page) return; // Reset any author styles that may apply as we only want explicit // styles defined in the injected user agents stylesheets to specify // the look-and-feel of the snapshotted plug-in overlay. root->setResetStyleInheritance(true); String mimeType = loadedMimeType(); DOMWrapperWorld& isolatedWorld = plugInImageElementIsolatedWorld(); document().ensurePlugInsInjectedScript(isolatedWorld); ScriptController& scriptController = document().frame()->script(); JSDOMGlobalObject* globalObject = JSC::jsCast<JSDOMGlobalObject*>(scriptController.globalObject(isolatedWorld)); JSC::ExecState* exec = globalObject->globalExec(); JSC::JSLockHolder lock(exec); JSC::MarkedArgumentBuffer argList; argList.append(toJS(exec, globalObject, root)); argList.append(jsString(exec, titleText(page, mimeType))); argList.append(jsString(exec, subtitleText(page, mimeType))); // This parameter determines whether or not the snapshot overlay should always be visible over the plugin snapshot. // If no snapshot was found then we want the overlay to be visible. argList.append(JSC::jsBoolean(!m_snapshotImage)); // It is expected the JS file provides a createOverlay(shadowRoot, title, subtitle) function. JSC::JSObject* overlay = globalObject->get(exec, JSC::Identifier::fromString(exec, "createOverlay")).toObject(exec); if (!overlay) { ASSERT(exec->hadException()); exec->clearException(); return; } JSC::CallData callData; JSC::CallType callType = overlay->methodTable()->getCallData(overlay, callData); if (callType == JSC::CallType::None) return; JSC::call(exec, overlay, callType, callData, globalObject, argList); exec->clearException(); }
JSC::JSValue jsArray(JSC::ExecState* exec, JSDOMGlobalObject* globalObject, PassRefPtr<DOMStringList> stringList) { JSC::MarkedArgumentBuffer list; if (stringList) { for (unsigned i = 0; i < stringList->length(); ++i) list.append(jsStringWithCache(exec, stringList->item(i))); } return JSC::constructArray(exec, 0, globalObject, list); }
static inline bool checkReadableStream(JSDOMGlobalObject& globalObject, JSReadableStream* readableStream, JSC::JSValue function) { auto& state = *globalObject.globalExec(); ASSERT(function); JSC::MarkedArgumentBuffer arguments; arguments.append(readableStream); ASSERT(!arguments.hasOverflowed()); return ReadableStreamInternal::callFunction(state, function, JSC::jsUndefined(), arguments).isTrue(); }
JSValue JSWebGLRenderingContextBase::getAttachedShaders(ExecState* exec) { if (exec->argumentCount() < 1) return exec->vm().throwException(exec, createNotEnoughArgumentsError(exec)); ExceptionCode ec = 0; WebGLRenderingContextBase& context = impl(); WebGLProgram* program = JSWebGLProgram::toWrapped(exec->uncheckedArgument(0)); if (!program && !exec->uncheckedArgument(0).isUndefinedOrNull()) return throwTypeError(exec); Vector<RefPtr<WebGLShader>> shaders; bool succeed = context.getAttachedShaders(program, shaders, ec); if (ec) { setDOMException(exec, ec); return jsNull(); } if (!succeed) return jsNull(); JSC::MarkedArgumentBuffer list; for (size_t ii = 0; ii < shaders.size(); ++ii) list.append(toJS(exec, globalObject(), shaders[ii].get())); return constructArray(exec, 0, globalObject(), list); }