Changeset 16286 in webkit
- Timestamp:
- Sep 10, 2006, 12:53:41 PM (18 years ago)
- Location:
- trunk/WebCore
- Files:
-
- 18 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/WebCore/ChangeLog
r16284 r16286 1 2006-09-10 Eric Seidel <eric@eseidel.com> 2 3 Reviewed by darin. 4 5 Remove a bunch more NSGraphicsContext related code. 6 Add a LocalCurrentGraphicsContext to simplify methods which need to call up into AppKit controls (and thus depend on the [NSGraphicsContext currentContext] being set correctly) 7 Add an "isPrinting" flag to many of the text drawing functions in order to avoid the need for a GraphicsContext::isPrinting() function. 8 9 No tests were harmed in the making of this patch. 10 11 * bridge/mac/WebCoreFrameBridge.mm: 12 (-[WebCoreFrameBridge drawRect:]): 13 * kcanvas/device/quartz/KRenderingDeviceQuartz.h: 14 (WebCore::KRenderingDeviceContextQuartz::cgContext): 15 (WebCore::KRenderingDeviceQuartz::isBuffered): 16 * kcanvas/device/quartz/KRenderingDeviceQuartz.mm: 17 (WebCore::KRenderingDeviceContextQuartz::KRenderingDeviceContextQuartz): 18 (WebCore::KRenderingDeviceContextQuartz::~KRenderingDeviceContextQuartz): 19 * kcanvas/device/quartz/QuartzSupport.mm: 20 * platform/Font.cpp: 21 (WebCore::Font::drawSimpleText): 22 (WebCore::Font::drawText): 23 * platform/Font.h: 24 * platform/GraphicsContext.cpp: 25 (WebCore::GraphicsContext::drawText): 26 * platform/GraphicsContext.h: 27 * platform/mac/FileButtonMac.mm: 28 (-[WebFileChooserButton drawRect:]): 29 * platform/mac/FontMac.mm: 30 (WebCore::ATSULayoutParameters::ATSULayoutParameters): 31 (WebCore::ATSULayoutParameters::initialize): 32 (WebCore::Font::drawComplexText): 33 (WebCore::Font::drawGlyphs): 34 * platform/mac/GraphicsContextMac.mm: 35 (WebCore::GraphicsContext::drawLineForMisspelling): 36 * platform/mac/ListBoxMac.mm: 37 (-[WebCoreTableView drawRow:clipRect:]): 38 * platform/mac/WebCoreTextRenderer.mm: 39 (WebCoreDrawTextAtPoint): 40 * rendering/EllipsisBox.cpp: 41 (WebCore::EllipsisBox::paint): 42 * rendering/InlineTextBox.cpp: 43 (WebCore::InlineTextBox::paint): 44 * rendering/RenderImage.cpp: 45 (WebCore::RenderImage::paint): 46 * rendering/RenderListMarker.cpp: 47 (WebCore::RenderListMarker::paint): 48 * rendering/RenderThemeMac.mm: 49 (WebCore::WebCoreNSGraphicsContextBridge::WebCoreNSGraphicsContextBridge): 50 (WebCore::WebCoreNSGraphicsContextBridge::~WebCoreNSGraphicsContextBridge): 51 (WebCore::RenderThemeMac::paintButton): 52 (WebCore::RenderThemeMac::paintTextField): 53 (WebCore::RenderThemeMac::paintTextArea): 54 1 55 2006-09-09 Steve Falkenburg <sfalken@apple.com> 2 56 -
trunk/WebCore/WebCore.xcodeproj/project.pbxproj
r16280 r16286 2015 2015 FAE04190097596C9000540BE /* SVGImageLoader.h in Headers */ = {isa = PBXBuildFile; fileRef = FAE0418E097596C9000540BE /* SVGImageLoader.h */; }; 2016 2016 /* End PBXBuildFile section */ 2017 2018 /* Begin PBXBuildStyle section */2019 BCA5EAC20AB2AAAA0009504D /* Development */ = {2020 isa = PBXBuildStyle;2021 buildSettings = {2022 COPY_PHASE_STRIP = NO;2023 };2024 name = Development;2025 };2026 BCA5EAC30AB2AAAA0009504D /* Deployment */ = {2027 isa = PBXBuildStyle;2028 buildSettings = {2029 COPY_PHASE_STRIP = YES;2030 };2031 name = Deployment;2032 };2033 /* End PBXBuildStyle section */2034 2017 2035 2018 /* Begin PBXContainerItemProxy section */ … … 7947 7930 isa = PBXProject; 7948 7931 buildConfigurationList = 149C284308902B11008A9EFC /* Build configuration list for PBXProject "WebCore" */; 7949 buildSettings = {7950 };7951 buildStyles = (7952 BCA5EAC20AB2AAAA0009504D /* Development */,7953 BCA5EAC30AB2AAAA0009504D /* Deployment */,7954 );7955 7932 hasScannedForEncodings = 1; 7956 7933 knownRegions = ( -
trunk/WebCore/bridge/mac/WebCoreFrameBridge.mm
r16274 r16286 931 931 { 932 932 PlatformGraphicsContext* platformContext = static_cast<PlatformGraphicsContext*>([[NSGraphicsContext currentContext] graphicsPort]); 933 934 933 ASSERT([[NSGraphicsContext currentContext] isFlipped]); 935 936 934 GraphicsContext context(platformContext); 935 937 936 [self _setupRootForPrinting:YES]; 938 937 -
trunk/WebCore/kcanvas/device/quartz/KRenderingDeviceQuartz.h
r16206 r16286 35 35 typedef struct CGContext *CGContextRef; 36 36 37 #ifdef __OBJC__38 @class NSGraphicsContext;39 #else40 class NSGraphicsContext;41 #endif42 43 37 namespace WebCore { 44 38 … … 57 51 58 52 CGContextRef cgContext() const { return m_cgContext; }; 59 NSGraphicsContext *nsGraphicsContext();60 53 61 54 private: 62 55 CGContextRef m_cgContext; 63 NSGraphicsContext *m_nsGraphicsContext;64 56 }; 65 57 … … 70 62 71 63 virtual bool isBuffered() const { return false; } 72 73 virtual KRenderingDeviceContext *popContext();74 virtual void pushContext(KRenderingDeviceContext *context);75 64 76 65 // context management. -
trunk/WebCore/kcanvas/device/quartz/KRenderingDeviceQuartz.mm
r16206 r16286 45 45 KRenderingDeviceContextQuartz::KRenderingDeviceContextQuartz(CGContextRef context) 46 46 : m_cgContext(CGContextRetain(context)) 47 , m_nsGraphicsContext(0)48 47 { 49 48 ASSERT(m_cgContext); … … 53 52 { 54 53 CGContextRelease(m_cgContext); 55 HardRelease(m_nsGraphicsContext);56 54 } 57 55 … … 79 77 } 80 78 81 NSGraphicsContext *KRenderingDeviceContextQuartz::nsGraphicsContext()82 {83 if (!m_nsGraphicsContext && m_cgContext)84 m_nsGraphicsContext = HardRetain([NSGraphicsContext graphicsContextWithGraphicsPort:m_cgContext flipped:YES]);85 return m_nsGraphicsContext;86 }87 88 79 GraphicsContext* KRenderingDeviceContextQuartz::createGraphicsContext() 89 80 { … … 127 118 ASSERT(quartzContext()); 128 119 return quartzContext()->cgContext(); 129 }130 131 void KRenderingDeviceQuartz::pushContext(KRenderingDeviceContext *context)132 {133 ASSERT(context);134 KRenderingDevice::pushContext(context);135 [NSGraphicsContext saveGraphicsState];136 [NSGraphicsContext setCurrentContext:quartzContext()->nsGraphicsContext()];137 ASSERT(quartzContext()->nsGraphicsContext() == [NSGraphicsContext currentContext]);138 }139 140 KRenderingDeviceContext *KRenderingDeviceQuartz::popContext()141 {142 [NSGraphicsContext restoreGraphicsState];143 KRenderingDeviceContext *poppedContext = KRenderingDevice::popContext();144 ASSERT(!currentContext() || currentCGContext() == [[NSGraphicsContext currentContext] graphicsPort]);145 return poppedContext;146 120 } 147 121 -
trunk/WebCore/kcanvas/device/quartz/QuartzSupport.mm
r16054 r16286 42 42 43 43 namespace WebCore { 44 45 #ifndef NDEBUG46 void debugDumpCGImageToFile(NSString *filename, CGImageRef image, int width, int height)47 {48 NSImage *fileImage = [[NSImage alloc] initWithSize:NSMakeSize(width, height)];49 [fileImage lockFocus];50 CGContextRef fileImageContext = (CGContextRef)[[NSGraphicsContext currentContext] graphicsPort];51 CGContextDrawImage(fileImageContext, GraphicsContext(fileImageContext).roundToDevicePixels(52 FloatRect(0, 0, width, height)), image);53 [fileImage unlockFocus];54 NSData *tiff = [fileImage TIFFRepresentation];55 [tiff writeToFile:filename atomically:YES];56 [fileImage release];57 }58 59 void debugDumpCGLayerToFile(NSString *filename, CGLayerRef layer, int width, int height)60 {61 NSImage *fileImage = [[NSImage alloc] initWithSize:NSMakeSize(width, height)];62 [fileImage lockFocus];63 CGContextRef fileImageContext = (CGContextRef)[[NSGraphicsContext currentContext] graphicsPort];64 CGContextDrawLayerAtPoint(fileImageContext, CGPointMake(0, 0), layer);65 [fileImage unlockFocus];66 NSData *tiff = [fileImage TIFFRepresentation];67 [tiff writeToFile:filename atomically:YES];68 [fileImage release];69 }70 71 void debugDumpCIImageToFile(NSString *filename, CIImage *ciImage, int width, int height)72 {73 NSImage *fileImage = [[NSImage alloc] initWithSize:NSMakeSize(width, height)];74 [fileImage lockFocus];75 CGContextRef fileImageContext = (CGContextRef)[[NSGraphicsContext currentContext] graphicsPort];76 CIContext *ciContext = [CIContext contextWithCGContext:fileImageContext options:nil];77 [ciContext drawImage:ciImage atPoint:CGPointZero fromRect:CGRectMake(0, 0, width, height)];78 [fileImage unlockFocus];79 NSData *tiff = [fileImage TIFFRepresentation];80 [tiff writeToFile:filename atomically:YES];81 [fileImage release];82 }83 #endif84 44 85 45 CFStringRef CFStringFromCGAffineTransform(CGAffineTransform t) -
trunk/WebCore/platform/Font.cpp
r16250 r16286 502 502 const FontData* nextFontData = glyphBuffer.fontDataAt(nextGlyph); 503 503 if (nextFontData != fontData) { 504 drawGlyphs(context, fontData, glyphBuffer, lastFrom, nextGlyph - lastFrom, startPoint );504 drawGlyphs(context, fontData, glyphBuffer, lastFrom, nextGlyph - lastFrom, startPoint, style.usePrinterFonts()); 505 505 lastFrom = nextGlyph; 506 506 fontData = nextFontData; … … 510 510 nextGlyph++; 511 511 } 512 drawGlyphs(context, fontData, glyphBuffer, lastFrom, nextGlyph - lastFrom, startPoint );512 drawGlyphs(context, fontData, glyphBuffer, lastFrom, nextGlyph - lastFrom, startPoint, style.usePrinterFonts()); 513 513 } 514 514 -
trunk/WebCore/platform/Font.h
r16250 r16286 155 155 bool canUseGlyphCache(const TextRun&) const; 156 156 void drawSimpleText(GraphicsContext*, const TextRun&, const TextStyle&, const FloatPoint&) const; 157 void drawGlyphs(GraphicsContext*, const FontData*, const GlyphBuffer&, int from, int to, const FloatPoint& ) const;157 void drawGlyphs(GraphicsContext*, const FontData*, const GlyphBuffer&, int from, int to, const FloatPoint&, bool usePrinterFont) const; 158 158 void drawComplexText(GraphicsContext*, const TextRun&, const TextStyle&, const FloatPoint&) const; 159 159 float floatWidthForSimpleText(const TextRun&, const TextStyle&, const FontData* substituteFontData, -
trunk/WebCore/platform/TextStyle.h
r16250 r16286 27 27 public: 28 28 TextStyle(int tabWidth = 0, int xpos = 0, int padding = 0, bool rtl = false, bool directionalOverride = false, 29 bool applyRunRounding = true, bool applyWordRounding = true, bool attemptFontSubstitution = true )29 bool applyRunRounding = true, bool applyWordRounding = true, bool attemptFontSubstitution = true, bool usePrinterFonts = false) 30 30 : m_tabWidth(tabWidth) 31 31 , m_xpos(xpos) … … 36 36 , m_applyWordRounding(applyWordRounding) 37 37 , m_attemptFontSubstitution(attemptFontSubstitution) 38 , m_usePrinterFonts(usePrinterFonts) 38 39 { 39 40 } … … 48 49 bool applyWordRounding() const { return m_applyWordRounding; } 49 50 bool attemptFontSubstitution() const { return m_attemptFontSubstitution; } 51 bool usePrinterFonts() const { return m_usePrinterFonts; } 50 52 51 53 void disableRoundingHacks() { m_applyRunRounding = m_applyWordRounding = false; } 52 54 void setRTL(bool b) { m_rtl = b; } 55 void setUsePrinterFonts(bool b) { m_usePrinterFonts = b; } 53 56 54 57 private: … … 61 64 bool m_applyWordRounding; 62 65 bool m_attemptFontSubstitution; 66 bool m_usePrinterFonts; 63 67 }; 64 68 -
trunk/WebCore/platform/mac/FontMac.mm
r16250 r16286 63 63 { 64 64 ATSULayoutParameters(const TextRun& run, const TextStyle& style) 65 :m_run(run), m_style(style), 66 m_font(0), m_fonts(0), m_charBuffer(0), m_hasSyntheticBold(false), m_syntheticBoldPass(false), m_padPerSpace(0) 65 : m_run(run) 66 , m_style(style) 67 , m_font(0) 68 , m_fonts(0) 69 , m_charBuffer(0) 70 , m_hasSyntheticBold(false) 71 , m_syntheticBoldPass(false) 72 , m_padPerSpace(0) 67 73 {} 68 74 69 void initialize(const Font* font);75 void initialize(const Font*, const GraphicsContext* = 0); 70 76 71 77 const TextRun& m_run; … … 262 268 } 263 269 264 void ATSULayoutParameters::initialize(const Font* font )270 void ATSULayoutParameters::initialize(const Font* font, const GraphicsContext* graphicsContext) 265 271 { 266 272 m_font = font; 267 273 268 274 // FIXME: It is probably best to always allocate a buffer for RTL, since even if for this 269 275 // fontData ATSUMirrors is true, for a substitute fontData it might be false. … … 272 278 m_charBuffer = (UChar*)((font->isSmallCaps() || (m_style.rtl() && !fontData->m_ATSUMirrors)) ? new UChar[m_run.length()] : 0); 273 279 274 // The only Cocoa calls here are to NSGraphicsContext, which does not raise exceptions.275 276 280 ATSUTextLayout layout; 277 281 OSStatus status; … … 307 311 ATSUSetTextLayoutRefCon(m_layout, (URefCon)this); 308 312 309 CGContextRef cgContext = (CGContextRef)[[NSGraphicsContext currentContext] graphicsPort]; 313 // FIXME: There are certain times when this method is called, when we don't have access to a GraphicsContext 314 // measuring text runs with floatWidthForComplexText is one example. 315 // ATSUI requires that we pass a valid CGContextRef to it when specifying kATSUCGContextTag (crashes when passed 0) 316 // ATSUI disables sub-pixel rendering if kATSUCGContextTag is not specified! So we're in a bind. 317 // Sometimes [[NSGraphicsContext currentContext] graphicsPort] may return the wrong (or no!) context. Nothing we can do about it (yet). 318 CGContextRef cgContext = graphicsContext ? graphicsContext->platformContext() : (CGContextRef)[[NSGraphicsContext currentContext] graphicsPort]; 319 310 320 ATSLineLayoutOptions lineLayoutOptions = kATSLineKeepSpacesOutOfMargin | kATSLineHasNoHangers; 311 321 Boolean rtl = m_style.rtl(); … … 468 478 TextRun adjustedRun = style.directionalOverride() ? addDirectionalOverride(run, style.rtl()) : run; 469 479 ATSULayoutParameters params(adjustedRun, style); 470 params.initialize(this); 471 472 [nsColor(graphicsContext->pen().color()) set]; 473 480 params.initialize(this, graphicsContext); 481 474 482 // ATSUI can't draw beyond -32768 to +32767 so we translate the CTM and tell ATSUI to draw at (0, 0). 475 // FIXME: Cut the dependency on currentContext here. 476 NSGraphicsContext *gContext = [NSGraphicsContext currentContext]; 477 CGContextRef context = (CGContextRef)[gContext graphicsPort]; 483 CGContextRef context = graphicsContext->platformContext(); 484 CGContextSetFillColorWithColor(context, cgColor(graphicsContext->pen().color())); 478 485 CGContextTranslateCTM(context, point.x(), point.y()); 479 bool flipped = [gContext isFlipped];480 if (!flipped)481 CGContextScaleCTM(context, 1.0, -1.0);482 486 status = ATSUDrawText(params.m_layout, adjustedRun.from(), runLength, 0, 0); 483 487 if (status == noErr && params.m_hasSyntheticBold) { … … 487 491 status = ATSUDrawText(params.m_layout, adjustedRun.from(), runLength, 0, 0); 488 492 } 489 if (!flipped)490 CGContextScaleCTM(context, 1.0, -1.0);491 493 CGContextTranslateCTM(context, -point.x(), -point.y()); 492 494 493 if (status != noErr) {495 if (status != noErr) 494 496 // Nothing to do but report the error (dev build only). 495 497 LOG_ERROR("ATSUDrawText() failed(%d)", status); 496 }497 498 498 499 disposeATSULayoutParameters(¶ms); … … 555 556 } 556 557 557 void Font::drawGlyphs(GraphicsContext* context, const FontData* font, const GlyphBuffer& glyphBuffer, int from, int numGlyphs, const FloatPoint& point) const 558 { 559 // FIXME: Grab the CGContext from the GraphicsContext eventually, when we have made sure to shield against flipping caused by calls into us 560 // from Safari. 561 NSGraphicsContext *gContext = [NSGraphicsContext currentContext]; 562 CGContextRef cgContext = (CGContextRef)[gContext graphicsPort]; 558 void Font::drawGlyphs(GraphicsContext* context, const FontData* font, const GlyphBuffer& glyphBuffer, int from, int numGlyphs, const FloatPoint& point, bool usePrinterFont) const 559 { 560 CGContextRef cgContext = context->platformContext(); 563 561 564 562 bool originalShouldUseFontSmoothing = wkCGContextGetShouldSmoothFonts(cgContext); … … 567 565 const FontPlatformData& platformData = font->platformData(); 568 566 NSFont* drawFont; 569 if ( [gContext isDrawingToScreen]) {567 if (!usePrinterFont) { 570 568 drawFont = [platformData.font screenFont]; 571 569 if (drawFont != platformData.font) … … 584 582 CGAffineTransform matrix; 585 583 memcpy(&matrix, [drawFont matrix], sizeof(matrix)); 586 if ([gContext isFlipped]) { 587 matrix.b = -matrix.b; 588 matrix.d = -matrix.d; 589 } 584 matrix.b = -matrix.b; 585 matrix.d = -matrix.d; 590 586 if (platformData.syntheticOblique) 591 587 matrix = CGAffineTransformConcat(matrix, CGAffineTransformMake(1, 0, -tanf(SYNTHETIC_OBLIQUE_ANGLE * acosf(0) / 90), 1, 0, 0)); … … 595 591 CGContextSetFontSize(cgContext, 1.0f); 596 592 597 [nsColor(context->pen().color()) set];593 CGContextSetFillColorWithColor(cgContext, cgColor(context->pen().color())); // WebCore expects text to respect the pen color, CG expects text to use fill 598 594 599 595 CGContextSetTextPosition(cgContext, point.x(), point.y()); -
trunk/WebCore/platform/mac/GraphicsContextMac.mm
r15999 r16286 135 135 } 136 136 137 // FIXME: This code should not use NSGraphicsContext currentContext 138 // In order to remove this requirement we will need to use CGPattern instead of NSColor 139 137 140 // Draw underline 138 141 NSGraphicsContext *currentContext = [NSGraphicsContext currentContext]; -
trunk/WebCore/platform/mac/ListBoxMac.mm
r16250 r16286 660 660 - (void)drawRow:(int)row clipRect:(NSRect)clipRect 661 661 { 662 if (!_box) {662 if (!_box) 663 663 return; 664 } 664 665 CGContextRef context = (CGContextRef)[[NSGraphicsContext currentContext] graphicsPort]; 666 ASSERT([[NSGraphicsContext currentContext] isFlipped]); 667 GraphicsContext graphicsContext(context); 665 668 666 669 const ListBoxItem &item = _box->itemAtIndex(row); … … 681 684 bool deleteRenderer = false; 682 685 const Font* renderer; 683 if (isSystemFont) {684 RenderWidget *client = static_cast<RenderWidget *>([self widget]->client());685 bool isPrinting = client->view()->printingMode();686 RenderWidget *client = static_cast<RenderWidget *>([self widget]->client()); 687 bool isPrinting = client->view()->printingMode(); 688 if (isSystemFont) 686 689 renderer = (item.type == ListBoxGroupLabel) ? groupLabelTextRenderer(isPrinting) : itemTextRenderer(isPrinting); 687 }else {690 else { 688 691 if (item.type == ListBoxGroupLabel) { 689 692 deleteRenderer = true; … … 700 703 style.setRTL(rtl); 701 704 style.disableRoundingHacks(); 705 style.setUsePrinterFonts(isPrinting); 702 706 703 707 TextRun run(reinterpret_cast<const UniChar *>(item.string.unicode()), item.string.length()); … … 711 715 point.setY(NSMaxY(cellRect) - renderer->descent() - bottomMargin); 712 716 713 CGContextRef context = (CGContextRef)[[NSGraphicsContext currentContext] graphicsPort];714 GraphicsContext graphicsContext(context);715 717 CGFloat red, green, blue, alpha; 716 718 [[color colorUsingColorSpaceName:NSDeviceRGBColorSpace] getRed:&red green:&green blue:&blue alpha:&alpha]; -
trunk/WebCore/platform/mac/WebCoreTextRenderer.mm
r16250 r16286 38 38 void WebCoreDrawTextAtPoint(const UniChar* buffer, unsigned length, NSPoint point, NSFont* font, NSColor* textColor) 39 39 { 40 NSGraphicsContext *nsContext = [NSGraphicsContext currentContext]; 41 CGContextRef cgContext = (CGContextRef)[nsContext graphicsPort]; 42 GraphicsContext graphicsContext(cgContext); 43 // Safari doesn't flip the NSGraphicsContext before calling WebKit, yet WebCore requires a flipped graphics context. 44 BOOL flipped = [nsContext isFlipped]; 45 if (!flipped) 46 CGContextScaleCTM(cgContext, 1.0, -1.0); 47 40 48 FontPlatformData f(font); 41 49 Font renderer(f); … … 43 51 TextStyle style; 44 52 style.disableRoundingHacks(); 53 style.setUsePrinterFonts(![[NSGraphicsContext currentContext] isDrawingToScreen]); 45 54 CGFloat red, green, blue, alpha; 46 55 [[textColor colorUsingColorSpaceName:NSDeviceRGBColorSpace] getRed:&red green:&green blue:&blue alpha:&alpha]; 47 CGContextRef context = (CGContextRef)[[NSGraphicsContext currentContext] graphicsPort];48 GraphicsContext graphicsContext(context);49 56 graphicsContext.setPen(makeRGBA((int)(red * 255), (int)(green * 255), (int)(blue * 255), (int)(alpha * 255))); 50 57 renderer.drawText(&graphicsContext, run, style, FloatPoint(point.x, point.y)); 58 if (!flipped) 59 CGContextScaleCTM(cgContext, 1.0, -1.0); 51 60 } 52 61 -
trunk/WebCore/rendering/EllipsisBox.cpp
r16250 r16286 24 24 #include "EllipsisBox.h" 25 25 26 #include "Document.h" 26 27 #include "GraphicsContext.h" 27 28 #include "TextStyle.h" … … 47 48 48 49 const String& str = m_str; 49 p->drawText(TextRun(str.impl()), IntPoint(m_x + _tx, m_y + _ty + m_baseline), TextStyle(0, 0, 0, false, _style->visuallyOrdered())); 50 TextStyle textStyle(0, 0, 0, false, _style->visuallyOrdered()); 51 textStyle.setUsePrinterFonts(object()->document()->printing()); 52 p->drawText(TextRun(str.impl()), IntPoint(m_x + _tx, m_y + _ty + m_baseline), textStyle); 50 53 51 54 if (setShadow) -
trunk/WebCore/rendering/InlineTextBox.cpp
r16250 r16286 345 345 346 346 TextStyle textStyle(textObject()->tabWidth(), textPos(), m_toAdd, m_reversed, m_dirOverride || styleToUse->visuallyOrdered()); 347 textStyle.setUsePrinterFonts(isPrinting); 347 348 348 349 if (!paintSelectedTextOnly && !paintSelectedTextSeparately) { -
trunk/WebCore/rendering/RenderImage.cpp
r15415 r16286 36 36 #include "HTMLNames.h" 37 37 #include "RenderView.h" 38 #include "TextStyle.h" 38 39 39 40 using namespace std; … … 254 255 // and only if it fits above the error image. 255 256 TextRun textRun(reinterpret_cast<const UChar*>(text.unicode()), text.length()); 257 TextStyle textStyle; 258 textStyle.setUsePrinterFonts(view()->printingMode()); 256 259 int textWidth = font.width(textRun); 257 260 if (errorPictureDrawn) { 258 261 if (usableWidth >= textWidth && font.height() <= imageY) 259 p->drawText(textRun, IntPoint(ax, ay + ascent) );262 p->drawText(textRun, IntPoint(ax, ay + ascent), textStyle); 260 263 } else if (usableWidth >= textWidth && cHeight >= font.height()) 261 p->drawText(textRun, IntPoint(ax, ay + ascent) );264 p->drawText(textRun, IntPoint(ax, ay + ascent), textStyle); 262 265 } 263 266 } -
trunk/WebCore/rendering/RenderListMarker.cpp
r15415 r16286 32 32 #include "RenderView.h" 33 33 #include "RenderListItem.h" 34 #include "TextStyle.h" 34 35 35 36 using namespace std; … … 232 233 const Font& font = style()->font(); 233 234 TextRun textRun(reinterpret_cast<const UChar*>(m_item.unicode()), m_item.length()); 235 TextStyle textStyle; 236 textStyle.setUsePrinterFonts(view()->printingMode()); 234 237 if (style()->direction() == LTR) { 235 238 int width = font.width(textRun); 236 p->drawText(textRun, marker.location() );239 p->drawText(textRun, marker.location(), textStyle); 237 240 UChar periodSpace[2] = { '.', ' ' }; 238 p->drawText(TextRun(periodSpace, 2), marker.location() + IntSize(width, 0) );241 p->drawText(TextRun(periodSpace, 2), marker.location() + IntSize(width, 0), textStyle); 239 242 } else { 240 243 UChar spacePeriod[2] = { ' ', '.' }; 241 244 TextRun spacePeriodRun(spacePeriod, 2); 242 245 int width = font.width(spacePeriodRun); 243 p->drawText(spacePeriodRun, marker.location() );244 p->drawText(textRun, marker.location() + IntSize(width, 0) );246 p->drawText(spacePeriodRun, marker.location(), textStyle); 247 p->drawText(textRun, marker.location() + IntSize(width, 0), textStyle); 245 248 } 246 249 } -
trunk/WebCore/rendering/RenderThemeMac.mm
r16158 r16286 38 38 namespace WebCore { 39 39 40 // This class automatically saves and restores the current NSGraphicsContext for 41 // functions which call out into AppKit and rely on the currentContext being set 42 class LocalCurrentGraphicsContext : Noncopyable { 43 public: 44 LocalCurrentGraphicsContext(GraphicsContext* graphicsContext) 45 { 46 if (graphicsContext->platformContext() == [[NSGraphicsContext currentContext] graphicsPort]) { 47 m_savedNSGraphicsContext = 0; 48 return; 49 } 50 51 m_savedNSGraphicsContext = [[NSGraphicsContext currentContext] retain]; 52 NSGraphicsContext* newContext = [NSGraphicsContext graphicsContextWithGraphicsPort:graphicsContext->platformContext() flipped:YES]; 53 [NSGraphicsContext setCurrentContext:newContext]; 54 } 55 ~LocalCurrentGraphicsContext() 56 { 57 if (m_savedNSGraphicsContext) { 58 [NSGraphicsContext setCurrentContext:m_savedNSGraphicsContext]; 59 [m_savedNSGraphicsContext release]; 60 } 61 } 62 63 private: 64 NSGraphicsContext* m_savedNSGraphicsContext; 65 }; 66 40 67 enum { 41 68 topMargin, … … 593 620 } 594 621 595 bool RenderThemeMac::paintButton(RenderObject* o, const RenderObject::PaintInfo&, const IntRect& r) 596 { 597 // FIXME: Ignores the GraphicsContext in the PaintInfo and always draws into the current 598 // NSGraphicsContext instead. 622 bool RenderThemeMac::paintButton(RenderObject* o, const RenderObject::PaintInfo& paintInfo, const IntRect& r) 623 { 624 LocalCurrentGraphicsContext LocalCurrentGraphicsContext(paintInfo.p); 599 625 600 626 // Determine the width and height needed for the control and prepare the cell for painting. … … 623 649 } 624 650 625 bool RenderThemeMac::paintTextField(RenderObject* o, const RenderObject::PaintInfo&, const IntRect& r) 626 { 627 // FIXME: Ignores the GraphicsContext in the PaintInfo and always draws into the current 628 // NSGraphicsContext instead. 651 bool RenderThemeMac::paintTextField(RenderObject* o, const RenderObject::PaintInfo& paintInfo, const IntRect& r) 652 { 653 LocalCurrentGraphicsContext LocalCurrentGraphicsContext(paintInfo.p); 629 654 wkDrawBezeledTextFieldCell(r, isEnabled(o) && !isReadOnlyControl(o)); 630 655 return false; … … 638 663 } 639 664 640 bool RenderThemeMac::paintTextArea(RenderObject* o, const RenderObject::PaintInfo&, const IntRect& r) 641 { 642 // FIXME: Ignores the GraphicsContext in the PaintInfo and always draws into the current 643 // NSGraphicsContext instead. 665 bool RenderThemeMac::paintTextArea(RenderObject* o, const RenderObject::PaintInfo& paintInfo, const IntRect& r) 666 { 667 LocalCurrentGraphicsContext LocalCurrentGraphicsContext(paintInfo.p); 644 668 wkDrawBezeledTextArea(r, isEnabled(o) && !isReadOnlyControl(o)); 645 669 return false;
Note:
See TracChangeset
for help on using the changeset viewer.