summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/treebuilder/in_column_group.c97
1 files changed, 97 insertions, 0 deletions
diff --git a/src/treebuilder/in_column_group.c b/src/treebuilder/in_column_group.c
new file mode 100644
index 0000000..35043b8
--- /dev/null
+++ b/src/treebuilder/in_column_group.c
@@ -0,0 +1,97 @@
+/*
+ * This file is part of Hubbub.
+ * Licensed under the MIT License,
+ * http://www.opensource.org/licenses/mit-license.php
+ * Copyright 2008 Andrew Sidwell
+ */
+
+#include <assert.h>
+#include <string.h>
+
+#include "treebuilder/modes.h"
+#include "treebuilder/internal.h"
+#include "treebuilder/treebuilder.h"
+#include "utils/utils.h"
+
+
+/**
+ * Handle tokens in "in column group" insertion mode
+ *
+ * \param treebuilder The treebuilder instance
+ * \param token The token to process
+ * \return True to reprocess the token, false otherwise
+ */
+bool handle_in_column_group(hubbub_treebuilder *treebuilder,
+ const hubbub_token *token)
+{
+ bool reprocess = false;
+ bool handled = false;
+
+ switch (token->type) {
+ case HUBBUB_TOKEN_CHARACTER:
+ if (process_characters_expect_whitespace(treebuilder,
+ token, true)) {
+ reprocess = true;
+ }
+ break;
+ case HUBBUB_TOKEN_COMMENT:
+ process_comment_append(treebuilder, token,
+ treebuilder->context.element_stack[
+ treebuilder->context.current_node].node);
+ break;
+ case HUBBUB_TOKEN_DOCTYPE:
+ /** \todo parse error */
+ break;
+ case HUBBUB_TOKEN_START_TAG:
+ {
+ element_type type = element_type_from_name(treebuilder,
+ &token->data.tag.name);
+
+ if (type == HTML) {
+ /* Process as if "in body" */
+ process_tag_in_body(treebuilder, token);
+ } else if (type == COL) {
+ insert_element_no_push(treebuilder, &token->data.tag);
+
+ /** \todo ack sc flag */
+ } else {
+ reprocess = true;
+ }
+ }
+ break;
+ case HUBBUB_TOKEN_END_TAG:
+ {
+ element_type type = element_type_from_name(treebuilder,
+ &token->data.tag.name);
+
+ if (type == COLGROUP) {
+ /** \todo fragment case */
+ handled = true;
+ } else if (type == COL) {
+ /** \todo parse error */
+ } else {
+ reprocess = true;
+ }
+ }
+ break;
+ case HUBBUB_TOKEN_EOF:
+ /** \todo fragment case */
+ reprocess = true;
+ break;
+ }
+
+ if (handled || reprocess) {
+ element_type otype;
+ void *node;
+
+ /* Pop the current node (which will be a colgroup) */
+ if (!element_stack_pop(treebuilder, &otype, &node)) {
+ /** \todo errors */
+ }
+
+ treebuilder->context.mode = IN_TABLE;
+ }
+
+ return reprocess;
+}
+