[gxml] Text.vala: make use of new check_index_size from parent class CharacterData



commit fa002bd140c160d50b657e85dd81e144820ed37c
Author: Richard Schwarting <aquarichy gmail com>
Date:   Sat Jul 27 00:01:53 2013 -0400

    Text.vala: make use of new check_index_size from parent class CharacterData

 gxml/Text.vala |   12 ++++++------
 1 files changed, 6 insertions(+), 6 deletions(-)
---
diff --git a/gxml/Text.vala b/gxml/Text.vala
index 2c4aca9..82598ea 100644
--- a/gxml/Text.vala
+++ b/gxml/Text.vala
@@ -75,20 +75,20 @@ namespace GXml {
                 * the first part, as the spec wants.
                 */
                public Text split_text (ulong offset) {
+                       Text other;
+
                        /* libxml2 doesn't handle this directly, in part because it doesn't
                           allow Text siblings.  Boo! */
-                       if (offset < 0 || this.length < offset) {
-                               GLib.warning ("INDEX_SIZE_ERR: split_text called with offset '%lu' on string 
of length '%lu'", offset, this.length); // i18n
-                               //this.owner_document.last_error = new DomError.INDEX_SIZE ("Offset '%u' is 
invalid for string of length '%u'", offset, this.length); // i18n
-                               return null;
+                       if (! this.check_index_size ("split_text", this.data.length, offset, null)) {
+                               return null; // perhaps return "" Text
                        }
 
-                       Text other = this.owner_document.create_text_node (this.data.substring 
((long)offset));
+                       other = this.owner_document.create_text_node (this.data.substring ((long)offset));
                        this.data = this.data.substring (0, (long)offset);
 
                        /* TODO: Ugh, can't actually let them be siblings in the tree, as
                                 the spec requests, because libxml2 automatically merges Text
-                                sibligns. */
+                                siblings. */
                        /* this.node->add_next_sibling (other.node); */
 
                        return other;


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]