| OLD | NEW |
| 1 /** | 1 /** |
| 2 * Copyright (C) 2003, 2006 Apple Computer, Inc. | 2 * Copyright (C) 2003, 2006 Apple Computer, Inc. |
| 3 * | 3 * |
| 4 * This library is free software; you can redistribute it and/or | 4 * This library is free software; you can redistribute it and/or |
| 5 * modify it under the terms of the GNU Library General Public | 5 * modify it under the terms of the GNU Library General Public |
| 6 * License as published by the Free Software Foundation; either | 6 * License as published by the Free Software Foundation; either |
| 7 * version 2 of the License, or (at your option) any later version. | 7 * version 2 of the License, or (at your option) any later version. |
| 8 * | 8 * |
| 9 * This library is distributed in the hope that it will be useful, | 9 * This library is distributed in the hope that it will be useful, |
| 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of | 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| (...skipping 15 matching lines...) Expand all Loading... |
| 26 #include "sky/engine/core/rendering/RenderBlock.h" | 26 #include "sky/engine/core/rendering/RenderBlock.h" |
| 27 #include "sky/engine/core/rendering/RootInlineBox.h" | 27 #include "sky/engine/core/rendering/RootInlineBox.h" |
| 28 #include "sky/engine/core/rendering/TextRunConstructor.h" | 28 #include "sky/engine/core/rendering/TextRunConstructor.h" |
| 29 #include "sky/engine/core/rendering/style/ShadowList.h" | 29 #include "sky/engine/core/rendering/style/ShadowList.h" |
| 30 #include "sky/engine/platform/fonts/Font.h" | 30 #include "sky/engine/platform/fonts/Font.h" |
| 31 #include "sky/engine/platform/graphics/GraphicsContextStateSaver.h" | 31 #include "sky/engine/platform/graphics/GraphicsContextStateSaver.h" |
| 32 #include "sky/engine/platform/text/TextRun.h" | 32 #include "sky/engine/platform/text/TextRun.h" |
| 33 | 33 |
| 34 namespace blink { | 34 namespace blink { |
| 35 | 35 |
| 36 void EllipsisBox::paint(PaintInfo& paintInfo, const LayoutPoint& paintOffset, La
youtUnit lineTop, LayoutUnit lineBottom) | 36 void EllipsisBox::paint(PaintInfo& paintInfo, const LayoutPoint& paintOffset, La
youtUnit lineTop, LayoutUnit lineBottom, Vector<RenderBox*>& layers) |
| 37 { | 37 { |
| 38 GraphicsContext* context = paintInfo.context; | 38 GraphicsContext* context = paintInfo.context; |
| 39 RenderStyle* style = renderer().style(isFirstLineStyle()); | 39 RenderStyle* style = renderer().style(isFirstLineStyle()); |
| 40 | 40 |
| 41 const Font& font = style->font(); | 41 const Font& font = style->font(); |
| 42 FloatPoint boxOrigin = locationIncludingFlipping(); | 42 FloatPoint boxOrigin = locationIncludingFlipping(); |
| 43 boxOrigin.moveBy(FloatPoint(paintOffset)); | 43 boxOrigin.moveBy(FloatPoint(paintOffset)); |
| 44 FloatRect boxRect(boxOrigin, LayoutSize(logicalWidth(), virtualLogicalHeight
())); | 44 FloatRect boxRect(boxOrigin, LayoutSize(logicalWidth(), virtualLogicalHeight
())); |
| 45 GraphicsContextStateSaver stateSaver(*context); | 45 GraphicsContextStateSaver stateSaver(*context); |
| 46 FloatPoint textOrigin = FloatPoint(boxOrigin.x(), boxOrigin.y() + font.fontM
etrics().ascent()); | 46 FloatPoint textOrigin = FloatPoint(boxOrigin.x(), boxOrigin.y() + font.fontM
etrics().ascent()); |
| (...skipping 21 matching lines...) Expand all Loading... |
| 68 textRunPaintInfo.bounds = boxRect; | 68 textRunPaintInfo.bounds = boxRect; |
| 69 context->drawText(font, textRunPaintInfo, textOrigin); | 69 context->drawText(font, textRunPaintInfo, textOrigin); |
| 70 | 70 |
| 71 // Restore the regular fill color. | 71 // Restore the regular fill color. |
| 72 if (styleTextColor != context->fillColor()) | 72 if (styleTextColor != context->fillColor()) |
| 73 context->setFillColor(styleTextColor); | 73 context->setFillColor(styleTextColor); |
| 74 | 74 |
| 75 if (hasShadow) | 75 if (hasShadow) |
| 76 context->clearDrawLooper(); | 76 context->clearDrawLooper(); |
| 77 | 77 |
| 78 paintMarkupBox(paintInfo, paintOffset, lineTop, lineBottom, style); | 78 paintMarkupBox(paintInfo, paintOffset, lineTop, lineBottom, style, layers); |
| 79 } | 79 } |
| 80 | 80 |
| 81 InlineBox* EllipsisBox::markupBox() const | 81 InlineBox* EllipsisBox::markupBox() const |
| 82 { | 82 { |
| 83 if (!m_shouldPaintMarkupBox || !renderer().isRenderBlock()) | 83 if (!m_shouldPaintMarkupBox || !renderer().isRenderBlock()) |
| 84 return 0; | 84 return 0; |
| 85 | 85 |
| 86 RenderBlock& block = toRenderBlock(renderer()); | 86 RenderBlock& block = toRenderBlock(renderer()); |
| 87 RootInlineBox* lastLine = block.lineAtIndex(block.lineCount() - 1); | 87 RootInlineBox* lastLine = block.lineAtIndex(block.lineCount() - 1); |
| 88 if (!lastLine) | 88 if (!lastLine) |
| 89 return 0; | 89 return 0; |
| 90 | 90 |
| 91 // If the last line-box on the last line of a block is a link, -webkit-line-
clamp paints that box after the ellipsis. | 91 // If the last line-box on the last line of a block is a link, -webkit-line-
clamp paints that box after the ellipsis. |
| 92 // It does not actually move the link. | 92 // It does not actually move the link. |
| 93 InlineBox* anchorBox = lastLine->lastChild(); | 93 InlineBox* anchorBox = lastLine->lastChild(); |
| 94 if (!anchorBox || !anchorBox->renderer().style()->isLink()) | 94 if (!anchorBox || !anchorBox->renderer().style()->isLink()) |
| 95 return 0; | 95 return 0; |
| 96 | 96 |
| 97 return anchorBox; | 97 return anchorBox; |
| 98 } | 98 } |
| 99 | 99 |
| 100 void EllipsisBox::paintMarkupBox(PaintInfo& paintInfo, const LayoutPoint& paintO
ffset, LayoutUnit lineTop, LayoutUnit lineBottom, RenderStyle* style) | 100 void EllipsisBox::paintMarkupBox(PaintInfo& paintInfo, const LayoutPoint& paintO
ffset, LayoutUnit lineTop, LayoutUnit lineBottom, RenderStyle* style, Vector<Ren
derBox*>& layers) |
| 101 { | 101 { |
| 102 InlineBox* markupBox = this->markupBox(); | 102 InlineBox* markupBox = this->markupBox(); |
| 103 if (!markupBox) | 103 if (!markupBox) |
| 104 return; | 104 return; |
| 105 | 105 |
| 106 LayoutPoint adjustedPaintOffset = paintOffset; | 106 LayoutPoint adjustedPaintOffset = paintOffset; |
| 107 adjustedPaintOffset.move(x() + m_logicalWidth - markupBox->x(), | 107 adjustedPaintOffset.move(x() + m_logicalWidth - markupBox->x(), |
| 108 y() + style->fontMetrics().ascent() - (markupBox->y() + markupBox->rende
rer().style(isFirstLineStyle())->fontMetrics().ascent())); | 108 y() + style->fontMetrics().ascent() - (markupBox->y() + markupBox->rende
rer().style(isFirstLineStyle())->fontMetrics().ascent())); |
| 109 markupBox->paint(paintInfo, adjustedPaintOffset, lineTop, lineBottom); | 109 markupBox->paint(paintInfo, adjustedPaintOffset, lineTop, lineBottom, layers
); |
| 110 } | 110 } |
| 111 | 111 |
| 112 IntRect EllipsisBox::selectionRect() | 112 IntRect EllipsisBox::selectionRect() |
| 113 { | 113 { |
| 114 RenderStyle* style = renderer().style(isFirstLineStyle()); | 114 RenderStyle* style = renderer().style(isFirstLineStyle()); |
| 115 const Font& font = style->font(); | 115 const Font& font = style->font(); |
| 116 return enclosingIntRect(font.selectionRectForText(constructTextRun(&renderer
(), font, m_str, style, TextRun::AllowTrailingExpansion), IntPoint(logicalLeft()
, logicalTop() + root().selectionTopAdjustedForPrecedingBlock()), root().selecti
onHeightAdjustedForPrecedingBlock())); | 116 return enclosingIntRect(font.selectionRectForText(constructTextRun(&renderer
(), font, m_str, style, TextRun::AllowTrailingExpansion), IntPoint(logicalLeft()
, logicalTop() + root().selectionTopAdjustedForPrecedingBlock()), root().selecti
onHeightAdjustedForPrecedingBlock())); |
| 117 } | 117 } |
| 118 | 118 |
| 119 void EllipsisBox::paintSelection(GraphicsContext* context, const FloatPoint& box
Origin, RenderStyle* style, const Font& font) | 119 void EllipsisBox::paintSelection(GraphicsContext* context, const FloatPoint& box
Origin, RenderStyle* style, const Font& font) |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 159 if (visibleToHitTestRequest(request) && boundsRect.intersects(HitTestLocatio
n::rectForPoint(locationInContainer.point(), 0, 0, 0, 0))) { | 159 if (visibleToHitTestRequest(request) && boundsRect.intersects(HitTestLocatio
n::rectForPoint(locationInContainer.point(), 0, 0, 0, 0))) { |
| 160 renderer().updateHitTestResult(result, locationInContainer.point() - toL
ayoutSize(adjustedLocation)); | 160 renderer().updateHitTestResult(result, locationInContainer.point() - toL
ayoutSize(adjustedLocation)); |
| 161 if (!result.addNodeToRectBasedTestResult(renderer().node(), request, loc
ationInContainer, boundsRect)) | 161 if (!result.addNodeToRectBasedTestResult(renderer().node(), request, loc
ationInContainer, boundsRect)) |
| 162 return true; | 162 return true; |
| 163 } | 163 } |
| 164 | 164 |
| 165 return false; | 165 return false; |
| 166 } | 166 } |
| 167 | 167 |
| 168 } // namespace blink | 168 } // namespace blink |
| OLD | NEW |