Changeset 93093 in webkit
- Timestamp:
- Aug 16, 2011 6:11:23 AM (13 years ago)
- Location:
- trunk/Source
- Files:
-
- 2 added
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r93087 r93093 1 2011-08-16 Lindsay Mathieson <lindsay.mathieson@gmail.com> 2 3 [Qt] Missing spell check support 4 https://bugs.webkit.org/show_bug.cgi?id=44114 5 6 Reviewed by Benjamin Poulain. 7 8 Add drawErrorUnderline() from Cairo to render the line for text checking on the Qt port. 9 10 * platform/graphics/qt/GraphicsContextQt.cpp: 11 (WebCore::drawErrorUnderline): 12 (WebCore::GraphicsContext::drawLineForTextChecking): 13 1 14 2011-08-15 MORITA Hajime <morrita@google.com> 2 15 -
trunk/Source/WebCore/platform/graphics/qt/GraphicsContextQt.cpp
r91914 r93093 901 901 } 902 902 903 void GraphicsContext::drawLineForTextChecking(const FloatPoint&, float, TextCheckingLineStyle) 904 { 905 if (paintingDisabled()) 906 return; 907 908 notImplemented(); 903 904 /* 905 * NOTE: This code is completely based upon the one from 906 * Source/WebCore/platform/graphics/cairo/DrawErrorUnderline.{h|cpp} 907 * 908 * Draws an error underline that looks like one of: 909 * 910 * H E H 911 * /\ /\ /\ /\ /\ - 912 * A/ \ / \ / \ A/ \ / \ | 913 * \ \ / \ / /D \ \ / \ | 914 * \ \/ C \/ / \ \/ C \ | height = heightSquares * square 915 * \ /\ F / \ F /\ \ | 916 * \ / \ / \ / \ \G | 917 * \ / \ / \ / \ / | 918 * \/ \/ \/ \/ - 919 * B B 920 * |---| 921 * unitWidth = (heightSquares - 1) * square 922 * 923 * The x, y, width, height passed in give the desired bounding box; 924 * x/width are adjusted to make the underline a integer number of units wide. 925 */ 926 static void drawErrorUnderline(QPainter *painter, qreal x, qreal y, qreal width, qreal height) 927 { 928 const qreal heightSquares = 2.5; 929 930 qreal square = height / heightSquares; 931 qreal halfSquare = 0.5 * square; 932 933 qreal unitWidth = (heightSquares - 1.0) * square; 934 int widthUnits = static_cast<int>((width + 0.5 * unitWidth) / unitWidth); 935 936 x += 0.5 * (width - widthUnits * unitWidth); 937 width = widthUnits * unitWidth; 938 939 qreal bottom = y + height; 940 qreal top = y; 941 942 QPainterPath path; 943 944 // Bottom of squiggle. 945 path.moveTo(x - halfSquare, top + halfSquare); // A 946 947 int i = 0; 948 for (i = 0; i < widthUnits; i += 2) { 949 qreal middle = x + (i + 1) * unitWidth; 950 qreal right = x + (i + 2) * unitWidth; 951 952 path.lineTo(middle, bottom); // B 953 954 if (i + 2 == widthUnits) 955 path.lineTo(right + halfSquare, top + halfSquare); // D 956 else if (i + 1 != widthUnits) 957 path.lineTo(right, top + square); // C 958 } 959 960 // Top of squiggle. 961 for (i -= 2; i >= 0; i -= 2) { 962 qreal left = x + i * unitWidth; 963 qreal middle = x + (i + 1) * unitWidth; 964 qreal right = x + (i + 2) * unitWidth; 965 966 if (i + 1 == widthUnits) 967 path.lineTo(middle + halfSquare, bottom - halfSquare); // G 968 else { 969 if (i + 2 == widthUnits) 970 path.lineTo(right, top); // E 971 972 path.lineTo(middle, bottom - halfSquare); // F 973 } 974 975 path.lineTo(left, top); // H 976 } 977 978 painter->drawPath(path); 979 } 980 981 982 void GraphicsContext::drawLineForTextChecking(const FloatPoint& origin, float width, TextCheckingLineStyle style) 983 { 984 if (paintingDisabled()) 985 return; 986 987 QPainter* painter = platformContext(); 988 const QPen originalPen = painter->pen(); 989 990 switch (style) { 991 case TextCheckingSpellingLineStyle: 992 painter->setPen(Qt::red); 993 break; 994 case TextCheckingGrammarLineStyle: 995 painter->setPen(Qt::green); 996 break; 997 default: 998 return; 999 } 1000 1001 drawErrorUnderline(painter, origin.x(), origin.y(), width, cMisspellingLineThickness); 1002 painter->setPen(originalPen); 909 1003 } 910 1004 -
trunk/Source/WebKit/qt/Api/qwebkitplatformplugin.h
r89958 r93093 21 21 #ifndef QWEBKITPLATFORMPLUGIN_H 22 22 #define QWEBKITPLATFORMPLUGIN_H 23 24 #include "qwebkitglobal.h" 23 25 24 26 /* … … 135 137 #endif 136 138 139 class QWEBKIT_EXPORT QWebSpellChecker : public QObject { 140 Q_OBJECT 141 public: 142 struct GrammarDetail { 143 int location; 144 int length; 145 QStringList guesses; 146 QString userDescription; 147 }; 148 149 virtual bool isContinousSpellCheckingEnabled() const = 0; 150 virtual void toggleContinousSpellChecking() = 0; 151 152 virtual void learnWord(const QString& word) = 0; 153 virtual void ignoreWordInSpellDocument(const QString& word) = 0; 154 virtual void checkSpellingOfString(const QString& word, int* misspellingLocation, int* misspellingLength) = 0; 155 virtual QString autoCorrectSuggestionForMisspelledWord(const QString& word) = 0; 156 virtual void guessesForWord(const QString& word, const QString& context, QStringList& guesses) = 0; 157 158 virtual bool isGrammarCheckingEnabled() = 0; 159 virtual void toggleGrammarChecking() = 0; 160 virtual void checkGrammarOfString(const QString&, QList<GrammarDetail>&, int* badGrammarLocation, int* badGrammarLength) = 0; 161 }; 162 137 163 class QWebKitPlatformPlugin { 138 164 public: … … 144 170 Haptics, 145 171 TouchInteraction, 146 FullScreenVideoPlayer 172 FullScreenVideoPlayer, 173 SpellChecker 147 174 }; 148 175 -
trunk/Source/WebKit/qt/ChangeLog
r93066 r93093 1 2011-08-16 Lindsay Mathieson <lindsay.mathieson@gmail.com> 2 3 [Qt] Missing spell check support 4 https://bugs.webkit.org/show_bug.cgi?id=44114 5 6 Reviewed by Benjamin Poulain. 7 8 Added a platform plugin to allow spell and grammar check in QtWebKit. 9 10 * Api/qwebkitplatformplugin.h: 11 * QtWebKit.pro: 12 * WebCoreSupport/EditorClientQt.cpp: 13 (WebCore::EditorClientQt::isContinuousSpellCheckingEnabled): 14 (WebCore::EditorClientQt::isGrammarCheckingEnabled): 15 (WebCore::EditorClientQt::toggleContinuousSpellChecking): 16 (WebCore::EditorClientQt::toggleGrammarChecking): 17 * WebCoreSupport/EditorClientQt.h: 18 (WebCore::EditorClientQt::textChecker): 19 * WebCoreSupport/QtPlatformPlugin.cpp: 20 (WebCore::QtPlatformPlugin::createSpellChecker): 21 * WebCoreSupport/QtPlatformPlugin.h: 22 * WebCoreSupport/TextCheckerClientQt.cpp: Added. 23 (convertToVectorList): 24 (WebCore::TextCheckerClientQt::ignoreWordInSpellDocument): 25 (WebCore::TextCheckerClientQt::learnWord): 26 (WebCore::TextCheckerClientQt::getAutoCorrectSuggestionForMisspelledWord): 27 (WebCore::TextCheckerClientQt::checkSpellingOfString): 28 (WebCore::TextCheckerClientQt::checkGrammarOfString): 29 (WebCore::TextCheckerClientQt::getGuessesForWord): 30 (WebCore::TextCheckerClientQt::isContinousSpellCheckingEnabled): 31 (WebCore::TextCheckerClientQt::toggleContinousSpellChecking): 32 (WebCore::TextCheckerClientQt::isGrammarCheckingEnabled): 33 (WebCore::TextCheckerClientQt::toggleGrammarChecking): 34 (WebCore::TextCheckerClientQt::loadSpellChecker): 35 * WebCoreSupport/TextCheckerClientQt.h: Added. 36 (WebCore::TextCheckerClientQt::requestCheckingOfString): 37 1 38 2011-08-15 Dmitry Titov <dimich@chromium.org> 2 39 -
trunk/Source/WebKit/qt/QtWebKit.pro
r91863 r93093 195 195 $$PWD/WebCoreSupport/QtPlatformPlugin.cpp \ 196 196 $$PWD/WebCoreSupport/SearchPopupMenuQt.cpp \ 197 $$PWD/WebCoreSupport/TextCheckerClientQt.cpp \ 197 198 $$PWD/WebCoreSupport/WebPlatformStrategies.cpp 198 199 … … 211 212 $$PWD/WebCoreSupport/PopupMenuQt.h \ 212 213 $$PWD/WebCoreSupport/SearchPopupMenuQt.h \ 214 $$PWD/WebCoreSupport/TextCheckerClientQt.h \ 213 215 $$PWD/WebCoreSupport/WebPlatformStrategies.h 214 216 -
trunk/Source/WebKit/qt/WebCoreSupport/EditorClientQt.cpp
r86798 r93093 57 57 #include <wtf/OwnPtr.h> 58 58 59 #define methodDebug() qDebug("EditorClientQt: %s", __FUNCTION__);60 59 61 60 static QString dumpPath(WebCore::Node *node) … … 110 109 bool EditorClientQt::isContinuousSpellCheckingEnabled() 111 110 { 112 return false;111 return m_textCheckerClient.isContinousSpellCheckingEnabled(); 113 112 } 114 113 115 114 bool EditorClientQt::isGrammarCheckingEnabled() 116 115 { 117 return false;116 return m_textCheckerClient.isGrammarCheckingEnabled(); 118 117 } 119 118 … … 345 344 void EditorClientQt::toggleContinuousSpellChecking() 346 345 { 347 notImplemented();346 m_textCheckerClient.toggleContinousSpellChecking(); 348 347 } 349 348 350 349 void EditorClientQt::toggleGrammarChecking() 351 350 { 352 notImplemented();351 return m_textCheckerClient.toggleGrammarChecking(); 353 352 } 354 353 … … 568 567 } 569 568 570 void EditorClientQt::ignoreWordInSpellDocument(const String&)571 {572 notImplemented();573 }574 575 void EditorClientQt::learnWord(const String&)576 {577 notImplemented();578 }579 580 void EditorClientQt::checkSpellingOfString(const UChar*, int, int*, int*)581 {582 notImplemented();583 }584 585 String EditorClientQt::getAutoCorrectSuggestionForMisspelledWord(const String&)586 {587 notImplemented();588 return String();589 }590 591 void EditorClientQt::checkGrammarOfString(const UChar*, int, Vector<GrammarDetail>&, int*, int*)592 {593 notImplemented();594 }595 596 569 void EditorClientQt::updateSpellingUIWithGrammarString(const String&, const GrammarDetail&) 597 570 { … … 613 586 notImplemented(); 614 587 return false; 615 }616 617 void EditorClientQt::getGuessesForWord(const String& word, const String& context, Vector<String>& guesses)618 {619 notImplemented();620 588 } 621 589 -
trunk/Source/WebKit/qt/WebCoreSupport/EditorClientQt.h
r84574 r93093 32 32 33 33 #include "EditorClient.h" 34 #include "TextCheckerClient.h"35 34 #include "RefCounted.h" 36 35 #include "TextCheckerClientQt.h" 37 36 #include <wtf/Forward.h> 38 37 … … 41 40 namespace WebCore { 42 41 43 class EditorClientQt : public EditorClient , public TextCheckerClient{42 class EditorClientQt : public EditorClient { 44 43 public: 45 44 EditorClientQt(QWebPage* page); … … 98 97 virtual void textDidChangeInTextArea(Element*); 99 98 100 virtual void ignoreWordInSpellDocument(const String&);101 virtual void learnWord(const String&);102 virtual void checkSpellingOfString(const UChar*, int length, int* misspellingLocation, int* misspellingLength);103 virtual String getAutoCorrectSuggestionForMisspelledWord(const String& misspelledWord);104 virtual void checkGrammarOfString(const UChar*, int length, Vector<GrammarDetail>&, int* badGrammarLocation, int* badGrammarLength);105 99 virtual void updateSpellingUIWithGrammarString(const String&, const GrammarDetail&); 106 100 virtual void updateSpellingUIWithMisspelledWord(const String&); 107 101 virtual void showSpellingUI(bool show); 108 102 virtual bool spellingUIIsShowing(); 109 virtual void getGuessesForWord(const String& word, const String& context, Vector<String>& guesses);110 103 virtual void willSetInputMethodState(); 111 104 virtual void setInputMethodState(bool enabled); 112 virtual void requestCheckingOfString(SpellChecker*, int, WebCore::TextCheckingTypeMask, const String&) {} 113 virtual TextCheckerClient* textChecker() { return this; } 105 virtual TextCheckerClient* textChecker() { return &m_textCheckerClient; } 114 106 115 107 bool isEditing() const; … … 119 111 120 112 private: 113 TextCheckerClientQt m_textCheckerClient; 121 114 QWebPage* m_page; 122 115 bool m_editing; -
trunk/Source/WebKit/qt/WebCoreSupport/QtPlatformPlugin.cpp
r86537 r93093 135 135 #endif 136 136 137 PassOwnPtr<QWebSpellChecker> QtPlatformPlugin::createSpellChecker() 138 { 139 QWebKitPlatformPlugin* p = plugin(); 140 return adoptPtr(p ? static_cast<QWebSpellChecker*>(p->createExtension(QWebKitPlatformPlugin::SpellChecker)) : 0); 137 141 } 142 143 } -
trunk/Source/WebKit/qt/WebCoreSupport/QtPlatformPlugin.h
r86537 r93093 34 34 class QWebFullScreenVideoHandler; 35 35 #endif 36 class QWebSpellChecker; 36 37 37 38 namespace WebCore { … … 54 55 PassOwnPtr<QWebFullScreenVideoHandler> createFullScreenVideoHandler(); 55 56 #endif 57 PassOwnPtr<QWebSpellChecker> createSpellChecker(); 56 58 57 59 QWebKitPlatformPlugin* plugin();
Note: See TracChangeset
for help on using the changeset viewer.