+2005-02-21 David Harrison <harrison@apple.com>
+
+ Reviewed by Darin.
+
+ <rdar://problem/3943090> REGRESSION (Mail): Spelling underline incompletely erased following certain steps
+
+ * WebCoreSupport.subproj/WebTextRenderer.m:
+ (-[WebTextRenderer misspellingLineThickness]):
+ (-[WebTextRenderer misspellingLinePatternWidth]):
+ Replaced #defines with these methods, so others can get the same info.
+
+ (-[WebTextRenderer drawLineForMisspelling:withWidth:]):
+ Keep underline within originally specified bounds.
+
+
2005-02-21 Darin Adler <darin@apple.com>
Reviewed by John.
}
}
-// Constants for pattern underline
-#define patternWidth 4
-#define patternHeight 3
+- (int)misspellingLineThickness
+{
+ return 3;
+}
+
+- (int)misspellingLinePatternWidth
+{
+ return 4;
+}
- (void)drawLineForMisspelling:(NSPoint)point withWidth:(int)width
{
// Constants for pattern color
static NSColor *spellingPatternColor = nil;
static bool usingDot = false;
+ int patternHeight = [self misspellingLineThickness];
+ int patternWidth = [self misspellingLinePatternWidth];
// Initialize pattern color if needed
if (!spellingPatternColor) {
spellingPatternColor = [color retain];
}
- // Width must be divisible by 4 to make sure we always draw full misspelling dots under words.
- // Do a small adjustment to shift the underline back to the left if the pattern was
- // expanded to the right "too much" to accomodate the drawing of a full dot.
- if (usingDot) {
- int w = (width + patternWidth) - (width % patternWidth);
- if (w - width > 2)
- point.x -= 1;
- width = w;
- }
+ // Make sure to draw only complete dots
+ // NOTE: Code here used to shift the underline to the left and increase the width
+ // to make sure everything gets underlined, but that results in drawing out of
+ // bounds, e.g. when at the edge of a view.
+ if (usingDot)
+ width -= (width % patternWidth);
// Compute the appropriate phase relative to the top level view in the window.
NSPoint originInWindow = [[NSView focusView] convertPoint:point toView:nil];
[currentContext restoreGraphicsState];
}
-#undef patternWidth
-#undef patternHeight
-
- (int)pointToOffset:(const WebCoreTextRun *)run style:(const WebCoreTextStyle *)style position:(int)x reversed:(BOOL)reversed includePartialGlyphs:(BOOL)includePartialGlyphs
{
if (style->smallCaps && !isSmallCapsRenderer) {