bug 2253. added controller to html text input
r = kmcclusk, norris
This commit is contained in:
Родитель
1ec73e897c
Коммит
aa753bbcf7
|
@ -1442,6 +1442,7 @@ static char *domPropNames[NS_DOM_PROP_MAX] = {
|
|||
"htmlinputelement.blur",
|
||||
"htmlinputelement.checked",
|
||||
"htmlinputelement.click",
|
||||
"htmlinputelement.controllers",
|
||||
"htmlinputelement.defaultchecked",
|
||||
"htmlinputelement.defaultvalue",
|
||||
"htmlinputelement.disabled",
|
||||
|
|
|
@ -45,6 +45,7 @@
|
|||
|
||||
#include "nsIDOMXULElement.h"
|
||||
#include "nsIDOMNSHTMLTextAreaElement.h"
|
||||
#include "nsIDOMNSHTMLInputElement.h"
|
||||
#include "nsIControllers.h"
|
||||
|
||||
#include "nsIPresContext.h"
|
||||
|
@ -366,6 +367,8 @@ XULCommandDispatcherImpl::UpdateCommands(const nsString& aEventName)
|
|||
NS_IMETHODIMP
|
||||
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) {
|
||||
nsCOMPtr<nsIDOMXULElement> xulElement = do_QueryInterface(mCurrentNode);
|
||||
if (xulElement)
|
||||
|
@ -375,6 +378,9 @@ XULCommandDispatcherImpl::GetControllers(nsIControllers** aResult)
|
|||
if (htmlTextArea)
|
||||
return htmlTextArea->GetControllers(aResult);
|
||||
|
||||
nsCOMPtr<nsIDOMNSHTMLInputElement> htmlInputElement = do_QueryInterface(mCurrentNode);
|
||||
if (htmlInputElement)
|
||||
return htmlInputElement->GetControllers(aResult);
|
||||
|
||||
nsCOMPtr<nsIDOMWindow> domWindow = do_QueryInterface(mCurrentNode);
|
||||
if (domWindow)
|
||||
|
|
|
@ -28,6 +28,7 @@ nsIDOMHTMLHeadingElement.h
|
|||
nsIDOMHTMLHtmlElement.h
|
||||
nsIDOMHTMLImageElement.h
|
||||
nsIDOMHTMLInputElement.h
|
||||
nsIDOMNSHTMLInputElement.h
|
||||
nsIDOMHTMLIsIndexElement.h
|
||||
nsIDOMHTMLLIElement.h
|
||||
nsIDOMHTMLLabelElement.h
|
||||
|
|
|
@ -57,6 +57,7 @@ EXPORTS = \
|
|||
nsIDOMHTMLHtmlElement.h \
|
||||
nsIDOMHTMLImageElement.h \
|
||||
nsIDOMHTMLInputElement.h \
|
||||
nsIDOMNSHTMLInputElement.h \
|
||||
nsIDOMHTMLIsIndexElement.h \
|
||||
nsIDOMHTMLLIElement.h \
|
||||
nsIDOMHTMLLabelElement.h \
|
||||
|
|
|
@ -52,6 +52,7 @@ EXPORTS= \
|
|||
nsIDOMHTMLHtmlElement.h \
|
||||
nsIDOMHTMLImageElement.h \
|
||||
nsIDOMHTMLInputElement.h \
|
||||
nsIDOMNSHTMLInputElement.h \
|
||||
nsIDOMHTMLIsIndexElement.h \
|
||||
nsIDOMHTMLLIElement.h \
|
||||
$(NULL)
|
||||
|
|
|
@ -26,3 +26,11 @@
|
|||
void select();
|
||||
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_BLUR,
|
||||
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_DEFAULTVALUE,
|
||||
NS_DOM_PROP_HTMLINPUTELEMENT_DISABLED,
|
||||
|
@ -692,6 +693,7 @@ enum nsDOMProp {
|
|||
NS_DOM_PROP_NSHTMLFORMELEMENT_ENCODING,
|
||||
NS_DOM_PROP_NSHTMLFORMELEMENT_ITEM,
|
||||
NS_DOM_PROP_NSHTMLFORMELEMENT_NAMEDITEM,
|
||||
NS_DOM_PROP_NSHTMLINPUTELEMENT_CONTROLLERS,
|
||||
NS_DOM_PROP_NSHTMLSELECTELEMENT_ITEM,
|
||||
NS_DOM_PROP_NSHTMLTEXTAREAELEMENT_CONTROLLERS,
|
||||
NS_DOM_PROP_NSLOCATION_RELOAD,
|
||||
|
|
|
@ -36,6 +36,8 @@
|
|||
#include "nsString.h"
|
||||
#include "nsIDOMHTMLInputElement.h"
|
||||
#include "nsIDOMHTMLFormElement.h"
|
||||
#include "nsIDOMNSHTMLInputElement.h"
|
||||
#include "nsIControllers.h"
|
||||
|
||||
|
||||
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(kIHTMLInputElementIID, NS_IDOMHTMLINPUTELEMENT_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(nsIDOMHTMLFormElement);
|
||||
NS_DEF_PTR(nsIDOMNSHTMLInputElement);
|
||||
NS_DEF_PTR(nsIControllers);
|
||||
|
||||
//
|
||||
// HTMLInputElement property ids
|
||||
|
@ -69,7 +75,8 @@ enum HTMLInputElement_slots {
|
|||
HTMLINPUTELEMENT_TYPE = -16,
|
||||
HTMLINPUTELEMENT_USEMAP = -17,
|
||||
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;
|
||||
}
|
||||
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:
|
||||
return nsJSUtils::nsCallJSScriptObjectGetProperty(a, cx, id, vp);
|
||||
}
|
||||
|
@ -786,7 +820,7 @@ HTMLInputElementBlur(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsva
|
|||
}
|
||||
{
|
||||
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) {
|
||||
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;
|
||||
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) {
|
||||
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;
|
||||
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) {
|
||||
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;
|
||||
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) {
|
||||
return nsJSUtils::nsReportError(cx, NS_ERROR_DOM_SECURITY_ERR);
|
||||
}
|
||||
|
@ -982,6 +1016,7 @@ static JSPropertySpec HTMLInputElementProperties[] =
|
|||
{"useMap", HTMLINPUTELEMENT_USEMAP, JSPROP_ENUMERATE},
|
||||
{"value", HTMLINPUTELEMENT_VALUE, JSPROP_ENUMERATE},
|
||||
{"autocomplete", HTMLINPUTELEMENT_AUTOCOMPLETE, JSPROP_ENUMERATE},
|
||||
{"controllers", NSHTMLINPUTELEMENT_CONTROLLERS, JSPROP_ENUMERATE | JSPROP_READONLY},
|
||||
{0}
|
||||
};
|
||||
|
||||
|
|
|
@ -45,6 +45,7 @@
|
|||
|
||||
#include "nsIDOMXULElement.h"
|
||||
#include "nsIDOMNSHTMLTextAreaElement.h"
|
||||
#include "nsIDOMNSHTMLInputElement.h"
|
||||
#include "nsIControllers.h"
|
||||
|
||||
#include "nsIPresContext.h"
|
||||
|
@ -366,6 +367,8 @@ XULCommandDispatcherImpl::UpdateCommands(const nsString& aEventName)
|
|||
NS_IMETHODIMP
|
||||
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) {
|
||||
nsCOMPtr<nsIDOMXULElement> xulElement = do_QueryInterface(mCurrentNode);
|
||||
if (xulElement)
|
||||
|
@ -375,6 +378,9 @@ XULCommandDispatcherImpl::GetControllers(nsIControllers** aResult)
|
|||
if (htmlTextArea)
|
||||
return htmlTextArea->GetControllers(aResult);
|
||||
|
||||
nsCOMPtr<nsIDOMNSHTMLInputElement> htmlInputElement = do_QueryInterface(mCurrentNode);
|
||||
if (htmlInputElement)
|
||||
return htmlInputElement->GetControllers(aResult);
|
||||
|
||||
nsCOMPtr<nsIDOMWindow> domWindow = do_QueryInterface(mCurrentNode);
|
||||
if (domWindow)
|
||||
|
|
Загрузка…
Ссылка в новой задаче