本文整理汇总了C++中SelectionController::rootEditableElement方法的典型用法代码示例。如果您正苦于以下问题:C++ SelectionController::rootEditableElement方法的具体用法?C++ SelectionController::rootEditableElement怎么用?C++ SelectionController::rootEditableElement使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SelectionController
的用法示例。
在下文中一共展示了SelectionController::rootEditableElement方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: clearSelectionIfNeeded
static void clearSelectionIfNeeded(Frame* oldFocusedFrame, Frame* newFocusedFrame, Node* newFocusedNode)
{
if (!oldFocusedFrame || !newFocusedFrame)
return;
if (oldFocusedFrame->document() != newFocusedFrame->document())
return;
SelectionController* s = oldFocusedFrame->selection();
if (s->isNone())
return;
bool caretBrowsing = oldFocusedFrame->settings()->caretBrowsingEnabled();
if (caretBrowsing)
return;
Node* selectionStartNode = s->selection().start().node();
if (selectionStartNode == newFocusedNode || selectionStartNode->isDescendantOf(newFocusedNode) || selectionStartNode->shadowAncestorNode() == newFocusedNode)
return;
if (Node* mousePressNode = newFocusedFrame->eventHandler()->mousePressNode())
if (mousePressNode->renderer() && !mousePressNode->canStartSelection())
if (Node* root = s->rootEditableElement())
if (Node* shadowAncestorNode = root->shadowAncestorNode())
// Don't do this for textareas and text fields, when they lose focus their selections should be cleared
// and then restored when they regain focus, to match other browsers.
if (!shadowAncestorNode->hasTagName(inputTag) && !shadowAncestorNode->hasTagName(textareaTag))
return;
s->clear();
}
示例2: clearSelectionIfNeeded
static void clearSelectionIfNeeded(Frame* oldFocusedFrame, Frame* newFocusedFrame, Node* newFocusedNode)
{
if (!oldFocusedFrame || !newFocusedFrame)
return;
if (oldFocusedFrame->document() != newFocusedFrame->document())
return;
SelectionController* s = oldFocusedFrame->selection();
if (s->isNone())
return;
bool caretBrowsing = oldFocusedFrame->settings()->caretBrowsingEnabled();
if (caretBrowsing)
return;
Node* selectionStartNode = s->selection().start().deprecatedNode();
if (selectionStartNode == newFocusedNode || selectionStartNode->isDescendantOf(newFocusedNode) || selectionStartNode->shadowAncestorNode() == newFocusedNode)
return;
if (Node* mousePressNode = newFocusedFrame->eventHandler()->mousePressNode()) {
if (mousePressNode->renderer() && !mousePressNode->canStartSelection()) {
// Don't clear the selection for contentEditable elements, but do clear it for input and textarea. See bug 38696.
Node * root = s->rootEditableElement();
if (!root)
return;
if (Node* shadowAncestorNode = root->shadowAncestorNode()) {
if (!shadowAncestorNode->hasTagName(inputTag) && !shadowAncestorNode->hasTagName(textareaTag))
return;
}
}
}
s->clear();
}