void WebFileSystemCallbacksImpl::didReadDirectory(const WebVector<WebFileSystemEntry>& entries, bool hasMore) { ASSERT(m_callbacks); for (size_t i = 0; i < entries.size(); ++i) m_callbacks->didReadDirectoryEntry(entries[i].name, entries[i].isDirectory); m_callbacks->didReadDirectoryEntries(hasMore); if (!hasMore) delete this; }
void WebHistoryItem::setDocumentState(const WebVector<WebString>& state) { ensureMutable(); // FIXME: would be nice to avoid the intermediate copy Vector<String> ds; for (size_t i = 0; i < state.size(); ++i) ds.append(state[i]); m_private->setDocumentState(ds); }
void WebIDBCallbacksImpl::onSuccess(const WebVector<WebString>& webStringList) { Vector<String> stringList; for (size_t i = 0; i < webStringList.size(); ++i) stringList.append(webStringList[i]); InspectorInstrumentationCookie cookie = InspectorInstrumentation::traceAsyncCallbackStarting(m_request->executionContext(), m_asyncOperationId); m_request->onSuccess(stringList); InspectorInstrumentation::traceAsyncCallbackCompleted(cookie); }
void WebFileChooserCompletionImpl::didChooseFile(const WebVector<WebString>& fileNames) { Vector<FileChooserFileInfo> fileInfo; for (size_t i = 0; i < fileNames.size(); ++i) fileInfo.append(FileChooserFileInfo(fileNames[i])); m_fileChooser->chooseFiles(fileInfo); // This object is no longer needed. delete this; }
void SpeechRecognitionClientProxy::didReceiveResults( const WebSpeechRecognitionHandle& handle, const WebVector<WebSpeechRecognitionResult>& newFinalResults, const WebVector<WebSpeechRecognitionResult>& currentInterimResults) { SpeechRecognition* recognition(handle); HeapVector<Member<SpeechRecognitionResult>> finalResultsVector( newFinalResults.size()); for (size_t i = 0; i < newFinalResults.size(); ++i) finalResultsVector[i] = Member<SpeechRecognitionResult>(newFinalResults[i]); HeapVector<Member<SpeechRecognitionResult>> interimResultsVector( currentInterimResults.size()); for (size_t i = 0; i < currentInterimResults.size(); ++i) interimResultsVector[i] = Member<SpeechRecognitionResult>(currentInterimResults[i]); recognition->didReceiveResults(finalResultsVector, interimResultsVector); }
// static void ColorBehavior::setGlobalTargetColorProfile( const WebVector<char>& profile) { if (profile.isEmpty()) return; // Take a lock around initializing and accessing the global device color // profile. SpinLock::Guard guard(gTargetColorSpaceLock); // Layout tests expect that only the first call will take effect. if (gTargetColorSpace) return; gTargetColorSpace = SkColorSpace::MakeICC(profile.data(), profile.size()).release(); // UMA statistics. BitmapImageMetrics::countOutputGamma(gTargetColorSpace); }
bool WebMediaConstraintsPrivate::getMandatoryConstraintValue(const WebString& name, WebString& value) { for (size_t i = 0; i < m_mandatory.size(); ++i) { if (m_mandatory[i].m_name == name) { value = m_mandatory[i].m_value; return true; } } return false; }
void GraphicsLayerChromium::updateChildList() { Vector<WebLayer> newChildren; if (!m_transformLayer.isNull()) { // Add the primary layer first. Even if we have negative z-order children, the primary layer always comes behind. newChildren.append(m_layer); } else if (!m_contentsLayer.isNull()) { // FIXME: add the contents layer in the correct order with negative z-order children. // This does not cause visible rendering issues because currently contents layers are only used // for replaced elements that don't have children. newChildren.append(m_contentsLayer); } const Vector<GraphicsLayer*>& childLayers = children(); size_t numChildren = childLayers.size(); for (size_t i = 0; i < numChildren; ++i) { GraphicsLayerChromium* curChild = static_cast<GraphicsLayerChromium*>(childLayers[i]); newChildren.append(curChild->layerForParent()); } if (m_linkHighlight) newChildren.append(m_linkHighlight->contentLayer()); for (size_t i = 0; i < newChildren.size(); ++i) newChildren[i].removeFromParent(); WebVector<WebLayer> newWebChildren; newWebChildren.assign(newChildren.data(), newChildren.size()); if (!m_transformLayer.isNull()) { m_transformLayer.setChildren(newWebChildren); if (!m_contentsLayer.isNull()) { // If we have a transform layer, then the contents layer is parented in the // primary layer (which is itself a child of the transform layer). m_layer.removeAllChildren(); m_layer.addChild(m_contentsLayer); } } else m_layer.setChildren(newWebChildren); }
bool WebMediaConstraintsPrivate::getOptionalConstraintValue(const WebString& name, WebString& value) { for (size_t i = 0; i < m_optional.size(); ++i) { if (m_optional[i].m_name == name) { value = m_optional[i].m_value; return true; } } return false; }
// Old style parser. Deprecated. static bool parse(const Dictionary& constraintsDictionary, WebVector<WebMediaConstraint>& optional, WebVector<WebMediaConstraint>& mandatory) { if (constraintsDictionary.isUndefinedOrNull()) return true; Vector<String> names; bool ok = constraintsDictionary.getPropertyNames(names); if (!ok) return false; String mandatoryName("mandatory"); String optionalName("optional"); for (Vector<String>::iterator it = names.begin(); it != names.end(); ++it) { if (*it != mandatoryName && *it != optionalName) return false; } if (names.contains(mandatoryName)) { Dictionary mandatoryConstraintsDictionary; bool ok = constraintsDictionary.get(mandatoryName, mandatoryConstraintsDictionary); if (!ok || mandatoryConstraintsDictionary.isUndefinedOrNull()) return false; ok = parseMandatoryConstraintsDictionary(mandatoryConstraintsDictionary, mandatory); if (!ok) return false; } Vector<WebMediaConstraint> optionalConstraintsVector; if (names.contains(optionalName)) { ArrayValue optionalConstraints; bool ok = DictionaryHelper::get(constraintsDictionary, optionalName, optionalConstraints); if (!ok || optionalConstraints.isUndefinedOrNull()) return false; size_t numberOfConstraints; ok = optionalConstraints.length(numberOfConstraints); if (!ok) return false; for (size_t i = 0; i < numberOfConstraints; ++i) { Dictionary constraint; ok = optionalConstraints.get(i, constraint); if (!ok || constraint.isUndefinedOrNull()) return false; ok = parseOptionalConstraintsVectorElement(constraint, optionalConstraintsVector); if (!ok) return false; } optional.assign(optionalConstraintsVector); } return true; }
void WebFormElement::getInputElements(WebVector<WebInputElement>& result) const { const HTMLFormElement* form = constUnwrap<HTMLFormElement>(); Vector<RefPtr<HTMLInputElement> > tempVector; for (size_t i = 0; i < form->formElements.size(); i++) { if (form->formElements[i]->hasLocalName(HTMLNames::inputTag)) tempVector.append(static_cast<HTMLInputElement*>( form->formElements[i])); } result.assign(tempVector); }
void WebScrollbarImpl::getTickmarks(WebVector<WebRect>& webTickmarks) const { Vector<IntRect> tickmarks; m_scrollbar->getTickmarks(tickmarks); WebVector<WebRect> result(tickmarks.size()); for (size_t i = 0; i < tickmarks.size(); ++i) result[i] = tickmarks[i]; webTickmarks.swap(result); }
TEST_F(TextFinderTest, OverlappingMatches) { document().body()->setInnerHTML("aababaa", ASSERT_NO_EXCEPTION); Node* textNode = document().body()->firstChild(); int identifier = 0; WebString searchText(String("aba")); WebFindOptions findOptions; // Default. textFinder().resetMatchCount(); textFinder().scopeStringMatches(identifier, searchText, findOptions, true); while (textFinder().scopingInProgress()) runPendingTasks(); // We shouldn't find overlapped matches. EXPECT_EQ(1, textFinder().totalMatchCount()); WebVector<WebFloatRect> matchRects; textFinder().findMatchRects(matchRects); ASSERT_EQ(1u, matchRects.size()); EXPECT_EQ(findInPageRect(textNode, 1, textNode, 4), matchRects[0]); }
TEST_F(TextFinderTest, ScopeRepeatPatternTextMatches) { document().body()->setInnerHTML("ab ab ab ab ab", ASSERT_NO_EXCEPTION); Node* textNode = document().body()->firstChild(); int identifier = 0; WebString searchText(String("ab ab")); WebFindOptions findOptions; // Default. textFinder().resetMatchCount(); textFinder().scopeStringMatches(identifier, searchText, findOptions, true); while (textFinder().scopingInProgress()) runPendingTasks(); EXPECT_EQ(2, textFinder().totalMatchCount()); WebVector<WebFloatRect> matchRects; textFinder().findMatchRects(matchRects); ASSERT_EQ(2u, matchRects.size()); EXPECT_EQ(findInPageRect(textNode, 0, textNode, 5), matchRects[0]); EXPECT_EQ(findInPageRect(textNode, 6, textNode, 11), matchRects[1]); }
TEST_F(WebFrameTest, IframeRedirect) { registerMockedHttpURLLoad("iframe_redirect.html"); registerMockedHttpURLLoad("visible_iframe.html"); WebView* webView = FrameTestHelpers::createWebViewAndLoad(m_baseURL + "iframe_redirect.html", true); webkit_support::RunAllPendingMessages(); // Queue the iframe. webkit_support::ServeAsynchronousMockedRequests(); // Load the iframe. WebFrame* iframe = webView->findFrameByName(WebString::fromUTF8("ifr")); ASSERT_TRUE(iframe); WebDataSource* iframeDataSource = iframe->dataSource(); ASSERT_TRUE(iframeDataSource); WebVector<WebURL> redirects; iframeDataSource->redirectChain(redirects); ASSERT_EQ(2U, redirects.size()); EXPECT_EQ(toKURL("about:blank"), toKURL(redirects[0].spec().data())); EXPECT_EQ(toKURL("http://www.test.com/visible_iframe.html"), toKURL(redirects[1].spec().data())); webView->close(); }
// FIXME: Cleanup when the chromium code has switched to the split sources implementation. void WebMediaStreamDescriptor::sources(WebVector<WebMediaStreamSource>& webSources) const { size_t numberOfAudioSources = m_private->numberOfAudioComponents(); size_t numberOfVideoSources = m_private->numberOfVideoComponents(); WebVector<WebMediaStreamSource> result(numberOfAudioSources + numberOfVideoSources); size_t i = 0; for (size_t j = 0; j < numberOfAudioSources; ++i, ++j) result[i] = m_private->audioComponent(j)->source(); for (size_t j = 0; j < numberOfVideoSources; ++i, ++j) result[i] = m_private->videoComponent(j)->source(); webSources.swap(result); }
// FIXME: Cleanup when the chromium code has switched to the split sources implementation. void WebMediaStreamDescriptor::initialize(const WebString& label, const WebVector<WebMediaStreamSource>& sources) { MediaStreamSourceVector audio, video; for (size_t i = 0; i < sources.size(); ++i) { MediaStreamSource* curr = sources[i]; if (curr->type() == MediaStreamSource::TypeAudio) audio.append(curr); else if (curr->type() == MediaStreamSource::TypeVideo) video.append(curr); } m_private = MediaStreamDescriptor::create(label, audio, video); }
void WebFormElement::getFormControlElements(WebVector<WebFormControlElement>& result) const { const HTMLFormElement* form = constUnwrap<HTMLFormElement>(); Vector<RefPtr<HTMLFormControlElement> > formControlElements; const Vector<FormAssociatedElement*>& associatedElements = form->associatedElements(); for (Vector<FormAssociatedElement*>::const_iterator it = associatedElements.begin(); it != associatedElements.end(); ++it) { if ((*it)->isFormControlElement()) formControlElements.append(toHTMLFormControlElement(*it)); } result.assign(formControlElements); }
bool MockConstraints::verifyConstraints(const WebMediaConstraints& constraints, WebString* failedConstraint) { WebVector<WebMediaConstraint> mandatoryConstraints; constraints.getMandatoryConstraints(mandatoryConstraints); if (mandatoryConstraints.size()) { for (size_t i = 0; i < mandatoryConstraints.size(); ++i) { const WebMediaConstraint& curr = mandatoryConstraints[i]; if (!isSupported(curr.m_name) || curr.m_value != "1") { if (failedConstraint) *failedConstraint = curr.m_name; return false; } } } WebVector<WebMediaConstraint> optionalConstraints; constraints.getOptionalConstraints(optionalConstraints); if (optionalConstraints.size()) { for (size_t i = 0; i < optionalConstraints.size(); ++i) { const WebMediaConstraint& curr = optionalConstraints[i]; if (!isValid(curr.m_name) || curr.m_value != "0") { if (failedConstraint) *failedConstraint = curr.m_name; return false; } } } return true; }
void WebDocument::images(WebVector<WebElement>& results) { RefPtr<HTMLCollection> images = unwrap<Document>()->images(); size_t sourceLength = images->length(); Vector<WebElement> temp; temp.reserveCapacity(sourceLength); for (size_t i = 0; i < sourceLength; ++i) { Element* element = images->item(i); if (element && element->isHTMLElement()) temp.append(WebElement(element)); } results.assign(temp); }
static bool parseMandatoryConstraintsDictionary(const Dictionary& mandatoryConstraintsDictionary, WebVector<WebMediaConstraint>& mandatory) { Vector<WebMediaConstraint> mandatoryConstraintsVector; HashMap<String, String> mandatoryConstraintsHashMap; bool ok = mandatoryConstraintsDictionary.getOwnPropertiesAsStringHashMap(mandatoryConstraintsHashMap); if (!ok) return false; for (const auto& iter : mandatoryConstraintsHashMap) mandatoryConstraintsVector.append(WebMediaConstraint(iter.key, iter.value)); mandatory.assign(mandatoryConstraintsVector); return true; }
static Vector<TextCheckingResult> toCoreResults(const WebVector<WebTextCheckingResult>& results) { Vector<TextCheckingResult> coreResults; for (size_t i = 0; i < results.size(); ++i) { TextCheckingResult coreResult; coreResult.type = toCoreCheckingType(results[i].error); coreResult.location = results[i].position; coreResult.length = results[i].length; coreResults.append(coreResult); } return coreResults; }
void WebDocument::images(WebVector<WebElement>& results) { RefPtr<HTMLCollection> images = unwrap<Document>()->images(); size_t sourceLength = images->length(); Vector<WebElement> temp; temp.reserveCapacity(sourceLength); for (size_t i = 0; i < sourceLength; ++i) { Node* node = images->item(i); if (node && node->isHTMLElement()) temp.append(WebElement(static_cast<Element*>(node))); } results.assign(temp); }
void AutocompletePopupMenuClient::initialize( HTMLInputElement* textField, const WebVector<WebString>& suggestions, int defaultSuggestionIndex) { ASSERT(defaultSuggestionIndex < static_cast<int>(suggestions.size())); // The suggestions must be set before initializing the // SuggestionsPopupMenuClient. setSuggestions(suggestions); SuggestionsPopupMenuClient::initialize(textField, defaultSuggestionIndex); }
TEST_F(TextFinderTest, ScopeTextMatchesSimple) { document().body()->setInnerHTML("XXXXFindMeYYYYfindmeZZZZ"); document().updateStyleAndLayout(); Node* textNode = document().body()->firstChild(); int identifier = 0; WebString searchText(String("FindMe")); WebFindOptions findOptions; // Default. textFinder().resetMatchCount(); textFinder().startScopingStringMatches(identifier, searchText, findOptions); while (textFinder().scopingInProgress()) runPendingTasks(); EXPECT_EQ(2, textFinder().totalMatchCount()); WebVector<WebFloatRect> matchRects; textFinder().findMatchRects(matchRects); ASSERT_EQ(2u, matchRects.size()); EXPECT_EQ(findInPageRect(textNode, 4, textNode, 10), matchRects[0]); EXPECT_EQ(findInPageRect(textNode, 14, textNode, 20), matchRects[1]); }
DataObject* DataObject::create(WebDragData data) { DataObject* dataObject = create(); WebVector<WebDragData::Item> items = data.items(); for (unsigned i = 0; i < items.size(); ++i) { WebDragData::Item item = items[i]; switch (item.storageType) { case WebDragData::Item::StorageTypeString: if (String(item.stringType) == mimeTypeTextURIList) dataObject->setURLAndTitle(item.stringData, item.title); else if (String(item.stringType) == mimeTypeTextHTML) dataObject->setHTMLAndBaseURL(item.stringData, item.baseURL); else dataObject->setData(item.stringType, item.stringData); break; case WebDragData::Item::StorageTypeFilename: dataObject->addFilename(item.filenameData, item.displayNameData); break; case WebDragData::Item::StorageTypeBinaryData: // This should never happen when dragging in. break; case WebDragData::Item::StorageTypeFileSystemFile: { // FIXME: The file system URL may refer a user visible file, see // http://crbug.com/429077 FileMetadata fileMetadata; fileMetadata.length = item.fileSystemFileSize; dataObject->add(File::createForFileSystemFile( item.fileSystemURL, fileMetadata, File::IsNotUserVisible)); } break; } } if (!data.filesystemId().isNull()) DraggedIsolatedFileSystem::prepareForDataObject(dataObject, data.filesystemId()); return dataObject; }
void WebDocument::forms(WebVector<WebFormElement>& results) const { HTMLCollection* forms = const_cast<Document*>(constUnwrap<Document>())->forms(); size_t sourceLength = forms->length(); Vector<WebFormElement> temp; temp.reserveCapacity(sourceLength); for (size_t i = 0; i < sourceLength; ++i) { Element* element = forms->item(i); // Strange but true, sometimes node can be 0. if (element && element->isHTMLElement()) temp.append(WebFormElement(toHTMLFormElement(element))); } results.assign(temp); }
void WebDocument::forms(WebVector<WebFormElement>& results) const { RefPtr<HTMLCollection> forms = const_cast<Document*>(constUnwrap<Document>())->forms(); size_t sourceLength = forms->length(); Vector<WebFormElement> temp; temp.reserveCapacity(sourceLength); for (size_t i = 0; i < sourceLength; ++i) { Node* node = forms->item(i); // Strange but true, sometimes node can be 0. if (node && node->isHTMLElement()) temp.append(WebFormElement(static_cast<HTMLFormElement*>(node))); } results.assign(temp); }
void WebFormElement::getFormControlElements(WebVector<WebFormControlElement>& result) const { const HTMLFormElement* form = constUnwrap<HTMLFormElement>(); Vector<RefPtr<HTMLFormControlElement> > tempVector; // FIXME: We should move the for-loop condition into a variable instead of // re-evaluating size each time. Also, consider refactoring this code so that // we don't call form->associatedElements() multiple times. for (size_t i = 0; i < form->associatedElements().size(); i++) { if (form->associatedElements()[i]->hasLocalName(HTMLNames::inputTag) || form->associatedElements()[i]->hasLocalName(HTMLNames::selectTag)) tempVector.append(form->associatedElements()[i]); } result.assign(tempVector); }
void ExternalPopupMenu::didAcceptIndices(const WebVector<int>& indices) { if (!m_popupMenuClient) { m_webExternalPopupMenu = 0; return; } // Calling methods on the PopupMenuClient might lead to this object being // derefed. This ensures it does not get deleted while we are running this // method. RefPtrWillBeRawPtr<ExternalPopupMenu> protect(this); m_popupMenuClient->popupDidHide(); if (!indices.size()) m_popupMenuClient->valueChanged(static_cast<unsigned>(-1), true); else { for (size_t i = 0; i < indices.size(); ++i) m_popupMenuClient->listBoxSelectItem(toPopupMenuItemIndex(indices[i], *m_popupMenuClient), (i > 0), false, (i == indices.size() - 1)); } m_webExternalPopupMenu = 0; }