Upstream version 9.38.198.0
[platform/framework/web/crosswalk.git] / src / third_party / WebKit / Source / core / fetch / FontResource.cpp
index 22df828..1e99662 100644 (file)
@@ -43,7 +43,7 @@
 #include "core/svg/SVGFontElement.h"
 #endif
 
-namespace WebCore {
+namespace blink {
 
 static const double fontLoadWaitLimitSec = 3.0;
 
@@ -76,8 +76,9 @@ static void recordPackageFormatHistogram(FontPackageFormat format)
 
 FontResource::FontResource(const ResourceRequest& resourceRequest)
     : Resource(resourceRequest, Font)
-    , m_loadInitiated(false)
+    , m_state(Unloaded)
     , m_exceedsFontLoadWaitLimit(false)
+    , m_corsFailed(false)
     , m_fontLoadWaitLimitTimer(this, &FontResource::fontLoadWaitLimitCallback)
 {
 }
@@ -86,6 +87,26 @@ FontResource::~FontResource()
 {
 }
 
+void FontResource::trace(Visitor* visitor)
+{
+#if ENABLE(SVG_FONTS)
+    visitor->trace(m_externalSVGDocument);
+#endif
+    Resource::trace(visitor);
+}
+
+void FontResource::didScheduleLoad()
+{
+    if (m_state == Unloaded)
+        m_state = LoadScheduled;
+}
+
+void FontResource::didUnscheduleLoad()
+{
+    if (m_state == LoadScheduled)
+        m_state = Unloaded;
+}
+
 void FontResource::load(ResourceFetcher*, const ResourceLoaderOptions& options)
 {
     // Don't load the file yet. Wait for an access before triggering the load.
@@ -103,8 +124,8 @@ void FontResource::didAddClient(ResourceClient* c)
 
 void FontResource::beginLoadIfNeeded(ResourceFetcher* dl)
 {
-    if (!m_loadInitiated) {
-        m_loadInitiated = true;
+    if (m_state != LoadInitiated) {
+        m_state = LoadInitiated;
         Resource::load(dl, m_options);
         m_fontLoadWaitLimitTimer.startOneShot(fontLoadWaitLimitSec, FROM_HERE);
 
@@ -177,7 +198,7 @@ SVGFontElement* FontResource::getSVGFontById(const String& fontName) const
     if (!collectionLength)
         return 0;
 
-#ifndef NDEBUG
+#if ENABLE(ASSERT)
     for (unsigned i = 0; i < collectionLength; ++i) {
         ASSERT(collection->item(i));
         ASSERT(isSVGFontElement(collection->item(i)));