зеркало из https://github.com/mozilla/pjs.git
Notify form submit observers on... well... form submission.
This commit is contained in:
Родитель
9fe502105e
Коммит
c881390b63
|
@ -71,6 +71,10 @@ static NS_DEFINE_CID(kIOServiceCID, NS_IOSERVICE_CID);
|
||||||
|
|
||||||
#include "nsIUnicodeEncoder.h"
|
#include "nsIUnicodeEncoder.h"
|
||||||
|
|
||||||
|
// FormSubmit observer notification
|
||||||
|
#include "nsIFormSubmitObserver.h"
|
||||||
|
#include "nsIObserverService.h"
|
||||||
|
#include "nsIServiceManager.h"
|
||||||
|
|
||||||
#include "net.h"
|
#include "net.h"
|
||||||
#include "xp_file.h"
|
#include "xp_file.h"
|
||||||
|
@ -470,6 +474,31 @@ nsFormFrame::OnSubmit(nsIPresContext* aPresContext, nsIFrame* aFrame)
|
||||||
aFrame->QueryInterface(kIFormControlFrameIID, (void**)&fcFrame);
|
aFrame->QueryInterface(kIFormControlFrameIID, (void**)&fcFrame);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Notify observers that the form is being submitted.
|
||||||
|
nsresult result = NS_OK;
|
||||||
|
nsIObserverService* theObserverService = nsnull;
|
||||||
|
result = nsServiceManager::GetService(NS_OBSERVERSERVICE_PROGID, nsIObserverService::GetIID(),
|
||||||
|
(nsISupports**) &theObserverService, nsnull);
|
||||||
|
if (NS_SUCCEEDED(result) && theObserverService){
|
||||||
|
nsString theTopic(NS_FORMSUBMIT_SUBJECT);
|
||||||
|
nsIEnumerator* theEnum;
|
||||||
|
result = theObserverService->EnumerateObserverList(theTopic.GetUnicode(), &theEnum);
|
||||||
|
if (NS_SUCCEEDED(result) && theEnum){
|
||||||
|
nsIFormSubmitObserver* formSubmitObserver;
|
||||||
|
nsISupports *inst;
|
||||||
|
|
||||||
|
for (theEnum->First(); theEnum->IsDone() != NS_OK; theEnum->Next()) {
|
||||||
|
result = theEnum->CurrentItem(&inst);
|
||||||
|
if (NS_SUCCEEDED(result) && inst) {
|
||||||
|
result = inst->QueryInterface(nsIFormSubmitObserver::GetIID(),(void**)&formSubmitObserver);
|
||||||
|
if (NS_SUCCEEDED(result) && formSubmitObserver) {
|
||||||
|
formSubmitObserver->Notify(mContent);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (isURLEncoded) {
|
if (isURLEncoded) {
|
||||||
ProcessAsURLEncoded(isPost, data, fcFrame);
|
ProcessAsURLEncoded(isPost, data, fcFrame);
|
||||||
}
|
}
|
||||||
|
|
Загрузка…
Ссылка в новой задаче