static inline FlagsString flagsString(ExecState* exec, JSObject* regexp) { FlagsString string; JSValue globalValue = regexp->get(exec, exec->propertyNames().global); if (exec->hadException()) return string; JSValue ignoreCaseValue = regexp->get(exec, exec->propertyNames().ignoreCase); if (exec->hadException()) return string; JSValue multilineValue = regexp->get(exec, exec->propertyNames().multiline); if (exec->hadException()) return string; JSValue unicodeValue = regexp->get(exec, exec->propertyNames().unicode); unsigned index = 0; if (globalValue.toBoolean(exec)) string[index++] = 'g'; if (ignoreCaseValue.toBoolean(exec)) string[index++] = 'i'; if (multilineValue.toBoolean(exec)) string[index++] = 'm'; if (unicodeValue.toBoolean(exec)) string[index++] = 'u'; ASSERT(index < string.size()); string[index] = 0; return string; }
static void populateContextMenuItems(ExecState* exec, JSArray* array, ContextMenu& menu) { for (size_t i = 0; i < array->length(); ++i) { JSObject* item = asObject(array->getIndex(exec, i)); JSValue label = item->get(exec, Identifier::fromString(exec, "label")); JSValue type = item->get(exec, Identifier::fromString(exec, "type")); JSValue id = item->get(exec, Identifier::fromString(exec, "id")); JSValue enabled = item->get(exec, Identifier::fromString(exec, "enabled")); JSValue checked = item->get(exec, Identifier::fromString(exec, "checked")); JSValue subItems = item->get(exec, Identifier::fromString(exec, "subItems")); if (!type.isString()) continue; String typeString = type.toWTFString(exec); if (typeString == "separator") { ContextMenuItem item(SeparatorType, ContextMenuItemTagNoAction, String()); menu.appendItem(item); } else if (typeString == "subMenu" && subItems.inherits(JSArray::info())) { ContextMenu subMenu; JSArray* subItemsArray = asArray(subItems); populateContextMenuItems(exec, subItemsArray, subMenu); ContextMenuItem item(SubmenuType, ContextMenuItemTagNoAction, label.toWTFString(exec), &subMenu); menu.appendItem(item); } else { ContextMenuAction typedId = static_cast<ContextMenuAction>(ContextMenuItemBaseCustomTag + id.toInt32(exec)); ContextMenuItem menuItem((typeString == "checkbox" ? CheckableActionType : ActionType), typedId, label.toWTFString(exec)); if (!enabled.isUndefined()) menuItem.setEnabled(enabled.toBoolean(exec)); if (!checked.isUndefined()) menuItem.setChecked(checked.toBoolean(exec)); menu.appendItem(menuItem); } } }
bool ScriptDebugServer::hasBreakpoint(intptr_t sourceID, const TextPosition& position) const { if (!m_breakpointsActivated) return false; SourceIdToBreakpointsMap::const_iterator it = m_sourceIdToBreakpoints.find(sourceID); if (it == m_sourceIdToBreakpoints.end()) return false; int lineNumber = position.m_line.oneBasedInt(); if (lineNumber <= 0) return false; LineToBreakpointMap::const_iterator breakIt = it->second.find(lineNumber); if (breakIt == it->second.end()) return false; // An empty condition counts as no condition which is equivalent to "true". if (breakIt->second.condition.isEmpty()) return true; JSValue exception; JSValue result = m_currentCallFrame->evaluate(stringToUString(breakIt->second.condition), exception); if (exception) { // An erroneous condition counts as "false". return false; } return result.toBoolean(m_currentCallFrame->scopeChain()->globalObject->globalExec()); }
void setJSXMLHttpRequestWithCredentials(ExecState* exec, JSObject* thisObject, JSValue value) { XMLHttpRequest* imp = static_cast<XMLHttpRequest*>(static_cast<JSXMLHttpRequest*>(thisObject)->impl()); ExceptionCode ec = 0; imp->setWithCredentials(value.toBoolean(exec), ec); setDOMException(exec, ec); }
bool Debugger::hasBreakpoint(SourceID sourceID, const TextPosition& position, Breakpoint *hitBreakpoint) { if (!m_breakpointsActivated) return false; SourceIDToBreakpointsMap::const_iterator it = m_sourceIDToBreakpoints.find(sourceID); if (it == m_sourceIDToBreakpoints.end()) return false; unsigned line = position.m_line.zeroBasedInt(); unsigned column = position.m_column.zeroBasedInt(); LineToBreakpointsMap::const_iterator breaksIt = it->value.find(line); if (breaksIt == it->value.end()) return false; bool hit = false; const BreakpointsInLine& breakpoints = breaksIt->value; unsigned breakpointsCount = breakpoints.size(); unsigned i; for (i = 0; i < breakpointsCount; i++) { unsigned breakLine = breakpoints[i].line; unsigned breakColumn = breakpoints[i].column; // Since frontend truncates the indent, the first statement in a line must match the breakpoint (line,0). ASSERT(this == m_currentCallFrame->codeBlock()->globalObject()->debugger()); if ((line != m_lastExecutedLine && line == breakLine && !breakColumn) || (line == breakLine && column == breakColumn)) { hit = true; break; } } if (!hit) return false; if (hitBreakpoint) *hitBreakpoint = breakpoints[i]; if (breakpoints[i].condition.isEmpty()) return true; // We cannot stop in the debugger while executing condition code, // so make it looks like the debugger is already paused. TemporaryPausedState pausedState(*this); JSValue exception; DebuggerCallFrame* debuggerCallFrame = currentDebuggerCallFrame(); JSValue result = debuggerCallFrame->evaluate(breakpoints[i].condition, exception); // We can lose the debugger while executing JavaScript. if (!m_currentCallFrame) return false; if (exception) { // An erroneous condition counts as "false". handleExceptionInBreakpointCondition(m_currentCallFrame, exception); return false; } return result.toBoolean(m_currentCallFrame); }
bool JSCustomSQLStatementErrorCallback::handleEvent(SQLTransaction* transaction, SQLError* error) { ASSERT(m_callback); ASSERT(m_frame); if (!m_frame->script()->isEnabled()) return true; JSGlobalObject* globalObject = m_frame->script()->globalObject(); ExecState* exec = globalObject->globalExec(); KJS::JSLock lock; JSValue* handleEventFunction = m_callback->get(exec, Identifier(exec, "handleEvent")); CallData handleEventCallData; CallType handleEventCallType = handleEventFunction->getCallData(handleEventCallData); CallData callbackCallData; CallType callbackCallType = CallTypeNone; if (handleEventCallType == CallTypeNone) { callbackCallType = m_callback->getCallData(callbackCallData); if (callbackCallType == CallTypeNone) { // FIXME: Should an exception be thrown here? return true; } } RefPtr<JSCustomSQLStatementErrorCallback> protect(this); ArgList args; args.append(toJS(exec, transaction)); args.append(toJS(exec, error)); JSValue* result; globalObject->startTimeoutCheck(); if (handleEventCallType != CallTypeNone) result = call(exec, handleEventFunction, handleEventCallType, handleEventCallData, m_callback, args); else result = call(exec, m_callback, callbackCallType, callbackCallData, m_callback, args); globalObject->stopTimeoutCheck(); if (exec->hadException()) { JSObject* exception = exec->exception()->toObject(exec); String message = exception->get(exec, exec->propertyNames().message)->toString(exec); int lineNumber = exception->get(exec, Identifier(exec, "line"))->toInt32(exec); String sourceURL = exception->get(exec, Identifier(exec, "sourceURL"))->toString(exec); m_frame->domWindow()->console()->addMessage(JSMessageSource, ErrorMessageLevel, message, lineNumber, sourceURL); exec->clearException(); // The spec says: // "If the error callback returns false, then move on to the next statement..." // "Otherwise, the error callback did not return false, or there was no error callback" // Therefore an exception and returning true are the same thing - so, return true on an exception return true; } Document::updateDocumentsRendering(); return result->toBoolean(exec); }
bool JSValueToBoolean(JSContextRef ctx, JSValueRef value) { ExecState* exec = toJS(ctx); APIEntryShim entryShim(exec); JSValue jsValue = toJS(exec, value); return jsValue.toBoolean(exec); }
JSValue JSDirectoryEntry::getDirectory(ExecState* exec) { DirectoryEntry* imp = static_cast<DirectoryEntry*>(impl()); const String& path = valueToStringWithUndefinedOrNullCheck(exec, exec->argument(0)); if (exec->hadException()) return jsUndefined(); int argsCount = exec->argumentCount(); if (argsCount <= 1) { imp->getDirectory(path); return jsUndefined(); } RefPtr<Flags> flags; if (!exec->argument(1).isNull() && !exec->argument(1).isUndefined() && exec->argument(1).isObject() && !exec->argument(1).inherits(&JSFlags::s_info)) { JSObject* object = exec->argument(1).getObject(); flags = Flags::create(); JSValue jsCreate = object->get(exec, Identifier(exec, "create")); flags->setCreate(jsCreate.toBoolean(exec)); JSValue jsExclusive = object->get(exec, Identifier(exec, "exclusive")); flags->setExclusive(jsExclusive.toBoolean(exec)); } else flags = toFlags(exec->argument(1)); if (exec->hadException()) return jsUndefined(); RefPtr<EntryCallback> successCallback; if (exec->argumentCount() > 2 && !exec->argument(2).isNull() && !exec->argument(2).isUndefined()) { if (!exec->argument(2).isObject()) { setDOMException(exec, TYPE_MISMATCH_ERR); return jsUndefined(); } successCallback = JSEntryCallback::create(asObject(exec->argument(2)), globalObject()); } RefPtr<ErrorCallback> errorCallback; if (exec->argumentCount() > 3 && !exec->argument(3).isNull() && !exec->argument(3).isUndefined()) { if (!exec->argument(3).isObject()) { setDOMException(exec, TYPE_MISMATCH_ERR); return jsUndefined(); } errorCallback = JSErrorCallback::create(asObject(exec->argument(3)), globalObject()); } imp->getDirectory(path, flags, successCallback, errorCallback); return jsUndefined(); }
bool JSValueToBoolean(JSContextRef ctx, JSValueRef value) { ExecState* exec = toJS(ctx); exec->globalData().heap.registerThread(); JSLock lock(exec); JSValue jsValue = toJS(exec, value); return jsValue.toBoolean(exec); }
bool JSCustomSQLStatementErrorCallback::handleEvent(SQLTransaction* transaction, SQLError* error) { ASSERT(m_callback); ASSERT(m_frame); if (!m_frame->script()->isEnabled()) return true; JSGlobalObject* globalObject = m_frame->script()->globalObject(); ExecState* exec = globalObject->globalExec(); JSC::JSLock lock(false); JSValue handleEventFunction = m_callback->get(exec, Identifier(exec, "handleEvent")); CallData handleEventCallData; CallType handleEventCallType = handleEventFunction.getCallData(handleEventCallData); CallData callbackCallData; CallType callbackCallType = CallTypeNone; if (handleEventCallType == CallTypeNone) { callbackCallType = m_callback->getCallData(callbackCallData); if (callbackCallType == CallTypeNone) { // FIXME: Should an exception be thrown here? return true; } } RefPtr<JSCustomSQLStatementErrorCallback> protect(this); MarkedArgumentBuffer args; args.append(toJS(exec, transaction)); args.append(toJS(exec, error)); JSValue result; globalObject->globalData()->timeoutChecker.start(); if (handleEventCallType != CallTypeNone) result = call(exec, handleEventFunction, handleEventCallType, handleEventCallData, m_callback, args); else result = call(exec, m_callback, callbackCallType, callbackCallData, m_callback, args); globalObject->globalData()->timeoutChecker.stop(); if (exec->hadException()) { reportCurrentException(exec); // The spec says: // "If the error callback returns false, then move on to the next statement..." // "Otherwise, the error callback did not return false, or there was no error callback" // Therefore an exception and returning true are the same thing - so, return true on an exception return true; } Document::updateStyleForAllDocuments(); return result.toBoolean(exec); }
JSLR_API bool _cdecl JSTryConvertToBool(JSContextRef ctx, JSValueRef value, bool* result) { ExecState* exec = toJS(ctx); JSValue jsValue = toJS(exec, value); if (jsValue.isBoolean()) { *result = jsValue.toBoolean(exec); return true; } return false; }
bool JSValueToBoolean(JSContextRef ctx, JSValueRef value) { if (!ctx) { ASSERT_NOT_REACHED(); return false; } ExecState* exec = toJS(ctx); JSLockHolder locker(exec); JSValue jsValue = toJS(exec, value); return jsValue.toBoolean(exec); }
JSValue JSInspectorFrontendHost::showContextMenu(ExecState* exec) { if (exec->argumentCount() < 2) return jsUndefined(); #if ENABLE(CONTEXT_MENUS) Event* event = toEvent(exec->argument(0)); JSArray* array = asArray(exec->argument(1)); Vector<ContextMenuItem*> items; for (size_t i = 0; i < array->length(); ++i) { JSObject* item = asObject(array->getIndex(i)); JSValue label = item->get(exec, Identifier(exec, "label")); JSValue type = item->get(exec, Identifier(exec, "type")); JSValue id = item->get(exec, Identifier(exec, "id")); JSValue enabled = item->get(exec, Identifier(exec, "enabled")); JSValue checked = item->get(exec, Identifier(exec, "checked")); if (!type.isString()) continue; String typeString = ustringToString(type.toString(exec)->value(exec)); if (typeString == "separator") { items.append(new ContextMenuItem(SeparatorType, ContextMenuItemCustomTagNoAction, String())); } else { ContextMenuAction typedId = static_cast<ContextMenuAction>(ContextMenuItemBaseCustomTag + id.toInt32(exec)); ContextMenuItem* menuItem = new ContextMenuItem((typeString == "checkbox" ? CheckableActionType : ActionType), typedId, ustringToString(label.toString(exec)->value(exec))); if (!enabled.isUndefined()) menuItem->setEnabled(enabled.toBoolean(exec)); if (!checked.isUndefined()) menuItem->setChecked(checked.toBoolean(exec)); items.append(menuItem); } } impl()->showContextMenu(event, items); #endif return jsUndefined(); }
bool ScriptDebugServer::hasBreakpoint(intptr_t sourceID, const TextPosition& position, ScriptBreakpoint *hitBreakpoint) const { if (!m_breakpointsActivated) return false; SourceIdToBreakpointsMap::const_iterator it = m_sourceIdToBreakpoints.find(sourceID); if (it == m_sourceIdToBreakpoints.end()) return false; int line = position.m_line.zeroBasedInt(); int column = position.m_column.zeroBasedInt(); if (line < 0 || column < 0) return false; LineToBreakpointsMap::const_iterator breaksIt = it->value.find(line); if (breaksIt == it->value.end()) return false; bool hit = false; const BreakpointsInLine& breaksVector = breaksIt->value; unsigned breaksCount = breaksVector.size(); unsigned i; for (i = 0; i < breaksCount; i++) { int breakLine = breaksVector.at(i).lineNumber; int breakColumn = breaksVector.at(i).columnNumber; // Since frontend truncates the indent, the first statement in a line must match the breakpoint (line,0). if ((line != m_lastExecutedLine && line == breakLine && !breakColumn) || (line == breakLine && column == breakColumn)) { hit = true; break; } } if (!hit) return false; if (hitBreakpoint) *hitBreakpoint = breaksVector.at(i); // An empty condition counts as no condition which is equivalent to "true". if (breaksVector.at(i).condition.isEmpty()) return true; JSValue exception; JSValue result = DebuggerCallFrame::evaluateWithCallFrame(m_currentCallFrame, breaksVector.at(i).condition, exception); if (exception) { // An erroneous condition counts as "false". reportException(m_currentCallFrame, exception); return false; } return result.toBoolean(m_currentCallFrame); }
void setJSHTMLObjectElementDeclare(ExecState* exec, EncodedJSValue thisValue, EncodedJSValue encodedValue) { JSValue value = JSValue::decode(encodedValue); UNUSED_PARAM(exec); JSHTMLObjectElement* castedThis = jsDynamicCast<JSHTMLObjectElement*>(JSValue::decode(thisValue)); if (!castedThis) { throwVMTypeError(exec); return; } HTMLObjectElement& impl = castedThis->impl(); bool nativeValue(value.toBoolean(exec)); if (exec->hadException()) return; impl.setBooleanAttribute(WebCore::HTMLNames::declareAttr, nativeValue); }
void setJSSVGPathSegArcRelSweepFlag(ExecState* exec, EncodedJSValue thisValue, EncodedJSValue encodedValue) { JSValue value = JSValue::decode(encodedValue); UNUSED_PARAM(exec); JSSVGPathSegArcRel* castedThis = jsDynamicCast<JSSVGPathSegArcRel*>(JSValue::decode(thisValue)); if (!castedThis) { throwVMTypeError(exec); return; } SVGPathSegArcRel& impl = castedThis->impl(); bool nativeValue(value.toBoolean(exec)); if (exec->hadException()) return; impl.setSweepFlag(nativeValue); }
void setJSAudioTrackEnabled(ExecState* exec, EncodedJSValue thisValue, EncodedJSValue encodedValue) { JSValue value = JSValue::decode(encodedValue); UNUSED_PARAM(exec); JSAudioTrack* castedThis = jsDynamicCast<JSAudioTrack*>(JSValue::decode(thisValue)); if (!castedThis) { throwVMTypeError(exec); return; } AudioTrack& impl = castedThis->impl(); bool nativeValue(value.toBoolean(exec)); if (exec->hadException()) return; impl.setEnabled(nativeValue); }
// When an exception occurs, the result of isUnscopable becomes false. static inline bool isUnscopable(ExecState* exec, JSScope* scope, JSObject* object, const Identifier& ident) { VM& vm = exec->vm(); auto throwScope = DECLARE_THROW_SCOPE(vm); if (scope->type() != WithScopeType) return false; JSValue unscopables = object->get(exec, exec->propertyNames().unscopablesSymbol); RETURN_IF_EXCEPTION(throwScope, false); if (!unscopables.isObject()) return false; JSValue blocked = jsCast<JSObject*>(unscopables)->get(exec, ident); RETURN_IF_EXCEPTION(throwScope, false); return blocked.toBoolean(exec); }
// When an exception occurs, the result of isUnscopable becomes false. static inline bool isUnscopable(ExecState* exec, JSScope* scope, JSObject* object, const Identifier& ident) { if (scope->type() != WithScopeType) return false; JSValue unscopables = object->get(exec, exec->propertyNames().unscopablesSymbol); if (exec->hadException()) return false; if (!unscopables.isObject()) return false; JSValue blocked = jsCast<JSObject*>(unscopables)->get(exec, ident); if (exec->hadException()) return false; return blocked.toBoolean(exec); }
void NPRuntimeObjectMap::convertJSValueToNPVariant(ExecState* exec, JSValue value, NPVariant& variant) { JSLock lock(SilenceAssertionsOnly); VOID_TO_NPVARIANT(variant); if (value.isNull()) { NULL_TO_NPVARIANT(variant); return; } if (value.isUndefined()) { VOID_TO_NPVARIANT(variant); return; } if (value.isBoolean()) { BOOLEAN_TO_NPVARIANT(value.toBoolean(exec), variant); return; } if (value.isNumber()) { DOUBLE_TO_NPVARIANT(value.toNumber(exec), variant); return; } if (value.isString()) { CString utf8String = value.toString(exec).utf8(); // This should use NPN_MemAlloc, but we know that it uses malloc under the hood. char* utf8Characters = static_cast<char*>(malloc(utf8String.length())); memcpy(utf8Characters, utf8String.data(), utf8String.length()); STRINGN_TO_NPVARIANT(utf8Characters, utf8String.length(), variant); return; } if (value.isObject()) { NPObject* npObject = getOrCreateNPObject(asObject(value)); OBJECT_TO_NPVARIANT(npObject, variant); return; } ASSERT_NOT_REACHED(); }
// Variant value must be released with NPReleaseVariantValue() void convertValueToNPVariant(ExecState* exec, JSValue value, NPVariant* result) { JSLock lock(SilenceAssertionsOnly); VOID_TO_NPVARIANT(*result); if (value.isString()) { UString ustring = value.toString(exec); CString cstring = ustring.utf8(); NPString string = { (const NPUTF8*)cstring.data(), static_cast<uint32_t>(cstring.length()) }; NPN_InitializeVariantWithStringCopy(result, &string); } else if (value.isNumber()) { DOUBLE_TO_NPVARIANT(value.toNumber(exec), *result); } else if (value.isBoolean()) { BOOLEAN_TO_NPVARIANT(value.toBoolean(exec), *result); } else if (value.isNull()) { NULL_TO_NPVARIANT(*result); } else if (value.isObject()) { JSObject* object = asObject(value); if (object->classInfo() == &CRuntimeObject::s_info) { CRuntimeObject* runtimeObject = static_cast<CRuntimeObject*>(object); CInstance* instance = runtimeObject->getInternalCInstance(); if (instance) { NPObject* obj = instance->getObject(); _NPN_RetainObject(obj); OBJECT_TO_NPVARIANT(obj, *result); } } else { #ifdef ANDROID RootObject* rootObject = findRootObject(exec->dynamicGlobalObject()); if (!rootObject) rootObject = findRootObject(exec->lexicalGlobalObject()); #else JSGlobalObject* globalObject = exec->dynamicGlobalObject(); RootObject* rootObject = findRootObject(globalObject); #endif if (rootObject) { NPObject* npObject = _NPN_CreateScriptObject(0, object, rootObject); OBJECT_TO_NPVARIANT(npObject, *result); } } } }
JSLR_API bool _cdecl JSTryConvertToBooleans(JSContextRef ctx, JSValueRef** value, size_t length, int** indices, bool** result) { auto values = *value; auto res = *result; auto ind = *indices; ExecState* exec = toJS(ctx); for (unsigned int i = 0; i < length; i++) { auto ptr = values[ind[i]]; JSValueRef js_value = *&ptr; JSValue jsValue = toJS(exec, js_value); if (!jsValue.isBoolean()) { return false; } *&res[i] = jsValue.toBoolean(exec); } return true; }
bool JSCustomSQLTransactionErrorCallback::handleEvent(SQLError* error) { ASSERT(m_callback); ASSERT(m_frame); if (!m_frame->script()->isEnabled()) return true; JSGlobalObject* globalObject = m_frame->script()->globalObject(); ExecState* exec = globalObject->globalExec(); JSC::JSLock lock(false); JSValue* function = m_callback->get(exec, Identifier(exec, "handleEvent")); CallData callData; CallType callType = function->getCallData(callData); if (callType == CallTypeNone) { callType = m_callback->getCallData(callData); if (callType == CallTypeNone) { // FIXME: Should an exception be thrown here? return true; } function = m_callback; } RefPtr<JSCustomSQLTransactionErrorCallback> protect(this); ArgList args; args.append(toJS(exec, error)); JSValue *result; globalObject->startTimeoutCheck(); result = call(exec, function, callType, callData, m_callback, args); globalObject->stopTimeoutCheck(); if (exec->hadException()) m_frame->domWindow()->console()->reportCurrentException(exec); Document::updateDocumentsRendering(); return result->toBoolean(exec); }
void NPRuntimeObjectMap::convertJSValueToNPVariant(ExecState* exec, JSValue value, NPVariant& variant) { JSLock lock(SilenceAssertionsOnly); VOID_TO_NPVARIANT(variant); if (value.isNull()) { NULL_TO_NPVARIANT(variant); return; } if (value.isUndefined()) { VOID_TO_NPVARIANT(variant); return; } if (value.isBoolean()) { BOOLEAN_TO_NPVARIANT(value.toBoolean(exec), variant); return; } if (value.isNumber()) { DOUBLE_TO_NPVARIANT(value.toNumber(exec), variant); return; } if (value.isString()) { NPString npString = createNPString(value.toString(exec).utf8()); STRINGN_TO_NPVARIANT(npString.UTF8Characters, npString.UTF8Length, variant); return; } if (value.isObject()) { NPObject* npObject = getOrCreateNPObject(exec->globalData(), asObject(value)); OBJECT_TO_NPVARIANT(npObject, variant); return; } ASSERT_NOT_REACHED(); }
static PassRefPtr<PositionOptions> createPositionOptions(ExecState* exec, JSValue* value) { if (!value->isObject()) return 0; JSObject* object = asObject(value); JSValue* enableHighAccuracyValue = object->get(exec, Identifier(exec, "enableHighAccuracy")); if (exec->hadException()) return 0; bool enableHighAccuracy = enableHighAccuracyValue->toBoolean(exec); if (exec->hadException()) return 0; JSValue* timeoutValue = object->get(exec, Identifier(exec, "timeout")); if (exec->hadException()) return 0; unsigned timeout = timeoutValue->toUInt32(exec); if (exec->hadException()) return 0; return PositionOptions::create(enableHighAccuracy, timeout); }
void setJSHTMLMarqueeElementTrueSpeed(ExecState* exec, JSObject* thisObject, JSValue value) { JSHTMLMarqueeElement* castedThis = static_cast<JSHTMLMarqueeElement*>(thisObject); HTMLMarqueeElement* imp = static_cast<HTMLMarqueeElement*>(castedThis->impl()); imp->setBooleanAttribute(WebCore::HTMLNames::truespeedAttr, value.toBoolean(exec)); }
void setJSHTMLFrameElementNoResize(ExecState* exec, JSObject* thisObject, JSValue value) { JSHTMLFrameElement* castedThis = static_cast<JSHTMLFrameElement*>(thisObject); HTMLFrameElement* imp = static_cast<HTMLFrameElement*>(castedThis->impl()); imp->setBooleanAttribute(WebCore::HTMLNames::noresizeAttr, value.toBoolean(exec)); }
//-------------------------------------------------------------------------- // KJSValueToCFTypeInternal //-------------------------------------------------------------------------- // Caller is responsible for releasing the returned CFTypeRef CFTypeRef KJSValueToCFTypeInternal(JSValue inValue, ExecState *exec, ObjectImpList* inImps) { if (!inValue) return 0; CFTypeRef result = 0; JSGlueAPIEntry entry; if (inValue.isBoolean()) { result = inValue.toBoolean(exec) ? kCFBooleanTrue : kCFBooleanFalse; RetainCFType(result); return result; } if (inValue.isString()) { UString uString = inValue.toString(exec); result = UStringToCFString(uString); return result; } if (inValue.isNumber()) { double number1 = inValue.toNumber(exec); double number2 = (double)inValue.toInteger(exec); if (number1 == number2) { int intValue = (int)number2; result = CFNumberCreate(0, kCFNumberIntType, &intValue); } else { result = CFNumberCreate(0, kCFNumberDoubleType, &number1); } return result; } if (inValue.isObject()) { if (inValue.inherits(&UserObjectImp::info)) { UserObjectImp* userObjectImp = static_cast<UserObjectImp *>(asObject(inValue)); JSUserObject* ptr = userObjectImp->GetJSUserObject(); if (ptr) { result = ptr->CopyCFValue(); } } else { JSObject *object = inValue.toObject(exec); UInt8 isArray = false; // if two objects reference each JSObject* imp = object; ObjectImpList* temp = inImps; while (temp) { if (imp == temp->imp) { return CFRetain(GetCFNull()); } temp = temp->next; } ObjectImpList imps; imps.next = inImps; imps.imp = imp; //[...] HACK since we do not have access to the class info we use class name instead #if 0 if (object->inherits(&ArrayInstanceImp::info)) #else if (object->className() == "Array") #endif { isArray = true; JSGlueGlobalObject* globalObject = static_cast<JSGlueGlobalObject*>(exec->dynamicGlobalObject()); if (globalObject && (globalObject->Flags() & kJSFlagConvertAssociativeArray)) { PropertyNameArray propNames(exec); object->getPropertyNames(exec, propNames); PropertyNameArray::const_iterator iter = propNames.begin(); PropertyNameArray::const_iterator end = propNames.end(); while(iter != end && isArray) { Identifier propName = *iter; UString ustr = propName.ustring(); const UniChar* uniChars = (const UniChar*)ustr.characters(); int size = ustr.length(); while (size--) { if (uniChars[size] < '0' || uniChars[size] > '9') { isArray = false; break; } } iter++; } } } if (isArray) { // This is an KJS array unsigned int length = object->get(exec, Identifier(exec, "length")).toUInt32(exec); result = CFArrayCreateMutable(0, 0, &kCFTypeArrayCallBacks); if (result) { for (unsigned i = 0; i < length; i++) { CFTypeRef cfValue = KJSValueToCFTypeInternal(object->get(exec, i), exec, &imps); CFArrayAppendValue((CFMutableArrayRef)result, cfValue); ReleaseCFType(cfValue); } } } else { // Not an array, just treat it like a dictionary which contains (property name, property value) pairs PropertyNameArray propNames(exec); object->getPropertyNames(exec, propNames); { result = CFDictionaryCreateMutable(0, 0, &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks); if (result) { PropertyNameArray::const_iterator iter = propNames.begin(); PropertyNameArray::const_iterator end = propNames.end(); while(iter != end) { Identifier propName = *iter; if (object->hasProperty(exec, propName)) { CFStringRef cfKey = IdentifierToCFString(propName); CFTypeRef cfValue = KJSValueToCFTypeInternal(object->get(exec, propName), exec, &imps); if (cfKey && cfValue) { CFDictionaryAddValue((CFMutableDictionaryRef)result, cfKey, cfValue); } ReleaseCFType(cfKey); ReleaseCFType(cfValue); } iter++; } } } } } return result; } if (inValue.isUndefinedOrNull()) { result = RetainCFType(GetCFNull()); return result; } ASSERT_NOT_REACHED(); return 0; }
void setJSHTMLUListElementCompact(ExecState* exec, JSObject* thisObject, JSValue value) { JSHTMLUListElement* castedThis = static_cast<JSHTMLUListElement*>(thisObject); HTMLUListElement* imp = static_cast<HTMLUListElement*>(castedThis->impl()); imp->setBooleanAttribute(WebCore::HTMLNames::compactAttr, value.toBoolean(exec)); }
void setRegExpConstructorMultiline(ExecState* exec, JSObject* baseObject, JSValue value) { asRegExpConstructor(baseObject)->setMultiline(value.toBoolean(exec)); }