EditorState.h 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  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. #ifndef EditorState_h
  26. #define EditorState_h
  27. #include "ArgumentCoders.h"
  28. #include <WebCore/IntRect.h>
  29. #include <wtf/NotFound.h>
  30. #include <wtf/text/WTFString.h>
  31. namespace WebKit {
  32. struct EditorState {
  33. EditorState()
  34. : shouldIgnoreCompositionSelectionChange(false)
  35. , selectionIsNone(true)
  36. , selectionIsRange(false)
  37. , isContentEditable(false)
  38. , isContentRichlyEditable(false)
  39. , isInPasswordField(false)
  40. , isInPlugin(false)
  41. , hasComposition(false)
  42. #if PLATFORM(QT)
  43. , cursorPosition(0)
  44. , anchorPosition(0)
  45. , inputMethodHints(0)
  46. #endif
  47. #if PLATFORM(MANX)
  48. , fieldType(-1)
  49. , fieldLang(-1)
  50. , caretOffset(-1)
  51. , hasPreviousNode(false)
  52. , hasNextNode(false)
  53. , isInLoginForm(false)
  54. , canSubmitImplicitly(false)
  55. , isFocusedByTabKey(false)
  56. #endif
  57. {
  58. }
  59. bool shouldIgnoreCompositionSelectionChange;
  60. bool selectionIsNone; // This will be false when there is a caret selection.
  61. bool selectionIsRange;
  62. bool isContentEditable;
  63. bool isContentRichlyEditable;
  64. bool isInPasswordField;
  65. bool isInPlugin;
  66. bool hasComposition;
  67. #if PLATFORM(QT)
  68. // The anchor, cursor represent either the selection or composition, depending
  69. // whether a composition exists or not.
  70. unsigned cursorPosition;
  71. unsigned anchorPosition;
  72. WebCore::IntRect editorRect;
  73. WebCore::IntRect compositionRect;
  74. uint64_t inputMethodHints;
  75. WTF::String selectedText;
  76. WTF::String surroundingText;
  77. #endif
  78. #if PLATFORM(MANX)
  79. int fieldType;
  80. int fieldLang;
  81. WebCore::IntRect fieldRect;
  82. String fieldText;
  83. WebCore::IntRect compositionRect;
  84. WebCore::IntRect selectedRect;
  85. String selectedText;
  86. int caretOffset;
  87. bool hasPreviousNode;
  88. bool hasNextNode;
  89. String psOSKAttr;
  90. bool isInLoginForm;
  91. bool canSubmitImplicitly;
  92. bool isFocusedByTabKey;
  93. #endif
  94. #if PLATFORM(QT) || PLATFORM(GTK)
  95. WebCore::IntRect cursorRect;
  96. #endif
  97. void encode(CoreIPC::ArgumentEncoder&) const;
  98. static bool decode(CoreIPC::ArgumentDecoder&, EditorState&);
  99. };
  100. }
  101. #endif // EditorState_h