Changeset 234048 in webkit
- Timestamp:
- Jul 20, 2018 10:05:16 AM (6 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r234045 r234048 1 2018-07-20 Zalan Bujtas <zalan@apple.com> 2 3 [LFC][Inline formatting context] Add basic text content handling. 4 https://bugs.webkit.org/show_bug.cgi?id=187860 5 6 Reviewed by Antti Koivisto. 7 8 InlineFormattingContext::layout() walks through the formatting root's descendant list in a post-order fashion and 9 feeds the TextContentProvider. 10 Eventually this would turn into a more generic loop where we stop and process the text content when finding a non-text content box (float, inline-box etc), but right now 11 this is about text content only. 12 13 * layout/displaytree/DisplayBox.h: 14 (WebCore::Display::Box::contentBoxBottom const): 15 (WebCore::Display::Box::contentBoxRight const): 16 * layout/inlineformatting/InlineFormattingContext.cpp: 17 (WebCore::Layout::InlineFormattingContext::layout const): 18 * layout/inlineformatting/textlayout/TextContentProvider.cpp: 19 (WebCore::Layout::TextContentProvider::textRuns): Add a helper function to support the case when all we need is just the run list in one go. 20 * layout/inlineformatting/textlayout/TextContentProvider.h: 21 * layout/layouttree/LayoutBox.cpp: 22 (WebCore::Layout::Box::isDescendantOf const): 23 * layout/layouttree/LayoutBox.h: 24 * layout/layouttree/LayoutInlineBox.h: 25 (WebCore::Layout::InlineBox::textContent const): 26 1 27 2018-07-20 Youenn Fablet <youenn@apple.com> 2 28 -
trunk/Source/WebCore/layout/displaytree/DisplayBox.h
r233350 r234048 147 147 LayoutUnit contentBoxTop() const { return borderTop() + paddingTop(); } 148 148 LayoutUnit contentBoxLeft() const { return borderLeft() + paddingLeft(); } 149 LayoutUnit contentBoxBottom() const { return contentBoxTop() + contentBoxHeight(); } 150 LayoutUnit contentBoxRight() const { return contentBoxLeft() + contentBoxWidth(); } 149 151 LayoutUnit contentBoxHeight() const; 150 152 LayoutUnit contentBoxWidth() const; -
trunk/Source/WebCore/layout/inlineformatting/InlineFormattingContext.cpp
r233469 r234048 32 32 #include "InlineFormattingState.h" 33 33 #include "LayoutBox.h" 34 #include "LayoutContainer.h" 34 35 #include "LayoutContext.h" 36 #include "LayoutInlineBox.h" 37 #include "LayoutInlineContainer.h" 38 #include "Logging.h" 39 #include "SimpleLineBreaker.h" 40 #include "TextContentProvider.h" 35 41 #include <wtf/IsoMallocInlines.h> 42 #include <wtf/text/TextStream.h> 36 43 37 44 namespace WebCore { … … 45 52 } 46 53 47 void InlineFormattingContext::layout(LayoutContext& , FormattingState&) const54 void InlineFormattingContext::layout(LayoutContext& layoutContext, FormattingState&) const 48 55 { 56 if (!is<Container>(root())) 57 return; 58 59 LOG_WITH_STREAM(FormattingContextLayout, stream << "[Start] -> inline formatting context -> layout context(" << &layoutContext << ") formatting root(" << &root() << ")"); 60 61 TextContentProvider textContentProvider; 62 auto& formattingRoot = downcast<Container>(root()); 63 auto* layoutBox = formattingRoot.firstInFlowOrFloatingChild(); 64 // Casually walk through the block's descendants and place the inline boxes one after the other as much as we can (yeah, I am looking at you floats). 65 while (layoutBox) { 66 if (is<Container>(layoutBox)) { 67 ASSERT(is<InlineContainer>(layoutBox)); 68 layoutBox = downcast<Container>(*layoutBox).firstInFlowOrFloatingChild(); 69 continue; 70 } 71 auto& inlineBox = downcast<InlineBox>(*layoutBox); 72 // Only text content at this point. 73 if (inlineBox.textContent()) 74 textContentProvider.appendText(*inlineBox.textContent(), inlineBox.style(), true); 75 76 for (; layoutBox; layoutBox = layoutBox->containingBlock()) { 77 if (layoutBox == &formattingRoot) { 78 layoutBox = nullptr; 79 break; 80 } 81 if (auto* nextSibling = layoutBox->nextInFlowOrFloatingSibling()) { 82 layoutBox = nextSibling; 83 break; 84 } 85 } 86 ASSERT(!layoutBox || layoutBox->isDescendantOf(formattingRoot)); 87 } 88 89 auto& formattingRootDisplayBox = *layoutContext.displayBoxForLayoutBox(formattingRoot); 90 auto lineLeft = formattingRootDisplayBox.contentBoxLeft(); 91 auto lineRight = formattingRootDisplayBox.contentBoxRight(); 92 93 auto textRuns = textContentProvider.textRuns(); 94 SimpleLineBreaker::LineConstraintList constraints; 95 constraints.append({ { }, lineLeft, lineRight }); 96 SimpleLineBreaker simpleLineBreaker(textRuns, textContentProvider, WTFMove(constraints), formattingRoot.style()); 97 auto layoutRuns = simpleLineBreaker.runs(); 98 99 LOG_WITH_STREAM(FormattingContextLayout, stream << "[End] -> inline formatting context -> layout context(" << &layoutContext << ") formatting root(" << &root() << ")"); 49 100 } 50 101 -
trunk/Source/WebCore/layout/inlineformatting/textlayout/TextContentProvider.cpp
r234000 r234048 210 210 } 211 211 212 TextContentProvider::TextRunList TextContentProvider::textRuns() 213 { 214 TextRunList textRunList; 215 216 auto textRunIterator = iterator(); 217 while (auto textRum = textRunIterator.current()) { 218 textRunList.append(*textRum); 219 ++textRunIterator; 220 } 221 return textRunList; 222 } 223 212 224 void TextContentProvider::findNextRun() 213 225 { -
trunk/Source/WebCore/layout/inlineformatting/textlayout/TextContentProvider.h
r234000 r234048 90 90 TextContentProvider& m_contentProvider; 91 91 }; 92 Iterator iterator(); 92 93 93 Iterator iterator(); 94 using TextRunList = Vector<TextRun>; 95 TextRunList textRuns(); 94 96 95 97 private: -
trunk/Source/WebCore/layout/layouttree/LayoutBox.cpp
r233201 r234048 142 142 } 143 143 144 bool Box::isDescendantOf( Container& container) const144 bool Box::isDescendantOf(const Container& container) const 145 145 { 146 146 for (auto* ancestor = containingBlock(); ancestor; ancestor = ancestor->containingBlock()) { -
trunk/Source/WebCore/layout/layouttree/LayoutBox.h
r233201 r234048 65 65 const Container* containingBlock() const; 66 66 const Container& formattingContextRoot() const; 67 bool isDescendantOf( Container&) const;67 bool isDescendantOf(const Container&) const; 68 68 69 69 bool isAnonymous() const { return !m_elementAttributes; } -
trunk/Source/WebCore/layout/layouttree/LayoutInlineBox.h
r233482 r234048 43 43 44 44 void setTextContent(String text) { m_textContent = text; } 45 std::optional<String> textContent() const { return m_textContent; } 45 46 46 47 private: 47 Stringm_textContent;48 std::optional<String> m_textContent; 48 49 }; 49 50
Note: See TracChangeset
for help on using the changeset viewer.