diff options
author | Marco Pesenti Gritti <marco@it.gnome.org> | 2003-01-02 04:08:38 +0800 |
---|---|---|
committer | Marco Pesenti Gritti <mpeseng@src.gnome.org> | 2003-01-02 04:08:38 +0800 |
commit | 2a830a379ab4c38b512ee521ccf10ba9cb28da53 (patch) | |
tree | 5ab90ff00c245743162cbf9f42951ca12c7cc090 /embed/mozilla/EphyWrapper.cpp | |
parent | 66677ed1062c18fd63cb13ea9480343a01058c96 (diff) | |
download | gsoc2013-epiphany-2a830a379ab4c38b512ee521ccf10ba9cb28da53.tar gsoc2013-epiphany-2a830a379ab4c38b512ee521ccf10ba9cb28da53.tar.gz gsoc2013-epiphany-2a830a379ab4c38b512ee521ccf10ba9cb28da53.tar.bz2 gsoc2013-epiphany-2a830a379ab4c38b512ee521ccf10ba9cb28da53.tar.lz gsoc2013-epiphany-2a830a379ab4c38b512ee521ccf10ba9cb28da53.tar.xz gsoc2013-epiphany-2a830a379ab4c38b512ee521ccf10ba9cb28da53.tar.zst gsoc2013-epiphany-2a830a379ab4c38b512ee521ccf10ba9cb28da53.zip |
Cleanup unused code. Reorder build. In new bookmark dialog enter activate
2003-01-01 Marco Pesenti Gritti <marco@it.gnome.org>
* embed/Makefile.am:
* embed/ephy-embed-favicon.c: (location_changed_cb), (favicon_cb):
* embed/ephy-embed-popup.c: (embed_popup_copy_location_cmd),
(embed_popup_save_page_as_cmd), (embed_popup_open_frame_cmd):
* embed/ephy-embed-shell.c: (ephy_embed_shell_free_cookies):
* embed/ephy-embed-shell.h:
* embed/ephy-embed-utils.c: (ephy_embed_utils_save):
* embed/ephy-embed.c: (ephy_embed_get_location),
(ephy_embed_shistory_copy):
* embed/ephy-embed.h:
* embed/mozilla/EphyWrapper.cpp:
* embed/mozilla/EphyWrapper.h:
* embed/mozilla/Makefile.am:
* embed/mozilla/mozilla-embed-shell.cpp:
* embed/mozilla/mozilla-embed.cpp:
* lib/Makefile.am:
* lib/toolbar/Makefile.am:
* lib/widgets/Makefile.am:
* src/Makefile.am:
* src/bookmarks/ephy-new-bookmark.c: (build_editing_table):
* src/ephy-nautilus-view.c: (gnv_embed_location_cb),
(gnv_popup_cmd_frame_in_new_window):
* src/ephy-shell.c: (build_homepage_url):
* src/ephy-tab.c: (ephy_tab_location_cb):
* src/pdm-dialog.c: (pdm_dialog_cookie_add):
* src/popup-commands.c: (popup_cmd_frame_in_new_tab),
(popup_cmd_frame_in_new_window):
Cleanup unused code.
Reorder build.
In new bookmark dialog enter activate ok.
Diffstat (limited to 'embed/mozilla/EphyWrapper.cpp')
-rw-r--r-- | embed/mozilla/EphyWrapper.cpp | 574 |
1 files changed, 0 insertions, 574 deletions
diff --git a/embed/mozilla/EphyWrapper.cpp b/embed/mozilla/EphyWrapper.cpp index ade9e67b2..716b5e75c 100644 --- a/embed/mozilla/EphyWrapper.cpp +++ b/embed/mozilla/EphyWrapper.cpp @@ -671,26 +671,6 @@ nsresult EphyWrapper::GetDocumentUrl (nsCString &url) return NS_OK; } -nsresult EphyWrapper::GetDocumentTitle (char **title) -{ - nsresult result; - - nsCOMPtr<nsIDOMDocument> DOMDocument; - - result = GetDOMDocument (getter_AddRefs(DOMDocument)); - if (NS_FAILED(result) || !DOMDocument) return NS_ERROR_FAILURE; - - nsCOMPtr<nsIDocument> doc = do_QueryInterface(DOMDocument); - if(!doc) return NS_ERROR_FAILURE; - - const nsString* t; - t = doc->GetDocumentTitle(); - - *title = g_strdup (NS_ConvertUCS2toUTF8(*t).get()); - - return NS_OK; -} - nsresult EphyWrapper::CopyHistoryTo (EphyWrapper *dest) { nsresult result; @@ -809,566 +789,12 @@ nsresult EphyWrapper::Paste(void) return clipboard->Paste (); } -nsresult EphyWrapper::GetLinkInterfaceItems (GList **list) -{ -#ifdef NOT_PORTED - nsresult result; - PRUint32 links_count; - - /* we accept these rel=.. elements, specified by the w3c */ - const gchar *rel_types[] = { - "START", "NEXT", "PREV", "PREVIOUS", "CONTENTS", "TOC", "INDEX", - "GLOSSARY", "COPYRIGHT", "CHAPTER", "SECTION", - "SUBSECTION", "APPENDIX", "HELP", "TOP", "SEARCH", "MADE", - "BOOKMARK", "HOME", - NULL /* terminator, must be last */ - }; - - nsCOMPtr<nsIDOMDocument> DOMDocument; - result = GetMainDOMDocument (getter_AddRefs(DOMDocument)); - if (NS_FAILED(result) || !DOMDocument) return NS_ERROR_FAILURE; - - /* get list of link elements*/ - NS_NAMED_LITERAL_STRING(strname, "LINK"); - - nsCOMPtr<nsIDOMNodeList> links; - result = aDOMDocument->GetElementsByTagName (strname, - getter_AddRefs (links)); - if (NS_FAILED (result)) return NS_ERROR_FAILURE; - - result = links->GetLength (&links_count); - if (NS_FAILED (result)) return NS_ERROR_FAILURE; - - for (PRUint32 i = 0; i < links_count; i++) - { - /* get to the link element */ - nsCOMPtr<nsIDOMNode> link; - result = links->Item (i, getter_AddRefs (link)); - if (NS_FAILED (result)) return NS_ERROR_FAILURE; - - nsCOMPtr<nsIDOMElement> linkElement; - linkElement = do_QueryInterface (aLink); - if (!linkElement) return NS_ERROR_FAILURE; - - /* get rel=.. element */ - NS_NAMED_LITERAL_STRING(attr_rel, "rel"); - nsAutoString value; - linkElement->GetAttribute (attr_rel, value); - - if (value.IsEmpty()) - { - NS_NAMED_LITERAL_STRING(attr_rev, "rev"); - linkElement->GetAttribute (attr_rev, value); - if (value.IsEmpty()) continue; - } - - nsCString relstr = NS_ConvertUCS2toUTF8(value); - ToUpperCase(relstr); - - /* check for elements we want */ - for (gint j = 0; (rel_types[j] != NULL); j++) - { - if (strcmp (relstr.get(), rel_types[j]) == 0) - { - /* found one! */ - LinkInterfaceItem *lti = - g_new0 (LinkInterfaceItem, 1); - - /* fill in struct */ - lti->type = (LinkInterfaceItemType) j; - - /* get href=.. element */ - NS_NAMED_LITERAL_STRING(attr_href, "href"); - nsAutoString value; - linkElement->GetAttribute (attr_href, value); - - if (value.IsEmpty()) - { - g_free (lti); - continue; - } - - /* resolve uri */ - nsCOMPtr<nsIDocument> doc = - do_QueryInterface (aDOMDocument); - if(!doc) return NS_ERROR_FAILURE; - - nsCOMPtr<nsIURI> uri; - doc->GetDocumentURL(getter_AddRefs(uri)); - - const nsACString &link = NS_ConvertUCS2toUTF8(value); - nsCAutoString href; - result = uri->Resolve (link, href); - if (NS_FAILED (result)) return NS_ERROR_FAILURE; - lti->href = g_strdup (href.get()); - - /* append to list of items */ - *list = g_list_append (*list, lti); - - /* get optional title=... element */ - NS_NAMED_LITERAL_STRING(attr_title, "title"); - linkElement->GetAttribute (attr_title, value); - if (value.IsEmpty()) continue; - - const nsACString &title = NS_ConvertUCS2toUTF8 (value); - lti->title = gul_string_strip_newline (PromiseFlatCString(title).get()); - } - } - } -#endif - return NS_OK; -} - -nsresult EphyWrapper::GetRealURL (nsCString &ret) -{ - nsresult result; - - nsCOMPtr<nsIDocShell> DocShell; - result = GetDocShell (getter_AddRefs(DocShell)); - if (NS_FAILED(result) || !DocShell) return NS_ERROR_FAILURE; - - nsCOMPtr<nsIWebNavigation> ContentNav = do_QueryInterface (DocShell, - &result); - if (!ContentNav) return NS_ERROR_FAILURE; - - nsCOMPtr<nsIURI> uri; - result = ContentNav->GetCurrentURI (getter_AddRefs(uri)); - if (!NS_SUCCEEDED(result) || (!uri)) return NS_ERROR_FAILURE; - - result = uri->GetSpec(ret); - if (!NS_SUCCEEDED(result) || ret.IsEmpty()) return NS_ERROR_FAILURE; - - return NS_OK; -} - nsresult EphyWrapper::SelectAll (void) { nsCOMPtr<nsIClipboardCommands> clipboard (do_GetInterface(mWebBrowser)); return clipboard->SelectAll (); } -nsresult EphyWrapper::ScrollUp (void) -{ - nsresult result; - - nsCOMPtr<nsIDOMWindow> DOMWindow; - result = GetFocusedDOMWindow (getter_AddRefs(DOMWindow)); - if (NS_FAILED(result) || !DOMWindow) return NS_ERROR_FAILURE; - - DOMWindow->ScrollByLines(-1); - - return NS_OK; -} - -nsresult EphyWrapper::ScrollDown (void) -{ - nsresult result; - - nsCOMPtr<nsIDOMWindow> DOMWindow; - result = GetFocusedDOMWindow (getter_AddRefs(DOMWindow)); - if (NS_FAILED(result) || !DOMWindow) return NS_ERROR_FAILURE; - - DOMWindow->ScrollByLines(1); - - return NS_OK; -} - -nsresult EphyWrapper::ScrollLeft (void) -{ - nsresult result; - - nsCOMPtr<nsIDOMWindow> DOMWindow; - result = GetFocusedDOMWindow (getter_AddRefs(DOMWindow)); - if (NS_FAILED(result) || !DOMWindow) return NS_ERROR_FAILURE; - - DOMWindow->ScrollBy(-16, 0); - - return NS_OK; -} - -nsresult EphyWrapper::ScrollRight (void) -{ - nsresult result; - - nsCOMPtr<nsIDOMWindow> DOMWindow; - result = GetFocusedDOMWindow (getter_AddRefs(DOMWindow)); - if (NS_FAILED(result) || !DOMWindow) return NS_ERROR_FAILURE; - - DOMWindow->ScrollBy(16, 0); - - return NS_OK; -} - -nsresult EphyWrapper::FineScroll (int horiz, int vert) -{ - nsresult result; - - nsCOMPtr<nsIDOMWindow> DOMWindow; - result = GetFocusedDOMWindow (getter_AddRefs(DOMWindow)); - if (NS_FAILED(result) || !DOMWindow) return NS_ERROR_FAILURE; - - DOMWindow->ScrollBy(horiz, vert); - - return NS_OK; -} - -nsresult EphyWrapper::GetLastModified (gchar **ret) -{ - nsresult result; - - nsCOMPtr<nsIDOMDocument> DOMDocument; - - result = GetDOMDocument (getter_AddRefs(DOMDocument)); - if (NS_FAILED(result) || !DOMDocument) return NS_ERROR_FAILURE; - - nsCOMPtr<nsIDOMNSHTMLDocument> doc = do_QueryInterface(DOMDocument); - if(!doc) return NS_ERROR_FAILURE; - - nsAutoString value; - doc->GetLastModified(value); - - *ret = g_strdup (NS_ConvertUCS2toUTF8(value).get()); - - return NS_OK; -} - -nsresult EphyWrapper::GetImages (GList **ret) -{ -#ifdef NOT_PORTED - nsresult result; - GHashTable *hash = g_hash_table_new (g_str_hash, g_str_equal); - - nsCOMPtr<nsIDOMDocument> DOMDocument; - - result = GetDOMDocument (getter_AddRefs(DOMDocument)); - if (NS_FAILED(result) || !DOMDocument) return NS_ERROR_FAILURE; - - nsCOMPtr<nsIDOMHTMLDocument> doc = do_QueryInterface(DOMDocument); - if(!doc) return NS_ERROR_FAILURE; - - nsCOMPtr<nsIDOMHTMLCollection> col; - doc->GetImages(getter_AddRefs(col)); - - PRUint32 count, i; - col->GetLength(&count); - for (i = 0; i < count; i++) - { - nsCOMPtr<nsIDOMNode> node; - col->Item(i, getter_AddRefs(node)); - if (!node) continue; - - nsCOMPtr<nsIDOMHTMLElement> element; - element = do_QueryInterface(node); - if (!element) continue; - - nsCOMPtr<nsIDOMHTMLImageElement> img; - img = do_QueryInterface(element); - if (!img) continue; - - ImageListItem *item = g_new0 (ImageListItem, 1); - - nsAutoString tmp; - result = img->GetSrc (tmp); - if (NS_SUCCEEDED(result)) - { - const nsACString &c = NS_ConvertUCS2toUTF8(tmp); - if (g_hash_table_lookup (hash, PromiseFlatCString(c).get())) - { - g_free (item); - continue; - } - item->url = g_strdup (c.get()); - g_hash_table_insert (hash, item->url, - GINT_TO_POINTER (TRUE)); - } - result = img->GetAlt (tmp); - if (NS_SUCCEEDED(result)) - { - const nsACString &c = NS_ConvertUCS2toUTF8(tmp); - item->alt = gul_string_strip_newline (PromiseFlatCString(c).get()); - } - result = element->GetTitle (tmp); - if (NS_SUCCEEDED(result)) - { - const nsACString &c = NS_ConvertUCS2toUTF8(tmp); - item->title = gul_string_strip_newline (PromiseFlatCString(c).get()); - } - result = img->GetWidth (&(item->width)); - result = img->GetHeight (&(item->height)); - - *ret = g_list_append (*ret, item); - } - - g_hash_table_destroy (hash); -#endif - return NS_OK; -} - -nsresult EphyWrapper::GetForms (GList **ret) -{ -#ifdef NOT_PORTED - nsresult result; - - nsCOMPtr<nsIDOMDocument> DOMDocument; - - result = GetDOMDocument (getter_AddRefs(DOMDocument)); - if (NS_FAILED(result) || !DOMDocument) return NS_ERROR_FAILURE; - - nsCOMPtr<nsIDOMHTMLDocument> doc = do_QueryInterface(DOMDocument); - if(!doc) return NS_ERROR_FAILURE; - - nsCOMPtr<nsIDOMHTMLCollection> col; - doc->GetForms(getter_AddRefs(col)); - - PRUint32 count, i; - col->GetLength(&count); - for (i = 0; i < count; i++) - { - nsCOMPtr<nsIDOMNode> node; - col->Item(i, getter_AddRefs(node)); - if (!node) continue; - - nsCOMPtr<nsIDOMHTMLElement> element; - element = do_QueryInterface(node); - if (!element) continue; - - nsCOMPtr<nsIDOMHTMLFormElement> form; - form = do_QueryInterface(element); - if (!form) continue; - - FormListItem *item = g_new0 (FormListItem, 1); - - nsAutoString tmp; - result = form->GetAction (tmp); - if (NS_SUCCEEDED(result)) - { - nsCOMPtr<nsIDocument> doc = - do_QueryInterface (aDOMDocument); - if(!doc) return NS_ERROR_FAILURE; - - nsCOMPtr<nsIURI> uri; - doc->GetDocumentURL(getter_AddRefs(uri)); - - const nsACString &s = NS_ConvertUTF8toUCS2(tmp); - nsCAutoString c; - result = uri->Resolve (c, s); - - item->action = s.Length() ? g_strdup (s.get()) : g_strdup (c.get()); - } - result = form->GetMethod (tmp); - if (NS_SUCCEEDED(result)) - { - const nsACString &c = NS_ConvertUTF8toUCS2(tmp); - item->method = g_strdup (PromiseFlatCString(c).get()); - } - result = form->GetName (tmp); - if (NS_SUCCEEDED(result)) - { - const nsACString &c = NS_ConvertUTF8toUCS2(tmp); - item->name = g_strdup (PromiseFlatCString(c).get()); - } - - *ret = g_list_append (*ret, item); - } -#endif - return NS_OK; -} - -nsresult EphyWrapper::GetLinks (GList **ret) -{ -#ifdef NOT_PORTED - nsresult result; - - nsCOMPtr<nsIDOMDocument> DOMDocument; - result = GetMainDOMDocument (getter_AddRefs(DOMDocument)); - if (NS_FAILED(result) || !DOMDocument) return NS_ERROR_FAILURE; - - /* first, get a list of <link> elements */ - PRUint32 links_count; - - NS_NAMED_LITERAL_STRING(strname, "LINK"); - - nsCOMPtr<nsIDOMNodeList> links; - result = DOMDocument->GetElementsByTagName (strname, - getter_AddRefs (links)); - if (NS_FAILED (result)) return NS_ERROR_FAILURE; - - result = aLinks->GetLength (&links_count); - if (NS_FAILED (result)) return NS_ERROR_FAILURE; - - for (PRUint32 i = 0; i < links_count; i++) - { - nsCOMPtr<nsIDOMNode> link; - result = links->Item (i, getter_AddRefs (link)); - if (NS_FAILED (result)) continue; - - nsCOMPtr<nsIDOMElement> linkElement; - linkElement = do_QueryInterface (link); - if (!linkElement) continue; - - NS_NAMED_LITERAL_STRING(attr_href, "href"); - nsAutoString value; - linkElement->GetAttribute (attr_href, value); - if (value.IsEmpty()) continue; - - const nsACString &link = NS_ConvertUCS2toUTF8(value); - - if (link.IsEmpty()) continue; - - nsCOMPtr<nsIDocument> doc = - do_QueryInterface (aDOMDocument); - if(!doc) continue; - - nsCOMPtr<nsIURI> uri; - doc->GetDocumentURL(getter_AddRefs(uri)); - - nsCAutoString tmp; - result = uri->Resolve (link, tmp); - - LinkListItem *i = g_new0 (LinkListItem, 1); - - if (!tmp.IsEmpty()) - { - i->url = g_strdup (tmp.get()); - } - else - { - i->url = g_strdup (link.get()); - } - - NS_NAMED_LITERAL_STRING(attr_title, "title"); - linkElement->GetAttribute (attr_title, value); - if (!value.IsEmpty()) - { - const nsACString &s = NS_ConvertUCS2toUTF8(value); - i->title = gul_string_strip_newline (PromiseFlatCString(s).get()); - } - - NS_NAMED_LITERAL_STRING(attr_rel, "rel"); - linkElement->GetAttribute (attr_rel, value); - if (!value.IsEmpty()) - { - const nsACString &s = NS_ConvertUCS2toUTF8(value); - i->rel = g_strdup (PromiseFlatCString(s).get()); - g_strdown (i->rel); - } - if (!i->rel || strlen (i->rel) == 0) - { - NS_NAMED_LITERAL_STRING(attr_rev, "rev"); - linkElement->GetAttribute (attr_rev, value); - if (!value.IsEmpty()) - { - const nsACString &s = NS_ConvertUCS2toUTF8(value); - i->rel = g_strdup (PromiseFlatCString(s).get()); - g_strdown (i->rel); - } - } - - *ret = g_list_append (*ret, i); - } - - /* next, get a list of anchors */ - nsCOMPtr<nsIDOMHTMLDocument> doc = do_QueryInterface(aDOMDocument); - if(!doc) return NS_ERROR_FAILURE; - - nsCOMPtr<nsIDOMHTMLCollection> col; - doc->GetLinks(getter_AddRefs(col)); - - PRUint32 count, i; - col->GetLength(&count); - for (i = 0; i < count; i++) - { - nsCOMPtr<nsIDOMNode> node; - col->Item(i, getter_AddRefs(node)); - if (!node) continue; - - nsCOMPtr<nsIDOMHTMLElement> element; - element = do_QueryInterface(node); - if (!element) continue; - - nsCOMPtr<nsIDOMHTMLAnchorElement> lnk; - lnk = do_QueryInterface(element); - if (!lnk) continue; - - LinkListItem *i = g_new0 (LinkListItem, 1); - - nsAutoString tmp; - - result = lnk->GetHref (tmp); - if (NS_SUCCEEDED(result)) - { - const nsACString &c = NS_ConvertUCS2toUTF8(tmp); - i->url = g_strdup (PromiseFlatCString(c).get()); - } - - result = lnk->GetRel (tmp); - if (NS_SUCCEEDED(result)) - { - const nsACString &c = NS_ConvertUCS2toUTF8(tmp); - i->rel = g_strdup (PromiseFlatCString(c).get()); - g_strdown (i->rel); - } - - if (!i->rel || strlen (i->rel) == 0) - { - result = lnk->GetRev (tmp); - if (NS_SUCCEEDED(result)) - { - const nsACString &c = NS_ConvertUCS2toUTF8(tmp); - i->rel = g_strdup (PromiseFlatCString(c).get()); - g_strdown (i->rel); - } - } - - i->title = mozilla_get_link_text (node); - if (i->title == NULL) - { - result = element->GetTitle (tmp); - if (NS_SUCCEEDED(result)) - { - const nsACString &c = NS_ConvertUCS2toUTF8(tmp); - i->title = gul_string_strip_newline (PromiseFlatCString(c).get()); - } - } - - - *ret = g_list_append (*ret, i); - } -#endif - return NS_OK; -} - -nsresult EphyWrapper::EvaluateJS (char *script) -{ - nsresult rv; - - nsCOMPtr<nsIDOMWindow> DOMWindow; - rv = mWebBrowser->GetContentDOMWindow(getter_AddRefs(DOMWindow)); - - nsCOMPtr<nsIScriptGlobalObject> globalObject; - globalObject = do_QueryInterface (DOMWindow); - if (!globalObject) return NS_ERROR_FAILURE; - - nsCOMPtr<nsIScriptContext> context; - rv = globalObject->GetContext(getter_AddRefs(context)); - if (NS_FAILED(rv) || !context) { - return NS_ERROR_FAILURE; - } - - context->SetProcessingScriptTag(PR_TRUE); - - PRBool isUndefined; - nsAutoString ret; - const nsAString &aScript = NS_ConvertUTF8toUCS2(script); - context->EvaluateString(aScript, nsnull, nsnull, nsnull, - 0, nsnull, - ret, &isUndefined); - - context->SetProcessingScriptTag(PR_FALSE); - - return NS_OK; -} - nsresult EphyWrapper::PushTargetDocument (nsIDOMDocument *domDoc) { mTargetDocument = domDoc; |