void AccessibilityMenuListPopup::didUpdateActiveOption(int optionIndex)
{
    ASSERT_ARG(optionIndex, optionIndex >= 0);
    ASSERT_ARG(optionIndex, optionIndex < static_cast<int>(m_children.size()));

    AXObjectCache* cache = axObjectCache();
    RefPtr<AccessibilityObject> child = m_children[optionIndex].get();

    cache->postNotification(child.get(), document(), AXObjectCache::AXFocusedUIElementChanged, TargetElement, PostSynchronously);
    cache->postNotification(child.get(), document(), AXObjectCache::AXMenuListItemSelected, TargetElement, PostSynchronously);
}
void AccessibilityMenuList::didUpdateActiveOption(int optionIndex)
{
    Ref<Document> document(m_renderer->document());
    AXObjectCache* cache = document->axObjectCache();

    const auto& childObjects = children();
    if (!childObjects.isEmpty()) {
        ASSERT(childObjects.size() == 1);
        ASSERT(childObjects[0]->isMenuListPopup());

        // We might be calling this method in situations where the renderers for list items
        // associated to the menu list have not been created (e.g. they might be rendered
        // in the UI process, as it's the case in the GTK+ port, which uses GtkMenuItem).
        // So, we need to make sure that the accessibility popup object has some children
        // before asking it to update its active option, or it will read invalid memory.
        // You can reproduce the issue in the GTK+ port by removing this check and running
        // accessibility/insert-selected-option-into-select-causes-crash.html (will crash).
        int popupChildrenSize = static_cast<int>(childObjects[0]->children().size());
        if (childObjects[0]->isMenuListPopup() && optionIndex >= 0 && optionIndex < popupChildrenSize) {
            if (AccessibilityMenuListPopup* popup = toAccessibilityMenuListPopup(childObjects[0].get()))
                popup->didUpdateActiveOption(optionIndex);
        }
    }

    cache->postNotification(this, &document.get(), AXObjectCache::AXMenuListValueChanged, TargetElement, PostSynchronously);
}
Exemple #3
0
bool Scrollbar::scroll(ScrollDirection direction, ScrollGranularity granularity, float multiplier)
{
#if HAVE(ACCESSIBILITY)
    if (AXObjectCache::accessibilityEnabled()) {
        if (parent() && parent()->isFrameView()) {
            Document* document = static_cast<FrameView*>(parent())->frame()->document();
            AXObjectCache* cache = document->axObjectCache();
            AccessibilityScrollbar* axObject = static_cast<AccessibilityScrollbar*>(cache->getOrCreate(ScrollBarRole));
            axObject->setScrollbar(this);
            cache->postNotification(axObject, document, AXObjectCache::AXValueChanged, true);
        }
    }
#endif

    // Ignore perpendicular scrolls.
    if ((m_orientation == HorizontalScrollbar) ? (direction == ScrollUp || direction == ScrollDown) : (direction == ScrollLeft || direction == ScrollRight))
        return false;
    float step = 0;
    switch (granularity) {
    case ScrollByLine:     step = m_lineStep;  break;
    case ScrollByPage:     step = m_pageStep;  break;
    case ScrollByDocument: step = m_totalSize; break;
    case ScrollByPixel:    step = m_pixelStep; break;
    }
    if (direction == ScrollUp || direction == ScrollLeft)
        multiplier = -multiplier;
    if (client())
        return client()->scroll(m_orientation, granularity, step, multiplier);

    return setCurrentPos(max(min(m_currentPos + (step * multiplier), static_cast<float>(m_totalSize - m_visibleSize)), 0.0f), NotFromScrollAnimator);
}
void AccessibilityMenuList::didUpdateActiveOption(int optionIndex)
{
    const AccessibilityChildrenVector& childObjects = children();
    if (childObjects.isEmpty())
        return;

    ASSERT(childObjects.size() == 1);
    ASSERT(childObjects[0]->isMenuListPopup());

    RefPtr<Document> document = m_renderer->document();
    AXObjectCache* cache = document->axObjectCache();

    if (AccessibilityMenuListPopup* popup = static_cast<AccessibilityMenuListPopup*>(childObjects[0].get()))
        popup->didUpdateActiveOption(optionIndex);

    cache->postNotification(this, document.get(), AXObjectCache::AXMenuListValueChanged, true, PostSynchronously);
}
void AccessibilityMenuList::didUpdateActiveOption(int optionIndex)
{
    Ref<Document> document(m_renderer->document());
    AXObjectCache* cache = document->axObjectCache();

    const AccessibilityChildrenVector& childObjects = children();
    if (!childObjects.isEmpty()) {
        ASSERT(childObjects.size() == 1);
        ASSERT(childObjects[0]->isMenuListPopup());

        if (childObjects[0]->isMenuListPopup()) {
            if (AccessibilityMenuListPopup* popup = toAccessibilityMenuListPopup(childObjects[0].get()))
                popup->didUpdateActiveOption(optionIndex);
        }
    }

    cache->postNotification(this, &document.get(), AXObjectCache::AXMenuListValueChanged, TargetElement, PostSynchronously);
}