Commit 765bd952 authored by aestes@apple.com's avatar aestes@apple.com

Add SPI for telling WebKit to prefer pictograph glyphs over monochrome ones

https://bugs.webkit.org/show_bug.cgi?id=122608

Reviewed by Dan Bernstein.

Based on patches by Dan Bernstein.

Source/WebCore:

Test: fonts/font-fallback-prefers-pictographs.html

Created a mechanism to append a font to the end of a font's fallback
list, before the system fallback list. This mechanism is used when
Settings::fontFallbackPrefersPictographs() is true to insert a
pictograph font ahead of a monochrome one from the system fallback list.

* WebCore.exp.in: Moved
__ZN7WebCore8Settings33setFontFallbackPrefersPictographsEb outside of
an iOS platform guard.
* css/CSSFontSelector.cpp:
(WebCore::CSSFontSelector::fallbackFontDataCount): Retuned 1 if
pictograph fonts are preferred.
(WebCore::CSSFontSelector::getFallbackFontData): Returned the
pictograph font's FontData if it is preferred.
* css/CSSFontSelector.h:
* page/Settings.cpp:
(WebCore::Settings::Settings): Initialized
m_fontFallbackPrefersPictographs to false.
(WebCore::Settings::setFontFallbackPrefersPictographs): Set
m_fontFallbackPrefersPictographs and called
Page::setNeedsRecalcStyleInAllFrames().
* page/Settings.h:
(WebCore::Settings::fontFallbackPrefersPictographs):
* platform/graphics/FontGlyphs.cpp:
(WebCore::FontGlyphs::realizeFontDataAt): Realized the selector's
fallback font if necessary.
* platform/graphics/FontSelector.h:
* style/StyleResolveTree.cpp:
(WebCore::Style::resolveTree): Removed iOS platform guards.
* testing/InternalSettings.cpp:
(WebCore::InternalSettings::setFontFallbackPrefersPictographs): Set the
corresponding WebCore::Setting.
* testing/InternalSettings.h: Defined an internal setting for the test.
* testing/InternalSettings.idl: Ditto.

Source/WebKit/mac:

* WebView/WebView.mm:
(-[WebView _setFontFallbackPrefersPictographs:]): Called
WebCore::Settings::setFontFallbackPrefersPictographs().
* WebView/WebViewPrivate.h:

LayoutTests:

