bool InterposeProperty(JSContext* cx, HandleObject target, const nsIID* iid, HandleId id, MutableHandle<JSPropertyDescriptor> descriptor) { // We only want to do interpostion on DOM instances and // wrapped natives. RootedObject unwrapped(cx, UncheckedUnwrap(target)); const js::Class* clasp = js::GetObjectClass(unwrapped); if (!mozilla::dom::IsDOMClass(clasp) && !IS_WN_CLASS(clasp) && !IS_PROTO_CLASS(clasp) && clasp != &OuterWindowProxyClass) { return true; } XPCWrappedNativeScope* scope = ObjectScope(CurrentGlobalOrNull(cx)); MOZ_ASSERT(scope->HasInterposition()); nsCOMPtr<nsIAddonInterposition> interp = scope->GetInterposition(); JSAddonId* addonId = AddonIdOfObject(target); RootedValue addonIdValue(cx, StringValue(StringOfAddonId(addonId))); RootedValue prop(cx, IdToValue(id)); RootedValue targetValue(cx, ObjectValue(*target)); RootedValue descriptorVal(cx); nsresult rv = interp->InterposeProperty(addonIdValue, targetValue, iid, prop, &descriptorVal); if (NS_FAILED(rv)) { xpc::Throw(cx, rv); return false; } if (!descriptorVal.isObject()) return true; // We need to be careful parsing descriptorVal. |cx| is in the compartment // of the add-on and the descriptor is in the compartment of the // interposition. We could wrap the descriptor in the add-on's compartment // and then parse it. However, parsing the descriptor fetches properties // from it, and we would try to interpose on those property accesses. So // instead we parse in the interposition's compartment and then wrap the // descriptor. { JSAutoCompartment ac(cx, &descriptorVal.toObject()); if (!JS::ObjectToCompletePropertyDescriptor(cx, target, descriptorVal, descriptor)) return false; } // Always make the property non-configurable regardless of what the // interposition wants. descriptor.setAttributes(descriptor.attributes() | JSPROP_PERMANENT); if (!JS_WrapPropertyDescriptor(cx, descriptor)) return false; return true; }
void ScrollAnimator::notifyAnimationTakeover( double monotonicTime, double animationStartTime, std::unique_ptr<cc::AnimationCurve> curve) { // If there is already an animation running and the compositor asks to take // over an animation, do nothing to avoid judder. if (hasRunningAnimation()) return; cc::ScrollOffsetAnimationCurve* scrollOffsetAnimationCurve = curve->ToScrollOffsetAnimationCurve(); ScrollOffset targetValue(scrollOffsetAnimationCurve->target_value().x(), scrollOffsetAnimationCurve->target_value().y()); if (willAnimateToOffset(targetValue)) { m_animationCurve = CompositorScrollOffsetAnimationCurve::create( std::move(scrollOffsetAnimationCurve)); m_startTime = animationStartTime; } }
bool InterposeCall(JSContext* cx, JS::HandleObject target, const JS::CallArgs& args, bool* done) { *done = false; XPCWrappedNativeScope* scope = ObjectScope(CurrentGlobalOrNull(cx)); MOZ_ASSERT(scope->HasInterposition()); nsCOMPtr<nsIAddonInterposition> interp = scope->GetInterposition(); RootedObject unwrappedTarget(cx, UncheckedUnwrap(target)); XPCWrappedNativeScope* targetScope = ObjectScope(unwrappedTarget); bool hasInterpostion = targetScope->HasCallInterposition(); if (!hasInterpostion) return true; // If there is a call interpostion, we don't want to propogate the // call to Base: *done = true; JSAddonId* addonId = AddonIdOfObject(target); RootedValue addonIdValue(cx, StringValue(StringOfAddonId(addonId))); RootedValue targetValue(cx, ObjectValue(*target)); RootedValue thisValue(cx, args.thisv()); RootedObject argsArray(cx, ConvertArgsToArray(cx, args)); if (!argsArray) return false; RootedValue argsVal(cx, ObjectValue(*argsArray)); RootedValue returnVal(cx); nsresult rv = interp->InterposeCall(addonIdValue, targetValue, thisValue, argsVal, args.rval()); if (NS_FAILED(rv)) { xpc::Throw(cx, rv); return false; } return true; }
static void DDTPickCallback(PickAttributes *pickAtts, void *) { const int targetDomain = pickAtts->GetDomain(); const int targetElement = pickAtts->GetElementNumber(); const std::string targetVariable = pickAtts->GetActiveVariable(); char buff[256]; buff[0] = '\0'; for (int i=0; i<pickAtts->GetNumVarInfos(); ++i) { const PickVarInfo &info = pickAtts->GetVarInfo(i); const doubleVector &values = info.GetValues(); // For the active variable only if (info.GetVariableName() == targetVariable) { if (info.GetVariableType() == "scalar" && values.size()==1) { SNPRINTF(buff, 256, info.GetFloatFormat().c_str(), values[0]); } } } std::string targetValue(buff); DDTSession* ddt = DDTManager::getInstance()->getSession(); if (ddt!=NULL) ddt->setFocusOnElement(targetDomain, targetVariable, targetElement, targetValue); else { ViewerBase::GetViewerMessaging()->Error( TR("Cannot focus on domain %1, element %2 of %3: unable to " "connect to DDT"). arg(targetDomain). arg(targetElement). arg(targetVariable)); } }
static bool CheckRegKeyWXP(bool& dmaDisabled, std::vector<std::string>& dmaDisabledlist) { dmaDisabled = false; HKEY hKey; LONG retCode = ERROR_SUCCESS; //HKLM\HARDWARE\DEVICEMAP\Scsi if(ERROR_SUCCESS != RegOpenKeyExA( HKEY_LOCAL_MACHINE, "HARDWARE\\DEVICEMAP\\Scsi", 0, KEY_QUERY_VALUE|KEY_ENUMERATE_SUB_KEYS, &hKey )) return false; char keyBuf[MAX_VALUE_NAME]; DWORD max_path = MAX_VALUE_NAME; retCode = RegEnumKeyExA(hKey, 0, keyBuf, &max_path, 0, 0, 0, 0); if(retCode != ERROR_SUCCESS) { RegCloseKey(hKey); return false; } HKEY hPortKey; for(DWORD nPort=1, retCode=ERROR_SUCCESS; retCode==ERROR_SUCCESS; nPort++) { //HKLM\HARDWARE\DEVICEMAP\Scsi\Scsi Port 0... if( ERROR_SUCCESS == RegOpenKeyExA(hKey, keyBuf, 0, KEY_QUERY_VALUE|KEY_ENUMERATE_SUB_KEYS, &hPortKey) ) { size_t dmaValue = 0; DWORD size = sizeof(DWORD); //DMAEnabled if( ERROR_SUCCESS != RegQueryValueExA(hPortKey, "DMAEnabled", 0, 0, (LPBYTE)&dmaValue, &size) ) { RegCloseKey(hPortKey); RegCloseKey(hKey); return false; } if(dmaValue == 0x0) { dmaDisabled = true; HKEY hBusKey; for(DWORD nBus=0,retCode=ERROR_SUCCESS;retCode==ERROR_SUCCESS;nBus++) { max_path = MAX_VALUE_NAME; keyBuf[0] = '\0'; retCode = RegEnumKeyExA(hPortKey, nBus, keyBuf, &max_path, 0, 0, 0, 0); if( retCode == ERROR_SUCCESS ) { //HKLM\HARDWARE\DEVICEMAP\Scsi\Scsi Port 0\Scsi Bus 0... if( ERROR_SUCCESS == RegOpenKeyExA(hPortKey, keyBuf, 0, KEY_QUERY_VALUE|KEY_ENUMERATE_SUB_KEYS, &hBusKey) ) { HKEY hTargetKey; for(DWORD nTarget=0,retCode=ERROR_SUCCESS;retCode==ERROR_SUCCESS;nTarget++) { max_path = MAX_VALUE_NAME; keyBuf[0] = '\0'; retCode = RegEnumKeyExA(hBusKey, nTarget, keyBuf, &max_path, 0, 0, 0, 0); if( retCode==ERROR_SUCCESS ) { std::string targetValue(keyBuf); if(targetValue.find("Target Id")==std::string::npos) continue; //HKLM\HARDWARE\DEVICEMAP\Scsi\Scsi Port 0\Scsi Bus 0\Target Id 0... targetValue += "\\Logical Unit Id 0"; if( ERROR_SUCCESS == RegOpenKeyExA(hBusKey, targetValue.c_str(), 0, KEY_QUERY_VALUE|KEY_ENUMERATE_SUB_KEYS, &hTargetKey) ) { max_path = MAX_VALUE_NAME; keyBuf[0] = '\0'; retCode = RegQueryValueExA(hTargetKey, "Identifier", 0, 0, (LPBYTE)keyBuf, &max_path); if( retCode==ERROR_SUCCESS ) { dmaDisabledlist.push_back(std::string(keyBuf)); } RegCloseKey(hTargetKey); } } } RegCloseKey(hBusKey); } } } } RegCloseKey(hPortKey); } max_path = MAX_VALUE_NAME; keyBuf[0] = '\0'; retCode = RegEnumKeyExA(hKey, nPort, keyBuf, &max_path, 0, 0, 0, 0); } RegCloseKey(hKey); return true; }