Commit 19be15b6 authored by Albert Astals Cid's avatar Albert Astals Cid
Browse files

Field readOnly applies to the user but not to JS

parent 1fd2004a
......@@ -41,8 +41,6 @@ class Okular::ExecutorKJSPrivate
}
~ExecutorKJSPrivate()
{
JSField::clearCachedFields();
delete m_interpreter;
}
......
......@@ -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();
}
}
......@@ -24,7 +24,6 @@ class JSField
public:
static void initType( KJSContext *ctx );
static KJSObject wrapField( KJSContext *ctx, FormField *field, Page *page );
static void clearCachedFields();
};
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment