Changeset 286801 in webkit
- Timestamp:
- Dec 9, 2021, 1:28:22 PM (5 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 5 edited
-
ChangeLog (modified) (1 diff)
-
layout/formattingContexts/inline/InlineDisplayContentBuilder.cpp (modified) (2 diffs)
-
layout/formattingContexts/inline/InlineItem.h (modified) (1 diff)
-
layout/formattingContexts/inline/InlineItemsBuilder.cpp (modified) (1 diff)
-
layout/formattingContexts/inline/InlineLineBuilder.cpp (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r286799 r286801 1 2021-12-09 Alan Bujtas <zalan@apple.com> 2 3 [LFC][IFC] Try not to include non-content type of inline boxes in the visual reordering 4 https://bugs.webkit.org/show_bug.cgi?id=234033 5 6 Reviewed by Antti Koivisto. 7 8 In InlineItemsBuilder::setBidiLevelForOpaqueInlineItems we try to figure out the bidi 9 level for inline box markers (<span> and </span>) mostly to be able to position 10 empty inline boxes (specifically with decorations). In some cases though the guessed 11 bidi level breaks the continuation between the content before and after the marker (e.g. before</span>after) 12 In this patch we try to limit the number of items associated with this guessed bidi level. 13 14 * layout/formattingContexts/inline/InlineDisplayContentBuilder.cpp: 15 (WebCore::Layout::InlineDisplayContentBuilder::processBidiContent): 16 * layout/formattingContexts/inline/InlineItem.h: 17 * layout/formattingContexts/inline/InlineItemsBuilder.cpp: 18 (WebCore::Layout::InlineItemsBuilder::breakAndComputeBidiLevels): 19 * layout/formattingContexts/inline/InlineLineBuilder.cpp: 20 (WebCore::Layout::LineBuilder::layoutInlineContent): we may only submit a subset of runs to the reordering 21 algorithm. It also means we may end up with gaps between the visual index values and the real run item indexes. 22 The runIndexOffsetMap ensures that the indexes are always consistent with the content in the lineRuns vector. 23 1 24 2021-12-08 BJ Burg <bburg@apple.com> 2 25 -
trunk/Source/WebCore/layout/formattingContexts/inline/InlineDisplayContentBuilder.cpp
r286789 r286801 461 461 void InlineDisplayContentBuilder::processBidiContent(const LineBuilder::LineContent& lineContent, const LineBox& lineBox, const InlineLayoutPoint& lineBoxLogicalTopLeft, DisplayBoxes& boxes) 462 462 { 463 ASSERT(lineContent.visualOrderList.size() == lineContent.runs.size());463 ASSERT(lineContent.visualOrderList.size() <= lineContent.runs.size()); 464 464 465 465 AncestorStack ancestorStack; … … 480 480 auto contentRightInVisualOrder = contentStartInVisualOrder; 481 481 auto& runs = lineContent.runs; 482 for (size_t i = 0; i < runs.size(); ++i) { 483 auto visualIndex = lineContent.visualOrderList[i]; 484 auto& lineRun = runs[visualIndex]; 482 for (auto visualOrder : lineContent.visualOrderList) { 483 ASSERT(runs[visualOrder].bidiLevel() != InlineItem::opaqueBidiLevel); 484 485 auto& lineRun = runs[visualOrder]; 485 486 auto& layoutBox = lineRun.layoutBox(); 486 487 487 auto needsDisplayBox = !lineRun.is InlineBoxEnd() && !lineRun.isWordBreakOpportunity();488 auto needsDisplayBox = !lineRun.isWordBreakOpportunity(); 488 489 if (!needsDisplayBox) 489 490 continue; -
trunk/Source/WebCore/layout/formattingContexts/inline/InlineItem.h
r286104 r286801 52 52 53 53 Type type() const { return m_type; } 54 static constexpr UBiDiLevel opaqueBidiLevel = 0xff; 54 55 UBiDiLevel bidiLevel() const { return m_bidiLevel; } 55 56 const Box& layoutBox() const { return *m_layoutBox; } -
trunk/Source/WebCore/layout/formattingContexts/inline/InlineItemsBuilder.cpp
r286104 r286801 334 334 } 335 335 if (inlineItems[index].isInlineBoxEnd()) { 336 // Inline box end (e.g. </span>) also uses the content bidi level, but in this case it's the previous content. 337 auto previousBidiLevel = [&]() -> std::optional<UBiDiLevel> { 338 for (auto i = index; i--;) { 339 if (inlineItemOffsets[i]) 340 return inlineItems[i].bidiLevel(); 341 } 342 return { }; 343 }(); 344 inlineItems[index].setBidiLevel(previousBidiLevel.value_or(rootBidiLevel)); 336 // Let's not confuse ubidi with non-content entries. Opaque runs are excluded from the visual list. 337 inlineItems[index].setBidiLevel(InlineItem::opaqueBidiLevel); 345 338 continue; 346 339 } -
trunk/Source/WebCore/layout/formattingContexts/inline/InlineLineBuilder.cpp
r285999 r286801 301 301 return { }; 302 302 303 Vector<UBiDiLevel> runLevels(lineRuns.size()); 304 // FIXME: We may cache these values in Line, if it turns out to be a perf hit. 305 for (size_t i = 0; i < lineRuns.size(); ++i) 306 runLevels[i] = lineRuns[i].bidiLevel(); 307 308 Vector<int32_t> visualOrderList(lineRuns.size()); 303 Vector<UBiDiLevel> runLevels; 304 runLevels.reserveInitialCapacity(lineRuns.size()); 305 306 Vector<size_t> runIndexOffsetMap; 307 runIndexOffsetMap.reserveInitialCapacity(lineRuns.size()); 308 auto hasOpaqueRun = false; 309 for (size_t i = 0, accumulatedOffset = 0; i < lineRuns.size(); ++i) { 310 if (lineRuns[i].bidiLevel() == InlineItem::opaqueBidiLevel) { 311 ++accumulatedOffset; 312 hasOpaqueRun = true; 313 continue; 314 } 315 runLevels.append(lineRuns[i].bidiLevel()); 316 runIndexOffsetMap.append(accumulatedOffset); 317 } 318 319 Vector<int32_t> visualOrderList(runLevels.size()); 309 320 ubidi_reorderVisual(runLevels.data(), runLevels.size(), visualOrderList.data()); 321 if (hasOpaqueRun) { 322 ASSERT(visualOrderList.size() == runIndexOffsetMap.size()); 323 for (size_t i = 0; i < runIndexOffsetMap.size(); ++i) 324 visualOrderList[i] += runIndexOffsetMap[visualOrderList[i]]; 325 } 310 326 return visualOrderList; 311 327 };
Note:
See TracChangeset
for help on using the changeset viewer.