Title: [171690] trunk/Source/WebCore
Revision
171690
Author
betra...@adobe.com
Date
2014-07-28 13:41:16 -0700 (Mon, 28 Jul 2014)

Log Message

[CSS Font Loading] Update Font Loading Code
https://bugs.webkit.org/show_bug.cgi?id=135340

Reviewed by Antti Koivisto.

Update the Font Loading code to build again, as trunk has evolved
since the feature was originally written. Mostly, this requires
updating the code to work with the new Font representation.

The original tests were enabled only for the Chromium port.
They will need to be updated when the feature is enabled by default.

* WebCore.xcodeproj/project.pbxproj: Add missing files.
* css/FontLoader.cpp: Update to new Font representation.
(WebCore::LoadFontCallback::createFromParams):
(WebCore::LoadFontCallback::~LoadFontCallback):
(WebCore::FontLoader::loadFont):
(WebCore::FontLoader::checkFont):
(WebCore::applyPropertyToCurrentStyle):
(WebCore::FontLoader::resolveFontStyle):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (171689 => 171690)


--- trunk/Source/WebCore/ChangeLog	2014-07-28 20:41:09 UTC (rev 171689)
+++ trunk/Source/WebCore/ChangeLog	2014-07-28 20:41:16 UTC (rev 171690)
@@ -1,3 +1,26 @@
+2014-07-28  Bear Travis  <betra...@adobe.com>
+
+        [CSS Font Loading] Update Font Loading Code
+        https://bugs.webkit.org/show_bug.cgi?id=135340
+
+        Reviewed by Antti Koivisto.
+
+        Update the Font Loading code to build again, as trunk has evolved
+        since the feature was originally written. Mostly, this requires
+        updating the code to work with the new Font representation.
+
+        The original tests were enabled only for the Chromium port.
+        They will need to be updated when the feature is enabled by default.
+
+        * WebCore.xcodeproj/project.pbxproj: Add missing files.
+        * css/FontLoader.cpp: Update to new Font representation.
+        (WebCore::LoadFontCallback::createFromParams):
+        (WebCore::LoadFontCallback::~LoadFontCallback):
+        (WebCore::FontLoader::loadFont):
+        (WebCore::FontLoader::checkFont):
+        (WebCore::applyPropertyToCurrentStyle):
+        (WebCore::FontLoader::resolveFontStyle):
+
 2014-07-28  Wenson Hsieh  <wenson_hs...@apple.com>
 
         Let WheelEvent wrap a PlatformWheelEvent

Modified: trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj (171689 => 171690)


--- trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj	2014-07-28 20:41:09 UTC (rev 171689)
+++ trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj	2014-07-28 20:41:16 UTC (rev 171690)
@@ -6505,6 +6505,7 @@
 		FD45A959175D417100C21EC8 /* PolygonShape.cpp in Sources */ = {isa = PBXBuildFile; fileRef = FD08A87A175D3926002CD360 /* PolygonShape.cpp */; };
 		FD45A95A175D417100C21EC8 /* RectangleShape.cpp in Sources */ = {isa = PBXBuildFile; fileRef = FD08A87C175D3926002CD360 /* RectangleShape.cpp */; };
 		FD45A95B175D41EE00C21EC8 /* ShapeInterval.h in Headers */ = {isa = PBXBuildFile; fileRef = FD08A885175D3926002CD360 /* ShapeInterval.h */; settings = {ATTRIBUTES = (Private, ); }; };
+		FD4E5D3B1983175500D93A77 /* JSFontLoader.cpp in Sources */ = {isa = PBXBuildFile; fileRef = FD96C9A4198314A50086E156 /* JSFontLoader.cpp */; };
 		FD537352137B651800008DCE /* ZeroPole.cpp in Sources */ = {isa = PBXBuildFile; fileRef = FD537350137B651800008DCE /* ZeroPole.cpp */; };
 		FD537353137B651800008DCE /* ZeroPole.h in Headers */ = {isa = PBXBuildFile; fileRef = FD537351137B651800008DCE /* ZeroPole.h */; };
 		FD537356137B653B00008DCE /* DynamicsCompressorKernel.cpp in Sources */ = {isa = PBXBuildFile; fileRef = FD537354137B653B00008DCE /* DynamicsCompressorKernel.cpp */; };
