void AudioBufferSourceNode::setBuffer(AudioBuffer* buffer, ExceptionState& exceptionState) { ASSERT(isMainThread()); // The context must be locked since changing the buffer can re-configure the number of channels that are output. AudioContext::AutoLocker contextLocker(context()); // This synchronizes with process(). MutexLocker processLocker(m_processLock); if (buffer) { // Do any necesssary re-configuration to the buffer's number of channels. unsigned numberOfChannels = buffer->numberOfChannels(); if (numberOfChannels > AudioContext::maxNumberOfChannels()) { exceptionState.throwTypeError("number of input channels (" + String::number(numberOfChannels) + ") exceeds maximum (" + String::number(AudioContext::maxNumberOfChannels()) + ")."); return; } output(0)->setNumberOfChannels(numberOfChannels); m_sourceChannels = adoptArrayPtr(new const float* [numberOfChannels]); m_destinationChannels = adoptArrayPtr(new float* [numberOfChannels]); for (unsigned i = 0; i < numberOfChannels; ++i) m_sourceChannels[i] = buffer->getChannelData(i)->data(); } m_virtualReadIndex = 0; m_buffer = buffer; }
bool AudioBufferSourceNode::setBuffer(AudioBuffer* buffer) { ASSERT(isMainThread()); // The context must be locked since changing the buffer can re-configure the number of channels that are output. AudioContext::AutoLocker contextLocker(context()); // This synchronizes with process(). MutexLocker processLocker(m_processLock); if (buffer) { // Do any necesssary re-configuration to the buffer's number of channels. unsigned numberOfChannels = buffer->numberOfChannels(); if (numberOfChannels > AudioContext::maxNumberOfChannels()) return false; output(0)->setNumberOfChannels(numberOfChannels); m_sourceChannels = adoptArrayPtr(new const float* [numberOfChannels]); m_destinationChannels = adoptArrayPtr(new float* [numberOfChannels]); for (unsigned i = 0; i < numberOfChannels; ++i) m_sourceChannels[i] = buffer->getChannelData(i)->data(); } m_virtualReadIndex = 0; m_buffer = buffer; return true; }
bool ANGLEPlatformBridge::compileShaderSource(const char* shaderSource, ANGLEShaderType shaderType, String& translatedShaderSource, String& shaderValidationLog, Vector<ANGLEShaderSymbol>& symbols, int extraCompileOptions) { if (!builtCompilers) { m_fragmentCompiler = ShConstructCompiler(SH_FRAGMENT_SHADER, m_shaderSpec, m_shaderOutput, &m_resources); m_vertexCompiler = ShConstructCompiler(SH_VERTEX_SHADER, m_shaderSpec, m_shaderOutput, &m_resources); if (!m_fragmentCompiler || !m_vertexCompiler) { cleanupCompilers(); return false; } builtCompilers = true; } ShHandle compiler; if (shaderType == SHADER_TYPE_VERTEX) compiler = m_vertexCompiler; else compiler = m_fragmentCompiler; const char* const shaderSourceStrings[] = { shaderSource }; #if ANGLE_SH_VERSION >= 111 bool validateSuccess = ShCompile(compiler, shaderSourceStrings, 1, SH_OBJECT_CODE | SH_VARIABLES | extraCompileOptions); #else bool validateSuccess = ShCompile(compiler, shaderSourceStrings, 1, SH_OBJECT_CODE | SH_ATTRIBUTES_UNIFORMS | extraCompileOptions); #endif if (!validateSuccess) { int logSize = getValidationResultValue(compiler, SH_INFO_LOG_LENGTH); if (logSize > 1) { OwnPtr<char[]> logBuffer = adoptArrayPtr(new char[logSize]); if (logBuffer) { ShGetInfoLog(compiler, logBuffer.get()); shaderValidationLog = logBuffer.get(); } } return false; } int translationLength = getValidationResultValue(compiler, SH_OBJECT_CODE_LENGTH); if (translationLength > 1) { OwnPtr<char[]> translationBuffer = adoptArrayPtr(new char[translationLength]); if (!translationBuffer) return false; ShGetObjectCode(compiler, translationBuffer.get()); translatedShaderSource = translationBuffer.get(); } if (!getSymbolInfo(compiler, SH_ACTIVE_ATTRIBUTES, symbols)) return false; if (!getSymbolInfo(compiler, SH_ACTIVE_UNIFORMS, symbols)) return false; return true; }
SkImageFilter* FEMerge::createImageFilter(SkiaImageFilterBuilder* builder) { unsigned size = numberOfEffectInputs(); OwnArrayPtr<SkAutoTUnref<SkImageFilter> > inputRefs = adoptArrayPtr(new SkAutoTUnref<SkImageFilter>[size]); OwnArrayPtr<SkImageFilter*> inputs = adoptArrayPtr(new SkImageFilter*[size]); for (unsigned i = 0; i < size; ++i) { inputRefs[i].reset(builder->build(inputEffect(i))); inputs[i] = inputRefs[i].get(); } return new SkMergeImageFilter(inputs.get(), size); }
void AudioBufferSourceHandler::setBuffer(AudioBuffer* buffer, ExceptionState& exceptionState) { ASSERT(isMainThread()); if (m_buffer) { exceptionState.throwDOMException( InvalidStateError, "Cannot set buffer after it has been already been set"); return; } // The context must be locked since changing the buffer can re-configure the number of channels that are output. AbstractAudioContext::AutoLocker contextLocker(context()); // This synchronizes with process(). MutexLocker processLocker(m_processLock); if (buffer) { // Do any necesssary re-configuration to the buffer's number of channels. unsigned numberOfChannels = buffer->numberOfChannels(); // This should not be possible since AudioBuffers can't be created with too many channels // either. if (numberOfChannels > AbstractAudioContext::maxNumberOfChannels()) { exceptionState.throwDOMException( NotSupportedError, ExceptionMessages::indexOutsideRange( "number of input channels", numberOfChannels, 1u, ExceptionMessages::InclusiveBound, AbstractAudioContext::maxNumberOfChannels(), ExceptionMessages::InclusiveBound)); return; } output(0).setNumberOfChannels(numberOfChannels); m_sourceChannels = adoptArrayPtr(new const float* [numberOfChannels]); m_destinationChannels = adoptArrayPtr(new float* [numberOfChannels]); for (unsigned i = 0; i < numberOfChannels; ++i) m_sourceChannels[i] = buffer->getChannelData(i)->data(); // If this is a grain (as set by a previous call to start()), validate the grain parameters // now since it wasn't validated when start was called (because there was no buffer then). if (m_isGrain) clampGrainParameters(buffer); } m_virtualReadIndex = 0; m_buffer = buffer; }
PassRefPtr<SkImageFilter> FEMerge::createImageFilter(SkiaImageFilterBuilder& builder) { unsigned size = numberOfEffectInputs(); OwnPtr<RefPtr<SkImageFilter>[]> inputRefs = adoptArrayPtr(new RefPtr<SkImageFilter>[size]); OwnPtr<SkImageFilter*[]> inputs = adoptArrayPtr(new SkImageFilter*[size]); for (unsigned i = 0; i < size; ++i) { inputRefs[i] = builder.build(inputEffect(i), operatingColorSpace()); inputs[i] = inputRefs[i].get(); } SkImageFilter::CropRect rect = getCropRect(builder.cropOffset()); return adoptRef(SkMergeImageFilter::Create(inputs.get(), size, 0, &rect)); }
bool ANGLEWebKitBridge::validateShaderSource(const char* shaderSource, ANGLEShaderType shaderType, String& translatedShaderSource, String& shaderValidationLog) { if (!builtCompilers) { m_fragmentCompiler = ShConstructCompiler(SH_FRAGMENT_SHADER, SH_WEBGL_SPEC, m_shaderOutput, &m_resources); m_vertexCompiler = ShConstructCompiler(SH_VERTEX_SHADER, SH_WEBGL_SPEC, m_shaderOutput, &m_resources); if (!m_fragmentCompiler || !m_vertexCompiler) { cleanupCompilers(); return false; } builtCompilers = true; } ShHandle compiler; if (shaderType == SHADER_TYPE_VERTEX) compiler = m_vertexCompiler; else compiler = m_fragmentCompiler; const char* const shaderSourceStrings[] = { shaderSource }; bool validateSuccess = ShCompile(compiler, shaderSourceStrings, 1, SH_OBJECT_CODE); if (!validateSuccess) { int logSize = 0; ShGetInfo(compiler, SH_INFO_LOG_LENGTH, &logSize); if (logSize > 1) { OwnArrayPtr<char> logBuffer = adoptArrayPtr(new char[logSize]); if (logBuffer) { ShGetInfoLog(compiler, logBuffer.get()); shaderValidationLog = logBuffer.get(); } } return false; } int translationLength = 0; ShGetInfo(compiler, SH_OBJECT_CODE_LENGTH, &translationLength); if (translationLength > 1) { OwnArrayPtr<char> translationBuffer = adoptArrayPtr(new char[translationLength]); if (!translationBuffer) return false; ShGetObjectCode(compiler, translationBuffer.get()); translatedShaderSource = translationBuffer.get(); } return true; }
bool GraphicsContext3D::getActiveUniform(Platform3DObject program, GC3Duint index, ActiveInfo& info) { if (!program) { synthesizeGLError(INVALID_VALUE); return false; } makeContextCurrent(); GLint maxUniformSize = 0; ::glGetProgramiv(program, GL_ACTIVE_UNIFORM_MAX_LENGTH, &maxUniformSize); OwnArrayPtr<GLchar> name = adoptArrayPtr(new GLchar[maxUniformSize]); // GL_ACTIVE_UNIFORM_MAX_LENGTH includes null termination. GLsizei nameLength = 0; GLint size = 0; GLenum type = 0; ::glGetActiveUniform(program, index, maxUniformSize, &nameLength, &size, &type, name.get()); if (!nameLength) return false; info.name = String(name.get(), nameLength); info.type = type; info.size = size; return true; }
// static PassRefPtr<SharedGraphicsContext3D> SharedGraphicsContext3D::create(HostWindow* hostWindow, CreationFlags flags) { GraphicsContext3D::Attributes attr; attr.depth = false; attr.stencil = true; attr.antialias = useLoopBlinnForPathRendering(); attr.canRecoverFromContextLoss = false; // Canvas contexts can not handle lost contexts. RefPtr<GraphicsContext3D> context = GraphicsContext3D::create(attr, hostWindow); if (!context) return 0; OwnPtr<SolidFillShader> solidFillShader = SolidFillShader::create(context.get()); if (!solidFillShader) return 0; OwnPtr<TexShader> texShader = TexShader::create(context.get()); if (!texShader) return 0; OwnPtr<BicubicShader> bicubicShader = BicubicShader::create(context.get()); if (!bicubicShader) return 0; OwnArrayPtr<OwnPtr<ConvolutionShader> > convolutionShaders = adoptArrayPtr(new OwnPtr<ConvolutionShader>[cMaxKernelWidth]); for (int i = 0; i < cMaxKernelWidth; ++i) { convolutionShaders[i] = ConvolutionShader::create(context.get(), i + 1); if (!convolutionShaders[i]) return 0; } return adoptRef(new SharedGraphicsContext3D(context.release(), solidFillShader.release(), texShader.release(), bicubicShader.release(), convolutionShaders.release(), flags)); }
std::string toSTD(WKStringRef string) { size_t bufferSize = WKStringGetMaximumUTF8CStringSize(string); OwnArrayPtr<char> buffer = adoptArrayPtr(new char[bufferSize]); size_t stringLength = WKStringGetUTF8CString(string, buffer.get(), bufferSize); return std::string(buffer.get(), stringLength - 1); }
void ContextMenu::getContextMenuItems(HMENU menu, Vector<ContextMenuItem>& items) { #if OS(WINCE) notImplemented(); #else int count = ::GetMenuItemCount(menu); if (count <= 0) return; for (int i = 0; i < count; ++i) { MENUITEMINFO info = {0}; info.cbSize = sizeof(MENUITEMINFO); info.fMask = MIIM_FTYPE | MIIM_ID | MIIM_STRING | MIIM_STATE | MIIM_SUBMENU; if (!::GetMenuItemInfo(menu, i, TRUE, &info)) continue; if (info.fType == MFT_SEPARATOR) { items.append(ContextMenuItem(SeparatorType, ContextMenuItemTagNoAction, String())); continue; } int menuStringLength = info.cch + 1; OwnArrayPtr<WCHAR> menuString = adoptArrayPtr(new WCHAR[menuStringLength]); info.dwTypeData = menuString.get(); info.cch = menuStringLength; if (::GetMenuItemInfo(menu, i, TRUE, &info)) items.append(ContextMenuItem(info)); } #endif }
bool GraphicsContext3DPrivate::getActiveUniform(Platform3DObject program, GC3Duint index, ActiveInfo& info) { if (!program) { synthesizeGLError(GL_INVALID_VALUE); return false; } makeContextCurrent(); GLint maxNameLength = 0; m_api->glGetProgramiv(program, GL_ACTIVE_UNIFORM_MAX_LENGTH, &maxNameLength); if (!maxNameLength) return false; OwnArrayPtr<char> name = adoptArrayPtr(new char[maxNameLength]); if (!name) { synthesizeGLError(GL_OUT_OF_MEMORY); return false; } GLsizei length = 0; GLint size = 0; GLenum type = 0; m_api->glGetActiveUniform(program, index, maxNameLength, &length, &size, &type, name.get()); if (!length) return false; info.name = String::fromUTF8(name.get(), length); info.type = type; info.size = size; return true; }
bool Arguments::deleteProperty(JSCell* cell, ExecState* exec, const Identifier& propertyName) { Arguments* thisObject = static_cast<Arguments*>(cell); bool isArrayIndex; unsigned i = propertyName.toArrayIndex(isArrayIndex); if (isArrayIndex && i < thisObject->d->numArguments) { if (!thisObject->d->deletedArguments) { thisObject->d->deletedArguments = adoptArrayPtr(new bool[thisObject->d->numArguments]); memset(thisObject->d->deletedArguments.get(), 0, sizeof(bool) * thisObject->d->numArguments); } if (!thisObject->d->deletedArguments[i]) { thisObject->d->deletedArguments[i] = true; return true; } } if (propertyName == exec->propertyNames().length && !thisObject->d->overrodeLength) { thisObject->d->overrodeLength = true; return true; } if (propertyName == exec->propertyNames().callee && !thisObject->d->overrodeCallee) { if (!thisObject->d->isStrictMode) { thisObject->d->overrodeCallee = true; return true; } thisObject->createStrictModeCalleeIfNecessary(exec); } if (propertyName == exec->propertyNames().caller && !thisObject->d->isStrictMode) thisObject->createStrictModeCallerIfNecessary(exec); return JSObject::deleteProperty(thisObject, exec, propertyName); }
void LayerTextureSubImage::uploadWithTexSubImage(const uint8_t* image, const IntRect& imageRect, const IntRect& sourceRect, const IntSize& destOffset, GC3Denum format, WebGraphicsContext3D* context) { TRACE_EVENT0("cc", "LayerTextureSubImage::uploadWithTexSubImage"); // Offset from image-rect to source-rect. IntPoint offset(sourceRect.x() - imageRect.x(), sourceRect.y() - imageRect.y()); const uint8_t* pixelSource; if (imageRect.width() == sourceRect.width() && !offset.x()) pixelSource = &image[4 * offset.y() * imageRect.width()]; else { size_t neededSize = 4 * sourceRect.width() * sourceRect.height(); if (m_subImageSize < neededSize) { m_subImage = adoptArrayPtr(new uint8_t[neededSize]); m_subImageSize = neededSize; } // Strides not equal, so do a row-by-row memcpy from the // paint results into a temp buffer for uploading. for (int row = 0; row < sourceRect.height(); ++row) memcpy(&m_subImage[sourceRect.width() * 4 * row], &image[4 * (offset.x() + (offset.y() + row) * imageRect.width())], sourceRect.width() * 4); pixelSource = &m_subImage[0]; } GLC(context, context->texSubImage2D(GraphicsContext3D::TEXTURE_2D, 0, destOffset.width(), destOffset.height(), sourceRect.width(), sourceRect.height(), format, GraphicsContext3D::UNSIGNED_BYTE, pixelSource)); }
void LayerTextureSubImage::uploadWithTexSubImage(const uint8_t* image, const IntRect& imageRect, const IntRect& sourceRect, const IntRect& destRect, GC3Denum format, GraphicsContext3D* context) { TRACE_EVENT("LayerTextureSubImage::uploadWithTexSubImage", this, 0); if (!m_subImage) m_subImage = adoptArrayPtr(new uint8_t[m_subImageSize.width() * m_subImageSize.height() * 4]); // Offset from image-rect to source-rect. IntPoint offset(sourceRect.x() - imageRect.x(), sourceRect.y() - imageRect.y()); const uint8_t* pixelSource; if (imageRect.width() == sourceRect.width() && !offset.x()) pixelSource = &image[4 * offset.y() * imageRect.width()]; else { // Strides not equal, so do a row-by-row memcpy from the // paint results into a temp buffer for uploading. for (int row = 0; row < destRect.height(); ++row) memcpy(&m_subImage[destRect.width() * 4 * row], &image[4 * (offset.x() + (offset.y() + row) * imageRect.width())], destRect.width() * 4); pixelSource = &m_subImage[0]; } context->texSubImage2D(GraphicsContext3D::TEXTURE_2D, 0, destRect.x(), destRect.y(), destRect.width(), destRect.height(), format, GraphicsContext3D::UNSIGNED_BYTE, pixelSource); }
bool NetscapePluginModule::getPluginInfo(const String& pluginPath, PluginInfoStore::Plugin& plugin) { String pathCopy = pluginPath; DWORD versionInfoSize = ::GetFileVersionInfoSizeW(pathCopy.charactersWithNullTermination(), 0); if (!versionInfoSize) return false; OwnArrayPtr<char> versionInfoData = adoptArrayPtr(new char[versionInfoSize]); if (!::GetFileVersionInfoW(pathCopy.charactersWithNullTermination(), 0, versionInfoSize, versionInfoData.get())) return false; String name = getVersionInfo(versionInfoData.get(), "ProductName"); String description = getVersionInfo(versionInfoData.get(), "FileDescription"); if (name.isNull() || description.isNull()) return false; VS_FIXEDFILEINFO* info; UINT infoSize; if (!::VerQueryValueW(versionInfoData.get(), L"\\", reinterpret_cast<void**>(&info), &infoSize) || infoSize < sizeof(VS_FIXEDFILEINFO)) return false; Vector<String> types; getVersionInfo(versionInfoData.get(), "MIMEType").split('|', types); Vector<String> extensionLists; getVersionInfo(versionInfoData.get(), "FileExtents").split('|', extensionLists); Vector<String> descriptions; getVersionInfo(versionInfoData.get(), "FileOpenName").split('|', descriptions); Vector<MimeClassInfo> mimes(types.size()); for (size_t i = 0; i < types.size(); i++) { String type = types[i].lower(); String description = i < descriptions.size() ? descriptions[i] : ""; String extensionList = i < extensionLists.size() ? extensionLists[i] : ""; Vector<String> extensionsVector; extensionList.split(',', extensionsVector); // Get rid of the extension list that may be at the end of the description string. int pos = description.find("(*"); if (pos != -1) { // There might be a space that we need to get rid of. if (pos > 1 && description[pos - 1] == ' ') pos--; description = description.left(pos); } mimes[i].type = type; mimes[i].desc = description; mimes[i].extensions.swap(extensionsVector); } plugin.path = pluginPath; plugin.info.desc = description; plugin.info.name = name; plugin.info.file = pathGetFileName(pluginPath); plugin.info.mimes.swap(mimes); plugin.fileVersion = fileVersion(info->dwFileVersionLS, info->dwFileVersionMS); return true; }
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()); }
String GraphicsContext3D::getShaderInfoLog(Platform3DObject shader) { ASSERT(shader); makeContextCurrent(); HashMap<Platform3DObject, ShaderSourceEntry>::iterator result = m_shaderSourceMap.find(shader); if (result == m_shaderSourceMap.end()) return String(); ShaderSourceEntry entry = result->second; if (!entry.isValid) return entry.log; GLint length = 0; ::glGetShaderiv(shader, GL_INFO_LOG_LENGTH, &length); if (!length) return String(); GLsizei size = 0; OwnArrayPtr<GLchar> info = adoptArrayPtr(new GLchar[length]); ::glGetShaderInfoLog(shader, length, &size, info.get()); return String(info.get()); }
void GraphicsContext3D::paintRenderingResultsToCanvas(ImageBuffer* imageBuffer, DrawingBuffer*) { int rowBytes = m_currentWidth * 4; int totalBytes = rowBytes * m_currentHeight; OwnArrayPtr<unsigned char> pixels = adoptArrayPtr(new unsigned char[totalBytes]); if (!pixels) return; readRenderingResults(pixels.get(), totalBytes); if (!m_attrs.premultipliedAlpha) { for (int i = 0; i < totalBytes; i += 4) { // Premultiply alpha. pixels[i + 0] = std::min(255, pixels[i + 0] * pixels[i + 3] / 255); pixels[i + 1] = std::min(255, pixels[i + 1] * pixels[i + 3] / 255); pixels[i + 2] = std::min(255, pixels[i + 2] * pixels[i + 3] / 255); } } #if PLATFORM(BLACKBERRY) paintToCanvas(pixels.get(), m_currentWidth, m_currentHeight, imageBuffer->internalSize().width(), imageBuffer->internalSize().height(), imageBuffer->context()); #else paintToCanvas(pixels.get(), m_currentWidth, m_currentHeight, imageBuffer->internalSize().width(), imageBuffer->internalSize().height(), imageBuffer->context()->platformContext()); #endif }
bool Arguments::deleteProperty(ExecState* exec, const Identifier& propertyName) { bool isArrayIndex; unsigned i = propertyName.toArrayIndex(isArrayIndex); if (isArrayIndex && i < d->numArguments) { if (!d->deletedArguments) { d->deletedArguments = adoptArrayPtr(new bool[d->numArguments]); memset(d->deletedArguments.get(), 0, sizeof(bool) * d->numArguments); } if (!d->deletedArguments[i]) { d->deletedArguments[i] = true; return true; } } if (propertyName == exec->propertyNames().length && !d->overrodeLength) { d->overrodeLength = true; return true; } if (propertyName == exec->propertyNames().callee && !d->overrodeCallee) { if (!d->isStrictMode) { d->overrodeCallee = true; return true; } createStrictModeCalleeIfNecessary(exec); } if (propertyName == exec->propertyNames().caller && !d->isStrictMode) createStrictModeCallerIfNecessary(exec); return JSObject::deleteProperty(exec, propertyName); }
static const PassRefPtr<KeyEventInfo> keyPadName(WKStringRef keyRef) { if (WKStringIsEqualToUTF8CString(keyRef, "leftArrow")) return adoptRef(new KeyEventInfo("KP_Left", "")); if (WKStringIsEqualToUTF8CString(keyRef, "rightArrow")) return adoptRef(new KeyEventInfo("KP_Right", "")); if (WKStringIsEqualToUTF8CString(keyRef, "upArrow")) return adoptRef(new KeyEventInfo("KP_Up", "")); if (WKStringIsEqualToUTF8CString(keyRef, "downArrow")) return adoptRef(new KeyEventInfo("KP_Down", "")); if (WKStringIsEqualToUTF8CString(keyRef, "pageUp")) return adoptRef(new KeyEventInfo("KP_Prior", "")); if (WKStringIsEqualToUTF8CString(keyRef, "pageDown")) return adoptRef(new KeyEventInfo("KP_Next", "")); if (WKStringIsEqualToUTF8CString(keyRef, "home")) return adoptRef(new KeyEventInfo("KP_Home", "")); if (WKStringIsEqualToUTF8CString(keyRef, "end")) return adoptRef(new KeyEventInfo("KP_End", "")); if (WKStringIsEqualToUTF8CString(keyRef, "insert")) return adoptRef(new KeyEventInfo("KP_Insert", "")); if (WKStringIsEqualToUTF8CString(keyRef, "delete")) return adoptRef(new KeyEventInfo("KP_Delete", "")); size_t bufferSize = WKStringGetMaximumUTF8CStringSize(keyRef); OwnArrayPtr<char> buffer = adoptArrayPtr(new char[bufferSize]); WKStringGetUTF8CString(keyRef, buffer.get(), bufferSize); return adoptRef(new KeyEventInfo(buffer.get(), buffer.get())); }
void BitmapSkPictureCanvasLayerTextureUpdater::Texture::prepareRect(const IntRect& sourceRect) { size_t bufferSize = TextureManager::memoryUseBytes(sourceRect.size(), texture()->format()); m_pixelData = adoptArrayPtr(new uint8_t[bufferSize]); OwnPtr<SkCanvas> canvas = adoptPtr(new skia::PlatformCanvas(sourceRect.width(), sourceRect.height(), false, m_pixelData.get())); textureUpdater()->paintContentsRect(canvas.get(), sourceRect); }
static inline void initializeWithUserDefault(WTFLogChannel& channel) { DWORD length = GetEnvironmentVariableA(channel.defaultName, 0, 0); if (!length) return; OwnArrayPtr<char> buffer = adoptArrayPtr(new char[length]); if (!GetEnvironmentVariableA(channel.defaultName, buffer.get(), length)) return; String variableValue(buffer.get()); static const String& hexadecimalPrefix = *new String("0x"); if (variableValue.length() < 3 || !variableValue.startsWith(hexadecimalPrefix, false)) { LOG_ERROR("Unable to parse hex value for %s (%s), logging is off", channel.defaultName, buffer.get()); return; } String unprefixedValue = variableValue.substring(2); // Now parse the unprefixed string as a hexadecimal number. bool parsedSuccessfully = false; unsigned logLevel = unprefixedValue.toUIntStrict(&parsedSuccessfully, 16); if (!parsedSuccessfully) { LOG_ERROR("Unable to parse hex value for %s (%s), logging is off", channel.defaultName, buffer.get()); return; } if ((logLevel & channel.mask) == channel.mask) channel.state = WTFLogChannelOn; else channel.state = WTFLogChannelOff; }
inline JSPropertyNameIterator::JSPropertyNameIterator(ExecState* exec, PropertyNameArrayData* propertyNameArrayData, size_t numCacheableSlots) : JSCell(exec->globalData(), exec->globalData().propertyNameIteratorStructure.get()) , m_numCacheableSlots(numCacheableSlots) , m_jsStringsSize(propertyNameArrayData->propertyNameVector().size()) , m_jsStrings(adoptArrayPtr(new WriteBarrier<Unknown>[m_jsStringsSize])) { }
void WindowProxy::createContext() { // Create a new environment using an empty template for the shadow // object. Reuse the global object if one has been created earlier. v8::Handle<v8::ObjectTemplate> globalTemplate = V8Window::getShadowObjectTemplate(m_isolate); if (globalTemplate.IsEmpty()) return; double contextCreationStartInSeconds = currentTime(); // Dynamically tell v8 about our extensions now. const V8Extensions& extensions = ScriptController::registeredExtensions(); OwnPtr<const char*[]> extensionNames = adoptArrayPtr(new const char*[extensions.size()]); int index = 0; for (size_t i = 0; i < extensions.size(); ++i) { extensionNames[index++] = extensions[i]->name(); } v8::ExtensionConfiguration extensionConfiguration(index, extensionNames.get()); v8::Handle<v8::Context> context = v8::Context::New(m_isolate, &extensionConfiguration, globalTemplate, m_global.newLocal(m_isolate)); if (context.IsEmpty()) return; m_scriptState = ScriptState::create(context, m_world); double contextCreationDurationInMilliseconds = (currentTime() - contextCreationStartInSeconds) * 1000; const char* histogramName = "WebCore.WindowProxy.createContext.MainWorld"; if (!m_world->isMainWorld()) histogramName = "WebCore.WindowProxy.createContext.IsolatedWorld"; blink::Platform::current()->histogramCustomCounts(histogramName, contextCreationDurationInMilliseconds, 0, 10000, 50); }
ScriptObject ScriptFunctionCall::construct(bool& hadException, bool reportExceptions) { ScriptScope scope(m_scriptState, reportExceptions); v8::Local<v8::Object> thisObject = m_thisObject.v8Object(); v8::Local<v8::Value> value = thisObject->Get(v8String(m_name)); if (!scope.success()) { hadException = true; return ScriptObject(); } ASSERT(value->IsFunction()); v8::Local<v8::Function> constructor(v8::Function::Cast(*value)); OwnArrayPtr<v8::Handle<v8::Value> > args = adoptArrayPtr(new v8::Handle<v8::Value>[m_arguments.size()]); for (size_t i = 0; i < m_arguments.size(); ++i) args[i] = m_arguments[i].v8Value(); v8::Local<v8::Object> result = SafeAllocation::newInstance(constructor, m_arguments.size(), args.get()); if (!scope.success()) { hadException = true; return ScriptObject(); } return ScriptObject(m_scriptState, result); }
ScriptValue ScriptFunctionCall::call(bool& hadException, bool reportExceptions) { ScriptScope scope(m_scriptState, reportExceptions); v8::Local<v8::Object> thisObject = m_thisObject.v8Object(); v8::Local<v8::Value> value = thisObject->Get(v8String(m_name)); if (!scope.success()) { hadException = true; return ScriptValue(); } ASSERT(value->IsFunction()); v8::Local<v8::Function> function(v8::Function::Cast(*value)); OwnArrayPtr<v8::Handle<v8::Value> > args = adoptArrayPtr(new v8::Handle<v8::Value>[m_arguments.size()]); for (size_t i = 0; i < m_arguments.size(); ++i) args[i] = m_arguments[i].v8Value(); v8::Local<v8::Value> result; { V8RecursionScope innerScope(getScriptExecutionContext()); result = function->Call(thisObject, m_arguments.size(), args.get()); } if (!scope.success()) { hadException = true; return ScriptValue(); } return ScriptValue(result); }
ScriptValue ScriptFunctionCall::call(bool& hadException, bool reportExceptions) { ScriptState::Scope scope(m_scriptState.get()); v8::TryCatch tryCatch; tryCatch.SetVerbose(reportExceptions); v8::Handle<v8::Object> thisObject = m_thisObject.v8Object(); v8::Local<v8::Value> value = thisObject->Get(v8String(m_scriptState->isolate(), m_name)); if (tryCatch.HasCaught()) { hadException = true; return ScriptValue(); } ASSERT(value->IsFunction()); v8::Local<v8::Function> function = v8::Local<v8::Function>::Cast(value); OwnPtr<v8::Handle<v8::Value>[]> info = adoptArrayPtr(new v8::Handle<v8::Value>[m_arguments.size()]); for (size_t i = 0; i < m_arguments.size(); ++i) { info[i] = m_arguments[i].v8Value(); ASSERT(!info[i].IsEmpty()); } v8::Local<v8::Value> result = V8ScriptRunner::callFunction(function, currentExecutionContext(m_scriptState->isolate()), thisObject, m_arguments.size(), info.get(), m_scriptState->isolate()); if (tryCatch.HasCaught()) { hadException = true; return ScriptValue(); } return ScriptValue(m_scriptState.get(), result); }
ScriptObject ScriptFunctionCall::construct(bool& hadException, bool reportExceptions) { ScriptState::Scope scope(m_scriptState.get()); v8::TryCatch tryCatch; tryCatch.SetVerbose(reportExceptions); v8::Handle<v8::Object> thisObject = m_thisObject.v8Object(); v8::Local<v8::Value> value = thisObject->Get(v8String(m_scriptState->isolate(), m_name)); if (tryCatch.HasCaught()) { hadException = true; return ScriptObject(); } ASSERT(value->IsFunction()); v8::Local<v8::Function> constructor = v8::Local<v8::Function>::Cast(value); OwnPtr<v8::Handle<v8::Value>[]> info = adoptArrayPtr(new v8::Handle<v8::Value>[m_arguments.size()]); for (size_t i = 0; i < m_arguments.size(); ++i) info[i] = m_arguments[i].v8Value(); v8::Local<v8::Object> result = V8ObjectConstructor::newInstance(m_scriptState->isolate(), constructor, m_arguments.size(), info.get()); if (tryCatch.HasCaught()) { hadException = true; return ScriptObject(); } return ScriptObject(m_scriptState.get(), result); }
static Vector<OwnArrayPtr<char>> createArgsArray(const String& prefix, const String& executablePath, const String& socket, const String& pluginPath) { ASSERT(!executablePath.isEmpty()); ASSERT(!socket.isEmpty()); Vector<String> splitArgs; prefix.split(' ', splitArgs); splitArgs.append(executablePath); splitArgs.append(socket); if (!pluginPath.isEmpty()) splitArgs.append(pluginPath); Vector<OwnArrayPtr<char>> args; args.resize(splitArgs.size() + 1); // Extra room for null. size_t numArgs = splitArgs.size(); for (size_t i = 0; i < numArgs; ++i) { CString param = splitArgs[i].utf8(); args[i] = adoptArrayPtr(new char[param.length() + 1]); // Room for the terminating null coming from the CString. strncpy(args[i].get(), param.data(), param.length() + 1); // +1 here so that strncpy copies the ending null. } // execvp() needs the pointers' array to be null-terminated. args[numArgs] = nullptr; return args; }