WebKit Bugzilla
Attachment 372337 Details for
Bug 198962
: [LFC][IFC] Inline quirks should have their dedicated class.
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
Patch
bug-198962-20190618073023.patch (text/plain), 14.80 KB, created by
zalan
on 2019-06-18 07:30:24 PDT
(
hide
)
Description:
Patch
Filename:
MIME Type:
Creator:
zalan
Created:
2019-06-18 07:30:24 PDT
Size:
14.80 KB
patch
obsolete
>Subversion Revision: 246492 >diff --git a/Source/WebCore/ChangeLog b/Source/WebCore/ChangeLog >index ad0822dd0ead93bb23f3fd6dc952f8342d0fb653..5b63e2abdf4ea77bb236b2384651b586faa78f5c 100644 >--- a/Source/WebCore/ChangeLog >+++ b/Source/WebCore/ChangeLog >@@ -1,3 +1,24 @@ >+2019-06-18 Zalan Bujtas <zalan@apple.com> >+ >+ [LFC][IFC] Inline quirks should have their dedicated class. >+ https://bugs.webkit.org/show_bug.cgi?id=198962 >+ <rdar://problem/51848170> >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ * Sources.txt: >+ * WebCore.xcodeproj/project.pbxproj: >+ * layout/LayoutState.h: >+ * layout/inlineformatting/InlineFormattingContext.h: >+ * layout/inlineformatting/InlineFormattingContextLineLayout.cpp: >+ (WebCore::Layout::InlineFormattingContext::LineLayout::createDisplayRuns const): >+ * layout/inlineformatting/InlineFormattingContextQuirks.cpp: Added. >+ (WebCore::Layout::InlineFormattingContext::Quirks::collapseLineDescent): >+ * layout/inlineformatting/InlineLine.cpp: >+ (WebCore::Layout::Line::close): >+ * layout/inlineformatting/InlineLineBreaker.cpp: >+ * layout/inlineformatting/InlineLineBreaker.h: >+ > 2019-06-18 Zalan Bujtas <zalan@apple.com> > > [LFC][IFC] Line::append() should take care of all the inline types. >diff --git a/Source/WebCore/Sources.txt b/Source/WebCore/Sources.txt >index 1b2cfd19487f8d62d530d75b54055d57bcf504af..ded889a052fc1a51defc22cb9ea23ec83e17c4be 100644 >--- a/Source/WebCore/Sources.txt >+++ b/Source/WebCore/Sources.txt >@@ -1351,6 +1351,7 @@ layout/floats/FloatingState.cpp > layout/inlineformatting/InlineFormattingContext.cpp > layout/inlineformatting/InlineFormattingContextGeometry.cpp > layout/inlineformatting/InlineFormattingContextLineLayout.cpp >+layout/inlineformatting/InlineFormattingContextQuirks.cpp > layout/inlineformatting/InlineFormattingState.cpp > layout/inlineformatting/InlineInvalidation.cpp > layout/inlineformatting/InlineLine.cpp >diff --git a/Source/WebCore/WebCore.xcodeproj/project.pbxproj b/Source/WebCore/WebCore.xcodeproj/project.pbxproj >index aacba4c14b071add6cd196b1ea7925fe76e5fe72..9142bafd1f5fecf9fff0c7c6dc6348f4dadcb7c0 100644 >--- a/Source/WebCore/WebCore.xcodeproj/project.pbxproj >+++ b/Source/WebCore/WebCore.xcodeproj/project.pbxproj >@@ -9144,6 +9144,7 @@ > 6F0830DF20B46951008A945B /* BlockFormattingContextGeometry.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = BlockFormattingContextGeometry.cpp; sourceTree = "<group>"; }; > 6F0CD692229ED31900C5994E /* InlineLine.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = InlineLine.cpp; sourceTree = "<group>"; }; > 6F0CD694229ED32700C5994E /* InlineLine.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = InlineLine.h; sourceTree = "<group>"; }; >+ 6F10B08622B8568D0090E69C /* InlineFormattingContextQuirks.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = InlineFormattingContextQuirks.cpp; sourceTree = "<group>"; }; > 6F1CC1DC225F8B4100720AD2 /* InlineTextItem.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = InlineTextItem.cpp; sourceTree = "<group>"; }; > 6F1CC1DD225F8B4200720AD2 /* InlineTextItem.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = InlineTextItem.h; sourceTree = "<group>"; }; > 6F222B741AB52D640094651A /* WebGLVertexArrayObjectBase.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = WebGLVertexArrayObjectBase.h; sourceTree = "<group>"; }; >@@ -16402,6 +16403,7 @@ > 6F7CA3C8208C2B2E002F29AB /* InlineFormattingContext.h */, > 6F35EFAF2187CBD50044E0F4 /* InlineFormattingContextGeometry.cpp */, > 6F25B200220A85AB0000011B /* InlineFormattingContextLineLayout.cpp */, >+ 6F10B08622B8568D0090E69C /* InlineFormattingContextQuirks.cpp */, > 115CFA7D208B8E10001E6991 /* InlineFormattingState.cpp */, > 115CFA7C208B8E10001E6991 /* InlineFormattingState.h */, > 1123AFDD209ABBBA00736ACC /* InlineInvalidation.cpp */, >diff --git a/Source/WebCore/layout/LayoutState.h b/Source/WebCore/layout/LayoutState.h >index 69727bd4f73ea3069f5bfa093c14a787fbc6c0a2..d9d10c0b862d309c780e023f540855b4f6d2ec57 100644 >--- a/Source/WebCore/layout/LayoutState.h >+++ b/Source/WebCore/layout/LayoutState.h >@@ -31,6 +31,7 @@ > #include <wtf/HashSet.h> > #include <wtf/IsoMalloc.h> > #include <wtf/OptionSet.h> >+#include <wtf/WeakPtr.h> > > namespace WebCore { > >diff --git a/Source/WebCore/layout/inlineformatting/InlineFormattingContext.h b/Source/WebCore/layout/inlineformatting/InlineFormattingContext.h >index fd60d5b9b5fe04d45dfbc0564933d2e89e167d9d..596e655c48a932d9892cef2d7052c1063ab2adbf 100644 >--- a/Source/WebCore/layout/inlineformatting/InlineFormattingContext.h >+++ b/Source/WebCore/layout/inlineformatting/InlineFormattingContext.h >@@ -95,6 +95,11 @@ private: > const Container& m_formattingRoot; > }; > >+ class Quirks { >+ public: >+ static bool lineDescentNeedsCollapsing(const LayoutState&, const Line::Content&); >+ }; >+ > class Geometry : public FormattingContext::Geometry { > public: > static HeightAndMargin inlineBlockHeightAndMargin(const LayoutState&, const Box&); >@@ -114,6 +119,8 @@ private: > void collectInlineContent() const; > > InlineFormattingState& formattingState() const { return downcast<InlineFormattingState>(FormattingContext::formattingState()); } >+ // FIXME: Come up with a structure that requires no friending. >+ friend class Line; > }; > > } >diff --git a/Source/WebCore/layout/inlineformatting/InlineFormattingContextLineLayout.cpp b/Source/WebCore/layout/inlineformatting/InlineFormattingContextLineLayout.cpp >index 49451000929afc74a49c1eec3400edf485167db5..550bbd64b37df9f5122f09ccbfe7913da0b00030 100644 >--- a/Source/WebCore/layout/inlineformatting/InlineFormattingContextLineLayout.cpp >+++ b/Source/WebCore/layout/inlineformatting/InlineFormattingContextLineLayout.cpp >@@ -310,8 +310,6 @@ void InlineFormattingContext::LineLayout::createDisplayRuns(const Line::Content& > Optional<unsigned> previousLineLastRunIndex = inlineDisplayRuns.isEmpty() ? Optional<unsigned>() : inlineDisplayRuns.size() - 1; > // 9.4.2 Inline formatting contexts > // A line box is always tall enough for all of the boxes it contains. >- >- // Ignore the initial strut. > auto lineBoxRect = Display::Rect { lineContent.logicalTop(), lineContent.logicalLeft(), 0, lineContent.logicalHeight()}; > // Create final display runs. > auto& lineRuns = lineContent.runs(); >diff --git a/Source/WebCore/layout/inlineformatting/InlineFormattingContextQuirks.cpp b/Source/WebCore/layout/inlineformatting/InlineFormattingContextQuirks.cpp >new file mode 100644 >index 0000000000000000000000000000000000000000..13ec8e8bba4a0878584cf817b551b24f77579913 >--- /dev/null >+++ b/Source/WebCore/layout/inlineformatting/InlineFormattingContextQuirks.cpp >@@ -0,0 +1,88 @@ >+/* >+ * Copyright (C) 2019 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. >+ */ >+ >+#include "config.h" >+#include "InlineFormattingContext.h" >+ >+#if ENABLE(LAYOUT_FORMATTING_CONTEXT) >+ >+#include "InlineItem.h" >+#include "InlineLine.h" >+#include "InlineTextItem.h" >+#include "LayoutState.h" >+ >+namespace WebCore { >+namespace Layout { >+ >+bool InlineFormattingContext::Quirks::lineDescentNeedsCollapsing(const LayoutState& layoutState, const Line::Content& lineContent) >+{ >+ // Collapse line descent in limited and full quirk mode when there's no baseline aligned content or >+ // the baseline aligned content has no descent. >+ if (!layoutState.inQuirksMode() && !layoutState.inLimitedQuirksMode()) >+ return false; >+ >+ for (auto& run : lineContent.runs()) { >+ auto& inlineItem = run->inlineItem; >+ if (inlineItem.style().verticalAlign() != VerticalAlign::Baseline) >+ continue; >+ >+ switch (inlineItem.type()) { >+ case InlineItem::Type::Text: >+ if (!run->isCollapsed) >+ return false; >+ break; >+ case InlineItem::Type::HardLineBreak: >+ return false; >+ case InlineItem::Type::ContainerStart: { >+ auto& displayBox = layoutState.displayBoxForLayoutBox(inlineItem.layoutBox()); >+ if (displayBox.horizontalBorder() || (displayBox.horizontalPadding() && displayBox.horizontalPadding().value())) >+ return false; >+ break; >+ } >+ case InlineItem::Type::ContainerEnd: >+ break; >+ case InlineItem::Type::Box: { >+ auto& layoutBox = inlineItem.layoutBox(); >+ if (layoutBox.isInlineBlockBox() && layoutBox.establishesInlineFormattingContext()) { >+ auto& formattingState = downcast<InlineFormattingState>(layoutState.establishedFormattingState(layoutBox)); >+ ASSERT(!formattingState.lineBoxes().isEmpty()); >+ auto inlineBlockBaseline = formattingState.lineBoxes().last().baseline(); >+ if (inlineBlockBaseline.descent) >+ return false; >+ } >+ break; >+ } >+ default: >+ ASSERT_NOT_REACHED(); >+ break; >+ } >+ } >+ return true; >+} >+ >+} >+} >+ >+#endif >diff --git a/Source/WebCore/layout/inlineformatting/InlineLine.cpp b/Source/WebCore/layout/inlineformatting/InlineLine.cpp >index 0d810867535223df92ff9a850136a0f0a07a197c..7198feb48555001b6e0348579e29367bd3fc618b 100644 >--- a/Source/WebCore/layout/inlineformatting/InlineLine.cpp >+++ b/Source/WebCore/layout/inlineformatting/InlineLine.cpp >@@ -101,8 +101,12 @@ std::unique_ptr<Line::Content> Line::close() > m_contentLogicalHeight = { }; > } > >- auto hasDescent = false; >- auto hasNonBaselineAlignedContent = false; >+ // Remove descent when all content is baseline aligned but none of them have descent. >+ if (InlineFormattingContext::Quirks::lineDescentNeedsCollapsing(m_layoutState, *m_content)) { >+ m_contentLogicalHeight -= m_baseline.descent; >+ m_baseline.descent = { }; >+ } >+ > for (auto& run : m_content->runs()) { > LayoutUnit logicalTop; > auto& inlineItem = run->inlineItem; >@@ -112,20 +116,17 @@ std::unique_ptr<Line::Content> Line::close() > > switch (verticalAlign) { > case VerticalAlign::Baseline: >- if (inlineItem.isLineBreak() || inlineItem.isText()) { >+ if (inlineItem.isLineBreak() || inlineItem.isText()) > logicalTop = baselineOffset() - ascent; >- hasDescent = hasDescent || !run->isCollapsed; >- } else if (inlineItem.isContainerStart()) { >+ else if (inlineItem.isContainerStart()) { > auto& displayBox = m_layoutState.displayBoxForLayoutBox(layoutBox); > logicalTop = baselineOffset() - ascent - displayBox.borderTop() - displayBox.paddingTop().valueOr(0); >- hasDescent = hasDescent || (displayBox.horizontalBorder() || (displayBox.horizontalPadding() && displayBox.horizontalPadding().value())); > } else if (layoutBox.isInlineBlockBox() && layoutBox.establishesInlineFormattingContext()) { > auto& formattingState = downcast<InlineFormattingState>(m_layoutState.establishedFormattingState(layoutBox)); > // Spec makes us generate at least one line -even if it is empty. > ASSERT(!formattingState.lineBoxes().isEmpty()); > auto inlineBlockBaseline = formattingState.lineBoxes().last().baseline(); > logicalTop = baselineOffset() - inlineBlockBaseline.ascent; >- hasDescent = hasDescent || inlineBlockBaseline.descent; > } else > logicalTop = baselineOffset() - run->logicalRect.height(); > break; >@@ -139,14 +140,8 @@ std::unique_ptr<Line::Content> Line::close() > ASSERT_NOT_IMPLEMENTED_YET(); > break; > } >- hasNonBaselineAlignedContent = hasNonBaselineAlignedContent || verticalAlign != VerticalAlign::Baseline; > run->logicalRect.setTop(logicalTop); > } >- // Remove descent when all content is baseline aligned but none of them have descent. >- if (!m_layoutState.inNoQuirksMode() && !hasNonBaselineAlignedContent && !hasDescent) { >- m_contentLogicalHeight -= m_baseline.descent; >- m_baseline.descent = { }; >- } > } > m_content->setLogicalRect({ logicalTop(), logicalLeft(), contentLogicalWidth(), logicalHeight() }); > m_content->setBaseline(m_baseline); >diff --git a/Source/WebCore/layout/inlineformatting/InlineLineBreaker.cpp b/Source/WebCore/layout/inlineformatting/InlineLineBreaker.cpp >index 996af40e86e32ca2a313e5a9ada938e11364f50f..cdd6860901b36cf61240386b65ee04d623882cc9 100644 >--- a/Source/WebCore/layout/inlineformatting/InlineLineBreaker.cpp >+++ b/Source/WebCore/layout/inlineformatting/InlineLineBreaker.cpp >@@ -29,6 +29,8 @@ > #if ENABLE(LAYOUT_FORMATTING_CONTEXT) > > #include "Hyphenation.h" >+#include "InlineItem.h" >+#include "InlineTextItem.h" > #include "LayoutState.h" > > namespace WebCore { >diff --git a/Source/WebCore/layout/inlineformatting/InlineLineBreaker.h b/Source/WebCore/layout/inlineformatting/InlineLineBreaker.h >index a845413c0329224b758e7adc6f6406de4448e174..ef9784f154c043c73c410d984e4e51800c34acac 100644 >--- a/Source/WebCore/layout/inlineformatting/InlineLineBreaker.h >+++ b/Source/WebCore/layout/inlineformatting/InlineLineBreaker.h >@@ -27,9 +27,12 @@ > > #if ENABLE(LAYOUT_FORMATTING_CONTEXT) > >+#include "LayoutUnit.h" >+ > namespace WebCore { > namespace Layout { > >+class InlineItem; > class InlineTextItem; > > class LineBreaker {
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Formatted Diff
|
Diff
Attachments on
bug 198962
: 372337