-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[IFC] Add fast path for simple text only content
https://bugs.webkit.org/show_bug.cgi?id=259900 Reviewed by Antti Koivisto. This patch adds a fast path for simple, text-only inline content. 1. Introduce a base class for line builders (AbstractLineBuilder) 2. Move shared types (LineInput etc) from LineBuilder to AbstractLineBuilder.h 3. Implement TextOnlyLineBuilder (This is really just a subset of LineBuilder with simplified state machine/logic) This improves PerformanceTests/Layout/line-layout.html by ~55%. * Source/WebCore/Headers.cmake: * Source/WebCore/Sources.txt: * Source/WebCore/WebCore.xcodeproj/project.pbxproj: * Source/WebCore/layout/formattingContexts/inline/InlineContentBreaker.cpp: (WebCore::Layout::InlineContentBreaker::ContinuousContent::appendTextContent): * Source/WebCore/layout/formattingContexts/inline/InlineContentBreaker.h: * Source/WebCore/layout/formattingContexts/inline/InlineFormattingContext.cpp: (WebCore::Layout::isRootStyleEligibleForSimplifiedTextOnlyInlineLayout): (WebCore::Layout::InlineFormattingContext::layoutInFlowAndFloatContent): (WebCore::Layout::InlineFormattingContext::textOnlyLineLayout): (WebCore::Layout::InlineFormattingContext::lineLayout): (WebCore::Layout::InlineFormattingContext::createDisplayContentForLine): (WebCore::Layout::InlineFormattingContext::resetGeometryForClampedContent): * Source/WebCore/layout/formattingContexts/inline/InlineFormattingContext.h: * Source/WebCore/layout/formattingContexts/inline/InlineFormattingGeometry.cpp: (WebCore::Layout::InlineFormattingGeometry::logicalTopForNextLine const): * Source/WebCore/layout/formattingContexts/inline/InlineFormattingGeometry.h: * Source/WebCore/layout/formattingContexts/inline/InlineFormattingState.h: (WebCore::Layout::InlineFormattingState::setIsNonBidiTextAndForcedLineBreakOnlyContent): (WebCore::Layout::InlineFormattingState::isNonBidiTextAndForcedLineBreakOnlyContent const): * Source/WebCore/layout/formattingContexts/inline/InlineItemsBuilder.cpp: (WebCore::Layout::InlineItemsBuilder::collectInlineItems): (WebCore::Layout::InlineItemsBuilder::handleTextContent): (WebCore::Layout::InlineItemsBuilder::handleInlineBoxStart): (WebCore::Layout::InlineItemsBuilder::handleInlineBoxEnd): (WebCore::Layout::InlineItemsBuilder::handleInlineLevelBox): * Source/WebCore/layout/formattingContexts/inline/InlineItemsBuilder.h: * Source/WebCore/layout/formattingContexts/inline/InlineLineBoxBuilder.cpp: (WebCore::Layout::LineBoxBuilder::LineBoxBuilder): * Source/WebCore/layout/formattingContexts/inline/InlineLineBoxBuilder.h: (WebCore::Layout::LineBoxBuilder::isFirstLine const): (WebCore::Layout::LineBoxBuilder::lineLayoutResult const): * Source/WebCore/layout/formattingContexts/inline/InlineLineBuilder.cpp: (WebCore::Layout::LineCandidate::InlineContent::appendInlineItem): (WebCore::Layout::LineBuilder::layoutInlineContent): * Source/WebCore/layout/formattingContexts/inline/InlineLineBuilder.h: * Source/WebCore/layout/formattingContexts/inline/InlineLineLayoutTypes.h: Added. * Source/WebCore/layout/formattingContexts/inline/TextOnlyLineBuilder.cpp: Added. (WebCore::Layout::inlineTextItemWidth): (WebCore::Layout::placedInlineItemEnd): (WebCore::Layout::isLastLineWithInlineContent): (WebCore::Layout::appendInlineTextItem): (WebCore::Layout::consumeTrailingLineBreakIfApplicable): (WebCore::Layout::TextOnlyLineBuilder::TextOnlyLineBuilder): (WebCore::Layout::TextOnlyLineBuilder::layoutInlineContent): (WebCore::Layout::TextOnlyLineBuilder::initialize): (WebCore::Layout::TextOnlyLineBuilder::placeInlineTextContent): (WebCore::Layout::TextOnlyLineBuilder::placeNonWrappingInlineTextContent): (WebCore::Layout::TextOnlyLineBuilder::handleInlineTextContent): (WebCore::Layout::TextOnlyLineBuilder::handleLineEnding): (WebCore::Layout::TextOnlyLineBuilder::horizontalAlignmentOffset const): (WebCore::Layout::TextOnlyLineBuilder::rebuildLine): (WebCore::Layout::TextOnlyLineBuilder::root const): * Source/WebCore/layout/formattingContexts/inline/TextOnlyLineBuilder.h: Added. (WebCore::Layout::TextOnlyLineBuilder::TextOnlyLineBuilder): (WebCore::Layout::TextOnlyLineBuilder::isFirstFormattedLine const): (WebCore::Layout::TextOnlyLineBuilder::intrinsicWidthMode const): (WebCore::Layout::TextOnlyLineBuilder::isInIntrinsicWidthMode const): (WebCore::Layout::TextOnlyLineBuilder::formattingContext const): * Source/WebCore/layout/formattingContexts/inline/display/InlineDisplayContentBuilder.cpp: (WebCore::Layout::InlineDisplayContentBuilder::build): (WebCore::Layout::InlineDisplayContentBuilder::processNonBidiContent): (WebCore::Layout::InlineDisplayContentBuilder::processBidiContent): (WebCore::Layout::InlineDisplayContentBuilder::processFloatBoxes): * Source/WebCore/layout/formattingContexts/inline/display/InlineDisplayContentBuilder.h: * Source/WebCore/layout/formattingContexts/inline/display/InlineDisplayLineBuilder.cpp: (WebCore::Layout::InlineDisplayLineBuilder::collectEnclosingLineGeometry const): (WebCore::Layout::InlineDisplayLineBuilder::build const): * Source/WebCore/layout/formattingContexts/inline/display/InlineDisplayLineBuilder.h: Canonical link: https://commits.webkit.org/266815@main
- Loading branch information
1 parent
eacccd2
commit ba2673d
Showing
25 changed files
with
753 additions
and
136 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
105 changes: 105 additions & 0 deletions
105
Source/WebCore/layout/formattingContexts/inline/AbstractLineBuilder.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,105 @@ | ||
/* | ||
* Copyright (C) 2023 Apple Inc. All rights reserved. | ||
* | ||
* Redistribution and use in source and binary forms, with or without | ||
* modification, are permitted provided that the following conditions | ||
* are met: | ||
* 1. Redistributions of source code must retain the above copyright | ||
* notice, this list of conditions and the following disclaimer. | ||
* 2. Redistributions in binary form must reproduce the above copyright | ||
* notice, this list of conditions and the following disclaimer in the | ||
* documentation and/or other materials provided with the distribution. | ||
* | ||
* THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' | ||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, | ||
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | ||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS | ||
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | ||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | ||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | ||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | ||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | ||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF | ||
* THE POSSIBILITY OF SUCH DAMAGE. | ||
*/ | ||
|
||
#pragma once | ||
|
||
#include "FloatingState.h" | ||
#include "InlineLineTypes.h" | ||
#include "LayoutUnits.h" | ||
|
||
namespace WebCore { | ||
namespace Layout { | ||
|
||
struct LineInput { | ||
InlineItemRange needsLayoutRange; | ||
InlineRect initialLogicalRect; | ||
}; | ||
|
||
struct LineLayoutResult { | ||
using PlacedFloatList = FloatingState::FloatList; | ||
using SuspendedFloatList = Vector<const Box*>; | ||
|
||
InlineItemRange inlineItemRange; | ||
const Line::RunList& inlineContent; | ||
|
||
struct FloatContent { | ||
PlacedFloatList placedFloats; | ||
SuspendedFloatList suspendedFloats; | ||
bool hasIntrusiveFloat { false }; | ||
}; | ||
FloatContent floatContent { }; | ||
|
||
struct ContentGeometry { | ||
InlineLayoutUnit logicalLeft { 0.f }; | ||
InlineLayoutUnit logicalWidth { 0.f }; | ||
InlineLayoutUnit logicalRightIncludingNegativeMargin { 0.f }; // Note that with negative horizontal margin value, contentLogicalLeft + contentLogicalWidth is not necessarily contentLogicalRight. | ||
std::optional<InlineLayoutUnit> trailingOverflowingContentWidth { }; | ||
}; | ||
ContentGeometry contentGeometry { }; | ||
|
||
struct LineGeometry { | ||
InlineLayoutPoint logicalTopLeft; | ||
InlineLayoutUnit logicalWidth { 0.f }; | ||
InlineLayoutUnit initialLogicalLeftIncludingIntrusiveFloats { 0.f }; | ||
std::optional<InlineLayoutUnit> initialLetterClearGap { }; | ||
}; | ||
LineGeometry lineGeometry { }; | ||
|
||
struct HangingContent { | ||
bool shouldContributeToScrollableOverflow { false }; | ||
InlineLayoutUnit logicalWidth { 0.f }; | ||
}; | ||
HangingContent hangingContent { }; | ||
|
||
struct Directionality { | ||
Vector<int32_t> visualOrderList; | ||
TextDirection inlineBaseDirection { TextDirection::LTR }; | ||
}; | ||
Directionality directionality { }; | ||
|
||
struct IsFirstLast { | ||
enum class FirstFormattedLine : uint8_t { | ||
No, | ||
WithinIFC, | ||
WithinBFC | ||
}; | ||
FirstFormattedLine isFirstFormattedLine { FirstFormattedLine::WithinIFC }; | ||
bool isLastLineWithInlineContent { true }; | ||
}; | ||
IsFirstLast isFirstLast { }; | ||
// Misc | ||
size_t nonSpanningInlineLevelBoxCount { 0 }; | ||
std::optional<InlineLayoutUnit> hintForNextLineTopToAvoidIntrusiveFloat { }; // This is only used for cases when intrusive floats prevent any content placement at current vertical position. | ||
}; | ||
|
||
class AbstractLineBuilder { | ||
public: | ||
virtual LineLayoutResult layoutInlineContent(const LineInput&, const std::optional<PreviousLine>&) = 0; | ||
virtual ~AbstractLineBuilder() { }; | ||
}; | ||
|
||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.