Exemple #1
0
StyleAttrib RenderStack::Get(StyleCategories cat) const {
	StyleAttrib v = Stack.back().Styles.Get(cat);
	if (v.IsNull())
		return Defaults[cat];
	else
		return v;
}
Exemple #2
0
void StyleSet::DebugCheckSanity() const {
	for (int i = CatFIRST; i < CatEND; i++) {
		StyleCategories cat = (StyleCategories) i;
		StyleAttrib     val = Get(cat);
		XO_DEBUG_ASSERT(val.IsNull() || val.Category == cat);
	}
}
Exemple #3
0
void Style::SetBoxInternal(StyleCategories catBase, StyleBox val) {
	StyleAttrib a;
	a.SetSize((StyleCategories)(catBase + 0), val.Left);
	Set(a);
	a.SetSize((StyleCategories)(catBase + 1), val.Top);
	Set(a);
	a.SetSize((StyleCategories)(catBase + 2), val.Right);
	Set(a);
	a.SetSize((StyleCategories)(catBase + 3), val.Bottom);
	Set(a);
}
Exemple #4
0
void StyleResolver::SetInherited(RenderStack& stack, const DomEl* node, StyleCategories cat) {
	RenderStackEl& result    = stack.StackBack();
	size_t         stackSize = stack.StackSize();

	for (ssize_t j = stackSize - 2; j >= 0; j--) {
		StyleAttrib attrib = stack.StackAt(j).Styles.Get(cat);
		if (!attrib.IsNull()) {
			SetFinal(result, attrib);
			break;
		}
	}
}
Exemple #5
0
static bool ParseSingleAttrib(const char* s, size_t len, bool (*parseFunc)(const char* s, size_t len, T& t), StyleCategories cat, Style& style) {
	T val;
	if (parseFunc(s, len, val)) {
		StyleAttrib attrib;
		attrib.Set(cat, val);
		style.Set(attrib);
		return true;
	} else {
		ParseFail("Parse failed, unknown value: '%.*s'\n", (int) len, s);
		return false;
	}
}
Exemple #6
0
void StyleSet::Set(const StyleAttrib& attrib, Pool* pool) {
	int32_t slot = GetSlot(attrib.GetCategory());
	if (slot != 0) {
		Attribs[slot - 1] = attrib;
		return;
	}
	if (Count >= Capacity)
		Grow(pool);
	Attribs[Count] = attrib;
	SetSlot(attrib.GetCategory(), Count + SlotOffset);
	Count++;
	//DebugCheckSanity();
}
Exemple #7
0
// This was added when font-family was stored as a string, but it is now stored as a FontID
static void ParseString(const char* s, size_t len, StyleCategories cat, Doc* doc, Style& style) {
	char        stat[64];
	StyleAttrib attrib;
	if (len < sizeof(stat)) {
		memcpy(stat, s, len);
		stat[len] = 0;
		attrib.Set(cat, stat, doc);
	} else {
		String copy;
		copy.Set(s, len);
		attrib.Set(cat, copy.Z, doc);
	}
	style.Set(attrib);
}
Exemple #8
0
static bool ParseBool(const char* s, size_t len, StyleCategories cat, Style& style) {
	bool val;
	if (len == 4 && s[0] == 't')
		val = true;
	else if (len == 5 && s[0] == 'f')
		val = false;
	else {
		ParseFail("Parse failed, illegal boolean value: '%.*s'. Valid values are 'true' and 'false'.\n", (int) len, s);
		return false;
	}
	StyleAttrib attrib;
	attrib.SetBool(cat, val);
	style.Set(attrib);
	return true;
}
Exemple #9
0
void Style::SetUniformBox(StyleCategories cat, Size size) {
	StyleAttrib val;
	val.SetSize(cat, size);
	SetUniformBox(cat, val);
}
Exemple #10
0
void Style::SetUniformBox(StyleCategories cat, Color color) {
	StyleAttrib val;
	val.SetColor(cat, color);
	SetUniformBox(cat, val);
}