[webkit-changes] [WebKit/WebKit] e188ce: [IFC] LineBox::inlineLevelBoxFor may return null_ptr

Alan Baradlay noreply at github.com
Mon Jan 16 08:20:32 PST 2023


  Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: e188ce4e6d0fb7a15d2c43f5081c11105b8da7b9
      https://github.com/WebKit/WebKit/commit/e188ce4e6d0fb7a15d2c43f5081c11105b8da7b9
  Author: Alan Baradlay <zalan at apple.com>
  Date:   2023-01-16 (Mon, 16 Jan 2023)

  Changed paths:
    M Source/WebCore/layout/formattingContexts/inline/InlineLineBox.cpp
    M Source/WebCore/layout/formattingContexts/inline/InlineLineBox.h
    M Source/WebCore/layout/formattingContexts/inline/InlineLineBoxBuilder.cpp
    M Source/WebCore/layout/formattingContexts/inline/InlineLineBoxBuilder.h
    M Source/WebCore/layout/formattingContexts/inline/InlineLineBoxVerticalAligner.cpp
    M Source/WebCore/layout/formattingContexts/inline/display/InlineDisplayContentBuilder.cpp

  Log Message:
  -----------
  [IFC] LineBox::inlineLevelBoxFor may return null_ptr
https://bugs.webkit.org/show_bug.cgi?id=250663

Reviewed by Antti Koivisto.

LineBox::inlineLevelBoxForLayoutBox() assumes it gets always called with a layoutBox present on the current line.
webkit.org/b/249942 showed that it's rather easy to call this function with incorrect layoutBox (not on the current line).

This patch addresses this issue by changing the return type of LineBox::inlineLevelBoxForLayoutBox from InlineLevelBox& to InlineLevelBox*
and return null_ptr if the layout box cannot be found on the current line box.
However this patch also extends LineBox interface with additional helper functions where the argument type makes such calls less error prone.
->
  parentInlineBox(const InlineLevelBox&)
  parentInlineBox(const Line::Run&);
  inlineLevelBoxFor(const Line::Run&);

as many of the inlineLevelBoxForLayoutBox() call sites are actually interested in
1. the parent inline box (which we always have).
2. inline boxes based on actual runs on the line.

* Source/WebCore/layout/formattingContexts/inline/InlineLineBox.cpp:
(WebCore::Layout::LineBox::logicalRectForTextRun const):
(WebCore::Layout::LineBox::inlineLevelBoxAbsoluteTop const):
(WebCore::Layout::LineBox::logicalRectForInlineLevelBox const):
* Source/WebCore/layout/formattingContexts/inline/InlineLineBox.h:
(WebCore::Layout::LineBox::inlineLevelBoxFor const):
(WebCore::Layout::LineBox::inlineBoxFor const):
(WebCore::Layout::LineBox::parentInlineBox const):
(WebCore::Layout::LineBox::inlineLevelBoxFor):
(WebCore::Layout::LineBox::parentInlineBox):
(WebCore::Layout::LineBox::inlineBoxFor):
(WebCore::Layout::LineBox::inlineLevelBoxForLayoutBox const): Deleted.
(WebCore::Layout::LineBox::inlineLevelBoxForLayoutBox): Deleted.
* Source/WebCore/layout/formattingContexts/inline/InlineLineBoxBuilder.cpp:
(WebCore::Layout::LineBoxBuilder::setVerticalPropertiesForInlineLevelBox const):
(WebCore::Layout::LineBoxBuilder::constructInlineLevelBoxes):
(WebCore::Layout::LineBoxBuilder::adjustInlineBoxHeightsForLineBoxContainIfApplicable):
(WebCore::Layout::LineBoxBuilder::adjustOutsideListMarkersPosition):
* Source/WebCore/layout/formattingContexts/inline/InlineLineBoxBuilder.h:
* Source/WebCore/layout/formattingContexts/inline/InlineLineBoxVerticalAligner.cpp:
(WebCore::Layout::LineBoxVerticalAligner::computeLineBoxLogicalHeight const):
(WebCore::Layout::LineBoxVerticalAligner::computeRootInlineBoxVerticalPosition const):
(WebCore::Layout::LineBoxVerticalAligner::alignInlineLevelBoxes const):
* Source/WebCore/layout/formattingContexts/inline/display/InlineDisplayContentBuilder.cpp:
(WebCore::Layout::InlineDisplayContentBuilder::processNonBidiContent):
(WebCore::Layout::InlineDisplayContentBuilder::adjustVisualGeometryForDisplayBox):
(WebCore::Layout::InlineDisplayContentBuilder::processBidiContent):

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




More information about the webkit-changes mailing list