本文整理汇总了C++中PaintLayer::location方法的典型用法代码示例。如果您正苦于以下问题:C++ PaintLayer::location方法的具体用法?C++ PaintLayer::location怎么用?C++ PaintLayer::location使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PaintLayer
的用法示例。
在下文中一共展示了PaintLayer::location方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: computeRelativePosition
void MouseRelatedEvent::computeRelativePosition()
{
Node* targetNode = target() ? target()->toNode() : nullptr;
if (!targetNode)
return;
// Compute coordinates that are based on the target.
m_layerLocation = m_pageLocation;
m_offsetLocation = m_pageLocation;
// Must have an updated layout tree for this math to work correctly.
targetNode->document().updateLayoutIgnorePendingStylesheets();
// Adjust offsetLocation to be relative to the target's padding box.
if (LayoutObject* r = targetNode->layoutObject()) {
FloatPoint localPos = r->absoluteToLocal(FloatPoint(absoluteLocation()), UseTransforms);
// Adding this here to address crbug.com/570666. Basically we'd like to
// find the local coordinates relative to the padding box not the border box.
if (r->isBoxModelObject()) {
LayoutBoxModelObject* layoutBox = toLayoutBoxModelObject(r);
localPos.move(-layoutBox->borderLeft(), -layoutBox->borderTop());
}
m_offsetLocation = roundedLayoutPoint(localPos);
float scaleFactor = 1 / pageZoomFactor(this);
if (scaleFactor != 1.0f)
m_offsetLocation.scale(scaleFactor, scaleFactor);
}
// Adjust layerLocation to be relative to the layer.
// FIXME: event.layerX and event.layerY are poorly defined,
// and probably don't always correspond to PaintLayer offsets.
// https://bugs.webkit.org/show_bug.cgi?id=21868
Node* n = targetNode;
while (n && !n->layoutObject())
n = n->parentNode();
if (n) {
// FIXME: This logic is a wrong implementation of convertToLayerCoords.
for (PaintLayer* layer = n->layoutObject()->enclosingLayer(); layer; layer = layer->parent())
m_layerLocation -= toLayoutSize(layer->location());
}
m_hasCachedRelativePosition = true;
}