
Go to the source code of this file.
Defines | |
| #define | NEXT_LINK 0 |
| #define | PREVIOUS_LINK 1 |
Enumerations | |
| enum | direction_t { pageUp_t, pageDown_t } |
Functions | |
| gboolean | mozilla_get_page_type (GtkMozEmbed *b, char **type) |
| gboolean | mozilla_save (GtkMozEmbed *b, gchar *file_name, gint all) |
| gboolean | mozilla_next_link (GtkMozEmbed *b) |
| gboolean | mozilla_previous_link (GtkMozEmbed *b) |
| gboolean | mozilla_handle_link (GtkMozEmbed *b) |
| gboolean | mozilla_overview_page (GtkMozEmbed *b) |
| gboolean | mozilla_next_page (GtkMozEmbed *b) |
| gboolean | mozilla_previous_page (GtkMozEmbed *b) |
| gboolean | mozilla_alt_page (GtkMozEmbed *b) |
| gboolean | mozilla_back (GtkMozEmbed *b) |
| gboolean | mozilla_scrollable (direction_t direction, GtkMozEmbed *b) |
| gboolean | mozilla_scroll (int count, GtkMozEmbed *b) |
| gboolean | mozilla_zoom (GtkMozEmbed *b, float size) |
| gint | mozilla_determine_page_offset (GtkMozEmbed *b) |
| char * | mozilla_uri_to_path (const char *uri) |
| int | raw_url_decode (char *str, int len) |
<File description>="">
Definition in file mozilla_api.h.
| #define NEXT_LINK 0 |
Definition at line 34 of file mozilla_api.h.
| #define PREVIOUS_LINK 1 |
Definition at line 35 of file mozilla_api.h.
| enum direction_t |
Definition at line 37 of file mozilla_api.h.
00038 { 00039 pageUp_t, 00040 pageDown_t, 00041 } direction_t;
| gboolean mozilla_alt_page | ( | GtkMozEmbed * | b | ) |
Method used to select the ALT link of the currently loaded XHTML page
| embed | reference to the MozEmbed widget |
Definition at line 337 of file mozilla_api.cpp.
00338 { 00339 return mozilla_link_module_goto_rel(b, "ALT"); 00340 }

