Title: [187249] trunk
Revision
187249
Author
[email protected]
Date
2015-07-23 13:24:08 -0700 (Thu, 23 Jul 2015)

Log Message

Web Inspector: Add a function to CSSCompletions to get a list of supported system fonts
https://bugs.webkit.org/show_bug.cgi?id=147009

Reviewed by Joseph Pecoraro.

Source/_javascript_Core:

* inspector/protocol/CSS.json: Added getSupportedSystemFontFamilyNames function.

Source/WebCore:

Test: inspector/css/get-system-fonts.html

* inspector/InspectorCSSAgent.cpp:
(WebCore::InspectorCSSAgent::getSupportedSystemFontFamilyNames):
Gets the list of system fonts (implemented in each platform) and returns that list.
* inspector/InspectorCSSAgent.h:
* platform/graphics/FontCache.h:
* platform/graphics/freetype/FontCacheFreeType.cpp:
(WebCore::FontCache::systemFontFamilies):
* platform/graphics/ios/FontCacheIOS.mm:
(WebCore::FontCache::systemFontFamilies):
* platform/graphics/mac/FontCacheMac.mm:
(WebCore::FontCache::systemFontFamilies):
* platform/graphics/win/FontCacheWin.cpp:
(WebCore::FontCache::systemFontFamilies):

Source/WebInspectorUI:

* UserInterface/Base/Main.js:
(WebInspector.loaded):
(WebInspector.activateExtraDomains):
* UserInterface/Base/Test.js:
(WebInspector.loaded):
* UserInterface/Models/CSSCompletions.js:
(WebInspector.CSSCompletions.requestCSSCompletions.fontFamilyNamesCallback):
(WebInspector.CSSCompletions.requestCSSCompletions):
Now also grabs the list of system font family names and adds that list to the existing completion
list for both font and font-family in CSSKeywordCompletions.
(WebInspector.CSSCompletions.requestCSSNameCompletions): Deleted.

LayoutTests:

Skip the get-system-fonts test until it is implemented.
* platform/efl/TestExpectations:
* platform/gtk/TestExpectations:
* platform/win/TestExpectations:

Added the get-system-fonts test that returns the list of system fonts.
* inspector/css/get-system-fonts-expected.html:
* inspector/css/get-system-fonts.html:

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (187248 => 187249)


--- trunk/LayoutTests/ChangeLog	2015-07-23 20:18:41 UTC (rev 187248)
+++ trunk/LayoutTests/ChangeLog	2015-07-23 20:24:08 UTC (rev 187249)
@@ -1,3 +1,19 @@
+2015-07-23  Devin Rousso  <[email protected]>
+
+        Web Inspector: Add a function to CSSCompletions to get a list of supported system fonts
+        https://bugs.webkit.org/show_bug.cgi?id=147009
+
+        Reviewed by Joseph Pecoraro.
+
+        Skip the get-system-fonts test until it is implemented.
+        * platform/efl/TestExpectations:
+        * platform/gtk/TestExpectations:
+        * platform/win/TestExpectations:
+
+        Added the get-system-fonts test that returns the list of system fonts.
+        * inspector/css/get-system-fonts-expected.html:
+        * inspector/css/get-system-fonts.html:
+
 2015-07-23  Brady Eidson  <[email protected]>
 
         Crash in WebPlatformStrategies::createPingHandle - Deref a null NetworkingContext.

Added: trunk/LayoutTests/inspector/css/get-system-fonts-expected.txt (0 => 187249)


--- trunk/LayoutTests/inspector/css/get-system-fonts-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/inspector/css/get-system-fonts-expected.txt	2015-07-23 20:24:08 UTC (rev 187249)
@@ -0,0 +1,4 @@
+Has at least 5 fonts: true
+PASS: Includes Arial
+PASS: Includes Times
+

Added: trunk/LayoutTests/inspector/css/get-system-fonts.html (0 => 187249)


