void InsertNodeBeforeCommand::doUnapply()
{
    if (!isEditableNode(*m_insertChild))
        return;

    // Need to notify this before actually deleting the text
    if (shouldPostAccessibilityNotification()) {
        Position position = is<Text>(m_insertChild.get()) ? Position(downcast<Text>(m_insertChild.get()), 0) : createLegacyEditingPosition(m_insertChild.get(), 0);
        notifyAccessibilityForTextChange(m_insertChild.get(), unapplyEditType(), m_insertChild->nodeValue(), VisiblePosition(position));
    }

    m_insertChild->remove(IGNORE_EXCEPTION);
}
void InsertNodeBeforeCommand::doApply()
{
    ContainerNode* parent = m_refChild->parentNode();
    if (!parent || (m_shouldAssumeContentIsAlwaysEditable == DoNotAssumeContentIsAlwaysEditable && !isEditableNode(*parent)))
        return;
    ASSERT(isEditableNode(*parent));

    parent->insertBefore(*m_insertChild, m_refChild.get(), IGNORE_EXCEPTION);

    if (shouldPostAccessibilityNotification()) {
        Position position = is<Text>(m_insertChild.get()) ? Position(downcast<Text>(m_insertChild.get()), 0) : createLegacyEditingPosition(m_insertChild.get(), 0);
        notifyAccessibilityForTextChange(m_insertChild.get(), applyEditType(), m_insertChild->nodeValue(), VisiblePosition(position));
    }
}
void ReplaceInsertIntoTextNodeCommand::notifyAccessibilityForTextChange(Node* node, AXTextEditType type, const String& text, const VisiblePosition& position)
{
    if (!shouldPostAccessibilityNotification())
        return;
    AXObjectCache* cache = document().existingAXObjectCache();
    if (!cache)
        return;
    switch (type) {
    case AXTextEditTypeAttributesChange:
    case AXTextEditTypeCut:
    case AXTextEditTypeUnknown:
        break;
    case AXTextEditTypeDelete:
        cache->postTextReplacementNotification(node, AXTextEditTypeDelete, text, AXTextEditTypeInsert, m_deletedText, position);
        break;
    case AXTextEditTypeDictation:
    case AXTextEditTypeInsert:
    case AXTextEditTypePaste:
    case AXTextEditTypeTyping:
        cache->postTextReplacementNotification(node, AXTextEditTypeDelete, m_deletedText, type, text, position);
        break;
    }
}