diff options
Diffstat (limited to 'Source/WebCore/rendering/EllipsisBox.cpp')
-rw-r--r-- | Source/WebCore/rendering/EllipsisBox.cpp | 63 |
1 files changed, 33 insertions, 30 deletions
diff --git a/Source/WebCore/rendering/EllipsisBox.cpp b/Source/WebCore/rendering/EllipsisBox.cpp index b9ce00ad1..fec6f207e 100644 --- a/Source/WebCore/rendering/EllipsisBox.cpp +++ b/Source/WebCore/rendering/EllipsisBox.cpp @@ -1,5 +1,5 @@ /** - * Copyright (C) 2003, 2006 Apple Computer, Inc. + * Copyright (C) 2003, 2006 Apple Inc. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public @@ -21,7 +21,7 @@ #include "EllipsisBox.h" #include "Document.h" -#include "Font.h" +#include "FontCascade.h" #include "GraphicsContext.h" #include "HitTestResult.h" #include "InlineTextBox.h" @@ -31,48 +31,51 @@ namespace WebCore { -EllipsisBox::EllipsisBox(RenderBlockFlow& renderer, const AtomicString& ellipsisStr, InlineFlowBox* parent, int width, int height, int y, bool firstLine, bool isVertical, InlineBox* markupBox) - : InlineElementBox(renderer, FloatPoint(0, y), width, firstLine, true, false, false, isVertical, 0, 0, parent) +EllipsisBox::EllipsisBox(RenderBlockFlow& renderer, const AtomicString& ellipsisStr, InlineFlowBox* parent, int width, int height, int y, bool firstLine, bool isHorizontal, InlineBox* markupBox) + : InlineElementBox(renderer, FloatPoint(0, y), width, firstLine, true, false, false, isHorizontal, 0, 0, parent) , m_shouldPaintMarkupBox(markupBox) , m_height(height) , m_str(ellipsisStr) , m_selectionState(RenderObject::SelectionNone) { +#if !ASSERT_WITH_SECURITY_IMPLICATION_DISABLED + m_isEverInChildList = false; +#endif } void EllipsisBox::paint(PaintInfo& paintInfo, const LayoutPoint& paintOffset, LayoutUnit lineTop, LayoutUnit lineBottom) { - GraphicsContext* context = paintInfo.context; + GraphicsContext& context = paintInfo.context(); const RenderStyle& lineStyle = this->lineStyle(); Color textColor = lineStyle.visitedDependentColor(CSSPropertyWebkitTextFillColor); - if (textColor != context->fillColor()) - context->setFillColor(textColor, lineStyle.colorSpace()); + if (textColor != context.fillColor()) + context.setFillColor(textColor); bool setShadow = false; if (lineStyle.textShadow()) { - context->setShadow(LayoutSize(lineStyle.textShadow()->x(), lineStyle.textShadow()->y()), - lineStyle.textShadow()->radius(), lineStyle.textShadow()->color(), lineStyle.colorSpace()); + context.setShadow(LayoutSize(lineStyle.textShadow()->x(), lineStyle.textShadow()->y()), + lineStyle.textShadow()->radius(), lineStyle.textShadow()->color()); setShadow = true; } - const Font& font = lineStyle.font(); + const FontCascade& font = lineStyle.fontCascade(); if (selectionState() != RenderObject::SelectionNone) { paintSelection(context, paintOffset, lineStyle, font); // Select the correct color for painting the text. - Color foreground = paintInfo.forceBlackText() ? Color::black : blockFlow().selectionForegroundColor(); + Color foreground = paintInfo.forceTextColor() ? paintInfo.forcedTextColor() : blockFlow().selectionForegroundColor(); if (foreground.isValid() && foreground != textColor) - context->setFillColor(foreground, lineStyle.colorSpace()); + context.setFillColor(foreground); } // FIXME: Why is this always LTR? Fix by passing correct text run flags below. - context->drawText(font, RenderBlock::constructTextRun(&blockFlow(), font, m_str, lineStyle, TextRun::AllowTrailingExpansion), LayoutPoint(x() + paintOffset.x(), y() + paintOffset.y() + lineStyle.fontMetrics().ascent())); + context.drawText(font, RenderBlock::constructTextRun(m_str, lineStyle, AllowTrailingExpansion), LayoutPoint(x() + paintOffset.x(), y() + paintOffset.y() + lineStyle.fontMetrics().ascent())); // Restore the regular fill color. - if (textColor != context->fillColor()) - context->setFillColor(textColor, lineStyle.colorSpace()); + if (textColor != context.fillColor()) + context.setFillColor(textColor); if (setShadow) - context->clearShadow(); + context.clearShadow(); paintMarkupBox(paintInfo, paintOffset, lineTop, lineBottom, lineStyle); } @@ -110,13 +113,16 @@ void EllipsisBox::paintMarkupBox(PaintInfo& paintInfo, const LayoutPoint& paintO IntRect EllipsisBox::selectionRect() { const RenderStyle& lineStyle = this->lineStyle(); - const Font& font = lineStyle.font(); + const FontCascade& font = lineStyle.fontCascade(); const RootInlineBox& rootBox = root(); // FIXME: Why is this always LTR? Fix by passing correct text run flags below. - return enclosingIntRect(font.selectionRectForText(RenderBlock::constructTextRun(&blockFlow(), font, m_str, lineStyle, TextRun::AllowTrailingExpansion), IntPoint(x(), y() + rootBox.selectionTopAdjustedForPrecedingBlock()), rootBox.selectionHeightAdjustedForPrecedingBlock())); + LayoutRect selectionRect = LayoutRect(x(), y() + rootBox.selectionTopAdjustedForPrecedingBlock(), 0, rootBox.selectionHeightAdjustedForPrecedingBlock()); + font.adjustSelectionRectForText(RenderBlock::constructTextRun(m_str, lineStyle, AllowTrailingExpansion), selectionRect); + // FIXME: use directional pixel snapping instead. + return enclosingIntRect(selectionRect); } -void EllipsisBox::paintSelection(GraphicsContext* context, const LayoutPoint& paintOffset, const RenderStyle& style, const Font& font) +void EllipsisBox::paintSelection(GraphicsContext& context, const LayoutPoint& paintOffset, const RenderStyle& style, const FontCascade& font) { Color textColor = style.visitedDependentColor(CSSPropertyColor); Color c = blockFlow().selectionBackgroundColor(); @@ -129,27 +135,24 @@ void EllipsisBox::paintSelection(GraphicsContext* context, const LayoutPoint& pa c = Color(0xff - c.red(), 0xff - c.green(), 0xff - c.blue()); const RootInlineBox& rootBox = root(); - LayoutUnit top = rootBox.selectionTop(); - LayoutUnit h = rootBox.selectionHeight(); - FloatRect clipRect(x() + paintOffset.x(), top + paintOffset.y(), m_logicalWidth, h); - alignSelectionRectToDevicePixels(clipRect); - - GraphicsContextStateSaver stateSaver(*context); - context->clip(clipRect); + GraphicsContextStateSaver stateSaver(context); // FIXME: Why is this always LTR? Fix by passing correct text run flags below. - context->drawHighlightForText(font, RenderBlock::constructTextRun(&blockFlow(), font, m_str, style, TextRun::AllowTrailingExpansion), roundedIntPoint(LayoutPoint(x() + paintOffset.x(), y() + paintOffset.y() + top)), h, c, style.colorSpace()); + LayoutRect selectionRect = LayoutRect(x() + paintOffset.x(), y() + paintOffset.y() + rootBox.selectionTop(), 0, rootBox.selectionHeight()); + TextRun run = RenderBlock::constructTextRun(m_str, style, AllowTrailingExpansion); + font.adjustSelectionRectForText(run, selectionRect); + context.fillRect(snapRectToDevicePixelsWithWritingDirection(selectionRect, renderer().document().deviceScaleFactor(), run.ltr()), c); } -bool EllipsisBox::nodeAtPoint(const HitTestRequest& request, HitTestResult& result, const HitTestLocation& locationInContainer, const LayoutPoint& accumulatedOffset, LayoutUnit lineTop, LayoutUnit lineBottom) +bool EllipsisBox::nodeAtPoint(const HitTestRequest& request, HitTestResult& result, const HitTestLocation& locationInContainer, const LayoutPoint& accumulatedOffset, LayoutUnit lineTop, LayoutUnit lineBottom, HitTestAction hitTestAction) { - LayoutPoint adjustedLocation = accumulatedOffset + roundedLayoutPoint(topLeft()); + LayoutPoint adjustedLocation = accumulatedOffset + LayoutPoint(topLeft()); // Hit test the markup box. if (InlineBox* markupBox = this->markupBox()) { const RenderStyle& lineStyle = this->lineStyle(); LayoutUnit mtx = adjustedLocation.x() + m_logicalWidth - markupBox->x(); LayoutUnit mty = adjustedLocation.y() + lineStyle.fontMetrics().ascent() - (markupBox->y() + markupBox->lineStyle().fontMetrics().ascent()); - if (markupBox->nodeAtPoint(request, result, locationInContainer, LayoutPoint(mtx, mty), lineTop, lineBottom)) { + if (markupBox->nodeAtPoint(request, result, locationInContainer, LayoutPoint(mtx, mty), lineTop, lineBottom, hitTestAction)) { blockFlow().updateHitTestResult(result, locationInContainer.point() - LayoutSize(mtx, mty)); return true; } |