コード例 #1
0
ファイル: nsAppShell.cpp プロジェクト: linclark/gecko-dev
void
nsAppShell::LegacyGeckoEvent::PostTo(mozilla::LinkedList<Event>& queue)
{
    {
        EVLOG("nsAppShell::PostEvent %p %d", ae, ae->Type());
        switch (ae->Type()) {
        case AndroidGeckoEvent::VIEWPORT:
            // Coalesce a previous viewport event with this one, while
            // allowing coalescing to happen across native callback events.
            for (Event* event = queue.getLast(); event;
                    event = event->getPrevious())
            {
                if (event->HasSameTypeAs(this) &&
                        static_cast<LegacyGeckoEvent*>(event)->ae->Type()
                            == AndroidGeckoEvent::VIEWPORT) {
                    // Found a previous viewport event; remove it.
                    delete event;
                    break;
                }
                NativeCallbackEvent callbackEvent(nullptr);
                if (event->HasSameTypeAs(&callbackEvent)) {
                    // Allow coalescing viewport events across callback events.
                    continue;
                }
                // End of search for viewport events to coalesce.
                break;
            }
            queue.insertBack(this);
            break;

        case AndroidGeckoEvent::MOTION_EVENT:
        case AndroidGeckoEvent::APZ_INPUT_EVENT:
            if (sAppShell->mAllowCoalescingTouches) {
                Event* const event = queue.getLast();
                if (event && event->HasSameTypeAs(this) && ae->CanCoalesceWith(
                        static_cast<LegacyGeckoEvent*>(event)->ae.get())) {

                    // consecutive motion-move events; drop the last one before adding the new one
                    EVLOG("nsAppShell: Dropping old move event at %p in favour of new move event %p", event, ae);
                    // Delete the event and remove from list.
                    delete event;
                }
            }
            queue.insertBack(this);
            break;

        default:
            queue.insertBack(this);
            break;
        }
    }
}
コード例 #2
0
ファイル: nsAppShell.cpp プロジェクト: JasonJinCn/gecko-dev
void
nsAppShell::LegacyGeckoEvent::PostTo(mozilla::LinkedList<Event>& queue)
{
    {
        EVLOG("nsAppShell::PostEvent %p %d", ae, ae->Type());
        switch (ae->Type()) {
        case AndroidGeckoEvent::COMPOSITOR_CREATE:
        case AndroidGeckoEvent::COMPOSITOR_PAUSE:
        case AndroidGeckoEvent::COMPOSITOR_RESUME:
            // Give priority to these events, but maintain their order wrt each other.
            {
                Event* event = queue.getFirst();
                while (event && event->HasSameTypeAs(this)) {
                    const auto& e = static_cast<LegacyGeckoEvent*>(event)->ae;
                    if (e->Type() != AndroidGeckoEvent::COMPOSITOR_CREATE
                            && e->Type() != AndroidGeckoEvent::COMPOSITOR_PAUSE
                            && e->Type() != AndroidGeckoEvent::COMPOSITOR_RESUME) {
                        break;
                    }
                    event = event->getNext();
                }
                if (event) {
                    event->setPrevious(this);
                } else {
                    queue.insertFront(this);
                }
                EVLOG("nsAppShell: Inserting compositor event %d to maintain priority order", ae->Type());
            }
            break;

        case AndroidGeckoEvent::VIEWPORT:
            // Coalesce a previous viewport event with this one, while
            // allowing coalescing to happen across native callback events.
            for (Event* event = queue.getLast(); event;
                    event = event->getPrevious())
            {
                if (event->HasSameTypeAs(this) &&
                        static_cast<LegacyGeckoEvent*>(event)->ae->Type()
                            == AndroidGeckoEvent::VIEWPORT) {
                    // Found a previous viewport event; remove it.
                    delete event;
                    break;
                }
                NativeCallbackEvent callbackEvent(nullptr);
                if (event->HasSameTypeAs(&callbackEvent)) {
                    // Allow coalescing viewport events across callback events.
                    continue;
                }
                // End of search for viewport events to coalesce.
                break;
            }
            queue.insertBack(this);
            break;

        case AndroidGeckoEvent::MOTION_EVENT:
        case AndroidGeckoEvent::APZ_INPUT_EVENT:
            if (nsAppShell::gAppShell->mAllowCoalescingTouches) {
                Event* const event = queue.getLast();
                if (event && event->HasSameTypeAs(this) && ae->CanCoalesceWith(
                        static_cast<LegacyGeckoEvent*>(event)->ae.get())) {

                    // consecutive motion-move events; drop the last one before adding the new one
                    EVLOG("nsAppShell: Dropping old move event at %p in favour of new move event %p", event, ae);
                    // Delete the event and remove from list.
                    delete event;
                }
            }
            queue.insertBack(this);
            break;

        default:
            queue.insertBack(this);
            break;
        }
    }
}