2 * Copyright (C) 2007, 2008, 2016 Apple Inc. All rights reserved.
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions
7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
13 * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
14 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
16 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR
17 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
18 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
19 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
20 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
21 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
23 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 #include "CSSFontFace.h"
30 #include "CSSPropertyNames.h"
31 #include "DOMCoreException.h"
32 #include "ExceptionCode.h"
33 #include "JSDOMPromise.h"
34 #include <wtf/RefCounted.h>
35 #include <wtf/RefPtr.h>
36 #include <wtf/WeakPtr.h>
37 #include <wtf/text/WTFString.h>
39 namespace Deprecated {
49 class FontFace final : public RefCounted<FontFace>, public CSSFontFace::Client {
51 static RefPtr<FontFace> create(JSC::ExecState&, ScriptExecutionContext&, const String& family, const Deprecated::ScriptValue& source, const Dictionary& descriptors, ExceptionCode&);
52 static Ref<FontFace> create(JSC::ExecState&, CSSFontFace&);
55 void setFamily(const String&, ExceptionCode&);
56 void setStyle(const String&, ExceptionCode&);
57 void setWeight(const String&, ExceptionCode&);
58 void setStretch(const String&, ExceptionCode&);
59 void setUnicodeRange(const String&, ExceptionCode&);
60 void setVariant(const String&, ExceptionCode&);
61 void setFeatureSettings(const String&, ExceptionCode&);
63 String family() const;
65 String weight() const;
66 String stretch() const;
67 String unicodeRange() const;
68 String variant() const;
69 String featureSettings() const;
70 String status() const;
72 typedef DOMPromise<FontFace&, DOMCoreException&> Promise;
73 Promise& promise() { return m_promise; }
77 CSSFontFace& backing() { return m_backing; }
79 static RefPtr<CSSValue> parseString(const String&, CSSPropertyID);
81 void fontStateChanged(CSSFontFace&, CSSFontFace::Status oldState, CSSFontFace::Status newState) override;
83 WeakPtr<FontFace> createWeakPtr() const;
85 // CSSFontFace::Client needs to be able to be held in a RefPtr.
86 void ref() override { RefCounted<FontFace>::ref(); }
87 void deref() override { RefCounted<FontFace>::deref(); }
90 FontFace(JSC::ExecState&, CSSFontSelector&);
91 FontFace(JSC::ExecState&, CSSFontFace&);
93 void fulfillPromise();
94 void rejectPromise(ExceptionCode);
96 WeakPtrFactory<FontFace> m_weakPtrFactory;
97 Ref<CSSFontFace> m_backing;