Changeset 234000 in webkit


Ignore:
Timestamp:
Jul 19, 2018 1:36:13 PM (6 years ago)
Author:
Alan Bujtas
Message:

[LFC] Introduce simple line breaker.
https://bugs.webkit.org/show_bug.cgi?id=187688

Reviewed by Antti Koivisto.

This patch takes the simple line layout implementation and refactors it in a way it is no longer requires a RenderBlockFlow object to run on.
Also this patch decouples text run generation and line breaking (and this implementation is going to replace the current simple line layout codebase)

TextContentProvider: Acts both as the container for all the text content (including hard line breaks) and as an iterator for the generated text runs.
SimpleTextRunGenerator: TextContentProvider uses it as the text run generator for simple content (in the future we'll have a ComplexTextRunGenerator).
SimpleLineBreaker: Input -> text runs + line constraints; Output -> layout runs after line breaking.

  • Sources.txt:
  • WebCore.xcodeproj/project.pbxproj:
  • layout/inlineformatting/textlayout/ContentProvider.cpp: Added.

(WebCore::Layout::TextContentProvider::TextItem::Style::Style):
(WebCore::Layout::TextContentProvider::ContentProvider):
(WebCore::Layout::TextContentProvider::~ContentProvider):
(WebCore::Layout::TextContentProvider::appendText):
(WebCore::Layout::TextContentProvider::appendLineBreak):
(WebCore::Layout::TextContentProvider::width const):
(WebCore::Layout::TextContentProvider::textWidth const):
(WebCore::Layout::TextContentProvider::fixedPitchWidth const):
(WebCore::Layout::TextContentProvider::toTextItemIndex const):
(WebCore::Layout::TextContentProvider::length const):
(WebCore::Layout::TextContentProvider::iterator):
(WebCore::Layout::TextContentProvider::findNextRun):
(WebCore::Layout::TextContentProvider::current const):

  • layout/inlineformatting/textlayout/ContentProvider.h: Added.

(WebCore::Layout::TextContentProvider::textContent const):
(WebCore::Layout::TextContentProvider::hardLineBreaks const):
(WebCore::Layout::TextContentProvider::Iterator::current const):
(WebCore::Layout::TextContentProvider::contains const):
(WebCore::Layout::TextContentProvider::Iterator::Iterator):
(WebCore::Layout::TextContentProvider::Iterator::operator++):

  • layout/inlineformatting/textlayout/Runs.h: Added.

(WebCore::Layout::TextRun::isWhitespace const):
(WebCore::Layout::TextRun::isNonWhitespace const):
(WebCore::Layout::TextRun::isLineBreak const):
(WebCore::Layout::TextRun::isSoftLineBreak const):
(WebCore::Layout::TextRun::isHardLineBreak const):
(WebCore::Layout::TextRun::isValid const):
(WebCore::Layout::TextRun::isCollapsed const):
(WebCore::Layout::TextRun::type const):
(WebCore::Layout::TextRun::setIsCollapsed):
(WebCore::Layout::TextRun::setWidth):
(WebCore::Layout::LayoutRun::start const):
(WebCore::Layout::LayoutRun::end const):
(WebCore::Layout::LayoutRun::length const):
(WebCore::Layout::LayoutRun::left const):
(WebCore::Layout::LayoutRun::right const):
(WebCore::Layout::LayoutRun::width const):
(WebCore::Layout::LayoutRun::isEndOfLine const):
(WebCore::Layout::LayoutRun::setEnd):
(WebCore::Layout::LayoutRun::setRight):
(WebCore::Layout::LayoutRun::setIsEndOfLine):
(WebCore::Layout::LayoutRun::LayoutRun):
(WebCore::Layout::TextRun::createWhitespaceRun):
(WebCore::Layout::TextRun::createNonWhitespaceRun):
(WebCore::Layout::TextRun::createSoftLineBreakRun):
(WebCore::Layout::TextRun::createHardLineBreakRun):
(WebCore::Layout::TextRun::TextRun):
(WebCore::Layout::TextRun::start const):
(WebCore::Layout::TextRun::end const):
(WebCore::Layout::TextRun::length const):
(WebCore::Layout::TextRun::width const):

  • layout/inlineformatting/textlayout/simple/SimpleContentProvider.cpp: Added.

(WebCore::Layout::SimpleContentProvider::SimpleContentProvider):
(WebCore::Layout::SimpleContentProvider::current const):
(WebCore::Layout::SimpleContentProvider::reset):
(WebCore::Layout::SimpleContentProvider::findNextRun):
(WebCore::Layout::SimpleContentProvider::moveToNextBreakablePosition):
(WebCore::Layout::SimpleContentProvider::moveToNextNonWhitespacePosition):
(WebCore::Layout::SimpleContentProvider::isAtLineBreak const):
(WebCore::Layout::SimpleContentProvider::isAtSoftLineBreak const):

  • layout/inlineformatting/textlayout/simple/SimpleContentProvider.h: Added.

(WebCore::Layout::SimpleContentProvider::Iterator::reset):
(WebCore::Layout::SimpleContentProvider::Position::operator== const):
(WebCore::Layout::SimpleContentProvider::Position::operator< const):
(WebCore::Layout::SimpleContentProvider::Position::operator ContentPosition const):
(WebCore::Layout::SimpleContentProvider::Position::resetItemPosition):
(WebCore::Layout::SimpleContentProvider::Position::contentPosition const):
(WebCore::Layout::SimpleContentProvider::Position::itemPosition const):
(WebCore::Layout::SimpleContentProvider::Iterator<T>::Iterator):
(WebCore::Layout::SimpleContentProvider::Iterator<T>::current const):
(WebCore::Layout::SimpleContentProvider::Iterator<T>::operator):
(WebCore::Layout::SimpleContentProvider::Position::operator++):
(WebCore::Layout::SimpleContentProvider::Position::operator+=):

  • layout/inlineformatting/textlayout/simple/SimpleLineBreaker.cpp: Added.

(WebCore::Layout::SimpleLineBreaker::TextRunList::TextRunList):
(WebCore::Layout::SimpleLineBreaker::Line::Line):
(WebCore::Layout::adjustedEndPosition):
(WebCore::Layout::SimpleLineBreaker::Line::append):
(WebCore::Layout::SimpleLineBreaker::Line::collapseTrailingWhitespace):
(WebCore::Layout::SimpleLineBreaker::Line::reset):
(WebCore::Layout::SimpleLineBreaker::Style::Style):
(WebCore::Layout::SimpleLineBreaker::SimpleLineBreaker):
(WebCore::Layout::SimpleLineBreaker::runs):
(WebCore::Layout::SimpleLineBreaker::createRunsForLine):
(WebCore::Layout::SimpleLineBreaker::handleOverflownRun):
(WebCore::Layout::SimpleLineBreaker::collapseLeadingWhitespace):
(WebCore::Layout::SimpleLineBreaker::collapseTrailingWhitespace):
(WebCore::Layout::SimpleLineBreaker::splitTextRun):
(WebCore::Layout::SimpleLineBreaker::split const):
(WebCore::Layout::SimpleLineBreaker::availableWidth const):
(WebCore::Layout::SimpleLineBreaker::verticalPosition const):

  • layout/inlineformatting/textlayout/simple/SimpleLineBreaker.h: Added.

(WebCore::Layout::SimpleLineBreaker::TextRunList::overrideCurrent):
(WebCore::Layout::SimpleLineBreaker::TextRunList::isCurrentOverridden const):
(WebCore::Layout::SimpleLineBreaker::Line::availableWidth const):
(WebCore::Layout::SimpleLineBreaker::Line::hasContent const):
(WebCore::Layout::SimpleLineBreaker::Line::setAvailableWidth):
(WebCore::Layout::SimpleLineBreaker::Line::hasTrailingWhitespace const):
(WebCore::Layout::SimpleLineBreaker::Line::isWhitespaceOnly const):
(WebCore::Layout::SimpleLineBreaker::wrapContentOnOverflow const):
(WebCore::Layout::SimpleLineBreaker::TextRunList::current const):
(WebCore::Layout::SimpleLineBreaker::TextRunList::operator++):

Location:
trunk/Source/WebCore
Files:
9 added
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r233995 r234000  
     12018-07-19  Zalan Bujtas  <zalan@apple.com>
     2
     3        [LFC] Introduce simple line breaker.
     4        https://bugs.webkit.org/show_bug.cgi?id=187688
     5
     6        Reviewed by Antti Koivisto.
     7
     8        This patch takes the simple line layout implementation and refactors it in a way it is no longer requires a RenderBlockFlow object to run on.
     9        Also this patch decouples text run generation and line breaking (and this implementation is going to replace the current simple line layout codebase)
     10
     11        TextContentProvider: Acts both as the container for all the text content (including hard line breaks) and as an iterator for the generated text runs.
     12        SimpleTextRunGenerator: TextContentProvider uses it as the text run generator for simple content (in the future we'll have a ComplexTextRunGenerator).
     13        SimpleLineBreaker: Input -> text runs + line constraints; Output -> layout runs after line breaking.
     14
     15        * Sources.txt:
     16        * WebCore.xcodeproj/project.pbxproj:
     17        * layout/inlineformatting/textlayout/ContentProvider.cpp: Added.
     18        (WebCore::Layout::TextContentProvider::TextItem::Style::Style):
     19        (WebCore::Layout::TextContentProvider::ContentProvider):
     20        (WebCore::Layout::TextContentProvider::~ContentProvider):
     21        (WebCore::Layout::TextContentProvider::appendText):
     22        (WebCore::Layout::TextContentProvider::appendLineBreak):
     23        (WebCore::Layout::TextContentProvider::width const):
     24        (WebCore::Layout::TextContentProvider::textWidth const):
     25        (WebCore::Layout::TextContentProvider::fixedPitchWidth const):
     26        (WebCore::Layout::TextContentProvider::toTextItemIndex const):
     27        (WebCore::Layout::TextContentProvider::length const):
     28        (WebCore::Layout::TextContentProvider::iterator):
     29        (WebCore::Layout::TextContentProvider::findNextRun):
     30        (WebCore::Layout::TextContentProvider::current const):
     31        * layout/inlineformatting/textlayout/ContentProvider.h: Added.
     32        (WebCore::Layout::TextContentProvider::textContent const):
     33        (WebCore::Layout::TextContentProvider::hardLineBreaks const):
     34        (WebCore::Layout::TextContentProvider::Iterator::current const):
     35        (WebCore::Layout::TextContentProvider::contains const):
     36        (WebCore::Layout::TextContentProvider::Iterator::Iterator):
     37        (WebCore::Layout::TextContentProvider::Iterator::operator++):
     38        * layout/inlineformatting/textlayout/Runs.h: Added.
     39        (WebCore::Layout::TextRun::isWhitespace const):
     40        (WebCore::Layout::TextRun::isNonWhitespace const):
     41        (WebCore::Layout::TextRun::isLineBreak const):
     42        (WebCore::Layout::TextRun::isSoftLineBreak const):
     43        (WebCore::Layout::TextRun::isHardLineBreak const):
     44        (WebCore::Layout::TextRun::isValid const):
     45        (WebCore::Layout::TextRun::isCollapsed const):
     46        (WebCore::Layout::TextRun::type const):
     47        (WebCore::Layout::TextRun::setIsCollapsed):
     48        (WebCore::Layout::TextRun::setWidth):
     49        (WebCore::Layout::LayoutRun::start const):
     50        (WebCore::Layout::LayoutRun::end const):
     51        (WebCore::Layout::LayoutRun::length const):
     52        (WebCore::Layout::LayoutRun::left const):
     53        (WebCore::Layout::LayoutRun::right const):
     54        (WebCore::Layout::LayoutRun::width const):
     55        (WebCore::Layout::LayoutRun::isEndOfLine const):
     56        (WebCore::Layout::LayoutRun::setEnd):
     57        (WebCore::Layout::LayoutRun::setRight):
     58        (WebCore::Layout::LayoutRun::setIsEndOfLine):
     59        (WebCore::Layout::LayoutRun::LayoutRun):
     60        (WebCore::Layout::TextRun::createWhitespaceRun):
     61        (WebCore::Layout::TextRun::createNonWhitespaceRun):
     62        (WebCore::Layout::TextRun::createSoftLineBreakRun):
     63        (WebCore::Layout::TextRun::createHardLineBreakRun):
     64        (WebCore::Layout::TextRun::TextRun):
     65        (WebCore::Layout::TextRun::start const):
     66        (WebCore::Layout::TextRun::end const):
     67        (WebCore::Layout::TextRun::length const):
     68        (WebCore::Layout::TextRun::width const):
     69        * layout/inlineformatting/textlayout/simple/SimpleContentProvider.cpp: Added.
     70        (WebCore::Layout::SimpleContentProvider::SimpleContentProvider):
     71        (WebCore::Layout::SimpleContentProvider::current const):
     72        (WebCore::Layout::SimpleContentProvider::reset):
     73        (WebCore::Layout::SimpleContentProvider::findNextRun):
     74        (WebCore::Layout::SimpleContentProvider::moveToNextBreakablePosition):
     75        (WebCore::Layout::SimpleContentProvider::moveToNextNonWhitespacePosition):
     76        (WebCore::Layout::SimpleContentProvider::isAtLineBreak const):
     77        (WebCore::Layout::SimpleContentProvider::isAtSoftLineBreak const):
     78        * layout/inlineformatting/textlayout/simple/SimpleContentProvider.h: Added.
     79        (WebCore::Layout::SimpleContentProvider::Iterator::reset):
     80        (WebCore::Layout::SimpleContentProvider::Position::operator== const):
     81        (WebCore::Layout::SimpleContentProvider::Position::operator< const):
     82        (WebCore::Layout::SimpleContentProvider::Position::operator ContentPosition const):
     83        (WebCore::Layout::SimpleContentProvider::Position::resetItemPosition):
     84        (WebCore::Layout::SimpleContentProvider::Position::contentPosition const):
     85        (WebCore::Layout::SimpleContentProvider::Position::itemPosition const):
     86        (WebCore::Layout::SimpleContentProvider::Iterator<T>::Iterator):
     87        (WebCore::Layout::SimpleContentProvider::Iterator<T>::current const):
     88        (WebCore::Layout::SimpleContentProvider::Iterator<T>::operator):
     89        (WebCore::Layout::SimpleContentProvider::Position::operator++):
     90        (WebCore::Layout::SimpleContentProvider::Position::operator+=):
     91        * layout/inlineformatting/textlayout/simple/SimpleLineBreaker.cpp: Added.
     92        (WebCore::Layout::SimpleLineBreaker::TextRunList::TextRunList):
     93        (WebCore::Layout::SimpleLineBreaker::Line::Line):
     94        (WebCore::Layout::adjustedEndPosition):
     95        (WebCore::Layout::SimpleLineBreaker::Line::append):
     96        (WebCore::Layout::SimpleLineBreaker::Line::collapseTrailingWhitespace):
     97        (WebCore::Layout::SimpleLineBreaker::Line::reset):
     98        (WebCore::Layout::SimpleLineBreaker::Style::Style):
     99        (WebCore::Layout::SimpleLineBreaker::SimpleLineBreaker):
     100        (WebCore::Layout::SimpleLineBreaker::runs):
     101        (WebCore::Layout::SimpleLineBreaker::createRunsForLine):
     102        (WebCore::Layout::SimpleLineBreaker::handleOverflownRun):
     103        (WebCore::Layout::SimpleLineBreaker::collapseLeadingWhitespace):
     104        (WebCore::Layout::SimpleLineBreaker::collapseTrailingWhitespace):
     105        (WebCore::Layout::SimpleLineBreaker::splitTextRun):
     106        (WebCore::Layout::SimpleLineBreaker::split const):
     107        (WebCore::Layout::SimpleLineBreaker::availableWidth const):
     108        (WebCore::Layout::SimpleLineBreaker::verticalPosition const):
     109        * layout/inlineformatting/textlayout/simple/SimpleLineBreaker.h: Added.
     110        (WebCore::Layout::SimpleLineBreaker::TextRunList::overrideCurrent):
     111        (WebCore::Layout::SimpleLineBreaker::TextRunList::isCurrentOverridden const):
     112        (WebCore::Layout::SimpleLineBreaker::Line::availableWidth const):
     113        (WebCore::Layout::SimpleLineBreaker::Line::hasContent const):
     114        (WebCore::Layout::SimpleLineBreaker::Line::setAvailableWidth):
     115        (WebCore::Layout::SimpleLineBreaker::Line::hasTrailingWhitespace const):
     116        (WebCore::Layout::SimpleLineBreaker::Line::isWhitespaceOnly const):
     117        (WebCore::Layout::SimpleLineBreaker::wrapContentOnOverflow const):
     118        (WebCore::Layout::SimpleLineBreaker::TextRunList::current const):
     119        (WebCore::Layout::SimpleLineBreaker::TextRunList::operator++):
     120
    11212018-07-19  Keith Rollin  <krollin@apple.com>
    2122
  • trunk/Source/WebCore/Sources.txt

    r233846 r234000  
    12331233layout/inlineformatting/InlineFormattingState.cpp
    12341234layout/inlineformatting/InlineInvalidation.cpp
     1235layout/inlineformatting/textlayout/TextContentProvider.cpp
     1236layout/inlineformatting/textlayout/simple/SimpleTextRunGenerator.cpp
     1237layout/inlineformatting/textlayout/simple/SimpleLineBreaker.cpp
    12351238layout/layouttree/LayoutBlockContainer.cpp
    12361239layout/layouttree/LayoutBox.cpp
  • trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj

    r233995 r234000  
    58085808                11E067EB1E62461300162D16 /* SimpleLineLayoutCoverage.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SimpleLineLayoutCoverage.cpp; sourceTree = "<group>"; };
    58095809                11E067ED1E6246E500162D16 /* SimpleLineLayoutCoverage.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SimpleLineLayoutCoverage.h; sourceTree = "<group>"; };
     5810                11EA57FB20FFAFB600311EBB /* SimpleTextRunGenerator.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SimpleTextRunGenerator.cpp; sourceTree = "<group>"; };
     5811                11EA57FC20FFAFB700311EBB /* SimpleTextRunGenerator.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SimpleTextRunGenerator.h; sourceTree = "<group>"; };
    58105812                11FF02D520BA3C810083F25B /* Verification.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = Verification.cpp; sourceTree = "<group>"; };
    58115813                1400D7A717136EA70077CE05 /* ScriptWrappableInlines.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ScriptWrappableInlines.h; sourceTree = "<group>"; };
     
    89178919                6F7CA3C8208C2B2E002F29AB /* InlineFormattingContext.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = InlineFormattingContext.h; sourceTree = "<group>"; };
    89188920                6F7CA3C9208C2B2E002F29AB /* InlineFormattingContext.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = InlineFormattingContext.cpp; sourceTree = "<group>"; };
     8921                6F8304C920FBA5E1004AD5D1 /* SimpleLineBreaker.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = SimpleLineBreaker.cpp; sourceTree = "<group>"; };
     8922                6F8304CA20FBA5E1004AD5D1 /* SimpleLineBreaker.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = SimpleLineBreaker.h; sourceTree = "<group>"; };
    89198923                6F995A091A7070E600A735F4 /* WebGLQuery.idl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = WebGLQuery.idl; sourceTree = "<group>"; };
    89208924                6F995A0A1A7070E600A735F4 /* WebGLSampler.idl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = WebGLSampler.idl; sourceTree = "<group>"; };
     
    89438947                6F995A301A70833700A735F4 /* JSWebGLVertexArrayObject.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSWebGLVertexArrayObject.h; sourceTree = "<group>"; };
    89448948                6FBB860520B464B600DAD938 /* FormattingContextGeometry.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = FormattingContextGeometry.cpp; sourceTree = "<group>"; };
     8949                6FCD19C120F9727A00FD4529 /* TextContentProvider.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = TextContentProvider.h; sourceTree = "<group>"; };
     8950                6FCD19C720F9727D00FD4529 /* TextContentProvider.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = TextContentProvider.cpp; sourceTree = "<group>"; };
     8951                6FCF975220F02B3500214960 /* Runs.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = Runs.h; sourceTree = "<group>"; };
    89458952                709A01FD1E3D0BCC006B0D4C /* ModuleFetchFailureKind.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ModuleFetchFailureKind.h; sourceTree = "<group>"; };
    89468953                71004B9D1DC1398800A52A38 /* playback-support.js */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.javascript; path = "playback-support.js"; sourceTree = "<group>"; };
     
    1577615783                        isa = PBXGroup;
    1577715784                        children = (
     15785                                6FE7DDDD20EC6E8B008B5B4E /* textlayout */,
    1577815786                                6F7CA3C9208C2B2E002F29AB /* InlineFormattingContext.cpp */,
    1577915787                                6F7CA3C8208C2B2E002F29AB /* InlineFormattingContext.h */,
     
    1950119509                        tabWidth = 4;
    1950219510                        usesTabs = 0;
     19511                };
     19512                6F13A12320F9949C001C025A /* simple */ = {
     19513                        isa = PBXGroup;
     19514                        children = (
     19515                                6F8304C920FBA5E1004AD5D1 /* SimpleLineBreaker.cpp */,
     19516                                6F8304CA20FBA5E1004AD5D1 /* SimpleLineBreaker.h */,
     19517                                11EA57FB20FFAFB600311EBB /* SimpleTextRunGenerator.cpp */,
     19518                                11EA57FC20FFAFB700311EBB /* SimpleTextRunGenerator.h */,
     19519                        );
     19520                        path = simple;
     19521                        sourceTree = "<group>";
     19522                };
     19523                6FE7DDDD20EC6E8B008B5B4E /* textlayout */ = {
     19524                        isa = PBXGroup;
     19525                        children = (
     19526                                6F13A12320F9949C001C025A /* simple */,
     19527                                6FCF975220F02B3500214960 /* Runs.h */,
     19528                                6FCD19C720F9727D00FD4529 /* TextContentProvider.cpp */,
     19529                                6FCD19C120F9727A00FD4529 /* TextContentProvider.h */,
     19530                        );
     19531                        path = textlayout;
     19532                        sourceTree = "<group>";
    1950319533                };
    1950419534                71025EC11F99F096004A250C /* animation */ = {
Note: See TracChangeset for help on using the changeset viewer.