mirror of
https://github.com/classilla/tenfourfox.git
synced 2024-10-25 06:28:30 +00:00
#164: fix static variables for anonymous methods ; implement plaintext of <<tab>>
This commit is contained in:
parent
4881c0af02
commit
72cddaa366
@ -302,10 +302,10 @@
|
|||||||
<property name="URL" code="pURL" type="text" access="rw" description="The current URL of the tab.">
|
<property name="URL" code="pURL" type="text" access="rw" description="The current URL of the tab.">
|
||||||
<cocoa key="URL"/>
|
<cocoa key="URL"/>
|
||||||
</property>
|
</property>
|
||||||
<property name="source" code="pSrc" type="text" access="r" description="The HTML source of the web page currently loaded in the tab.">
|
<property name="HTML" code="pHTM" type="text" access="r" description="The HTML source of the web page currently loaded in the tab.">
|
||||||
<cocoa key="source"/>
|
<cocoa key="source"/>
|
||||||
</property>
|
</property>
|
||||||
<property name="text" code="pTxt" type="text" access="r" description="The text of the web page currently loaded in the tab. Modifications to text aren't reflected on the web page.">
|
<property name="plaintext" code="pTxt" type="text" access="r" description="The text of the web page currently loaded in the tab. Modifications to text aren't reflected on the web page.">
|
||||||
<cocoa key="text"/>
|
<cocoa key="text"/>
|
||||||
</property>
|
</property>
|
||||||
<property name="selected" code="pSTx" type="text" access="r" description="The selected text on the web page currently loaded in the tab.">
|
<property name="selected" code="pSTx" type="text" access="r" description="The selected text on the web page currently loaded in the tab.">
|
||||||
|
@ -107,8 +107,6 @@ typedef unsigned int NSUInteger;
|
|||||||
struct objc_method remoMeth;
|
struct objc_method remoMeth;
|
||||||
struct objc_method openMeth;
|
struct objc_method openMeth;
|
||||||
struct objc_method_list methodList;
|
struct objc_method_list methodList;
|
||||||
BOOL didInit;
|
|
||||||
NSUInteger openExpected;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
+ (GeckoScriptingRoot*)sharedScriptingRoot;
|
+ (GeckoScriptingRoot*)sharedScriptingRoot;
|
||||||
@ -208,6 +206,8 @@ void SetupMacScripting(void) {
|
|||||||
#pragma mark -
|
#pragma mark -
|
||||||
|
|
||||||
static GeckoScriptingRoot *sharedScriptingRoot = nil;
|
static GeckoScriptingRoot *sharedScriptingRoot = nil;
|
||||||
|
static NSUInteger openExpected = 1; // we always start with a window
|
||||||
|
static BOOL didInit = NO;
|
||||||
|
|
||||||
@implementation GeckoScriptingRoot
|
@implementation GeckoScriptingRoot
|
||||||
|
|
||||||
@ -222,9 +222,6 @@ static GeckoScriptingRoot *sharedScriptingRoot = nil;
|
|||||||
|
|
||||||
- (id)init {
|
- (id)init {
|
||||||
self = [super init];
|
self = [super init];
|
||||||
if (self)
|
|
||||||
didInit = NO;
|
|
||||||
openExpected = 0;
|
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -277,6 +274,7 @@ static GeckoScriptingRoot *sharedScriptingRoot = nil;
|
|||||||
|
|
||||||
class_addMethods([application class], &methodList);
|
class_addMethods([application class], &methodList);
|
||||||
didInit = YES;
|
didInit = YES;
|
||||||
|
openExpected = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (NSArray*)scriptWindows {
|
- (NSArray*)scriptWindows {
|
||||||
@ -676,12 +674,8 @@ static GeckoScriptingRoot *sharedScriptingRoot = nil;
|
|||||||
nsCOMPtr<nsIDocument> pdoc = piWindow->GetDoc();
|
nsCOMPtr<nsIDocument> pdoc = piWindow->GetDoc();
|
||||||
if (!pdoc)
|
if (!pdoc)
|
||||||
return @"";
|
return @"";
|
||||||
nsCOMPtr<nsIPresShell> p = pdoc->GetShell();
|
if (pdoc) {
|
||||||
if (!p)
|
nsCOMPtr<nsIDOMHTMLDocument> htmlDocument(do_QueryInterface(pdoc));
|
||||||
return @"";
|
|
||||||
nsIDocument* doc = p->GetDocument();
|
|
||||||
if (doc) {
|
|
||||||
nsCOMPtr<nsIDOMHTMLDocument> htmlDocument(do_QueryInterface(doc));
|
|
||||||
if (htmlDocument) {
|
if (htmlDocument) {
|
||||||
nsAutoString title;
|
nsAutoString title;
|
||||||
if (NS_SUCCEEDED(htmlDocument->GetTitle(title))) {
|
if (NS_SUCCEEDED(htmlDocument->GetTitle(title))) {
|
||||||
@ -763,24 +757,54 @@ static GeckoScriptingRoot *sharedScriptingRoot = nil;
|
|||||||
|
|
||||||
- (NSString*)source {
|
- (NSString*)source {
|
||||||
#if(0)
|
#if(0)
|
||||||
nsCOMPtr<nsIDOMDocument> document;
|
NS_WARNING("AppleScript: tab title");
|
||||||
if (NS_SUCCEEDED(mContentWindow->GetDocument(getter_AddRefs(document))) && document) {
|
nsCOMPtr<nsPIDOMWindow> piWindow = do_QueryInterface(mContentWindow);
|
||||||
|
if (!piWindow)
|
||||||
|
return @"";
|
||||||
|
nsCOMPtr<nsIDocument> pdoc = piWindow->GetDoc();
|
||||||
|
if (pdoc) {
|
||||||
nsCOMPtr<nsIDOMSerializer> serializer(do_CreateInstance(NS_XMLSERIALIZER_CONTRACTID));
|
nsCOMPtr<nsIDOMSerializer> serializer(do_CreateInstance(NS_XMLSERIALIZER_CONTRACTID));
|
||||||
if (serializer) {
|
if (serializer) {
|
||||||
nsAutoString source;
|
nsAutoString source;
|
||||||
if (NS_SUCCEEDED(serializer->SerializeToString(document, source))) {
|
if (NS_SUCCEEDED(serializer->SerializeToString(pdoc, source))) {
|
||||||
return [NSString stringWithUTF8String:NS_ConvertUTF16toUTF8(source).get()];
|
return [NSString stringWithUTF8String:NS_ConvertUTF16toUTF8(source).get()];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
return @"";
|
return @"";
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
- (NSString*)text {
|
- (NSString*)text {
|
||||||
|
NS_WARNING("AppleScript: tab text");
|
||||||
|
nsresult rv;
|
||||||
|
|
||||||
|
nsCOMPtr<nsPIDOMWindow> piWindow = do_QueryInterface(mContentWindow);
|
||||||
|
if (!piWindow)
|
||||||
|
return @"";
|
||||||
|
nsCOMPtr<nsIDocument> pdoc = piWindow->GetDoc();
|
||||||
|
if (!pdoc)
|
||||||
|
return @"";
|
||||||
|
nsCOMPtr<nsIDOMDocument> domdoc = do_QueryInterface(pdoc);
|
||||||
|
if (!domdoc)
|
||||||
|
return @"";
|
||||||
|
|
||||||
|
nsAutoString outbuf;
|
||||||
|
nsCOMPtr<nsIDocumentEncoder> encoder = do_CreateInstance(
|
||||||
|
"@mozilla.org/layout/documentEncoder;1?type=text/plain");
|
||||||
|
rv = encoder->Init(domdoc, NS_LITERAL_STRING("text/plain"), 0 |
|
||||||
|
nsIDocumentEncoder::SkipInvisibleContent |
|
||||||
|
nsIDocumentEncoder::OutputFormatted |
|
||||||
|
nsIDocumentEncoder::OutputLFLineBreak |
|
||||||
|
nsIDocumentEncoder::OutputFormatFlowed |
|
||||||
|
0);
|
||||||
|
if (NS_FAILED(rv))
|
||||||
|
return @"";
|
||||||
|
if (NS_SUCCEEDED(encoder->EncodeToString(outbuf))) {
|
||||||
|
return [NSString stringWithUTF8String:NS_ConvertUTF16toUTF8(outbuf).get()];
|
||||||
|
}
|
||||||
#if(0)
|
#if(0)
|
||||||
nsCOMPtr<nsIDOMDocument> document;
|
if (pdoc) {
|
||||||
if (NS_SUCCEEDED(mContentWindow->GetDocument(getter_AddRefs(document))) && document) {
|
|
||||||
nsresult rv = NS_OK;
|
nsresult rv = NS_OK;
|
||||||
|
|
||||||
nsCAutoString formatType(NS_DOC_ENCODER_CONTRACTID_BASE);
|
nsCAutoString formatType(NS_DOC_ENCODER_CONTRACTID_BASE);
|
||||||
|
Loading…
Reference in New Issue
Block a user