// TODO(yosin): Maybe baseline would be better? static bool absoluteCaretY(const VisiblePosition& c, int& y) { IntRect rect = absoluteCaretBoundsOf(c); if (rect.isEmpty()) return false; y = rect.y() + rect.height() / 2; return true; }
IntPoint visiblePositionToContentsPoint(const VisiblePosition& pos) { IntPoint result = absoluteCaretBoundsOf(pos).minXMaxYCorner(); // Need to move the point at least by 1 - caret's minXMaxYCorner is not // evaluated to the same line as the text by hit testing. result.move(0, -1); return result; }
// We use the bottom-left corner of the caret rect to represent the // location of a VisiblePosition. This way locations corresponding to // VisiblePositions on the same line will all have the same y coordinate // unless the text is transformed. static IntPoint positionLocation(const VisiblePosition& vp) { return absoluteCaretBoundsOf(vp).minXMaxYCorner(); }