Font::primaryFontData() should return a reference
authorantti@apple.com <antti@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 6 Jan 2015 11:23:58 +0000 (11:23 +0000)
committerantti@apple.com <antti@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 6 Jan 2015 11:23:58 +0000 (11:23 +0000)
https://bugs.webkit.org/show_bug.cgi?id=140081

Reviewed by Darin Adler.

It is not null.

Also rename primaryFont() -> primaryFontData().

* accessibility/ios/WebAccessibilityObjectWrapperIOS.mm:
(AXAttributeStringSetStyle):
* accessibility/mac/WebAccessibilityObjectWrapperMac.mm:
(AXAttributeStringSetStyle):
* bindings/objc/DOM.mm:
(-[DOMElement _font]):
* editing/cocoa/HTMLConverter.mm:
(_font):
(WebCore::editingAttributedStringFromRange):
* editing/ios/EditorIOS.mm:
(WebCore::Editor::fontForSelection):
(WebCore::Editor::fontAttributesForSelectionStart):
* editing/mac/EditorMac.mm:
(WebCore::Editor::fontForSelection):
(WebCore::Editor::fontAttributesForSelectionStart):
* platform/graphics/Font.cpp:
(WebCore::Font::fastAverageCharWidthIfAvailable):
* platform/graphics/Font.h:
(WebCore::Font::fontMetrics):
(WebCore::Font::spaceWidth):
(WebCore::Font::tabWidth):
(WebCore::Font::primaryFontData):
(WebCore::Font::primaryFont): Deleted.
* platform/graphics/FontFastPath.cpp:
(WebCore::Font::primaryFontHasGlyphForCharacter):
* platform/graphics/FontGlyphs.cpp:
(WebCore::FontGlyphs::determinePitch):
(WebCore::FontGlyphs::glyphDataForSystemFallback):
(WebCore::FontGlyphs::glyphDataForCharacter):
* platform/graphics/FontGlyphs.h:
(WebCore::FontGlyphs::primaryFontData):
(WebCore::FontGlyphs::primarySimpleFontData):
* platform/graphics/WidthIterator.cpp:
(WebCore::WidthIterator::advanceInternal):
* platform/graphics/mac/ComplexTextController.cpp:
(WebCore::ComplexTextController::advance):
(WebCore::ComplexTextController::adjustGlyphsAndAdvances):
* platform/graphics/mac/ComplexTextController.h:
(WebCore::ComplexTextController::ComplexTextRun::create):
(WebCore::ComplexTextController::ComplexTextRun::fontData):
* platform/graphics/mac/ComplexTextControllerCoreText.mm:
(WebCore::ComplexTextController::ComplexTextRun::ComplexTextRun):
(WebCore::ComplexTextController::collectComplexTextRunsForCharacters):
* platform/graphics/mac/FontMac.mm:
(WebCore::Font::primaryFontDataIsSystemFont):
* platform/graphics/opentype/OpenTypeMathData.cpp:
* platform/graphics/opentype/OpenTypeMathData.h:
* rendering/InlineFlowBox.cpp:
(WebCore::InlineFlowBox::requiresIdeographicBaseline):
* rendering/InlineTextBox.cpp:
(WebCore::InlineTextBox::constructTextRun):
* rendering/RenderBlock.cpp:
(WebCore::RenderBlock::adjustLogicalLeftOffsetForLine):
(WebCore::RenderBlock::adjustLogicalRightOffsetForLine):
(WebCore::constructTextRunInternal):
* rendering/RenderTextControlSingleLine.cpp:
(WebCore::RenderTextControlSingleLine::preferredContentLogicalWidth):
* rendering/RenderThemeIOS.mm:
(WebCore::adjustInputElementButtonStyle):
* rendering/RootInlineBox.cpp:
(WebCore::RootInlineBox::ascentAndDescentForBox):
* rendering/SimpleLineLayout.cpp:
(WebCore::SimpleLineLayout::canUseFor):
* rendering/mathml/RenderMathMLOperator.cpp:
(WebCore::RenderMathMLOperator::getGlyphAssemblyFallBack):
(WebCore::RenderMathMLOperator::getDisplayStyleLargeOperator):
(WebCore::RenderMathMLOperator::findStretchyData):
(WebCore::RenderMathMLOperator::trailingSpaceError):
* rendering/mathml/RenderMathMLRadicalOperator.cpp:
(WebCore::RenderMathMLRadicalOperator::stretchTo):
(WebCore::RenderMathMLRadicalOperator::computePreferredLogicalWidths):
(WebCore::RenderMathMLRadicalOperator::computeLogicalHeight):
(WebCore::RenderMathMLRadicalOperator::paint):
* rendering/mathml/RenderMathMLRoot.cpp:
(WebCore::RenderMathMLRoot::updateStyle):
* rendering/svg/SVGInlineTextBox.cpp:
(WebCore::SVGInlineTextBox::constructTextRun):
* rendering/svg/SVGTextLayoutEngineSpacing.cpp:
(WebCore::SVGTextLayoutEngineSpacing::calculateSVGKerning):
* rendering/svg/SVGTextMetrics.cpp:
(WebCore::SVGTextMetrics::constructTextRun):
(WebCore::SVGTextMetrics::SVGTextMetrics):
* rendering/svg/SVGTextRunRenderingContext.cpp:
(WebCore::missingGlyphForFont):
(WebCore::SVGTextRunRenderingContext::glyphDataForCharacter):

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

38 files changed:
Source/WebCore/ChangeLog
Source/WebCore/accessibility/ios/WebAccessibilityObjectWrapperIOS.mm
Source/WebCore/accessibility/mac/WebAccessibilityObjectWrapperMac.mm
Source/WebCore/bindings/objc/DOM.mm
Source/WebCore/editing/cocoa/HTMLConverter.mm
Source/WebCore/editing/ios/EditorIOS.mm
Source/WebCore/editing/mac/EditorMac.mm
Source/WebCore/platform/graphics/Font.cpp
Source/WebCore/platform/graphics/Font.h
Source/WebCore/platform/graphics/FontFastPath.cpp
Source/WebCore/platform/graphics/FontGlyphs.cpp
Source/WebCore/platform/graphics/FontGlyphs.h
Source/WebCore/platform/graphics/WidthIterator.cpp
Source/WebCore/platform/graphics/mac/ComplexTextController.cpp
Source/WebCore/platform/graphics/mac/ComplexTextController.h
Source/WebCore/platform/graphics/mac/ComplexTextControllerCoreText.mm
Source/WebCore/platform/graphics/mac/FontMac.mm
Source/WebCore/platform/graphics/opentype/OpenTypeMathData.cpp
Source/WebCore/platform/graphics/opentype/OpenTypeMathData.h
Source/WebCore/platform/graphics/win/UniscribeController.cpp
Source/WebCore/rendering/InlineFlowBox.cpp
Source/WebCore/rendering/InlineTextBox.cpp
Source/WebCore/rendering/RenderBlock.cpp
Source/WebCore/rendering/RenderTextControlSingleLine.cpp
Source/WebCore/rendering/RenderThemeIOS.mm
Source/WebCore/rendering/RootInlineBox.cpp
Source/WebCore/rendering/SimpleLineLayout.cpp
Source/WebCore/rendering/mathml/RenderMathMLOperator.cpp
Source/WebCore/rendering/mathml/RenderMathMLRadicalOperator.cpp
Source/WebCore/rendering/mathml/RenderMathMLRoot.cpp
Source/WebCore/rendering/style/RenderStyle.cpp
Source/WebCore/rendering/svg/SVGInlineTextBox.cpp
Source/WebCore/rendering/svg/SVGTextLayoutEngineSpacing.cpp
Source/WebCore/rendering/svg/SVGTextMetrics.cpp
Source/WebCore/rendering/svg/SVGTextRunRenderingContext.cpp
Source/WebKit/mac/WebCoreSupport/PopupMenuMac.mm
Source/WebKit2/WebProcess/WebCoreSupport/mac/WebPopupMenuMac.mm
Source/WebKit2/WebProcess/WebPage/WebPage.cpp

