Beispiel #1
0
ExceptionOr<Ref<Database>> DatabaseManager::tryToOpenDatabaseBackend(DatabaseContext& backendContext, const String& name, const String& expectedVersion, const String& displayName, unsigned estimatedSize, bool setVersionInNewDatabase,
    OpenAttempt attempt)
{
    ExceptionOr<void> preflightResult;
    switch (attempt) {
    case FirstTryToOpenDatabase:
        preflightResult = DatabaseTracker::singleton().canEstablishDatabase(backendContext, name, estimatedSize);
        break;
    case RetryOpenDatabase:
        preflightResult = DatabaseTracker::singleton().retryCanEstablishDatabase(backendContext, name, estimatedSize);
        break;
    }
    if (preflightResult.hasException())
        return preflightResult.releaseException();

    auto database = adoptRef(*new Database(backendContext, name, expectedVersion, displayName, estimatedSize));

    auto openResult = database->openAndVerifyVersion(setVersionInNewDatabase);
    if (openResult.hasException())
        return openResult.releaseException();

    // FIXME: What guarantees backendContext.securityOrigin() is non-null?
    DatabaseTracker::singleton().setDatabaseDetails(backendContext.securityOrigin(), name, displayName, estimatedSize);
    return WTFMove(database);
}
Beispiel #2
0
ExceptionOr<Ref<HTMLTableCellElement>> HTMLTableRowElement::insertCell(int index)
{
    if (index < -1)
        return Exception { INDEX_SIZE_ERR };
    auto children = cells();
    int numCells = children->length();
    if (index > numCells)
        return Exception { INDEX_SIZE_ERR };
    auto cell = HTMLTableCellElement::create(tdTag, document());
    ExceptionOr<void> result;
    if (index < 0 || index >= numCells)
        result = appendChild(cell);
    else
        result = insertBefore(cell, index < 1 ? firstChild() : children->item(index));
    if (result.hasException())
        return result.releaseException();
    return WTFMove(cell);
}