[gxml] Set owned getter DomNonDocumentTypeChildNode.previous/next_element_sibling
- From: Daniel Espinosa Ortiz <despinosa src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gxml] Set owned getter DomNonDocumentTypeChildNode.previous/next_element_sibling
- Date: Mon, 4 Sep 2017 04:33:45 +0000 (UTC)
commit 8d391689b5b0d728fe8612e8735fca4c37c0bdad
Author: Yannick Inizan <inizan yannick gmail com>
Date: Sat Sep 2 18:21:14 2017 -0500
Set owned getter DomNonDocumentTypeChildNode.previous/next_element_sibling
gxml/DomCollections.vala | 4 ++--
gxml/GXmlChildNode.vala | 26 ++++++++++++++++----------
gxml/GomElement.vala | 26 ++++++++++++++++----------
gxml/GomText.vala | 26 ++++++++++++++++----------
4 files changed, 50 insertions(+), 32 deletions(-)
---
diff --git a/gxml/DomCollections.vala b/gxml/DomCollections.vala
index 84efb0e..ab16d06 100644
--- a/gxml/DomCollections.vala
+++ b/gxml/DomCollections.vala
@@ -58,8 +58,8 @@ public interface GXml.DomParentNode : GLib.Object {
}
public interface GXml.DomNonDocumentTypeChildNode : GLib.Object {
- public abstract DomElement? previous_element_sibling { get; }
- public abstract DomElement? next_element_sibling { get; }
+ public abstract DomElement? previous_element_sibling { owned get; }
+ public abstract DomElement? next_element_sibling { owned get; }
}
public interface GXml.DomChildNode : GLib.Object {
diff --git a/gxml/GXmlChildNode.vala b/gxml/GXmlChildNode.vala
index f2850fc..19de0e3 100644
--- a/gxml/GXmlChildNode.vala
+++ b/gxml/GXmlChildNode.vala
@@ -41,25 +41,31 @@ public class GXml.GNonDocumentChildNode : GXml.GChildNode,
// DomNonDocumentTypeChildNode
public DomElement? previous_element_sibling {
- get {
+ owned get {
if (parent_node != null) {
var i = parent_node.child_nodes.index_of (this);
- if (i == 0) return null;
- var n = parent_node.child_nodes.item (i - 1);
- if (n is DomElement) return (DomElement) n;
- return null;
+ if (i == 0)
+ return null;
+ for (var j = i; j >= 1; j--) {
+ var n = parent_node.child_nodes.item (j - 1);
+ if (n is DomElement)
+ return n as DomElement;
+ }
}
return null;
}
}
public DomElement? next_element_sibling {
- get {
+ owned get {
if (parent_node != null) {
var i = parent_node.child_nodes.index_of (this);
- if (i == parent_node.child_nodes.length - 1) return null;
- var n = parent_node.child_nodes.item (i + 1);
- if (n is DomElement) return (DomElement) n;
- return null;
+ if (i == parent_node.child_nodes.length - 1)
+ return null;
+ for (var j = i; j < parent_node.child_nodes.length - 1; j--) {
+ var n = parent_node.child_nodes.item (j + 1);
+ if (n is DomElement)
+ return (DomElement) n;
+ }
}
return null;
}
diff --git a/gxml/GomElement.vala b/gxml/GomElement.vala
index 959ca79..ef2436d 100644
--- a/gxml/GomElement.vala
+++ b/gxml/GomElement.vala
@@ -220,25 +220,31 @@ public class GXml.GomElement : GomNode,
}
// DomNonDocumentTypeChildNode
public DomElement? previous_element_sibling {
- get {
+ owned get {
if (parent_node != null) {
var i = parent_node.child_nodes.index_of (this);
- if (i == 0) return null;
- var n = parent_node.child_nodes.item (i - 1);
- if (n is DomElement) return (DomElement) n;
- return null;
+ if (i == 0)
+ return null;
+ for (var j = i; j >= 1; j--) {
+ var n = parent_node.child_nodes.item (j - 1);
+ if (n is DomElement)
+ return n as DomElement;
+ }
}
return null;
}
}
public DomElement? next_element_sibling {
- get {
+ owned get {
if (parent_node != null) {
var i = parent_node.child_nodes.index_of (this);
- if (i == parent_node.child_nodes.length - 1) return null;
- var n = parent_node.child_nodes.item (i + 1);
- if (n is DomElement) return (DomElement) n;
- return null;
+ if (i == parent_node.child_nodes.length - 1)
+ return null;
+ for (var j = i; j < parent_node.child_nodes.length - 1; j--) {
+ var n = parent_node.child_nodes.item (j + 1);
+ if (n is DomElement)
+ return (DomElement) n;
+ }
}
return null;
}
diff --git a/gxml/GomText.vala b/gxml/GomText.vala
index ef21278..f5215fb 100644
--- a/gxml/GomText.vala
+++ b/gxml/GomText.vala
@@ -41,25 +41,31 @@ public class GXml.GomCharacterData : GomNode,
}
// DomNonDocumentTypeChildNode
public DomElement? previous_element_sibling {
- get {
+ owned get {
if (parent_node != null) {
var i = parent_node.child_nodes.index_of (this);
- if (i == 0) return null;
- var n = parent_node.child_nodes.item (i - 1);
- if (n is DomElement) return (DomElement) n;
- return null;
+ if (i == 0)
+ return null;
+ for (var j = i; j >= 1; j--) {
+ var n = parent_node.child_nodes.item (j - 1);
+ if (n is DomElement)
+ return n as DomElement;
+ }
}
return null;
}
}
public DomElement? next_element_sibling {
- get {
+ owned get {
if (parent_node != null) {
var i = parent_node.child_nodes.index_of (this);
- if (i == parent_node.child_nodes.length - 1) return null;
- var n = parent_node.child_nodes.item (i + 1);
- if (n is DomElement) return (DomElement) n;
- return null;
+ if (i == parent_node.child_nodes.length - 1)
+ return null;
+ for (var j = i; j < parent_node.child_nodes.length - 1; j--) {
+ var n = parent_node.child_nodes.item (j + 1);
+ if (n is DomElement)
+ return (DomElement) n;
+ }
}
return null;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]