index f2134f0..e2a2752 100644 (file)
@@ -1,3 +1,100 @@
+2015-01-05  Antti Koivisto  <antti@apple.com>
+
+        Font::primaryFontData() should return a reference
+        https://bugs.webkit.org/show_bug.cgi?id=140081
+
+        Reviewed by Darin Adler.
+
+        It is not null.
+
+        Also rename primaryFont() -> primaryFontData().
+
+        * accessibility/ios/WebAccessibilityObjectWrapperIOS.mm:
+        (AXAttributeStringSetStyle):
+        * accessibility/mac/WebAccessibilityObjectWrapperMac.mm:
+        (AXAttributeStringSetStyle):
+        * bindings/objc/DOM.mm:
+        (-[DOMElement _font]):
+        * editing/cocoa/HTMLConverter.mm:
+        (_font):
+        (WebCore::editingAttributedStringFromRange):
+        * editing/ios/EditorIOS.mm:
+        (WebCore::Editor::fontForSelection):
+        (WebCore::Editor::fontAttributesForSelectionStart):
+        * editing/mac/EditorMac.mm:
+        (WebCore::Editor::fontForSelection):
+        (WebCore::Editor::fontAttributesForSelectionStart):
+        * platform/graphics/Font.cpp:
+        (WebCore::Font::fastAverageCharWidthIfAvailable):
+        * platform/graphics/Font.h:
+        (WebCore::Font::fontMetrics):
+        (WebCore::Font::spaceWidth):
+        (WebCore::Font::tabWidth):
+        (WebCore::Font::primaryFontData):
+        (WebCore::Font::primaryFont): Deleted.
+        * platform/graphics/FontFastPath.cpp:
+        (WebCore::Font::primaryFontHasGlyphForCharacter):
+        * platform/graphics/FontGlyphs.cpp:
+        (WebCore::FontGlyphs::determinePitch):
+        (WebCore::FontGlyphs::glyphDataForSystemFallback):
+        (WebCore::FontGlyphs::glyphDataForCharacter):
+        * platform/graphics/FontGlyphs.h:
+        (WebCore::FontGlyphs::primaryFontData):
+        (WebCore::FontGlyphs::primarySimpleFontData):
+        * platform/graphics/WidthIterator.cpp:
+        (WebCore::WidthIterator::advanceInternal):
+        * platform/graphics/mac/ComplexTextController.cpp:
+        (WebCore::ComplexTextController::advance):
+        (WebCore::ComplexTextController::adjustGlyphsAndAdvances):
+        * platform/graphics/mac/ComplexTextController.h:
+        (WebCore::ComplexTextController::ComplexTextRun::create):
+        (WebCore::ComplexTextController::ComplexTextRun::fontData):
+        * platform/graphics/mac/ComplexTextControllerCoreText.mm:
+        (WebCore::ComplexTextController::ComplexTextRun::ComplexTextRun):
+        (WebCore::ComplexTextController::collectComplexTextRunsForCharacters):
+        * platform/graphics/mac/FontMac.mm:
+        (WebCore::Font::primaryFontDataIsSystemFont):
+        * platform/graphics/opentype/OpenTypeMathData.cpp:
+        * platform/graphics/opentype/OpenTypeMathData.h:
+        * rendering/InlineFlowBox.cpp:
+        (WebCore::InlineFlowBox::requiresIdeographicBaseline):
+        * rendering/InlineTextBox.cpp:
+        (WebCore::InlineTextBox::constructTextRun):
+        * rendering/RenderBlock.cpp:
+        (WebCore::RenderBlock::adjustLogicalLeftOffsetForLine):
+        (WebCore::RenderBlock::adjustLogicalRightOffsetForLine):
+        (WebCore::constructTextRunInternal):
+        * rendering/RenderTextControlSingleLine.cpp:
+        (WebCore::RenderTextControlSingleLine::preferredContentLogicalWidth):
+        * rendering/RenderThemeIOS.mm:
+        (WebCore::adjustInputElementButtonStyle):
+        * rendering/RootInlineBox.cpp:
+        (WebCore::RootInlineBox::ascentAndDescentForBox):
+        * rendering/SimpleLineLayout.cpp:
+        (WebCore::SimpleLineLayout::canUseFor):
+        * rendering/mathml/RenderMathMLOperator.cpp:
+        (WebCore::RenderMathMLOperator::getGlyphAssemblyFallBack):
+        (WebCore::RenderMathMLOperator::getDisplayStyleLargeOperator):
+        (WebCore::RenderMathMLOperator::findStretchyData):
+        (WebCore::RenderMathMLOperator::trailingSpaceError):
+        * rendering/mathml/RenderMathMLRadicalOperator.cpp:
+        (WebCore::RenderMathMLRadicalOperator::stretchTo):
+        (WebCore::RenderMathMLRadicalOperator::computePreferredLogicalWidths):
+        (WebCore::RenderMathMLRadicalOperator::computeLogicalHeight):
+        (WebCore::RenderMathMLRadicalOperator::paint):
+        * rendering/mathml/RenderMathMLRoot.cpp:
+        (WebCore::RenderMathMLRoot::updateStyle):
+        * rendering/svg/SVGInlineTextBox.cpp:
+        (WebCore::SVGInlineTextBox::constructTextRun):
+        * rendering/svg/SVGTextLayoutEngineSpacing.cpp:
+        (WebCore::SVGTextLayoutEngineSpacing::calculateSVGKerning):
+        * rendering/svg/SVGTextMetrics.cpp:
+        (WebCore::SVGTextMetrics::constructTextRun):
+        (WebCore::SVGTextMetrics::SVGTextMetrics):
+        * rendering/svg/SVGTextRunRenderingContext.cpp:
+        (WebCore::missingGlyphForFont):
+        (WebCore::SVGTextRunRenderingContext::glyphDataForCharacter):
+
 2015-01-06  Shivakumar JM  <shiva.jm@samsung.com>
 
         Fix Unused parameter warning in Webcore bindings.
index dd48dcc..b2f379d 100644 (file)
@@ -1758,7 +1758,7 @@ static void AXAttributeStringSetStyle(NSMutableAttributedString* attrString, Ren
     RenderStyle& style = renderer->style();
     
     // set basic font info
-    AXAttributeStringSetFont(attrString, style.font().primaryFont()->getCTFont(), range);
+    AXAttributeStringSetFont(attrString, style.font().primaryFontData().getCTFont(), range);
                 
     int decor = style.textDecorationsInEffect();
     if ((decor & (TextDecorationUnderline | TextDecorationLineThrough)) != 0) {
index cd74bc2..0999c92 100644 (file)
@@ -848,7 +848,7 @@ static void AXAttributeStringSetStyle(NSMutableAttributedString* attrString, Ren
     const RenderStyle& style = renderer->style();
     
     // set basic font info
-    AXAttributeStringSetFont(attrString, NSAccessibilityFontTextAttribute, style.font().primaryFont()->getNSFont(), range);
+    AXAttributeStringSetFont(attrString, NSAccessibilityFontTextAttribute, style.font().primaryFontData().getNSFont(), range);
     
     // set basic colors
     AXAttributeStringSetColor(attrString, NSAccessibilityForegroundColorTextAttribute, nsColor(style.visitedDependentColor(CSSPropertyColor)), range);
index 65866ed..50e285b 100644 (file)
@@ -669,7 +669,7 @@ id <DOMEventTarget> kit(WebCore::EventTarget* eventTarget)
     auto renderer = core(self)->renderer();
     if (!renderer)
         return nil;
-    return renderer->style().font().primaryFont()->getNSFont();
+    return renderer->style().font().primaryFontData().getNSFont();
 }
 #else
 - (CTFontRef)_font
@@ -677,7 +677,7 @@ id <DOMEventTarget> kit(WebCore::EventTarget* eventTarget)
     RenderObject* renderer = core(self)->renderer();
     if (!renderer)
         return nil;
-    return renderer->style().font().primaryFont()->getCTFont();
+    return renderer->style().font().primaryFontData().getCTFont();
 }
 #endif
 
index 6893924..c96ca89 100644 (file)
@@ -1114,7 +1114,7 @@ static PlatformFont *_font(Element& element)
     auto renderer = element.renderer();
     if (!renderer)
         return nil;
-    return renderer->style().font().primaryFont()->getNSFont();
+    return renderer->style().font().primaryFontData().getNSFont();
 }
 #else
 static PlatformFont *_font(Element& element)
@@ -1122,7 +1122,7 @@ static PlatformFont *_font(Element& element)
     auto renderer = element.renderer();
     if (!renderer)
         return nil;
-    return (PlatformFont *)renderer->style().font().primaryFont()->getCTFont();
+    return (PlatformFont *)renderer->style().font().primaryFontData().getCTFont();
 }
 #endif
 
