#include "wtf/RefCounted.h"
#include "wtf/text/WTFString.h"
-namespace WebCore {
+namespace blink {
class FloatPoint;
class Font;
typedef unsigned ExpansionBehavior;
- enum RoundingHackFlags {
- NoRounding = 0,
- RunRounding = 1 << 0,
- WordRounding = 1 << 1,
- };
-
- typedef unsigned RoundingHacks;
-
- TextRun(const LChar* c, unsigned len, float xpos = 0, float expansion = 0, ExpansionBehavior expansionBehavior = AllowTrailingExpansion | ForbidLeadingExpansion, TextDirection direction = LTR, bool directionalOverride = false, bool characterScanForCodePath = true, RoundingHacks roundingHacks = RunRounding | WordRounding)
+ TextRun(const LChar* c, unsigned len, float xpos = 0, float expansion = 0, ExpansionBehavior expansionBehavior = AllowTrailingExpansion | ForbidLeadingExpansion, TextDirection direction = LTR, bool directionalOverride = false, bool characterScanForCodePath = true)
: m_charactersLength(len)
, m_len(len)
, m_xpos(xpos)
, m_direction(direction)
, m_directionalOverride(directionalOverride)
, m_characterScanForCodePath(characterScanForCodePath)
- , m_applyRunRounding((roundingHacks & RunRounding) && s_allowsRoundingHacks)
- , m_applyWordRounding((roundingHacks & WordRounding) && s_allowsRoundingHacks)
, m_disableSpacing(false)
, m_tabSize(0)
{
m_data.characters8 = c;
}
- TextRun(const UChar* c, unsigned len, float xpos = 0, float expansion = 0, ExpansionBehavior expansionBehavior = AllowTrailingExpansion | ForbidLeadingExpansion, TextDirection direction = LTR, bool directionalOverride = false, bool characterScanForCodePath = true, RoundingHacks roundingHacks = RunRounding | WordRounding)
+ TextRun(const UChar* c, unsigned len, float xpos = 0, float expansion = 0, ExpansionBehavior expansionBehavior = AllowTrailingExpansion | ForbidLeadingExpansion, TextDirection direction = LTR, bool directionalOverride = false, bool characterScanForCodePath = true)
: m_charactersLength(len)
, m_len(len)
, m_xpos(xpos)
, m_direction(direction)
, m_directionalOverride(directionalOverride)
, m_characterScanForCodePath(characterScanForCodePath)
- , m_applyRunRounding((roundingHacks & RunRounding) && s_allowsRoundingHacks)
- , m_applyWordRounding((roundingHacks & WordRounding) && s_allowsRoundingHacks)
, m_disableSpacing(false)
, m_tabSize(0)
{
m_data.characters16 = c;
}
- TextRun(const String& string, float xpos = 0, float expansion = 0, ExpansionBehavior expansionBehavior = AllowTrailingExpansion | ForbidLeadingExpansion, TextDirection direction = LTR, bool directionalOverride = false, bool characterScanForCodePath = true, RoundingHacks roundingHacks = RunRounding | WordRounding)
+ TextRun(const String& string, float xpos = 0, float expansion = 0, ExpansionBehavior expansionBehavior = AllowTrailingExpansion | ForbidLeadingExpansion, TextDirection direction = LTR, bool directionalOverride = false, bool characterScanForCodePath = true)
: m_charactersLength(string.length())
, m_len(string.length())
, m_xpos(xpos)
, m_direction(direction)
, m_directionalOverride(directionalOverride)
, m_characterScanForCodePath(characterScanForCodePath)
- , m_applyRunRounding((roundingHacks & RunRounding) && s_allowsRoundingHacks)
- , m_applyWordRounding((roundingHacks & WordRounding) && s_allowsRoundingHacks)
, m_disableSpacing(false)
, m_tabSize(0)
{
}
}
- TextRun(const StringView& string, float xpos = 0, float expansion = 0, ExpansionBehavior expansionBehavior = AllowTrailingExpansion | ForbidLeadingExpansion, TextDirection direction = LTR, bool directionalOverride = false, bool characterScanForCodePath = true, RoundingHacks roundingHacks = RunRounding | WordRounding)
+ TextRun(const StringView& string, float xpos = 0, float expansion = 0, ExpansionBehavior expansionBehavior = AllowTrailingExpansion | ForbidLeadingExpansion, TextDirection direction = LTR, bool directionalOverride = false, bool characterScanForCodePath = true)
: m_charactersLength(string.length())
, m_len(string.length())
, m_xpos(xpos)
, m_direction(direction)
, m_directionalOverride(directionalOverride)
, m_characterScanForCodePath(characterScanForCodePath)
- , m_applyRunRounding((roundingHacks & RunRounding) && s_allowsRoundingHacks)
- , m_applyWordRounding((roundingHacks & WordRounding) && s_allowsRoundingHacks)
, m_disableSpacing(false)
, m_tabSize(0)
{
bool ltr() const { return m_direction == LTR; }
bool directionalOverride() const { return m_directionalOverride; }
bool characterScanForCodePath() const { return m_characterScanForCodePath; }
- bool applyRunRounding() const { return m_applyRunRounding; }
- bool applyWordRounding() const { return m_applyWordRounding; }
bool spacingDisabled() const { return m_disableSpacing; }
void disableSpacing() { m_disableSpacing = true; }
- void disableRoundingHacks() { m_applyRunRounding = m_applyWordRounding = false; }
void setDirection(TextDirection direction) { m_direction = direction; }
void setDirectionalOverride(bool override) { m_directionalOverride = override; }
void setCharacterScanForCodePath(bool scan) { m_characterScanForCodePath = scan; }
RenderingContext* renderingContext() const { return m_renderingContext.get(); }
void setRenderingContext(PassRefPtr<RenderingContext> context) { m_renderingContext = context; }
- static void setAllowsRoundingHacks(bool);
- static bool allowsRoundingHacks();
-
private:
- static bool s_allowsRoundingHacks;
-
union {
const LChar* characters8;
const UChar* characters16;
unsigned m_direction : 1;
unsigned m_directionalOverride : 1; // Was this direction set by an override character.
unsigned m_characterScanForCodePath : 1;
- unsigned m_applyRunRounding : 1;
- unsigned m_applyWordRounding : 1;
unsigned m_disableSpacing : 1;
unsigned m_tabSize;
RefPtr<RenderingContext> m_renderingContext;