Exemple #1
0
void EditCommand::setEndingSelection(const VisibleSelection &s)
{
    Element* root = s.rootEditableElement();
    for (EditCommand* cmd = this; cmd; cmd = cmd->m_parent) {
        cmd->m_endingSelection = s;
        cmd->m_endingRootEditableElement = root;
    }
}
bool canAppendNewLineFeedToSelection(const VisibleSelection& selection)
{
    Node* node = selection.rootEditableElement();
    if (!node)
        return false;
    
    RefPtr<BeforeTextInsertedEvent> event = BeforeTextInsertedEvent::create(String("\n"));
    node->dispatchEvent(event, IGNORE_EXCEPTION);
    return event->text().length();
}
bool canAppendNewLineFeedToSelection(const VisibleSelection& selection)
{
    Element* element = selection.rootEditableElement();
    if (!element)
        return false;

    RefPtrWillBeRawPtr<BeforeTextInsertedEvent> event = BeforeTextInsertedEvent::create(String("\n"));
    element->dispatchEvent(event);
    return event->text().length();
}
Exemple #4
0
void EditCommand::setStartingSelection(const VisibleSelection& s)
{
    Element* root = s.rootEditableElement();
    for (EditCommand* cmd = this; ; cmd = cmd->m_parent) {
        cmd->m_startingSelection = s;
        cmd->m_startingRootEditableElement = root;
        if (!cmd->m_parent || cmd->m_parent->isFirstCommand(cmd))
            break;
    }
}
Exemple #5
0
static bool canAppendNewLineFeed(const VisibleSelection& selection)
{
    Node* node = selection.rootEditableElement();
    if (!node)
        return false;

    RefPtr<BeforeTextInsertedEvent> event = BeforeTextInsertedEvent::create(String("\n"));
    ExceptionCode ec = 0;
    node->dispatchEvent(event, ec);
    return event->text().length();
}
Exemple #6
0
void EditorClientImpl::toggleContinuousSpellChecking()
{
    if (isContinuousSpellCheckingEnabled()) {
        m_spellCheckThisFieldStatus = SpellCheckForcedOff;
    } else {
        m_spellCheckThisFieldStatus = SpellCheckForcedOn;
        const Frame* frame = m_webView->focusedWebCoreFrame();
        if (frame) {
            VisibleSelection frameSelection = frame->selection()->selection();
            Element* rootEditableElement = frameSelection.rootEditableElement();
            // If a selection is in an editable element spell check its content.
            if (rootEditableElement) {
                VisibleSelection selection = VisibleSelection::selectionFromContentsOfNode(rootEditableElement);
                frame->editor()->markMisspellingsAndBadGrammar(selection);
            }
        }
    }
}
void EditorClientImpl::toggleContinuousSpellChecking()
{
    if (isContinuousSpellCheckingEnabled()) {
        m_spellCheckThisFieldStatus = SpellCheckForcedOff;
        if (Page* page = m_webView->page()) {
            for (Frame* frame = page->mainFrame(); frame && frame->document(); frame = frame->tree()->traverseNext()) {
                frame->document()->markers()->removeMarkers(DocumentMarker::MisspellingMarkers());
            }
        }
    } else {
        m_spellCheckThisFieldStatus = SpellCheckForcedOn;
        if (Frame* frame = m_webView->focusedWebCoreFrame()) {
            VisibleSelection frameSelection = frame->selection().selection();
            // If a selection is in an editable element spell check its content.
            if (Element* rootEditableElement = frameSelection.rootEditableElement()) {
                frame->editor().elementDidBeginEditing(rootEditableElement);
            }
        }
    }
}