本文整理汇总了C++中Selection::GetFocusNode方法的典型用法代码示例。如果您正苦于以下问题:C++ Selection::GetFocusNode方法的具体用法?C++ Selection::GetFocusNode怎么用?C++ Selection::GetFocusNode使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Selection
的用法示例。
在下文中一共展示了Selection::GetFocusNode方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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);
}
}
示例2: ProcessTextSelChangeEvent
void SelectionManager::ProcessTextSelChangeEvent(AccEvent* aEvent) {
// Fire selection change event if it's not pure caret-move selection change,
// i.e. the accessible has or had not collapsed selection.
AccTextSelChangeEvent* event = downcast_accEvent(aEvent);
if (!event->IsCaretMoveOnly()) nsEventShell::FireEvent(aEvent);
// Fire caret move event if there's a caret in the selection.
nsINode* caretCntrNode = nsCoreUtils::GetDOMNodeFromDOMPoint(
event->mSel->GetFocusNode(), event->mSel->FocusOffset());
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;
Selection* selection = caretCntr->DOMSelection();
// XXX Sometimes we can't get a selection for caretCntr, in that case assume
// event->mSel is correct.
if (!selection) selection = event->mSel;
mCaretOffset = caretCntr->DOMPointToOffset(selection->GetFocusNode(),
selection->FocusOffset());
mAccWithCaret = caretCntr;
if (mCaretOffset != -1) {
RefPtr<AccCaretMoveEvent> caretMoveEvent =
new AccCaretMoveEvent(caretCntr, mCaretOffset, aEvent->FromUserInput());
nsEventShell::FireEvent(caretMoveEvent);
}
}
示例3: GetSelection
void
AccessibleCaretManager::UpdateCaretsForCursorMode()
{
AC_LOG("%s, selection: %p", __FUNCTION__, GetSelection());
nsRefPtr<nsCaret> caret = mPresShell->GetCaret();
if (!caret || !caret->IsVisible()) {
HideCarets();
return;
}
nsRefPtr<nsFrameSelection> fs = GetFrameSelection();
Selection* selection = GetSelection();
if (!fs || !selection) {
HideCarets();
return;
}
nsINode* focusNode = selection->GetFocusNode();
nsIContent* focusContent = focusNode->AsContent();
uint32_t focusOffset = selection->FocusOffset();
nsIFrame* frame = nullptr;
int32_t offset = 0;
nsresult rv = nsCaret::GetCaretFrameForNodeOffset(
fs, focusContent, focusOffset, fs->GetHint(), fs->GetCaretBidiLevel(),
&frame, &offset);
if (NS_FAILED(rv) || !frame) {
HideCarets();
return;
}
Element* editingHost = frame->GetContent()->GetEditingHost();
if (!editingHost) {
HideCarets();
return;
}
// No need to consider whether the caret's position is out of scrollport.
// According to the spec, we need to explicitly hide it after the scrolling is
// ended.
bool oldSecondCaretVisible = mSecondCaret->IsLogicallyVisible();
PositionChangedResult caretResult = mFirstCaret->SetPosition(frame, offset);
mFirstCaret->SetSelectionBarEnabled(false);
if (nsContentUtils::HasNonEmptyTextContent(
editingHost, nsContentUtils::eRecurseIntoChildren)) {
mFirstCaret->SetAppearance(Appearance::Normal);
} else {
mFirstCaret->SetAppearance(Appearance::NormalNotShown);
}
LaunchCaretTimeoutTimer();
mSecondCaret->SetAppearance(Appearance::None);
if ((caretResult == PositionChangedResult::Changed ||
oldSecondCaretVisible) && !mActiveCaret) {
DispatchCaretStateChangedEvent(CaretChangedReason::Updateposition);
}
}
示例4: SchedulePaint
void nsCaret::SchedulePaint()
{
Selection* selection = GetSelectionInternal();
nsINode* focusNode;
if (mOverrideContent) {
focusNode = mOverrideContent;
} else if (selection) {
focusNode = selection->GetFocusNode();
} else {
return;
}
if (!focusNode || !focusNode->IsContent()) {
return;
}
nsIFrame* f = focusNode->AsContent()->GetPrimaryFrame();
if (!f) {
return;
}
// This may not be the correct continuation frame, but that's OK since we're
// just scheduling a paint of the window (or popup).
f->SchedulePaint();
}