--- trunk/LayoutTests/inspector/css/get-system-fonts.html	                        (rev 0)
+++ trunk/LayoutTests/inspector/css/get-system-fonts.html	2015-07-23 20:24:08 UTC (rev 187249)
@@ -0,0 +1,28 @@
+<!DOCTYPE html>
+<html>
+<head>
+<script type="text/_javascript_" src=""
+<script>
+// Testing that we can get the fonts on the system and that the fonts contain some universal fonts (arial, times, etc).
+function test() {
+    function hasFontFamily(fontFamilies, fontFamily) {
+        return (fontFamilies.includes(fontFamily) ? "PASS: Includes " : "FAIL: Missing ") + fontFamily;
+    }
+
+    function fontFamilyNamesCallback(error, fontFamilyNames) {
+        InspectorTest.assert(!error, "Error in getting font family names.");
+
+        if (!error) {
+            InspectorTest.log("Has at least 5 fonts: " + (fontFamilyNames.length >= 5));
+            InspectorTest.log(hasFontFamily(fontFamilyNames, "Arial"));
+            InspectorTest.log(hasFontFamily(fontFamilyNames, "Times"));
+        }
+
+        InspectorTest.completeTest();
+    }
+    CSSAgent.getSupportedSystemFontFamilyNames(fontFamilyNamesCallback);
+}
+</script>
+</head>
+<body _onload_="runTest()"></body>
+</html>

Modified: trunk/LayoutTests/platform/efl/TestExpectations (187248 => 187249)


--- trunk/LayoutTests/platform/efl/TestExpectations	2015-07-23 20:18:41 UTC (rev 187248)
+++ trunk/LayoutTests/platform/efl/TestExpectations	2015-07-23 20:24:08 UTC (rev 187249)
@@ -660,6 +660,8 @@
 
 #webkit.org/b/142158 inspector-protocol/dom/remove-multiple-nodes.html [ Crash Pass ]
 
+webkit.org/b/147018 inspector/css/get-system-fonts.html [ Skip ]
+
 #////////////////////////////////////////////////////////////////////////////////////////
 # FLAKY TESTS
 #////////////////////////////////////////////////////////////////////////////////////////

Modified: trunk/LayoutTests/platform/gtk/TestExpectations (187248 => 187249)


--- trunk/LayoutTests/platform/gtk/TestExpectations	2015-07-23 20:18:41 UTC (rev 187248)
+++ trunk/LayoutTests/platform/gtk/TestExpectations	2015-07-23 20:24:08 UTC (rev 187249)
@@ -1319,6 +1319,7 @@
 
 webkit.org/b/139362 inspector/css/pseudo-element-matches.html [ Timeout ]
 webkit.org/b/139362 inspector/css/selector-specificity.html [ Timeout Pass ]
+webkit.org/b/147018 inspector/css/get-system-fonts.html [ Skip ]
 
 webkit.org/b/139363 media/media-controls-timeline-updates.html [ Timeout ]
 

Modified: trunk/LayoutTests/platform/win/TestExpectations (187248 => 187249)


--- trunk/LayoutTests/platform/win/TestExpectations	2015-07-23 20:18:41 UTC (rev 187248)
+++ trunk/LayoutTests/platform/win/TestExpectations	2015-07-23 20:24:08 UTC (rev 187249)
@@ -2359,6 +2359,8 @@
 inspector/css/selector-specificity.html [ Skip ]
 inspector/css/pseudo-element-matches.html [ Skip ]
 
+webkit.org/b/147017 inspector/css/get-system-fonts.html [ Skip ]
+
 # Inspector Protocol
 webkit.org/b/140510 inspector-protocol/debugger/terminate-dedicated-worker-while-paused.html [ Skip ]  # Crashing
 inspector-protocol/debugger/pause-on-assert.html [ Skip ]

Modified: trunk/Source/_javascript_Core/ChangeLog (187248 => 187249)


