void CompositeAnimationPrivate::updateKeyframeAnimations(RenderObject* renderer, RenderStyle* currentStyle, RenderStyle* targetStyle) { // Nothing to do if we don't have any animations, and didn't have any before if (m_keyframeAnimations.isEmpty() && !targetStyle->hasAnimations()) return; // Nothing to do if the current and target animations are the same if (currentStyle && currentStyle->hasAnimations() && targetStyle->hasAnimations() && *(currentStyle->animations()) == *(targetStyle->animations())) return; // Mark all existing animations as no longer active AnimationNameMap::const_iterator kfend = m_keyframeAnimations.end(); for (AnimationNameMap::const_iterator it = m_keyframeAnimations.begin(); it != kfend; ++it) it->second->setIndex(-1); // Now mark any still active animations as active and add any new animations if (targetStyle->animations()) { int numAnims = targetStyle->animations()->size(); for (int i = 0; i < numAnims; ++i) { const Animation* anim = targetStyle->animations()->animation(i); AtomicString animationName(anim->name()); if (!anim->isValidAnimation()) continue; // See if there is a current animation for this name RefPtr<KeyframeAnimation> keyframeAnim = m_keyframeAnimations.get(animationName.impl()); if (keyframeAnim) { // There is one so it is still active // Animations match, but play states may differ. update if needed keyframeAnim->updatePlayState(anim->playState() == AnimPlayStatePlaying); // Set the saved animation to this new one, just in case the play state has changed keyframeAnim->setAnimation(anim); keyframeAnim->setIndex(i); } else if ((anim->duration() || anim->delay()) && anim->iterationCount()) { keyframeAnim = KeyframeAnimation::create(const_cast<Animation*>(anim), renderer, i, m_compositeAnimation, currentStyle ? currentStyle : targetStyle); m_keyframeAnimations.set(keyframeAnim->name().impl(), keyframeAnim); } } } // Make a list of animations to be removed Vector<AtomicStringImpl*> animsToBeRemoved; kfend = m_keyframeAnimations.end(); for (AnimationNameMap::const_iterator it = m_keyframeAnimations.begin(); it != kfend; ++it) { KeyframeAnimation* keyframeAnim = it->second.get(); if (keyframeAnim->index() < 0) animsToBeRemoved.append(keyframeAnim->name().impl()); } // Now remove the animations from the list for (size_t j = 0; j < animsToBeRemoved.size(); ++j) m_keyframeAnimations.remove(animsToBeRemoved[j]); }
void CookieDatabaseBackingStore::sendChangesToDatabase() { MutexLocker lock(m_mutex); size_t sizeOfChange = m_changedCookies.size(); if (!sizeOfChange) return; SQLiteTransaction transaction(m_db, false); transaction.begin(); for (size_t i = 0; i < sizeOfChange; i++) { SQLiteStatement* m_statement; const RefPtr<ParsedCookie> cookie = m_changedCookies[i].first; Action action = m_changedCookies[i].second; if (action == Delete) { m_statement = m_deleteStatement; // Binds all the values if (m_statement->bindText(1, cookie->name()) || m_statement->bindText(2, cookie->domain()) || m_statement->bindText(3, cookie->path()) || m_statement->bindText(4, cookie->protocol())) { LOG_ERROR("Cannot bind cookie data to delete"); LOG_ERROR("SQLite Error Message: %s", m_db.lastErrorMsg()); continue; } } else { if (action == Update) m_statement = m_updateStatement; else m_statement = m_insertStatement; // Binds all the values if (m_statement->bindText(1, cookie->name()) || m_statement->bindText(2, cookie->value()) || m_statement->bindText(3, cookie->domain()) || m_statement->bindText(4, cookie->path()) || m_statement->bindDouble(5, cookie->expiry()) || m_statement->bindDouble(6, cookie->lastAccessed()) || m_statement->bindInt64(7, cookie->isSecure()) || m_statement->bindInt64(8, cookie->isHttpOnly()) || m_statement->bindDouble(9, cookie->creationTime()) || m_statement->bindText(10, cookie->protocol())) { LOG_ERROR("Cannot bind cookie data to save"); LOG_ERROR("SQLite Error Message: %s", m_db.lastErrorMsg()); continue; } } int rc = m_statement->step(); m_statement->reset(); if (rc != SQLResultOk && rc != SQLResultDone) { LOG_ERROR("Cannot make call to the database"); LOG_ERROR("SQLite Error Message: %s", m_db.lastErrorMsg()); continue; } } transaction.commit(); m_changedCookies.clear(); }
static void insertPerformanceEntry(PerformanceEntryMap& performanceEntryMap, PassRefPtr<PerformanceEntry> performanceEntry) { RefPtr<PerformanceEntry> entry = performanceEntry; PerformanceEntryMap::iterator it = performanceEntryMap.find(entry->name()); if (it != performanceEntryMap.end()) it->value.append(entry); else { Vector<RefPtr<PerformanceEntry> > v(1); v[0] = entry; performanceEntryMap.set(entry->name(), v); } }
bool CookieMap::addOrReplaceCookie(PassRefPtr<ParsedCookie> prpCandidateCookie, RefPtr<ParsedCookie>& replacedCookie, CookieFilter filter) { RefPtr<ParsedCookie> candidateCookie = prpCandidateCookie; CookieLog("CookieMap - Attempting to add cookie - %s", cookie->name().utf8().data()); size_t cookieCount = m_cookieVector.size(); for (size_t i = 0; i < cookieCount; i++) { if (m_cookieVector[i]->name() == candidateCookie->name() && m_cookieVector[i]->path() == candidateCookie->path()) { if (filter == NoHttpOnlyCookie && m_cookieVector[i]->isHttpOnly()) return false; replacedCookie = m_cookieVector[i]; m_cookieVector[i] = candidateCookie; if (replacedCookie == m_oldestCookie) updateOldestCookie(); return true; } } m_cookieVector.append(candidateCookie); if (!candidateCookie->isSession()) cookieManager().addedCookie(); if (!m_oldestCookie || m_oldestCookie->lastAccessed() > candidateCookie->lastAccessed()) m_oldestCookie = candidateCookie; return true; }
void LayerAndroid::addAnimation(PassRefPtr<AndroidAnimation> prpAnim) { RefPtr<AndroidAnimation> anim = prpAnim; pair<String, int> key(anim->name(), anim->type()); removeAnimationsForProperty(anim->type()); m_animations.add(key, anim); }
/** * Extract command from commands queue and dispatch it. * * A global python_mutex is held while the command is being * dispatched. */ bool Marshaller::dispatch_command() volatile { bool result = false; assert(!commands_.empty()); RefPtr<Message> cmd = commands_.front(); commands_.pop(); try { Lock<Mutex> lock(python_mutex()); result = cmd->dispatch(); } catch (const std::exception& e) { error_message(e.what()); } catch (...) { error_message("Unknown exception in command_loop"); } if (debugCommands_) { clog << __func__ << ": " << cmd->name() << "=" << result << endl; } { Lock<Mutex> lock(commands_.mutex()); cmd.reset(); } return result; }
PassRefPtr<IDBObjectStoreBackendInterface> IDBDatabaseBackendImpl::createObjectStore(int64_t id, const String& name, const IDBKeyPath& keyPath, bool autoIncrement, IDBTransactionBackendInterface* transactionPtr, ExceptionCode& ec) { ASSERT(!m_objectStores.contains(id)); RefPtr<IDBObjectStoreBackendImpl> objectStore = IDBObjectStoreBackendImpl::create(this, IDBObjectStoreMetadata(name, id, keyPath, autoIncrement, IDBObjectStoreBackendInterface::MinimumIndexId)); ASSERT(objectStore->name() == name); RefPtr<IDBTransactionBackendImpl> transaction = IDBTransactionBackendImpl::from(transactionPtr); ASSERT(transaction->mode() == IDBTransaction::VERSION_CHANGE); // FIXME: Fix edge cases around transaction aborts that prevent this from just being ASSERT(id == m_metadata.maxObjectStoreId + 1) ASSERT(id > m_metadata.maxObjectStoreId); m_metadata.maxObjectStoreId = id; RefPtr<IDBDatabaseBackendImpl> database = this; if (!transaction->scheduleTask( createCallbackTask(&IDBDatabaseBackendImpl::createObjectStoreInternal, database, objectStore, transaction), createCallbackTask(&IDBDatabaseBackendImpl::removeObjectStoreFromMap, database, objectStore))) { ec = IDBDatabaseException::TRANSACTION_INACTIVE_ERR; return 0; } m_objectStores.set(id, objectStore); return objectStore.release(); }
void NamedAttrMap::addAttribute(Attribute *attribute) { // Add the attribute to the list Attribute **newAttrs = static_cast<Attribute **>(fastMalloc((len + 1) * sizeof(Attribute *))); if (attrs) { for (unsigned i = 0; i < len; i++) newAttrs[i] = attrs[i]; fastFree(attrs); } attrs = newAttrs; attrs[len++] = attribute; attribute->ref(); Attr * const attr = attribute->attr(); if (attr) attr->m_element = element; // Notify the element that the attribute has been added, and dispatch appropriate mutation events // Note that element may be null here if we are called from insertAttr() during parsing if (element) { RefPtr<Attribute> a = attribute; element->attributeChanged(a.get()); // Because of our updateStyleAttributeIfNeeded() style modification events are never sent at the right time, so don't bother sending them. if (a->name() != styleAttr) { element->dispatchAttrAdditionEvent(a.get()); element->dispatchSubtreeModifiedEvent(false); } } }
PassRefPtr<IDBIndexBackendInterface> IDBObjectStoreBackendImpl::createIndex(const String& name, const String& keyPath, bool unique, bool multiEntry, IDBTransactionBackendInterface* transaction, ExceptionCode& ec) { if (name.isNull()) { ec = IDBDatabaseException::NON_TRANSIENT_ERR; return 0; } if (m_indexes.contains(name)) { ec = IDBDatabaseException::CONSTRAINT_ERR; return 0; } if (transaction->mode() != IDBTransaction::VERSION_CHANGE) { ec = IDBDatabaseException::NOT_ALLOWED_ERR; return 0; } RefPtr<IDBIndexBackendImpl> index = IDBIndexBackendImpl::create(m_backingStore.get(), m_databaseId, this, name, m_name, keyPath, unique, multiEntry); ASSERT(index->name() == name); RefPtr<IDBObjectStoreBackendImpl> objectStore = this; RefPtr<IDBTransactionBackendInterface> transactionPtr = transaction; if (!transaction->scheduleTask( createCallbackTask(&IDBObjectStoreBackendImpl::createIndexInternal, objectStore, index, transactionPtr), createCallbackTask(&IDBObjectStoreBackendImpl::removeIndexFromMap, objectStore, index))) { ec = IDBDatabaseException::TRANSACTION_INACTIVE_ERR; return 0; } m_indexes.set(name, index); return index.release(); }
void LegacyTransaction::onAbort(PassRefPtr<IDBDatabaseError> prpError) { LOG(StorageAPI, "LegacyTransaction::onAbort"); RefPtr<IDBDatabaseError> error = prpError; ASSERT(m_state != Finished); if (m_state != Finishing) { ASSERT(error.get()); setError(DOMError::create(error->name()), error->message()); // Abort was not triggered by front-end, so outstanding requests must // be aborted now. while (!m_requestList.isEmpty()) { RefPtr<LegacyRequest> request = *m_requestList.begin(); m_requestList.remove(request); request->abort(); } m_state = Finishing; } if (isVersionChange()) { for (auto& objectStore : m_objectStoreCleanupMap) objectStore.key->setMetadata(objectStore.value); m_database->setMetadata(m_previousMetadata); m_database->close(); } m_objectStoreCleanupMap.clear(); closeOpenCursors(); // Enqueue events before notifying database, as database may close which enqueues more events and order matters. enqueueEvent(Event::create(eventNames().abortEvent, true, false)); m_database->transactionFinished(this); }
void CookieManager::removeCookieWithName(const KURL& url, const String& cookieName) { // Dispatch the message because the database cookies are not loaded in memory yet. if (!m_syncedWithDatabase && !m_privateMode) { typedef void (WebCore::CookieManager::*FunctionType)(const KURL&, const String&); BlackBerry::Platform::webKitThreadMessageClient()->dispatchMessage( BlackBerry::Platform::createMethodCallMessage<FunctionType, CookieManager, const KURL, const String>( &CookieManager::removeCookieWithName, this, url, cookieName)); return; } // We get all cookies from all domains that domain matches the request domain // and delete any cookies with the specified name that path matches the request path Vector<RefPtr<ParsedCookie> > results; getRawCookies(results, url, WithHttpOnlyCookies); // Delete the cookies that path matches the request path for (size_t i = 0; i < results.size(); i++) { RefPtr<ParsedCookie> cookie = results[i]; if (!equalIgnoringCase(cookie->name(), cookieName)) continue; if (url.path().startsWith(cookie->path(), false)) { cookie->forceExpire(); checkAndTreatCookie(cookie, RemoveFromBackingStore); } } }
void NamedNodeMap::addAttribute(PassRefPtr<Attribute> prpAttribute) { RefPtr<Attribute> attribute = prpAttribute; if (m_element) m_element->willModifyAttribute(attribute->name(), nullAtom, attribute->value()); m_attributes.append(attribute); if (Attr* attr = attribute->attr()) attr->m_element = m_element; if (m_element) m_element->didModifyAttribute(attribute.get()); }
void RealtimeMediaSourceCenterQt5WebRTC::createMediaStream(MediaStreamCreationClient* client, const String& audioDeviceID, const String& videoDeviceID) { ASSERT(client); RefPtr<RealtimeMediaSourceQt5WebRTC> audioSource = findSource(audioDeviceID, RealtimeMediaSource::Audio); RefPtr<RealtimeMediaSourceQt5WebRTC> videoSource = findSource(videoDeviceID, RealtimeMediaSource::Video); m_sourceMap.clear(); if (!audioSource && !videoSource) { client->failedToCreateStreamWithPermissionError(); return; } String audioSourceName = audioSource ? audioSource->name() : String(); String videoSourceName = videoSource ? videoSource->name() : String(); std::shared_ptr<WRTCInt::RTCMediaStream> rtcStream( getRTCMediaSourceCenter().createMediaStream( audioSourceName.utf8().data(), videoSourceName.utf8().data())); Vector<RefPtr<RealtimeMediaSource>> audioSources; Vector<RefPtr<RealtimeMediaSource>> videoSources; if (audioSource) { audioSource->setRTCStream(rtcStream); audioSources.append(audioSource.release()); } if (videoSource) { videoSource->setRTCStream(rtcStream); videoSources.append(videoSource.release()); } String id = rtcStream->id().c_str(); client->didCreateStream(MediaStreamPrivate::create(id, audioSources, videoSources)); }
void NamedNodeMap::removeAttribute(size_t index) { ASSERT(index < length()); RefPtr<Attribute> attribute = m_attributes[index]; if (m_element) m_element->willRemoveAttribute(attribute->name(), attribute->value()); if (Attr* attr = attribute->attr()) attr->m_element = 0; m_attributes.remove(index); if (m_element) m_element->didRemoveAttribute(attribute.get()); }
// Creates a new SharedWorkerProxy or returns an existing one from the repository. Must only be called while the repository mutex is held. PassRefPtr<SharedWorkerProxy> DefaultSharedWorkerRepository::getProxy(const String& name, const KURL& url) { // Look for an existing worker, and create one if it doesn't exist. // Items in the cache are freed on another thread, so copy the URL before creating the origin, to make sure no references to external strings linger. RefPtr<SecurityOrigin> origin = SecurityOrigin::create(url.copy()); SharedWorkerNameMap* nameMap = m_cache.get(origin); if (!nameMap) { nameMap = new SharedWorkerNameMap(); m_cache.set(origin, nameMap); } RefPtr<SharedWorkerProxy> proxy = nameMap->get(name); if (!proxy.get()) { proxy = SharedWorkerProxy::create(name, url); nameMap->set(proxy->name(), proxy); } return proxy; }
void NamedNodeMap::replaceAttribute(size_t index, PassRefPtr<Attribute> prpAttribute) { ASSERT(index < length()); RefPtr<Attribute> attribute = prpAttribute; Attribute* old = m_attributes[index].get(); if (m_element) m_element->willModifyAttribute(attribute->name(), old->value(), attribute->value()); if (Attr* attr = old->attr()) attr->m_element = 0; m_attributes[index] = attribute; if (Attr* attr = attribute->attr()) attr->m_element = m_element; if (m_element) m_element->didModifyAttribute(attribute.get()); }
void NamedNodeMap::addAttribute(PassRefPtr<Attribute> prpAttribute) { RefPtr<Attribute> attribute = prpAttribute; // Add the attribute to the list m_attributes.append(attribute); if (Attr* attr = attribute->attr()) attr->m_element = m_element; // Notify the element that the attribute has been added, and dispatch appropriate mutation events // Note that element may be null here if we are called from insertAttribute() during parsing if (m_element) { m_element->attributeChanged(attribute.get()); // Because of our updateStyleAttribute() style modification events are never sent at the right time, so don't bother sending them. if (attribute->name() != styleAttr) { m_element->dispatchAttrAdditionEvent(attribute.get()); m_element->dispatchSubtreeModifiedEvent(); } } }
void CookieManager::setCookieInPrivateMode(const URL& url, const String& value, CookieFilter filter) { if (m_acceptPolicy == Never) return; RefPtr<ParsedCookie> cookie = parseOneCookie(url, value); if (!cookie || cookie->name().isEmpty()) return; if (filter == NoHttpOnlyCookies && cookie->isHttpOnly()) return; Vector<String> domain; cookie->domain().split(".", false, domain); m_privateCookiesTree->insert(cookie, domain, m_backingStore.get(), filter, OnlyInMemory); if (m_cookieChangeCallback) m_cookieChangeCallback(); }
void RadioInputType::handleKeydownEvent(KeyboardEvent* event) { BaseCheckableInputType::handleKeydownEvent(event); if (event->defaultHandled()) return; const String& key = event->keyIdentifier(); if (key != "Up" && key != "Down" && key != "Left" && key != "Right") return; // Left and up mean "previous radio button". // Right and down mean "next radio button". // Tested in WinIE, and even for RTL, left still means previous radio button (and so moves // to the right). Seems strange, but we'll match it. // However, when using Spatial Navigation, we need to be able to navigate without changing the selection. if (isSpatialNavigationEnabled(element().document().frame())) return; bool forward = (key == "Down" || key == "Right"); // We can only stay within the form's children if the form hasn't been demoted to a leaf because // of malformed HTML. Node* node = &element(); while ((node = (forward ? NodeTraversal::next(node) : NodeTraversal::previous(node)))) { // Once we encounter a form element, we know we're through. if (is<HTMLFormElement>(*node)) break; // Look for more radio buttons. if (!is<HTMLInputElement>(*node)) continue; RefPtr<HTMLInputElement> inputElement = downcast<HTMLInputElement>(node); if (inputElement->form() != element().form()) break; if (inputElement->isRadioButton() && inputElement->name() == element().name() && inputElement->isFocusable()) { element().document().setFocusedElement(inputElement); inputElement->dispatchSimulatedClick(event, SendNoEvents, DoNotShowPressedLook); event->setDefaultHandled(); return; } } }
String CookieManager::generateHtmlFragmentForCookies() { // If the database hasn't been sync-ed at this point, force a sync load if (!m_syncedWithDatabase && !m_privateMode) m_cookieBackingStore->openAndLoadDatabaseSynchronously(cookieJar()); CookieLog("CookieManager - generateHtmlFragmentForCookies\n"); Vector<RefPtr<ParsedCookie> > cookieCandidates; for (HashMap<String, CookieMap*>::iterator it = m_managerMap.begin(); it != m_managerMap.end(); ++it) it->value->getAllChildCookies(&cookieCandidates); String result; RefPtr<ParsedCookie> cookie = 0; result.append(String("<table style=\"word-wrap:break-word\" cellSpacing=\"0\" cellPadding=\"0\" border=\"1\"><tr><th>Domain</th><th>Path</th><th>Protocol</th><th>Name</th><th>Value</th><th>Secure</th><th>HttpOnly</th><th>Session</th></tr>")); for (size_t i = 0; i < cookieCandidates.size(); ++i) { cookie = cookieCandidates[i]; result.append(String("<tr><td align=\"center\">")); result.append(cookie->domain()); result.append(String("<td align=\"center\">")); result.append(cookie->path()); result.append(String("<td align=\"center\">")); result.append(cookie->protocol()); result.append(String("<td align=\"center\">")); result.append(cookie->name()); result.append(String("<td align=\"center\" style= \"word-break:break-all\">")); result.append(cookie->value()); result.append(String("<td align=\"center\">")); result.append(String(cookie->isSecure() ? "Yes" : "No")); result.append(String("<td align=\"center\">")); result.append(String(cookie->isHttpOnly() ? "Yes" : "No")); result.append(String("<td align=\"center\">")); result.append(String(cookie->isSession() ? "Yes" : "No")); result.append(String("</td></tr>")); } result.append(String("</table>")); return result; }
PassRefPtr<IDBObjectStoreBackendInterface> IDBDatabaseBackendImpl::createObjectStore(const String& name, const String& keyPath, bool autoIncrement, IDBTransactionBackendInterface* transactionPtr, ExceptionCode& ec) { ASSERT(transactionPtr->mode() == IDBTransaction::VERSION_CHANGE); if (m_objectStores.contains(name)) { ec = IDBDatabaseException::CONSTRAINT_ERR; return 0; } RefPtr<IDBObjectStoreBackendImpl> objectStore = IDBObjectStoreBackendImpl::create(m_sqliteDatabase.get(), name, keyPath, autoIncrement); ASSERT(objectStore->name() == name); RefPtr<IDBDatabaseBackendImpl> database = this; RefPtr<IDBTransactionBackendInterface> transaction = transactionPtr; if (!transaction->scheduleTask(createCallbackTask(&IDBDatabaseBackendImpl::createObjectStoreInternal, database, objectStore, transaction), createCallbackTask(&IDBDatabaseBackendImpl::removeObjectStoreFromMap, database, objectStore))) { ec = IDBDatabaseException::NOT_ALLOWED_ERR; return 0; } m_objectStores.set(name, objectStore); return objectStore.release(); }
void IDBObjectStoreBackendImpl::createIndex(const String& name, const String& keyPath, bool unique, PassRefPtr<IDBCallbacks> callbacks) { if (m_indexes.contains(name)) { callbacks->onError(IDBDatabaseError::create(IDBDatabaseException::CONSTRAINT_ERR, "Index name already exists.")); return; } SQLiteStatement insert(sqliteDatabase(), "INSERT INTO Indexes (objectStoreId, name, keyPath, isUnique) VALUES (?, ?, ?, ?)"); bool ok = insert.prepare() == SQLResultOk; ASSERT_UNUSED(ok, ok); // FIXME: Better error handling. insert.bindInt64(1, m_id); insert.bindText(2, name); insert.bindText(3, keyPath); insert.bindInt(4, static_cast<int>(unique)); ok = insert.step() == SQLResultDone; ASSERT_UNUSED(ok, ok); // FIXME: Better error handling. int64_t id = sqliteDatabase().lastInsertRowID(); RefPtr<IDBIndexBackendInterface> index = IDBIndexBackendImpl::create(this, id, name, keyPath, unique); ASSERT(index->name() == name); m_indexes.set(name, index); callbacks->onSuccess(index.release()); }
void CompositeAnimation::updateKeyframeAnimations(RenderObject* renderer, RenderStyle* currentStyle, RenderStyle* targetStyle) { // Nothing to do if we don't have any animations, and didn't have any before if (m_keyframeAnimations.isEmpty() && !targetStyle->hasAnimations()) return; m_keyframeAnimations.checkConsistency(); AnimationNameMap::const_iterator kfend = m_keyframeAnimations.end(); if (currentStyle && currentStyle->hasAnimations() && targetStyle->hasAnimations() && *(currentStyle->animations()) == *(targetStyle->animations())) { // The current and target animations are the same so we just need to toss any // animation which is finished (postActive). for (AnimationNameMap::const_iterator it = m_keyframeAnimations.begin(); it != kfend; ++it) { if (it->second->postActive()) it->second->setIndex(-1); } } else { // Mark all existing animations as no longer active. for (AnimationNameMap::const_iterator it = m_keyframeAnimations.begin(); it != kfend; ++it) it->second->setIndex(-1); // Toss the animation order map. m_keyframeAnimationOrderMap.clear(); // Now mark any still active animations as active and add any new animations. if (targetStyle->animations()) { int numAnims = targetStyle->animations()->size(); for (int i = 0; i < numAnims; ++i) { const Animation* anim = targetStyle->animations()->animation(i); AtomicString animationName(anim->name()); if (!anim->isValidAnimation()) continue; // See if there is a current animation for this name. RefPtr<KeyframeAnimation> keyframeAnim = m_keyframeAnimations.get(animationName.impl()); if (keyframeAnim) { // If this animation is postActive, skip it so it gets removed at the end of this function. if (keyframeAnim->postActive()) continue; // This one is still active. // Animations match, but play states may differ. Update if needed. keyframeAnim->updatePlayState(anim->playState() == AnimPlayStatePlaying); // Set the saved animation to this new one, just in case the play state has changed. keyframeAnim->setAnimation(anim); keyframeAnim->setIndex(i); } else if ((anim->duration() || anim->delay()) && anim->iterationCount()) { keyframeAnim = KeyframeAnimation::create(const_cast<Animation*>(anim), renderer, i, this, targetStyle); m_keyframeAnimations.set(keyframeAnim->name().impl(), keyframeAnim); } // Add this to the animation order map. if (keyframeAnim) m_keyframeAnimationOrderMap.append(keyframeAnim->name().impl()); } } } // Make a list of animations to be removed. Vector<AtomicStringImpl*> animsToBeRemoved; kfend = m_keyframeAnimations.end(); for (AnimationNameMap::const_iterator it = m_keyframeAnimations.begin(); it != kfend; ++it) { KeyframeAnimation* keyframeAnim = it->second.get(); if (keyframeAnim->index() < 0) animsToBeRemoved.append(keyframeAnim->name().impl()); } // Now remove the animations from the list. for (size_t j = 0; j < animsToBeRemoved.size(); ++j) m_keyframeAnimations.remove(animsToBeRemoved[j]); }
void IDBObjectStoreBackendImpl::addIndexToMap(ScriptExecutionContext*, PassRefPtr<IDBObjectStoreBackendImpl> objectStore, PassRefPtr<IDBIndexBackendImpl> index) { RefPtr<IDBIndexBackendImpl> indexPtr = index; ASSERT(!objectStore->m_indexes.contains(indexPtr->name())); objectStore->m_indexes.set(indexPtr->name(), indexPtr); }
void ArgumentCoder<WebCore::FilterOperations>::encode(ArgumentEncoder& encoder, const WebCore::FilterOperations& filters) { encoder << static_cast<uint32_t>(filters.size()); for (size_t i = 0; i < filters.size(); ++i) { const FilterOperation* filter = filters.at(i); FilterOperation::OperationType type = filter->getOperationType(); encoder.encodeEnum(type); switch (type) { case FilterOperation::GRAYSCALE: case FilterOperation::SEPIA: case FilterOperation::SATURATE: case FilterOperation::HUE_ROTATE: encoder << static_cast<double>(static_cast<const BasicColorMatrixFilterOperation*>(filter)->amount()); break; case FilterOperation::INVERT: case FilterOperation::BRIGHTNESS: case FilterOperation::CONTRAST: case FilterOperation::OPACITY: encoder << static_cast<double>(static_cast<const BasicComponentTransferFilterOperation*>(filter)->amount()); break; case FilterOperation::BLUR: ArgumentCoder<Length>::encode(encoder, static_cast<const BlurFilterOperation*>(filter)->stdDeviation()); break; case FilterOperation::DROP_SHADOW: { const DropShadowFilterOperation* shadow = static_cast<const DropShadowFilterOperation*>(filter); ArgumentCoder<IntPoint>::encode(encoder, shadow->location()); encoder << static_cast<int32_t>(shadow->stdDeviation()); ArgumentCoder<Color>::encode(encoder, shadow->color()); break; } #if ENABLE(CSS_SHADERS) case FilterOperation::CUSTOM: // Custom Filters are converted to VALIDATED_CUSTOM before reaching this point. ASSERT_NOT_REACHED(); break; case FilterOperation::VALIDATED_CUSTOM: { const ValidatedCustomFilterOperation* customOperation = static_cast<const ValidatedCustomFilterOperation*>(filter); ASSERT(customOperation->validatedProgram()); RefPtr<CustomFilterValidatedProgram> program = customOperation->validatedProgram(); ASSERT(program->isInitialized()); ASSERT(program->platformCompiledProgram()); ASSERT(program->platformCompiledProgram()->client()); WebCustomFilterProgramProxy* customFilterProgramProxy = static_cast<WebCustomFilterProgramProxy*>(program->platformCompiledProgram()->client()); const CustomFilterProgramInfo& programInfo = program->programInfo(); // FIXME: CustomFilterOperation should not need the meshType, it should just be encoded in the program itself. // https://bugs.webkit.org/show_bug.cgi?id=102529 encoder.encodeEnum(programInfo.meshType()); encoder << customFilterProgramProxy->id(); CustomFilterParameterList parameters = customOperation->parameters(); encoder << static_cast<uint32_t>(parameters.size()); for (size_t i = 0; i < parameters.size(); ++i) { RefPtr<CustomFilterParameter> parameter = parameters[i]; encoder << parameter->name(); encoder.encodeEnum(parameter->parameterType()); switch (parameter->parameterType()) { case CustomFilterParameter::ARRAY: { CustomFilterArrayParameter* arrayParameter = static_cast<CustomFilterArrayParameter*>(parameter.get()); encoder << static_cast<uint32_t>(arrayParameter->size()); for (size_t j = 0; j < arrayParameter->size(); ++j) encoder << arrayParameter->valueAt(j); break; } case CustomFilterParameter::NUMBER: { CustomFilterNumberParameter* nubmerParameter = static_cast<CustomFilterNumberParameter*>(parameter.get()); encoder << static_cast<uint32_t>(nubmerParameter->size()); for (size_t j = 0; j < nubmerParameter->size(); ++j) encoder << nubmerParameter->valueAt(j); break; } case CustomFilterParameter::TRANSFORM: { CustomFilterTransformParameter* transformParameter = static_cast<CustomFilterTransformParameter*>(parameter.get()); ArgumentCoder<TransformOperations>::encode(encoder, transformParameter->operations()); break; } } } encoder << customOperation->meshRows(); encoder << customOperation->meshColumns(); break; } #endif default: break; } } }
void IDBDatabaseBackendImpl::addObjectStoreToMap(ScriptExecutionContext*, PassRefPtr<IDBDatabaseBackendImpl> database, PassRefPtr<IDBObjectStoreBackendImpl> objectStore) { RefPtr<IDBObjectStoreBackendImpl> objectStorePtr = objectStore; ASSERT(!database->m_objectStores.contains(objectStorePtr->name())); database->m_objectStores.set(objectStorePtr->name(), objectStorePtr); }
void CompositeAnimation::updateKeyframeAnimations(RenderObject* renderer, RenderStyle* currentStyle, RenderStyle* targetStyle) { // Nothing to do if we don't have any animations, and didn't have any before if (m_keyframeAnimations.isEmpty() && !targetStyle->hasAnimations()) return; m_keyframeAnimations.checkConsistency(); AnimationNameMap::const_iterator kfend = m_keyframeAnimations.end(); if (currentStyle && currentStyle->hasAnimations() && targetStyle->hasAnimations() && *(currentStyle->animations()) == *(targetStyle->animations())) { // The current and target animations are the same so we just need to toss any // animation which is finished (postActive). for (AnimationNameMap::const_iterator it = m_keyframeAnimations.begin(); it != kfend; ++it) { if (it->value->postActive()) it->value->setIndex(-1); } } else { // Mark all existing animations as no longer active. for (AnimationNameMap::const_iterator it = m_keyframeAnimations.begin(); it != kfend; ++it) it->value->setIndex(-1); // Toss the animation order map. m_keyframeAnimationOrderMap.clear(); DEFINE_STATIC_LOCAL(const AtomicString, none, ("none", AtomicString::ConstructFromLiteral)); // Now mark any still active animations as active and add any new animations. if (targetStyle->animations()) { int numAnims = targetStyle->animations()->size(); for (int i = 0; i < numAnims; ++i) { const Animation& animation = targetStyle->animations()->animation(i); AtomicString animationName(animation.name()); if (!animation.isValidAnimation()) continue; // See if there is a current animation for this name. RefPtr<KeyframeAnimation> keyframeAnim = m_keyframeAnimations.get(animationName.impl()); if (keyframeAnim) { // If this animation is postActive, skip it so it gets removed at the end of this function. if (keyframeAnim->postActive()) continue; // This one is still active. // Animations match, but play states may differ. Update if needed. keyframeAnim->updatePlayState(animation.playState()); // Set the saved animation to this new one, just in case the play state has changed. keyframeAnim->setAnimation(&animation); keyframeAnim->setIndex(i); } else if ((animation.duration() || animation.delay()) && animation.iterationCount() && animationName != none) { keyframeAnim = KeyframeAnimation::create(const_cast<Animation*>(&animation), renderer, i, this, targetStyle); LOG(Animations, "Creating KeyframeAnimation %p with keyframes %s, duration %.2f, delay %.2f, iterations %.2f", keyframeAnim.get(), animation.name().utf8().data(), animation.duration(), animation.delay(), animation.iterationCount()); if (m_suspended) { keyframeAnim->updatePlayState(AnimPlayStatePaused); LOG(Animations, " (created in suspended/paused state)"); } #if !LOG_DISABLED HashSet<CSSPropertyID>::const_iterator endProperties = keyframeAnim->keyframes().endProperties(); for (HashSet<CSSPropertyID>::const_iterator it = keyframeAnim->keyframes().beginProperties(); it != endProperties; ++it) LOG(Animations, " property %s", getPropertyName(*it)); #endif m_keyframeAnimations.set(keyframeAnim->name().impl(), keyframeAnim); } // Add this to the animation order map. if (keyframeAnim) m_keyframeAnimationOrderMap.append(keyframeAnim->name().impl()); } } } // Make a list of animations to be removed. Vector<AtomicStringImpl*> animsToBeRemoved; kfend = m_keyframeAnimations.end(); for (AnimationNameMap::const_iterator it = m_keyframeAnimations.begin(); it != kfend; ++it) { KeyframeAnimation* keyframeAnim = it->value.get(); if (keyframeAnim->index() < 0) { animsToBeRemoved.append(keyframeAnim->name().impl()); animationController()->animationWillBeRemoved(keyframeAnim); keyframeAnim->clear(); LOG(Animations, "Removing KeyframeAnimation %p", keyframeAnim); } } // Now remove the animations from the list. for (size_t j = 0; j < animsToBeRemoved.size(); ++j) m_keyframeAnimations.remove(animsToBeRemoved[j]); }
void CompositeAnimation::updateKeyframeAnimations(RenderElement* renderer, RenderStyle* currentStyle, RenderStyle* targetStyle) { // Nothing to do if we don't have any animations, and didn't have any before if (m_keyframeAnimations.isEmpty() && !targetStyle->hasAnimations()) return; m_keyframeAnimations.checkConsistency(); if (currentStyle && currentStyle->hasAnimations() && targetStyle->hasAnimations() && *(currentStyle->animations()) == *(targetStyle->animations())) { // The current and target animations are the same so we just need to toss any // animation which is finished (postActive). for (auto& animation : m_keyframeAnimations.values()) { if (animation->postActive()) animation->setIndex(-1); } } else { // Mark all existing animations as no longer active. for (auto& animation : m_keyframeAnimations.values()) animation->setIndex(-1); #if ENABLE(CSS_ANIMATIONS_LEVEL_2) m_hasScrollTriggeredAnimation = false; #endif // Toss the animation order map. m_keyframeAnimationOrderMap.clear(); DEPRECATED_DEFINE_STATIC_LOCAL(const AtomicString, none, ("none", AtomicString::ConstructFromLiteral)); // Now mark any still active animations as active and add any new animations. if (targetStyle->animations()) { int numAnims = targetStyle->animations()->size(); for (int i = 0; i < numAnims; ++i) { Animation& animation = targetStyle->animations()->animation(i); AtomicString animationName(animation.name()); if (!animation.isValidAnimation()) continue; // See if there is a current animation for this name. RefPtr<KeyframeAnimation> keyframeAnim = m_keyframeAnimations.get(animationName.impl()); if (keyframeAnim) { // If this animation is postActive, skip it so it gets removed at the end of this function. if (keyframeAnim->postActive()) continue; #if ENABLE(CSS_ANIMATIONS_LEVEL_2) if (animation.trigger()->isScrollAnimationTrigger()) m_hasScrollTriggeredAnimation = true; #endif // This one is still active. // Animations match, but play states may differ. Update if needed. keyframeAnim->updatePlayState(animation.playState()); // Set the saved animation to this new one, just in case the play state has changed. keyframeAnim->setAnimation(animation); keyframeAnim->setIndex(i); } else if ((animation.duration() || animation.delay()) && animation.iterationCount() && animationName != none) { keyframeAnim = KeyframeAnimation::create(animation, renderer, i, this, targetStyle); LOG(Animations, "Creating KeyframeAnimation %p with keyframes %s, duration %.2f, delay %.2f, iterations %.2f", keyframeAnim.get(), animation.name().utf8().data(), animation.duration(), animation.delay(), animation.iterationCount()); if (m_suspended) { keyframeAnim->updatePlayState(AnimPlayStatePaused); LOG(Animations, " (created in suspended/paused state)"); } #if !LOG_DISABLED for (auto propertyID : keyframeAnim->keyframes().properties()) LOG(Animations, " property %s", getPropertyName(propertyID)); #endif #if ENABLE(CSS_ANIMATIONS_LEVEL_2) if (animation.trigger()->isScrollAnimationTrigger()) m_hasScrollTriggeredAnimation = true; #endif m_keyframeAnimations.set(keyframeAnim->name().impl(), keyframeAnim); } // Add this to the animation order map. if (keyframeAnim) m_keyframeAnimationOrderMap.append(keyframeAnim->name().impl()); } } } // Make a list of animations to be removed. Vector<AtomicStringImpl*> animsToBeRemoved; for (auto& animation : m_keyframeAnimations.values()) { if (animation->index() < 0) { animsToBeRemoved.append(animation->name().impl()); animationController().animationWillBeRemoved(animation.get()); animation->clear(); LOG(Animations, "Removing KeyframeAnimation %p", animation.get()); } } // Now remove the animations from the list. for (auto nameForRemoval : animsToBeRemoved) m_keyframeAnimations.remove(nameForRemoval); }
void CookieDatabaseBackingStore::invokeSendChangesToDatabase() { ASSERT(isCurrentThread()); if (!m_db.isOpen()) { LOG_ERROR("Timer Fired, but database is closed."); return; } Vector<CookieAction> changedCookies; { MutexLocker lock(m_mutex); changedCookies.swap(m_changedCookies); ASSERT(m_changedCookies.isEmpty()); } if (changedCookies.isEmpty()) { CookieLog("CookieBackingStore - Timer fired, but no cookies in changelist"); return; } CookieLog("CookieBackingStore - Timer fired, sending changes to database. We have %d changes", changedCookies.size()); SQLiteTransaction transaction(m_db, false); transaction.begin(); // Iterate through every element in the change list to make calls // If error occurs, ignore it and continue to the next statement size_t sizeOfChange = changedCookies.size(); for (size_t i = 0; i < sizeOfChange; i++) { SQLiteStatement* m_statement; const RefPtr<ParsedCookie> cookie = changedCookies[i].first; UpdateParameter action = changedCookies[i].second; if (action == Delete) { m_statement = m_deleteStatement; CookieLog("CookieBackingStore - deleting cookie %s.", cookie.toString().utf8().data()); // Binds all the values if (m_statement->bindText(1, cookie->name()) || m_statement->bindText(2, cookie->domain()) || m_statement->bindText(3, cookie->path()) || m_statement->bindText(4, cookie->protocol())) { LOG_ERROR("Cannot bind cookie data to delete"); LOG_ERROR("SQLite Error Message: %s", m_db.lastErrorMsg()); ASSERT_NOT_REACHED(); continue; } } else { if (action == Update) { CookieLog("CookieBackingStore - updating cookie %s.", cookie->toString().utf8().data()); m_statement = m_updateStatement; } else { CookieLog("CookieBackingStore - inserting cookie %s.", cookie->toString().utf8().data()); m_statement = m_insertStatement; } // Binds all the values if (m_statement->bindText(1, cookie->name()) || m_statement->bindText(2, cookie->value()) || m_statement->bindText(3, cookie->domain()) || m_statement->bindText(4, cookie->path()) || m_statement->bindDouble(5, cookie->expiry()) || m_statement->bindDouble(6, cookie->lastAccessed()) || m_statement->bindInt64(7, cookie->isSecure()) || m_statement->bindInt64(8, cookie->isHttpOnly()) || m_statement->bindDouble(9, cookie->creationTime()) || m_statement->bindText(10, cookie->protocol())) { LOG_ERROR("Cannot bind cookie data to save"); LOG_ERROR("SQLite Error Message: %s", m_db.lastErrorMsg()); ASSERT_NOT_REACHED(); continue; } } int rc = m_statement->step(); m_statement->reset(); if (rc != SQLResultOk && rc != SQLResultDone) { LOG_ERROR("Cannot make call to the database"); LOG_ERROR("SQLite Error Message: %s", m_db.lastErrorMsg()); ASSERT_NOT_REACHED(); continue; } } transaction.commit(); CookieLog("CookieBackingStore - transaction complete"); }
void HTMLViewSourceDocument::addViewSourceToken(Token* token) { if (!m_current) createContainingTable(); if (token->tagName == textAtom) addText(token->text.get(), ""); else if (token->tagName == commentAtom) { if (token->beginTag) { m_current = addSpanWithClassName("webkit-html-comment"); addText(String("<!--") + token->text.get() + "-->", "webkit-html-comment"); } } else { // Handle the tag. String classNameStr = "webkit-html-tag"; m_current = addSpanWithClassName(classNameStr); String text = "<"; if (!token->beginTag) text += "/"; text += token->tagName; Vector<UChar>* guide = token->m_sourceInfo.get(); if (!guide || !guide->size()) text += ">"; addText(text, classNameStr); // Walk our guide string that tells us where attribute names/values should go. if (guide && guide->size()) { unsigned size = guide->size(); unsigned begin = 0; unsigned currAttr = 0; RefPtr<Attribute> attr = 0; for (unsigned i = 0; i < size; i++) { if (guide->at(i) == 'a' || guide->at(i) == 'x' || guide->at(i) == 'v') { // Add in the string. addText(String(static_cast<UChar*>(guide->data()) + begin, i - begin), classNameStr); begin = i + 1; if (guide->at(i) == 'a') { if (token->attrs && currAttr < token->attrs->length()) attr = token->attrs->attributeItem(currAttr++); else attr = 0; } if (attr) { if (guide->at(i) == 'a') { String name = attr->name().toString(); m_current = addSpanWithClassName("webkit-html-attribute-name"); addText(name, "webkit-html-attribute-name"); if (m_current != m_tbody) m_current = static_cast<Element*>(m_current->parent()); } else { const String& value = attr->value().string(); // Compare ignoring case since HTMLTokenizer doesn't // lower names when passing in tokens to // HTMLViewSourceDocument. if (equalIgnoringCase(token->tagName, "base") && equalIgnoringCase(attr->name().localName(), "href")) { // Catch the href attribute in the base element. // It will be used for rendering anchors created // by addLink() below. setBaseElementURL(KURL(url(), value)); } // FIXME: XML could use namespace prefixes and confuse us. if (equalIgnoringCase(attr->name().localName(), "src") || equalIgnoringCase(attr->name().localName(), "href")) m_current = addLink(value, equalIgnoringCase(token->tagName, "a")); else m_current = addSpanWithClassName("webkit-html-attribute-value"); addText(value, "webkit-html-attribute-value"); if (m_current != m_tbody) m_current = static_cast<Element*>(m_current->parent()); } } } } // Add in any string that might be left. if (begin < size) addText(String(static_cast<UChar*>(guide->data()) + begin, size - begin), classNameStr); // Add in the end tag. addText(">", classNameStr); } m_current = m_td; } }