| gboolean mozilla_back | ( | GtkMozEmbed * | b | ) |
Method used to go one step back in the browser history
| embed | reference to the MozEmbed widget |
Definition at line 472 of file mozilla_api.cpp.
00473 { 00474 g_return_val_if_fail(b != NULL, FALSE); 00475 00476 if (gtk_moz_embed_can_go_back(GTK_MOZ_EMBED(b))) 00477 { 00478 gtk_moz_embed_go_back(GTK_MOZ_EMBED(b)); 00479 return TRUE; 00480 } 00481 else 00482 { 00483 return FALSE; 00484 } 00485 }
| gint mozilla_determine_page_offset | ( | GtkMozEmbed * | b | ) |
Method used to retrieve the scrolled offset of the currently loaded "one page" XHTML page
| embed | reference to the MozEmbed widget |
Definition at line 650 of file mozilla_api.cpp.
00651 { 00652 nsCOMPtr < nsIWebBrowser > wb; 00653 nsCOMPtr < nsIScrollable > scrollable; 00654 gint offset = DEFAULT_PAGE_OFFSET; 00655 00656 BR_PAGEBARPRINTF("mozilla_determine_page_offset -- entry\n"); 00657 00658 g_return_val_if_fail(b != NULL, DEFAULT_PAGE_OFFSET); 00659 00660 BR_PAGEBARPRINTF("mozilla_determine_page_offset -- b != NULL\n"); 00661 00662 gtk_moz_embed_get_nsIWebBrowser(b, getter_AddRefs(wb)); 00663 if (!wb) 00664 { 00665 BR_WARNPRINTF("mozilla_determine_page_offset -- wb == null\n"); 00666 return (DEFAULT_PAGE_OFFSET); 00667 } 00668 00669 // determine web page size 00670 scrollable = do_QueryInterface(wb); 00671 00672 if (scrollable) 00673 { 00674 gint minPos; 00675 gint maxPos; 00676 gint curPos; 00677 int pixelscale, htmlSize, htmlPos; 00678 gulong theWindowSize; 00679 00680 scrollable->GetScrollRange(scrollable->ScrollOrientation_Y, &minPos, &maxPos); 00681 BR_PAGEBARPRINTF("scrollable->getScrollRange returned [%d,%d]\n", minPos, maxPos); 00682 scrollable->GetCurScrollPos(scrollable->ScrollOrientation_Y, &curPos); 00683 BR_PAGEBARPRINTF("scrollable->getCurScrollPos returned %d\n", curPos); 00684 00685 // determine window size (in pixels) 00686 theWindowSize = GetWebPageWindowSize(wb); 00687 BR_PAGEBARPRINTF("theWindowSize=%d\n", theWindowSize); 00688 00689 // determine pixel scale to convert from twips to pixels 00690 // scaled to avoid using floats 00691 pixelscale = (int) (100 / GetWebPagePixelScale(wb)); 00692 BR_PAGEBARPRINTF("100/pixelscale=%d\n", pixelscale); 00693 00694 // Sizes in pixels, already scaled for percentage to avoid 00695 // using floats 00696 htmlSize = (maxPos - minPos); 00697 htmlPos = curPos * 100 + theWindowSize * pixelscale; 00698 00699 // Calculate offset in percentage -- rounded to integer value 00700 offset = (gint) (htmlPos / htmlSize) + 1; 00701 if (offset > 100) 00702 { 00703 offset = 100; 00704 } 00705 BR_PAGEBARPRINTF("CALCULATED OFFSET = %d\n", offset); 00706 00707 } 00708 00709 return offset; 00710 }

| gboolean mozilla_get_page_type | ( | GtkMozEmbed * | b, | |
| char ** | type | |||
| ) |
Method used to retrieve the type of a page (attribute of meta TAG)
| embed | reference to the MozEmbed widget | |
| type | return the type information (allocated memory should be cleared by the calling routine |
| gboolean mozilla_handle_link | ( | GtkMozEmbed * | b | ) |
Method used to select the previous link of the currently loaded XHTML page when no "previous" link is available the last link on the page will be selected
| embed | reference to the MozEmbed widget |
Definition at line 425 of file mozilla_api.cpp.
00426 { 00427 nsCOMPtr < nsIWebBrowser > wb; 00428 char *urlValue; 00429 nsAutoString aHref; 00430 00431 g_return_val_if_fail(b != NULL, FALSE); 00432 gtk_moz_embed_get_nsIWebBrowser(b, getter_AddRefs(wb)); 00433 if (!wb) 00434 return (FALSE); 00435 00436 // see if there is a focused element 00437 nsCOMPtr < nsIWebBrowserFocus > focus = do_QueryInterface(wb); 00438 nsCOMPtr < nsIDOMElement > focusElement; 00439 focus->GetFocusedElement(getter_AddRefs(focusElement)); 00440 00441 if (focusElement) 00442 { 00443 BR_MOZILLA_DOCPRINTF("There is a focused element"); 00444 00445 nsCOMPtr < nsIDOMHTMLAnchorElement > anchor = do_QueryInterface(focusElement); 00446 if (anchor) 00447 { 00448 anchor->GetHref(aHref); 00449 00450 // return a new |char| buffer you must free with |nsMemory::Free| 00451 urlValue = ToNewCString(aHref); 00452 00453 BR_MOZILLA_DOCPRINTF("node is anchor with url %s", urlValue); 00454 gtk_moz_embed_load_url(GTK_MOZ_EMBED(b), urlValue); 00455 00456 nsMemory::Free(urlValue); 00457 return TRUE; 00458 } 00459 else 00460 { 00461 BR_MOZILLA_DOCPRINTF("node is NO anchor !!!!!"); 00462 } // (anchor) 00463 } 00464 else 00465 { 00466 BR_MOZILLA_DOCPRINTF("page does not contain a focussed element"); 00467 } 00468 return FALSE; 00469 }
| gboolean mozilla_next_link | ( | GtkMozEmbed * | b | ) |
Method used to select the next link of the currently loaded XHTML page when no "next" link is available the first link on th epage will be selected
| embed | reference to the MozEmbed widget |
Definition at line 223 of file mozilla_api.cpp.
00224 { 00225 return mozilla_link_update(embed, NEXT_LINK); 00226 }

| gboolean mozilla_next_page | ( | GtkMozEmbed * | b | ) |
Method used to go to the next page
| embed | reference to the MozEmbed widget |
Definition at line 322 of file mozilla_api.cpp.
00323 { 00324 return mozilla_link_module_goto_rel(b, "NEXT"); 00325 }

| gboolean mozilla_overview_page | ( | GtkMozEmbed * | b | ) |
Method used to select the INDEX link of the currently loaded XHTML page
| embed | reference to the MozEmbed widget |
Definition at line 332 of file mozilla_api.cpp.
00333 { 00334 return mozilla_link_module_goto_rel(b, "INDEX"); 00335 }

| gboolean mozilla_previous_link | ( | GtkMozEmbed * | b | ) |
Method used to select the currently focussed link
| embed | reference to the MozEmbed widget |
Definition at line 228 of file mozilla_api.cpp.
00229 { 00230 return mozilla_link_update(embed, PREVIOUS_LINK); 00231 }

| gboolean mozilla_previous_page | ( | GtkMozEmbed * | b | ) |
Method used to go to the previous page
| embed | reference to the MozEmbed widget |
Definition at line 327 of file mozilla_api.cpp.
00328 { 00329 return mozilla_link_module_goto_rel(b, "PREV"); 00330 }

| gboolean mozilla_save | ( | GtkMozEmbed * | b, | |
| gchar * | file_name, | |||
| gint | all | |||
| ) |
Method used to save a webpage -- only used for debug reasons
| embed | reference to the MozEmbed widget | |
| filename | where to save | |
| all |
Definition at line 156 of file mozilla_api.cpp.
00157 { 00158 #ifdef SELECTION_ENABLED 00159 nsCOMPtr < nsIWebBrowser > wb; 00160 gint i = 0; 00161 gchar *relative_path = NULL; 00162 00163 g_return_val_if_fail(b != NULL, FALSE); 00164 00165 00166 gtk_moz_embed_get_nsIWebBrowser(b, getter_AddRefs(wb)); 00167 if (!wb) 00168 return (FALSE); 00169 00170 nsCOMPtr < nsIWebNavigation > nav(do_QueryInterface(wb)); 00171 00172 nsCOMPtr < nsIDOMDocument > domDoc; 00173 nav->GetDocument(getter_AddRefs(domDoc)); 00174 00175 if (!domDoc) 00176 return (FALSE); 00177 nsCOMPtr < nsIWebBrowserPersist > persist(do_QueryInterface(wb)); 00178 00179 if (persist) 00180 { 00181 nsCOMPtr < nsILocalFile > file; 00182 nsCOMPtr < nsILocalFile > relative = nsnull; 00183 if (all) 00184 { 00185 00186 relative_path = g_strdup(file_name); 00187 relative_path = g_strconcat(relative_path, "_files/", NULL); 00188 00189 for (i = strlen(relative_path) - 1; i >= 0; --i) 00190 if (relative_path[i] == '/') 00191 { 00192 relative_path[i] = '\0'; 00193 break; 00194 } 00195 00196 mkdir(relative_path, 0755); 00197 00198 nsAutoString s; 00199 00200 s.AssignWithConversion(relative_path); 00201 NS_NewLocalFile(s, PR_TRUE, getter_AddRefs(relative)); 00202 } 00203 00204 nsAutoString s; 00205 00206 s.AssignWithConversion(file_name); 00207 NS_NewLocalFile(s, PR_TRUE, getter_AddRefs(file)); 00208 00209 if (file) 00210 persist->SaveDocument(domDoc, file, relative, nsnull, 0, 0); 00211 00212 if (all) 00213 g_free(relative_path); 00214 00215 return (TRUE); 00216 } 00217 #endif //SELECTION_ENABLED 00218 return (FALSE); 00219 }
| gboolean mozilla_scroll | ( | int | count, | |
| GtkMozEmbed * | b | |||
| ) |
Method to scroll on page up or down in the currently displayed XHTML page
| embed | reference to the MozEmbed widget | |
| count | number of pages to scroll (positive values move down in the view) |
Definition at line 624 of file mozilla_api.cpp.
00625 { 00626 gboolean returnValue = FALSE; 00627 00628 nsCOMPtr < nsIWebBrowser > wb; 00629 nsCOMPtr < nsITextScroll > textscrollInterface; 00630 00631 g_return_val_if_fail(b != NULL, FALSE); 00632 00633 BR_PAGEBARPRINTF("count %d", count); 00634 00635 gtk_moz_embed_get_nsIWebBrowser(b, getter_AddRefs(wb)); 00636 if (wb) 00637 { 00638 textscrollInterface = do_QueryInterface(wb); 00639 00640 if (textscrollInterface) 00641 { 00642 // prevents scrolling off the end of the view 00643 textscrollInterface->ScrollByPages(count); 00644 returnValue = TRUE; 00645 } 00646 } 00647 return returnValue; 00648 }
| gboolean mozilla_scrollable | ( | direction_t | direction, | |
| GtkMozEmbed * | b | |||
| ) |
Method used to check if it possible to scroll on page down or up in the currently displayed XHTML page
| embed | reference to the MozEmbed widget | |
| direction |
Definition at line 570 of file mozilla_api.cpp.
00571 { 00572 PRBool scrollable = PR_FALSE; 00573 00574 nsCOMPtr < nsIWebBrowser > wb; 00575 nsCOMPtr < nsIDocShell > doc_shell; 00576 nsCOMPtr < nsIPresShell > presShell; 00577 //nsCOMPtr < nsIViewManager > vm; 00578 //nsCOMPtr < nsIScrollableView > scrollview; 00579 00580 gtk_moz_embed_get_nsIWebBrowser(b, getter_AddRefs(wb)); 00581 00582 if (wb) 00583 { 00584 doc_shell = do_GetInterface(wb); 00585 00586 if (doc_shell) 00587 { 00588 doc_shell->GetPresShell(getter_AddRefs(presShell)); 00589 00590 if (presShell) 00591 { 00592 nsIViewManager *vm = presShell->GetViewManager(); 00593 00594 if (vm) 00595 { 00596 nsIScrollableView *scrollableView = nsnull; 00597 00598 vm->GetRootScrollableView(&scrollableView); 00599 00600 if (scrollableView) 00601 { 00602 switch (direction) 00603 { 00604 case pageDown_t: 00605 scrollableView->CanScroll(PR_FALSE, PR_TRUE, scrollable); 00606 break; 00607 case pageUp_t: 00608 scrollableView->CanScroll(PR_FALSE, PR_FALSE, scrollable); 00609 break; 00610 } 00611 00612 } 00613 } 00614 00615 } 00616 } 00617 } 00618 00619 BR_PAGEBARPRINTF("return %s", (scrollable == PR_TRUE) ? "TRUE" : "FALSE"); 00620 00621 return scrollable; 00622 }
| char* mozilla_uri_to_path | ( | const char * | uri | ) |
Method used to convert from uri to file system path.
| uri | reference to the input uri |
Definition at line 943 of file mozilla_api.cpp.
00944 { 00945 // in fact, we should use nsIURI to get path from uri 00946 // just remove file:// prefix if there is any 00947 char * protocol = "file://"; 00948 if (NULL == aUri) return NULL; 00949 unsigned int min = strlen(protocol); 00950 00951 if (strlen(aUri) <= min) return NULL; 00952 if (aUri != strstr(aUri, protocol)) 00953 { 00954 return NULL; 00955 } 00956 00957 char * path = strdup((char *) &aUri[min]); 00958 00959 // we should handle the %20 %2f... 00960 raw_url_decode(path, strlen(path)); 00961 return path; 00962 00963 // the following code does not work, I don't know the reason, it once works 00964 /* 00965 nsresult rv; 00966 nsCOMPtr<nsIURI> theURI; 00967 rv = NS_NewURI(getter_AddRefs(theURI), aUri); 00968 if (NS_FAILED(rv)) return NULL; 00969 nsCAutoString path; 00970 theURI->GetPath(path); 00971 return ToNewCString(path); 00972 */ 00973 }

| gboolean mozilla_zoom | ( | GtkMozEmbed * | b, | |
| float | size | |||
| ) |
Method used to zoom the currently loaded page
| embed | reference to the MozEmbed widget | |
| size | zoom factor |
Definition at line 487 of file mozilla_api.cpp.
00488 { 00489 nsCOMPtr < nsIWebBrowser > wb; 00490 nsCOMPtr < nsIDOMWindow > activeWindow; 00491 00492 g_return_val_if_fail(b != NULL, FALSE); 00493 gtk_moz_embed_get_nsIWebBrowser(b, getter_AddRefs(wb)); 00494 if (!wb) 00495 return (FALSE); 00496 00497 BR_LOGPRINTF("mozilla_zoom -- GetDOMOWindowObject"); 00498 00499 activeWindow = GetDOMOWindowObject(wb); 00500 00501 if ((activeWindow) && (size > 0)) 00502 { 00503 activeWindow->SetTextZoom(size); 00504 return TRUE; 00505 } 00506 return FALSE; 00507 }

| int raw_url_decode | ( | char * | str, | |
| int | len | |||
| ) |
Definition at line 920 of file mozilla_api.cpp.
00921 { 00922 char *dest = str; 00923 char *data = str; 00924 00925 while (len--) { 00926 if (*data == '%' && len >= 2 && isxdigit((int) *(data + 1)) 00927 && isxdigit((int) *(data + 2))) { 00928 *dest = (char) htoi(data + 1); 00929 data += 2; 00930 len -= 2; 00931 } else { 00932 *dest = *data; 00933 } 00934 data++; 00935 dest++; 00936 } 00937 *dest = '\0'; 00938 return dest - str; 00939 }

1.5.6