bug 2253. added controller to html text input

r = kmcclusk, norris
This commit is contained in:
buster%netscape.com 1999-12-01 15:11:33 +00:00
Родитель 1ec73e897c
Коммит aa753bbcf7
9 изменённых файлов: 67 добавлений и 6 удалений

Просмотреть файл

@ -1442,6 +1442,7 @@ static char *domPropNames[NS_DOM_PROP_MAX] = {
"htmlinputelement.blur", "htmlinputelement.blur",
"htmlinputelement.checked", "htmlinputelement.checked",
"htmlinputelement.click", "htmlinputelement.click",
"htmlinputelement.controllers",
"htmlinputelement.defaultchecked", "htmlinputelement.defaultchecked",
"htmlinputelement.defaultvalue", "htmlinputelement.defaultvalue",
"htmlinputelement.disabled", "htmlinputelement.disabled",

Просмотреть файл

@ -45,6 +45,7 @@
#include "nsIDOMXULElement.h" #include "nsIDOMXULElement.h"
#include "nsIDOMNSHTMLTextAreaElement.h" #include "nsIDOMNSHTMLTextAreaElement.h"
#include "nsIDOMNSHTMLInputElement.h"
#include "nsIControllers.h" #include "nsIControllers.h"
#include "nsIPresContext.h" #include "nsIPresContext.h"
@ -366,6 +367,8 @@ XULCommandDispatcherImpl::UpdateCommands(const nsString& aEventName)
NS_IMETHODIMP NS_IMETHODIMP
XULCommandDispatcherImpl::GetControllers(nsIControllers** aResult) XULCommandDispatcherImpl::GetControllers(nsIControllers** aResult)
{ {
//XXX: we should fix this so there's a generic interface that describes controllers,
// so this code would have no special knowledge of what object might have controllers.
if (mCurrentNode) { if (mCurrentNode) {
nsCOMPtr<nsIDOMXULElement> xulElement = do_QueryInterface(mCurrentNode); nsCOMPtr<nsIDOMXULElement> xulElement = do_QueryInterface(mCurrentNode);
if (xulElement) if (xulElement)
@ -375,6 +378,9 @@ XULCommandDispatcherImpl::GetControllers(nsIControllers** aResult)
if (htmlTextArea) if (htmlTextArea)
return htmlTextArea->GetControllers(aResult); return htmlTextArea->GetControllers(aResult);
nsCOMPtr<nsIDOMNSHTMLInputElement> htmlInputElement = do_QueryInterface(mCurrentNode);
if (htmlInputElement)
return htmlInputElement->GetControllers(aResult);
nsCOMPtr<nsIDOMWindow> domWindow = do_QueryInterface(mCurrentNode); nsCOMPtr<nsIDOMWindow> domWindow = do_QueryInterface(mCurrentNode);
if (domWindow) if (domWindow)

Просмотреть файл

@ -28,6 +28,7 @@ nsIDOMHTMLHeadingElement.h
nsIDOMHTMLHtmlElement.h nsIDOMHTMLHtmlElement.h
nsIDOMHTMLImageElement.h nsIDOMHTMLImageElement.h
nsIDOMHTMLInputElement.h nsIDOMHTMLInputElement.h
nsIDOMNSHTMLInputElement.h
nsIDOMHTMLIsIndexElement.h nsIDOMHTMLIsIndexElement.h
nsIDOMHTMLLIElement.h nsIDOMHTMLLIElement.h
nsIDOMHTMLLabelElement.h nsIDOMHTMLLabelElement.h

Просмотреть файл

@ -57,6 +57,7 @@ EXPORTS = \
nsIDOMHTMLHtmlElement.h \ nsIDOMHTMLHtmlElement.h \
nsIDOMHTMLImageElement.h \ nsIDOMHTMLImageElement.h \
nsIDOMHTMLInputElement.h \ nsIDOMHTMLInputElement.h \
nsIDOMNSHTMLInputElement.h \
nsIDOMHTMLIsIndexElement.h \ nsIDOMHTMLIsIndexElement.h \
nsIDOMHTMLLIElement.h \ nsIDOMHTMLLIElement.h \
nsIDOMHTMLLabelElement.h \ nsIDOMHTMLLabelElement.h \

Просмотреть файл

@ -52,6 +52,7 @@ EXPORTS= \
nsIDOMHTMLHtmlElement.h \ nsIDOMHTMLHtmlElement.h \
nsIDOMHTMLImageElement.h \ nsIDOMHTMLImageElement.h \
nsIDOMHTMLInputElement.h \ nsIDOMHTMLInputElement.h \
nsIDOMNSHTMLInputElement.h \
nsIDOMHTMLIsIndexElement.h \ nsIDOMHTMLIsIndexElement.h \
nsIDOMHTMLLIElement.h \ nsIDOMHTMLLIElement.h \
$(NULL) $(NULL)

Просмотреть файл

@ -26,3 +26,11 @@
void select(); void select();
void click(); void click();
}; };
interface NSHTMLInputElement {
/* IID: { 0x993d2efc, 0xa768, 0x11d3, \
{ 0xbc, 0xcd, 0x00, 0x60, 0xb0, 0xfc, 0x76, 0xbd } } */
readonly attribute xpidl nsIControllers controllers;
};

Просмотреть файл

@ -403,7 +403,8 @@ enum nsDOMProp {
NS_DOM_PROP_HTMLINPUTELEMENT_AUTOCOMPLETE, NS_DOM_PROP_HTMLINPUTELEMENT_AUTOCOMPLETE,
NS_DOM_PROP_HTMLINPUTELEMENT_BLUR, NS_DOM_PROP_HTMLINPUTELEMENT_BLUR,
NS_DOM_PROP_HTMLINPUTELEMENT_CHECKED, NS_DOM_PROP_HTMLINPUTELEMENT_CHECKED,
NS_DOM_PROP_HTMLINPUTELEMENT_CLICK, NS_DOM_PROP_HTMLINPUTELEMENT_CLICK,
NS_DOM_PROP_HTMLINPUTELEMENT_CONTROLLERS,
NS_DOM_PROP_HTMLINPUTELEMENT_DEFAULTCHECKED, NS_DOM_PROP_HTMLINPUTELEMENT_DEFAULTCHECKED,
NS_DOM_PROP_HTMLINPUTELEMENT_DEFAULTVALUE, NS_DOM_PROP_HTMLINPUTELEMENT_DEFAULTVALUE,
NS_DOM_PROP_HTMLINPUTELEMENT_DISABLED, NS_DOM_PROP_HTMLINPUTELEMENT_DISABLED,
@ -692,6 +693,7 @@ enum nsDOMProp {
NS_DOM_PROP_NSHTMLFORMELEMENT_ENCODING, NS_DOM_PROP_NSHTMLFORMELEMENT_ENCODING,
NS_DOM_PROP_NSHTMLFORMELEMENT_ITEM, NS_DOM_PROP_NSHTMLFORMELEMENT_ITEM,
NS_DOM_PROP_NSHTMLFORMELEMENT_NAMEDITEM, NS_DOM_PROP_NSHTMLFORMELEMENT_NAMEDITEM,
NS_DOM_PROP_NSHTMLINPUTELEMENT_CONTROLLERS,
NS_DOM_PROP_NSHTMLSELECTELEMENT_ITEM, NS_DOM_PROP_NSHTMLSELECTELEMENT_ITEM,
NS_DOM_PROP_NSHTMLTEXTAREAELEMENT_CONTROLLERS, NS_DOM_PROP_NSHTMLTEXTAREAELEMENT_CONTROLLERS,
NS_DOM_PROP_NSLOCATION_RELOAD, NS_DOM_PROP_NSLOCATION_RELOAD,

Просмотреть файл

@ -36,6 +36,8 @@
#include "nsString.h" #include "nsString.h"
#include "nsIDOMHTMLInputElement.h" #include "nsIDOMHTMLInputElement.h"
#include "nsIDOMHTMLFormElement.h" #include "nsIDOMHTMLFormElement.h"
#include "nsIDOMNSHTMLInputElement.h"
#include "nsIControllers.h"
static NS_DEFINE_IID(kIScriptObjectOwnerIID, NS_ISCRIPTOBJECTOWNER_IID); static NS_DEFINE_IID(kIScriptObjectOwnerIID, NS_ISCRIPTOBJECTOWNER_IID);
@ -43,9 +45,13 @@ static NS_DEFINE_IID(kIJSScriptObjectIID, NS_IJSSCRIPTOBJECT_IID);
static NS_DEFINE_IID(kIScriptGlobalObjectIID, NS_ISCRIPTGLOBALOBJECT_IID); static NS_DEFINE_IID(kIScriptGlobalObjectIID, NS_ISCRIPTGLOBALOBJECT_IID);
static NS_DEFINE_IID(kIHTMLInputElementIID, NS_IDOMHTMLINPUTELEMENT_IID); static NS_DEFINE_IID(kIHTMLInputElementIID, NS_IDOMHTMLINPUTELEMENT_IID);
static NS_DEFINE_IID(kIHTMLFormElementIID, NS_IDOMHTMLFORMELEMENT_IID); static NS_DEFINE_IID(kIHTMLFormElementIID, NS_IDOMHTMLFORMELEMENT_IID);
static NS_DEFINE_IID(kINSHTMLInputElementIID, NS_IDOMNSHTMLINPUTELEMENT_IID);
static NS_DEFINE_IID(kIControllersIID, NS_ICONTROLLERS_IID);
NS_DEF_PTR(nsIDOMHTMLInputElement); NS_DEF_PTR(nsIDOMHTMLInputElement);
NS_DEF_PTR(nsIDOMHTMLFormElement); NS_DEF_PTR(nsIDOMHTMLFormElement);
NS_DEF_PTR(nsIDOMNSHTMLInputElement);
NS_DEF_PTR(nsIControllers);
// //
// HTMLInputElement property ids // HTMLInputElement property ids
@ -69,7 +75,8 @@ enum HTMLInputElement_slots {
HTMLINPUTELEMENT_TYPE = -16, HTMLINPUTELEMENT_TYPE = -16,
HTMLINPUTELEMENT_USEMAP = -17, HTMLINPUTELEMENT_USEMAP = -17,
HTMLINPUTELEMENT_VALUE = -18, HTMLINPUTELEMENT_VALUE = -18,
HTMLINPUTELEMENT_AUTOCOMPLETE = -19 HTMLINPUTELEMENT_AUTOCOMPLETE = -19,
NSHTMLINPUTELEMENT_CONTROLLERS = -20
}; };
/***********************************************************************/ /***********************************************************************/
@ -436,6 +443,33 @@ GetHTMLInputElementProperty(JSContext *cx, JSObject *obj, jsval id, jsval *vp)
} }
break; break;
} }
case NSHTMLINPUTELEMENT_CONTROLLERS:
{
PRBool ok = PR_FALSE;
secMan->CheckScriptAccess(scriptCX, obj, NS_DOM_PROP_NSHTMLINPUTELEMENT_CONTROLLERS, PR_FALSE, &ok);
if (!ok) {
return nsJSUtils::nsReportError(cx, NS_ERROR_DOM_SECURITY_ERR);
}
nsIControllers* prop;
nsIDOMNSHTMLInputElement* b;
if (NS_OK == a->QueryInterface(kINSHTMLInputElementIID, (void **)&b)) {
nsresult result = NS_OK;
result = b->GetControllers(&prop);
if(NS_SUCCEEDED(result)) {
// get the js object; n.b., this will do a release on 'prop'
nsJSUtils::nsConvertXPCObjectToJSVal(prop, nsIControllers::GetIID(), cx, vp);
NS_RELEASE(b);
}
else {
NS_RELEASE(b);
return nsJSUtils::nsReportError(cx, result);
}
}
else {
return nsJSUtils::nsReportError(cx, NS_ERROR_DOM_WRONG_TYPE_ERR);
}
break;
}
default: default:
return nsJSUtils::nsCallJSScriptObjectGetProperty(a, cx, id, vp); return nsJSUtils::nsCallJSScriptObjectGetProperty(a, cx, id, vp);
} }
@ -786,7 +820,7 @@ HTMLInputElementBlur(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsva
} }
{ {
PRBool ok; PRBool ok;
secMan->CheckScriptAccess(scriptCX, obj, NS_DOM_PROP_HTMLINPUTELEMENT_BLUR,PR_FALSE , &ok); secMan->CheckScriptAccess(scriptCX, obj, NS_DOM_PROP_HTMLINPUTELEMENT_BLUR, PR_FALSE, &ok);
if (!ok) { if (!ok) {
return nsJSUtils::nsReportError(cx, NS_ERROR_DOM_SECURITY_ERR); return nsJSUtils::nsReportError(cx, NS_ERROR_DOM_SECURITY_ERR);
} }
@ -829,7 +863,7 @@ HTMLInputElementFocus(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsv
} }
{ {
PRBool ok; PRBool ok;
secMan->CheckScriptAccess(scriptCX, obj, NS_DOM_PROP_HTMLINPUTELEMENT_FOCUS,PR_FALSE , &ok); secMan->CheckScriptAccess(scriptCX, obj, NS_DOM_PROP_HTMLINPUTELEMENT_FOCUS, PR_FALSE, &ok);
if (!ok) { if (!ok) {
return nsJSUtils::nsReportError(cx, NS_ERROR_DOM_SECURITY_ERR); return nsJSUtils::nsReportError(cx, NS_ERROR_DOM_SECURITY_ERR);
} }
@ -872,7 +906,7 @@ HTMLInputElementSelect(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, js
} }
{ {
PRBool ok; PRBool ok;
secMan->CheckScriptAccess(scriptCX, obj, NS_DOM_PROP_HTMLINPUTELEMENT_SELECT,PR_FALSE , &ok); secMan->CheckScriptAccess(scriptCX, obj, NS_DOM_PROP_HTMLINPUTELEMENT_SELECT, PR_FALSE, &ok);
if (!ok) { if (!ok) {
return nsJSUtils::nsReportError(cx, NS_ERROR_DOM_SECURITY_ERR); return nsJSUtils::nsReportError(cx, NS_ERROR_DOM_SECURITY_ERR);
} }
@ -915,7 +949,7 @@ HTMLInputElementClick(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsv
} }
{ {
PRBool ok; PRBool ok;
secMan->CheckScriptAccess(scriptCX, obj, NS_DOM_PROP_HTMLINPUTELEMENT_CLICK,PR_FALSE , &ok); secMan->CheckScriptAccess(scriptCX, obj, NS_DOM_PROP_HTMLINPUTELEMENT_CLICK, PR_FALSE, &ok);
if (!ok) { if (!ok) {
return nsJSUtils::nsReportError(cx, NS_ERROR_DOM_SECURITY_ERR); return nsJSUtils::nsReportError(cx, NS_ERROR_DOM_SECURITY_ERR);
} }
@ -982,6 +1016,7 @@ static JSPropertySpec HTMLInputElementProperties[] =
{"useMap", HTMLINPUTELEMENT_USEMAP, JSPROP_ENUMERATE}, {"useMap", HTMLINPUTELEMENT_USEMAP, JSPROP_ENUMERATE},
{"value", HTMLINPUTELEMENT_VALUE, JSPROP_ENUMERATE}, {"value", HTMLINPUTELEMENT_VALUE, JSPROP_ENUMERATE},
{"autocomplete", HTMLINPUTELEMENT_AUTOCOMPLETE, JSPROP_ENUMERATE}, {"autocomplete", HTMLINPUTELEMENT_AUTOCOMPLETE, JSPROP_ENUMERATE},
{"controllers", NSHTMLINPUTELEMENT_CONTROLLERS, JSPROP_ENUMERATE | JSPROP_READONLY},
{0} {0}
}; };

Просмотреть файл

@ -45,6 +45,7 @@
#include "nsIDOMXULElement.h" #include "nsIDOMXULElement.h"
#include "nsIDOMNSHTMLTextAreaElement.h" #include "nsIDOMNSHTMLTextAreaElement.h"
#include "nsIDOMNSHTMLInputElement.h"
#include "nsIControllers.h" #include "nsIControllers.h"
#include "nsIPresContext.h" #include "nsIPresContext.h"
@ -366,6 +367,8 @@ XULCommandDispatcherImpl::UpdateCommands(const nsString& aEventName)
NS_IMETHODIMP NS_IMETHODIMP
XULCommandDispatcherImpl::GetControllers(nsIControllers** aResult) XULCommandDispatcherImpl::GetControllers(nsIControllers** aResult)
{ {
//XXX: we should fix this so there's a generic interface that describes controllers,
// so this code would have no special knowledge of what object might have controllers.
if (mCurrentNode) { if (mCurrentNode) {
nsCOMPtr<nsIDOMXULElement> xulElement = do_QueryInterface(mCurrentNode); nsCOMPtr<nsIDOMXULElement> xulElement = do_QueryInterface(mCurrentNode);
if (xulElement) if (xulElement)
@ -375,6 +378,9 @@ XULCommandDispatcherImpl::GetControllers(nsIControllers** aResult)
if (htmlTextArea) if (htmlTextArea)
return htmlTextArea->GetControllers(aResult); return htmlTextArea->GetControllers(aResult);
nsCOMPtr<nsIDOMNSHTMLInputElement> htmlInputElement = do_QueryInterface(mCurrentNode);
if (htmlInputElement)
return htmlInputElement->GetControllers(aResult);
nsCOMPtr<nsIDOMWindow> domWindow = do_QueryInterface(mCurrentNode); nsCOMPtr<nsIDOMWindow> domWindow = do_QueryInterface(mCurrentNode);
if (domWindow) if (domWindow)