001: /*******************************************************************************
002: * Copyright (c) 2000, 2005 IBM Corporation and others.
003: * All rights reserved. This program and the accompanying materials
004: * are made available under the terms of the Eclipse Public License v1.0
005: * which accompanies this distribution, and is available at
006: * http://www.eclipse.org/legal/epl-v10.html
007: *
008: * Contributors:
009: * IBM Corporation - initial API and implementation
010: *******************************************************************************/package org.eclipse.swt.browser;
011:
012: import org.eclipse.swt.internal.*;
013:
014: // GOOGLE: make this public
015: public class WebKit {
016:
017: static {
018: Library.loadLibrary("swt-webkit"); //$NON-NLS-1$
019: WebInitForCarbon();
020: }
021:
022: /* Objective-C class ids */
023: static final int C_NSHTTPCookieStorage = WebKit
024: .objc_getClass("NSHTTPCookieStorage"); //$NON-NLS-1$
025: static final int C_NSNotificationCenter = WebKit
026: .objc_getClass("NSNotificationCenter"); //$NON-NLS-1$
027: static final int C_NSNumber = WebKit.objc_getClass("NSNumber"); //$NON-NLS-1$
028: static final int C_NSURL = WebKit.objc_getClass("NSURL"); //$NON-NLS-1$
029: static final int C_NSURLRequest = WebKit
030: .objc_getClass("NSURLRequest"); //$NON-NLS-1$
031: static final int C_WebKitDelegate = WebKit
032: .objc_getClass("WebKitDelegate"); //$NON-NLS-1$
033: static final int C_WebDownload = WebKit
034: .objc_getClass("WebDownload"); //$NON-NLS-1$
035: static final int C_WebView = WebKit.objc_getClass("WebView"); //$NON-NLS-1$
036:
037: /* Objective-C method selectors */
038: static final int S_absoluteString = WebKit
039: .sel_registerName("absoluteString"); //$NON-NLS-1$
040: static final int S_addObserver_selector_name_object = WebKit
041: .sel_registerName("addObserver:selector:name:object:"); //$NON-NLS-1$
042: static final int S_alloc = WebKit.sel_registerName("alloc"); //$NON-NLS-1$
043: static final int S_autorelease = WebKit
044: .sel_registerName("autorelease"); //$NON-NLS-1$
045: static final int S_cancel = WebKit.sel_registerName("cancel"); //$NON-NLS-1$
046: static final int S_canGoBack = WebKit.sel_registerName("canGoBack"); //$NON-NLS-1$
047: static final int S_canGoForward = WebKit
048: .sel_registerName("canGoForward"); //$NON-NLS-1$
049: static final int S_canShowMIMEType = WebKit
050: .sel_registerName("canShowMIMEType:"); //$NON-NLS-1$
051: static final int S_chooseFilename = WebKit
052: .sel_registerName("chooseFilename:"); //$NON-NLS-1$
053: static final int S_cookies = WebKit.sel_registerName("cookies"); //$NON-NLS-1$
054: static final int S_count = WebKit.sel_registerName("count"); //$NON-NLS-1$
055: static final int S_dataSource = WebKit
056: .sel_registerName("dataSource"); //$NON-NLS-1$
057: static final int S_defaultCenter = WebKit
058: .sel_registerName("defaultCenter"); //$NON-NLS-1$
059: static final int S_deleteCookie = WebKit
060: .sel_registerName("deleteCookie:"); //$NON-NLS-1$
061: static final int S_download = WebKit.sel_registerName("download"); //$NON-NLS-1$
062: static final int S_goBack = WebKit.sel_registerName("goBack:"); //$NON-NLS-1$
063: static final int S_goForward = WebKit
064: .sel_registerName("goForward:"); //$NON-NLS-1$
065: static final int S_handleNotification = WebKit
066: .sel_registerName("handleNotification:"); //$NON-NLS-1$
067: static final int S_ignore = WebKit.sel_registerName("ignore"); //$NON-NLS-1$
068: static final int S_initialRequest = WebKit
069: .sel_registerName("initialRequest"); //$NON-NLS-1$
070: static final int S_initWithProc = WebKit
071: .sel_registerName("initWithProc:user_data:"); //$NON-NLS-1$
072: static final int S_isSessionOnly = WebKit
073: .sel_registerName("isSessionOnly"); //$NON-NLS-1$
074: static final int S_loadHTMLStringbaseURL = WebKit
075: .sel_registerName("loadHTMLString:baseURL:"); //$NON-NLS-1$
076: static final int S_loadRequest = WebKit
077: .sel_registerName("loadRequest:"); //$NON-NLS-1$
078: static final int S_mainFrame = WebKit.sel_registerName("mainFrame"); //$NON-NLS-1$
079: static final int S_name = WebKit.sel_registerName("name"); //$NON-NLS-1$
080: static final int S_numberWithInt = WebKit
081: .sel_registerName("numberWithInt:"); //$NON-NLS-1$
082: static final int S_objectAtIndex = WebKit
083: .sel_registerName("objectAtIndex:"); //$NON-NLS-1$
084: static final int S_provisionalDataSource = WebKit
085: .sel_registerName("provisionalDataSource"); //$NON-NLS-1$
086: static final int S_release = WebKit.sel_registerName("release"); //$NON-NLS-1$
087: static final int S_reload = WebKit.sel_registerName("reload:"); //$NON-NLS-1$
088: static final int S_retain = WebKit.sel_registerName("retain"); //$NON-NLS-1$
089: static final int S_removeObserver_name_object = WebKit
090: .sel_registerName("removeObserver:name:object:"); //$NON-NLS-1$
091: static final int S_removeObserver = WebKit
092: .sel_registerName("removeObserver:"); //$NON-NLS-1$
093: static final int S_requestWithURL = WebKit
094: .sel_registerName("requestWithURL:"); //$NON-NLS-1$
095: static final int S_request = WebKit.sel_registerName("request"); //$NON-NLS-1$
096: static final int S_retainCount = WebKit
097: .sel_registerName("retainCount"); //$NON-NLS-1$
098: static final int S_setDestinationAllowOverwrite = WebKit
099: .sel_registerName("setDestination:allowOverwrite:"); //$NON-NLS-1$
100: static final int S_setDownloadDelegate = WebKit
101: .sel_registerName("setDownloadDelegate:"); //$NON-NLS-1$
102: static final int S_setFrameLoadDelegate = WebKit
103: .sel_registerName("setFrameLoadDelegate:"); //$NON-NLS-1$
104: static final int S_setGroupName = WebKit
105: .sel_registerName("setGroupName:"); //$NON-NLS-1$
106: static final int S_setPolicyDelegate = WebKit
107: .sel_registerName("setPolicyDelegate:"); //$NON-NLS-1$
108: static final int S_setResourceLoadDelegate = WebKit
109: .sel_registerName("setResourceLoadDelegate:"); //$NON-NLS-1$
110: static final int S_setStatusText = WebKit
111: .sel_registerName("setStatusText:"); //$NON-NLS-1$
112: static final int S_setUIDelegate = WebKit
113: .sel_registerName("setUIDelegate:"); //$NON-NLS-1$
114: static final int S_sharedHTTPCookieStorage = WebKit
115: .sel_registerName("sharedHTTPCookieStorage"); //$NON-NLS-1$
116: static final int S_stopLoading = WebKit
117: .sel_registerName("stopLoading:"); //$NON-NLS-1$
118: static final int S_stringByEvaluatingJavaScriptFromString = WebKit
119: .sel_registerName("stringByEvaluatingJavaScriptFromString:"); //$NON-NLS-1$
120: static final int S_takeStringURLFrom = WebKit
121: .sel_registerName("takeStringURLFrom:"); //$NON-NLS-1$
122: static final int S_use = WebKit.sel_registerName("use"); //$NON-NLS-1$
123: static final int S_webFrame = WebKit.sel_registerName("webFrame"); //$NON-NLS-1$
124: static final int S_URL = WebKit.sel_registerName("URL"); //$NON-NLS-1$
125: static final int S_URLWithString = WebKit
126: .sel_registerName("URLWithString:"); //$NON-NLS-1$
127:
128: /* WebKit */
129: static final native int HIWebViewCreate(int[] outView);
130:
131: static final native int HIWebViewGetWebView(int inView);
132:
133: static final native void WebInitForCarbon();
134:
135: /* OBJ-C runtime primitives */
136: static final native int objc_getClass(byte[] className);
137:
138: //GOOGLE: make this public
139: public static final native int objc_msgSend(int object, int selector);
140:
141: static final native int objc_msgSend(int object, int selector,
142: int arg0);
143:
144: static final native int objc_msgSend(int object, int selector,
145: int arg0, int arg1);
146:
147: static final native int objc_msgSend(int object, int selector,
148: int arg0, int arg1, int arg2);
149:
150: static final native int objc_msgSend(int object, int selector,
151: int arg0, int arg1, int arg2, int arg3);
152:
153: static final native int sel_registerName(byte[] selectorName);
154:
155: static byte[] ascii(String name) {
156: int length = name.length();
157: char[] chars = new char[length];
158: name.getChars(0, length, chars, 0);
159: byte[] buffer = new byte[length + 1];
160: for (int i = 0; i < length; i++) {
161: buffer[i] = (byte) chars[i];
162: }
163: return buffer;
164: }
165:
166: // GOOGLE: make this public
167: public static int sel_registerName(String selector) {
168: return WebKit.sel_registerName(ascii(selector));
169: }
170:
171: static int objc_getClass(String className) {
172: return WebKit.objc_getClass(ascii(className));
173: }
174: }
|