Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(245)

Side by Side Diff: Source/core/svg/SVGRemoteFontFaceSource.cpp

Issue 656913006: Remove SVG fonts (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Update tests for landing Created 6 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "config.h"
6 #if ENABLE(SVG_FONTS)
7 #include "core/svg/SVGRemoteFontFaceSource.h"
8
9 #include "core/SVGNames.h"
10 #include "core/css/FontLoader.h"
11 #include "core/dom/ElementTraversal.h"
12 #include "core/svg/SVGFontData.h"
13 #include "core/svg/SVGFontElement.h"
14 #include "core/svg/SVGFontFaceElement.h"
15 #include "platform/fonts/FontDescription.h"
16 #include "platform/fonts/SimpleFontData.h"
17
18 namespace blink {
19
20 SVGRemoteFontFaceSource::SVGRemoteFontFaceSource(const String& uri, FontResource * font, PassRefPtrWillBeRawPtr<FontLoader> fontLoader)
21 : RemoteFontFaceSource(font, fontLoader)
22 , m_uri(uri)
23 {
24 }
25
26 SVGRemoteFontFaceSource::~SVGRemoteFontFaceSource()
27 {
28 }
29
30 bool SVGRemoteFontFaceSource::ensureFontData()
31 {
32 return resource()->ensureSVGFontData();
33 }
34
35 PassRefPtr<SimpleFontData> SVGRemoteFontFaceSource::createFontData(const FontDes cription& fontDescription)
36 {
37 if (!isLoaded())
38 return createLoadingFallbackFontData(fontDescription);
39
40 // Parse the external SVG document, and extract the <font> element.
41 if (!resource()->ensureSVGFontData())
42 return nullptr;
43
44 if (!m_externalSVGFontElement) {
45 String fragmentIdentifier;
46 size_t start = m_uri.find('#');
47 if (start != kNotFound)
48 fragmentIdentifier = m_uri.substring(start + 1);
49 m_externalSVGFontElement = resource()->getSVGFontById(fragmentIdentifier );
50 }
51
52 if (!m_externalSVGFontElement)
53 return nullptr;
54
55 // Select first <font-face> child
56 if (SVGFontFaceElement* fontFaceElement = Traversal<SVGFontFaceElement>::fir stChild(*m_externalSVGFontElement)) {
57 return SimpleFontData::create(
58 SVGFontData::create(fontFaceElement),
59 fontDescription.effectiveFontSize(),
60 fontDescription.isSyntheticBold(),
61 fontDescription.isSyntheticItalic());
62 }
63 return nullptr;
64 }
65
66 void SVGRemoteFontFaceSource::trace(Visitor* visitor)
67 {
68 visitor->trace(m_externalSVGFontElement);
69 RemoteFontFaceSource::trace(visitor);
70 }
71
72 } // namespace blink
73
74 #endif // ENABLE(SVG_FONTS)
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698