* fonts/font-fallback-prefers-pictographs-expected.html: Added.
* fonts/font-fallback-prefers-pictographs.html: Added.

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@157265 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 50cd41c0
2013-10-10 Andy Estes <aestes@apple.com>
Add SPI for telling WebKit to prefer pictograph glyphs over monochrome ones
https://bugs.webkit.org/show_bug.cgi?id=122608
Reviewed by Dan Bernstein.
Based on patches by Dan Bernstein.
* fonts/font-fallback-prefers-pictographs-expected.html: Added.
* fonts/font-fallback-prefers-pictographs.html: Added.
2013-10-10 Gustavo Noronha Silva <gns@gnome.org>
Unreviewed gardening. Add timeout annotation to gtk-wk2-specific expectation for
<!DOCTYPE html>
<span style="font-family: -webkit-pictograph">&#x2665;</span>
<!DOCTYPE html>
<script>
if (window.internals)
window.internals.settings.setFontFallbackPrefersPictographs(true);
</script>
&#x2665;
2013-10-10 Andy Estes <aestes@apple.com>
Add SPI for telling WebKit to prefer pictograph glyphs over monochrome ones
https://bugs.webkit.org/show_bug.cgi?id=122608
Reviewed by Dan Bernstein.
Based on patches by Dan Bernstein.
Test: fonts/font-fallback-prefers-pictographs.html
Created a mechanism to append a font to the end of a font's fallback
list, before the system fallback list. This mechanism is used when
Settings::fontFallbackPrefersPictographs() is true to insert a
pictograph font ahead of a monochrome one from the system fallback list.
* WebCore.exp.in: Moved
__ZN7WebCore8Settings33setFontFallbackPrefersPictographsEb outside of
an iOS platform guard.
* css/CSSFontSelector.cpp:
(WebCore::CSSFontSelector::fallbackFontDataCount): Retuned 1 if
pictograph fonts are preferred.
(WebCore::CSSFontSelector::getFallbackFontData): Returned the
pictograph font's FontData if it is preferred.
* css/CSSFontSelector.h:
* page/Settings.cpp:
(WebCore::Settings::Settings): Initialized
m_fontFallbackPrefersPictographs to false.
(WebCore::Settings::setFontFallbackPrefersPictographs): Set
m_fontFallbackPrefersPictographs and called
Page::setNeedsRecalcStyleInAllFrames().
* page/Settings.h:
(WebCore::Settings::fontFallbackPrefersPictographs):
* platform/graphics/FontGlyphs.cpp:
(WebCore::FontGlyphs::realizeFontDataAt): Realized the selector's
fallback font if necessary.
* platform/graphics/FontSelector.h:
* style/StyleResolveTree.cpp:
(WebCore::Style::resolveTree): Removed iOS platform guards.
* testing/InternalSettings.cpp:
(WebCore::InternalSettings::setFontFallbackPrefersPictographs): Set the
corresponding WebCore::Setting.
* testing/InternalSettings.h: Defined an internal setting for the test.
* testing/InternalSettings.idl: Ditto.
2013-10-10 Sergio Correia <sergio.correia@openbossa.org>
Remove unused attribute in CoordinatedTile class
......@@ -1118,6 +1118,7 @@ __ZN7WebCore8Settings32setAcceleratedCompositingEnabledEb
__ZN7WebCore8Settings32setNeedsAdobeFrameReloadingQuirkEb
__ZN7WebCore8Settings32setScreenFontSubstitutionEnabledEb
__ZN7WebCore8Settings33setAggressiveTileRetentionEnabledEb
__ZN7WebCore8Settings33setFontFallbackPrefersPictographsEb
__ZN7WebCore8Settings37setScrollingPerformanceLoggingEnabledEb
__ZN7WebCore8Settings38setLowPowerVideoAudioBufferSizeEnabledEb
__ZN7WebCore8Settings41setAcceleratedCompositedAnimationsEnabledEb
......@@ -2243,7 +2244,6 @@ __ZN7WebCore8IntPointC1ERK7CGPoint
__ZN7WebCore8PositionC1EN3WTF10PassRefPtrINS_4NodeEEENS0_19LegacyEditingOffsetE
__ZN7WebCore8SVGNames4initEv
__ZN7WebCore8Settings13setStandaloneEb
__ZN7WebCore8Settings33setFontFallbackPrefersPictographsEb
__ZN7WebCore9FontCache17getCachedFontDataERKNS_15FontDescriptionERKN3WTF12AtomicStringEbNS0_12ShouldRetainE
__ZN7WebCore9FontCache25getLastResortFallbackFontERKNS_15FontDescriptionENS0_12ShouldRetainE
__ZN7WebCore9FrameView20setWasScrolledByUserEb
......
......@@ -632,4 +632,29 @@ bool CSSFontSelector::resolvesFamilyFor(const FontDescription& description) cons
return false;
}
size_t CSSFontSelector::fallbackFontDataCount()
{
if (!m_document)
return 0;
if (Settings* settings = m_document->settings())
return settings->fontFallbackPrefersPictographs() ? 1 : 0;
return 0;
}
PassRefPtr<FontData> CSSFontSelector::getFallbackFontData(const FontDescription& fontDescription, size_t index)
{
ASSERT_UNUSED(index, !index);
if (!m_document)
return 0;
Settings* settings = m_document->settings();
if (!settings || !settings->fontFallbackPrefersPictographs())
return 0;
return fontCache()->getCachedFontData(fontDescription, settings->pictographFontFamily());
}
}
......@@ -57,6 +57,8 @@ public:
virtual unsigned uniqueId() const OVERRIDE { return m_uniqueId; }
virtual PassRefPtr<FontData> getFontData(const FontDescription&, const AtomicString&) OVERRIDE;
virtual size_t fallbackFontDataCount() OVERRIDE;
virtual PassRefPtr<FontData> getFallbackFontData(const FontDescription&, size_t) OVERRIDE;
CSSSegmentedFontFace* getFontFace(const FontDescription&, const AtomicString& family);
virtual bool resolvesFamilyFor(const FontDescription&) const OVERRIDE;
......
......@@ -182,6 +182,7 @@ Settings::Settings(Page* page)
#if ENABLE(PAGE_VISIBILITY_API)
, m_hiddenPageCSSAnimationSuspensionEnabled(false)
#endif
, m_fontFallbackPrefersPictographs(false)
{
// A Frame may not have been created yet, so we initialize the AtomicString
// hash before trying to use it.
......@@ -641,6 +642,15 @@ void Settings::setHiddenPageCSSAnimationSuspensionEnabled(bool flag)
}
#endif
void Settings::setFontFallbackPrefersPictographs(bool preferPictographs)
{
if (m_fontFallbackPrefersPictographs == preferPictographs)
return;
m_fontFallbackPrefersPictographs = preferPictographs;
m_page->setNeedsRecalcStyleInAllFrames();
}
void Settings::setLowPowerVideoAudioBufferSizeEnabled(bool flag)
{
gLowPowerVideoAudioBufferSizeEnabled = flag;
......
......@@ -261,6 +261,9 @@ public:
void setHiddenPageCSSAnimationSuspensionEnabled(bool);
#endif
void setFontFallbackPrefersPictographs(bool);
bool fontFallbackPrefersPictographs() const { return m_fontFallbackPrefersPictographs; }
static bool lowPowerVideoAudioBufferSizeEnabled() { return gLowPowerVideoAudioBufferSizeEnabled; }
static void setLowPowerVideoAudioBufferSizeEnabled(bool);
......@@ -323,6 +326,8 @@ private:
#if ENABLE(PAGE_VISIBILITY_API)
bool m_hiddenPageCSSAnimationSuspensionEnabled : 1;
#endif
bool m_fontFallbackPrefersPictographs : 1;
static double gDefaultMinDOMTimerInterval;
static double gDefaultDOMTimerAlignmentInterval;
......
......@@ -99,8 +99,20 @@ const FontData* FontGlyphs::realizeFontDataAt(const FontDescription& description
// Make sure we're not passing in some crazy value here.
ASSERT(realizedFontIndex == m_realizedFontData.size());
if (m_familyIndex == cAllFamiliesScanned)
return 0;
if (m_familyIndex <= cAllFamiliesScanned) {
if (!m_fontSelector)
return 0;
size_t index = cAllFamiliesScanned - m_familyIndex;
if (index == m_fontSelector->fallbackFontDataCount())
return 0;
m_familyIndex--;
RefPtr<FontData> fallback = m_fontSelector->getFallbackFontData(description, index);
if (fallback)
m_realizedFontData.append(fallback);
return fallback.get();
}
// Ask the font cache for the font data.
// We are obtaining this font for the first time. We keep track of the families we've looked at before
......
......@@ -39,7 +39,12 @@ class FontSelectorClient;
class FontSelector : public RefCounted<FontSelector> {
public:
virtual ~FontSelector() { }
// FIXME: Remove the "get" prefix from these two member functions
virtual PassRefPtr<FontData> getFontData(const FontDescription&, const AtomicString& familyName) = 0;
virtual PassRefPtr<FontData> getFallbackFontData(const FontDescription&, size_t) = 0;
virtual size_t fallbackFontDataCount() = 0;
virtual bool resolvesFamilyFor(const FontDescription&) const = 0;
virtual void fontCacheInvalidated() { }
......
......@@ -27,6 +27,7 @@
#include "StyleResolveTree.h"
#include "AXObjectCache.h"
#include "CSSFontSelector.h"
#include "Element.h"
#include "ElementIterator.h"
#include "ElementRareData.h"
......@@ -791,7 +792,6 @@ void resolveTree(Document& document, Change change)
if (resolveRootStyle) {
RefPtr<RenderStyle> documentStyle = resolveForDocument(document);
#if PLATFORM(IOS)
// Inserting the pictograph font at the end of the font fallback list is done by the
// font selector, so set a font selector if needed.
if (Settings* settings = document.settings()) {
......@@ -799,7 +799,6 @@ void resolveTree(Document& document, Change change)
if (settings->fontFallbackPrefersPictographs() && styleResolver)
documentStyle->font().update(styleResolver->fontSelector());
}
#endif
Style::Change documentChange = determineChange(documentStyle.get(), document.renderView()->style(), document.settings());
if (documentChange != NoChange)
......
......@@ -522,4 +522,10 @@ void InternalSettings::setAutoscrollForDragAndDropEnabled(bool enabled, Exceptio
settings()->setAutoscrollForDragAndDropEnabled(enabled);
}
void InternalSettings::setFontFallbackPrefersPictographs(bool preferPictographs, ExceptionCode& ec)
{
InternalSettingsGuardForSettings();
settings()->setFontFallbackPrefersPictographs(preferPictographs);
}
}
......@@ -135,6 +135,7 @@ public:
void setTimeWithoutMouseMovementBeforeHidingControls(double time, ExceptionCode&);
void setUseLegacyBackgroundSizeShorthandBehavior(bool enabled, ExceptionCode&);
void setAutoscrollForDragAndDropEnabled(bool enabled, ExceptionCode&);
void setFontFallbackPrefersPictographs(bool preferPictographs, ExceptionCode&);
private:
explicit InternalSettings(Page*);
......
......@@ -59,4 +59,5 @@
[RaisesException] void setTimeWithoutMouseMovementBeforeHidingControls(double time);
[RaisesException] void setUseLegacyBackgroundSizeShorthandBehavior(boolean enabled);
[RaisesException] void setAutoscrollForDragAndDropEnabled(boolean enabled);
[RaisesException] void setFontFallbackPrefersPictographs(boolean preferPictographs);
};
2013-10-10 Andy Estes <aestes@apple.com>
Add SPI for telling WebKit to prefer pictograph glyphs over monochrome ones
https://bugs.webkit.org/show_bug.cgi?id=122608
Reviewed by Dan Bernstein.
Based on patches by Dan Bernstein.
* WebView/WebView.mm:
(-[WebView _setFontFallbackPrefersPictographs:]): Called
WebCore::Settings::setFontFallbackPrefersPictographs().
* WebView/WebViewPrivate.h:
2013-10-10 Mark Rowe <mrowe@apple.com>
<rdar://problem/13341666> WebKit should always build against an SDK.
......
......@@ -3154,6 +3154,12 @@ static Vector<String> toStringVector(NSArray* patterns)
return _private->sourceApplicationAuditData.get();
}
- (void)_setFontFallbackPrefersPictographs:(BOOL)flag
{
if (_private->page)
_private->page->settings().setFontFallbackPrefersPictographs(flag);
}
@end
@implementation _WebSafeForwarder
......
......@@ -649,6 +649,8 @@ Could be worth adding to the API.
@property (nonatomic, copy, getter=_sourceApplicationAuditData, setter=_setSourceApplicationAuditData:) NSData *sourceApplicationAuditData;
- (void)_setFontFallbackPrefersPictographs:(BOOL)flag;
@end
@interface WebView (WebViewPrintingPrivate)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment