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

Side by Side Diff: Source/core/css/FontFace.cpp

Issue 1103273010: Add parseFontFaceDescriptor for @font-face handling (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: V2 Created 5 years, 7 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
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2013 Google Inc. All rights reserved. 2 * Copyright (C) 2013 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
58 #include "core/frame/Settings.h" 58 #include "core/frame/Settings.h"
59 #include "core/frame/UseCounter.h" 59 #include "core/frame/UseCounter.h"
60 #include "platform/FontFamilyNames.h" 60 #include "platform/FontFamilyNames.h"
61 #include "platform/SharedBuffer.h" 61 #include "platform/SharedBuffer.h"
62 62
63 namespace blink { 63 namespace blink {
64 64
65 static PassRefPtrWillBeRawPtr<CSSValue> parseCSSValue(const Document* document, const String& s, CSSPropertyID propertyID) 65 static PassRefPtrWillBeRawPtr<CSSValue> parseCSSValue(const Document* document, const String& s, CSSPropertyID propertyID)
66 { 66 {
67 CSSParserContext context(*document, UseCounter::getFrom(document)); 67 CSSParserContext context(*document, UseCounter::getFrom(document));
68 return CSSParser::parseSingleValue(propertyID, s, context); 68 StringBuilder builder;
69 builder.appendLiteral("@font-face { ");
70 builder.append(getPropertyNameString(propertyID));
71 builder.appendLiteral(" : ");
72 builder.append(s);
73 builder.appendLiteral("; }");
74 RefPtrWillBeRawPtr<StyleRuleBase> rule = CSSParser::parseRule(context, 0, bu ilder.toString());
75 if (!rule || !rule->isFontFaceRule())
76 return nullptr;
77 return toStyleRuleFontFace(rule.get())->properties().getPropertyCSSValue(pro pertyID);
69 } 78 }
70 79
71 PassRefPtrWillBeRawPtr<FontFace> FontFace::create(ExecutionContext* context, con st AtomicString& family, StringOrArrayBufferOrArrayBufferView& source, const Fon tFaceDescriptors& descriptors) 80 PassRefPtrWillBeRawPtr<FontFace> FontFace::create(ExecutionContext* context, con st AtomicString& family, StringOrArrayBufferOrArrayBufferView& source, const Fon tFaceDescriptors& descriptors)
72 { 81 {
73 if (source.isString()) 82 if (source.isString())
74 return create(context, family, source.getAsString(), descriptors); 83 return create(context, family, source.getAsString(), descriptors);
75 if (source.isArrayBuffer()) 84 if (source.isArrayBuffer())
76 return create(context, family, source.getAsArrayBuffer(), descriptors); 85 return create(context, family, source.getAsArrayBuffer(), descriptors);
77 if (source.isArrayBufferView()) 86 if (source.isArrayBufferView())
78 return create(context, family, source.getAsArrayBufferView(), descriptor s); 87 return create(context, family, source.getAsArrayBufferView(), descriptor s);
(...skipping 501 matching lines...) Expand 10 before | Expand all | Expand 10 after
580 { 589 {
581 return m_cssFontFace->hadBlankText(); 590 return m_cssFontFace->hadBlankText();
582 } 591 }
583 592
584 bool FontFace::hasPendingActivity() const 593 bool FontFace::hasPendingActivity() const
585 { 594 {
586 return m_status == Loading && executionContext() && !executionContext()->act iveDOMObjectsAreStopped(); 595 return m_status == Loading && executionContext() && !executionContext()->act iveDOMObjectsAreStopped();
587 } 596 }
588 597
589 } // namespace blink 598 } // namespace blink
OLDNEW
« no previous file with comments | « no previous file | Source/core/css/StyleRule.h » ('j') | Source/core/css/parser/CSSPropertyParser.cpp » ('J')

Powered by Google App Engine
This is Rietveld 408576698