void IDBOpenDBRequest::onSuccess(PassOwnPtr<WebIDBDatabase> backend, const IDBDatabaseMetadata& metadata) { IDB_TRACE("IDBOpenDBRequest::onSuccess()"); if (m_contextStopped || !executionContext()) { OwnPtr<WebIDBDatabase> db = backend; if (db) db->close(); return; } if (!shouldEnqueueEvent()) return; IDBDatabase* idbDatabase = nullptr; if (resultAsAny()) { // Previous onUpgradeNeeded call delivered the backend. ASSERT(!backend.get()); idbDatabase = resultAsAny()->idbDatabase(); ASSERT(idbDatabase); ASSERT(!m_databaseCallbacks); } else { ASSERT(backend.get()); ASSERT(m_databaseCallbacks); idbDatabase = IDBDatabase::create(executionContext(), backend, m_databaseCallbacks.release()); setResult(IDBAny::create(idbDatabase)); } idbDatabase->setMetadata(metadata); enqueueEvent(Event::create(EventTypeNames::success)); }
WebSocketChannel::SendResult MainThreadWebSocketChannel::send(PassOwnPtr<Vector<char> > data) { WTF_LOG(Network, "MainThreadWebSocketChannel %p send() Sending Vector %p", this, data.get()); enqueueVector(WebSocketFrame::OpCodeBinary, data); processOutgoingFrameQueue(); return WebSocketChannel::SendSuccess; }
void ScrollingTree::commitNewTreeState(PassOwnPtr<ScrollingStateTree> scrollingStateTree) { ASSERT(ScrollingThread::isCurrentThread()); bool rootStateNodeChanged = scrollingStateTree->hasNewRootStateNode(); ScrollingStateScrollingNode* rootNode = scrollingStateTree->rootStateNode(); if (rootNode && (rootStateNodeChanged || rootNode->hasChangedProperty(ScrollingStateScrollingNode::WheelEventHandlerCount) || rootNode->hasChangedProperty(ScrollingStateScrollingNode::NonFastScrollableRegion) || rootNode->hasChangedProperty(ScrollingStateNode::ScrollLayer))) { MutexLocker lock(m_mutex); if (rootStateNodeChanged || rootNode->hasChangedProperty(ScrollingStateNode::ScrollLayer)) m_mainFrameScrollPosition = IntPoint(); if (rootStateNodeChanged || rootNode->hasChangedProperty(ScrollingStateScrollingNode::WheelEventHandlerCount)) m_hasWheelEventHandlers = scrollingStateTree->rootStateNode()->wheelEventHandlerCount(); if (rootStateNodeChanged || rootNode->hasChangedProperty(ScrollingStateScrollingNode::NonFastScrollableRegion)) m_nonFastScrollableRegion = scrollingStateTree->rootStateNode()->nonFastScrollableRegion(); } bool scrollRequestIsProgammatic = rootNode ? rootNode->requestedScrollPositionRepresentsProgrammaticScroll() : false; TemporaryChange<bool> changeHandlingProgrammaticScroll(m_isHandlingProgrammaticScroll, scrollRequestIsProgammatic); removeDestroyedNodes(scrollingStateTree.get()); updateTreeFromStateNode(rootNode); }
DiscardablePixelRef::DiscardablePixelRef(const SkImageInfo& info, size_t rowBytes, PassOwnPtr<SkMutex> mutex) : SkPixelRef(info, mutex.get()) , m_lockedMemory(0) , m_mutex(mutex) , m_rowBytes(rowBytes) { }
void DOMWrapperWorld::registerDOMObjectHolderInternal(PassOwnPtr<DOMObjectHolderBase> holderBase) { ASSERT(!m_domObjectHolders.contains(holderBase.get())); holderBase->setWorld(this); holderBase->setWeak(&DOMWrapperWorld::weakCallbackForDOMObjectHolder); m_domObjectHolders.add(holderBase); }
PassOwnPtr<AsyncFileWriter> WorkerPlatformAsyncFileSystemCallbacks::createAsyncFileWriter(PassOwnPtr<BlackBerry::Platform::WebFileWriter> platformWriter) { ASSERT(m_writerClient); BlackBerry::Platform::WebFileWriter* platformWriterPtr = platformWriter.get(); OwnPtr<WorkerAsyncFileWriterBlackBerry> writer = WorkerAsyncFileWriterBlackBerry::create(m_context, m_mode, platformWriter, m_writerClient); platformWriterPtr->setClient(writer->platformWriterClient()); return writer.release(); }
static PassRefPtr<DrawingBufferForTests> create(PassOwnPtr<WebGraphicsContext3D> context, const IntSize& size, PreserveDrawingBuffer preserve) { OwnPtr<Extensions3DUtil> extensionsUtil = Extensions3DUtil::create(context.get()); RefPtr<DrawingBufferForTests> drawingBuffer = adoptRef(new DrawingBufferForTests(context, extensionsUtil.release(), preserve)); if (!drawingBuffer->initialize(size)) { drawingBuffer->beginDestruction(); return PassRefPtr<DrawingBufferForTests>(); } return drawingBuffer.release(); }
void ScrollingTree::commitNewTreeState(PassOwnPtr<ScrollingTreeState> scrollingTreeState) { ASSERT(ScrollingThread::isCurrentThread()); if (scrollingTreeState->changedProperties() & ScrollingTreeState::WheelEventHandlerCount) { MutexLocker lock(m_mutex); m_hasWheelEventHandlers = scrollingTreeState->wheelEventHandlerCount(); } m_rootNode->update(scrollingTreeState.get()); }
void MainThreadTaskRunner::perform(PassOwnPtr<ExecutionContextTask> task, bool isInspectorTask) { if (!isInspectorTask && (m_context->tasksNeedSuspension() || !m_pendingTasks.isEmpty())) { m_pendingTasks.append(task); return; } const bool instrumenting = !isInspectorTask && !task->taskNameForInstrumentation().isEmpty(); if (instrumenting) InspectorInstrumentation::willPerformExecutionContextTask(m_context, task.get()); task->performTask(m_context); if (instrumenting) InspectorInstrumentation::didPerformExecutionContextTask(m_context); }
void WebWorkerClientImpl::postMessageToWorkerContextTask(ScriptExecutionContext* context, WebWorkerClientImpl* thisPtr, const String& message, PassOwnPtr<MessagePortChannelArray> channels) { WebMessagePortChannelArray webChannels(channels.get() ? channels->size() : 0); for (size_t i = 0; i < webChannels.size(); ++i) { webChannels[i] = (*channels)[i]->channel()->webChannelRelease(); webChannels[i]->setClient(0); } thisPtr->m_webWorker->postMessageToWorkerContext(message, webChannels); }
void CCThreadProxy::beginFrameAndCommit(int sequenceNumber, double frameBeginTime, PassOwnPtr<CCScrollUpdateSet> scrollInfo) { TRACE_EVENT("CCThreadProxy::beginFrameAndCommit", this, 0); ASSERT(isMainThread()); if (!m_layerTreeHost) return; // Scroll deltas need to be applied even if the commit will be dropped. m_layerTreeHost->applyScrollDeltas(*scrollInfo.get()); // Drop beginFrameAndCommit calls that occur out of sequence. See createBeginFrameAndCommitTaskOnImplThread for // an explanation of how out-of-sequence beginFrameAndCommit tasks can occur. if (sequenceNumber < m_lastExecutedBeginFrameAndCommitSequenceNumber) { TRACE_EVENT("EarlyOut_StaleBeginFrameAndCommit", this, 0); return; } m_lastExecutedBeginFrameAndCommitSequenceNumber = sequenceNumber; // FIXME: recreate the context if it was requested by the impl thread { TRACE_EVENT("CCLayerTreeHost::animateAndLayout", this, 0); m_layerTreeHost->animateAndLayout(frameBeginTime); } ASSERT(m_lastExecutedBeginFrameAndCommitSequenceNumber == sequenceNumber); // Clear the commit flag after animateAndLayout here --- objects that only // layout when painted will trigger another setNeedsCommit inside // updateLayers. m_commitRequested = false; m_layerTreeHost->updateLayers(); { // Blocking call to CCThreadProxy::commitOnImplThread TRACE_EVENT("commit", this, 0); CCCompletionEvent completion; s_ccThread->postTask(createCCThreadTask(this, &CCThreadProxy::commitOnImplThread, AllowCrossThreadAccess(&completion))); completion.wait(); } m_layerTreeHost->commitComplete(); if (m_redrawAfterCommit) setNeedsRedraw(); m_redrawAfterCommit = false; ASSERT(m_lastExecutedBeginFrameAndCommitSequenceNumber == sequenceNumber); }
void WebWorkerBase::postMessageTask(ScriptExecutionContext* context, WebWorkerBase* thisPtr, String message, PassOwnPtr<MessagePortChannelArray> channels) { if (!thisPtr->client()) return; WebMessagePortChannelArray webChannels(channels.get() ? channels->size() : 0); for (size_t i = 0; i < webChannels.size(); ++i) { webChannels[i] = (*channels)[i]->channel()->webChannelRelease(); webChannels[i]->setClient(0); } thisPtr->client()->postMessageToWorkerObject(message, webChannels); }
void HTMLResourcePreloader::preload(PassOwnPtr<PreloadRequest> preload) { if (preload->isPreconnect()) { preconnectHost(preload.get()); return; } // TODO(yoichio): Should preload if document is imported. if (!m_document->loader()) return; FetchRequest request = preload->resourceRequest(m_document); // TODO(dgozman): This check should go to HTMLPreloadScanner, but this requires // making Document::completeURLWithOverride logic to be statically accessible. if (request.url().protocolIsData()) return; if (preload->resourceType() == Resource::Script || preload->resourceType() == Resource::CSSStyleSheet || preload->resourceType() == Resource::ImportResource) request.setCharset(preload->charset().isEmpty() ? m_document->charset().string() : preload->charset()); request.setForPreload(true); Platform::current()->histogramCustomCounts("WebCore.PreloadDelayMs", static_cast<int>(1000 * (monotonicallyIncreasingTime() - preload->discoveryTime())), 0, 2000, 20); m_document->loader()->startPreload(preload->resourceType(), request); }
void ScrollingTree::commitNewTreeState(PassOwnPtr<ScrollingStateTree> scrollingStateTree) { ASSERT(ScrollingThread::isCurrentThread()); if (scrollingStateTree->rootStateNode()->changedProperties() & (ScrollingStateScrollingNode::WheelEventHandlerCount | ScrollingStateScrollingNode::NonFastScrollableRegion) || scrollingStateTree->rootStateNode()->scrollLayerDidChange()) { MutexLocker lock(m_mutex); if (scrollingStateTree->rootStateNode()->scrollLayerDidChange()) m_mainFrameScrollPosition = IntPoint(); if (scrollingStateTree->rootStateNode()->changedProperties() & ScrollingStateScrollingNode::WheelEventHandlerCount) m_hasWheelEventHandlers = scrollingStateTree->rootStateNode()->wheelEventHandlerCount(); if (scrollingStateTree->rootStateNode()->changedProperties() & ScrollingStateScrollingNode::NonFastScrollableRegion) m_nonFastScrollableRegion = scrollingStateTree->rootStateNode()->nonFastScrollableRegion(); } TemporaryChange<bool> changeHandlingProgrammaticScroll(m_isHandlingProgrammaticScroll, scrollingStateTree->rootStateNode()->requestedScrollPositionRepresentsProgrammaticScroll()); removeDestroyedNodes(scrollingStateTree.get()); updateTreeFromStateNode(scrollingStateTree->rootStateNode()); }
void InspectorConsoleAgent::addConsoleMessage(PassOwnPtr<ConsoleMessage> consoleMessage) { ASSERT_ARG(consoleMessage, consoleMessage); if (m_previousMessage && !isGroupMessage(m_previousMessage->type()) && m_previousMessage->isEqual(consoleMessage.get())) { m_previousMessage->incrementCount(); if (m_frontend && m_enabled) m_previousMessage->updateRepeatCountInConsole(m_frontend); } else { m_previousMessage = consoleMessage.get(); m_consoleMessages.append(consoleMessage); if (m_frontend && m_enabled) m_previousMessage->addToFrontend(m_frontend, m_injectedScriptManager, true); } if (!m_frontend && m_consoleMessages.size() >= maximumConsoleMessages) { m_expiredConsoleMessageCount += expireConsoleMessagesStep; m_consoleMessages.remove(0, expireConsoleMessagesStep); } }
void ImageDecodingStore::insertCacheInternal(PassOwnPtr<CacheEntry> cacheEntry) { if (!cacheEntry->isDiscardable()) incrementMemoryUsage(cacheEntry->memoryUsageInBytes()); TRACE_COUNTER1("webkit", "ImageDecodingStoreMemoryUsageBytes", m_memoryUsageInBytes); // m_orderedCacheList is used to support LRU operations to reorder cache // entries quickly. m_orderedCacheList.append(cacheEntry.get()); CacheIdentifier key = cacheEntry->cacheKey(); // m_cacheMap is used for indexing and quick lookup of a cached image. It owns // all cache entries. m_cacheMap.add(key, cacheEntry); TRACE_COUNTER1("webkit", "ImageDecodingStoreNumOfEntries", m_cacheMap.size()); // m_cachedSizeMap keeps all scaled sizes associated with an ImageFrameGenerator. CachedSizeMap::AddResult result = m_cachedSizeMap.add(key.first, SizeSet()); result.iterator->value.add(key.second); }
void ScrollingTree::commitNewTreeState(PassOwnPtr<ScrollingTreeState> scrollingTreeState) { ASSERT(ScrollingThread::isCurrentThread()); if (scrollingTreeState->changedProperties() & (ScrollingTreeState::WheelEventHandlerCount | ScrollingTreeState::NonFastScrollableRegion | ScrollingTreeState::ScrollLayer)) { MutexLocker lock(m_mutex); if (scrollingTreeState->changedProperties() & ScrollingTreeState::ScrollLayer) m_mainFrameScrollPosition = IntPoint(); if (scrollingTreeState->changedProperties() & ScrollingTreeState::WheelEventHandlerCount) m_hasWheelEventHandlers = scrollingTreeState->wheelEventHandlerCount(); if (scrollingTreeState->changedProperties() & ScrollingTreeState::NonFastScrollableRegion) m_nonFastScrollableRegion = scrollingTreeState->nonFastScrollableRegion(); } TemporaryChange<bool> changeHandlingProgrammaticScroll(m_isHandlingProgrammaticScroll, scrollingTreeState->requestedScrollPositionRepresentsProgrammaticScroll()); m_rootNode->update(scrollingTreeState.get()); updateDebugRootLayer(); }
void HTMLResourcePreloader::preload(PassOwnPtr<PreloadRequest> preload, const NetworkHintsInterface& networkHintsInterface) { if (preload->isPreconnect()) { preconnectHost(preload.get(), networkHintsInterface); return; } // TODO(yoichio): Should preload if document is imported. if (!m_document->loader()) return; FetchRequest request = preload->resourceRequest(m_document); // TODO(dgozman): This check should go to HTMLPreloadScanner, but this requires // making Document::completeURLWithOverride logic to be statically accessible. if (request.url().protocolIsData()) return; if (preload->resourceType() == Resource::Script || preload->resourceType() == Resource::CSSStyleSheet || preload->resourceType() == Resource::ImportResource) request.setCharset(preload->charset().isEmpty() ? m_document->characterSet().getString() : preload->charset()); request.setForPreload(true); int duration = static_cast<int>(1000 * (monotonicallyIncreasingTime() - preload->discoveryTime())); DEFINE_STATIC_LOCAL(CustomCountHistogram, preloadDelayHistogram, ("WebCore.PreloadDelayMs", 0, 2000, 20)); preloadDelayHistogram.count(duration); m_document->loader()->startPreload(preload->resourceType(), request); }
void ImageDecodingStore::insertCacheInternal(PassOwnPtr<T> cacheEntry, U* cacheMap, V* identifierMap) { const size_t cacheEntryBytes = cacheEntry->memoryUsageInBytes(); if (cacheEntry->isDiscardable()) m_discardableMemoryUsageInBytes += cacheEntryBytes; else m_heapMemoryUsageInBytes += cacheEntryBytes; // m_orderedCacheList is used to support LRU operations to reorder cache // entries quickly. m_orderedCacheList.append(cacheEntry.get()); typename U::KeyType key = cacheEntry->cacheKey(); typename V::AddResult result = identifierMap->add(cacheEntry->generator(), typename V::MappedType()); result.storedValue->value.add(key); cacheMap->add(key, cacheEntry); TRACE_COUNTER1("webkit", "ImageDecodingStoreDiscardableMemoryUsageBytes", m_discardableMemoryUsageInBytes); TRACE_COUNTER1("webkit", "ImageDecodingStoreHeapMemoryUsageBytes", m_heapMemoryUsageInBytes); TRACE_COUNTER1("webkit", "ImageDecodingStoreNumOfImages", m_imageCacheMap.size()); TRACE_COUNTER1("webkit", "ImageDecodingStoreNumOfDecoders", m_decoderCacheMap.size()); }
void WebWorkerClientImpl::postMessageToWorkerContext( PassRefPtr<SerializedScriptValue> message, PassOwnPtr<MessagePortChannelArray> channels) { // Worker.terminate() could be called from JS before the context is started. if (m_askedToTerminate) return; ++m_unconfirmedMessageCount; if (!isMainThread()) { WebWorkerBase::dispatchTaskToMainThread(createCallbackTask(&postMessageToWorkerContextTask, AllowCrossThreadAccess(this), message->toWireString(), channels)); return; } WebMessagePortChannelArray webChannels(channels.get() ? channels->size() : 0); for (size_t i = 0; i < webChannels.size(); ++i) { WebMessagePortChannel* webchannel = (*channels)[i]->channel()->webChannelRelease(); webchannel->setClient(0); webChannels[i] = webchannel; } m_webWorker->postMessageToWorkerContext(message->toWireString(), webChannels); }
PassOwnPtr<GraphicsContext3DSwapBuffersCompleteCallbackAdapter> GraphicsContext3DSwapBuffersCompleteCallbackAdapter::create(PassOwnPtr<Extensions3DChromium::SwapBuffersCompleteCallbackCHROMIUM> cb) { return adoptPtr(cb.get() ? new GraphicsContext3DSwapBuffersCompleteCallbackAdapter(cb) : 0); }
void MainThreadTaskRunner::postTask(const WebTraceLocation& location, PassOwnPtr<ExecutionContextTask> task) { if (!task->taskNameForInstrumentation().isEmpty()) InspectorInstrumentation::didPostExecutionContextTask(m_context, task.get()); Platform::current()->mainThread()->taskRunner()->postTask(location, new MainThreadTask(createWeakPointerToSelf(), task, false)); }
void start(PassOwnPtr<FetchDataConsumerHandle> handle) { m_loader->start(handle.get(), this); }
void InspectorInputAgent::dispatchTouchEvent(ErrorString* error, const String& type, PassOwnPtr<protocol::Array<protocol::Input::TouchPoint>> touchPoints, const protocol::Maybe<int>& modifiers, const protocol::Maybe<double>& timestamp) { PlatformEvent::Type convertedType; if (type == "touchStart") { convertedType = PlatformEvent::TouchStart; } else if (type == "touchEnd") { convertedType = PlatformEvent::TouchEnd; } else if (type == "touchMove") { convertedType = PlatformEvent::TouchMove; } else { *error = "Unrecognized type: " + type; return; } unsigned convertedModifiers = GetEventModifiers(modifiers.fromMaybe(0)); SyntheticInspectorTouchEvent event(convertedType, convertedModifiers, timestamp.fromMaybe(currentTime())); int autoId = 0; for (size_t i = 0; i < touchPoints->length(); ++i) { protocol::Input::TouchPoint* point = touchPoints->get(i); int radiusX = point->getRadiusX(1); int radiusY = point->getRadiusY(1); double rotationAngle = point->getRotationAngle(0.0); double force = point->getForce(1.0); int id; if (point->hasId()) { if (autoId > 0) id = -1; else id = point->getId(0); autoId = -1; } else { id = autoId++; } if (id < 0) { *error = "All or none of the provided TouchPoints must supply positive integer ids."; return; } PlatformTouchPoint::State convertedState; String state = point->getState(); if (state == "touchPressed") { convertedState = PlatformTouchPoint::TouchPressed; } else if (state == "touchReleased") { convertedState = PlatformTouchPoint::TouchReleased; } else if (state == "touchMoved") { convertedState = PlatformTouchPoint::TouchMoved; } else if (state == "touchStationary") { convertedState = PlatformTouchPoint::TouchStationary; } else if (state == "touchCancelled") { convertedState = PlatformTouchPoint::TouchCancelled; } else { *error = "Unrecognized state: " + state; return; } // Some platforms may have flipped coordinate systems, but the given coordinates // assume the origin is in the top-left of the window. Convert. IntPoint convertedPoint, globalPoint; ConvertInspectorPoint(m_inspectedFrames->root(), IntPoint(point->getX(), point->getY()), &convertedPoint, &globalPoint); SyntheticInspectorTouchPoint touchPoint(id++, convertedState, globalPoint, convertedPoint, radiusX, radiusY, rotationAngle, force); event.append(touchPoint); } m_inspectedFrames->root()->eventHandler().handleTouchEvent(event); }
PassOwnPtr<WebCore::ContextMenu> ContextMenuClientImpl::customizeMenu(PassOwnPtr<WebCore::ContextMenu> defaultMenu) { // Displaying the context menu in this function is a big hack as we don't // have context, i.e. whether this is being invoked via a script or in // response to user input (Mouse event WM_RBUTTONDOWN, // Keyboard events KeyVK_APPS, Shift+F10). Check if this is being invoked // in response to the above input events before popping up the context menu. if (!m_webView->contextMenuAllowed()) return defaultMenu; HitTestResult r = m_webView->page()->contextMenuController()->hitTestResult(); Frame* selectedFrame = r.innerNodeFrame(); WebContextMenuData data; data.mousePosition = selectedFrame->view()->contentsToWindow(r.roundedPointInInnerNodeFrame()); // Compute edit flags. data.editFlags = WebContextMenuData::CanDoNone; if (m_webView->focusedWebCoreFrame()->editor()->canUndo()) data.editFlags |= WebContextMenuData::CanUndo; if (m_webView->focusedWebCoreFrame()->editor()->canRedo()) data.editFlags |= WebContextMenuData::CanRedo; if (m_webView->focusedWebCoreFrame()->editor()->canCut()) data.editFlags |= WebContextMenuData::CanCut; if (m_webView->focusedWebCoreFrame()->editor()->canCopy()) data.editFlags |= WebContextMenuData::CanCopy; if (m_webView->focusedWebCoreFrame()->editor()->canPaste()) data.editFlags |= WebContextMenuData::CanPaste; if (m_webView->focusedWebCoreFrame()->editor()->canDelete()) data.editFlags |= WebContextMenuData::CanDelete; // We can always select all... data.editFlags |= WebContextMenuData::CanSelectAll; data.editFlags |= WebContextMenuData::CanTranslate; // Links, Images, Media tags, and Image/Media-Links take preference over // all else. data.linkURL = r.absoluteLinkURL(); if (!r.absoluteImageURL().isEmpty()) { data.srcURL = r.absoluteImageURL(); data.mediaType = WebContextMenuData::MediaTypeImage; } else if (!r.absoluteMediaURL().isEmpty()) { data.srcURL = r.absoluteMediaURL(); // We know that if absoluteMediaURL() is not empty, then this // is a media element. HTMLMediaElement* mediaElement = toMediaElement(r.innerNonSharedNode()); if (mediaElement->hasTagName(HTMLNames::videoTag)) data.mediaType = WebContextMenuData::MediaTypeVideo; else if (mediaElement->hasTagName(HTMLNames::audioTag)) data.mediaType = WebContextMenuData::MediaTypeAudio; if (mediaElement->error()) data.mediaFlags |= WebContextMenuData::MediaInError; if (mediaElement->paused()) data.mediaFlags |= WebContextMenuData::MediaPaused; if (mediaElement->muted()) data.mediaFlags |= WebContextMenuData::MediaMuted; if (mediaElement->loop()) data.mediaFlags |= WebContextMenuData::MediaLoop; if (mediaElement->supportsSave()) data.mediaFlags |= WebContextMenuData::MediaCanSave; if (mediaElement->hasAudio()) data.mediaFlags |= WebContextMenuData::MediaHasAudio; if (mediaElement->hasVideo()) data.mediaFlags |= WebContextMenuData::MediaHasVideo; if (mediaElement->controls()) data.mediaFlags |= WebContextMenuData::MediaControls; } else if (r.innerNonSharedNode()->hasTagName(HTMLNames::objectTag) || r.innerNonSharedNode()->hasTagName(HTMLNames::embedTag)) { RenderObject* object = r.innerNonSharedNode()->renderer(); if (object && object->isWidget()) { Widget* widget = toRenderWidget(object)->widget(); if (widget && widget->isPluginContainer()) { data.mediaType = WebContextMenuData::MediaTypePlugin; WebPluginContainerImpl* plugin = static_cast<WebPluginContainerImpl*>(widget); WebString text = plugin->plugin()->selectionAsText(); if (!text.isEmpty()) { data.selectedText = text; data.editFlags |= WebContextMenuData::CanCopy; } data.editFlags &= ~WebContextMenuData::CanTranslate; data.linkURL = plugin->plugin()->linkAtPosition(data.mousePosition); if (plugin->plugin()->supportsPaginatedPrint()) data.mediaFlags |= WebContextMenuData::MediaCanPrint; HTMLPlugInImageElement* pluginElement = toHTMLPlugInImageElement(r.innerNonSharedNode()); data.srcURL = pluginElement->document()->completeURL(pluginElement->url()); data.mediaFlags |= WebContextMenuData::MediaCanSave; // Add context menu commands that are supported by the plugin. if (plugin->plugin()->canRotateView()) data.mediaFlags |= WebContextMenuData::MediaCanRotate; } } } data.isImageBlocked = (data.mediaType == WebContextMenuData::MediaTypeImage) && !r.image(); // If it's not a link, an image, a media element, or an image/media link, // show a selection menu or a more generic page menu. if (selectedFrame->document()->loader()) data.frameEncoding = selectedFrame->document()->encoding(); // Send the frame and page URLs in any case. data.pageURL = urlFromFrame(m_webView->mainFrameImpl()->frame()); if (selectedFrame != m_webView->mainFrameImpl()->frame()) { data.frameURL = urlFromFrame(selectedFrame); RefPtr<HistoryItem> historyItem = selectedFrame->loader()->history()->currentItem(); if (historyItem) data.frameHistoryItem = WebHistoryItem(historyItem); } if (r.isSelected()) { if (!r.innerNonSharedNode()->hasTagName(HTMLNames::inputTag) || !static_cast<HTMLInputElement*>(r.innerNonSharedNode())->isPasswordField()) data.selectedText = selectedFrame->editor()->selectedText().stripWhiteSpace(); } if (r.isContentEditable()) { data.isEditable = true; #if ENABLE(INPUT_SPEECH) if (r.innerNonSharedNode()->hasTagName(HTMLNames::inputTag)) { data.isSpeechInputEnabled = static_cast<HTMLInputElement*>(r.innerNonSharedNode())->isSpeechEnabled(); } #endif // When Chrome enables asynchronous spellchecking, its spellchecker adds spelling markers to misspelled // words and attaches suggestions to these markers in the background. Therefore, when a user right-clicks // a mouse on a word, Chrome just needs to find a spelling marker on the word instead of spellchecking it. if (selectedFrame->settings() && selectedFrame->settings()->asynchronousSpellCheckingEnabled()) { DocumentMarker marker; data.misspelledWord = selectMisspellingAsync(selectedFrame, marker); if (marker.description().length()) { Vector<String> suggestions; marker.description().split('\n', suggestions); data.dictionarySuggestions = suggestions; } else if (m_webView->spellCheckClient()) { int misspelledOffset, misspelledLength; m_webView->spellCheckClient()->spellCheck(data.misspelledWord, misspelledOffset, misspelledLength, &data.dictionarySuggestions); } } else { data.isSpellCheckingEnabled = m_webView->focusedWebCoreFrame()->editor()->isContinuousSpellCheckingEnabled(); // Spellchecking might be enabled for the field, but could be disabled on the node. if (m_webView->focusedWebCoreFrame()->editor()->isSpellCheckingEnabledInFocusedNode()) { data.misspelledWord = selectMisspelledWord(defaultMenu.get(), selectedFrame); if (m_webView->spellCheckClient()) { int misspelledOffset, misspelledLength; m_webView->spellCheckClient()->spellCheck( data.misspelledWord, misspelledOffset, misspelledLength, &data.dictionarySuggestions); if (!misspelledLength) data.misspelledWord.reset(); } } } HTMLFormElement* form = selectedFrame->selection()->currentForm(); if (form && r.innerNonSharedNode()->hasTagName(HTMLNames::inputTag)) { HTMLInputElement* selectedElement = static_cast<HTMLInputElement*>(r.innerNonSharedNode()); if (selectedElement) { WebSearchableFormData ws = WebSearchableFormData(WebFormElement(form), WebInputElement(selectedElement)); if (ws.url().isValid()) data.keywordURL = ws.url(); } } } #if OS(DARWIN) if (selectedFrame->editor()->selectionHasStyle(CSSPropertyDirection, "ltr") != FalseTriState) data.writingDirectionLeftToRight |= WebContextMenuData::CheckableMenuItemChecked; if (selectedFrame->editor()->selectionHasStyle(CSSPropertyDirection, "rtl") != FalseTriState) data.writingDirectionRightToLeft |= WebContextMenuData::CheckableMenuItemChecked; #endif // OS(DARWIN) // Now retrieve the security info. DocumentLoader* dl = selectedFrame->loader()->documentLoader(); WebDataSource* ds = WebDataSourceImpl::fromDocumentLoader(dl); if (ds) data.securityInfo = ds->response().securityInfo(); data.referrerPolicy = static_cast<WebReferrerPolicy>(selectedFrame->document()->referrerPolicy()); // Filter out custom menu elements and add them into the data. populateCustomMenuItems(defaultMenu.get(), &data); data.node = r.innerNonSharedNode(); WebFrame* selected_web_frame = WebFrameImpl::fromFrame(selectedFrame); if (m_webView->client()) m_webView->client()->showContextMenu(selected_web_frame, data); return defaultMenu; }
bool JPEGImageEncoder::encodeWithPreInitializedState(PassOwnPtr<JPEGImageEncoderState> encoderState, const unsigned char* inputPixels) { JPEGImageEncoderStateImpl* encoderStateImpl = static_cast<JPEGImageEncoderStateImpl*>(encoderState.get()); Vector<JSAMPLE> row; row.resize(encoderStateImpl->cinfo()->image_width * encoderStateImpl->cinfo()->input_components); jmp_buf jumpBuffer; encoderStateImpl->cinfo()->client_data = &jumpBuffer; if (setjmp(jumpBuffer)) { return false; } unsigned char* pixels = const_cast<unsigned char*>(inputPixels); const size_t pixelRowStride = encoderStateImpl->cinfo()->image_width * 4; while (encoderStateImpl->cinfo()->next_scanline < encoderStateImpl->cinfo()->image_height) { JSAMPLE* rowData = row.data(); RGBAtoRGB(pixels, encoderStateImpl->cinfo()->image_width, rowData); jpeg_write_scanlines(encoderStateImpl->cinfo(), &rowData, 1); pixels += pixelRowStride; } jpeg_finish_compress(encoderStateImpl->cinfo()); return true; }
void JettisonedCodeBlocks::addCodeBlock(PassOwnPtr<CodeBlock> codeBlock) { ASSERT(m_map.find(codeBlock.get()) == m_map.end()); m_map.add(codeBlock.leakPtr(), false); }
PassOwnPtr<GraphicsContextLostCallbackAdapter> GraphicsContextLostCallbackAdapter::create(PassOwnPtr<GraphicsContext3D::ContextLostCallback> cb) { return adoptPtr(cb.get() ? new GraphicsContextLostCallbackAdapter(cb) : 0); }