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


C++ TextEditor::GetDocument方法代码示例

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


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

示例1: return

NS_IMETHODIMP
SelectionMoveCommands::DoCommand(const char* aCommandName,
                                 nsISupports* aCommandRefCon) {
  nsCOMPtr<nsIEditor> editor = do_QueryInterface(aCommandRefCon);
  if (NS_WARN_IF(!editor)) {
    return NS_ERROR_FAILURE;
  }

  TextEditor* textEditor = editor->AsTextEditor();
  MOZ_ASSERT(textEditor);
  RefPtr<Document> doc = textEditor->GetDocument();
  if (doc) {
    // Most of the commands below (possibly all of them) need layout to
    // be up to date.
    doc->FlushPendingNotifications(FlushType::Layout);
  }

  nsCOMPtr<nsISelectionController> selectionController =
      textEditor->GetSelectionController();
  if (NS_WARN_IF(!selectionController)) {
    return NS_ERROR_FAILURE;
  }

  // scroll commands
  for (size_t i = 0; i < mozilla::ArrayLength(scrollCommands); i++) {
    const ScrollCommand& cmd = scrollCommands[i];
    if (!nsCRT::strcmp(aCommandName, cmd.reverseScroll)) {
      return (selectionController->*(cmd.scroll))(false);
    } else if (!nsCRT::strcmp(aCommandName, cmd.forwardScroll)) {
      return (selectionController->*(cmd.scroll))(true);
    }
  }

  // caret movement/selection commands
  for (size_t i = 0; i < mozilla::ArrayLength(moveCommands); i++) {
    const MoveCommand& cmd = moveCommands[i];
    if (!nsCRT::strcmp(aCommandName, cmd.reverseMove)) {
      return (selectionController->*(cmd.move))(false, false);
    } else if (!nsCRT::strcmp(aCommandName, cmd.forwardMove)) {
      return (selectionController->*(cmd.move))(true, false);
    } else if (!nsCRT::strcmp(aCommandName, cmd.reverseSelect)) {
      return (selectionController->*(cmd.move))(false, true);
    } else if (!nsCRT::strcmp(aCommandName, cmd.forwardSelect)) {
      return (selectionController->*(cmd.move))(true, true);
    }
  }

  // physical-direction movement/selection
  for (size_t i = 0; i < mozilla::ArrayLength(physicalCommands); i++) {
    const PhysicalCommand& cmd = physicalCommands[i];
    if (!nsCRT::strcmp(aCommandName, cmd.move)) {
      return selectionController->PhysicalMove(cmd.direction, cmd.amount,
                                               false);
    } else if (!nsCRT::strcmp(aCommandName, cmd.select)) {
      return selectionController->PhysicalMove(cmd.direction, cmd.amount, true);
    }
  }

  return NS_ERROR_FAILURE;
}
开发者ID:jasonLaster,项目名称:gecko-dev,代码行数:60,代码来源:EditorCommands.cpp


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