Title: [281373] trunk/Source/WebCore
Revision
281373
Author
za...@apple.com
Date
2021-08-21 06:49:32 -0700 (Sat, 21 Aug 2021)

Log Message

[IFC][Integration] Do not scan the content for overflowing glyph when line-box-contain is set to glyph
https://bugs.webkit.org/show_bug.cgi?id=228895
<rdar://problem/81651487>

Reviewed by Antti Koivisto.

This is in preparation for removing content scanning completely.

* layout/integration/LayoutIntegrationCoverage.cpp:
(WebCore::LayoutIntegration::printReason):
(WebCore::LayoutIntegration::canUseForText):
(WebCore::LayoutIntegration::canUseForFontAndText):
* layout/integration/LayoutIntegrationCoverage.h:

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (281372 => 281373)


--- trunk/Source/WebCore/ChangeLog	2021-08-21 13:42:48 UTC (rev 281372)
+++ trunk/Source/WebCore/ChangeLog	2021-08-21 13:49:32 UTC (rev 281373)
@@ -1,5 +1,21 @@
 2021-08-21  Zalan Bujtas  <za...@apple.com>
 
+        [IFC][Integration] Do not scan the content for overflowing glyph when line-box-contain is set to glyph
+        https://bugs.webkit.org/show_bug.cgi?id=228895
+        <rdar://problem/81651487>
+
+        Reviewed by Antti Koivisto.
+
+        This is in preparation for removing content scanning completely. 
+
+        * layout/integration/LayoutIntegrationCoverage.cpp:
+        (WebCore::LayoutIntegration::printReason):
+        (WebCore::LayoutIntegration::canUseForText):
+        (WebCore::LayoutIntegration::canUseForFontAndText):
+        * layout/integration/LayoutIntegrationCoverage.h:
+
+2021-08-21  Zalan Bujtas  <za...@apple.com>
+
         Fix spelling: MidWorkdBreak -> MidWordBreak
 
         Unreviewed.

Modified: trunk/Source/WebCore/layout/integration/LayoutIntegrationCoverage.cpp (281372 => 281373)


--- trunk/Source/WebCore/layout/integration/LayoutIntegrationCoverage.cpp	2021-08-21 13:42:48 UTC (rev 281372)
+++ trunk/Source/WebCore/layout/integration/LayoutIntegrationCoverage.cpp	2021-08-21 13:49:32 UTC (rev 281373)
@@ -204,8 +204,8 @@
     case AvoidanceReason::FlowChildIsSelected:
         stream << "selected content";
         break;
-    case AvoidanceReason::FlowFontHasOverflowGlyph:
-        stream << "-webkit-line-box-contain: glyphs with overflowing text.";
+    case AvoidanceReason::FlowHasLineBoxContainGlyphs:
+        stream << "-webkit-line-box-contain: glyphs";
         break;
     case AvoidanceReason::FlowTextHasSurrogatePair:
         stream << "surrogate pair";
@@ -436,18 +436,10 @@
 }
 
 template <typename CharacterType>
-static OptionSet<AvoidanceReason> canUseForText(const CharacterType* text, unsigned length, const FontCascade& fontCascade, std::optional<float> lineHeightConstraint, IncludeReasons includeReasons)
+static OptionSet<AvoidanceReason> canUseForText(const CharacterType* text, unsigned length, const FontCascade& fontCascade, IncludeReasons includeReasons)
 {
     OptionSet<AvoidanceReason> reasons;
     auto& primaryFont = fontCascade.primaryFont();
-    auto& fontMetrics = primaryFont.fontMetrics();
-    auto availableSpaceForGlyphAscent = fontMetrics.ascent();
-    auto availableSpaceForGlyphDescent = fontMetrics.descent();
-    if (lineHeightConstraint) {
-        auto lineHeightPadding = *lineHeightConstraint - fontMetrics.height();
-        availableSpaceForGlyphAscent += lineHeightPadding / 2;
-        availableSpaceForGlyphDescent += lineHeightPadding / 2;
-    }
 
     for (unsigned i = 0; i < length; ++i) {
         auto character = text[i];
@@ -458,21 +450,15 @@
         auto glyphData = fontCascade.glyphDataForCharacter(character, false);
         if (!glyphData.isValid() || glyphData.font != &primaryFont)
             SET_REASON_AND_RETURN_IF_NEEDED(FlowPrimaryFontIsInsufficient, reasons, includeReasons);
-
-        if (lineHeightConstraint) {
-            auto bounds = primaryFont.boundsForGlyph(glyphData.glyph);
-            if (ceilf(-bounds.y()) > availableSpaceForGlyphAscent || ceilf(bounds.maxY()) > availableSpaceForGlyphDescent)
-                SET_REASON_AND_RETURN_IF_NEEDED(FlowFontHasOverflowGlyph, reasons, includeReasons);
-        }
     }
     return reasons;
 }
 
