本文整理汇总了C++中LayoutBlock::node方法的典型用法代码示例。如果您正苦于以下问题:C++ LayoutBlock::node方法的具体用法?C++ LayoutBlock::node怎么用?C++ LayoutBlock::node使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类LayoutBlock
的用法示例。
在下文中一共展示了LayoutBlock::node方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: findGoodTouchTargets
void findGoodTouchTargets(const IntRect& touchBoxInRootFrame, LocalFrame* mainFrame, Vector<IntRect>& goodTargets, WillBeHeapVector<RawPtrWillBeMember<Node>>& highlightNodes)
{
goodTargets.clear();
int touchPointPadding = ceil(std::max(touchBoxInRootFrame.width(), touchBoxInRootFrame.height()) * 0.5);
IntPoint touchPoint = touchBoxInRootFrame.center();
IntPoint contentsPoint = mainFrame->view()->rootFrameToContents(touchPoint);
HitTestResult result = mainFrame->eventHandler().hitTestResultAtPoint(contentsPoint, HitTestRequest::ReadOnly | HitTestRequest::Active | HitTestRequest::ListBased, LayoutSize(touchPointPadding, touchPointPadding));
const WillBeHeapListHashSet<RefPtrWillBeMember<Node>>& hitResults = result.listBasedTestResult();
// Blacklist nodes that are container of disambiguated nodes.
// It is not uncommon to have a clickable <div> that contains other clickable objects.
// This heuristic avoids excessive disambiguation in that case.
WillBeHeapHashSet<RawPtrWillBeMember<Node>> blackList;
for (const auto& hitResult : hitResults) {
// Ignore any Nodes that can't be clicked on.
LayoutObject* layoutObject = hitResult.get()->layoutObject();
if (!layoutObject || !hitResult.get()->willRespondToMouseClickEvents())
continue;
// Blacklist all of the Node's containers.
for (LayoutBlock* container = layoutObject->containingBlock(); container; container = container->containingBlock()) {
Node* containerNode = container->node();
if (!containerNode)
continue;
if (!blackList.add(containerNode).isNewEntry)
break;
}
}
WillBeHeapHashMap<RawPtrWillBeMember<Node>, TouchTargetData> touchTargets;
float bestScore = 0;
for (const auto& hitResult : hitResults) {
for (Node* node = hitResult.get(); node; node = node->parentNode()) {
if (blackList.contains(node))
continue;
if (node->isDocumentNode() || isHTMLHtmlElement(*node) || isHTMLBodyElement(*node))
break;
if (node->willRespondToMouseClickEvents()) {
TouchTargetData& targetData = touchTargets.add(node, TouchTargetData()).storedValue->value;
targetData.windowBoundingBox = boundingBoxForEventNodes(node);
targetData.score = scoreTouchTarget(touchPoint, touchPointPadding, targetData.windowBoundingBox);
bestScore = std::max(bestScore, targetData.score);
break;
}
}
}
for (const auto& touchTarget : touchTargets) {
// Currently the scoring function uses the overlap area with the fat point as the score.
// We ignore the candidates that has less than 1/2 overlap (we consider not really ambiguous enough) than the best candidate to avoid excessive popups.
if (touchTarget.value.score < bestScore * 0.5)
continue;
goodTargets.append(touchTarget.value.windowBoundingBox);
highlightNodes.append(touchTarget.key);
}
}