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()); }
static FloatPoint convertAbsoluteLocationForLayoutObjectFloat(const LayoutPoint& location, const LayoutObject& layoutObject) { return layoutObject.absoluteToLocal(FloatPoint(location), UseTransforms); }