| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2010 Google Inc. All rights reserved. | 2 * Copyright (C) 2010 Google Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions | 5 * modification, are permitted provided that the following conditions |
| 6 * are met: | 6 * are met: |
| 7 * 1. Redistributions of source code must retain the above copyright | 7 * 1. Redistributions of source code must retain the above copyright |
| 8 * notice, this list of conditions and the following disclaimer. | 8 * notice, this list of conditions and the following disclaimer. |
| 9 * 2. Redistributions in binary form must reproduce the above copyright | 9 * 2. Redistributions in binary form must reproduce the above copyright |
| 10 * notice, this list of conditions and the following disclaimer in the | 10 * notice, this list of conditions and the following disclaimer in the |
| (...skipping 27 matching lines...) Expand all Loading... |
| 38 #include "wtf/text/WTFString.h" | 38 #include "wtf/text/WTFString.h" |
| 39 | 39 |
| 40 namespace blink { | 40 namespace blink { |
| 41 | 41 |
| 42 class LocalFrame; | 42 class LocalFrame; |
| 43 class SpellCheckRequester; | 43 class SpellCheckRequester; |
| 44 class TextCheckerClient; | 44 class TextCheckerClient; |
| 45 | 45 |
| 46 class SpellCheckRequest final : public TextCheckingRequest { | 46 class SpellCheckRequest final : public TextCheckingRequest { |
| 47 public: | 47 public: |
| 48 static PassRefPtrWillBeRawPtr<SpellCheckRequest> create(TextCheckingTypeMask
, TextCheckingProcessType, const EphemeralRange& checkingRange, const EphemeralR
ange& paragraphRange, int requestNumber = 0); | 48 static RawPtr<SpellCheckRequest> create(TextCheckingTypeMask, TextCheckingPr
ocessType, const EphemeralRange& checkingRange, const EphemeralRange& paragraphR
ange, int requestNumber = 0); |
| 49 | 49 |
| 50 ~SpellCheckRequest() override; | 50 ~SpellCheckRequest() override; |
| 51 void dispose(); | 51 void dispose(); |
| 52 | 52 |
| 53 PassRefPtrWillBeRawPtr<Range> checkingRange() const { return m_checkingRange
; } | 53 RawPtr<Range> checkingRange() const { return m_checkingRange; } |
| 54 PassRefPtrWillBeRawPtr<Range> paragraphRange() const { return m_paragraphRan
ge; } | 54 RawPtr<Range> paragraphRange() const { return m_paragraphRange; } |
| 55 PassRefPtrWillBeRawPtr<Element> rootEditableElement() const { return m_rootE
ditableElement; } | 55 RawPtr<Element> rootEditableElement() const { return m_rootEditableElement;
} |
| 56 | 56 |
| 57 void setCheckerAndSequence(SpellCheckRequester*, int sequence); | 57 void setCheckerAndSequence(SpellCheckRequester*, int sequence); |
| 58 #if !ENABLE(OILPAN) | 58 #if !ENABLE(OILPAN) |
| 59 void requesterDestroyed(); | 59 void requesterDestroyed(); |
| 60 #endif | 60 #endif |
| 61 | 61 |
| 62 const TextCheckingRequestData& data() const override; | 62 const TextCheckingRequestData& data() const override; |
| 63 bool isValid() const; | 63 bool isValid() const; |
| 64 void didSucceed(const Vector<TextCheckingResult>&) override; | 64 void didSucceed(const Vector<TextCheckingResult>&) override; |
| 65 void didCancel() override; | 65 void didCancel() override; |
| 66 | 66 |
| 67 int requestNumber() const { return m_requestNumber; } | 67 int requestNumber() const { return m_requestNumber; } |
| 68 | 68 |
| 69 DECLARE_VIRTUAL_TRACE(); | 69 DECLARE_VIRTUAL_TRACE(); |
| 70 | 70 |
| 71 private: | 71 private: |
| 72 SpellCheckRequest(PassRefPtrWillBeRawPtr<Range> checkingRange, PassRefPtrWil
lBeRawPtr<Range> paragraphRange, const String&, TextCheckingTypeMask, TextChecki
ngProcessType, const Vector<uint32_t>& documentMarkersInRange, const Vector<unsi
gned>& documentMarkerOffsets, int requestNumber); | 72 SpellCheckRequest(RawPtr<Range> checkingRange, RawPtr<Range> paragraphRange,
const String&, TextCheckingTypeMask, TextCheckingProcessType, const Vector<uint
32_t>& documentMarkersInRange, const Vector<unsigned>& documentMarkerOffsets, in
t requestNumber); |
| 73 | 73 |
| 74 RawPtrWillBeMember<SpellCheckRequester> m_requester; | 74 Member<SpellCheckRequester> m_requester; |
| 75 RefPtrWillBeMember<Range> m_checkingRange; | 75 Member<Range> m_checkingRange; |
| 76 RefPtrWillBeMember<Range> m_paragraphRange; | 76 Member<Range> m_paragraphRange; |
| 77 RefPtrWillBeMember<Element> m_rootEditableElement; | 77 Member<Element> m_rootEditableElement; |
| 78 TextCheckingRequestData m_requestData; | 78 TextCheckingRequestData m_requestData; |
| 79 int m_requestNumber; | 79 int m_requestNumber; |
| 80 }; | 80 }; |
| 81 | 81 |
| 82 class SpellCheckRequester final : public NoBaseWillBeGarbageCollectedFinalized<S
pellCheckRequester> { | 82 class SpellCheckRequester final : public GarbageCollectedFinalized<SpellCheckReq
uester> { |
| 83 WTF_MAKE_NONCOPYABLE(SpellCheckRequester); USING_FAST_MALLOC_WILL_BE_REMOVED
(SpellCheckRequester); | 83 WTF_MAKE_NONCOPYABLE(SpellCheckRequester); |
| 84 public: | 84 public: |
| 85 static PassOwnPtrWillBeRawPtr<SpellCheckRequester> create(LocalFrame& frame) | 85 static RawPtr<SpellCheckRequester> create(LocalFrame& frame) |
| 86 { | 86 { |
| 87 return adoptPtrWillBeNoop(new SpellCheckRequester(frame)); | 87 return new SpellCheckRequester(frame); |
| 88 } | 88 } |
| 89 | 89 |
| 90 ~SpellCheckRequester(); | 90 ~SpellCheckRequester(); |
| 91 DECLARE_TRACE(); | 91 DECLARE_TRACE(); |
| 92 | 92 |
| 93 bool isCheckable(Range*) const; | 93 bool isCheckable(Range*) const; |
| 94 | 94 |
| 95 void requestCheckingFor(PassRefPtrWillBeRawPtr<SpellCheckRequest>); | 95 void requestCheckingFor(RawPtr<SpellCheckRequest>); |
| 96 void cancelCheck(); | 96 void cancelCheck(); |
| 97 | 97 |
| 98 int lastRequestSequence() const | 98 int lastRequestSequence() const |
| 99 { | 99 { |
| 100 return m_lastRequestSequence; | 100 return m_lastRequestSequence; |
| 101 } | 101 } |
| 102 | 102 |
| 103 int lastProcessedSequence() const | 103 int lastProcessedSequence() const |
| 104 { | 104 { |
| 105 return m_lastProcessedSequence; | 105 return m_lastProcessedSequence; |
| 106 } | 106 } |
| 107 | 107 |
| 108 // Exposed for leak detector only, see comment for corresponding | 108 // Exposed for leak detector only, see comment for corresponding |
| 109 // SpellChecker method. | 109 // SpellChecker method. |
| 110 void prepareForLeakDetection(); | 110 void prepareForLeakDetection(); |
| 111 | 111 |
| 112 private: | 112 private: |
| 113 friend class SpellCheckRequest; | 113 friend class SpellCheckRequest; |
| 114 | 114 |
| 115 explicit SpellCheckRequester(LocalFrame&); | 115 explicit SpellCheckRequester(LocalFrame&); |
| 116 | 116 |
| 117 bool canCheckAsynchronously(Range*) const; | 117 bool canCheckAsynchronously(Range*) const; |
| 118 TextCheckerClient& client() const; | 118 TextCheckerClient& client() const; |
| 119 void timerFiredToProcessQueuedRequest(Timer<SpellCheckRequester>*); | 119 void timerFiredToProcessQueuedRequest(Timer<SpellCheckRequester>*); |
| 120 void invokeRequest(PassRefPtrWillBeRawPtr<SpellCheckRequest>); | 120 void invokeRequest(RawPtr<SpellCheckRequest>); |
| 121 void enqueueRequest(PassRefPtrWillBeRawPtr<SpellCheckRequest>); | 121 void enqueueRequest(RawPtr<SpellCheckRequest>); |
| 122 void didCheckSucceed(int sequence, const Vector<TextCheckingResult>&); | 122 void didCheckSucceed(int sequence, const Vector<TextCheckingResult>&); |
| 123 void didCheckCancel(int sequence); | 123 void didCheckCancel(int sequence); |
| 124 void didCheck(int sequence, const Vector<TextCheckingResult>&); | 124 void didCheck(int sequence, const Vector<TextCheckingResult>&); |
| 125 | 125 |
| 126 void clearProcessingRequest(); | 126 void clearProcessingRequest(); |
| 127 | 127 |
| 128 RawPtrWillBeMember<LocalFrame> m_frame; | 128 Member<LocalFrame> m_frame; |
| 129 LocalFrame& frame() const | 129 LocalFrame& frame() const |
| 130 { | 130 { |
| 131 ASSERT(m_frame); | 131 ASSERT(m_frame); |
| 132 return *m_frame; | 132 return *m_frame; |
| 133 } | 133 } |
| 134 | 134 |
| 135 int m_lastRequestSequence; | 135 int m_lastRequestSequence; |
| 136 int m_lastProcessedSequence; | 136 int m_lastProcessedSequence; |
| 137 | 137 |
| 138 Timer<SpellCheckRequester> m_timerToProcessQueuedRequest; | 138 Timer<SpellCheckRequester> m_timerToProcessQueuedRequest; |
| 139 | 139 |
| 140 RefPtrWillBeMember<SpellCheckRequest> m_processingRequest; | 140 Member<SpellCheckRequest> m_processingRequest; |
| 141 | 141 |
| 142 typedef WillBeHeapDeque<RefPtrWillBeMember<SpellCheckRequest>> RequestQueue; | 142 typedef HeapDeque<Member<SpellCheckRequest>> RequestQueue; |
| 143 RequestQueue m_requestQueue; | 143 RequestQueue m_requestQueue; |
| 144 }; | 144 }; |
| 145 | 145 |
| 146 } // namespace blink | 146 } // namespace blink |
| 147 | 147 |
| 148 #endif // SpellCheckRequester_h | 148 #endif // SpellCheckRequester_h |
| OLD | NEW |