Title: [253906] trunk/Source/WebCore
- Revision
- 253906
- Author
- [email protected]
- Date
- 2019-12-25 04:22:43 -0800 (Wed, 25 Dec 2019)
Log Message
[LFC][IFC] Add support for zero-width-space character (U+200B)
https://bugs.webkit.org/show_bug.cgi?id=205586
<rdar://problem/58188505>
Reviewed by Antti Koivisto.
If a line has only U+200B characters, it is still considered empty from line breaking point of view.
(Note that U+200B is not considered a whitespace character so a run with U+200B does not collapse.)
* layout/inlineformatting/InlineLineBuilder.cpp:
(WebCore::Layout::LineBuilder::appendTextContent): empty runs don't collapse.
(WebCore::Layout::LineBuilder::isVisuallyNonEmpty const):
(WebCore::Layout::LineBuilder::InlineItemRun::hasEmptyTextContent const):
* layout/inlineformatting/InlineLineBuilder.h:
* layout/inlineformatting/InlineTextItem.cpp:
(WebCore::Layout::InlineTextItem::isEmptyContent const):
* layout/inlineformatting/InlineTextItem.h:
Modified Paths
Diff
Modified: trunk/Source/WebCore/ChangeLog (253905 => 253906)
--- trunk/Source/WebCore/ChangeLog 2019-12-25 12:07:06 UTC (rev 253905)
+++ trunk/Source/WebCore/ChangeLog 2019-12-25 12:22:43 UTC (rev 253906)
@@ -1,5 +1,25 @@
2019-12-25 Zalan Bujtas <[email protected]>
+ [LFC][IFC] Add support for zero-width-space character (U+200B)
+ https://bugs.webkit.org/show_bug.cgi?id=205586
+ <rdar://problem/58188505>
+
+ Reviewed by Antti Koivisto.
+
+ If a line has only U+200B characters, it is still considered empty from line breaking point of view.
+ (Note that U+200B is not considered a whitespace character so a run with U+200B does not collapse.)
+
+ * layout/inlineformatting/InlineLineBuilder.cpp:
+ (WebCore::Layout::LineBuilder::appendTextContent): empty runs don't collapse.
+ (WebCore::Layout::LineBuilder::isVisuallyNonEmpty const):
+ (WebCore::Layout::LineBuilder::InlineItemRun::hasEmptyTextContent const):
+ * layout/inlineformatting/InlineLineBuilder.h:
+ * layout/inlineformatting/InlineTextItem.cpp:
+ (WebCore::Layout::InlineTextItem::isEmptyContent const):
+ * layout/inlineformatting/InlineTextItem.h:
+
+2019-12-25 Zalan Bujtas <[email protected]>
+
[LFC][IFC] Fix LayoutTests/imported/w3c/web-platform-tests/css/css-text/letter-spacing/letter-spacing-control-chars-001.html
https://bugs.webkit.org/show_bug.cgi?id=205585
<rdar://problem/58188420>
Modified: trunk/Source/WebCore/layout/inlineformatting/InlineLineBuilder.cpp (253905 => 253906)
--- trunk/Source/WebCore/layout/inlineformatting/InlineLineBuilder.cpp 2019-12-25 12:07:06 UTC (rev 253905)
+++ trunk/Source/WebCore/layout/inlineformatting/InlineLineBuilder.cpp 2019-12-25 12:22:43 UTC (rev 253906)
@@ -495,17 +495,11 @@
void LineBuilder::appendTextContent(const InlineTextItem& inlineItem, InlineLayoutUnit logicalWidth)
{
auto willCollapseCompletely = [&] {
- // Empty run.
- if (!inlineItem.length()) {
- ASSERT(!logicalWidth);
- return true;
- }
+ if (!inlineItem.isCollapsible())
+ return false;
// Leading whitespace.
if (m_inlineItemRuns.isEmpty())
return !shouldPreserveLeadingContent(inlineItem);
-
- if (!inlineItem.isCollapsible())
- return false;
// Check if the last item is collapsed as well.
for (auto i = m_inlineItemRuns.size(); i--;) {
auto& run = m_inlineItemRuns[i];
@@ -687,7 +681,7 @@
bool LineBuilder::isVisuallyNonEmpty(const InlineItemRun& run) const
{
if (run.isText())
- return !run.isCollapsedToZeroAdvanceWidth();
+ return !run.hasEmptyTextContent();
// Note that this does not check whether the inline container has content. It simply checks if the container itself is considered non-empty.
if (run.isContainerStart() || run.isContainerEnd()) {
@@ -874,7 +868,13 @@
ASSERT(m_logicalWidth > 0 || (!m_logicalWidth && style().letterSpacing() >= intMaxForLayoutUnit));
}
+bool LineBuilder::InlineItemRun::hasEmptyTextContent() const
+{
+ ASSERT(isText());
+ return isCollapsedToZeroAdvanceWidth() || downcast<InlineTextItem>(m_inlineItem).isEmptyContent();
}
+
}
+}
#endif
Modified: trunk/Source/WebCore/layout/inlineformatting/InlineLineBuilder.h (253905 => 253906)
--- trunk/Source/WebCore/layout/inlineformatting/InlineLineBuilder.h 2019-12-25 12:07:06 UTC (rev 253905)
+++ trunk/Source/WebCore/layout/inlineformatting/InlineLineBuilder.h 2019-12-25 12:22:43 UTC (rev 253906)
@@ -188,6 +188,7 @@
bool isCollapsible() const { return is<InlineTextItem>(m_inlineItem) && downcast<InlineTextItem>(m_inlineItem).isCollapsible(); }
bool isWhitespace() const { return is<InlineTextItem>(m_inlineItem) && downcast<InlineTextItem>(m_inlineItem).isWhitespace(); }
+ bool hasEmptyTextContent() const;
bool hasExpansionOpportunity() const { return isWhitespace() && !isCollapsedToZeroAdvanceWidth(); }
Modified: trunk/Source/WebCore/layout/inlineformatting/InlineTextItem.cpp (253905 => 253906)
--- trunk/Source/WebCore/layout/inlineformatting/InlineTextItem.cpp 2019-12-25 12:07:06 UTC (rev 253905)
+++ trunk/Source/WebCore/layout/inlineformatting/InlineTextItem.cpp 2019-12-25 12:22:43 UTC (rev 253906)
@@ -28,9 +28,9 @@
#if ENABLE(LAYOUT_FORMATTING_CONTEXT)
-#include "FontCascade.h"
#include "InlineSoftLineBreakItem.h"
#include "TextUtil.h"
+#include <wtf/unicode/CharacterNames.h>
namespace WebCore {
namespace Layout {
@@ -147,6 +147,12 @@
{
}
+bool InlineTextItem::isEmptyContent() const
+{
+ // FIXME: We should check for more zero width content and not just U+200B.
+ return !m_length || (m_length == 1 && layoutBox().textContext()->content[start()] == zeroWidthSpace);
+}
+
std::unique_ptr<InlineTextItem> InlineTextItem::left(unsigned length) const
{
RELEASE_ASSERT(length <= this->length());
Modified: trunk/Source/WebCore/layout/inlineformatting/InlineTextItem.h (253905 => 253906)
--- trunk/Source/WebCore/layout/inlineformatting/InlineTextItem.h 2019-12-25 12:07:06 UTC (rev 253905)
+++ trunk/Source/WebCore/layout/inlineformatting/InlineTextItem.h 2019-12-25 12:22:43 UTC (rev 253906)
@@ -48,6 +48,7 @@
bool isWhitespace() const { return m_textItemType == TextItemType::Whitespace; }
bool isCollapsible() const { return isWhitespace() && style().collapseWhiteSpace(); }
Optional<InlineLayoutUnit> width() const { return m_width; }
+ bool isEmptyContent() const;
std::unique_ptr<InlineTextItem> left(unsigned length) const;
std::unique_ptr<InlineTextItem> right(unsigned length) const;
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes