Skip to content
Permalink
Browse files
BreakingContext::handleReplaced() should use replacedBox instead of m…
…_current.renderer().

https://bugs.webkit.org/show_bug.cgi?id=174011

Reviewed by Simon Fraser.

No change in functionality.

* rendering/line/BreakingContext.h:
(WebCore::BreakingContext::handleReplaced):
* rendering/line/LineWidth.cpp:
(WebCore::LineWidth::applyOverhang):
* rendering/line/LineWidth.h:


Canonical link: https://commits.webkit.org/190844@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@218989 268f45cc-cd09-0410-ab3c-d52691b4dbfc
  • Loading branch information
alanbaradlay committed Jun 30, 2017
1 parent 65f910d commit 682e9cb591dc3b633cc9ff3b08b0b7a4ac289618
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 13 deletions.
@@ -1,3 +1,18 @@
2017-06-29 Zalan Bujtas <zalan@apple.com>

BreakingContext::handleReplaced() should use replacedBox instead of m_current.renderer().
https://bugs.webkit.org/show_bug.cgi?id=174011

Reviewed by Simon Fraser.

No change in functionality.

* rendering/line/BreakingContext.h:
(WebCore::BreakingContext::handleReplaced):
* rendering/line/LineWidth.cpp:
(WebCore::LineWidth::applyOverhang):
* rendering/line/LineWidth.h:

2017-06-29 Wenson Hsieh <wenson_hsieh@apple.com>

[iOS DnD] Web content process crashes when the selection is moved far offscreen in dragstart
@@ -542,8 +542,8 @@ inline void BreakingContext::handleReplaced()
m_width.updateAvailableWidth(replacedBox.logicalHeight());

// Break on replaced elements if either has normal white-space.
if (((m_autoWrap || RenderStyle::autoWrap(m_lastWS)) && (!m_current.renderer()->isImage() || m_allowImagesToBreak)
&& (!m_current.renderer()->isRubyRun() || downcast<RenderRubyRun>(m_current.renderer())->canBreakBefore(m_renderTextInfo.lineBreakIterator))) || replacedBox.isAnonymousInlineBlock()) {
if (((m_autoWrap || RenderStyle::autoWrap(m_lastWS)) && (!replacedBox.isImage() || m_allowImagesToBreak)
&& (!is<RenderRubyRun>(replacedBox) || downcast<RenderRubyRun>(replacedBox).canBreakBefore(m_renderTextInfo.lineBreakIterator))) || replacedBox.isAnonymousInlineBlock()) {
if (auto* renderer = m_current.renderer())
commitLineBreakAtCurrentWidth(*renderer);
else
@@ -562,7 +562,7 @@ inline void BreakingContext::handleReplaced()
m_lineLayoutState.prevFloatBottomFromAnonymousInlineBlock(), m_lineLayoutState.maxFloatBottomFromAnonymousInlineBlock());

if (m_ignoringSpaces)
m_lineWhitespaceCollapsingState.stopIgnoringSpaces(InlineIterator(0, m_current.renderer(), 0));
m_lineWhitespaceCollapsingState.stopIgnoringSpaces(InlineIterator(0, &replacedBox, 0));

m_lineInfo.setEmpty(false, &m_block, &m_width);
m_ignoringSpaces = false;
@@ -572,22 +572,22 @@ inline void BreakingContext::handleReplaced()

// Optimize for a common case. If we can't find whitespace after the list
// item, then this is all moot.
LayoutUnit replacedLogicalWidth = m_block.logicalWidthForChild(replacedBox) + m_block.marginStartForChild(replacedBox) + m_block.marginEndForChild(replacedBox) + inlineLogicalWidth(m_current.renderer());
if (is<RenderListMarker>(*m_current.renderer())) {
if (m_blockStyle.collapseWhiteSpace() && shouldSkipWhitespaceAfterStartObject(m_block, m_current.renderer(), m_lineWhitespaceCollapsingState)) {
LayoutUnit replacedLogicalWidth = m_block.logicalWidthForChild(replacedBox) + m_block.marginStartForChild(replacedBox) + m_block.marginEndForChild(replacedBox) + inlineLogicalWidth(&replacedBox);
if (is<RenderListMarker>(replacedBox)) {
if (m_blockStyle.collapseWhiteSpace() && shouldSkipWhitespaceAfterStartObject(m_block, &replacedBox, m_lineWhitespaceCollapsingState)) {
// Like with inline flows, we start ignoring spaces to make sure that any
// additional spaces we see will be discarded.
m_currentCharacterIsSpace = true;
m_currentCharacterIsWS = false;
m_ignoringSpaces = true;
}
if (downcast<RenderListMarker>(*m_current.renderer()).isInside())
if (downcast<RenderListMarker>(replacedBox).isInside())
m_width.addUncommittedReplacedWidth(replacedLogicalWidth);
} else
m_width.addUncommittedReplacedWidth(replacedLogicalWidth);
if (is<RenderRubyRun>(*m_current.renderer())) {
m_width.applyOverhang(downcast<RenderRubyRun>(m_current.renderer()), m_lastObject, m_nextObject);
downcast<RenderRubyRun>(m_current.renderer())->updatePriorContextFromCachedBreakIterator(m_renderTextInfo.lineBreakIterator);
if (is<RenderRubyRun>(replacedBox)) {
m_width.applyOverhang(downcast<RenderRubyRun>(replacedBox), m_lastObject, m_nextObject);
downcast<RenderRubyRun>(replacedBox).updatePriorContextFromCachedBreakIterator(m_renderTextInfo.lineBreakIterator);
} else {
// Update prior line break context characters, using U+FFFD (OBJECT REPLACEMENT CHARACTER) for replaced element.
m_renderTextInfo.lineBreakIterator.updatePriorContext(replacementCharacter);
@@ -129,11 +129,11 @@ void LineWidth::commit()
m_hasCommitted = true;
}

void LineWidth::applyOverhang(RenderRubyRun* rubyRun, RenderObject* startRenderer, RenderObject* endRenderer)
void LineWidth::applyOverhang(const RenderRubyRun& rubyRun, RenderObject* startRenderer, RenderObject* endRenderer)
{
float startOverhang;
float endOverhang;
rubyRun->getOverhang(m_isFirstLine, startRenderer, endRenderer, startOverhang, endOverhang);
rubyRun.getOverhang(m_isFirstLine, startRenderer, endRenderer, startOverhang, endOverhang);

startOverhang = std::min(startOverhang, m_committedWidth);
m_availableWidth += startOverhang;
@@ -73,7 +73,7 @@ class LineWidth {
m_hasUncommittedReplaced = true;
}
void commit();
void applyOverhang(RenderRubyRun*, RenderObject* startRenderer, RenderObject* endRenderer);
void applyOverhang(const RenderRubyRun&, RenderObject* startRenderer, RenderObject* endRenderer);
void fitBelowFloats(bool isFirstLine = false);
void setTrailingWhitespaceWidth(float collapsedWhitespace, float borderPaddingMargin = 0);
IndentTextOrNot shouldIndentText() const { return m_shouldIndentText; }

0 comments on commit 682e9cb

Please sign in to comment.