EditorState.cpp 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177
  1. /*
  2. * Copyright (C) 2010, 2011 Apple Inc. All rights reserved.
  3. *
  4. * Redistribution and use in source and binary forms, with or without
  5. * modification, are permitted provided that the following conditions
  6. * are met:
  7. * 1. Redistributions of source code must retain the above copyright
  8. * notice, this list of conditions and the following disclaimer.
  9. * 2. Redistributions in binary form must reproduce the above copyright
  10. * notice, this list of conditions and the following disclaimer in the
  11. * documentation and/or other materials provided with the distribution.
  12. *
  13. * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
  14. * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
  15. * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
  16. * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
  17. * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
  18. * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
  19. * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
  20. * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
  21. * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
  22. * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
  23. * THE POSSIBILITY OF SUCH DAMAGE.
  24. */
  25. #include "config.h"
  26. #include "EditorState.h"
  27. #include "Arguments.h"
  28. #include "WebCoreArgumentCoders.h"
  29. namespace WebKit {
  30. void EditorState::encode(CoreIPC::ArgumentEncoder& encoder) const
  31. {
  32. encoder << shouldIgnoreCompositionSelectionChange;
  33. encoder << selectionIsNone;
  34. encoder << selectionIsRange;
  35. encoder << isContentEditable;
  36. encoder << isContentRichlyEditable;
  37. encoder << isInPasswordField;
  38. encoder << isInPlugin;
  39. encoder << hasComposition;
  40. #if PLATFORM(QT)
  41. encoder << cursorPosition;
  42. encoder << anchorPosition;
  43. encoder << editorRect;
  44. encoder << compositionRect;
  45. encoder << inputMethodHints;
  46. encoder << selectedText;
  47. encoder << surroundingText;
  48. #endif
  49. #if PLATFORM(QT) || PLATFORM(GTK)
  50. encoder << cursorRect;
  51. #endif
  52. #if PLATFORM(MANX)
  53. encoder << fieldType;
  54. encoder << fieldLang;
  55. encoder << fieldRect;
  56. encoder << fieldText;
  57. encoder << compositionRect;
  58. encoder << selectedRect;
  59. encoder << selectedText;
  60. encoder << caretOffset;
  61. encoder << hasPreviousNode;
  62. encoder << hasNextNode;
  63. encoder << psOSKAttr;
  64. encoder << isInLoginForm;
  65. encoder << canSubmitImplicitly;
  66. encoder << isFocusedByTabKey;
  67. #endif
  68. }
  69. bool EditorState::decode(CoreIPC::ArgumentDecoder& decoder, EditorState& result)
  70. {
  71. if (!decoder.decode(result.shouldIgnoreCompositionSelectionChange))
  72. return false;
  73. if (!decoder.decode(result.selectionIsNone))
  74. return false;
  75. if (!decoder.decode(result.selectionIsRange))
  76. return false;
  77. if (!decoder.decode(result.isContentEditable))
  78. return false;
  79. if (!decoder.decode(result.isContentRichlyEditable))
  80. return false;
  81. if (!decoder.decode(result.isInPasswordField))
  82. return false;
  83. if (!decoder.decode(result.isInPlugin))
  84. return false;
  85. if (!decoder.decode(result.hasComposition))
  86. return false;
  87. #if PLATFORM(QT)
  88. if (!decoder.decode(result.cursorPosition))
  89. return false;
  90. if (!decoder.decode(result.anchorPosition))
  91. return false;
  92. if (!decoder.decode(result.editorRect))
  93. return false;
  94. if (!decoder.decode(result.compositionRect))
  95. return false;
  96. if (!decoder.decode(result.inputMethodHints))
  97. return false;
  98. if (!decoder.decode(result.selectedText))
  99. return false;
  100. if (!decoder.decode(result.surroundingText))
  101. return false;
  102. #endif
  103. #if PLATFORM(QT) || PLATFORM(GTK)
  104. if (!decoder.decode(result.cursorRect))
  105. return false;
  106. #endif
  107. #if PLATFORM(MANX)
  108. if (!decoder.decode(result.fieldType))
  109. return false;
  110. if (!decoder.decode(result.fieldLang))
  111. return false;
  112. if (!decoder.decode(result.fieldRect))
  113. return false;
  114. if (!decoder.decode(result.fieldText))
  115. return false;
  116. if (!decoder.decode(result.compositionRect))
  117. return false;
  118. if (!decoder.decode(result.selectedRect))
  119. return false;
  120. if (!decoder.decode(result.selectedText))
  121. return false;
  122. if (!decoder.decode(result.caretOffset))
  123. return false;
  124. if (!decoder.decode(result.hasPreviousNode))
  125. return false;
  126. if (!decoder.decode(result.hasNextNode))
  127. return false;
  128. if (!decoder.decode(result.psOSKAttr))
  129. return false;
  130. if (!decoder.decode(result.isInLoginForm))
  131. return false;
  132. if (!decoder.decode(result.canSubmitImplicitly))
  133. return false;
  134. if (!decoder.decode(result.isFocusedByTabKey))
  135. return false;
  136. #endif
  137. return true;
  138. }
  139. }