Switch whitespace mode back to pre-wrap

When we removed position: sticky, we introduced a subtle line breaking
bug to pre-wrap that would cause whitespace to accumulate at the
beginning of lines that follow unclean breaks. This patch adds back the
deleted code (cleansed of the position sticky bits).
This commit is contained in:
Adam Barth 2016-01-25 00:03:08 -08:00
parent 229bda2ff4
commit f7731bbdd2
2 changed files with 16 additions and 1 deletions

View File

@ -99,6 +99,8 @@ public:
}
private:
void skipTrailingWhitespace(InlineIterator&, const LineInfo&);
InlineBidiResolver& m_resolver;
InlineIterator m_current;
@ -183,6 +185,18 @@ inline bool requiresLineBox(const InlineIterator& it, const LineInfo& lineInfo =
return notJustWhitespace || isEmptyInline(it.object());
}
// FIXME: The entire concept of the skipTrailingWhitespace function is flawed, since we really need to be building
// line boxes even for containers that may ultimately collapse away. Otherwise we'll never get positioned
// elements quite right. In other words, we need to build this function's work into the normal line
// object iteration process.
// NB. this function will insert any floating elements that would otherwise
// be skipped but it will not position them.
inline void BreakingContext::skipTrailingWhitespace(InlineIterator& iterator, const LineInfo& lineInfo)
{
while (!iterator.atEnd() && !requiresLineBox(iterator, lineInfo, TrailingWhitespace))
iterator.increment();
}
inline void BreakingContext::initializeForCurrentObject()
{
m_currentStyle = m_current.object()->style();
@ -551,6 +565,7 @@ inline bool BreakingContext::handleText(WordMeasurements& wordMeasurements, bool
if (!m_width.fitsOnLine(charWidth)) {
lineWasTooWide = true;
m_lineBreak.moveTo(m_current.object(), m_current.offset(), m_current.nextBreakablePosition());
skipTrailingWhitespace(m_lineBreak, m_lineInfo);
}
}
if (lineWasTooWide || !m_width.fitsOnLine()) {

View File

@ -966,7 +966,7 @@ public:
static EPosition initialPosition() { return StaticPosition; }
static EUnicodeBidi initialUnicodeBidi() { return UBNormal; }
static EVisibility initialVisibility() { return VISIBLE; }
static EWhiteSpace initialWhiteSpace() { return PRE_LINE; }
static EWhiteSpace initialWhiteSpace() { return PRE_WRAP; }
static short initialHorizontalBorderSpacing() { return 0; }
static short initialVerticalBorderSpacing() { return 0; }
static Color initialColor() { return Color::white; }