Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: 857fd6ae4fe6ff242b4375eb3538dc2995e93434
      
https://github.com/WebKit/WebKit/commit/857fd6ae4fe6ff242b4375eb3538dc2995e93434
  Author: Vitor Roriz <[email protected]>
  Date:   2024-08-29 (Thu, 29 Aug 2024)

  Changed paths:
    M Source/WebCore/layout/formattingContexts/inline/InlineContentCache.h
    M Source/WebCore/layout/formattingContexts/inline/InlineItemsBuilder.cpp
    M Source/WebCore/layout/formattingContexts/inline/InlineItemsBuilder.h
    M Source/WebCore/platform/text/TextSpacing.cpp
    M Source/WebCore/platform/text/TextSpacing.h

  Log Message:
  -----------
  text-spacing: text-autospace: handle element boundary spacing on IFC (layout 
part)
https://bugs.webkit.org/show_bug.cgi?id=278531
rdar://133319434

Reviewed by Alan Baradlay.

This patch is a step on handling the addition of extra spacing between relevant
characters as required by the text-autospace property [1].
The work will be divided into 2 parts: lauout and display. This patch is
responsible for display.

Up to know we are able to handle spacing between characters within an element.
We also want to handle the case of two adjacent characters that belong to 
different
elements.

For characters within an element we add spacing by manipulating the
correspondent's character's glyphs and advances. We always add spacing as
leading spacing. So if character "A" and "B" need spacing in between them,
this is added as a leading spacing of "B" by expanding its advance.width and
moving its origin.x by the required spacing size.

However, for element boundaries, specification [1] says:

"At element boundaries, the amount of extra spacing introduced between
characters is determined by and rendered within the innermost element that
contains the boundary."

This means that for such a case, spacing has to be added between the elements.

We compute the necessary spacing to be "placed" in between element boundaries at
InlineItemsBuilder::build with computeInlineBoxBoundaryTextSpacingsIfNeeded.
At InlineItemsBuilder::computeInlineTextItemWidths we use such spacing to
contribute to the related InlineTextItem's width.

Important thing to notice:
Given the example:
<span>agua</span><span>水<span>
This would be represented by:
 InlineStartBox | InlineTextItem | InlineEndBox | InlineStartBox | 
InlineTextItem | InlineEndBox
 Being "agua" the content of the first InlineTextItem and "水" the content of 
the second InlineTextItem.

 Visually, the spacing necessary between "agua" and "水" has to appear between 
the first InlineEndBox
 and the second InlineStartBox. This means that such spacing should not 
visually contribute for
 the width of InlineTextItem. It might seem that we are doing this at this 
patch, however,
 this part is just addressing layout, and this information is sufficient for 
InlineContentBreaker to
 take such spacing in consideration. Later, on a future patch which will 
address "display", we will
 then need to place this spacing in its correct visual order: it should me 
moved in front of the InlineStartBox
 and its value should be removed from the InlineTextItem's width, such that it 
doesn't get accounted for twice.

[1] https://www.w3.org/TR/css-text-4/#text-autospace-property

* Source/WebCore/layout/formattingContexts/inline/InlineContentCache.h:
(WebCore::Layout::InlineContentCache::inlineBoxBoundaryTextSpacings const):
(WebCore::Layout::InlineContentCache::setInlineBoxBoundaryTextSpacings):
* Source/WebCore/layout/formattingContexts/inline/InlineFormattingContext.h:
(WebCore::Layout::InlineFormattingContext::inlineContentCache const):
* Source/WebCore/layout/formattingContexts/inline/InlineItemsBuilder.cpp:
(WebCore::Layout::InlineItemsBuilder::build):
(WebCore::Layout::InlineItemsBuilder::adjustInlineBoxBoundaryTextSpacingsIfNeeded):
(WebCore::Layout::InlineItemsBuilder::collectInlineItems):
(WebCore::Layout::InlineItemsBuilder::computeInlineTextItemWidths):
* Source/WebCore/layout/formattingContexts/inline/InlineItemsBuilder.h:
* Source/WebCore/platform/text/TextSpacing.cpp:
(WebCore::TextAutospace::shouldApplySpacing const):
* Source/WebCore/platform/text/TextSpacing.h:

Canonical link: https://commits.webkit.org/282917@main



To unsubscribe from these emails, change your notification settings at 
https://github.com/WebKit/WebKit/settings/notifications
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to