[Kazehakase-cvs] CVS update: kazehakase/src/mozilla

Back to archive index

Hiroyuki Ikezoe ikezo****@users*****
Tue Apr 25 14:31:31 JST 2006


Index: kazehakase/src/mozilla/kz-mozwrapper.cpp
diff -u kazehakase/src/mozilla/kz-mozwrapper.cpp:1.111 kazehakase/src/mozilla/kz-mozwrapper.cpp:1.112
--- kazehakase/src/mozilla/kz-mozwrapper.cpp:1.111	Tue Apr 25 12:46:32 2006
+++ kazehakase/src/mozilla/kz-mozwrapper.cpp	Tue Apr 25 14:31:31 2006
@@ -1559,6 +1559,7 @@
 	nsresult rv;
 	PRUint32 num = 0;
 	gboolean flag = FALSE;
+	const PRUnichar aLiteral[] = { 'a', '\0' };
         // get frame window
         nsCOMPtr<nsIDOMWindowCollection> frames;
         domWindow->GetFrames(getter_AddRefs(frames));
@@ -1574,72 +1575,60 @@
 		{
 			nsCOMPtr<nsIDOMWindow> childWindow;
 	                frames->Item(i, getter_AddRefs(childWindow));
-	                rv = GetAnchorsFromWindow(childWindow, list);
+	                rv = GetDestAnchorsFromWindow(childWindow, list);
 	        	if (NS_SUCCEEDED(rv))
 				flag |= TRUE;
 		}
 	}
 	else
 	{
-	        rv = GetAnchorsFromWindow(domWindow, list);
-	       	if (NS_SUCCEEDED(rv))
-			flag |= TRUE;
-	}
-
-	return flag ? NS_OK : NS_ERROR_FAILURE;
-}
+		nsCOMPtr<nsIDOMDocument> domDoc;
+		domWindow->GetDocument(getter_AddRefs(domDoc));
 
-nsresult
-KzMozWrapper::GetAnchorsFromWindow (nsIDOMWindow *domWindow,
-				    GList **list)
-{
-	nsresult rv;
-	gboolean flag = FALSE;
-	const PRUnichar aLiteral[] = { 'a', '\0' };
+		nsCOMPtr<nsIDOMNodeList> nodeList;
+		rv = domDoc->GetElementsByTagName(nsEmbedString(aLiteral),
+				getter_AddRefs(nodeList));
+		if (NS_FAILED(rv) || !nodeList) return NS_ERROR_FAILURE;
 
-	nsCOMPtr<nsIDOMDocument> domDoc;
-	domWindow->GetDocument(getter_AddRefs(domDoc));
+		PRUint32 num;
+		rv = nodeList->GetLength(&num);
+		if (NS_FAILED(rv) || num < 1) return NS_ERROR_FAILURE;
 
-	nsCOMPtr<nsIDOMNodeList> nodeList;
-	rv = domDoc->GetElementsByTagName(nsEmbedString(aLiteral),
-			getter_AddRefs(nodeList));
-	if (NS_FAILED(rv) || !nodeList) return NS_ERROR_FAILURE;
-
-	PRUint32 num;
-	rv = nodeList->GetLength(&num);
-	if (NS_FAILED(rv) || num < 1) return NS_ERROR_FAILURE;
+		nsEmbedCString docURL;
+		GetDocumentUrl(docURL);
 
-	// store links to GList
-	nsCOMPtr<nsIDOMNode> node;
-	for (PRUint32 i = 0; i < num; i++)
-	{
-		rv = nodeList->Item(i, getter_AddRefs(node));
-		if (NS_FAILED(rv) || !node) continue;
+		// store links to GList
+		nsCOMPtr<nsIDOMNode> node;
+		for (PRUint32 i = 0; i < num; i++)
+		{
+			rv = nodeList->Item(i, getter_AddRefs(node));
+			if (NS_FAILED(rv) || !node) continue;
 
-		// check the node has name attribute or id attribure.
-		char *value =  NULL;
-		GetAttributeFromNode(node, "name", &value);
-		if (!value)
-			GetAttributeFromNode(node, "id", &value);
-		if (!value)
-			continue;
-
-		char *uri;
-		GetLinkFromNode(domDoc, node, &uri);
-		uri = g_strdup_printf ("%s#%s", uri, value);
-		g_free(value);
-
-		KzBookmark *link;
-		link = kz_bookmark_new_with_attrs(NULL, uri, NULL);
-		*list = g_list_append(*list, link);
-		g_free(uri);
+			// check the node has name attribute or id attribure.
+			char *value =  NULL;
+			GetAttributeFromNode(node, "name", &value);
+			if (!value)
+				GetAttributeFromNode(node, "id", &value);
+			if (!value)
+				continue;
+
+			char *uri;
+			uri = g_strdup_printf ("%s#%s", docURL.get(), value);
+			g_free(value);
+
+			KzBookmark *link;
+			link = kz_bookmark_new_with_attrs(NULL, uri, NULL);
+			*list = g_list_append(*list, link);
+			g_free(uri);
 
-		flag = TRUE;
+			flag = TRUE;
+		}
 	}
-	
+
 	return flag ? NS_OK : NS_ERROR_FAILURE;
 }
 
+
 nsresult
 KzMozWrapper::GetLinksFromWindow (nsIDOMWindow *domWindow,
 				  GList **list,
@@ -1734,7 +1723,6 @@
 	if (!NS_SUCCEEDED(result) || !attrNode)  return NS_ERROR_FAILURE;
 
 	nsEmbedString nodeValue;
-
 	result = attrNode->GetNodeValue(nodeValue);
 	if (!NS_SUCCEEDED(result))  return NS_ERROR_FAILURE;
 
@@ -1742,6 +1730,7 @@
 	NS_UTF16ToCString(nodeValue,
 			  NS_CSTRING_ENCODING_UTF8, cNodeValue);
 	*value = g_strdup(cNodeValue.get());
+
 	return NS_OK;
 }
 
@@ -1754,8 +1743,7 @@
 	// get url
 	char *hrefattr =  NULL;
 	GetAttributeFromNode(node, "href", &hrefattr);
-	if (!hrefattr) return NS_ERROR_FAILURE;	
-
+	if (!hrefattr) return NS_ERROR_FAILURE;
 
 	nsEmbedCString hrefc,linkc;
 	hrefc.Assign(hrefattr);
Index: kazehakase/src/mozilla/kz-mozwrapper.h
diff -u kazehakase/src/mozilla/kz-mozwrapper.h:1.52 kazehakase/src/mozilla/kz-mozwrapper.h:1.53
--- kazehakase/src/mozilla/kz-mozwrapper.h:1.52	Tue Apr 25 12:46:33 2006
+++ kazehakase/src/mozilla/kz-mozwrapper.h	Tue Apr 25 14:31:31 2006
@@ -127,8 +127,6 @@
 				          GList **list,
 				          nsISelection *selection, 
 				          gboolean selected_only);
-	nsresult GetAnchorsFromWindow    (nsIDOMWindow *domWindow,
-				          GList **list);
 	nsresult GetDestAnchorsFromWindow (nsIDOMWindow *domWindow,
 					   GList **list);
 	nsresult GetPostData             (nsIHistoryEntry *he,


More information about the Kazehakase-cvs mailing list
Back to archive index