Continue with InlineBox float->LayoutUnit migration.

This is the second patch in the series to migrate
to LayoutUnits in all InlineBox classes.

BUG=321237

Review URL: https://codereview.chromium.org/699683002

git-svn-id: svn://svn.chromium.org/blink/trunk@185320 bbb929c8-8fbe-4397-9dbb-9b2b20218538
parent d7a5c035
......@@ -79,9 +79,9 @@ bool EllipsisBox::nodeAtPoint(const HitTestRequest& request, HitTestResult& resu
}
}
FloatPoint boxOrigin = locationIncludingFlipping();
FloatPointWillBeLayoutPoint boxOrigin = locationIncludingFlipping();
boxOrigin.moveBy(accumulatedOffset);
FloatRect boundsRect(boxOrigin, size());
FloatRectWillBeLayoutRect boundsRect(boxOrigin, size());
if (visibleToHitTestRequest(request) && boundsRect.intersects(HitTestLocation::rectForPoint(locationInContainer.point(), 0, 0, 0, 0))) {
renderer().updateHitTestResult(result, locationInContainer.point() - toLayoutSize(adjustedLocation));
if (!result.addNodeToRectBasedTestResult(renderer().node(), request, locationInContainer, boundsRect))
......
......@@ -20,6 +20,7 @@
#ifndef EllipsisBox_h
#define EllipsisBox_h
#include "core/rendering/FloatToLayoutUnit.h"
#include "core/rendering/InlineBox.h"
namespace blink {
......@@ -31,7 +32,7 @@ class EllipsisBox final : public InlineBox {
public:
EllipsisBox(RenderObject& obj, const AtomicString& ellipsisStr, InlineFlowBox* parent,
int width, int height, int x, int y, bool firstLine, bool isVertical, InlineBox* markupBox)
: InlineBox(obj, FloatPoint(x, y), width, firstLine, true, false, false, isVertical, 0, 0, parent)
: InlineBox(obj, FloatPointWillBeLayoutPoint(x, y), width, firstLine, true, false, false, isVertical, 0, 0, parent)
, m_shouldPaintMarkupBox(markupBox)
, m_height(height)
, m_str(ellipsisStr)
......@@ -45,7 +46,7 @@ public:
void setSelectionState(RenderObject::SelectionState s) { m_selectionState = s; }
IntRect selectionRect();
virtual float virtualLogicalHeight() const override { return m_height; }
virtual FloatWillBeLayoutUnit virtualLogicalHeight() const override { return m_height; }
virtual RenderObject::SelectionState selectionState() const override { return m_selectionState; }
const AtomicString& ellipsisStr() { return m_str; }
InlineBox* markupBox() const;
......
......@@ -5,47 +5,67 @@
#ifndef FloatToLayoutUnit_h
#define FloatToLayoutUnit_h
namespace blink {
#include "platform/LayoutUnit.h"
#if ENABLE(LAYOUT_UNIT_IN_INLINE_BOXES)
namespace blink {
class FloatPoint;
class FloatRect;
class FloatSize;
class LayoutUnit;
class LayoutPoint;
class LayoutRect;
class LayoutSize;
using FloatWillBeLayoutUnit = LayoutUnit;
using FloatPointWillBeLayoutPoint = LayoutPoint;
using FloatRectWillBeLayoutRect = LayoutRect;
using FloatSizeWillBeLayoutSize = LayoutSize;
class FloatLineLayoutUnit {
public:
FloatLineLayoutUnit() : m_value(0) { }
FloatLineLayoutUnit(float f) : m_value(f) { }
#define ZERO_LAYOUT_UNIT LayoutUnit(0)
#define MINUS_ONE_LAYOUT_UNIT LayoutUnit(-1)
float toFloat() const
{
return m_value;
}
#define LAYOUT_UNIT_TO_FLOAT(layoutUnit) (layoutUnit)
#define LAYOUT_UNIT_CEIL(layoutUnit) (layoutUnit.ceil())
#define INT_TO_LAYOUT_UNIT(i) (LayoutUnit(i))
LayoutUnit toLayoutUnit() const
{
return LayoutUnit(m_value);
}
#else // ENABLE(LAYOUT_UNIT_IN_INLINE_BOXES)
public:
float m_value;
};
class FloatPoint;
class FloatRect;
class FloatSize;
class LayoutUnitLineLayoutUnit {
public:
LayoutUnitLineLayoutUnit() { }
LayoutUnitLineLayoutUnit(LayoutUnit f) : m_value(f) { }
using FloatWillBeLayoutUnit = float;
using FloatPointWillBeLayoutPoint = FloatPoint;
using FloatRectWillBeLayoutRect = FloatRect;
using FloatSizeWillBeLayoutSize = FloatSize;
float toFloat() const
{
return m_value.toFloat();
}
#define ZERO_LAYOUT_UNIT 0
#define MINUS_ONE_LAYOUT_UNIT -1
LayoutUnit toLayoutUnit() const
{
return m_value;
}
#define LAYOUT_UNIT_TO_FLOAT(layoutUnit) (layoutUnit.toFloat())
#define LAYOUT_UNIT_CEIL(layoutUnit) (ceilf(layoutUnit))
#define INT_TO_LAYOUT_UNIT(i) (i)
public:
LayoutUnit m_value;
};
#if ENABLE(LAYOUT_UNIT_IN_INLINE_BOXES)
using LineLayoutUnit = LayoutUnitLineLayoutUnit;
#else // ENABLE(LAYOUT_UNIT_IN_INLINE_BOXES)
using LineLayoutUnit = FloatLineLayoutUnit;
#endif // ENABLE(LAYOUT_UNIT_IN_INLINE_BOXES)
using FloatWillBeLayoutUnit = float;
using FloatPointWillBeLayoutPoint = FloatPoint;
using FloatRectWillBeLayoutRect = FloatRect;
using FloatSizeWillBeLayoutSize = FloatSize;
} // namespace blink
#endif // FloatToLayoutUnit_h
......@@ -123,9 +123,9 @@ FloatWillBeLayoutUnit InlineBox::logicalHeight() const
return virtualLogicalHeight();
if (renderer().isText())
return m_bitfields.isText() ? INT_TO_LAYOUT_UNIT(renderer().style(isFirstLineStyle())->fontMetrics().height()) : ZERO_LAYOUT_UNIT;
return m_bitfields.isText() ? renderer().style(isFirstLineStyle())->fontMetrics().height() : 0;
if (renderer().isBox() && parent())
return isHorizontal() ? LAYOUT_UNIT_TO_FLOAT(toRenderBox(renderer()).height()) : LAYOUT_UNIT_TO_FLOAT(toRenderBox(renderer()).width());
return isHorizontal() ? toRenderBox(renderer()).height().toFloat() : toRenderBox(renderer()).width().toFloat();
ASSERT(isInlineFlowBox());
RenderBoxModelObject* flowObject = boxModelObject();
......@@ -296,7 +296,7 @@ FloatWillBeLayoutUnit InlineBox::placeEllipsisBox(bool, FloatWillBeLayoutUnit, F
{
// Use -1 to mean "we didn't set the position."
truncatedWidth += logicalWidth();
return MINUS_ONE_LAYOUT_UNIT;
return -1;
}
void InlineBox::clearKnownToHaveNoOverflow()
......
......@@ -44,7 +44,7 @@ public:
, m_prev(0)
, m_parent(0)
, m_renderer(obj)
, m_logicalWidth(ZERO_LAYOUT_UNIT)
, m_logicalWidth(0)
#if ENABLE(ASSERT)
, m_hasBadParent(false)
#endif
......@@ -131,7 +131,7 @@ public:
virtual FloatWillBeLayoutUnit virtualLogicalHeight() const
{
ASSERT_NOT_REACHED();
return ZERO_LAYOUT_UNIT;
return 0;
}
bool isHorizontal() const { return m_bitfields.isHorizontal(); }
......@@ -219,9 +219,9 @@ public:
setY(left);
}
int pixelSnappedLogicalLeft() const { return logicalLeft(); }
int pixelSnappedLogicalRight() const { return LAYOUT_UNIT_CEIL(logicalRight()); }
int pixelSnappedLogicalRight() const { return ceilf(logicalRight()); }
int pixelSnappedLogicalTop() const { return logicalTop(); }
int pixelSnappedLogicalBottom() const { return LAYOUT_UNIT_CEIL(logicalBottom()); }
int pixelSnappedLogicalBottom() const { return ceilf(logicalBottom()); }
// The logicalTop[ position is the top edge of the line box in a horizontal line and the left edge in a vertical line.
FloatWillBeLayoutUnit logicalTop() const { return isHorizontal() ? m_topLeft.y() : m_topLeft.x(); }
......
......@@ -254,7 +254,7 @@ void InlineFlowBox::attachLineBoxToRenderObject()
rendererLineBoxes()->attachLineBox(this);
}
void InlineFlowBox::adjustPosition(float dx, float dy)
void InlineFlowBox::adjustPosition(FloatWillBeLayoutUnit dx, FloatWillBeLayoutUnit dy)
{
InlineBox::adjustPosition(dx, dy);
for (InlineBox* child = firstChild(); child; child = child->nextOnLine())
......@@ -359,16 +359,16 @@ void InlineFlowBox::determineSpacingForFlowBoxes(bool lastLine, bool isLogically
}
}
float InlineFlowBox::placeBoxesInInlineDirection(float logicalLeft, bool& needsWordSpacing)
FloatWillBeLayoutUnit InlineFlowBox::placeBoxesInInlineDirection(FloatWillBeLayoutUnit logicalLeft, bool& needsWordSpacing)
{
// Set our x position.
beginPlacingBoxRangesInInlineDirection(logicalLeft);
float startLogicalLeft = logicalLeft;
FloatWillBeLayoutUnit startLogicalLeft = logicalLeft;
logicalLeft += borderLogicalLeft() + paddingLogicalLeft();
float minLogicalLeft = startLogicalLeft;
float maxLogicalRight = logicalLeft;
FloatWillBeLayoutUnit minLogicalLeft = startLogicalLeft;
FloatWillBeLayoutUnit maxLogicalRight = logicalLeft;
placeBoxRangeInInlineDirection(firstChild(), 0, logicalLeft, minLogicalLeft, maxLogicalRight, needsWordSpacing);
......@@ -377,14 +377,14 @@ float InlineFlowBox::placeBoxesInInlineDirection(float logicalLeft, bool& needsW
return logicalLeft;
}
float InlineFlowBox::placeBoxRangeInInlineDirection(InlineBox* firstChild, InlineBox* lastChild,
float& logicalLeft, float& minLogicalLeft, float& maxLogicalRight, bool& needsWordSpacing)
FloatWillBeLayoutUnit InlineFlowBox::placeBoxRangeInInlineDirection(InlineBox* firstChild, InlineBox* lastChild,
FloatWillBeLayoutUnit& logicalLeft, FloatWillBeLayoutUnit& minLogicalLeft, FloatWillBeLayoutUnit& maxLogicalRight, bool& needsWordSpacing)
{
for (InlineBox* curr = firstChild; curr && curr != lastChild; curr = curr->nextOnLine()) {
if (curr->renderer().isText()) {
InlineTextBox* text = toInlineTextBox(curr);
RenderText& rt = text->renderer();
float space = 0;
FloatWillBeLayoutUnit space = 0;
if (rt.textLength()) {
if (needsWordSpacing && isSpaceOrNewline(rt.characterAt(text->start())))
space = rt.style(isFirstLineStyle())->font().fontDescription().wordSpacing();
......@@ -743,7 +743,7 @@ void InlineFlowBox::placeBoxesInBlockDirection(LayoutUnit top, LayoutUnit maxHei
}
}
void InlineFlowBox::computeMaxLogicalTop(float& maxLogicalTop) const
void InlineFlowBox::computeMaxLogicalTop(FloatWillBeLayoutUnit& maxLogicalTop) const
{
for (InlineBox* curr = firstChild(); curr; curr = curr->nextOnLine()) {
if (curr->renderer().isOutOfFlowPositioned())
......@@ -752,11 +752,11 @@ void InlineFlowBox::computeMaxLogicalTop(float& maxLogicalTop) const
if (descendantsHaveSameLineHeightAndBaseline())
continue;
maxLogicalTop = std::max<float>(maxLogicalTop, curr->y());
float localMaxLogicalTop = 0;
maxLogicalTop = std::max<FloatWillBeLayoutUnit>(maxLogicalTop, curr->y());
FloatWillBeLayoutUnit localMaxLogicalTop = 0;
if (curr->isInlineFlowBox())
toInlineFlowBox(curr)->computeMaxLogicalTop(localMaxLogicalTop);
maxLogicalTop = std::max<float>(maxLogicalTop, localMaxLogicalTop);
maxLogicalTop = std::max<FloatWillBeLayoutUnit>(maxLogicalTop, localMaxLogicalTop);
}
}
......@@ -1141,9 +1141,9 @@ bool InlineFlowBox::canAccommodateEllipsis(bool ltr, int blockEdge, int ellipsis
return true;
}
float InlineFlowBox::placeEllipsisBox(bool ltr, float blockLeftEdge, float blockRightEdge, float ellipsisWidth, float &truncatedWidth, bool& foundBox)
FloatWillBeLayoutUnit InlineFlowBox::placeEllipsisBox(bool ltr, FloatWillBeLayoutUnit blockLeftEdge, FloatWillBeLayoutUnit blockRightEdge, FloatWillBeLayoutUnit ellipsisWidth, FloatWillBeLayoutUnit &truncatedWidth, bool& foundBox)
{
float result = -1;
FloatWillBeLayoutUnit result = -1;
// We iterate over all children, the foundBox variable tells us when we've found the
// box containing the ellipsis. All boxes after that one in the flow are hidden.
// If our flow is ltr then iterate over the boxes from left to right, otherwise iterate
......
......@@ -21,6 +21,7 @@
#ifndef InlineFlowBox_h
#define InlineFlowBox_h
#include "core/rendering/FloatToLayoutUnit.h"
#include "core/rendering/InlineBox.h"
#include "core/rendering/RenderObjectInlines.h"
#include "core/rendering/RenderOverflow.h"
......@@ -106,7 +107,7 @@ public:
virtual void deleteLine() override final;
virtual void extractLine() override final;
virtual void attachLine() override final;
virtual void adjustPosition(float dx, float dy) override;
virtual void adjustPosition(FloatWillBeLayoutUnit dx, FloatWillBeLayoutUnit dy) override;
virtual void extractLineBoxFromRenderObject();
virtual void attachLineBoxToRenderObject();
......@@ -174,11 +175,11 @@ public:
// Helper functions used during line construction and placement.
void determineSpacingForFlowBoxes(bool lastLine, bool isLogicallyLastRunWrapped, RenderObject* logicallyLastRunRenderer);
LayoutUnit getFlowSpacingLogicalWidth();
float placeBoxesInInlineDirection(float logicalLeft, bool& needsWordSpacing);
float placeBoxRangeInInlineDirection(InlineBox* firstChild, InlineBox* lastChild,
float& logicalLeft, float& minLogicalLeft, float& maxLogicalRight, bool& needsWordSpacing);
void beginPlacingBoxRangesInInlineDirection(float logicalLeft) { setLogicalLeft(logicalLeft); }
void endPlacingBoxRangesInInlineDirection(float logicalLeft, float logicalRight, float minLogicalLeft, float maxLogicalRight)
FloatWillBeLayoutUnit placeBoxesInInlineDirection(FloatWillBeLayoutUnit logicalLeft, bool& needsWordSpacing);
FloatWillBeLayoutUnit placeBoxRangeInInlineDirection(InlineBox* firstChild, InlineBox* lastChild,
FloatWillBeLayoutUnit& logicalLeft, FloatWillBeLayoutUnit& minLogicalLeft, FloatWillBeLayoutUnit& maxLogicalRight, bool& needsWordSpacing);
void beginPlacingBoxRangesInInlineDirection(FloatWillBeLayoutUnit logicalLeft) { setLogicalLeft(logicalLeft); }
void endPlacingBoxRangesInInlineDirection(FloatWillBeLayoutUnit logicalLeft, FloatWillBeLayoutUnit logicalRight, FloatWillBeLayoutUnit minLogicalLeft, FloatWillBeLayoutUnit maxLogicalRight)
{
setLogicalWidth(logicalRight - logicalLeft);
if (knownToHaveNoOverflow() && (minLogicalLeft < logicalLeft || maxLogicalRight > logicalRight))
......@@ -205,7 +206,7 @@ public:
virtual RenderObject::SelectionState selectionState() const override;
virtual bool canAccommodateEllipsis(bool ltr, int blockEdge, int ellipsisWidth) const override final;
virtual float placeEllipsisBox(bool ltr, float blockLeftEdge, float blockRightEdge, float ellipsisWidth, float &truncatedWidth, bool&) override;
virtual FloatWillBeLayoutUnit placeEllipsisBox(bool ltr, FloatWillBeLayoutUnit blockLeftEdge, FloatWillBeLayoutUnit blockRightEdge, FloatWillBeLayoutUnit ellipsisWidth, FloatWillBeLayoutUnit &truncatedWidth, bool&) override;
bool hasTextChildren() const { return m_hasTextChildren; }
bool hasTextDescendants() const { return m_hasTextDescendants; }
......@@ -269,16 +270,16 @@ public:
void setOverflowFromLogicalRects(const LayoutRect& logicalLayoutOverflow, const LayoutRect& logicalVisualOverflow, LayoutUnit lineTop, LayoutUnit lineBottom);
FloatRect frameRectIncludingLineHeight(LayoutUnit lineTop, LayoutUnit lineBottom) const
FloatRectWillBeLayoutRect frameRectIncludingLineHeight(LayoutUnit lineTop, LayoutUnit lineBottom) const
{
if (isHorizontal())
return FloatRect(m_topLeft.x(), lineTop.toFloat(), width(), (lineBottom - lineTop).toFloat());
return FloatRect(lineTop.toFloat(), m_topLeft.y(), (lineBottom - lineTop).toFloat(), height());
return FloatRectWillBeLayoutRect(m_topLeft.x(), lineTop.toFloat(), width(), (lineBottom - lineTop).toFloat());
return FloatRectWillBeLayoutRect(lineTop.toFloat(), m_topLeft.y(), (lineBottom - lineTop).toFloat(), height());
}
FloatRect logicalFrameRectIncludingLineHeight(LayoutUnit lineTop, LayoutUnit lineBottom) const
FloatRectWillBeLayoutRect logicalFrameRectIncludingLineHeight(LayoutUnit lineTop, LayoutUnit lineBottom) const
{
return FloatRect(logicalLeft(), lineTop.toFloat(), logicalWidth(), (lineBottom - lineTop).toFloat());
return FloatRectWillBeLayoutRect(logicalLeft(), lineTop.toFloat(), logicalWidth(), (lineBottom - lineTop).toFloat());
}
bool descendantsHaveSameLineHeightAndBaseline() const { return m_descendantsHaveSameLineHeightAndBaseline; }
......@@ -315,7 +316,7 @@ protected:
// Maximum logicalTop among all children of an InlineFlowBox. Used to
// calculate the offset for TextUnderlinePositionUnder.
void computeMaxLogicalTop(float& maxLogicalTop) const;
void computeMaxLogicalTop(FloatWillBeLayoutUnit& maxLogicalTop) const;
private:
unsigned m_includeLogicalLeftEdge : 1;
......
......@@ -206,12 +206,12 @@ LayoutRect InlineTextBox::localSelectionRect(int startPos, int endPos)
bool respectHyphen = ePos == m_len && hasHyphen();
TextRun textRun = constructTextRun(styleToUse, font, respectHyphen ? &charactersWithHyphen : 0);
FloatPoint startingPoint = FloatPoint(logicalLeft(), selTop.toFloat());
FloatPointWillBeLayoutPoint startingPoint = FloatPointWillBeLayoutPoint(logicalLeft(), selTop.toFloat());
LayoutRect r;
if (sPos || ePos != static_cast<int>(m_len))
r = enclosingIntRect(font.selectionRectForText(textRun, startingPoint, selHeight, sPos, ePos));
else // Avoid computing the font width when the entire line box is selected as an optimization.
r = enclosingIntRect(FloatRect(startingPoint, FloatSize(m_logicalWidth, selHeight.toFloat())));
r = enclosingIntRect(FloatRectWillBeLayoutRect(startingPoint, FloatSizeWillBeLayoutSize(m_logicalWidth, selHeight.toFloat())));
LayoutUnit logicalWidth = r.width();
if (r.x() > logicalRight())
......@@ -248,7 +248,7 @@ void InlineTextBox::attachLine()
renderer().attachTextBox(this);
}
float InlineTextBox::placeEllipsisBox(bool flowIsLTR, float visibleLeftEdge, float visibleRightEdge, float ellipsisWidth, float &truncatedWidth, bool& foundBox)
FloatWillBeLayoutUnit InlineTextBox::placeEllipsisBox(bool flowIsLTR, FloatWillBeLayoutUnit visibleLeftEdge, FloatWillBeLayoutUnit visibleRightEdge, FloatWillBeLayoutUnit ellipsisWidth, FloatWillBeLayoutUnit &truncatedWidth, bool& foundBox)
{
if (foundBox) {
m_truncation = cFullTruncation;
......@@ -256,7 +256,7 @@ float InlineTextBox::placeEllipsisBox(bool flowIsLTR, float visibleLeftEdge, flo
}
// For LTR this is the left edge of the box, for RTL, the right edge in parent coordinates.
float ellipsisX = flowIsLTR ? visibleRightEdge - ellipsisWidth : visibleLeftEdge + ellipsisWidth;
FloatWillBeLayoutUnit ellipsisX = flowIsLTR ? visibleRightEdge - ellipsisWidth : visibleLeftEdge + ellipsisWidth;
// Criteria for full truncation:
// LTR: the left edge of the ellipsis is to the left of our text run.
......@@ -299,7 +299,7 @@ float InlineTextBox::placeEllipsisBox(bool flowIsLTR, float visibleLeftEdge, flo
// If we got here that means that we were only partially truncated and we need to return the pixel offset at which
// to place the ellipsis.
float widthOfVisibleText = renderer().width(m_start, offset, textPos(), flowIsLTR ? LTR : RTL, isFirstLineStyle());
FloatWillBeLayoutUnit widthOfVisibleText = renderer().width(m_start, offset, textPos(), flowIsLTR ? LTR : RTL, isFirstLineStyle());
// The ellipsis needs to be placed just after the last visible character.
// Where "after" is defined by the flow directionality, not the inline
......@@ -326,9 +326,9 @@ bool InlineTextBox::nodeAtPoint(const HitTestRequest& request, HitTestResult& re
if (isLineBreak())
return false;
FloatPoint boxOrigin = locationIncludingFlipping();
FloatPointWillBeLayoutPoint boxOrigin = locationIncludingFlipping();
boxOrigin.moveBy(accumulatedOffset);
FloatRect rect(boxOrigin, size());
FloatRectWillBeLayoutRect rect(boxOrigin, size());
if (m_truncation != cFullTruncation && visibleToHitTestRequest(request) && locationInContainer.intersects(rect)) {
renderer().updateHitTestResult(result, flipForWritingMode(locationInContainer.point() - toLayoutSize(accumulatedOffset)));
if (!result.addNodeToRectBasedTestResult(renderer().node(), request, locationInContainer, rect))
......@@ -383,12 +383,12 @@ void InlineTextBox::selectionStartEnd(int& sPos, int& ePos) const
ePos = std::min(endPos - m_start, (int)m_len);
}
void InlineTextBox::paintDocumentMarker(GraphicsContext* pt, const FloatPoint& boxOrigin, DocumentMarker* marker, RenderStyle* style, const Font& font, bool grammar)
void InlineTextBox::paintDocumentMarker(GraphicsContext* pt, const FloatPointWillBeLayoutPoint& boxOrigin, DocumentMarker* marker, RenderStyle* style, const Font& font, bool grammar)
{
InlineTextBoxPainter(*this).paintDocumentMarker(pt, boxOrigin, marker, style, font, grammar);
}
void InlineTextBox::paintTextMatchMarker(GraphicsContext* pt, const FloatPoint& boxOrigin, DocumentMarker* marker, RenderStyle* style, const Font& font)
void InlineTextBox::paintTextMatchMarker(GraphicsContext* pt, const FloatPointWillBeLayoutPoint& boxOrigin, DocumentMarker* marker, RenderStyle* style, const Font& font)
{
InlineTextBoxPainter(*this).paintTextMatchMarker(pt, boxOrigin, marker, style, font);
}
......@@ -403,7 +403,7 @@ int InlineTextBox::caretMaxOffset() const
return m_start + m_len;
}
float InlineTextBox::textPos() const
FloatWillBeLayoutUnit InlineTextBox::textPos() const
{
// When computing the width of a text run, RenderBlock::computeInlineDirectionPositionsForLine() doesn't include the actual offset
// from the containing block edge in its measurement. textPos() should be consistent so the text are rendered in the same width.
......@@ -412,7 +412,7 @@ float InlineTextBox::textPos() const
return logicalLeft() - root().logicalLeft();
}
int InlineTextBox::offsetForPosition(float lineOffset, bool includePartialGlyphs) const
int InlineTextBox::offsetForPosition(FloatWillBeLayoutUnit lineOffset, bool includePartialGlyphs) const
{
if (isLineBreak())
return 0;
......@@ -430,7 +430,7 @@ int InlineTextBox::offsetForPosition(float lineOffset, bool includePartialGlyphs
return font.offsetForPosition(constructTextRun(style, font), lineOffset - logicalLeft(), includePartialGlyphs);
}
float InlineTextBox::positionForOffset(int offset) const
FloatWillBeLayoutUnit InlineTextBox::positionForOffset(int offset) const
{
ASSERT(offset >= m_start);
ASSERT(offset <= m_start + m_len);
......@@ -474,7 +474,7 @@ bool InlineTextBox::containsCaretOffset(int offset) const
return true;
}
void InlineTextBox::characterWidths(Vector<float>& widths) const
void InlineTextBox::characterWidths(Vector<FloatWillBeLayoutUnit>& widths) const
{
FontCachePurgePreventer fontCachePurgePreventer;
......@@ -484,7 +484,7 @@ void InlineTextBox::characterWidths(Vector<float>& widths) const
TextRun textRun = constructTextRun(styleToUse, font);
SimpleShaper shaper(&font, textRun);
float lastWidth = 0;
FloatWillBeLayoutUnit lastWidth = 0;
widths.resize(m_len);
for (unsigned i = 0; i < m_len; i++) {
shaper.advance(i + 1);
......
......@@ -23,6 +23,7 @@
#ifndef InlineTextBox_h
#define InlineTextBox_h
#include "core/rendering/FloatToLayoutUnit.h"
#include "core/rendering/InlineBox.h"
#include "core/rendering/RenderText.h" // so textRenderer() can be inline
#include "platform/fonts/TextBlob.h"
......@@ -97,19 +98,19 @@ public:
#endif
enum RotationDirection { Counterclockwise, Clockwise };
static AffineTransform rotation(const FloatRect& boxRect, RotationDirection);
static AffineTransform rotation(const FloatRectWillBeLayoutRect& boxRect, RotationDirection);
public:
TextRun constructTextRunForInspector(RenderStyle*, const Font&) const;
virtual FloatRect calculateBoundaries() const override { return FloatRect(x(), y(), width(), height()); }
virtual FloatRectWillBeLayoutRect calculateBoundaries() const override { return FloatRectWillBeLayoutRect(x(), y(), width(), height()); }
virtual LayoutRect localSelectionRect(int startPos, int endPos);
bool isSelected(int startPos, int endPos) const;
void selectionStartEnd(int& sPos, int& ePos) const;
// These functions both paint markers and update the DocumentMarker's renderedRect.
virtual void paintDocumentMarker(GraphicsContext*, const FloatPoint& boxOrigin, DocumentMarker*, RenderStyle*, const Font&, bool grammar);
virtual void paintTextMatchMarker(GraphicsContext*, const FloatPoint& boxOrigin, DocumentMarker*, RenderStyle*, const Font&);
virtual void paintDocumentMarker(GraphicsContext*, const FloatPointWillBeLayoutPoint& boxOrigin, DocumentMarker*, RenderStyle*, const Font&, bool grammar);
virtual void paintTextMatchMarker(GraphicsContext*, const FloatPointWillBeLayoutPoint& boxOrigin, DocumentMarker*, RenderStyle*, const Font&);
protected:
virtual void paint(PaintInfo&, const LayoutPoint&, LayoutUnit lineTop, LayoutUnit lineBottom) override;
......@@ -125,7 +126,7 @@ public:
private:
virtual void clearTruncation() override final { m_truncation = cNoTruncation; }
virtual float placeEllipsisBox(bool flowIsLTR, float visibleLeftEdge, float visibleRightEdge, float ellipsisWidth, float &truncatedWidth, bool& foundBox) override final;
virtual FloatWillBeLayoutUnit placeEllipsisBox(bool flowIsLTR, FloatWillBeLayoutUnit visibleLeftEdge, FloatWillBeLayoutUnit visibleRightEdge, FloatWillBeLayoutUnit ellipsisWidth, FloatWillBeLayoutUnit &truncatedWidth, bool& foundBox) override final;
public:
virtual bool isLineBreak() const override final;
......@@ -144,16 +145,16 @@ public:
virtual int caretMinOffset() const override final;
virtual int caretMaxOffset() const override final;
float textPos() const; // returns the x position relative to the left start of the text line.
FloatWillBeLayoutUnit textPos() const; // returns the x position relative to the left start of the text line.
public:
virtual int offsetForPosition(float x, bool includePartialGlyphs = true) const;
virtual float positionForOffset(int offset) const;
virtual int offsetForPosition(FloatWillBeLayoutUnit x, bool includePartialGlyphs = true) const;
virtual FloatWillBeLayoutUnit positionForOffset(int offset) const;
bool containsCaretOffset(int offset) const; // false for offset after line break
// Fills a vector with the pixel width of each character.
void characterWidths(Vector<float>&) const;
void characterWidths(Vector<FloatWillBeLayoutUnit>&) const;
private:
InlineTextBox* m_prevTextBox; // The previous box that also uses our RenderObject
......@@ -175,9 +176,9 @@ private:
DEFINE_INLINE_BOX_TYPE_CASTS(InlineTextBox);
void alignSelectionRectToDevicePixels(FloatRect&);
void alignSelectionRectToDevicePixels(FloatRectWillBeLayoutRect&);
inline AffineTransform InlineTextBox::rotation(const FloatRect& boxRect, RotationDirection rotationDirection)
inline AffineTransform InlineTextBox::rotation(const FloatRectWillBeLayoutRect& boxRect, RotationDirection rotationDirection)
{
return rotationDirection == Clockwise ? AffineTransform(0, 1, -1, 0, boxRect.x() + boxRect.maxY(), boxRect.maxY() - boxRect.x())
: AffineTransform(0, -1, 1, 0, boxRect.x() - boxRect.maxY(), boxRect.x() + boxRect.maxY());
......
......@@ -114,7 +114,7 @@ bool RootInlineBox::lineCanAccommodateEllipsis(bool ltr, int blockEdge, int line
return InlineFlowBox::canAccommodateEllipsis(ltr, blockEdge, ellipsisWidth);
}
float RootInlineBox::placeEllipsis(const AtomicString& ellipsisStr, bool ltr, float blockLeftEdge, float blockRightEdge, float ellipsisWidth,
FloatWillBeLayoutUnit RootInlineBox::placeEllipsis(const AtomicString& ellipsisStr, bool ltr, FloatWillBeLayoutUnit blockLeftEdge, FloatWillBeLayoutUnit blockRightEdge, FloatWillBeLayoutUnit ellipsisWidth,
InlineBox* markupBox)
{
// Create an ellipsis box.
......@@ -137,15 +137,15 @@ float RootInlineBox::placeEllipsis(const AtomicString& ellipsisStr, bool ltr, f
// of that glyph. Mark all of the objects that intersect the ellipsis box as not painting (as being
// truncated).
bool foundBox = false;
float truncatedWidth = 0;
float position = placeEllipsisBox(ltr, blockLeftEdge, blockRightEdge, ellipsisWidth, truncatedWidth, foundBox);
FloatWillBeLayoutUnit truncatedWidth = 0;
FloatWillBeLayoutUnit position = placeEllipsisBox(ltr, blockLeftEdge, blockRightEdge, ellipsisWidth, truncatedWidth, foundBox);
ellipsisBox->setLogicalLeft(position);
return truncatedWidth;
}
float RootInlineBox::placeEllipsisBox(bool ltr, float blockLeftEdge, float blockRightEdge, float ellipsisWidth, float &truncatedWidth, bool& foundBox)
FloatWillBeLayoutUnit RootInlineBox::placeEllipsisBox(bool ltr, FloatWillBeLayoutUnit blockLeftEdge, FloatWillBeLayoutUnit blockRightEdge, FloatWillBeLayoutUnit ellipsisWidth, FloatWillBeLayoutUnit &truncatedWidth, bool& foundBox)
{
float result = InlineFlowBox::placeEllipsisBox(ltr, blockLeftEdge, blockRightEdge, ellipsisWidth, truncatedWidth, foundBox);
FloatWillBeLayoutUnit result = InlineFlowBox::placeEllipsisBox(ltr, blockLeftEdge, blockRightEdge, ellipsisWidth, truncatedWidth, foundBox);
if (result == -1) {
result = ltr ? blockRightEdge - ellipsisWidth : blockLeftEdge;
truncatedWidth = blockRightEdge - blockLeftEdge;
......@@ -169,7 +169,7 @@ bool RootInlineBox::nodeAtPoint(const HitTestRequest& request, HitTestResult& re
return InlineFlowBox::nodeAtPoint(request, result, locationInContainer, accumulatedOffset, lineTop, lineBottom);
}
void RootInlineBox::adjustPosition(float dx, float dy)
void RootInlineBox::adjustPosition(FloatWillBeLayoutUnit dx, FloatWillBeLayoutUnit dy)
{
InlineFlowBox::adjustPosition(dx, dy);
LayoutUnit blockDirectionDelta = isHorizontal() ? dy : dx; // The block direction delta is a LayoutUnit.
......@@ -246,9 +246,9 @@ LayoutUnit RootInlineBox::alignBoxesInBlockDirection(LayoutUnit heightOfBlock, G
return heightOfBlock + maxHeight;
}
float RootInlineBox::maxLogicalTop() const
FloatWillBeLayoutUnit RootInlineBox::maxLogicalTop() const
{
float maxLogicalTop = 0;
FloatWillBeLayoutUnit maxLogicalTop = 0;
computeMaxLogicalTop(maxLogicalTop);
return maxLogicalTop;
}
......
......@@ -21,6 +21,7 @@
#ifndef RootInlineBox_h
#define RootInlineBox_h
#include "core/rendering/FloatToLayoutUnit.h"
#include "core/rendering/InlineFlowBox.h"
#include "platform/text/BidiContext.h"
......@@ -46,7 +47,7 @@ public:
RootInlineBox* nextRootBox() const { return static_cast<RootInlineBox*>(m_nextLineBox); }
RootInlineBox* prevRootBox() const { return static_cast<RootInlineBox*>(m_prevLineBox); }
virtual void adjustPosition(float dx, float dy) override final;
virtual void adjustPosition(FloatWillBeLayoutUnit dx, FloatWillBeLayoutUnit dy) override final;
LayoutUnit lineTop() const { return m_lineTop; }
LayoutUnit lineBottom() const { return m_lineBottom; }
......@@ -92,9 +93,9 @@ public:
bool lineCanAccommodateEllipsis(bool ltr, int blockEdge, int lineBoxEdge, int ellipsisWidth);
// Return the truncatedWidth, the width of the truncated text + ellipsis.
float placeEllipsis(const AtomicString& ellipsisStr, bool ltr, float blockLeftEdge, float blockRightEdge, float ellipsisWidth, InlineBox* markupBox = 0);
FloatWillBeLayoutUnit placeEllipsis(const AtomicString& ellipsisStr, bool ltr, FloatWillBeLayoutUnit blockLeftEdge, FloatWillBeLayoutUnit blockRightEdge, FloatWillBeLayoutUnit ellipsisWidth, InlineBox* markupBox = 0);
// Return the position of the EllipsisBox or -1.
virtual float placeEllipsisBox(bool ltr, float blockLeftEdge, float blockRightEdge, float ellipsisWidth, float &truncatedWidth, bool& foundBox) override final;
virtual FloatWillBeLayoutUnit placeEllipsisBox(bool ltr, FloatWillBeLayoutUnit blockLeftEdge, FloatWillBeLayoutUnit blockRightEdge, FloatWillBeLayoutUnit ellipsisWidth, FloatWillBeLayoutUnit &truncatedWidth, bool& foundBox) override final;
using InlineBox::hasEllipsisBox;
EllipsisBox* ellipsisBox() const;
......@@ -170,7 +171,7 @@ public:
}
// Used to calculate the underline offset for TextUnderlinePositionUnder.
float maxLogicalTop() const;
FloatWillBeLayoutUnit maxLogicalTop() const;
Node* getLogicalStartBoxWithNode(InlineBox*&) const;
Node* getLogicalEndBoxWithNode(InlineBox*&) const;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment