Summary: | ASSERTION FAILED: !m_trailingWhitespaceWidth in WebCore::SimpleLineLayout::LineState::removeTrailingWhitespace | ||||||||
---|---|---|---|---|---|---|---|---|---|
Product: | WebKit | Reporter: | Renata Hodovan <hodovan> | ||||||
Component: | Layout and Rendering | Assignee: | zalan <zalan> | ||||||
Status: | RESOLVED FIXED | ||||||||
Severity: | Normal | CC: | commit-queue, esprehn+autocc, glenn, koivisto, kondapallykalyan, simon.fraser, zalan | ||||||
Priority: | P2 | ||||||||
Version: | WebKit Local Build | ||||||||
Hardware: | Unspecified | ||||||||
OS: | Unspecified | ||||||||
Bug Depends on: | |||||||||
Bug Blocks: | 116980 | ||||||||
Attachments: |
|
Description
Renata Hodovan
2016-10-27 13:43:09 PDT
Created attachment 293051 [details]
Test
It looks like we end up with a NaN tab width when the font-size is 0. FontCascade::tabWidth() -> float tabDeltaWidth = tabWidth - fmodf(position, tabWidth); when tabWidth = 0 -> tabDeltaWidth = NaN diff --git a/Source/WebCore/platform/graphics/FontCascade.h b/Source/WebCore/platform/graphics/FontCascade.h index a463e37..a461402 100644 --- a/Source/WebCore/platform/graphics/FontCascade.h +++ b/Source/WebCore/platform/graphics/FontCascade.h @@ -365,6 +365,8 @@ inline float FontCascade::tabWidth(const Font& font, unsigned tabSize, float pos if (!tabSize) return letterSpacing(); float tabWidth = tabSize * font.spaceWidth() + letterSpacing(); + if (!tabWidth) + return 0; float tabDeltaWidth = tabWidth - fmodf(position, tabWidth); return (tabDeltaWidth < font.spaceWidth() / 2) ? tabWidth : tabDeltaWidth; } ^^ fixes the NaN issue, though I guess it's pretty useless to iterate through all the runs when the font size is 0. early return on zero fonts. diff --git a/Source/WebCore/rendering/SimpleLineLayoutTextFragmentIterator.cpp b/Source/WebCore/rendering/SimpleLineLayoutTextFragmentIterator.cpp index 251dfe3..cb68346 100644 --- a/Source/WebCore/rendering/SimpleLineLayoutTextFragmentIterator.cpp +++ b/Source/WebCore/rendering/SimpleLineLayoutTextFragmentIterator.cpp @@ -149,6 +149,8 @@ float TextFragmentIterator::textWidth(unsigned from, unsigned to, float xPositio auto& segment = *m_currentSegment; ASSERT(segment.start <= from && from <= segment.end && segment.start <= to && to <= segment.end); ASSERT(is<RenderText>(segment.renderer)); + if (!m_style.font.size()) + return 0; if (m_style.font.isFixedPitch() || (from == segment.start && to == segment.end)) return downcast<RenderText>(segment.renderer).width(from - segment.start, to - from, m_style.font, xPosition, nullptr, nullptr); return segment.text.is8Bit() ? runWidth<LChar>(segment, from, to, xPosition) : runWidth<UChar>(segment, from, to, xPosition); @@ -197,7 +199,7 @@ template <typename CharacterType> float TextFragmentIterator::runWidth(const FlowContents::Segment& segment, unsigned startPosition, unsigned endPosition, float xPosition) const { ASSERT(startPosition <= endPosition); - if (startPosition == endPosition) + if (startPosition == endPosition || !m_style.font.size()) return 0; unsigned segmentFrom = startPosition - segment.start; unsigned segmentTo = endPosition - segment.start; Created attachment 293444 [details]
Patch
Comment on attachment 293444 [details] Patch Clearing flags on attachment: 293444 Committed r208170: <http://trac.webkit.org/changeset/208170> All reviewed patches have been landed. Closing bug. |