LCOV - code coverage report
Current view: top level - extensions/spellcheck/hunspell/glue - RemoteSpellCheckEngineParent.cpp (source / functions) Hit Total Coverage
Test: output.info Lines: 0 31 0.0 %
Date: 2017-07-14 16:53:18 Functions: 0 8 0.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* vim: set ts=2 sw=2 sts=2 tw=80: */
       2             : /* This Source Code Form is subject to the terms of the Mozilla Public
       3             :  * License, v. 2.0. If a copy of the MPL was not distributed with this
       4             :  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
       5             : 
       6             : #include "RemoteSpellCheckEngineParent.h"
       7             : #include "mozilla/Unused.h"
       8             : #include "nsISpellChecker.h"
       9             : #include "nsServiceManagerUtils.h"
      10             : 
      11             : namespace mozilla {
      12             : 
      13           0 : RemoteSpellcheckEngineParent::RemoteSpellcheckEngineParent()
      14             : {
      15           0 :   mSpellChecker = do_CreateInstance(NS_SPELLCHECKER_CONTRACTID);
      16           0 : }
      17             : 
      18           0 : RemoteSpellcheckEngineParent::~RemoteSpellcheckEngineParent()
      19             : {
      20           0 : }
      21             : 
      22             : mozilla::ipc::IPCResult
      23           0 : RemoteSpellcheckEngineParent::RecvSetDictionary(
      24             :   const nsString& aDictionary,
      25             :   bool* success)
      26             : {
      27           0 :   nsresult rv = mSpellChecker->SetCurrentDictionary(aDictionary);
      28           0 :   *success = NS_SUCCEEDED(rv);
      29           0 :   return IPC_OK();
      30             : }
      31             : 
      32             : mozilla::ipc::IPCResult
      33           0 : RemoteSpellcheckEngineParent::RecvSetDictionaryFromList(
      34             :                                 nsTArray<nsString>&& aList,
      35             :                                 const intptr_t& aPromiseId)
      36             : {
      37           0 :   for (auto& dictionary : aList) {
      38           0 :     MOZ_ASSERT(!dictionary.IsEmpty());
      39           0 :     nsresult rv = mSpellChecker->SetCurrentDictionary(dictionary);
      40           0 :     if (NS_SUCCEEDED(rv)) {
      41           0 :       Unused << SendNotifyOfCurrentDictionary(dictionary, aPromiseId);
      42           0 :       return IPC_OK();
      43             :     }
      44             :   }
      45           0 :   Unused << SendNotifyOfCurrentDictionary(EmptyString(), aPromiseId);
      46           0 :   return IPC_OK();
      47             : }
      48             : 
      49             : mozilla::ipc::IPCResult
      50           0 : RemoteSpellcheckEngineParent::RecvCheck(
      51             :   const nsString& aWord,
      52             :   bool* aIsMisspelled)
      53             : {
      54           0 :   nsresult rv = mSpellChecker->CheckWord(aWord, aIsMisspelled, nullptr);
      55             : 
      56             :   // If CheckWord failed, we can't tell whether the word is correctly spelled.
      57           0 :   if (NS_FAILED(rv))
      58           0 :     *aIsMisspelled = false;
      59           0 :   return IPC_OK();
      60             : }
      61             : 
      62             : mozilla::ipc::IPCResult
      63           0 : RemoteSpellcheckEngineParent::RecvCheckAndSuggest(
      64             :   const nsString& aWord,
      65             :   bool* aIsMisspelled,
      66             :   InfallibleTArray<nsString>* aSuggestions)
      67             : {
      68           0 :   nsresult rv = mSpellChecker->CheckWord(aWord, aIsMisspelled, aSuggestions);
      69           0 :   if (NS_FAILED(rv)) {
      70           0 :     aSuggestions->Clear();
      71           0 :     *aIsMisspelled = false;
      72             :   }
      73           0 :   return IPC_OK();
      74             : }
      75             : 
      76             : void
      77           0 : RemoteSpellcheckEngineParent::ActorDestroy(ActorDestroyReason aWhy)
      78             : {
      79           0 : }
      80             : 
      81             : } // namespace mozilla

Generated by: LCOV version 1.13