#ifndef FontFamily_h
#define FontFamily_h
#include "platform/PlatformExport.h"
#include "wtf/RefCounted.h"
#include "wtf/RefPtr.h"
#include "wtf/text/AtomicString.h"
namespace WebCore {
class SharedFontFamily;
class PLATFORM_EXPORT FontFamily {
public:
FontFamily() { }
~FontFamily();
void setFamily(const AtomicString& family) { m_family = family; }
const AtomicString& family() const { return m_family; }
bool familyIsEmpty() const { return m_family.isEmpty(); }
const FontFamily* next() const;
void appendFamily(PassRefPtr<SharedFontFamily>);
PassRefPtr<SharedFontFamily> releaseNext();
private:
AtomicString m_family;
RefPtr<SharedFontFamily> m_next;
};
class PLATFORM_EXPORT SharedFontFamily : public FontFamily, public RefCounted<SharedFontFamily> {
public:
static PassRefPtr<SharedFontFamily> create()
{
return adoptRef(new SharedFontFamily);
}
private:
SharedFontFamily() { }
};
PLATFORM_EXPORT bool operator==(const FontFamily&, const FontFamily&);
inline bool operator!=(const FontFamily& a, const FontFamily& b) { return !(a == b); }
inline FontFamily::~FontFamily()
{
RefPtr<SharedFontFamily> reaper = m_next.release();
while (reaper && reaper->hasOneRef())
reaper = reaper->releaseNext();
}
inline const FontFamily* FontFamily::next() const
{
return m_next.get();
}
inline void FontFamily::appendFamily(PassRefPtr<SharedFontFamily> family)
{
m_next = family;
}
inline PassRefPtr<SharedFontFamily> FontFamily::releaseNext()
{
return m_next.release();
}
}
#endif