-static OptionSet<AvoidanceReason> canUseForText(StringView text, const FontCascade& fontCascade, std::optional<float> lineHeightConstraint, IncludeReasons includeReasons)
+static OptionSet<AvoidanceReason> canUseForText(StringView text, const FontCascade& fontCascade, IncludeReasons includeReasons)
 {
     if (text.is8Bit())
-        return canUseForText(text.characters8(), text.length(), fontCascade, lineHeightConstraint, includeReasons);
-    return canUseForText(text.characters16(), text.length(), fontCascade, lineHeightConstraint, includeReasons);
+        return canUseForText(text.characters8(), text.length(), fontCascade, includeReasons);
+    return canUseForText(text.characters16(), text.length(), fontCascade, includeReasons);
 }
 
 static OptionSet<AvoidanceReason> canUseForFontAndText(const RenderBoxModelObject& container, IncludeReasons includeReasons)
@@ -483,9 +469,8 @@
     auto& fontCascade = style.fontCascade();
     if (fontCascade.primaryFont().isInterstitial())
         SET_REASON_AND_RETURN_IF_NEEDED(FlowIsMissingPrimaryFont, reasons, includeReasons);
-    std::optional<float> lineHeightConstraint;
     if (style.lineBoxContain().contains(LineBoxContain::Glyphs))
-        lineHeightConstraint = container.lineHeight(false, HorizontalLine, PositionOfInteriorLineBoxes).toFloat();
+        SET_REASON_AND_RETURN_IF_NEEDED(FlowHasLineBoxContainGlyphs, reasons, includeReasons);
     for (const auto& textRenderer : childrenOfType<RenderText>(container)) {
         // FIXME: Do not return until after checking all children.
         if (textRenderer.isCombineText())
@@ -508,7 +493,7 @@
                 SET_REASON_AND_RETURN_IF_NEEDED(FlowHasComplexFontCodePath, reasons, includeReasons);
         }
 
-        auto textReasons = canUseForText(textRenderer.stringView(), fontCascade, lineHeightConstraint, includeReasons);
+        auto textReasons = canUseForText(textRenderer.stringView(), fontCascade, includeReasons);
         if (textReasons)
             ADD_REASONS_AND_RETURN_IF_NEEDED(textReasons, reasons, includeReasons);
     }

Modified: trunk/Source/WebCore/layout/integration/LayoutIntegrationCoverage.h (281372 => 281373)


--- trunk/Source/WebCore/layout/integration/LayoutIntegrationCoverage.h	2021-08-21 13:42:48 UTC (rev 281372)
+++ trunk/Source/WebCore/layout/integration/LayoutIntegrationCoverage.h	2021-08-21 13:49:32 UTC (rev 281373)
@@ -82,7 +82,7 @@
     FlowDoesNotEstablishInlineFormattingContext  = 1LLU  << 42,
     FlowChildIsSelected                          = 1LLU  << 43,
     FlowHasHangingPunctuation                    = 1LLU  << 44,
-    FlowFontHasOverflowGlyph                     = 1LLU  << 45,
+    FlowHasLineBoxContainGlyphs                  = 1LLU  << 45,
     FlowTextHasSurrogatePair                     = 1LLU  << 46,
     MultiColumnFlowIsNotTopLevel                 = 1LLU  << 47,
     MultiColumnFlowHasColumnSpanner              = 1LLU  << 48,
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to