std::wstring Loader::get_difference( const HashSet& os, const HashStringMap& om, const HashSet& ns, const HashStringMap& nm ) { std::set<size_t> removed; std::set_difference( os.begin(), os.end(), ns.begin(), ns.end(), std::inserter(removed, removed.begin()) ); std::set<size_t> added; std::set_difference( ns.begin(), ns.end(), os.begin(), os.end(), std::inserter(added, added.begin()) ); std::wstringstream strm; for ( std::set<size_t>::iterator it = removed.begin(); it != removed.end(); ++it ) { std::map<size_t, std::wstring>::const_iterator find_it = om.find( *it ); if ( find_it != om.end() ) { strm << std::endl << L"remove: " << find_it->second; } } for ( std::set<size_t>::iterator it = added.begin(); it != added.end(); ++it ) { std::map<size_t, std::wstring>::const_iterator find_it = nm.find( *it ); if ( find_it != nm.end() ) { strm << std::endl << L"add: " << find_it->second; } } return strm.str(); }
void SVGStyledElement::updateElementInstance(SVGDocumentExtensions* extensions) const { SVGStyledElement* nonConstThis = const_cast<SVGStyledElement*>(this); HashSet<SVGElementInstance*>* set = extensions->instancesForElement(nonConstThis); if (!set || set->isEmpty()) return; // We need to be careful here, as the instancesForElement // hash set may be modified after we call updateInstance! HashSet<SVGElementInstance*> localCopy; // First create a local copy of the hashset HashSet<SVGElementInstance*>::const_iterator it1 = set->begin(); const HashSet<SVGElementInstance*>::const_iterator end1 = set->end(); for (; it1 != end1; ++it1) localCopy.add(*it1); // Actually nofify instances to update HashSet<SVGElementInstance*>::const_iterator it2 = localCopy.begin(); const HashSet<SVGElementInstance*>::const_iterator end2 = localCopy.end(); for (; it2 != end2; ++it2) (*it2)->updateInstance(nonConstThis); }
void destroyStringTable() { for (HashSet<const char*>::iterator itr = s_stringTable.begin(); itr != s_stringTable.end(); ++itr) fastFree((void*)*itr); s_stringTable.clear(); for (HashSet<const wchar_t*>::iterator itr = s_stringTableW.begin(); itr != s_stringTableW.end(); ++itr) fastFree((void*)*itr); s_stringTableW.clear(); }
static inline void removeFromCacheAndInvalidateDependencies(RenderObject* object, bool needsLayout) { ASSERT(object); if (SVGResources* resources = SVGResourcesCache::cachedResourcesForRenderObject(object)) { #if ENABLE(FILTERS) if (RenderSVGResourceFilter* filter = resources->filter()) filter->removeClientFromCache(object); #endif if (RenderSVGResourceMasker* masker = resources->masker()) masker->removeClientFromCache(object); if (RenderSVGResourceClipper* clipper = resources->clipper()) clipper->removeClientFromCache(object); } if (!object->node() || !object->node()->isSVGElement()) return; HashSet<SVGElement*>* dependencies = object->document()->accessSVGExtensions()->setOfElementsReferencingTarget(toSVGElement(object->node())); if (!dependencies) return; HashSet<SVGElement*>::iterator end = dependencies->end(); for (HashSet<SVGElement*>::iterator it = dependencies->begin(); it != end; ++it) { if (RenderObject* renderer = (*it)->renderer()) RenderSVGResource::markForLayoutAndParentResourceInvalidation(renderer, needsLayout); } }
void WebApplicationCacheManager::getApplicationCacheOrigins(uint64_t callbackID) { WebProcess::LocalTerminationDisabler terminationDisabler(WebProcess::shared()); HashSet<RefPtr<SecurityOrigin>, SecurityOriginHash> origins; cacheStorage().getOriginsWithCache(origins); Vector<SecurityOriginData> identifiers; identifiers.reserveCapacity(origins.size()); HashSet<RefPtr<SecurityOrigin>, SecurityOriginHash>::iterator end = origins.end(); HashSet<RefPtr<SecurityOrigin>, SecurityOriginHash>::iterator i = origins.begin(); for (; i != end; ++i) { RefPtr<SecurityOrigin> origin = *i; SecurityOriginData originData; originData.protocol = origin->protocol(); originData.host = origin->host(); originData.port = origin->port(); identifiers.uncheckedAppend(originData); } WebProcess::shared().connection()->send(Messages::WebApplicationCacheManagerProxy::DidGetApplicationCacheOrigins(identifiers, callbackID), 0); }
void VM::releaseExecutableMemory() { prepareToDiscardCode(); if (entryScope) { StackPreservingRecompiler recompiler; HeapIterationScope iterationScope(heap); HashSet<JSCell*> roots; heap.getConservativeRegisterRoots(roots); HashSet<JSCell*>::iterator end = roots.end(); for (HashSet<JSCell*>::iterator ptr = roots.begin(); ptr != end; ++ptr) { ScriptExecutable* executable = 0; JSCell* cell = *ptr; if (cell->inherits(ScriptExecutable::info())) executable = static_cast<ScriptExecutable*>(*ptr); else if (cell->inherits(JSFunction::info())) { JSFunction* function = jsCast<JSFunction*>(*ptr); if (function->isHostFunction()) continue; executable = function->jsExecutable(); } else continue; ASSERT(executable->inherits(ScriptExecutable::info())); executable->unlinkCalls(); if (executable->inherits(FunctionExecutable::info())) recompiler.currentlyExecutingFunctions.add(static_cast<FunctionExecutable*>(executable)); } heap.objectSpace().forEachLiveCell<StackPreservingRecompiler>(iterationScope, recompiler); } m_regExpCache->invalidateCode(); heap.collectAllGarbage(); }
void SVGResourcesCache::addResourcesFromRenderer(RenderElement& renderer, const RenderStyle& style) { ASSERT(!m_cache.contains(&renderer)); const SVGRenderStyle& svgStyle = style.svgStyle(); // Build a list of all resources associated with the passed RenderObject OwnPtr<SVGResources> newResources = adoptPtr(new SVGResources); if (!newResources->buildCachedResources(renderer, svgStyle)) return; // Put object in cache. SVGResources& resources = *m_cache.add(&renderer, newResources.release()).iterator->value; // Run cycle-detection _afterwards_, so self-references can be caught as well. SVGResourcesCycleSolver solver(renderer, resources); solver.resolveCycles(); // Walk resources and register the render object at each resources. HashSet<RenderSVGResourceContainer*> resourceSet; resources.buildSetOfResources(resourceSet); for (auto it = resourceSet.begin(), end = resourceSet.end(); it != end; ++it) (*it)->addClient(&renderer); }
bool SVGResourcesCycleSolver::resourceContainsCycles(RenderObject* renderer) const { ASSERT(renderer); // First (first loop iteration) operate on the resources of the given // renderer. // <marker id="a"> <path marker-start="url(#b)"/> ... // <marker id="b" marker-start="url(#a)"/> // Then operate on the child resources of the given renderer. // <marker id="a"> <path marker-start="url(#b)"/> ... // <marker id="b"> <path marker-start="url(#a)"/> ... for (RenderObject* child = renderer; child; child = child->nextInPreOrder(renderer)) { SVGResources* childResources = SVGResourcesCache::cachedResourcesForRenderObject(child); if (!childResources) continue; // A child of the given 'resource' contains resources. HashSet<RenderSVGResourceContainer*> childSet; childResources->buildSetOfResources(childSet); // Walk all child resources and check whether they reference any resource contained in the resources set. HashSet<RenderSVGResourceContainer*>::iterator end = childSet.end(); for (HashSet<RenderSVGResourceContainer*>::iterator it = childSet.begin(); it != end; ++it) { if (m_allResources.contains(*it)) return true; } } return false; }
void PluginView::stop() { if (!m_isStarted) return; HashSet<RefPtr<PluginStream> > streams = m_streams; HashSet<RefPtr<PluginStream> >::iterator end = streams.end(); for (HashSet<RefPtr<PluginStream> >::iterator it = streams.begin(); it != end; ++it) { (*it)->stop(); disconnectStream((*it).get()); } ASSERT(m_streams.isEmpty()); m_isStarted = false; JSC::JSLock::DropAllLocks dropAllLocks(false); PluginMainThreadScheduler::scheduler().unregisterPlugin(m_instance); // Destroy the plugin PluginView::setCurrentPluginView(this); setCallingPlugin(true); m_plugin->pluginFuncs()->destroy(m_instance, 0); setCallingPlugin(false); PluginView::setCurrentPluginView(0); m_instance->pdata = 0; }
void IDBTransaction::closeOpenCursors() { HashSet<IDBCursor*> cursors; cursors.swap(m_openCursors); for (HashSet<IDBCursor*>::iterator i = cursors.begin(); i != cursors.end(); ++i) (*i)->close(); }
void JSGlobalData::releaseExecutableMemory() { if (dynamicGlobalObject) { StackPreservingRecompiler recompiler; HashSet<JSCell*> roots; heap.getConservativeRegisterRoots(roots); HashSet<JSCell*>::iterator end = roots.end(); for (HashSet<JSCell*>::iterator ptr = roots.begin(); ptr != end; ++ptr) { ScriptExecutable* executable = 0; JSCell* cell = *ptr; if (cell->inherits(&ScriptExecutable::s_info)) executable = static_cast<ScriptExecutable*>(*ptr); else if (cell->inherits(&JSFunction::s_info)) { JSFunction* function = jsCast<JSFunction*>(*ptr); if (function->isHostFunction()) continue; executable = function->jsExecutable(); } else continue; ASSERT(executable->inherits(&ScriptExecutable::s_info)); executable->unlinkCalls(); if (executable->inherits(&FunctionExecutable::s_info)) recompiler.currentlyExecutingFunctions.add(static_cast<FunctionExecutable*>(executable)); } heap.objectSpace().forEachCell<StackPreservingRecompiler>(recompiler); } m_regExpCache->invalidateCode(); heap.collectAllGarbage(); }
virtual void handleEvent(Event* event) { if (event->type() != eventNames().clickEvent) return; Frame* frame = m_parent->page()->mainFrame(); while (frame) { RenderView* view = frame->contentRenderer(); const HashSet<RenderWidget*> widgets = view->widgets(); HashSet<RenderWidget*>::const_iterator it = widgets.begin(); HashSet<RenderWidget*>::const_iterator end = widgets.end(); for (; it != end; ++it) { Widget* widget = (*it)->widget(); // PluginWidget is used only with PluginToggleWidget if (widget && widget->isPluginWidget()) { /*SAMSUNG FIX*/ PluginToggleWidget* ptw = static_cast<PluginToggleWidget*>(widget); //SanJose++ ptw->swapPlugin(*it,((widget == this)?true:false)); //SanJose-- } } frame = frame->tree()->traverseNext(); } }
void SVGDocumentExtensions::removeAllElementReferencesForTarget(SVGElement* referencedElement) { ASSERT(referencedElement); HashMap<SVGElement*, OwnPtr<HashSet<SVGElement*> > >::iterator it = m_elementDependencies.find(referencedElement); if (it == m_elementDependencies.end()) return; ASSERT(it->key == referencedElement); Vector<SVGElement*> toBeNotified; HashSet<SVGElement*>* referencingElements = it->value.get(); HashSet<SVGElement*>::iterator setEnd = referencingElements->end(); for (HashSet<SVGElement*>::iterator setIt = referencingElements->begin(); setIt != setEnd; ++setIt) toBeNotified.append(*setIt); // Force rebuilding the referencingElement so it knows about this change. Vector<SVGElement*>::iterator vectorEnd = toBeNotified.end(); for (Vector<SVGElement*>::iterator vectorIt = toBeNotified.begin(); vectorIt != vectorEnd; ++vectorIt) { // Before rebuilding referencingElement ensure it was not removed from under us. if (HashSet<SVGElement*>* referencingElements = setOfElementsReferencingTarget(referencedElement)) { if (referencingElements->contains(*vectorIt)) (*vectorIt)->svgAttributeChanged(XLinkNames::hrefAttr); } } m_elementDependencies.remove(referencedElement); }
bool CompositeAnimation::pauseTransitionAtTime(CSSPropertyID property, double t) { if ((property < firstCSSProperty) || (property >= firstCSSProperty + numCSSProperties)) return false; ImplicitAnimation* implAnim = m_transitions.get(property).get(); if (!implAnim) { // Check to see if this property is being animated via a shorthand. // This code is only used for testing, so performance is not critical here. HashSet<CSSPropertyID> shorthandProperties = CSSPropertyAnimation::animatableShorthandsAffectingProperty(property); bool anyPaused = false; HashSet<CSSPropertyID>::const_iterator end = shorthandProperties.end(); for (HashSet<CSSPropertyID>::const_iterator it = shorthandProperties.begin(); it != end; ++it) { if (pauseTransitionAtTime(*it, t)) anyPaused = true; } return anyPaused; } if (!implAnim->running()) return false; if ((t >= 0.0) && (t <= implAnim->duration())) { implAnim->freezeAtTime(t); return true; } return false; }
JSValue* JSClipboard::getValueProperty(ExecState* exec, int token) const { Clipboard* clipboard = impl(); switch (token) { case DropEffect: ASSERT(clipboard->isForDragging() || clipboard->dropEffect().isNull()); return jsStringOrUndefined(clipboard->dropEffect()); case EffectAllowed: ASSERT(clipboard->isForDragging() || clipboard->effectAllowed().isNull()); return jsStringOrUndefined(clipboard->effectAllowed()); case Types: { HashSet<String> types = clipboard->types(); if (types.isEmpty()) return jsNull(); else { List list; HashSet<String>::const_iterator end = types.end(); for (HashSet<String>::const_iterator it = types.begin(); it != end; ++it) list.append(jsString(UString(*it))); return exec->lexicalInterpreter()->builtinArray()->construct(exec, list); } } default: return 0; } }
void RadioButtonGroup::remove(HTMLInputElement* button) { ASSERT(button->isRadioButton()); HashSet<HTMLInputElement*>::iterator it = m_members.find(button); if (it == m_members.end()) return; bool wasValid = isValid(); m_members.remove(it); if (button->isRequired()) { ASSERT(m_requiredCount); --m_requiredCount; } if (m_checkedButton) { button->setNeedsStyleRecalc(); if (m_checkedButton == button) { m_checkedButton = nullptr; setNeedsStyleRecalcForAllButtons(); } } if (m_members.isEmpty()) { ASSERT(!m_requiredCount); ASSERT(!m_checkedButton); } else if (wasValid != isValid()) updateValidityForAllButtons(); if (!wasValid) { // A radio button not in a group is always valid. We need to make it // valid only if the group was invalid. button->updateValidity(); } }
// FIXME: integrate ChromiumDataObject and DataTransferItemList rather than holding them separately and keeping them synced. void ClipboardChromium::mayUpdateItems(Vector<RefPtr<DataTransferItem> >& items) { if (!items.isEmpty() && !storageHasUpdated()) return; items.clear(); ScriptExecutionContext* scriptExecutionContext = m_frame->document()->scriptExecutionContext(); if (isForCopyAndPaste() && policy() == ClipboardReadable) { // Iterate through the types and add them. HashSet<String> types = m_dataObject->types(); for (HashSet<String>::const_iterator it = types.begin(); it != types.end(); ++it) items.append(DataTransferItemChromium::createFromPasteboard(this, scriptExecutionContext, *it)); return; } bool success = false; String plainText = m_dataObject->getData(mimeTypeTextPlain, success); if (success) items.append(DataTransferItemChromium::create(this, scriptExecutionContext, plainText, mimeTypeTextPlain)); success = false; String htmlText = m_dataObject->getData(mimeTypeTextHTML, success); if (success) items.append(DataTransferItemChromium::create(this, scriptExecutionContext, htmlText, mimeTypeTextHTML)); if (m_dataObject->containsFilenames()) { const Vector<String>& filenames = m_dataObject->filenames(); for (Vector<String>::const_iterator it = filenames.begin(); it != filenames.end(); ++it) items.append(DataTransferItemChromium::create(this, scriptExecutionContext, File::create(*it))); } m_dragStorageUpdated = false; }
void SVGResourcesCache::addResourcesFromRenderObject(RenderObject* object, const RenderStyle* style) { ASSERT(object); ASSERT(style); ASSERT(!m_cache.contains(object)); const SVGRenderStyle* svgStyle = style->svgStyle(); ASSERT(svgStyle); // Build a list of all resources associated with the passed RenderObject SVGResources* resources = new SVGResources; if (!resources->buildCachedResources(object, svgStyle)) { delete resources; return; } // Put object in cache. m_cache.set(object, resources); // Run cycle-detection _afterwards_, so self-references can be caught as well. SVGResourcesCycleSolver solver(object, resources); solver.resolveCycles(); // Walk resources and register the render object at each resources. HashSet<RenderSVGResourceContainer*> resourceSet; resources->buildSetOfResources(resourceSet); HashSet<RenderSVGResourceContainer*>::iterator end = resourceSet.end(); for (HashSet<RenderSVGResourceContainer*>::iterator it = resourceSet.begin(); it != end; ++it) (*it)->addClient(object); }
void DatabaseThread::cleanupDatabaseThread() { DCHECK(isDatabaseThread()); STORAGE_DVLOG(1) << "Cleaning up DatabaseThread " << this; // Clean up the list of all pending transactions on this database thread m_transactionCoordinator->shutdown(); // Close the databases that we ran transactions on. This ensures that if any // transactions are still open, they are rolled back and we don't leave the // database in an inconsistent or locked state. if (m_openDatabaseSet.size() > 0) { // As the call to close will modify the original set, we must take a copy to // iterate over. HashSet<CrossThreadPersistent<Database>> openSetCopy; openSetCopy.swap(m_openDatabaseSet); HashSet<CrossThreadPersistent<Database>>::iterator end = openSetCopy.end(); for (HashSet<CrossThreadPersistent<Database>>::iterator it = openSetCopy.begin(); it != end; ++it) (*it)->close(); } m_openDatabaseSet.clear(); m_thread->postTask(BLINK_FROM_HERE, WTF::bind(&DatabaseThread::cleanupDatabaseThreadCompleted, wrapCrossThreadPersistent(this))); }
void MediaPlayer::getSupportedTypes(HashSet<String>& types) { for (auto& engine : installedMediaEngines()) { HashSet<String> engineTypes; engine.getSupportedTypes(engineTypes); types.add(engineTypes.begin(), engineTypes.end()); } }
void visit(HashSet<int>& set) { HashSet<int>::Iterator it = set.begin(); for (; it != set.end(); ++it) { value_sum += (*it); } }
void V8MutationObserver::visitDOMWrapper(void* object, const v8::Persistent<v8::Object>& wrapper, v8::Isolate* isolate) { MutationObserver* observer = static_cast<MutationObserver*>(object); HashSet<Node*> observedNodes = observer->getObservedNodes(); for (HashSet<Node*>::iterator it = observedNodes.begin(); it != observedNodes.end(); ++it) { v8::UniqueId id(reinterpret_cast<intptr_t>(V8GCController::opaqueRootForGC(*it, isolate))); isolate->SetReferenceFromGroup(id, wrapper); } }
static void setLiveValues(HashMap<Node*, AbstractValue>& values, HashSet<Node*>& live) { values.clear(); HashSet<Node*>::iterator iter = live.begin(); HashSet<Node*>::iterator end = live.end(); for (; iter != end; ++iter) values.add(*iter, AbstractValue()); }
bool JSMutationObserverOwner::isReachableFromOpaqueRoots(JSC::Handle<JSC::Unknown> handle, void*, SlotVisitor& visitor) { MutationObserver* observer = jsCast<JSMutationObserver*>(handle.get().asCell())->impl(); HashSet<Node*> observedNodes = observer->getObservedNodes(); for (HashSet<Node*>::iterator it = observedNodes.begin(); it != observedNodes.end(); ++it) { if (visitor.containsOpaqueRoot(root(*it))) return true; } return false; }
void checkAllQueries(const MemoryIndexPtr& memory, const RAMDirectoryPtr& ramdir, const AnalyzerPtr& analyzer) { IndexSearcherPtr ram = newLucene<IndexSearcher>(ramdir); IndexSearcherPtr mem = memory->createSearcher(); QueryParserPtr qp = newLucene<QueryParser>(LuceneVersion::LUCENE_CURRENT, L"foo", analyzer); for (HashSet<String>::iterator query = queries.begin(); query != queries.end(); ++query) { TopDocsPtr ramDocs = ram->search(qp->parse(*query), 1); TopDocsPtr memDocs = mem->search(qp->parse(*query), 1); EXPECT_EQ(ramDocs->totalHits, memDocs->totalHits); } }
void RadioButtonGroup::setNeedsValidityCheckForAllButtons() { typedef HashSet<HTMLInputElement*>::const_iterator Iterator; Iterator end = m_members.end(); for (Iterator it = m_members.begin(); it != end; ++it) { HTMLInputElement* button = *it; ASSERT(button->isRadioButton()); button->setNeedsValidityCheck(); } }
static void webkit_web_view_container_forall(GtkContainer* container, gboolean, GtkCallback callback, gpointer callbackData) { //WebKitWebView* webView = WEBKIT_WEB_VIEW(container); ////WebKitWebViewPrivate* priv = webView->priv; HashSet<GtkWidget*> children = children; HashSet<GtkWidget*>::const_iterator end = children.end(); for (HashSet<GtkWidget*>::const_iterator current = children.begin(); current != end; ++current) (*callback)(*current, callbackData); }
LayerTreeCoordinator::~LayerTreeCoordinator() { // Prevent setCoordinatedGraphicsLayerClient(0) -> detachLayer() from modifying the set while we iterate it. HashSet<WebCore::CoordinatedGraphicsLayer*> registeredLayers; registeredLayers.swap(m_registeredLayers); HashSet<WebCore::CoordinatedGraphicsLayer*>::iterator end = registeredLayers.end(); for (HashSet<WebCore::CoordinatedGraphicsLayer*>::iterator it = registeredLayers.begin(); it != end; ++it) (*it)->setCoordinatedGraphicsLayerClient(0); }
void HTMLStyleElement::getSubresourceAttributeStrings(Vector<String>& urls) const { HashSet<String> styleURLs; StyleSheet* styleSheet = const_cast<HTMLStyleElement*>(this)->sheet(); if (styleSheet) styleSheet->addSubresourceURLStrings(styleURLs, ownerDocument()->baseURL()); HashSet<String>::iterator end = styleURLs.end(); for (HashSet<String>::iterator i = styleURLs.begin(); i != end; ++i) urls.append(*i); }
void PageGroup::removeLocalStorage() { HashSet<Page*> pages = this->pages(); HashSet<Page*>::iterator pagesEnd = pages.end(); for(HashSet<Page*>::iterator pit = pages.begin(); pit != pagesEnd; ++pit) { Page* p = *pit; for (Frame* frame = p->mainFrame(); frame; frame = frame->tree()->traverseNext()) frame->document()->domWindow()->clearDOMStorage(); } m_localStorage = 0; }