Field readOnly applies to the user but not to JS

This commit is contained in:
Albert Astals Cid 2017-03-02 22:38:29 +01:00
parent 1fd2004aa3
commit 19be15b6a5
3 changed files with 0 additions and 32 deletions

View file

@ -41,8 +41,6 @@ class Okular::ExecutorKJSPrivate
}
~ExecutorKJSPrivate()
{
JSField::clearCachedFields();
delete m_interpreter;
}

View file

@ -27,9 +27,6 @@ using namespace Okular;
static KJSPrototype *g_fieldProto;
typedef QHash< FormField *, KJSObject > FormCache;
Q_GLOBAL_STATIC( FormCache, g_fieldCache )
// Field.doc
static KJSObject fieldGetDoc( KJSContext *context, void * )
{
@ -115,16 +112,6 @@ static KJSObject fieldGetType( KJSContext *, void *object )
static KJSObject fieldGetValue( KJSContext *context, void *object )
{
FormField *field = reinterpret_cast< FormField * >( object );
if ( field->isReadOnly() )
{
KJSObject value = g_fieldCache->value( field );
if ( g_fieldCache.exists() && g_fieldCache->contains( field ) )
value = g_fieldCache->value( field );
else
value = KJSString("");
qCDebug(OkularCoreDebug) << "Getting the value of a readonly field" << field->name() << ":" << value.toString( context );
return value;
}
switch ( field->type() )
{
@ -159,14 +146,6 @@ static void fieldSetValue( KJSContext *context, void *object, KJSObject value )
{
FormField *field = reinterpret_cast< FormField * >( object );
if ( field->isReadOnly() )
{
// ### throw exception?
qCDebug(OkularCoreDebug) << "Trying to change the readonly field" << field->name() << "to" << value.toString( context );
g_fieldCache->insert( field, value );
return;
}
switch ( field->type() )
{
case FormField::FormButton:
@ -219,11 +198,3 @@ KJSObject JSField::wrapField( KJSContext *ctx, FormField *field, Page *page )
f.setProperty( ctx, QStringLiteral("page"), page->number() );
return f;
}
void JSField::clearCachedFields()
{
if ( g_fieldCache.exists() )
{
g_fieldCache->clear();
}
}

View file

@ -24,7 +24,6 @@ class JSField
public:
static void initType( KJSContext *ctx );
static KJSObject wrapField( KJSContext *ctx, FormField *field, Page *page );
static void clearCachedFields();
};
}