Faster way for simple line layout to check if text has fallback fonts
authorantti@apple.com <antti@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 25 Oct 2013 15:58:24 +0000 (15:58 +0000)
committerantti@apple.com <antti@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 25 Oct 2013 15:58:24 +0000 (15:58 +0000)
https://bugs.webkit.org/show_bug.cgi?id=123342

Reviewed by Andreas Kling.

Don't use RenderText::knownToHaveNoOverflowAndNoFallbackFonts as it is slow.

Simple text code path test already guarantees there is no overflow. Test for fallback
fonts explicitly.

* platform/graphics/SimpleFontData.h:

    Make FINAL.

* rendering/RenderText.cpp:
* rendering/RenderText.h:

    Remove knownToHaveNoOverflowAndNoFallbackFonts() as it has no clients.

* rendering/SimpleLineLayout.cpp:
(WebCore::SimpleLineLayout::canUseFor):

    Check if all characters can be found from the primary font.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@158012 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/WebCore/ChangeLog
Source/WebCore/platform/graphics/SimpleFontData.h
Source/WebCore/rendering/RenderText.cpp
Source/WebCore/rendering/RenderText.h
Source/WebCore/rendering/SimpleLineLayout.cpp

index 030c69d..fc3c22c 100644 (file)
@@ -1,3 +1,29 @@
+2013-10-25  Antti Koivisto  <antti@apple.com>
+
+        Faster way for simple line layout to check if text has fallback fonts
+        https://bugs.webkit.org/show_bug.cgi?id=123342
+
+        Reviewed by Andreas Kling.
+        
+        Don't use RenderText::knownToHaveNoOverflowAndNoFallbackFonts as it is slow.
+
+        Simple text code path test already guarantees there is no overflow. Test for fallback
+        fonts explicitly.
+
+        * platform/graphics/SimpleFontData.h:
+        
+            Make FINAL.
+
+        * rendering/RenderText.cpp:
+        * rendering/RenderText.h:
+        
+            Remove knownToHaveNoOverflowAndNoFallbackFonts() as it has no clients.
+
+        * rendering/SimpleLineLayout.cpp:
+        (WebCore::SimpleLineLayout::canUseFor):
+        
+            Check if all characters can be found from the primary font.
+
 2013-10-25  Andreas Kling  <akling@apple.com>
 
         SVGResourcesCache::clientDestroyed() should take a RenderElement&.
index 53985ec..e9a57e6 100644 (file)
@@ -65,7 +65,7 @@ struct WidthIterator;
 enum FontDataVariant { AutoVariant, NormalVariant, SmallCapsVariant, EmphasisMarkVariant, BrokenIdeographVariant };
 enum Pitch { UnknownPitch, FixedPitch, VariablePitch };
 
-class SimpleFontData : public FontData {
+class SimpleFontData FINAL : public FontData {
 public:
     class AdditionalFontData {
         WTF_MAKE_FAST_ALLOCATED;
index aeef662..e74b5a8 100644 (file)
@@ -510,14 +510,6 @@ float RenderText::maxLogicalWidth() const
     return m_maxWidth;
 }
 
-bool RenderText::knownToHaveNoOverflowAndNoFallbackFonts() const
-{
-    if (preferredLogicalWidthsDirty())
-        const_cast<RenderText*>(this)->computePreferredLogicalWidths(0);
-
-    return m_knownToHaveNoOverflowAndNoFallbackFonts;
-}
-
 void RenderText::computePreferredLogicalWidths(float leadWidth)
 {
     HashSet<const SimpleFontData*> fallbackFonts;
index aadc0d4..c156f45 100644 (file)
@@ -140,7 +140,6 @@ public:
     bool isAllCollapsibleWhitespace() const;
 
     bool canUseSimpleFontCodePath() const { return m_canUseSimpleFontCodePath; }
-    bool knownToHaveNoOverflowAndNoFallbackFonts() const;
 
     void removeAndDestroyTextBoxes();
 
index 60e2d5b..dc00ca8 100644 (file)
@@ -148,8 +148,8 @@ bool canUseFor(const RenderBlockFlow& flow)
         return false;
     if (style.font().codePath(TextRun(textRenderer.text())) != Font::Simple)
         return false;
-    if (!textRenderer.knownToHaveNoOverflowAndNoFallbackFonts())
-        return false;
+
+    auto primaryFontData = style.font().primaryFont();
 
     unsigned length = textRenderer.textLength();
     unsigned consecutiveSpaceCount = 0;
@@ -178,6 +178,8 @@ bool canUseFor(const RenderBlockFlow& flow)
                 || direction == U_LEFT_TO_RIGHT_EMBEDDING || direction == U_LEFT_TO_RIGHT_OVERRIDE)
                 return false;
         }
+        if (!primaryFontData->glyphForCharacter(character))
+            return false;
     }
     return true;
 }