--- trunk/Source/_javascript_Core/ChangeLog	2015-07-23 20:18:41 UTC (rev 187248)
+++ trunk/Source/_javascript_Core/ChangeLog	2015-07-23 20:24:08 UTC (rev 187249)
@@ -1,3 +1,12 @@
+2015-07-23  Devin Rousso  <[email protected]>
+
+        Web Inspector: Add a function to CSSCompletions to get a list of supported system fonts
+        https://bugs.webkit.org/show_bug.cgi?id=147009
+
+        Reviewed by Joseph Pecoraro.
+
+        * inspector/protocol/CSS.json: Added getSupportedSystemFontFamilyNames function.
+
 2015-07-22  Sukolsak Sakshuwong  <[email protected]>
 
         Add ENABLE_WEBASSEMBLY feature flag for WebAssembly

Modified: trunk/Source/_javascript_Core/inspector/protocol/CSS.json (187248 => 187249)


--- trunk/Source/_javascript_Core/inspector/protocol/CSS.json	2015-07-23 20:18:41 UTC (rev 187248)
+++ trunk/Source/_javascript_Core/inspector/protocol/CSS.json	2015-07-23 20:24:08 UTC (rev 187249)
@@ -348,6 +348,13 @@
             "description": "Returns all supported CSS property names."
         },
         {
+            "name": "getSupportedSystemFontFamilyNames",
+            "returns": [
+                { "name": "fontFamilyNames", "type": "array", "items": { "type": "string" }, "description": "Supported system font families." }
+            ],
+            "description": "Returns all supported system font family names."
+        },
+        {
             "name": "forcePseudoState",
             "parameters": [
                 { "name": "nodeId", "$ref": "DOM.NodeId", "description": "The element id for which to force the pseudo state." },

Modified: trunk/Source/WebCore/ChangeLog (187248 => 187249)


--- trunk/Source/WebCore/ChangeLog	2015-07-23 20:18:41 UTC (rev 187248)
+++ trunk/Source/WebCore/ChangeLog	2015-07-23 20:24:08 UTC (rev 187249)
@@ -1,3 +1,26 @@
+2015-07-23  Devin Rousso  <[email protected]>
+
+        Web Inspector: Add a function to CSSCompletions to get a list of supported system fonts
+        https://bugs.webkit.org/show_bug.cgi?id=147009
+
+        Reviewed by Joseph Pecoraro.
+
+        Test: inspector/css/get-system-fonts.html
+
+        * inspector/InspectorCSSAgent.cpp:
+        (WebCore::InspectorCSSAgent::getSupportedSystemFontFamilyNames):
+        Gets the list of system fonts (implemented in each platform) and returns that list.
+        * inspector/InspectorCSSAgent.h:
+        * platform/graphics/FontCache.h:
+        * platform/graphics/freetype/FontCacheFreeType.cpp:
+        (WebCore::FontCache::systemFontFamilies):
+        * platform/graphics/ios/FontCacheIOS.mm:
+        (WebCore::FontCache::systemFontFamilies):
+        * platform/graphics/mac/FontCacheMac.mm:
+        (WebCore::FontCache::systemFontFamilies):
+        * platform/graphics/win/FontCacheWin.cpp:
+        (WebCore::FontCache::systemFontFamilies):
+
 2015-07-23  Brent Fulgham  <[email protected]>
 
         [Win] Implement High DPI support features

Modified: trunk/Source/WebCore/inspector/InspectorCSSAgent.cpp (187248 => 187249)


--- trunk/Source/WebCore/inspector/InspectorCSSAgent.cpp	2015-07-23 20:18:41 UTC (rev 187248)
+++ trunk/Source/WebCore/inspector/InspectorCSSAgent.cpp	2015-07-23 20:24:08 UTC (rev 187249)
@@ -36,6 +36,7 @@
 #include "ContentSecurityPolicy.h"
 #include "DOMWindow.h"
 #include "ExceptionCodePlaceholder.h"
+#include "FontCache.h"
 #include "HTMLHeadElement.h"
 #include "HTMLStyleElement.h"
 #include "InspectorDOMAgent.h"
@@ -708,6 +709,17 @@
     cssProperties = WTF::move(properties);
 }
 
+void InspectorCSSAgent::getSupportedSystemFontFamilyNames(ErrorString&, RefPtr<Inspector::Protocol::Array<String>>& fontFamilyNames)
+{
+    auto families = Inspector::Protocol::Array<String>::create();
+
+    Vector<String> systemFontFamilies = FontCache::singleton().systemFontFamilies();
+    for (const auto& familyName : systemFontFamilies)
+        families->addItem(familyName);
+
+    fontFamilyNames = WTF::move(families);
+}
+
 void InspectorCSSAgent::forcePseudoState(ErrorString& errorString, int nodeId, const InspectorArray& forcedPseudoClasses)
 {
     Element* element = m_domAgent->assertElement(errorString, nodeId);

Modified: trunk/Source/WebCore/inspector/InspectorCSSAgent.h (187248 => 187249)


--- trunk/Source/WebCore/inspector/InspectorCSSAgent.h	2015-07-23 20:18:41 UTC (rev 187248)
+++ trunk/Source/WebCore/inspector/InspectorCSSAgent.h	2015-07-23 20:24:08 UTC (rev 187249)
@@ -119,6 +119,7 @@
     virtual void setRuleSelector(ErrorString&, const Inspector::InspectorObject& ruleId, const String& selector, RefPtr<Inspector::Protocol::CSS::CSSRule>& result) override;
     virtual void addRule(ErrorString&, int contextNodeId, const String& selector, RefPtr<Inspector::Protocol::CSS::CSSRule>& result) override;
     virtual void getSupportedCSSProperties(ErrorString&, RefPtr<Inspector::Protocol::Array<Inspector::Protocol::CSS::CSSPropertyInfo>>& result) override;
+    virtual void getSupportedSystemFontFamilyNames(ErrorString&, RefPtr<Inspector::Protocol::Array<String>>& result) override;
     virtual void forcePseudoState(ErrorString&, int nodeId, const Inspector::InspectorArray& forcedPseudoClasses) override;
     virtual void getNamedFlowCollection(ErrorString&, int documentNodeId, RefPtr<Inspector::Protocol::Array<Inspector::Protocol::CSS::NamedFlow>>& result) override;
 

Modified: trunk/Source/WebCore/platform/graphics/FontCache.h (187248 => 187249)


--- trunk/Source/WebCore/platform/graphics/FontCache.h	2015-07-23 20:18:41 UTC (rev 187248)
+++ trunk/Source/WebCore/platform/graphics/FontCache.h	2015-07-23 20:24:08 UTC (rev 187249)
@@ -110,10 +110,9 @@
 public:
     WEBCORE_EXPORT static FontCache& singleton();
 
-    // This method is implemented by the platform.
+    // These methods are implemented by the platform.
     RefPtr<Font> systemFallbackForCharacters(const FontDescription&, const Font* originalFontData, bool isPlatformFont, const UChar* characters, unsigned length);
-
-    // Also implemented by the platform.
+    Vector<String> systemFontFamilies();
     void platformInit();
 
 #if PLATFORM(IOS)

Modified: trunk/Source/WebCore/platform/graphics/freetype/FontCacheFreeType.cpp (187248 => 187249)


--- trunk/Source/WebCore/platform/graphics/freetype/FontCacheFreeType.cpp	2015-07-23 20:18:41 UTC (rev 187248)
+++ trunk/Source/WebCore/platform/graphics/freetype/FontCacheFreeType.cpp	2015-07-23 20:24:08 UTC (rev 187249)
@@ -98,6 +98,13 @@
     return fontForPlatformData(alternateFontData);
 }
 
+Vector<String> FontCache::systemFontFamilies()
+{
+    // FIXME: <https://webkit.org/b/147018> Web Inspector: [Freetype] Allow inspector to retrieve a list of system fonts
+    Vector<String> fontFamilies;
+    return fontFamilies;
+}
+
 Ref<Font> FontCache::lastResortFallbackFont(const FontDescription& fontDescription)
 {
     // We want to return a fallback font here, otherwise the logic preventing FontConfig

Modified: trunk/Source/WebCore/platform/graphics/ios/FontCacheIOS.mm (187248 => 187249)


--- trunk/Source/WebCore/platform/graphics/ios/FontCacheIOS.mm	2015-07-23 20:18:41 UTC (rev 187248)
+++ trunk/Source/WebCore/platform/graphics/ios/FontCacheIOS.mm	2015-07-23 20:24:08 UTC (rev 187249)
@@ -462,6 +462,13 @@
     return lastResortFallbackFont(description);
 }
 
+Vector<String> FontCache::systemFontFamilies()
+{
+    // FIXME: <https://webkit.org/b/147033> Web Inspector: [iOS] Allow inspector to retrieve a list of system fonts
+    Vector<String> fontFamilies;
+    return fontFamilies;
+}
+
 RefPtr<Font> FontCache::similarFont(const FontDescription& description)
 {
     // Attempt to find an appropriate font using a match based on the presence of keywords in

Modified: trunk/Source/WebCore/platform/graphics/mac/FontCacheMac.mm (187248 => 187249)


--- trunk/Source/WebCore/platform/graphics/mac/FontCacheMac.mm	2015-07-23 20:18:41 UTC (rev 187248)
+++ trunk/Source/WebCore/platform/graphics/mac/FontCacheMac.mm	2015-07-23 20:24:08 UTC (rev 187249)
@@ -527,6 +527,26 @@
     return fontForPlatformData(alternateFont);
 }
 
+Vector<String> FontCache::systemFontFamilies()
+{
+    Vector<String> fontFamilies;
+    RetainPtr<CFArrayRef> availableFontFamilies = adoptCF(CTFontManagerCopyAvailableFontFamilyNames());
+    CFIndex count = CFArrayGetCount(availableFontFamilies.get());
+    for (CFIndex i = 0; i < count; ++i) {
+        CFStringRef fontName = static_cast<CFStringRef>(CFArrayGetValueAtIndex(availableFontFamilies.get(), i));
+        if (CFGetTypeID(fontName) != CFStringGetTypeID()) {
+            ASSERT_NOT_REACHED();
+            continue;
+        }
+        // We don't want to make the hidden system fonts visible and since they
+        // all begin with a period, ignore all fonts that begin with a period.
+        if (CFStringHasPrefix(fontName, CFSTR(".")))
+            continue;
+        fontFamilies.append(fontName);
+    }
+    return fontFamilies;
+}
+
 RefPtr<Font> FontCache::similarFont(const FontDescription& description)
 {
     // Attempt to find an appropriate font using a match based on 

Modified: trunk/Source/WebCore/platform/graphics/win/FontCacheWin.cpp (187248 => 187249)


--- trunk/Source/WebCore/platform/graphics/win/FontCacheWin.cpp	2015-07-23 20:18:41 UTC (rev 187248)
+++ trunk/Source/WebCore/platform/graphics/win/FontCacheWin.cpp	2015-07-23 20:24:08 UTC (rev 187249)
@@ -309,6 +309,13 @@
     return fontData.release();
 }
 
+Vector<String> FontCache::systemFontFamilies()
+{
+    // FIXME: <https://webkit.org/b/147017> Web Inspector: [Win] Allow inspector to retrieve a list of system fonts
+    Vector<String> fontFamilies;
+    return fontFamilies;
+}
+
 RefPtr<Font> FontCache::fontFromDescriptionAndLogFont(const FontDescription& fontDescription, const LOGFONT& font, AtomicString& outFontFamilyName)
 {
     AtomicString familyName = String(font.lfFaceName, wcsnlen(font.lfFaceName, LF_FACESIZE));

Modified: trunk/Source/WebInspectorUI/ChangeLog (187248 => 187249)


--- trunk/Source/WebInspectorUI/ChangeLog	2015-07-23 20:18:41 UTC (rev 187248)
+++ trunk/Source/WebInspectorUI/ChangeLog	2015-07-23 20:24:08 UTC (rev 187249)
@@ -1,3 +1,22 @@
+2015-07-23  Devin Rousso  <[email protected]>
+
+        Web Inspector: Add a function to CSSCompletions to get a list of supported system fonts
+        https://bugs.webkit.org/show_bug.cgi?id=147009
+
+        Reviewed by Joseph Pecoraro.
+
+        * UserInterface/Base/Main.js:
+        (WebInspector.loaded):
+        (WebInspector.activateExtraDomains):
+        * UserInterface/Base/Test.js:
+        (WebInspector.loaded):
+        * UserInterface/Models/CSSCompletions.js:
+        (WebInspector.CSSCompletions.requestCSSCompletions.fontFamilyNamesCallback):
+        (WebInspector.CSSCompletions.requestCSSCompletions):
+        Now also grabs the list of system font family names and adds that list to the existing completion
+        list for both font and font-family in CSSKeywordCompletions.
+        (WebInspector.CSSCompletions.requestCSSNameCompletions): Deleted.
+
 2015-07-23  Matt Baker  <[email protected]>
 
         Web Inspector: wrong cursor shown when selecting time interval from timeline overview

Modified: trunk/Source/WebInspectorUI/UserInterface/Base/Main.js (187248 => 187249)


--- trunk/Source/WebInspectorUI/UserInterface/Base/Main.js	2015-07-23 20:18:41 UTC (rev 187248)
+++ trunk/Source/WebInspectorUI/UserInterface/Base/Main.js	2015-07-23 20:24:08 UTC (rev 187249)
@@ -90,7 +90,7 @@
         InspectorAgent.enable();
 
     // Perform one-time tasks.
-    WebInspector.CSSCompletions.requestCSSNameCompletions();
+    WebInspector.CSSCompletions.requestCSSCompletions();
     this._generateDisclosureTriangleImages();
 
     // Listen for the ProvisionalLoadStarted event before registering for events so our code gets called before any managers or sidebars.
@@ -501,7 +501,7 @@
 
     this.notifications.dispatchEventToListeners(WebInspector.Notification.ExtraDomainsActivated, {"domains": domains});
 
-    WebInspector.CSSCompletions.requestCSSNameCompletions();
+    WebInspector.CSSCompletions.requestCSSCompletions();
 
     this._updateReloadToolbarButton();
     this._updateDownloadToolbarButton();

Modified: trunk/Source/WebInspectorUI/UserInterface/Base/Test.js (187248 => 187249)


--- trunk/Source/WebInspectorUI/UserInterface/Base/Test.js	2015-07-23 20:18:41 UTC (rev 187248)
+++ trunk/Source/WebInspectorUI/UserInterface/Base/Test.js	2015-07-23 20:24:08 UTC (rev 187249)
@@ -69,7 +69,7 @@
     ConsoleAgent.enable();
 
     // Perform one-time tasks.
-    WebInspector.CSSCompletions.requestCSSNameCompletions();
+    WebInspector.CSSCompletions.requestCSSCompletions();
 
     // Global settings.
     this.showShadowDOMSetting = new WebInspector.Setting("show-shadow-dom", true);

Modified: trunk/Source/WebInspectorUI/UserInterface/Models/CSSCompletions.js (187248 => 187249)


--- trunk/Source/WebInspectorUI/UserInterface/Models/CSSCompletions.js	2015-07-23 20:18:41 UTC (rev 187248)
+++ trunk/Source/WebInspectorUI/UserInterface/Models/CSSCompletions.js	2015-07-23 20:24:08 UTC (rev 187249)
@@ -76,7 +76,7 @@
 
     // Static
 
-    static requestCSSNameCompletions()
+    static requestCSSCompletions()
     {
         if (WebInspector.CSSCompletions.cssNameCompletions)
             return;
@@ -158,8 +158,21 @@
             updateCodeMirrorCSSMode("text/x-scss");
         }
 
-        if (window.CSSAgent)
+        function fontFamilyNamesCallback(error, fontFamilyNames)
+        {
+            if (error)
+                return;
+
+            WebInspector.CSSKeywordCompletions.addPropertyCompletionValues("font-family", fontFamilyNames);
+            WebInspector.CSSKeywordCompletions.addPropertyCompletionValues("font", fontFamilyNames);
+        }
+
+        if (window.CSSAgent) {
             CSSAgent.getSupportedCSSProperties(propertyNamesCallback);
+
+            if (CSSAgent.getSupportedSystemFontFamilyNames)
+                CSSAgent.getSupportedSystemFontFamilyNames(fontFamilyNamesCallback);
+        }
     }
 
     // Public
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to