// Draws a filled rectangle with a stroked border. void GraphicsContext::drawRect(const IntRect& rect) { // FIXME: this function does not handle patterns and gradients // like drawPath does, it probably should. if (paintingDisabled()) return; CGContextRef context = platformContext(); CGContextFillRect(context, rect); if (strokeStyle() != NoStroke) { // We do a fill of four rects to simulate the stroke of a border. Color oldFillColor = fillColor(); if (oldFillColor != strokeColor()) setCGFillColor(context, strokeColor(), strokeColorSpace()); CGRect rects[4] = { FloatRect(rect.x(), rect.y(), rect.width(), 1), FloatRect(rect.x(), rect.bottom() - 1, rect.width(), 1), FloatRect(rect.x(), rect.y() + 1, 1, rect.height() - 2), FloatRect(rect.right() - 1, rect.y() + 1, 1, rect.height() - 2) }; CGContextFillRects(context, rects, 4); if (oldFillColor != strokeColor()) setCGFillColor(context, oldFillColor, fillColorSpace()); } }
// Draws a filled rectangle with a stroked border. void GraphicsContext::drawRect(const IntRect& rect) { if (paintingDisabled()) return; CGContextRef context = platformContext(); if (fillColor().alpha()) CGContextFillRect(context, rect); if (strokeStyle() != NoStroke && strokeColor().alpha()) { // We do a fill of four rects to simulate the stroke of a border. Color oldFillColor = fillColor(); if (oldFillColor != strokeColor()) setCGFillColor(context, strokeColor()); CGRect rects[4] = { FloatRect(rect.x(), rect.y(), rect.width(), 1), FloatRect(rect.x(), rect.bottom() - 1, rect.width(), 1), FloatRect(rect.x(), rect.y() + 1, 1, rect.height() - 2), FloatRect(rect.right() - 1, rect.y() + 1, 1, rect.height() - 2) }; CGContextFillRects(context, rects, 4); if (oldFillColor != strokeColor()) setCGFillColor(context, oldFillColor); } }