Changeset 43039 in webkit
- Timestamp:
- Apr 29, 2009 6:35:07 PM (15 years ago)
- Location:
- trunk
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/WebCore/ChangeLog
r43037 r43039 1 2009-04-29 Douglas Davidson <ddavidso@apple.com> 2 3 Reviewed by Justin Garcia. 4 5 <rdar://problem/6836921> Mail exhibits issues with text checking, e.g. menu items not always validated correctly 6 7 Updates to the text checking code to enable text checking even if spellchecking is turned off 8 and fix an off-by-one error in selection handling. 9 10 * editing/Editor.cpp: 11 (WebCore::Editor::markMisspellingsAfterTypingToPosition): 12 (WebCore::Editor::markAllMisspellingsAndBadGrammarInRanges): 13 (WebCore::Editor::markMisspellingsAndBadGrammar): 14 * editing/Editor.h: 15 * editing/TypingCommand.cpp: 16 (WebCore::TypingCommand::markMisspellingsAfterTyping): 17 1 18 2009-04-29 Oliver Hunt <oliver@apple.com> 2 19 -
trunk/WebCore/editing/Editor.cpp
r43035 r43039 2157 2157 void Editor::markMisspellingsAfterTypingToPosition(const VisiblePosition &p) 2158 2158 { 2159 #if PLATFORM(MAC) && !defined(BUILDING_ON_TIGER) && !defined(BUILDING_ON_LEOPARD) 2160 bool markSpelling = isContinuousSpellCheckingEnabled(); 2161 bool markGrammar = markSpelling && isGrammarCheckingEnabled(); 2162 bool performTextCheckingReplacements = isAutomaticQuoteSubstitutionEnabled() 2163 || isAutomaticLinkDetectionEnabled() 2164 || isAutomaticDashSubstitutionEnabled() 2165 || isAutomaticTextReplacementEnabled() 2166 || (markSpelling && isAutomaticSpellingCorrectionEnabled()); 2167 if (!markSpelling && !performTextCheckingReplacements) 2168 return; 2169 2170 VisibleSelection adjacentWords = VisibleSelection(startOfWord(p, LeftWordIfOnBoundary), endOfWord(p, RightWordIfOnBoundary)); 2171 if (markGrammar) { 2172 VisibleSelection selectedSentence = VisibleSelection(startOfSentence(p), endOfSentence(p)); 2173 markAllMisspellingsAndBadGrammarInRanges(true, adjacentWords.toNormalizedRange().get(), true, selectedSentence.toNormalizedRange().get(), performTextCheckingReplacements); 2174 } else { 2175 markAllMisspellingsAndBadGrammarInRanges(markSpelling, adjacentWords.toNormalizedRange().get(), false, adjacentWords.toNormalizedRange().get(), performTextCheckingReplacements); 2176 } 2177 #else 2159 2178 if (!isContinuousSpellCheckingEnabled()) 2160 2179 return; 2161 2180 2162 #if PLATFORM(MAC) && !defined(BUILDING_ON_TIGER) && !defined(BUILDING_ON_LEOPARD)2163 VisibleSelection adjacentWords = VisibleSelection(startOfWord(p, LeftWordIfOnBoundary), endOfWord(p, RightWordIfOnBoundary));2164 if (isGrammarCheckingEnabled()) {2165 VisibleSelection selectedSentence = VisibleSelection(startOfSentence(p), endOfSentence(p));2166 markAllMisspellingsAndBadGrammarInRanges(adjacentWords.toNormalizedRange().get(), true, selectedSentence.toNormalizedRange().get(), true);2167 } else {2168 markAllMisspellingsAndBadGrammarInRanges(adjacentWords.toNormalizedRange().get(), false, adjacentWords.toNormalizedRange().get(), true);2169 }2170 #else2171 2181 // Check spelling of one word 2172 2182 markMisspellings(VisibleSelection(startOfWord(p, LeftWordIfOnBoundary), endOfWord(p, RightWordIfOnBoundary))); … … 2250 2260 #if PLATFORM(MAC) && !defined(BUILDING_ON_TIGER) && !defined(BUILDING_ON_LEOPARD) 2251 2261 2252 void Editor::markAllMisspellingsAndBadGrammarInRanges( Range* spellingRange, bool markGrammar, Range* grammarRange, bool performTextCheckingReplacements)2262 void Editor::markAllMisspellingsAndBadGrammarInRanges(bool markSpelling, Range* spellingRange, bool markGrammar, Range* grammarRange, bool performTextCheckingReplacements) 2253 2263 { 2254 2264 // This function is called with selections already expanded to word boundaries. … … 2299 2309 selectionOffset = TextIterator::rangeLength(offsetAsRange.get()); 2300 2310 restoreSelectionAfterChange = true; 2301 adjustSelectionForParagraphBoundaries = (selectionOffset > =paragraphLength) ? true : false;2311 adjustSelectionForParagraphBoundaries = (selectionOffset > paragraphLength) ? true : false; 2302 2312 } 2303 2313 } … … 2305 2315 2306 2316 Vector<TextCheckingResult> results; 2307 uint64_t checkingTypes = markGrammar ? (TextCheckingTypeSpelling | TextCheckingTypeGrammar) : TextCheckingTypeSpelling; 2317 uint64_t checkingTypes = 0; 2318 if (markSpelling) 2319 checkingTypes |= TextCheckingTypeSpelling; 2320 if (markGrammar) 2321 checkingTypes |= TextCheckingTypeGrammar; 2308 2322 if (performTextCheckingReplacements) { 2309 2323 if (isAutomaticLinkDetectionEnabled()) … … 2315 2329 if (isAutomaticTextReplacementEnabled()) 2316 2330 checkingTypes |= TextCheckingTypeReplacement; 2317 if ( isAutomaticSpellingCorrectionEnabled())2331 if (markSpelling && isAutomaticSpellingCorrectionEnabled()) 2318 2332 checkingTypes |= TextCheckingTypeCorrection; 2319 2333 } … … 2324 2338 int resultLocation = result->location + offsetDueToReplacement; 2325 2339 int resultLength = result->length; 2326 if ( result->type == TextCheckingTypeSpelling && resultLocation >= spellingRangeStartOffset && resultLocation + resultLength <= spellingRangeEndOffset) {2340 if (markSpelling && result->type == TextCheckingTypeSpelling && resultLocation >= spellingRangeStartOffset && resultLocation + resultLength <= spellingRangeEndOffset) { 2327 2341 ASSERT(resultLength > 0 && resultLocation >= 0); 2328 2342 RefPtr<Range> misspellingRange = TextIterator::subrange(spellingRange, resultLocation - spellingRangeStartOffset, resultLength); … … 2397 2411 if (!isContinuousSpellCheckingEnabled()) 2398 2412 return; 2399 markAllMisspellingsAndBadGrammarInRanges( spellingSelection.toNormalizedRange().get(), markGrammar && isGrammarCheckingEnabled(), grammarSelection.toNormalizedRange().get(), false);2413 markAllMisspellingsAndBadGrammarInRanges(true, spellingSelection.toNormalizedRange().get(), markGrammar && isGrammarCheckingEnabled(), grammarSelection.toNormalizedRange().get(), false); 2400 2414 #else 2401 2415 markMisspellings(spellingSelection); -
trunk/WebCore/editing/Editor.h
r42911 r43039 218 218 bool isAutomaticSpellingCorrectionEnabled(); 219 219 void toggleAutomaticSpellingCorrection(); 220 void markAllMisspellingsAndBadGrammarInRanges( Range* spellingRange, bool markGrammar, Range* grammarRange, bool performTextCheckingReplacements);220 void markAllMisspellingsAndBadGrammarInRanges(bool markSpelling, Range* spellingRange, bool markGrammar, Range* grammarRange, bool performTextCheckingReplacements); 221 221 #endif 222 222 void advanceToNextMisspelling(bool startBeforeSelection = false); -
trunk/WebCore/editing/TypingCommand.cpp
r43035 r43039 282 282 void TypingCommand::markMisspellingsAfterTyping() 283 283 { 284 #if PLATFORM(MAC) && !defined(BUILDING_ON_TIGER) && !defined(BUILDING_ON_LEOPARD) 285 if (!document()->frame()->editor()->isContinuousSpellCheckingEnabled() 286 && !document()->frame()->editor()->isAutomaticQuoteSubstitutionEnabled() 287 && !document()->frame()->editor()->isAutomaticLinkDetectionEnabled() 288 && !document()->frame()->editor()->isAutomaticDashSubstitutionEnabled() 289 && !document()->frame()->editor()->isAutomaticTextReplacementEnabled()) 290 return; 291 #else 284 292 if (!document()->frame()->editor()->isContinuousSpellCheckingEnabled()) 285 293 return; 294 #endif 286 295 // Take a look at the selection that results after typing and determine whether we need to spellcheck. 287 296 // Since the word containing the current selection is never marked, this does a check to -
trunk/WebKit/mac/ChangeLog
r43025 r43039 1 2009-04-29 Douglas Davidson <ddavidso@apple.com> 2 3 Reviewed by Justin Garcia. 4 5 <rdar://problem/6836921> Mail exhibits issues with text checking, e.g. menu items not always validated correctly 6 7 * WebView/WebHTMLView.mm: 8 (-[WebHTMLView validateUserInterfaceItemWithoutDelegate:]): 9 (-[WebHTMLView orderFrontSubstitutionsPanel:]): 10 * WebView/WebView.mm: 11 (-[WebView validateUserInterfaceItemWithoutDelegate:]): 12 1 13 2009-04-29 David Hyatt <hyatt@apple.com> 2 14 -
trunk/WebKit/mac/WebView/WebHTMLView.mm
r42936 r43039 2660 2660 2661 2661 #if !defined(BUILDING_ON_TIGER) && !defined(BUILDING_ON_LEOPARD) 2662 if (action == @selector(orderFrontSubstitutionsPanel:)) { 2663 NSMenuItem *menuItem = (NSMenuItem *)item; 2664 if ([menuItem isKindOfClass:[NSMenuItem class]]) { 2665 BOOL panelShowing = [[[NSSpellChecker sharedSpellChecker] substitutionsPanel] isVisible]; 2666 [menuItem setTitle:panelShowing 2667 ? UI_STRING("Hide Substitutions", "menu item title") 2668 : UI_STRING("Show Substitutions", "menu item title")]; 2669 } 2670 return [self _canEdit]; 2671 } 2662 2672 // FIXME 4799134: WebView is the bottleneck for this logic, but we must validate 2663 2673 // the selector here because we implement it here, and we must implement it here because the AppKit … … 4992 5002 4993 5003 #if !defined(BUILDING_ON_TIGER) && !defined(BUILDING_ON_LEOPARD) 5004 5005 - (void)orderFrontSubstitutionsPanel:(id)sender 5006 { 5007 COMMAND_PROLOGUE 5008 5009 NSSpellChecker *checker = [NSSpellChecker sharedSpellChecker]; 5010 if (!checker) { 5011 LOG_ERROR("No NSSpellChecker"); 5012 return; 5013 } 5014 5015 NSPanel *substitutionsPanel = [checker substitutionsPanel]; 5016 if ([substitutionsPanel isVisible]) { 5017 [substitutionsPanel orderOut:sender]; 5018 return; 5019 } 5020 [substitutionsPanel orderFront:sender]; 5021 } 4994 5022 4995 5023 // FIXME 4799134: WebView is the bottleneck for this logic, but we must implement these methods here because -
trunk/WebKit/mac/WebView/WebView.mm
r43025 r43039 253 253 macro(moveWordRightAndModifySelection) \ 254 254 macro(outdent) \ 255 macro(orderFrontSubstitutionsPanel) \ 255 256 macro(pageDown) \ 256 257 macro(pageDownAndModifySelection) \ … … 3752 3753 } 3753 3754 return retVal; 3755 } else if (action == @selector(toggleSmartInsertDelete:)) { 3756 BOOL checkMark = [self smartInsertDeleteEnabled]; 3757 if ([(NSObject *)item isKindOfClass:[NSMenuItem class]]) { 3758 NSMenuItem *menuItem = (NSMenuItem *)item; 3759 [menuItem setState:checkMark ? NSOnState : NSOffState]; 3760 } 3761 return YES; 3754 3762 #ifndef BUILDING_ON_TIGER 3755 3763 } else if (action == @selector(toggleGrammarChecking:)) {
Note: See TracChangeset
for help on using the changeset viewer.