@@ -6545,6 +6546,7 @@
 		FD8AA63E169514A700D2EA68 /* JSPannerNodeCustom.cpp in Sources */ = {isa = PBXBuildFile; fileRef = FD8AA63D169514A700D2EA68 /* JSPannerNodeCustom.cpp */; };
 		FD8C46EB154608E700A5910C /* AudioScheduledSourceNode.cpp in Sources */ = {isa = PBXBuildFile; fileRef = FD8C46E9154608E700A5910C /* AudioScheduledSourceNode.cpp */; };
 		FD8C46EC154608E700A5910C /* AudioScheduledSourceNode.h in Headers */ = {isa = PBXBuildFile; fileRef = FD8C46EA154608E700A5910C /* AudioScheduledSourceNode.h */; };
+		FD96C9971982FBDF0086E156 /* FontLoader.cpp in Sources */ = {isa = PBXBuildFile; fileRef = FD96C9961982FB4C0086E156 /* FontLoader.cpp */; };
 		FDA15E9D12B03EE1003A583A /* JSAudioBuffer.cpp in Sources */ = {isa = PBXBuildFile; fileRef = FDA15E8112B03EE1003A583A /* JSAudioBuffer.cpp */; };
 		FDA15E9E12B03EE1003A583A /* JSAudioBuffer.h in Headers */ = {isa = PBXBuildFile; fileRef = FDA15E8212B03EE1003A583A /* JSAudioBuffer.h */; };
 		FDA15E9F12B03EE1003A583A /* JSAudioBufferSourceNode.cpp in Sources */ = {isa = PBXBuildFile; fileRef = FDA15E8312B03EE1003A583A /* JSAudioBufferSourceNode.cpp */; };
@@ -14118,6 +14120,8 @@
 		FD8AA63D169514A700D2EA68 /* JSPannerNodeCustom.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSPannerNodeCustom.cpp; sourceTree = "<group>"; };
 		FD8C46E9154608E700A5910C /* AudioScheduledSourceNode.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = AudioScheduledSourceNode.cpp; sourceTree = "<group>"; };
 		FD8C46EA154608E700A5910C /* AudioScheduledSourceNode.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AudioScheduledSourceNode.h; sourceTree = "<group>"; };
+		FD96C9961982FB4C0086E156 /* FontLoader.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = FontLoader.cpp; sourceTree = "<group>"; };
+		FD96C9A4198314A50086E156 /* JSFontLoader.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSFontLoader.cpp; sourceTree = "<group>"; };
 		FDA15E8112B03EE1003A583A /* JSAudioBuffer.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSAudioBuffer.cpp; sourceTree = "<group>"; };
 		FDA15E8212B03EE1003A583A /* JSAudioBuffer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSAudioBuffer.h; sourceTree = "<group>"; };
 		FDA15E8312B03EE1003A583A /* JSAudioBufferSourceNode.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSAudioBufferSourceNode.cpp; sourceTree = "<group>"; };
@@ -16258,6 +16262,7 @@
 				409EBDC216B7F3A600CBA3FC /* JSCSSFontFaceLoadEvent.h */,
 				40ECAE8016B8B68A00C36103 /* JSDOMError.cpp */,
 				40ECAE7D16B8B67200C36103 /* JSDOMError.h */,
+				FD96C9A4198314A50086E156 /* JSFontLoader.cpp */,
 				409EBDBF16B7F38E00CBA3FC /* JSFontLoader.h */,
 				938E65F609F0985D008A48EC /* JSHTMLElementWrapperFactory.cpp */,
 				938E65F009F09840008A48EC /* JSHTMLElementWrapperFactory.h */,
