当前位置: 首页>>代码示例>>C++>>正文


C++ HyperTextAccessible::GetCaretOffset方法代码示例

本文整理汇总了C++中HyperTextAccessible::GetCaretOffset方法的典型用法代码示例。如果您正苦于以下问题:C++ HyperTextAccessible::GetCaretOffset方法的具体用法?C++ HyperTextAccessible::GetCaretOffset怎么用?C++ HyperTextAccessible::GetCaretOffset使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在HyperTextAccessible的用法示例。


在下文中一共展示了HyperTextAccessible::GetCaretOffset方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: AccCaretMoveEvent

void
SelectionManager::NormalSelectionChanged(nsISelection* aSelection)
{
  mLastUsedSelection = do_GetWeakReference(aSelection);

  int32_t rangeCount = 0;
  aSelection->GetRangeCount(&rangeCount);
  if (rangeCount == 0) {
    mLastTextAccessible = nullptr;
    return; // No selection
  }

  HyperTextAccessible* textAcc =
    nsAccUtils::GetTextAccessibleFromSelection(aSelection);
  if (!textAcc)
    return;

  int32_t caretOffset = -1;
  nsresult rv = textAcc->GetCaretOffset(&caretOffset);
  if (NS_FAILED(rv))
    return;

  if (textAcc == mLastTextAccessible && caretOffset == mLastCaretOffset) {
    int32_t selectionCount = 0;
    textAcc->GetSelectionCount(&selectionCount);   // Don't swallow similar events when selecting text
    if (!selectionCount)
      return;  // Swallow duplicate caret event
  }

  mLastCaretOffset = caretOffset;
  mLastTextAccessible = textAcc;

  nsRefPtr<AccEvent> event = new AccCaretMoveEvent(mLastTextAccessible);
  mLastTextAccessible->Document()->FireDelayedEvent(event);
}
开发者ID:Incognito,项目名称:mozilla-central,代码行数:35,代码来源:SelectionManager.cpp

示例2: AccCaretMoveEvent

void
SelectionManager::ProcessTextSelChangeEvent(AccEvent* aEvent)
{
  AccTextSelChangeEvent* event = downcast_accEvent(aEvent);
  Selection* sel = static_cast<Selection*>(event->mSel.get());

  // Fire selection change event if it's not pure caret-move selection change.
  if (sel->GetRangeCount() != 1 || !sel->IsCollapsed())
    nsEventShell::FireEvent(aEvent);

  // Fire caret move event if there's a caret in the selection.
  nsINode* caretCntrNode =
    nsCoreUtils::GetDOMNodeFromDOMPoint(sel->GetFocusNode(),
                                        sel->GetFocusOffset());
  if (!caretCntrNode)
    return;

  HyperTextAccessible* caretCntr = nsAccUtils::GetTextContainer(caretCntrNode);
  NS_ASSERTION(caretCntr,
               "No text container for focus while there's one for common ancestor?!");
  if (!caretCntr)
    return;

  int32_t caretOffset = -1;
  if (NS_SUCCEEDED(caretCntr->GetCaretOffset(&caretOffset)) && caretOffset != -1) {
    nsRefPtr<AccCaretMoveEvent> caretMoveEvent =
      new AccCaretMoveEvent(caretCntr, caretOffset, aEvent->FromUserInput());
    nsEventShell::FireEvent(caretMoveEvent);
  }
}
开发者ID:drexler,项目名称:releases-mozilla-aurora,代码行数:30,代码来源:SelectionManager.cpp

示例3: GetAccessibleWrap

static gint
getCaretOffsetCB(AtkText *aText)
{
  AccessibleWrap* accWrap = GetAccessibleWrap(ATK_OBJECT(aText));
  if (!accWrap)
    return 0;

  HyperTextAccessible* text = accWrap->AsHyperText();
  if (!text || !text->IsTextRole())
    return 0;

    int32_t offset;
    nsresult rv = text->GetCaretOffset(&offset);
    return (NS_FAILED(rv)) ? 0 : static_cast<gint>(offset);
}
开发者ID:hideakihata,项目名称:mozilla-central.fgv,代码行数:15,代码来源:nsMaiInterfaceText.cpp

