void SpeechSynthesis::boundaryEventOccurred(PassRefPtr<PlatformSpeechSynthesisUtterance> utterance, SpeechBoundary boundary, unsigned charIndex)
{
    DEPRECATED_DEFINE_STATIC_LOCAL(const String, wordBoundaryString, (ASCIILiteral("word")));
    DEPRECATED_DEFINE_STATIC_LOCAL(const String, sentenceBoundaryString, (ASCIILiteral("sentence")));

    switch (boundary) {
    case SpeechWordBoundary:
        fireEvent(eventNames().boundaryEvent, static_cast<SpeechSynthesisUtterance*>(utterance->client()), charIndex, wordBoundaryString);
        break;
    case SpeechSentenceBoundary:
        fireEvent(eventNames().boundaryEvent, static_cast<SpeechSynthesisUtterance*>(utterance->client()), charIndex, sentenceBoundaryString);
        break;
    default:
        ASSERT_NOT_REACHED();
    }
}
Example #2
0
void Profiler::didFinishAllExecution(ExecState* exec)
{
    ExecState* globalExec = exec->lexicalGlobalObject()->globalExec();
    for (ptrdiff_t i = m_currentProfiles.size() - 1; i >= 0; --i) {
        ProfileGenerator* profileGenerator = m_currentProfiles[i].get();
        if (profileGenerator->originatingGlobalExec() == globalExec && profileGenerator->didFinishAllExecution()) {
            PassRefPtr<ProfileGenerator> prpProfileGenerator = m_currentProfiles[i].release();
            m_currentProfiles.remove(i);

            if (!m_currentProfiles.size())
                s_sharedEnabledProfilerReference = 0;

            if (ProfilerClient* client = prpProfileGenerator->client())
                client->finishedProfiling(prpProfileGenerator->profile());
        }
    }
}
Example #3
0
WebKitNotification::WebKitNotification(const String& title, const String& body, const String& iconUrl, ExecutionContext* context, ExceptionState& es, PassRefPtr<NotificationCenter> provider)
    : NotificationBase(title, context, provider->client())
{
    ScriptWrappable::init(this);

    if (provider->checkPermission() != NotificationClient::PermissionAllowed) {
        es.throwSecurityError("Notification permission has not been granted.");
        return;
    }

    KURL icon = iconUrl.isEmpty() ? KURL() : executionContext()->completeURL(iconUrl);
    if (!icon.isEmpty() && !icon.isValid()) {
        es.throwDOMException(SyntaxError, "'" + iconUrl + "' is not a valid icon URL.");
        return;
    }

    setBody(body);
    setIconUrl(icon);
}
Notification::Notification(const String& title, const String& body, const String& iconURI, ScriptExecutionContext* context, ExceptionState& es, PassRefPtr<NotificationCenter> provider)
    : ActiveDOMObject(context)
    , m_title(title)
    , m_body(body)
    , m_state(Idle)
    , m_notificationClient(provider->client())
{
    ASSERT(m_notificationClient);

    ScriptWrappable::init(this);
    if (provider->checkPermission() != NotificationClient::PermissionAllowed) {
        es.throwSecurityError(ExceptionMessages::failedToExecute("createNotification", "NotificationCenter", "Notification permission has not been granted."));
        return;
    }

    m_icon = iconURI.isEmpty() ? KURL() : scriptExecutionContext()->completeURL(iconURI);
    if (!m_icon.isEmpty() && !m_icon.isValid()) {
        es.throwDOMException(SyntaxError, ExceptionMessages::failedToExecute("createNotification", "NotificationCenter", "'" + iconURI + "' is not a valid icon URL."));
        return;
    }
}
void SpeechSynthesis::speakingErrorOccurred(PassRefPtr<PlatformSpeechSynthesisUtterance> utterance)
{
    if (utterance->client())
        handleSpeakingCompleted(static_cast<SpeechSynthesisUtterance*>(utterance->client()), true);
}
void SpeechSynthesis::didFinishSpeaking(PassRefPtr<PlatformSpeechSynthesisUtterance> utterance)
{
    if (utterance->client())
        handleSpeakingCompleted(static_cast<SpeechSynthesisUtterance*>(utterance->client()), false);
}
void SpeechSynthesis::didResumeSpeaking(PassRefPtr<PlatformSpeechSynthesisUtterance> utterance)
{
    m_isPaused = false;
    if (utterance->client())
        fireEvent(eventNames().resumeEvent, static_cast<SpeechSynthesisUtterance*>(utterance->client()), 0, String());
}
void SpeechSynthesis::didStartSpeaking(PassRefPtr<PlatformSpeechSynthesisUtterance> utterance)
{
    if (utterance->client())
        fireEvent(eventNames().startEvent, static_cast<SpeechSynthesisUtterance*>(utterance->client()), 0, String());
}