@@ -22106,6 +22111,7 @@
 				FC9A0F73164094CF003D6B8D /* DOMWindowCSS.idl */,
 				FBDB619A16D6032A00BB3394 /* ElementRuleCollector.cpp */,
 				FBDB619E16D6036500BB3394 /* ElementRuleCollector.h */,
+				FD96C9961982FB4C0086E156 /* FontLoader.cpp */,
 				409EBDB516B7EEA300CBA3FC /* FontLoader.h */,
 				409EBDB716B7EEBA00CBA3FC /* FontLoader.idl */,
 				CD4E0AFA11F7BC27009D3811 /* fullscreen.css */,
@@ -27051,6 +27057,8 @@
 			isa = PBXSourcesBuildPhase;
 			buildActionMask = 2147483647;
 			files = (
+				FD4E5D3B1983175500D93A77 /* JSFontLoader.cpp in Sources */,
+				FD96C9971982FBDF0086E156 /* FontLoader.cpp in Sources */,
 				41E1B1D00FF5986900576B3B /* AbstractWorker.cpp in Sources */,
 				0F29C16E1300C2E2002D794E /* AccessibilityAllInOne.cpp in Sources */,
 				76CDD2F21103DA6600680521 /* AccessibilityMenuList.cpp in Sources */,

Modified: trunk/Source/WebCore/css/FontLoader.cpp (171689 => 171690)


--- trunk/Source/WebCore/css/FontLoader.cpp	2014-07-28 20:41:09 UTC (rev 171689)
+++ trunk/Source/WebCore/css/FontLoader.cpp	2014-07-28 20:41:16 UTC (rev 171690)
@@ -35,6 +35,8 @@
 #include "CSSSegmentedFontFace.h"
 #include "Dictionary.h"
 #include "Document.h"
+#include "ExceptionCodeDescription.h"
+#include "Font.h"
 #include "FrameView.h"
 #include "StyleProperties.h"
 #include "StyleResolver.h"
@@ -51,7 +53,7 @@
         return adoptRef<LoadFontCallback>(new LoadFontCallback(numLoading, loadCallback, errorCallback));
     }
 
-    static PassRefPtr<LoadFontCallback> createFromParams(const Dictionary& params, const FontFamily& family)
+    static PassRefPtr<LoadFontCallback> createFromParams(const Dictionary& params, const Font& font)
     {
         RefPtr<VoidCallback> onsuccess;
         RefPtr<VoidCallback> onerror;
@@ -59,14 +61,14 @@
         params.get("onerror", onerror);
         if (!onsuccess && !onerror)
             return 0;
-        int numFamilies = 0;
-        for (const FontFamily* f = &family; f; f = f->next())
-            numFamilies++;
+        int numFamilies = font.familyCount();
         return LoadFontCallback::create(numFamilies, onsuccess, onerror);
     }
 
     virtual void notifyLoaded() override;
     virtual void notifyError() override;
+    virtual ~LoadFontCallback() { };
+
 private:
     LoadFontCallback(int numLoading, PassRefPtr<VoidCallback> loadCallback, PassRefPtr<VoidCallback> errorCallback)
         : m_numLoading(numLoading)
@@ -234,10 +236,10 @@
     Font font;
     if (!resolveFontStyle(fontString, font))
         return;
-    RefPtr<LoadFontCallback> callback = LoadFontCallback::createFromParams(params, font.family());
+    RefPtr<LoadFontCallback> callback = LoadFontCallback::createFromParams(params, font);
     