示例4: FocusMgr

void
EventQueue::ProcessEventQueue()
{
    // Process only currently queued events.
    nsTArray<nsRefPtr<AccEvent> > events;
    events.SwapElements(mEvents);

    uint32_t eventCount = events.Length();
#ifdef A11Y_LOG
    if (eventCount > 0 && logging::IsEnabled(logging::eEvents)) {
        logging::MsgBegin("EVENTS", "events processing");
        logging::Address("document", mDocument);
        logging::MsgEnd();
    }
#endif

    for (uint32_t idx = 0; idx < eventCount; idx++) {
        AccEvent* event = events[idx];
        if (event->mEventRule != AccEvent::eDoNotEmit) {
            Accessible* target = event->GetAccessible();
            if (!target || target->IsDefunct())
                continue;

            // Dispatch the focus event if target is still focused.
            if (event->mEventType == nsIAccessibleEvent::EVENT_FOCUS) {
                FocusMgr()->ProcessFocusEvent(event);
                continue;
            }

            // Dispatch caret moved and text selection change events.
            if (event->mEventType == nsIAccessibleEvent::EVENT_TEXT_CARET_MOVED) {
                AccCaretMoveEvent* caretMoveEvent = downcast_accEvent(event);
                HyperTextAccessible* hyperText = target->AsHyperText();
                if (hyperText &&
                        NS_SUCCEEDED(hyperText->GetCaretOffset(&caretMoveEvent->mCaretOffset))) {

                    nsEventShell::FireEvent(caretMoveEvent);

                    // There's a selection so fire selection change as well.
                    int32_t selectionCount;
                    hyperText->GetSelectionCount(&selectionCount);
                    if (selectionCount)
                        nsEventShell::FireEvent(nsIAccessibleEvent::EVENT_TEXT_SELECTION_CHANGED,
                                                hyperText);
                }
                continue;
            }

            // Fire selected state change events in support to selection events.
            if (event->mEventType == nsIAccessibleEvent::EVENT_SELECTION_ADD) {
                nsEventShell::FireEvent(event->mAccessible, states::SELECTED,
                                        true, event->mIsFromUserInput);

            } else if (event->mEventType == nsIAccessibleEvent::EVENT_SELECTION_REMOVE) {
                nsEventShell::FireEvent(event->mAccessible, states::SELECTED,
                                        false, event->mIsFromUserInput);

            } else if (event->mEventType == nsIAccessibleEvent::EVENT_SELECTION) {
                AccSelChangeEvent* selChangeEvent = downcast_accEvent(event);
                nsEventShell::FireEvent(event->mAccessible, states::SELECTED,
                                        (selChangeEvent->mSelChangeType == AccSelChangeEvent::eSelectionAdd),
                                        event->mIsFromUserInput);

                if (selChangeEvent->mPackedEvent) {
                    nsEventShell::FireEvent(selChangeEvent->mPackedEvent->mAccessible,
                                            states::SELECTED,
                                            (selChangeEvent->mPackedEvent->mSelChangeType == AccSelChangeEvent::eSelectionAdd),
                                            selChangeEvent->mPackedEvent->mIsFromUserInput);
                }
            }

            nsEventShell::FireEvent(event);

            // Fire text change events.
            AccMutationEvent* mutationEvent = downcast_accEvent(event);
            if (mutationEvent) {
                if (mutationEvent->mTextChangeEvent)
                    nsEventShell::FireEvent(mutationEvent->mTextChangeEvent);
            }
        }

        if (event->mEventType == nsIAccessibleEvent::EVENT_HIDE)
            mDocument->ShutdownChildrenInSubtree(event->mAccessible);

        if (!mDocument)
            return;
    }
}
开发者ID:eric30,项目名称:releases-mozilla-central,代码行数:88,代码来源:EventQueue.cpp


注:本文中的HyperTextAccessible::GetCaretOffset方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。