本文整理汇总了C++中LayoutObject::absoluteToLocal方法的典型用法代码示例。如果您正苦于以下问题:C++ LayoutObject::absoluteToLocal方法的具体用法?C++ LayoutObject::absoluteToLocal怎么用?C++ LayoutObject::absoluteToLocal使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类LayoutObject
的用法示例。
在下文中一共展示了LayoutObject::absoluteToLocal方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: appendServerMapMousePosition
static void appendServerMapMousePosition(StringBuilder& url, Event* event)
{
if (!event->isMouseEvent())
return;
ASSERT(event->target());
Node* target = event->target()->toNode();
ASSERT(target);
if (!isHTMLImageElement(*target))
return;
HTMLImageElement& imageElement = toHTMLImageElement(*target);
if (!imageElement.isServerMap())
return;
LayoutObject* layoutObject = imageElement.layoutObject();
if (!layoutObject || !layoutObject->isBox())
return;
// The coordinates sent in the query string are relative to the height and
// width of the image element, ignoring CSS transform/zoom.
LayoutPoint mapPoint(layoutObject->absoluteToLocal(FloatPoint(toMouseEvent(event)->absoluteLocation()), UseTransforms));
// The origin (0,0) is at the upper left of the content area, inside the
// padding and border.
mapPoint -= toLayoutBox(layoutObject)->contentBoxOffset();
// CSS zoom is not reflected in the map coordinates.
float scaleFactor = 1 / layoutObject->style()->effectiveZoom();
mapPoint.scale(scaleFactor, scaleFactor);
// Negative coordinates are clamped to 0 such that clicks in the left and
// top padding/border areas receive an X or Y coordinate of 0.
IntPoint clampedPoint(roundedIntPoint(mapPoint));
clampedPoint.clampNegativeToZero();
url.append('?');
url.appendNumber(clampedPoint.x());
url.append(',');
url.appendNumber(clampedPoint.y());
}
示例2: convertAbsoluteLocationForLayoutObjectFloat
static FloatPoint convertAbsoluteLocationForLayoutObjectFloat(const LayoutPoint& location, const LayoutObject& layoutObject)
{
return layoutObject.absoluteToLocal(FloatPoint(location), UseTransforms);
}