@@ -2594,10 +2594,10 @@ NSAttributedString *editingAttributedStringFromRange(Range& range, IncludeImages
             [attrs.get() setObject:[NSNumber numberWithInteger:NSUnderlineStyleSingle] forKey:NSUnderlineStyleAttributeName];
         if (style.textDecorationsInEffect() & TextDecorationLineThrough)
             [attrs.get() setObject:[NSNumber numberWithInteger:NSUnderlineStyleSingle] forKey:NSStrikethroughStyleAttributeName];
-        if (NSFont *font = style.font().primaryFont()->getNSFont())
+        if (NSFont *font = style.font().primaryFontData().getNSFont())
             [attrs.get() setObject:font forKey:NSFontAttributeName];
         else
-            [attrs.get() setObject:[fontManager convertFont:WebDefaultFont() toSize:style.font().primaryFont()->platformData().size()] forKey:NSFontAttributeName];
+            [attrs.get() setObject:[fontManager convertFont:WebDefaultFont() toSize:style.font().primaryFontData().platformData().size()] forKey:NSFontAttributeName];
         if (style.visitedDependentColor(CSSPropertyColor).alpha())
             [attrs.get() setObject:nsColor(style.visitedDependentColor(CSSPropertyColor)) forKey:NSForegroundColorAttributeName];
         else
index b9eb96c..3be9699 100644 (file)
@@ -211,9 +211,9 @@ const SimpleFontData* Editor::fontForSelection(bool& hasMultipleFonts) const
         Node* nodeToRemove;
         RenderStyle* style = styleForSelectionStart(&m_frame, nodeToRemove); // sets nodeToRemove
 
-        const SimpleFontData* result = 0;
+        const SimpleFontData* result = nullptr;
         if (style)
-            result = style->font().primaryFont();
+            result = &style->font().primaryFontData();
 
         if (nodeToRemove) {
             ExceptionCode ec;
@@ -235,10 +235,10 @@ const SimpleFontData* Editor::fontForSelection(bool& hasMultipleFonts) const
             if (!renderer)
                 continue;
             // FIXME: Are there any node types that have renderers, but that we should be skipping?
-            const SimpleFontData* primaryFont = renderer->style().font().primaryFont();
+            const SimpleFontData& primaryFont = renderer->style().font().primaryFontData();
             if (!font)
-                font = primaryFont;
-            else if (font != primaryFont) {
+                font = &primaryFont;
+            else if (font != &primaryFont) {
                 hasMultipleFonts = true;
                 break;
             }
@@ -257,7 +257,7 @@ NSDictionary* Editor::fontAttributesForSelectionStart() const
 
     NSMutableDictionary* result = [NSMutableDictionary dictionary];
     
-    CTFontRef font = style->font().primaryFont()->getCTFont();
+    CTFontRef font = style->font().primaryFontData().getCTFont();
     if (font)
         [result setObject:(id)font forKey:NSFontAttributeName];
 
index 29276fa..1303281 100644 (file)
@@ -113,9 +113,9 @@ const SimpleFontData* Editor::fontForSelection(bool& hasMultipleFonts) const
         Node* nodeToRemove;
         RenderStyle* style = styleForSelectionStart(&m_frame, nodeToRemove); // sets nodeToRemove
 
-        const SimpleFontData* result = 0;
+        const SimpleFontData* result = nullptr;
         if (style)
-            result = style->font().primaryFont();
+            result = &style->font().primaryFontData();
 
         if (nodeToRemove)
             nodeToRemove->remove(ASSERT_NO_EXCEPTION);
@@ -135,10 +135,10 @@ const SimpleFontData* Editor::fontForSelection(bool& hasMultipleFonts) const
             if (!renderer)
                 continue;
             // FIXME: Are there any node types that have renderers, but that we should be skipping?
-            const SimpleFontData* primaryFont = renderer->style().font().primaryFont();
+            const SimpleFontData& primaryFont = renderer->style().font().primaryFontData();
             if (!font)
-                font = primaryFont;
-            else if (font != primaryFont) {
+                font = &primaryFont;
+            else if (font != &primaryFont) {
                 hasMultipleFonts = true;
                 break;
             }
@@ -160,8 +160,8 @@ NSDictionary* Editor::fontAttributesForSelectionStart() const
     if (style->visitedDependentColor(CSSPropertyBackgroundColor).isValid() && style->visitedDependentColor(CSSPropertyBackgroundColor).alpha() != 0)
         [result setObject:nsColor(style->visitedDependentColor(CSSPropertyBackgroundColor)) forKey:NSBackgroundColorAttributeName];
 
-    if (style->font().primaryFont()->getNSFont())
-        [result setObject:style->font().primaryFont()->getNSFont() forKey:NSFontAttributeName];
+    if (style->font().primaryFontData().getNSFont())
+        [result setObject:style->font().primaryFontData().getNSFont() forKey:NSFontAttributeName];
 
     if (style->visitedDependentColor(CSSPropertyColor).isValid() && style->visitedDependentColor(CSSPropertyColor) != Color::black)
         [result setObject:nsColor(style->visitedDependentColor(CSSPropertyColor)) forKey:NSForegroundColorAttributeName];
index 890b68e..a49b7dc 100644 (file)
@@ -506,7 +506,7 @@ bool Font::fastAverageCharWidthIfAvailable(float& width) const
 {
     bool success = hasValidAverageCharWidth();
     if (success)
-        width = roundf(primaryFont()->avgCharWidth()); // FIXME: primaryFont() might not correspond to firstFamily().
+        width = roundf(primaryFontData().avgCharWidth()); // FIXME: primaryFontData() might not correspond to firstFamily().
     return success;
 }
 
index 2f53354..8ace9cc 100644 (file)
@@ -172,10 +172,10 @@ public:
 
     bool isPlatformFont() const { return m_glyphs->isForPlatformFont(); }
 
-    const FontMetrics& fontMetrics() const { return primaryFont()->fontMetrics(); }
-    float spaceWidth() const { return primaryFont()->spaceWidth() + m_letterSpacing; }
+    const FontMetrics& fontMetrics() const { return primaryFontData().fontMetrics(); }
+    float spaceWidth() const { return primaryFontData().spaceWidth() + m_letterSpacing; }
     float tabWidth(const SimpleFontData&, unsigned tabSize, float position) const;
-    float tabWidth(unsigned tabSize, float position) const { return tabWidth(*primaryFont(), tabSize, position); }
+    float tabWidth(unsigned tabSize, float position) const { return tabWidth(primaryFontData(), tabSize, position); }
     bool hasValidAverageCharWidth() const;
     bool fastAverageCharWidthIfAvailable(float &width) const; // returns true on success
 
@@ -183,7 +183,7 @@ public:
     int emphasisMarkDescent(const AtomicString&) const;
     int emphasisMarkHeight(const AtomicString&) const;
 
-    const SimpleFontData* primaryFont() const;
+    const SimpleFontData& primaryFontData() const;
     const FontData* fontDataAt(unsigned) const;
     GlyphData glyphDataForCharacter(UChar32 c, bool mirror, FontDataVariant variant = AutoVariant) const
     {
@@ -192,7 +192,6 @@ public:
 #if PLATFORM(COCOA)
     const SimpleFontData* fontDataForCombiningCharacterSequence(const UChar*, size_t length, FontDataVariant) const;
 #endif
-    bool primaryFontHasGlyphForCharacter(UChar32) const;
 
     static bool isCJKIdeograph(UChar32);
     static bool isCJKIdeographOrSymbol(UChar32);
@@ -357,7 +356,7 @@ inline Font::~Font()
 {
 }
 
-inline const SimpleFontData* Font::primaryFont() const
+inline const SimpleFontData& Font::primaryFontData() const
 {
     ASSERT(m_glyphs);
     return m_glyphs->primarySimpleFontData(m_fontDescription);
index 7e2c706..0ec6e83 100644 (file)
@@ -40,11 +40,6 @@ using namespace Unicode;
 
 namespace WebCore {
 
-bool Font::primaryFontHasGlyphForCharacter(UChar32 character) const
-{
-    return primaryFont()->glyphForCharacter(character);
-}
-
 // FIXME: This function may not work if the emphasis mark uses a complex script, but none of the
 // standard emphasis marks do so.
 bool Font::getEmphasisMarkGlyphData(const AtomicString& mark, GlyphData& glyphData) const
index 9884869..62d7d9c 100644 (file)
@@ -75,11 +75,11 @@ void FontGlyphs::releaseFontData()
 
 void FontGlyphs::determinePitch(const FontDescription& description)
 {
-    const FontData* fontData = primaryFontData(description);
-    if (is<SimpleFontData>(*fontData))
-        m_pitch = downcast<SimpleFontData>(*fontData).pitch();
+    const FontData& fontData = *realizeFontDataAt(description, 0);
+    if (is<SimpleFontData>(fontData))
+        m_pitch = downcast<SimpleFontData>(fontData).pitch();
     else {
-        const SegmentedFontData& segmentedFontData = downcast<SegmentedFontData>(*fontData);
+        const SegmentedFontData& segmentedFontData = downcast<SegmentedFontData>(fontData);
         unsigned numRanges = segmentedFontData.numRanges();
         if (numRanges == 1)
             m_pitch = segmentedFontData.rangeAt(0).fontData()->pitch();
@@ -245,9 +245,10 @@ static GlyphData glyphDataForNonCJKCharacterWithGlyphOrientation(UChar32 charact
 GlyphData FontGlyphs::glyphDataForSystemFallback(UChar32 c, const FontDescription& description, FontDataVariant variant)
 {
     // System fallback is character-dependent.
-    auto* originalFontData = primaryFontData(description)->simpleFontDataForCharacter(c);
+    auto& primaryFontData = *realizeFontDataAt(description, 0);
+    auto* originalFontData = primaryFontData.simpleFontDataForCharacter(c);
     if (!originalFontData)
-        originalFontData = &primaryFontData(description)->simpleFontDataForFirstRange();
+        originalFontData = &primaryFontData.simpleFontDataForFirstRange();
 
     RefPtr<SimpleFontData> systemFallbackFontData = originalFontData->systemFallbackFontDataForCharacter(c, description, m_isForPlatformFont);
     if (!systemFallbackFontData)
@@ -364,7 +365,7 @@ GlyphData FontGlyphs::glyphDataForCharacter(const FontDescription& description,
     ASSERT(isMainThread());
 
     if (variant == AutoVariant) {
-        if (description.smallCaps() && !primarySimpleFontData(description)->isSVGFont()) {
+        if (description.smallCaps() && !primarySimpleFontData(description).isSVGFont()) {
             UChar32 upperC = u_toupper(c);
             if (upperC != c) {
                 c = upperC;
@@ -385,7 +386,7 @@ GlyphData FontGlyphs::glyphDataForCharacter(const FontDescription& description,
 
     RefPtr<GlyphPage>& cachedPage = pageNumber ? m_cachedPages.add(pageNumber, nullptr).iterator->value : m_cachedPageZero;
     if (!cachedPage)
-        cachedPage = glyphPageFromFontData(pageNumber, *primaryFontData(description));
+        cachedPage = glyphPageFromFontData(pageNumber, *realizeFontDataAt(description, 0));
 
     GlyphData glyphData = cachedPage ? cachedPage->glyphDataForCharacter(c) : GlyphData();
     if (!glyphData.glyph) {
index 206b173..d463350 100644 (file)
@@ -67,8 +67,7 @@ public:
     WidthCache& widthCache() { return m_widthCache; }
     const WidthCache& widthCache() const { return m_widthCache; }
 
-    const SimpleFontData* primarySimpleFontData(const FontDescription&);
-    const FontData* primaryFontData(const FontDescription& description) { return realizeFontDataAt(description, 0); }
+    const SimpleFontData& primarySimpleFontData(const FontDescription&);
     WEBCORE_EXPORT const FontData* realizeFontDataAt(const FontDescription&, unsigned index);
 
 private:
@@ -106,16 +105,16 @@ inline bool FontGlyphs::isFixedPitch(const FontDescription& description)
     return m_pitch == FixedPitch;
 };
 
-inline const SimpleFontData* FontGlyphs::primarySimpleFontData(const FontDescription& description)
+inline const SimpleFontData& FontGlyphs::primarySimpleFontData(const FontDescription& description)
 {
     ASSERT(isMainThread());
     if (!m_cachedPrimarySimpleFontData) {
-        auto* fontData = primaryFontData(description);
-        m_cachedPrimarySimpleFontData = fontData->simpleFontDataForCharacter(' ');
+        auto& fontData = *realizeFontDataAt(description, 0);
+        m_cachedPrimarySimpleFontData = fontData.simpleFontDataForCharacter(' ');
         if (!m_cachedPrimarySimpleFontData)
-            m_cachedPrimarySimpleFontData = &fontData->simpleFontDataForFirstRange();
+            m_cachedPrimarySimpleFontData = &fontData.simpleFontDataForFirstRange();
     }
-    return m_cachedPrimarySimpleFontData;
+    return *m_cachedPrimarySimpleFontData;
 }
 
 }
index 2028e03..535799c 100644 (file)
@@ -166,8 +166,8 @@ inline unsigned WidthIterator::advanceInternal(TextIterator& textIterator, Glyph
     float lastRoundingWidth = m_finalRoundingWidth;
     FloatRect bounds;
 
-    const SimpleFontData* primaryFont = m_font->primaryFont();
-    const SimpleFontData* lastFontData = primaryFont;
+    const SimpleFontData& primaryFontData = m_font->primaryFontData();
+    const SimpleFontData* lastFontData = &primaryFontData;
     int lastGlyphCount = glyphBuffer ? glyphBuffer->size() : 0;
 
     UChar32 character = 0;
@@ -211,14 +211,14 @@ inline unsigned WidthIterator::advanceInternal(TextIterator& textIterator, Glyph
             }
 
             lastFontData = fontData;
-            if (m_fallbackFonts && fontData != primaryFont) {
+            if (m_fallbackFonts && fontData != &primaryFontData) {
                 // FIXME: This does a little extra work that could be avoided if
                 // glyphDataForCharacter() returned whether it chose to use a small caps font.
                 if (!m_font->isSmallCaps() || character == u_toupper(character))
                     m_fallbackFonts->add(fontData);
                 else {
                     const GlyphData& uppercaseGlyphData = m_font->glyphDataForCharacter(u_toupper(character), rtl);
-                    if (uppercaseGlyphData.fontData != primaryFont)
+                    if (uppercaseGlyphData.fontData != &primaryFontData)
                         m_fallbackFonts->add(uppercaseGlyphData.fontData);
                 }
             }
index 5ebd43e..4fa5e64 100644 (file)
@@ -494,8 +494,8 @@ void ComplexTextController::advance(unsigned offset, GlyphBuffer* glyphBuffer, G
         size_t glyphCount = complexTextRun.glyphCount();
         unsigned g = ltr ? m_glyphInCurrentRun : glyphCount - 1 - m_glyphInCurrentRun;
         unsigned k = leftmostGlyph + g;
-        if (fallbackFonts && complexTextRun.fontData() != m_font.primaryFont())
-            fallbackFonts->add(complexTextRun.fontData());
+        if (fallbackFonts && &complexTextRun.fontData() != &m_font.primaryFontData())
+            fallbackFonts->add(&complexTextRun.fontData());
 
         // We must store the initial advance for the first glyph we are going to draw.
         // When leftmostGlyph is 0, it represents the first glyph to draw, taking into
@@ -520,7 +520,7 @@ void ComplexTextController::advance(unsigned offset, GlyphBuffer* glyphBuffer, G
                 return;
 
             if (glyphBuffer && !m_characterInCurrentGlyph)
-                glyphBuffer->add(m_adjustedGlyphs[k], complexTextRun.fontData(), adjustedAdvance, complexTextRun.indexAt(m_glyphInCurrentRun));
+                glyphBuffer->add(m_adjustedGlyphs[k], &complexTextRun.fontData(), adjustedAdvance, complexTextRun.indexAt(m_glyphInCurrentRun));
 
             unsigned oldCharacterInCurrentGlyph = m_characterInCurrentGlyph;
             m_characterInCurrentGlyph = std::min(m_currentCharacter - complexTextRun.stringLocation(), glyphEndOffset) - glyphStartOffset;
@@ -566,9 +566,9 @@ void ComplexTextController::adjustGlyphsAndAdvances()
     for (size_t r = 0; r < runCount; ++r) {
         ComplexTextRun& complexTextRun = *m_complexTextRuns[r];
         unsigned glyphCount = complexTextRun.glyphCount();
-        const SimpleFontData* fontData = complexTextRun.fontData();
+        const SimpleFontData& fontData = complexTextRun.fontData();
 #if PLATFORM(IOS)
-        bool isEmoji = fontData->platformData().m_isEmoji;
+        bool isEmoji = fontData.platformData().m_isEmoji;
 #endif
 
         // Represent the initial advance for a text run by adjusting the advance
@@ -588,8 +588,8 @@ void ComplexTextController::adjustGlyphsAndAdvances()
         const CGSize* advances = complexTextRun.advances();
 
         bool lastRun = r + 1 == runCount;
-        bool roundsAdvances = !m_font.isPrinterFont() && fontData->platformData().roundsGlyphAdvances();
-        float spaceWidth = fontData->spaceWidth() - fontData->syntheticBoldOffset();
+        bool roundsAdvances = !m_font.isPrinterFont() && fontData.platformData().roundsGlyphAdvances();
+        float spaceWidth = fontData.spaceWidth() - fontData.syntheticBoldOffset();
         CGFloat roundedSpaceWidth = roundCGFloat(spaceWidth);
         const UChar* cp = complexTextRun.characters();
         CGPoint glyphOrigin = CGPointZero;
@@ -616,7 +616,7 @@ void ComplexTextController::adjustGlyphsAndAdvances()
                 nextCh = *(m_complexTextRuns[r + 1]->characters() + m_complexTextRuns[r + 1]->indexAt(0));
 
             bool treatAsSpace = Font::treatAsSpace(ch);
-            CGGlyph glyph = treatAsSpace ? fontData->spaceGlyph() : glyphs[i];
+            CGGlyph glyph = treatAsSpace ? fontData.spaceGlyph() : glyphs[i];
             CGSize advance = treatAsSpace ? CGSizeMake(spaceWidth, advances[i].height) : advances[i];
 #if PLATFORM(IOS)
             if (isEmoji && advance.width)
@@ -624,25 +624,25 @@ void ComplexTextController::adjustGlyphsAndAdvances()
 #endif
 
             if (ch == '\t' && m_run.allowTabs())
-                advance.width = m_font.tabWidth(*fontData, m_run.tabSize(), m_run.xPos() + m_totalWidth + widthSinceLastCommit);
+                advance.width = m_font.tabWidth(fontData, m_run.tabSize(), m_run.xPos() + m_totalWidth + widthSinceLastCommit);
             else if (Font::treatAsZeroWidthSpace(ch) && !treatAsSpace) {
                 advance.width = 0;
-                glyph = fontData->spaceGlyph();
+                glyph = fontData.spaceGlyph();
             }
 
             float roundedAdvanceWidth = roundf(advance.width);
             if (roundsAdvances)
                 advance.width = roundedAdvanceWidth;
 
-            advance.width += fontData->syntheticBoldOffset();
+            advance.width += fontData.syntheticBoldOffset();
 
  
             // We special case spaces in two ways when applying word rounding. 
             // First, we round spaces to an adjusted width in all fonts. 
             // Second, in fixed-pitch fonts we ensure that all glyphs that 
             // match the width of the space glyph have the same width as the space glyph. 
-            if (m_run.applyWordRounding() && roundedAdvanceWidth == roundedSpaceWidth && (fontData->pitch() == FixedPitch || glyph == fontData->spaceGlyph()))
-                advance.width = fontData->adjustedSpaceWidth();
+            if (m_run.applyWordRounding() && roundedAdvanceWidth == roundedSpaceWidth && (fontData.pitch() == FixedPitch || glyph == fontData.spaceGlyph()))
+                advance.width = fontData.adjustedSpaceWidth();
 
             if (hasExtraSpacing) {
                 // If we're a glyph with an advance, go ahead and add in letter-spacing.
@@ -716,7 +716,7 @@ void ComplexTextController::adjustGlyphsAndAdvances()
             m_adjustedAdvances.append(advance);
             m_adjustedGlyphs.append(glyph);
             
-            FloatRect glyphBounds = fontData->boundsForGlyph(glyph);
+            FloatRect glyphBounds = fontData.boundsForGlyph(glyph);
             glyphBounds.move(glyphOrigin.x, glyphOrigin.y);
             m_minGlyphBoundingBoxX = std::min(m_minGlyphBoundingBoxX, glyphBounds.x());
             m_maxGlyphBoundingBoxX = std::max(m_maxGlyphBoundingBoxX, glyphBounds.maxX());
index e469b5d..f1619d8 100644 (file)
@@ -73,18 +73,18 @@ public:
 private:
     class ComplexTextRun : public RefCounted<ComplexTextRun> {
     public:
-        static Ref<ComplexTextRun> create(CTRunRef ctRun, const SimpleFontData* fontData, const UChar* characters, unsigned stringLocation, size_t stringLength, CFRange runRange)
+        static Ref<ComplexTextRun> create(CTRunRef ctRun, const SimpleFontData& fontData, const UChar* characters, unsigned stringLocation, size_t stringLength, CFRange runRange)
         {
             return adoptRef(*new ComplexTextRun(ctRun, fontData, characters, stringLocation, stringLength, runRange));
         }
 
-        static Ref<ComplexTextRun> create(const SimpleFontData* fontData, const UChar* characters, unsigned stringLocation, size_t stringLength, bool ltr)
+        static Ref<ComplexTextRun> create(const SimpleFontData& fontData, const UChar* characters, unsigned stringLocation, size_t stringLength, bool ltr)
         {
             return adoptRef(*new ComplexTextRun(fontData, characters, stringLocation, stringLength, ltr));
         }
 
         unsigned glyphCount() const { return m_glyphCount; }
-        const SimpleFontData* fontData() const { return m_fontData; }
+        const SimpleFontData& fontData() const { return m_fontData; }
         const UChar* characters() const { return m_characters; }
         unsigned stringLocation() const { return m_stringLocation; }
         size_t stringLength() const { return m_stringLength; }
@@ -100,11 +100,11 @@ private:
         void setIsNonMonotonic();
 
     private:
-        ComplexTextRun(CTRunRef, const SimpleFontData*, const UChar* characters, unsigned stringLocation, size_t stringLength, CFRange runRange);
-        ComplexTextRun(const SimpleFontData*, const UChar* characters, unsigned stringLocation, size_t stringLength, bool ltr);
+        ComplexTextRun(CTRunRef, const SimpleFontData&, const UChar* characters, unsigned stringLocation, size_t stringLength, CFRange runRange);
+        ComplexTextRun(const SimpleFontData&, const UChar* characters, unsigned stringLocation, size_t stringLength, bool ltr);
 
         unsigned m_glyphCount;
-        const SimpleFontData* m_fontData;
+        const SimpleFontData& m_fontData;
         const UChar* m_characters;
         unsigned m_stringLocation;
         size_t m_stringLength;
index a29323a..4ad6f99 100644 (file)
@@ -94,7 +94,7 @@
 
 namespace WebCore {
 
-ComplexTextController::ComplexTextRun::ComplexTextRun(CTRunRef ctRun, const SimpleFontData* fontData, const UChar* characters, unsigned stringLocation, size_t stringLength, CFRange runRange)
+ComplexTextController::ComplexTextRun::ComplexTextRun(CTRunRef ctRun, const SimpleFontData& fontData, const UChar* characters, unsigned stringLocation, size_t stringLength, CFRange runRange)
     : m_fontData(fontData)
     , m_characters(characters)
     , m_stringLocation(stringLocation)
@@ -130,7 +130,7 @@ ComplexTextController::ComplexTextRun::ComplexTextRun(CTRunRef ctRun, const Simp
 
 // Missing glyphs run constructor. Core Text will not generate a run of missing glyphs, instead falling back on
 // glyphs from LastResort. We want to use the primary font's missing glyph in order to match the fast text code path.
-ComplexTextController::ComplexTextRun::ComplexTextRun(const SimpleFontData* fontData, const UChar* characters, unsigned stringLocation, size_t stringLength, bool ltr)
+ComplexTextController::ComplexTextRun::ComplexTextRun(const SimpleFontData& fontData, const UChar* characters, unsigned stringLocation, size_t stringLength, bool ltr)
     : m_fontData(fontData)
     , m_characters(characters)
     , m_stringLocation(stringLocation)
@@ -163,7 +163,7 @@ ComplexTextController::ComplexTextRun::ComplexTextRun(const SimpleFontData* font
     // Synthesize a run of missing glyphs.
     m_glyphsVector.fill(0, m_glyphCount);
     m_glyphs = m_glyphsVector.data();
-    m_advancesVector.fill(CGSizeMake(m_fontData->widthForGlyph(0), 0), m_glyphCount);
+    m_advancesVector.fill(CGSizeMake(m_fontData.widthForGlyph(0), 0), m_glyphCount);
     m_advances = m_advancesVector.data();
 }
 
@@ -188,7 +188,7 @@ void ComplexTextController::collectComplexTextRunsForCharacters(const UChar* cp,
 {
     if (!fontData) {
         // Create a run of missing glyphs from the primary font.
-        m_complexTextRuns.append(ComplexTextRun::create(m_font.primaryFont(), cp, stringLocation, length, m_run.ltr()));
+        m_complexTextRuns.append(ComplexTextRun::create(m_font.primaryFontData(), cp, stringLocation, length, m_run.ltr()));
         return;
     }
 
@@ -273,7 +273,7 @@ void ComplexTextController::collectComplexTextRunsForCharacters(const UChar* cp,
                     // NSFontRenderingMode.
                     RetainPtr<CFStringRef> fontName = adoptCF(CTFontCopyPostScriptName(runFont));
                     if (CFEqual(fontName.get(), CFSTR("LastResort"))) {
-                        m_complexTextRuns.append(ComplexTextRun::create(m_font.primaryFont(), cp, stringLocation + runRange.location, runRange.length, m_run.ltr()));
+                        m_complexTextRuns.append(ComplexTextRun::create(m_font.primaryFontData(), cp, stringLocation + runRange.location, runRange.length, m_run.ltr()));
                         continue;
                     }
                     runFontData = fontCache().getCachedFontData(m_font.fontDescription(), fontName.get(), false, FontCache::DoNotRetain).get();
@@ -289,14 +289,14 @@ void ComplexTextController::collectComplexTextRunsForCharacters(const UChar* cp,
                     ASSERT(runFontData);
 #endif
                 }
-                if (m_fallbackFonts && runFontData != m_font.primaryFont())
+                if (m_fallbackFonts && runFontData != &m_font.primaryFontData())
                     m_fallbackFonts->add(runFontData);
             }
         }
-        if (m_fallbackFonts && runFontData != m_font.primaryFont())
+        if (m_fallbackFonts && runFontData != &m_font.primaryFontData())
             m_fallbackFonts->add(fontData);
 
-        m_complexTextRuns.append(ComplexTextRun::create(ctRun, runFontData, cp, stringLocation, length, runRange));
+        m_complexTextRuns.append(ComplexTextRun::create(ctRun, *runFontData, cp, stringLocation, length, runRange));
     }
 }
 
index a155592..ded20a9 100644 (file)
@@ -593,8 +593,8 @@ DashArray Font::dashesForIntersectionsWithRect(const TextRun& run, const FloatPo
 bool Font::primaryFontDataIsSystemFont() const
 {
 #if PLATFORM(IOS) || __MAC_OS_X_VERSION_MIN_REQUIRED > 1090
-    const auto* fontData = primaryFont();
-    return !fontData->isSVGFont() && CTFontDescriptorIsSystemUIFont(adoptCF(CTFontCopyFontDescriptor(fontData->platformData().ctFont())).get());
+    const auto& fontData = primaryFontData();
+    return !fontData.isSVGFont() && CTFontDescriptorIsSystemUIFont(adoptCF(CTFontCopyFontDescriptor(fontData.platformData().ctFont())).get());
 #else
     // System fonts are hidden by having a name that begins with a period, so simply search
     // for that here rather than try to keep the list up to date.
index 1182f7a..96c05b7 100644 (file)
@@ -265,7 +265,7 @@ OpenTypeMathData::~OpenTypeMathData()
 }
 
 #if ENABLE(OPENTYPE_MATH)
-float OpenTypeMathData::getMathConstant(const SimpleFontData* font, MathConstant constant) const
+float OpenTypeMathData::getMathConstant(const SimpleFontData& font, MathConstant constant) const
 {
     int32_t value = 0;
 
@@ -286,9 +286,9 @@ float OpenTypeMathData::getMathConstant(const SimpleFontData* font, MathConstant
     if (constant == ScriptPercentScaleDown || constant == ScriptScriptPercentScaleDown || constant == RadicalDegreeBottomRaisePercent)
         return value / 100.0;
 
-    return value * font->sizePerUnit();
+    return value * font.sizePerUnit();
 #else
-float OpenTypeMathData::getMathConstant(const SimpleFontData*, MathConstant) const
+float OpenTypeMathData::getMathConstant(const SimpleFontData&, MathConstant) const
 {
     ASSERT_NOT_REACHED();
     return 0;
@@ -296,7 +296,7 @@ float OpenTypeMathData::getMathConstant(const SimpleFontData*, MathConstant) con
 }
 
 #if ENABLE(OPENTYPE_MATH)
-float OpenTypeMathData::getItalicCorrection(const SimpleFontData* font, Glyph glyph) const
+float OpenTypeMathData::getItalicCorrection(const SimpleFontData& font, Glyph glyph) const
 {
     const OpenType::MATHTable* math = OpenType::validateTable<OpenType::MATHTable>(m_mathBuffer);
     ASSERT(math);
@@ -308,9 +308,9 @@ float OpenTypeMathData::getItalicCorrection(const SimpleFontData* font, Glyph gl
     if (!mathItalicsCorrectionInfo)
         return 0;
 
-    return mathItalicsCorrectionInfo->getItalicCorrection(*m_mathBuffer, glyph) * font->sizePerUnit();
+    return mathItalicsCorrectionInfo->getItalicCorrection(*m_mathBuffer, glyph) * font.sizePerUnit();
 #else
-float OpenTypeMathData::getItalicCorrection(const SimpleFontData*, Glyph) const
+float OpenTypeMathData::getItalicCorrection(const SimpleFontData&, Glyph) const
 {
     ASSERT_NOT_REACHED();
     return 0;
index 570f95e..6dff3e7 100644 (file)
@@ -113,8 +113,8 @@ public:
         bool isExtender;
     };
 
-    float getMathConstant(const SimpleFontData*, MathConstant) const;
-    float getItalicCorrection(const SimpleFontData*, Glyph) const;
+    float getMathConstant(const SimpleFontData&, MathConstant) const;
+    float getItalicCorrection(const SimpleFontData&, Glyph) const;
     void getMathVariants(Glyph, bool isVertical, Vector<Glyph>& sizeVariants, Vector<AssemblyPart>& assemblyParts) const;
 
 private:
index 8abbfeb..2cc0f2c 100644 (file)
@@ -165,7 +165,7 @@ void UniscribeController::advance(unsigned offset, GlyphBuffer* glyphBuffer)
                 smallCapsBuffer[index] = forceSmallCaps ? c : newC;
         }
 
-        if (m_fallbackFonts && fontData && nextFontData != fontData && fontData != m_font.primaryFont())
+        if (m_fallbackFonts && fontData && nextFontData != fontData && fontData != &m_font.primaryFontData())
             m_fallbackFonts->add(fontData);
 
         if (nextFontData != fontData || nextIsSmallCaps != isSmallCaps) {
@@ -179,7 +179,7 @@ void UniscribeController::advance(unsigned offset, GlyphBuffer* glyphBuffer)
     
     int itemLength = m_run.rtl() ? indexOfFontTransition + 1 : length - indexOfFontTransition;
     if (itemLength) {
-        if (m_fallbackFonts && nextFontData && nextFontData != m_font.primaryFont())
+        if (m_fallbackFonts && nextFontData && nextFontData != &m_font.primaryFontData())
             m_fallbackFonts->add(nextFontData);
 
         int itemStart = m_run.rtl() ? 0 : indexOfFontTransition;
index 825414a..8417b51 100644 (file)
@@ -449,7 +449,7 @@ bool InlineFlowBox::requiresIdeographicBaseline(const GlyphOverflowAndFallbackFo
 
     const RenderStyle& lineStyle = this->lineStyle();
     if (lineStyle.fontDescription().nonCJKGlyphOrientation() == NonCJKGlyphOrientationUpright
-        || lineStyle.font().primaryFont()->hasVerticalGlyphs())
+        || lineStyle.font().primaryFontData().hasVerticalGlyphs())
         return true;
 
     for (InlineBox* child = firstChild(); child; child = child->nextOnLine()) {
@@ -460,7 +460,7 @@ bool InlineFlowBox::requiresIdeographicBaseline(const GlyphOverflowAndFallbackFo
             if (downcast<InlineFlowBox>(*child).requiresIdeographicBaseline(textBoxDataMap))
                 return true;
         } else {
-            if (child->lineStyle().font().primaryFont()->hasVerticalGlyphs())
+            if (child->lineStyle().font().primaryFontData().hasVerticalGlyphs())
                 return true;
             
             const Vector<const SimpleFontData*>* usedFonts = nullptr;
index 0c01ca9..afd21b5 100644 (file)
@@ -1388,7 +1388,7 @@ TextRun InlineTextBox::constructTextRun(const RenderStyle& style, const Font& fo
 
     TextRun run(string, textPos(), expansion(), expansionBehavior(), direction(), dirOverride() || style.rtlOrdering() == VisualOrder, !renderer().canUseSimpleFontCodePath());
     run.setTabSize(!style.collapseWhiteSpace(), style.tabSize());
-    if (font.primaryFont()->isSVGFont())
+    if (font.primaryFontData().isSVGFont())
         run.setRenderingContext(SVGTextRunRenderingContext::create(renderer()));
 
     // Propagate the maximum length of the characters buffer to the TextRun, even when we're only processing a substring.
index 524bd97..686d9be 100644 (file)
@@ -2320,7 +2320,7 @@ LayoutUnit RenderBlock::adjustLogicalLeftOffsetForLine(LayoutUnit offsetFromFloa
         return left;
 
     // FIXME: Should letter-spacing apply? This is complicated since it doesn't apply at the edge?
-    float maxCharWidth = lineGrid->style().font().primaryFont()->maxCharWidth();
+    float maxCharWidth = lineGrid->style().font().primaryFontData().maxCharWidth();
     if (!maxCharWidth)
         return left;
 
@@ -2360,7 +2360,7 @@ LayoutUnit RenderBlock::adjustLogicalRightOffsetForLine(LayoutUnit offsetFromFlo
         return right;
 
     // FIXME: Should letter-spacing apply? This is complicated since it doesn't apply at the edge?
-    float maxCharWidth = lineGrid->style().font().primaryFont()->maxCharWidth();
+    float maxCharWidth = lineGrid->style().font().primaryFontData().maxCharWidth();
     if (!maxCharWidth)
         return right;
 
@@ -3694,7 +3694,7 @@ static inline TextRun constructTextRunInternal(RenderObject* context, const Font
     bool directionalOverride = style.rtlOrdering() == VisualOrder;
 
     TextRun run(characters, length, 0, 0, expansion, textDirection, directionalOverride);
-    if (font.primaryFont()->isSVGFont()) {
+    if (font.primaryFontData().isSVGFont()) {
         ASSERT(context); // FIXME: Thread a RenderObject& to this point so we don't have to dereference anything.
         run.setRenderingContext(SVGTextRunRenderingContext::create(*context));
     }
@@ -3714,7 +3714,7 @@ static inline TextRun constructTextRunInternal(RenderObject* context, const Font
             directionalOverride |= isOverride(style.unicodeBidi());
     }
     TextRun run(characters, length, 0, 0, expansion, textDirection, directionalOverride);
-    if (font.primaryFont()->isSVGFont()) {
+    if (font.primaryFontData().isSVGFont()) {
         ASSERT(context); // FIXME: Thread a RenderObject& to this point so we don't have to dereference anything.
         run.setRenderingContext(SVGTextRunRenderingContext::create(*context));
     }
index 2bd35c3..54105e2 100644 (file)
@@ -346,7 +346,7 @@ LayoutUnit RenderTextControlSingleLine::preferredContentLogicalWidth(float charW
     if (family == "Lucida Grande")
         maxCharWidth = scaleEmToUnits(4027);
     else if (style().font().hasValidAverageCharWidth())
-        maxCharWidth = roundf(style().font().primaryFont()->maxCharWidth());
+        maxCharWidth = roundf(style().font().primaryFontData().maxCharWidth());
 #endif
 
     // For text inputs, IE adds some extra width.
index a7d7192..21ca821 100644 (file)
@@ -580,7 +580,7 @@ static void adjustInputElementButtonStyle(RenderStyle& style, HTMLInputElement&
     Font font = style.font();
     
     RenderObject* renderer = inputElement.renderer();
-    if (font.primaryFont()->isSVGFont() && !renderer)
+    if (font.primaryFontData().isSVGFont() && !renderer)
         return;
     
     FontCachePurgePreventer fontCachePurgePreventer;
index 7c60dc3..50b4900 100644 (file)
@@ -901,7 +901,7 @@ void RootInlineBox::ascentAndDescentForBox(InlineBox& box, GlyphOverflowAndFallb
 
     const RenderStyle& boxLineStyle = box.lineStyle();
     if (usedFonts && !usedFonts->isEmpty() && (includeFont || (boxLineStyle.lineHeight().isNegative() && includeLeading))) {
-        usedFonts->append(boxLineStyle.font().primaryFont());
+        usedFonts->append(&boxLineStyle.font().primaryFontData());
         for (size_t i = 0; i < usedFonts->size(); ++i) {
             const FontMetrics& fontMetrics = usedFonts->at(i)->fontMetrics();
             int usedFontAscent = fontMetrics.ascent(baselineType());
index c9e383d..6428016 100644 (file)
@@ -178,10 +178,10 @@ bool canUseFor(const RenderBlockFlow& flow)
             }
         }
     }
-    if (style.font().primaryFont()->isSVGFont())
+    if (style.font().primaryFontData().isSVGFont())
         return false;
     // We assume that all lines have metrics based purely on the primary font.
-    auto& primaryFontData = *style.font().primaryFont();
+    auto& primaryFontData = style.font().primaryFontData();
     if (primaryFontData.isLoading())
         return false;
     for (const auto& textRenderer : childrenOfType<RenderText>(flow)) {
index 83974c9..05d20d8 100644 (file)
@@ -1522,7 +1522,7 @@ bool RenderMathMLOperator::getGlyphAssemblyFallBack(Vector<OpenTypeMathData::Ass
     if (!bottom.glyph)
         bottom.glyph = extension.glyph;
 
-    top.fontData = style().font().primaryFont();
+    top.fontData = &style().font().primaryFontData();
     extension.fontData = top.fontData;
     bottom.fontData = top.fontData;
     if (middle.glyph)
@@ -1539,24 +1539,24 @@ RenderMathMLOperator::StretchyData RenderMathMLOperator::getDisplayStyleLargeOpe
 
     ASSERT(m_isVertical && isLargeOperatorInDisplayStyle());
 
-    const auto& primaryFontData = style().font().primaryFont();
+    const auto& primaryFontData = style().font().primaryFontData();
     GlyphData baseGlyph = style().font().glyphDataForCharacter(character, !style().isLeftToRightDirection());
-    if (!primaryFontData || !primaryFontData->mathData() || baseGlyph.fontData != primaryFontData)
+    if (!primaryFontData.mathData() || baseGlyph.fontData != &primaryFontData)
         return data;
 
     Vector<Glyph> sizeVariants;
     Vector<OpenTypeMathData::AssemblyPart> assemblyParts;
 
     // The value of displayOperatorMinHeight is sometimes too small, so we ensure that it is at least \sqrt{2} times the size of the base glyph.
-    float displayOperatorMinHeight = std::max(baseGlyph.fontData->boundsForGlyph(baseGlyph.glyph).height() * sqrtOfTwoFloat, primaryFontData->mathData()->getMathConstant(primaryFontData, OpenTypeMathData::DisplayOperatorMinHeight));
+    float displayOperatorMinHeight = std::max(baseGlyph.fontData->boundsForGlyph(baseGlyph.glyph).height() * sqrtOfTwoFloat, primaryFontData.mathData()->getMathConstant(primaryFontData, OpenTypeMathData::DisplayOperatorMinHeight));
 
-    primaryFontData->mathData()->getMathVariants(baseGlyph.glyph, true, sizeVariants, assemblyParts);
+    primaryFontData.mathData()->getMathVariants(baseGlyph.glyph, true, sizeVariants, assemblyParts);
 
     // We choose the first size variant that is larger than the expected displayOperatorMinHeight and otherwise fallback to the largest variant.
     for (auto& variant : sizeVariants) {
         GlyphData sizeVariant;
         sizeVariant.glyph = variant;
-        sizeVariant.fontData = primaryFontData;
+        sizeVariant.fontData = &primaryFontData;
         data.setSizeVariantMode(sizeVariant);
         if (boundsForGlyph(sizeVariant).height() >= displayOperatorMinHeight)
             return data;
@@ -1571,18 +1571,18 @@ RenderMathMLOperator::StretchyData RenderMathMLOperator::findStretchyData(UChar
     StretchyData data;
     StretchyData assemblyData;
 
-    const auto& primaryFontData = style().font().primaryFont();
+    const auto& primaryFontData = style().font().primaryFontData();
     GlyphData baseGlyph = style().font().glyphDataForCharacter(character, !style().isLeftToRightDirection());
     
-    if (primaryFontData && primaryFontData->mathData() && baseGlyph.fontData == primaryFontData) {
+    if (primaryFontData.mathData() && baseGlyph.fontData == &primaryFontData) {
         Vector<Glyph> sizeVariants;
         Vector<OpenTypeMathData::AssemblyPart> assemblyParts;
-        primaryFontData->mathData()->getMathVariants(baseGlyph.glyph, m_isVertical, sizeVariants, assemblyParts);
+        primaryFontData.mathData()->getMathVariants(baseGlyph.glyph, m_isVertical, sizeVariants, assemblyParts);
         // We verify the size variants.
         for (auto& variant : sizeVariants) {
             GlyphData sizeVariant;
             sizeVariant.glyph = variant;
-            sizeVariant.fontData = primaryFontData;
+            sizeVariant.fontData = &primaryFontData;
             if (maximumGlyphWidth)
                 *maximumGlyphWidth = std::max(*maximumGlyphWidth, advanceForGlyph(sizeVariant));
             else {
@@ -1983,8 +1983,8 @@ void RenderMathMLOperator::paintChildren(PaintInfo& paintInfo, const LayoutPoint
 
 LayoutUnit RenderMathMLOperator::trailingSpaceError()
 {
-    const auto& primaryFontData = style().font().primaryFont();
-    if (!primaryFontData || !primaryFontData->mathData())
+    const auto& primaryFontData = style().font().primaryFontData();
+    if (!primaryFontData.mathData())
         return 0;
 
     // For OpenType MATH font, the layout is based on RenderMathOperator for which the preferred width is sometimes overestimated (bug https://bugs.webkit.org/show_bug.cgi?id=130326).
index c949508..b71d929 100644 (file)
@@ -63,8 +63,7 @@ RenderMathMLRadicalOperator::RenderMathMLRadicalOperator(Document& document, Ref
 
 void RenderMathMLRadicalOperator::stretchTo(LayoutUnit heightAboveBaseline, LayoutUnit depthBelowBaseline)
 {
-    const auto& primaryFontData = style().font().primaryFont();
-    if (!primaryFontData || !primaryFontData->mathData()) {
+    if (!style().font().primaryFontData().mathData()) {
         // If we do not have an OpenType MATH font, we always make the radical depth a bit larger than the target.
         depthBelowBaseline += gRadicalBottomPointLower;
     }
@@ -84,8 +83,7 @@ void RenderMathMLRadicalOperator::computePreferredLogicalWidths()
 {
     ASSERT(preferredLogicalWidthsDirty());
 
-    const auto& primaryFontData = style().font().primaryFont();
-    if (primaryFontData && primaryFontData->mathData()) {
+    if (style().font().primaryFontData().mathData()) {
         RenderMathMLOperator::computePreferredLogicalWidths();
         return;
     }
@@ -98,8 +96,7 @@ void RenderMathMLRadicalOperator::computePreferredLogicalWidths()
 
 void RenderMathMLRadicalOperator::computeLogicalHeight(LayoutUnit logicalHeight, LayoutUnit logicalTop, LogicalExtentComputedValues& computedValues) const
 {
-    const auto& primaryFontData = style().font().primaryFont();
-    if (primaryFontData && primaryFontData->mathData()) {
+    if (style().font().primaryFontData().mathData()) {
         RenderMathMLOperator::computeLogicalHeight(logicalHeight, logicalTop, computedValues);
         return;
     }
@@ -114,8 +111,7 @@ void RenderMathMLRadicalOperator::paint(PaintInfo& info, const LayoutPoint& pain
     if (info.context->paintingDisabled() || info.phase != PaintPhaseForeground || style().visibility() != VISIBLE)
         return;
 
-    const auto& primaryFontData = style().font().primaryFont();
-    if (primaryFontData && primaryFontData->mathData()) {
+    if (style().font().primaryFontData().mathData()) {
         RenderMathMLOperator::paint(info, paintOffset);
         return;
     }
index e6ba565..85bee39 100644 (file)
@@ -208,17 +208,17 @@ void RenderMathMLRoot::updateStyle()
     LayoutUnit kernAfterDegree = -10 * style().font().size() / 18;
     m_degreeBottomRaisePercent = 0.6f;
 
-    const auto& primaryFontData = style().font().primaryFont();
-    if (primaryFontData && primaryFontData->mathData()) {
+    const auto& primaryFontData = style().font().primaryFontData();
+    if (auto* mathData = style().font().primaryFontData().mathData()) {
         // FIXME: m_verticalGap should use RadicalDisplayStyleVertical in display mode (https://bugs.webkit.org/show_bug.cgi?id=118737).
-        m_verticalGap = primaryFontData->mathData()->getMathConstant(primaryFontData, OpenTypeMathData::RadicalVerticalGap);
-        m_ruleThickness = primaryFontData->mathData()->getMathConstant(primaryFontData, OpenTypeMathData::RadicalRuleThickness);
-        m_extraAscender = primaryFontData->mathData()->getMathConstant(primaryFontData, OpenTypeMathData::RadicalExtraAscender);
+        m_verticalGap = mathData->getMathConstant(primaryFontData, OpenTypeMathData::RadicalVerticalGap);
+        m_ruleThickness = mathData->getMathConstant(primaryFontData, OpenTypeMathData::RadicalRuleThickness);
+        m_extraAscender = mathData->getMathConstant(primaryFontData, OpenTypeMathData::RadicalExtraAscender);
 
         if (!isRenderMathMLSquareRoot()) {
-            kernBeforeDegree = primaryFontData->mathData()->getMathConstant(primaryFontData, OpenTypeMathData::RadicalKernBeforeDegree);
-            kernAfterDegree = primaryFontData->mathData()->getMathConstant(primaryFontData, OpenTypeMathData::RadicalKernAfterDegree);
-            m_degreeBottomRaisePercent = primaryFontData->mathData()->getMathConstant(primaryFontData, OpenTypeMathData::RadicalDegreeBottomRaisePercent);
+            kernBeforeDegree = mathData->getMathConstant(primaryFontData, OpenTypeMathData::RadicalKernBeforeDegree);
+            kernAfterDegree = mathData->getMathConstant(primaryFontData, OpenTypeMathData::RadicalKernAfterDegree);
+            m_degreeBottomRaisePercent = mathData->getMathConstant(primaryFontData, OpenTypeMathData::RadicalDegreeBottomRaisePercent);
         }
     }
 
index 1409118..01e92ae 100644 (file)
@@ -1184,7 +1184,7 @@ const AtomicString& RenderStyle::hyphenString() const
     // FIXME: This should depend on locale.
     DEPRECATED_DEFINE_STATIC_LOCAL(AtomicString, hyphenMinusString, (&hyphenMinus, 1));
     DEPRECATED_DEFINE_STATIC_LOCAL(AtomicString, hyphenString, (&hyphen, 1));
-    return font().primaryFontHasGlyphForCharacter(hyphen) ? hyphenString : hyphenMinusString;
+    return font().primaryFontData().glyphForCharacter(hyphen) ? hyphenString : hyphenMinusString;
 }
 
 const AtomicString& RenderStyle::textEmphasisMarkString() const
index c94457b..6c82493 100644 (file)
@@ -422,7 +422,7 @@ TextRun SVGInlineTextBox::constructTextRun(RenderStyle* style, const SVGTextFrag
                 , direction()
                 , dirOverride() || style->rtlOrdering() == VisualOrder /* directionalOverride */);
 
-    if (style->font().primaryFont()->isSVGFont())
+    if (style->font().primaryFontData().isSVGFont())
         run.setRenderingContext(SVGTextRunRenderingContext::create(renderer()));
 
     run.disableRoundingHacks();
index 4d96f98..2132e22 100644 (file)
@@ -41,16 +41,16 @@ SVGTextLayoutEngineSpacing::SVGTextLayoutEngineSpacing(const Font& font)
 float SVGTextLayoutEngineSpacing::calculateSVGKerning(bool isVerticalText, const SVGTextMetrics::Glyph& currentGlyph)
 {
 #if ENABLE(SVG_FONTS)
-    const SimpleFontData* fontData = m_font.primaryFont();
-    if (!fontData->isSVGFont()) {
+    const SimpleFontData& fontData = m_font.primaryFontData();
+    if (!fontData.isSVGFont()) {
         m_lastGlyph.isValid = false;
         return 0;
     }
 
-    ASSERT(fontData->isCustomFont());
-    ASSERT(fontData->isSVGFont());
+    ASSERT(fontData.isCustomFont());
+    ASSERT(fontData.isSVGFont());
 
-    const SVGFontData* svgFontData = static_cast<const SVGFontData*>(fontData->fontData());
+    const SVGFontData* svgFontData = static_cast<const SVGFontData*>(fontData.fontData());
     SVGFontFaceElement* svgFontFace = svgFontData->svgFontFaceElement();
     ASSERT(svgFontFace);
 
index 9cf62df..0811055 100644 (file)
@@ -70,7 +70,7 @@ TextRun SVGTextMetrics::constructTextRun(RenderSVGInlineText& text, unsigned pos
                 , style.direction()
                 , isOverride(style.unicodeBidi()) /* directionalOverride */);
 
-    if (style.font().primaryFont()->isSVGFont())
+    if (style.font().primaryFontData().isSVGFont())
         run.setRenderingContext(SVGTextRunRenderingContext::create(text));
 
     run.disableRoundingHacks();
@@ -91,7 +91,7 @@ SVGTextMetrics SVGTextMetrics::measureCharacterRange(RenderSVGInlineText& text,
 
 SVGTextMetrics::SVGTextMetrics(RenderSVGInlineText& text, unsigned position, unsigned length, float width, const String& glyphName)
 {
-    bool needsContext = text.style().font().primaryFont()->isSVGFont();
+    bool needsContext = text.style().font().primaryFontData().isSVGFont();
     float scalingFactor = text.scalingFactor();
     ASSERT(scalingFactor);
 
index 7eee3f9..3e87b72 100644 (file)
@@ -292,13 +292,13 @@ void SVGTextRunRenderingContext::drawSVGGlyphs(GraphicsContext* context, const S
 
 static GlyphData missingGlyphForFont(const Font& font)
 {
-    const SimpleFontData* primaryFontData = font.primaryFont();
-    if (!primaryFontData->isSVGFont())
+    const SimpleFontData& primaryFontData = font.primaryFontData();
+    if (!primaryFontData.isSVGFont())
         return GlyphData();
     SVGFontElement* fontElement;
     SVGFontFaceElement* fontFaceElement;
-    svgFontAndFontFaceElementForFontData(primaryFontData, fontFaceElement, fontElement);
-    return GlyphData(fontElement->missingGlyph(), primaryFontData);
+    svgFontAndFontFaceElementForFontData(&primaryFontData, fontFaceElement, fontElement);
+    return GlyphData(fontElement->missingGlyph(), &primaryFontData);
 }
 
 GlyphData SVGTextRunRenderingContext::glyphDataForCharacter(const Font& font, WidthIterator& iterator, UChar32 character, bool mirror, int currentCharacter, unsigned& advanceLength, String& normalizedSpacesStringCache)
@@ -314,7 +314,7 @@ GlyphData SVGTextRunRenderingContext::glyphDataForCharacter(const Font& font, Wi
         auto& elementRenderer = is<RenderElement>(renderer()) ? downcast<RenderElement>(renderer()) : *renderer().parent();
         if (Element* parentRendererElement = elementRenderer.element()) {
             if (is<SVGAltGlyphElement>(*parentRendererElement))
-                glyphData.fontData = font.primaryFont();
+                glyphData.fontData = &font.primaryFontData();
         }
     }
 
index 6922215..36e54b9 100644 (file)
@@ -81,9 +81,9 @@ void PopupMenuMac::populate()
         PopupMenuStyle style = m_client->itemStyle(i);
         RetainPtr<NSMutableDictionary> attributes = adoptNS([[NSMutableDictionary alloc] init]);
         if (style.font() != Font()) {
-            NSFont *font = style.font().primaryFont()->getNSFont();
+            NSFont *font = style.font().primaryFontData().getNSFont();
             if (!font) {
-                CGFloat size = style.font().primaryFont()->platformData().size();
+                CGFloat size = style.font().primaryFontData().platformData().size();
                 font = style.font().weight() < FontWeightBold ? [NSFont systemFontOfSize:size] : [NSFont boldSystemFontOfSize:size];
             }
             [attributes setObject:font forKey:NSFontAttributeName];
@@ -148,7 +148,7 @@ void PopupMenuMac::show(const IntRect& r, FrameView* v, int index)
     NSMenu* menu = [m_popup menu];
     
     NSPoint location;
-    NSFont* font = m_client->menuStyle().font().primaryFont()->getNSFont();
+    NSFont* font = m_client->menuStyle().font().primaryFontData().getNSFont();
 
     // These values were borrowed from AppKit to match their placement of the menu.
     const int popOverHorizontalAdjust = -10;
index dfcb58a..fa202a9 100644 (file)
@@ -39,7 +39,7 @@ void WebPopupMenu::setUpPlatformData(const IntRect&, PlatformPopupMenuData& data
 {
 #if USE(APPKIT)
     // FIXME: font will be nil here for custom fonts, we should fix that.
-    NSFont *font = m_popupClient->menuStyle().font().primaryFont()->getNSFont();
+    NSFont *font = m_popupClient->menuStyle().font().primaryFontData().getNSFont();
     if (!font)
         return;
     
index da9d678..24b7f63 100644 (file)
@@ -800,7 +800,7 @@ EditorState WebPage::editorState() const
     if (!selection.isNone()) {
         Node* nodeToRemove;
         if (RenderStyle* style = Editor::styleForSelectionStart(&frame, nodeToRemove)) {
-            CTFontRef font = style->font().primaryFont()->getCTFont();
+            CTFontRef font = style->font().primaryFontData().getCTFont();
             CTFontSymbolicTraits traits = font ? CTFontGetSymbolicTraits(font) : 0;
             
             if (traits & kCTFontTraitBold)