1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143
|
/*
* Copyright 2001, 2002, 2003 Sun Microsystems Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
#include <string.h>
#include <libgtkhtml/gtkhtml.h>
#include "layout/htmlboxtext.h"
#include "layout/htmlboxinline.h"
#include "layout/htmlboxtable.h"
#include "layout/htmlboxtablecell.h"
#include "htmlboxblockaccessible.h"
#include "htmlboxblocktextaccessible.h"
#include "htmlboxblocklinkaccessible.h"
static void html_box_block_accessible_class_init (HtmlBoxBlockAccessibleClass *klass);
GType
html_box_block_accessible_get_type (void)
{
static GType type = 0;
if (!type) {
static const GTypeInfo tinfo = {
sizeof (HtmlBoxBlockAccessibleClass),
(GBaseInitFunc) NULL, /* base init */
(GBaseFinalizeFunc) NULL, /* base finalize */
(GClassInitFunc) html_box_block_accessible_class_init,
(GClassFinalizeFunc) NULL, /* class finalize */
NULL, /* class data */
sizeof (HtmlBoxBlockAccessible),
0, /* nb preallocs */
(GInstanceInitFunc) NULL, /* instance init */
NULL /* value table */
};
type = g_type_register_static (HTML_TYPE_BOX_ACCESSIBLE, "HtmlBoxBlockAccessible", &tinfo, 0);
}
return type;
}
static gboolean
contains_link (HtmlBox *root)
{
HtmlBox *box;
gboolean ret;
box = root->children;
ret = FALSE;
while (box) {
if (HTML_IS_BOX_INLINE (box)) {
DomNode *node;
node = box->dom_node;
if (node->xmlnode->name) {
if (strcasecmp ((char *)node->xmlnode->name, "a") == 0 &&
(xmlHasProp (node->xmlnode, (const unsigned char*)"href") != NULL)) {
ret = TRUE;
break;
}
}
ret = contains_link (box);
if (ret)
break;
}
box = box->next;
}
return ret;
}
static gboolean
contains_text (HtmlBox *root)
{
HtmlBox *box;
gboolean ret;
if (HTML_IS_BOX_BLOCK (root)) {
if (root->dom_node && strcmp ((char *)root->dom_node->xmlnode->name, "p") != 0) {
return FALSE;
}
}
box = root->children;
ret = FALSE;
while (box) {
if (HTML_IS_BOX_TEXT (box)) {
if (html_box_text_get_len (HTML_BOX_TEXT (box)) > 0) {
ret = TRUE;
break;
}
} else if (HTML_IS_BOX_INLINE (box)) {
ret = contains_text (box);
if (ret)
break;
}
box = box->next;
}
return ret;
}
AtkObject*
html_box_block_accessible_new (GObject *obj)
{
GObject *object;
AtkObject *atk_object;
HtmlBox *box;
g_return_val_if_fail (HTML_IS_BOX_BLOCK (obj), NULL);
box = HTML_BOX (obj);
if (contains_text (box)) {
if (contains_link (box))
atk_object = html_box_block_link_accessible_new (obj);
else
atk_object = html_box_block_text_accessible_new (obj);
} else {
object = g_object_new (HTML_TYPE_BOX_BLOCK_ACCESSIBLE, NULL);
atk_object = ATK_OBJECT (object);
atk_object_initialize (atk_object, obj);
atk_object->role = ATK_ROLE_PANEL;
}
return atk_object;
}
static void
html_box_block_accessible_class_init (HtmlBoxBlockAccessibleClass *klass)
{
}
|