-    for (const FontFamily* f = &font.family(); f; f = f->next()) {
-        CSSSegmentedFontFace* face = m_document->ensureStyleResolver()->fontSelector()->getFontFace(font.fontDescription(), f->family());
+    for (unsigned i = 0; i < font.familyCount(); i++) {
+        CSSSegmentedFontFace* face = m_document->ensureStyleResolver().fontSelector()->getFontFace(font.fontDescription(), font.familyAt(i));
         if (!face) {
             if (callback)
                 callback->notifyError();
@@ -253,17 +255,17 @@
     Font font;
     if (!resolveFontStyle(fontString, font))
         return false;
-    for (const FontFamily* f = &font.family(); f; f = f->next()) {
-        CSSSegmentedFontFace* face = m_document->ensureStyleResolver()->fontSelector()->getFontFace(font.fontDescription(), f->family());
+    for (unsigned i = 0; i < font.familyCount(); i++) {
+        CSSSegmentedFontFace* face = m_document->ensureStyleResolver().fontSelector()->getFontFace(font.fontDescription(), font.familyAt(i));
         if (!face || !face->checkFont())
             return false;
     }
     return true;
 }
 
-static void applyPropertyToCurrentStyle(StyleResolver* styleResolver, CSSPropertyID id, const RefPtr<StyleProperties>& parsedStyle)
+static void applyPropertyToCurrentStyle(StyleResolver& styleResolver, CSSPropertyID id, const RefPtr<StyleProperties>& parsedStyle)
 {
-    styleResolver->applyPropertyToCurrentStyle(id, parsedStyle->getPropertyCSSValue(id).get());
+    styleResolver.applyPropertyToCurrentStyle(id, parsedStyle->getPropertyCSSValue(id).get());
 }
 
 bool FontLoader::resolveFontStyle(const String& fontString, Font& font)
@@ -280,11 +282,8 @@
 
     RefPtr<RenderStyle> style = RenderStyle::create();
 
-    FontFamily fontFamily;
-    fontFamily.setFamily(defaultFontFamily);
-
     FontDescription defaultFontDescription;
-    defaultFontDescription.setFamily(fontFamily);
+    defaultFontDescription.setOneFamily(defaultFontFamily);
     defaultFontDescription.setSpecifiedSize(defaultFontSize);
     defaultFontDescription.setComputedSize(defaultFontSize);
 
@@ -293,8 +292,8 @@
     style->font().update(style->font().fontSelector());
 
     // Now map the font property longhands into the style.
-    StyleResolver* styleResolver = m_document->ensureStyleResolver();
-    styleResolver->applyPropertyToStyle(CSSPropertyFontFamily, parsedStyle->getPropertyCSSValue(CSSPropertyFontFamily).get(), style.get());
+    StyleResolver& styleResolver = m_document->ensureStyleResolver();
+    styleResolver.applyPropertyToStyle(CSSPropertyFontFamily, parsedStyle->getPropertyCSSValue(CSSPropertyFontFamily).get(), style.get());
     applyPropertyToCurrentStyle(styleResolver, CSSPropertyFontStyle, parsedStyle);
     applyPropertyToCurrentStyle(styleResolver, CSSPropertyFontVariant, parsedStyle);
     applyPropertyToCurrentStyle(styleResolver, CSSPropertyFontWeight, parsedStyle);
@@ -302,13 +301,13 @@
     // As described in BUG66291, setting font-size and line-height on a font may entail a CSSPrimitiveValue::computeLengthDouble call,
     // which assumes the fontMetrics are available for the affected font, otherwise a crash occurs (see http://trac.webkit.org/changeset/96122).
     // The updateFont() calls below update the fontMetrics and ensure the proper setting of font-size and line-height.
-    styleResolver->updateFont();
+    styleResolver.updateFont();
     applyPropertyToCurrentStyle(styleResolver, CSSPropertyFontSize, parsedStyle);
-    styleResolver->updateFont();
+    styleResolver.updateFont();
     applyPropertyToCurrentStyle(styleResolver, CSSPropertyLineHeight, parsedStyle);
 
     font = style->font();
-    font.update(styleResolver->fontSelector());
+    font.update(styleResolver.fontSelector());
     return true;
 }
 
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to