Title: [281423] trunk/Source/WebCore
- Revision
- 281423
- Author
- mmaxfi...@apple.com
- Date
- 2021-08-22 16:45:54 -0700 (Sun, 22 Aug 2021)
Log Message
REGRESSION(r281389): canUseSimplifiedTextMeasuring() needs to match with WidthIterator::applyCSSVisibilityRules()
https://bugs.webkit.org/show_bug.cgi?id=229388
Reviewed by Alan Bujtas.
WidthIterator::applyCSSVisibilityRules() has some special handling for specific characters.
If those characters are present, we need to make sure we actually use WidthIterator::applyCSSVisibilityRules()
instead of taking the fast path in FontCascade::widthForSimpleText().
This is split out from https://bugs.webkit.org/show_bug.cgi?id=215643, and will be tested by that bug's test.
* layout/layouttree/LayoutTreeBuilder.cpp:
(WebCore::Layout::canUseSimplifiedTextMeasuring):
* platform/graphics/WidthIterator.cpp:
(WebCore::WidthIterator::characterCanUseSimplifiedTextMeasuring):
(WebCore::WidthIterator::applyCSSVisibilityRules):
* platform/graphics/WidthIterator.h:
* rendering/RenderText.cpp:
(WebCore::RenderText::computeCanUseSimplifiedTextMeasuring const):
Modified Paths
Diff
Modified: trunk/Source/WebCore/ChangeLog (281422 => 281423)
--- trunk/Source/WebCore/ChangeLog 2021-08-22 22:18:46 UTC (rev 281422)
+++ trunk/Source/WebCore/ChangeLog 2021-08-22 23:45:54 UTC (rev 281423)
@@ -1,3 +1,25 @@
+2021-08-22 Myles C. Maxfield <mmaxfi...@apple.com>
+
+ REGRESSION(r281389): canUseSimplifiedTextMeasuring() needs to match with WidthIterator::applyCSSVisibilityRules()
+ https://bugs.webkit.org/show_bug.cgi?id=229388
+
+ Reviewed by Alan Bujtas.
+
+ WidthIterator::applyCSSVisibilityRules() has some special handling for specific characters.
+ If those characters are present, we need to make sure we actually use WidthIterator::applyCSSVisibilityRules()
+ instead of taking the fast path in FontCascade::widthForSimpleText().
+
+ This is split out from https://bugs.webkit.org/show_bug.cgi?id=215643, and will be tested by that bug's test.
+
+ * layout/layouttree/LayoutTreeBuilder.cpp:
+ (WebCore::Layout::canUseSimplifiedTextMeasuring):
+ * platform/graphics/WidthIterator.cpp:
+ (WebCore::WidthIterator::characterCanUseSimplifiedTextMeasuring):
+ (WebCore::WidthIterator::applyCSSVisibilityRules):
+ * platform/graphics/WidthIterator.h:
+ * rendering/RenderText.cpp:
+ (WebCore::RenderText::computeCanUseSimplifiedTextMeasuring const):
+
2021-08-22 Alan Bujtas <za...@apple.com>
[LFC][IFC] Add support for vertical-align: sub
Modified: trunk/Source/WebCore/layout/layouttree/LayoutTreeBuilder.cpp (281422 => 281423)
--- trunk/Source/WebCore/layout/layouttree/LayoutTreeBuilder.cpp 2021-08-22 22:18:46 UTC (rev 281422)
+++ trunk/Source/WebCore/layout/layouttree/LayoutTreeBuilder.cpp 2021-08-22 23:45:54 UTC (rev 281423)
@@ -61,6 +61,7 @@
#include "RenderTableCaption.h"
#include "RenderTableCell.h"
#include "RenderView.h"
+#include "WidthIterator.h"
#include <wtf/IsoMallocInlines.h>
#include <wtf/text/TextStream.h>
@@ -106,7 +107,7 @@
return false;
for (unsigned i = 0; i < content.length(); ++i) {
- if ((!whitespaceIsCollapsed && content[i] == '\t') || content[i] == noBreakSpace || content[i] == softHyphen || content[i] >= HiraganaLetterSmallA)
+ if (!WidthIterator::characterCanUseSimplifiedTextMeasuring(content[i], whitespaceIsCollapsed))
return false;
}
return true;
Modified: trunk/Source/WebCore/platform/graphics/WidthIterator.cpp (281422 => 281423)
--- trunk/Source/WebCore/platform/graphics/WidthIterator.cpp 2021-08-22 22:18:46 UTC (rev 281422)
+++ trunk/Source/WebCore/platform/graphics/WidthIterator.cpp 2021-08-22 23:45:54 UTC (rev 281423)
@@ -515,8 +515,51 @@
}
}
+bool WidthIterator::characterCanUseSimplifiedTextMeasuring(UChar character, bool whitespaceIsCollapsed)
+{
+ // This function needs to be kept in sync with applyCSSVisibilityRules().
+
+ switch (character) {
+ case tabCharacter:
+ if (!whitespaceIsCollapsed)
+ return false;
+ break;
+ case noBreakSpace:
+ case softHyphen:
+ case newlineCharacter:
+ case carriageReturn:
+ case leftToRightMark:
+ case rightToLeftMark:
+ case leftToRightEmbed:
+ case rightToLeftEmbed:
+ case leftToRightOverride:
+ case rightToLeftOverride:
+ case leftToRightIsolate:
+ case rightToLeftIsolate:
+ case zeroWidthNonJoiner:
+ case zeroWidthJoiner:
+ case popDirectionalFormatting:
+ case popDirectionalIsolate:
+ case firstStrongIsolate:
+ case objectReplacementCharacter:
+ case zeroWidthNoBreakSpace:
+ return false;
+ break;
+ }
+
+ if (character >= HiraganaLetterSmallA
+ || u_charType(character) == U_CONTROL_CHAR
+ || (character >= nullCharacter && character < space)
+ || (character >= deleteCharacter && character < noBreakSpace))
+ return false;
+
+ return true;
+}
+
void WidthIterator::applyCSSVisibilityRules(GlyphBuffer& glyphBuffer, unsigned glyphBufferStartIndex)
{
+ // This function needs to be kept in sync with characterCanUseSimplifiedTextMeasuring().
+
Vector<unsigned> glyphsIndicesToBeDeleted;
float yPosition = height(glyphBuffer.initialAdvance());
Modified: trunk/Source/WebCore/platform/graphics/WidthIterator.h (281422 => 281423)
--- trunk/Source/WebCore/platform/graphics/WidthIterator.h 2021-08-22 22:18:46 UTC (rev 281422)
+++ trunk/Source/WebCore/platform/graphics/WidthIterator.h 2021-08-22 23:45:54 UTC (rev 281423)
@@ -56,6 +56,8 @@
float runWidthSoFar() const { return m_runWidthSoFar; }
unsigned currentCharacterIndex() const { return m_currentCharacterIndex; }
+ static bool characterCanUseSimplifiedTextMeasuring(UChar, bool whitespaceIsCollapsed);
+
private:
GlyphData glyphDataForCharacter(UChar32, bool mirror);
template <typename TextIterator>
Modified: trunk/Source/WebCore/rendering/RenderText.cpp (281422 => 281423)
--- trunk/Source/WebCore/rendering/RenderText.cpp 2021-08-22 22:18:46 UTC (rev 281422)
+++ trunk/Source/WebCore/rendering/RenderText.cpp 2021-08-22 23:45:54 UTC (rev 281423)
@@ -52,6 +52,7 @@
#include "Text.h"
#include "TextResourceDecoder.h"
#include "VisiblePosition.h"
+#include "WidthIterator.h"
#include <wtf/IsoMallocInlines.h>
#include <wtf/NeverDestroyed.h>
#include <wtf/text/StringBuilder.h>
@@ -1433,7 +1434,7 @@
auto whitespaceIsCollapsed = style().collapseWhiteSpace();
for (unsigned i = 0; i < text().length(); ++i) {
- if ((!whitespaceIsCollapsed && text()[i] == '\t') || text()[i] == noBreakSpace || text()[i] == softHyphen || text()[i] >= HiraganaLetterSmallA)
+ if (!WidthIterator::characterCanUseSimplifiedTextMeasuring(text()[i], whitespaceIsCollapsed))
return false;
}
return true;
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes