diff --git a/Source/WebCore/platform/graphics/haiku/GraphicsContextHaiku.cpp b/Source/WebCore/platform/graphics/haiku/GraphicsContextHaiku.cpp index 42b4be465c30..68030eea033b 100644 --- a/Source/WebCore/platform/graphics/haiku/GraphicsContextHaiku.cpp +++ b/Source/WebCore/platform/graphics/haiku/GraphicsContextHaiku.cpp @@ -72,11 +72,7 @@ void GraphicsContextHaiku::drawRect(const FloatRect& rect, float borderThickness m_view->FillRect(rect, B_SOLID_LOW); // TODO: Support gradients - if (strokeStyle() != NoStroke && borderThickness > 0.0f && strokeColor().isVisible()) - { - m_view->SetPenSize(borderThickness); - m_view->StrokeRect(rect, m_strokeStyle); - } + strokeRect(rect, borderThickness); } void GraphicsContextHaiku::drawNativeImage(NativeImage& image, const FloatSize& imageSize, const FloatRect& destRect, const FloatRect& srcRect, const ImagePaintingOptions& options) @@ -105,11 +101,27 @@ void GraphicsContextHaiku::drawBitmap(BBitmap* image, const FloatSize& imageSize } // This is only used to draw borders. +// The line width is already accounted for, the points being not the center of +// the edges, but opposite corners of the rectangle containing the line. void GraphicsContextHaiku::drawLine(const FloatPoint& point1, const FloatPoint& point2) { if (strokeStyle() == NoStroke || !strokeColor().isVisible()) return; - m_view->StrokeLine(point1, point2, m_strokeStyle); + + BPoint start = point1; + BPoint end = point2; + // This test breaks for a vertical line as wide as long, but in that + // case there's no information to tell vertical and horizontal apart. + if (fabs(end.y - start.y - m_view->PenSize()) < 1) { + // Horizontal line + end.y = start.y = (end.y + start.y) / 2; + end.x--; + } else { + // Vertical line + end.x = start.x = (end.x + start.x) / 2; + end.y--; + } + m_view->StrokeLine(start, end, m_strokeStyle); } // This method is only used to draw the little circles used in lists. @@ -396,19 +408,34 @@ void GraphicsContextHaiku::drawFocusRing(const Vector& rects, float w m_view->PopState(); } -void GraphicsContextHaiku::drawLinesForText(const FloatPoint& point, float, const DashArray& widths, bool printing, bool doubleUnderlines, WebCore::StrokeStyle) +void GraphicsContextHaiku::drawLinesForText(const FloatPoint& point, + float thickness, const DashArray& widths, bool printing, + bool doubleUnderlines, WebCore::StrokeStyle style) { - if (widths.size() <= 0) + if (widths.isEmpty() || style == NoStroke) + return; + + Color lineColor(strokeColor()); + FloatRect bounds = computeLineBoundsAndAntialiasingModeForText( + FloatRect(point, FloatSize(widths.last(), thickness)), + printing, lineColor); + if (bounds.isEmpty() || !strokeColor().isVisible()) return; + float y = bounds.center().y(); + + float oldSize = m_view->PenSize(); + m_view->SetPenSize(bounds.height()); + // TODO would be faster to use BeginLineArray/EndLineArray here - // TODO in Cairo, these are not lines, but filled rectangle? Whats the thickness? for (size_t i = 0; i < widths.size(); i += 2) { - drawLine( - FloatPoint(point.x() + widths[i], point.y()), - FloatPoint(point.x() + widths[i+1], point.y())); + m_view->StrokeLine( + BPoint(bounds.x() + widths[i], y), + BPoint(bounds.x() + widths[i+1], y)); } + + m_view->SetPenSize(oldSize); } void GraphicsContextHaiku::drawDotsForDocumentMarker(WebCore::FloatRect const&,