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

Back to archive index

Hiroyuki Ikezoe ikezo****@users*****
Tue Apr 25 12:46:33 JST 2006


Index: kazehakase/src/mozilla/kz-mozwrapper.cpp
diff -u kazehakase/src/mozilla/kz-mozwrapper.cpp:1.110 kazehakase/src/mozilla/kz-mozwrapper.cpp:1.111
--- kazehakase/src/mozilla/kz-mozwrapper.cpp:1.110	Tue Apr 25 10:28:01 2006
+++ kazehakase/src/mozilla/kz-mozwrapper.cpp	Tue Apr 25 12:46:32 2006
@@ -1559,8 +1559,6 @@
 	nsresult rv;
 	PRUint32 num = 0;
 	gboolean flag = FALSE;
-	const PRUnichar aLiteral[] = { 'a', '\0' };
-
         // get frame window
         nsCOMPtr<nsIDOMWindowCollection> frames;
         domWindow->GetFrames(getter_AddRefs(frames));
@@ -1576,60 +1574,69 @@
 		{
 			nsCOMPtr<nsIDOMWindow> childWindow;
 	                frames->Item(i, getter_AddRefs(childWindow));
-	                rv = GetLinksFromWindow(childWindow, list,
-					        NULL, TRUE);
+	                rv = GetAnchorsFromWindow(childWindow, list);
 	        	if (NS_SUCCEEDED(rv))
 				flag |= TRUE;
 		}
 	}
 	else
 	{
-		nsCOMPtr<nsIDOMDocument> domDoc;
-		domWindow->GetDocument(getter_AddRefs(domDoc));
+	        rv = GetAnchorsFromWindow(domWindow, list);
+	       	if (NS_SUCCEEDED(rv))
+			flag |= TRUE;
+	}
 
-		nsCOMPtr<nsIDOMNodeList> nodeList;
-		rv = domDoc->GetElementsByTagName(nsEmbedString(aLiteral),
-						  getter_AddRefs(nodeList));
-	        if (NS_FAILED(rv) || !nodeList) return NS_ERROR_FAILURE;
+	return flag ? NS_OK : NS_ERROR_FAILURE;
+}
 
-		PRUint32 num;
-		rv = nodeList->GetLength(&num);
-		if (NS_FAILED(rv) || num < 1) return NS_ERROR_FAILURE;
+nsresult
+KzMozWrapper::GetAnchorsFromWindow (nsIDOMWindow *domWindow,
+				    GList **list)
+{
+	nsresult rv;
+	gboolean flag = FALSE;
+	const PRUnichar aLiteral[] = { 'a', '\0' };
 
-		// 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;
+	nsCOMPtr<nsIDOMDocument> domDoc;
+	domWindow->GetDocument(getter_AddRefs(domDoc));
 
-			// 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;
-			nsEmbedCString cValue,cURI;
-			cValue.Assign("#");
-			cValue.Append(value, strlen(value));
-			g_free(value);
-
-			ResolveURI(domDoc, cValue, cURI);
-
-			uri = g_strdup(cURI.get());
-
-			KzBookmark *link;
-			link = kz_bookmark_new_with_attrs(NULL, uri, NULL);
-			*list = g_list_append(*list, link);
-			g_free(uri);
+	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;
 
-			flag |= TRUE;
-		}
-	}
+	// 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);
 
+		flag = TRUE;
+	}
+	
 	return flag ? NS_OK : NS_ERROR_FAILURE;
 }
 
Index: kazehakase/src/mozilla/kz-mozwrapper.h
diff -u kazehakase/src/mozilla/kz-mozwrapper.h:1.51 kazehakase/src/mozilla/kz-mozwrapper.h:1.52
--- kazehakase/src/mozilla/kz-mozwrapper.h:1.51	Fri Apr 21 14:56:54 2006
+++ kazehakase/src/mozilla/kz-mozwrapper.h	Tue Apr 25 12:46:33 2006
@@ -127,6 +127,8 @@
 				          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