OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2007 Eric Seidel <eric@webkit.org> | 2 * Copyright (C) 2007 Eric Seidel <eric@webkit.org> |
3 * Copyright (C) 2007, 2008 Nikolas Zimmermann <zimmermann@kde.org> | 3 * Copyright (C) 2007, 2008 Nikolas Zimmermann <zimmermann@kde.org> |
4 * Copyright (C) 2008 Apple Inc. All rights reserved. | 4 * Copyright (C) 2008 Apple Inc. All rights reserved. |
5 * | 5 * |
6 * This library is free software; you can redistribute it and/or | 6 * This library is free software; you can redistribute it and/or |
7 * modify it under the terms of the GNU Library General Public | 7 * modify it under the terms of the GNU Library General Public |
8 * License as published by the Free Software Foundation; either | 8 * License as published by the Free Software Foundation; either |
9 * version 2 of the License, or (at your option) any later version. | 9 * version 2 of the License, or (at your option) any later version. |
10 * | 10 * |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
42 #include "platform/fonts/Font.h" | 42 #include "platform/fonts/Font.h" |
43 #include <math.h> | 43 #include <math.h> |
44 | 44 |
45 namespace WebCore { | 45 namespace WebCore { |
46 | 46 |
47 using namespace SVGNames; | 47 using namespace SVGNames; |
48 | 48 |
49 inline SVGFontFaceElement::SVGFontFaceElement(Document& document) | 49 inline SVGFontFaceElement::SVGFontFaceElement(Document& document) |
50 : SVGElement(font_faceTag, document) | 50 : SVGElement(font_faceTag, document) |
51 , m_fontFaceRule(StyleRuleFontFace::create()) | 51 , m_fontFaceRule(StyleRuleFontFace::create()) |
52 , m_fontElement(0) | 52 , m_fontElement(nullptr) |
53 , m_weakFactory(this) | 53 , m_weakFactory(this) |
54 { | 54 { |
55 ScriptWrappable::init(this); | 55 ScriptWrappable::init(this); |
56 RefPtrWillBeRawPtr<MutableStylePropertySet> styleDeclaration = MutableStyleP
ropertySet::create(HTMLStandardMode); | 56 RefPtrWillBeRawPtr<MutableStylePropertySet> styleDeclaration = MutableStyleP
ropertySet::create(HTMLStandardMode); |
57 m_fontFaceRule->setProperties(styleDeclaration.release()); | 57 m_fontFaceRule->setProperties(styleDeclaration.release()); |
58 } | 58 } |
59 | 59 |
60 DEFINE_NODE_FACTORY(SVGFontFaceElement) | 60 DEFINE_NODE_FACTORY(SVGFontFaceElement) |
61 | 61 |
62 static CSSPropertyID cssPropertyIdForFontFaceAttributeName(const QualifiedName&
attrName) | 62 static CSSPropertyID cssPropertyIdForFontFaceAttributeName(const QualifiedName&
attrName) |
(...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
275 | 275 |
276 bool describesParentFont = isSVGFontElement(*parentNode()); | 276 bool describesParentFont = isSVGFontElement(*parentNode()); |
277 RefPtrWillBeRawPtr<CSSValueList> list = nullptr; | 277 RefPtrWillBeRawPtr<CSSValueList> list = nullptr; |
278 | 278 |
279 if (describesParentFont) { | 279 if (describesParentFont) { |
280 m_fontElement = toSVGFontElement(parentNode()); | 280 m_fontElement = toSVGFontElement(parentNode()); |
281 | 281 |
282 list = CSSValueList::createCommaSeparated(); | 282 list = CSSValueList::createCommaSeparated(); |
283 list->append(CSSFontFaceSrcValue::createLocal(fontFamily())); | 283 list->append(CSSFontFaceSrcValue::createLocal(fontFamily())); |
284 } else { | 284 } else { |
285 m_fontElement = 0; | 285 m_fontElement = nullptr; |
286 // we currently ignore all but the last src element, alternatively we co
uld concat them | 286 // we currently ignore all but the last src element, alternatively we co
uld concat them |
287 if (SVGFontFaceSrcElement* element = Traversal<SVGFontFaceSrcElement>::l
astChild(*this)) | 287 if (SVGFontFaceSrcElement* element = Traversal<SVGFontFaceSrcElement>::l
astChild(*this)) |
288 list = element->srcValue(); | 288 list = element->srcValue(); |
289 } | 289 } |
290 | 290 |
291 if (!list || !list->length()) | 291 if (!list || !list->length()) |
292 return; | 292 return; |
293 | 293 |
294 // Parse in-memory CSS rules | 294 // Parse in-memory CSS rules |
295 m_fontFaceRule->mutableProperties().addParsedProperty(CSSProperty(CSSPropert
ySrc, list)); | 295 m_fontFaceRule->mutableProperties().addParsedProperty(CSSProperty(CSSPropert
ySrc, list)); |
(...skipping 24 matching lines...) Expand all Loading... |
320 | 320 |
321 rebuildFontFace(); | 321 rebuildFontFace(); |
322 return InsertionDone; | 322 return InsertionDone; |
323 } | 323 } |
324 | 324 |
325 void SVGFontFaceElement::removedFrom(ContainerNode* rootParent) | 325 void SVGFontFaceElement::removedFrom(ContainerNode* rootParent) |
326 { | 326 { |
327 SVGElement::removedFrom(rootParent); | 327 SVGElement::removedFrom(rootParent); |
328 | 328 |
329 if (rootParent->inDocument()) { | 329 if (rootParent->inDocument()) { |
330 m_fontElement = 0; | 330 m_fontElement = nullptr; |
331 document().accessSVGExtensions().unregisterSVGFontFaceElement(this); | 331 document().accessSVGExtensions().unregisterSVGFontFaceElement(this); |
332 | 332 |
333 // FIXME: HTMLTemplateElement's document or imported document can be ac
tive? | 333 // FIXME: HTMLTemplateElement's document or imported document can be ac
tive? |
334 // If so, we also need to check whether fontSelector() is nullptr or not
. | 334 // If so, we also need to check whether fontSelector() is nullptr or not
. |
335 // Otherwise, we will use just document().isActive() here. | 335 // Otherwise, we will use just document().isActive() here. |
336 if (document().isActive() && document().styleEngine()->fontSelector()) { | 336 if (document().isActive() && document().styleEngine()->fontSelector()) { |
337 document().styleEngine()->fontSelector()->fontFaceCache()->remove(m_
fontFaceRule.get()); | 337 document().styleEngine()->fontSelector()->fontFaceCache()->remove(m_
fontFaceRule.get()); |
338 document().accessSVGExtensions().registerPendingSVGFontFaceElementsF
orRemoval(this); | 338 document().accessSVGExtensions().registerPendingSVGFontFaceElementsF
orRemoval(this); |
339 } | 339 } |
340 m_fontFaceRule->mutableProperties().clear(); | 340 m_fontFaceRule->mutableProperties().clear(); |
341 document().styleResolverChanged(); | 341 document().styleResolverChanged(); |
342 } else | 342 } else |
343 ASSERT(!m_fontElement); | 343 ASSERT(!m_fontElement); |
344 } | 344 } |
345 | 345 |
346 void SVGFontFaceElement::childrenChanged(bool changedByParser, Node* beforeChang
e, Node* afterChange, int childCountDelta) | 346 void SVGFontFaceElement::childrenChanged(bool changedByParser, Node* beforeChang
e, Node* afterChange, int childCountDelta) |
347 { | 347 { |
348 SVGElement::childrenChanged(changedByParser, beforeChange, afterChange, chil
dCountDelta); | 348 SVGElement::childrenChanged(changedByParser, beforeChange, afterChange, chil
dCountDelta); |
349 rebuildFontFace(); | 349 rebuildFontFace(); |
350 } | 350 } |
351 | 351 |
352 void SVGFontFaceElement::trace(Visitor* visitor) | 352 void SVGFontFaceElement::trace(Visitor* visitor) |
353 { | 353 { |
354 visitor->trace(m_fontFaceRule); | 354 visitor->trace(m_fontFaceRule); |
| 355 visitor->trace(m_fontElement); |
355 SVGElement::trace(visitor); | 356 SVGElement::trace(visitor); |
356 } | 357 } |
357 | 358 |
358 } // namespace WebCore | 359 } // namespace WebCore |
359 | 360 |
360 #endif // ENABLE(SVG_FONTS) | 361 #endif // ENABLE(SVG_FONTS) |
OLD | NEW |