Example #1
0
void CSSLayout::set_selection(CSSLayoutNode start, size_t start_text_offset, CSSLayoutNode end, size_t end_text_offset)
{
	impl->throw_if_disposed();
	if (start.is_null() || end.is_null())
	{
		clear_selection();
	}
	else
	{
		impl->box_tree.set_selection(start.impl->box_node, start_text_offset, end.impl->box_node, end_text_offset);
	}
}
Example #2
0
void CSSLayoutElement::append_child(CSSLayoutNode &new_child)
{
	if (!is_null() && !new_child.is_null())
	{
		if (new_child.impl->box_node->get_parent())
			throw Exception("Node already has a parent");
		impl->box_node->push_back(new_child.impl->box_node);
	}
}
Example #3
0
/*
void CSSLayoutElement::apply_properties(const std::vector<CSSPropertyValue *> &properties)
{
	if (!is_null())
	{
		impl->layout_impl.lock()->box_tree.apply_properties(static_cast<CSSBoxElement*>(impl->box_node), properties);

		// Temp hack to support before and after pseudo elements.
		// To do: Make a better more official way to create pseudo elements.
		if (static_cast<CSSBoxElement*>(impl->box_node)->properties.content.type == CSSValueContent::type_string)
		{
			CSSBoxText *box_text = new CSSBoxText();
			box_text->set_text(static_cast<CSSBoxElement*>(impl->box_node)->properties.content.str);
			impl->box_node->push_back(box_text);
		}
	}
}

void CSSLayoutElement::apply_properties(const std::string &style_string, const std::string &base_uri)
{
	apply_properties(CSSDocument::get_style_properties(style_string, base_uri));
}
*/
void CSSLayoutElement::insert_before(CSSLayoutNode &new_child, CSSLayoutNode &ref_child)
{
	if (!is_null() && !new_child.is_null())
	{
		if (ref_child.is_null())
		{
			append_child(new_child);
		}
		else
		{
			if (new_child.impl->box_node->get_parent())
				throw Exception("Node already has a parent");
			if (ref_child.impl->box_node->get_parent() != impl->box_node)
				throw Exception("Node is not a direct child of this element");
			impl->box_node->insert(new_child.impl->box_node, ref_child.impl->box_node);
		}
	}
}
Example #4
0
void CSSLayoutElement::remove_child(CSSLayoutNode &old_child)
{
	if (!is_null() && !old_child.is_null())
	{
		CSSBoxNode *parent = old_child.impl->box_node->get_parent();
		if (parent != impl->box_node)
			throw Exception("Node is not a direct child of this element");
		old_child.impl->box_node->remove();
	}
}
Example #5
0
CSSLayoutElement CSSLayout::find_element(const std::string &name)
{
	if (!get_root_element().is_null())
	{
		std::vector<CSSLayoutNode> stack;
		stack.push_back(get_root_element());
		while (!stack.empty())
		{
			if (stack.back().is_element() && stack.back().to_element().get_name() == name)
				return stack.back().to_element();

			CSSLayoutNode next = stack.back().get_first_child();
			if (!next.is_null())
			{
				stack.push_back(next);
			}
			else
			{
				while (!stack.empty())
				{
					next = stack.back().get_next_sibling();
					if (next.is_null())
					{
						stack.pop_back();
					}
					else
					{
						stack.back() = next;
						break;
					}
				}
			}
		}
		return CSSLayoutElement();
	}
	else
	{
		return CSSLayoutElement();
	}
}