Skip to content
Permalink
Browse files
[LFC][IFC] Disable simplified text measuring codepath when first styl…
…e line has related unique values

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

Reviewed by Antti Koivisto.

* layout/formattingContexts/inline/InlineLineBuilder.cpp:
(WebCore::Layout::LineBuilder::inlineItemWidth const):
* layout/integration/LayoutIntegrationBoxTree.cpp:
* rendering/RenderText.cpp:
(WebCore::RenderText::computeCanUseSimplifiedTextMeasuring const):


Canonical link: https://commits.webkit.org/242500@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@283535 268f45cc-cd09-0410-ab3c-d52691b4dbfc
  • Loading branch information
alanbujtas committed Oct 5, 2021
1 parent 8c3b157 commit caf42d5b47dccd66001b48b5b2646c4a195a97af
Showing 4 changed files with 27 additions and 7 deletions.
@@ -1,3 +1,16 @@
2021-10-04 Alan Bujtas <zalan@apple.com>

[LFC][IFC] Disable simplified text measuring codepath when first style line has related unique values
https://bugs.webkit.org/show_bug.cgi?id=231177

Reviewed by Antti Koivisto.

* layout/formattingContexts/inline/InlineLineBuilder.cpp:
(WebCore::Layout::LineBuilder::inlineItemWidth const):
* layout/integration/LayoutIntegrationBoxTree.cpp:
* rendering/RenderText.cpp:
(WebCore::RenderText::computeCanUseSimplifiedTextMeasuring const):

2021-10-04 Alan Bujtas <zalan@apple.com>

[LFC][IFC] Hyphenation should not be applied with 'word-break: break-all'
@@ -218,7 +218,7 @@ InlineLayoutUnit LineBuilder::inlineItemWidth(const InlineItem& inlineItem, Inli
if (is<InlineTextItem>(inlineItem)) {
auto& inlineTextItem = downcast<InlineTextItem>(inlineItem);
if (auto contentWidth = inlineTextItem.width()) {
ASSERT(inlineTextItem.firstLineStyle() == inlineTextItem.style());
ASSERT(&inlineTextItem.firstLineStyle() == &inlineTextItem.style());
return *contentWidth;
}
auto& fontCascade = m_isFirstLine ? inlineTextItem.firstLineStyle().fontCascade() : inlineTextItem.style().fontCascade();
@@ -44,7 +44,7 @@ namespace LayoutIntegration {
static constexpr size_t smallTreeThreshold = 8;

// FIXME: see webkit.org/b/230964
#define CAN_USE_FIRST_LINE_STYLE_RESOLVE 0
#define CAN_USE_FIRST_LINE_STYLE_RESOLVE 1

static RenderStyle rootBoxStyle(const RenderStyle& style)
{
@@ -1429,22 +1429,29 @@ bool RenderText::computeCanUseSimplifiedTextMeasuring() const
if (!m_canUseSimpleFontCodePath)
return false;

auto& font = style().fontCascade();
if (font.wordSpacing() || font.letterSpacing())
// FIXME: All these checks should be more fine-grained at the inline item level.
auto& style = this->style();
if (&style != &firstLineStyle()) {
auto& firstLineStyle = this->firstLineStyle();
if (style.fontCascade() != firstLineStyle.fontCascade() || style.collapseWhiteSpace() != firstLineStyle.collapseWhiteSpace())
return false;
}

auto& fontCascade = style.fontCascade();
if (fontCascade.wordSpacing() || fontCascade.letterSpacing())
return false;

// Additional check on the font codepath.
TextRun run(m_text);
run.setCharacterScanForCodePath(false);
if (font.codePath(run) != FontCascade::CodePath::Simple)
if (fontCascade.codePath(run) != FontCascade::CodePath::Simple)
return false;

auto& fontCascade = style().fontCascade();
auto& primaryFont = fontCascade.primaryFont();
if (primaryFont.syntheticBoldOffset())
return false;

auto whitespaceIsCollapsed = style().collapseWhiteSpace();
auto whitespaceIsCollapsed = style.collapseWhiteSpace();
for (unsigned i = 0; i < text().length(); ++i) {
auto character = text()[i];
if (!WidthIterator::characterCanUseSimplifiedTextMeasuring(character, whitespaceIsCollapsed))

0 comments on commit caf42d5

Please sign in to comment.