interface for grammar checkers

Jos Collin joscollin at gmail.com
Sun Jun 28 16:37:20 UTC 2015


Hello Firefox-Devs,

We are trying to add a new interface for Grammar Checker Extensions in 
the Firefox Code. The existing Grammar Checker Extensions  either have 
no good integration, like LanguageToolFx which offers no underlining, or 
they use their own logic to modify the DOM to produce the underlines. 
That is very fragile and they regularly fail after Firefox updates, or 
on some web pages. Thus the plan to have a proper interface in Firefox 
that makes it possible to write robust checkers without complex and 
fragile DOM manipulations.

We have come up with a Plan, which is described in the below bug report. 
As per the Plan, The Extension implements the grammar checking task. 
After the text has been checked, the extension calls the interface with 
the list of errors it has found. The interface basically accepts the 
list of errors from the Extension and then marks the errors in the 
textarea, by default using a blue underline. The interface also accepts 
the list optional corrections for each error from the extension and add 
it to the context menu when the user right clicks on a particular error.

https://bugzilla.mozilla.org/show_bug.cgi?id=1140402

I have the following questions with the Plan. I request you developers 
to go through the above bug report and provide your answers / 
suggestions to the following questions, so that we could implement this 
interface successfully.

------------------------------------------------------------
The questions follows:

1. As per the Current Plan, markErrors(GrammarCheckErrorListObj) 
interface function in nsIEditorGrammarCheck is supposed to take in the 
list of errors as a parameter. We cannot pass a C++ object (containing 
the list of errors) or an STL vector from the Extension to the 
markErrors() interface. So Does it make sense to get the errors a JSON 
string?  Thus the GrammarCheckErrorList object or the Vector should be 
created with in the C++ code by parsing the JSON string data. So the 
data will arrive from the Extension side and the C++ will add functions 
to operate on that data, which forms the GrammarCheckErrorList object. 
Please suggest.

2. If the errors can be passed in as a JSON string, then Is there any 
way to convert the JSON string to say C++ vectors ? Is there any such 
function already exist in the Firefox code ?

3. If the errors can be passed in as a JSON string, then Is there a JSON 
String Parser already exist in the Firefox code that we could use ?


4. Regarding the Reference to the TextArea (event.target), how the 
Textarea object or reference can be passed to the C++ code ? What would 
be the type of that object ? Is it possible to do as in 
nsIEditorSpellCheck::InitSpellChecker ? In InitSpellChecker, the 
Textarea is passed in as a parameter: 'in nsIEditor editor'. Please suggest.

5. In nsEditorSpellCheck.cpp, I couldn't find an underlinered() 
function, which underline the errors found by the Spell Checker. I 
wonder how this is implemented for the spell checker. Is it a feature 
provided by the libeditor (editor/libeditor/) ?

Thanks,
Jos Collin



More information about the firefox-dev mailing list