diff options
Diffstat (limited to 'WebCore/rendering/InlineTextBox.cpp')
-rw-r--r-- | WebCore/rendering/InlineTextBox.cpp | 58 |
1 files changed, 30 insertions, 28 deletions
diff --git a/WebCore/rendering/InlineTextBox.cpp b/WebCore/rendering/InlineTextBox.cpp index eb5947c..68bff3c 100644 --- a/WebCore/rendering/InlineTextBox.cpp +++ b/WebCore/rendering/InlineTextBox.cpp @@ -139,10 +139,10 @@ IntRect InlineTextBox::selectionRect(int tx, int ty, int startPos, int endPos) IntRect r = enclosingIntRect(f.selectionRectForText(TextRun(characters, len, textObj->allowTabs(), textPos(), m_toAdd, direction() == RTL, m_dirOverride), IntPoint(tx + m_x, ty + selTop), selHeight, sPos, ePos)); - if (r.x() > tx + m_x + m_width) + if (r.x() > tx + m_x + m_logicalWidth) r.setWidth(0); - else if (r.right() - 1 > tx + m_x + m_width) - r.setWidth(tx + m_x + m_width - r.x()); + else if (r.right() - 1 > tx + m_x + m_logicalWidth) + r.setWidth(tx + m_x + m_logicalWidth - r.x()); return r; } @@ -182,7 +182,7 @@ int InlineTextBox::placeEllipsisBox(bool flowIsLTR, int visibleLeftEdge, int vis // LTR: the left edge of the ellipsis is to the left of our text run. // RTL: the right edge of the ellipsis is to the right of our text run. bool ltrFullTruncation = flowIsLTR && ellipsisX <= m_x; - bool rtlFullTruncation = !flowIsLTR && ellipsisX >= (m_x + m_width); + bool rtlFullTruncation = !flowIsLTR && ellipsisX >= (m_x + m_logicalWidth); if (ltrFullTruncation || rtlFullTruncation) { // Too far. Just set full truncation, but return -1 and let the ellipsis just be placed at the edge of the box. m_truncation = cFullTruncation; @@ -190,7 +190,7 @@ int InlineTextBox::placeEllipsisBox(bool flowIsLTR, int visibleLeftEdge, int vis return -1; } - bool ltrEllipsisWithinBox = flowIsLTR && (ellipsisX < m_x + m_width); + bool ltrEllipsisWithinBox = flowIsLTR && (ellipsisX < m_x + m_logicalWidth); bool rtlEllipsisWithinBox = !flowIsLTR && (ellipsisX > m_x); if (ltrEllipsisWithinBox || rtlEllipsisWithinBox) { foundBox = true; @@ -202,7 +202,7 @@ int InlineTextBox::placeEllipsisBox(bool flowIsLTR, int visibleLeftEdge, int vis if (ltr != flowIsLTR) { // Width in pixels of the visible portion of the box, excluding the ellipsis. int visibleBoxWidth = visibleRightEdge - visibleLeftEdge - ellipsisWidth; - ellipsisX = ltr ? m_x + visibleBoxWidth : m_x + m_width - visibleBoxWidth; + ellipsisX = ltr ? m_x + visibleBoxWidth : m_x + m_logicalWidth - visibleBoxWidth; } int offset = offsetForPosition(ellipsisX, false); @@ -228,7 +228,7 @@ int InlineTextBox::placeEllipsisBox(bool flowIsLTR, int visibleLeftEdge, int vis if (flowIsLTR) return m_x + widthOfVisibleText; else - return (m_x + m_width) - widthOfVisibleText - ellipsisWidth; + return (m_x + m_logicalWidth) - widthOfVisibleText - ellipsisWidth; } return -1; } @@ -286,7 +286,7 @@ bool InlineTextBox::nodeAtPoint(const HitTestRequest&, HitTestResult& result, in if (isLineBreak()) return false; - IntRect rect(tx + m_x, ty + m_y, m_width, height()); + IntRect rect(tx + m_x, ty + m_y, m_logicalWidth, logicalHeight()); if (m_truncation != cFullTruncation && visibleToHitTesting() && rect.intersects(result.rectFromPoint(x, y))) { renderer()->updateHitTestResult(result, IntPoint(x - tx, y - ty)); if (!result.addNodeToRectBasedTestResult(renderer()->node(), x, y, rect)) @@ -367,9 +367,9 @@ void InlineTextBox::paint(PaintInfo& paintInfo, int tx, int ty) // FIXME: Technically we're potentially incorporating other visual overflow that had nothing to do with us. // Would it be simpler to just check our own shadow and stroke overflow by hand here? int leftOverflow = parent()->x() - parent()->leftVisualOverflow(); - int rightOverflow = parent()->rightVisualOverflow() - (parent()->x() + parent()->width()); + int rightOverflow = parent()->rightVisualOverflow() - (parent()->x() + parent()->logicalWidth()); int xPos = tx + m_x - leftOverflow; - int w = width() + leftOverflow + rightOverflow; + int w = logicalWidth() + leftOverflow + rightOverflow; if (xPos >= paintInfo.rect.right() || xPos + w <= paintInfo.rect.x()) return; @@ -393,7 +393,7 @@ void InlineTextBox::paint(PaintInfo& paintInfo, int tx, int ty) // NOTE: WebKit's behavior differs from that of IE which appears to just overlay the ellipsis on top of the // truncated string i.e. |Hello|CBA| -> |...lo|CBA| int widthOfVisibleText = toRenderText(renderer())->width(m_start, m_truncation, textPos(), m_firstLine); - int widthOfHiddenText = m_width - widthOfVisibleText; + int widthOfHiddenText = m_logicalWidth - widthOfVisibleText; // FIXME: The hit testing logic also needs to take this translation int account. tx += direction() == LTR ? widthOfHiddenText : -widthOfHiddenText; } @@ -526,9 +526,9 @@ void InlineTextBox::paint(PaintInfo& paintInfo, int tx, int ty) updateGraphicsContext(context, textFillColor, textStrokeColor, textStrokeWidth, styleToUse->colorSpace()); if (!paintSelectedTextSeparately || ePos <= sPos) { // FIXME: Truncate right-to-left text correctly. - paintTextWithShadows(context, font, textRun, 0, length, length, textOrigin, m_x + tx, m_y + ty, width(), height(), textShadow, textStrokeWidth > 0); + paintTextWithShadows(context, font, textRun, 0, length, length, textOrigin, m_x + tx, m_y + ty, logicalWidth(), logicalHeight(), textShadow, textStrokeWidth > 0); } else - paintTextWithShadows(context, font, textRun, ePos, sPos, length, textOrigin, m_x + tx, m_y + ty, width(), height(), textShadow, textStrokeWidth > 0); + paintTextWithShadows(context, font, textRun, ePos, sPos, length, textOrigin, m_x + tx, m_y + ty, logicalWidth(), logicalHeight(), textShadow, textStrokeWidth > 0); if (textStrokeWidth > 0) context->restore(); @@ -540,7 +540,7 @@ void InlineTextBox::paint(PaintInfo& paintInfo, int tx, int ty) context->save(); updateGraphicsContext(context, selectionFillColor, selectionStrokeColor, selectionStrokeWidth, styleToUse->colorSpace()); - paintTextWithShadows(context, font, textRun, sPos, ePos, length, textOrigin, m_x + tx, m_y + ty, width(), height(), selectionShadow, selectionStrokeWidth > 0); + paintTextWithShadows(context, font, textRun, sPos, ePos, length, textOrigin, m_x + tx, m_y + ty, logicalWidth(), logicalHeight(), selectionShadow, selectionStrokeWidth > 0); if (selectionStrokeWidth > 0) context->restore(); @@ -633,7 +633,7 @@ void InlineTextBox::paintSelection(GraphicsContext* context, int tx, int ty, Ren ePos = length; } - context->clip(IntRect(m_x + tx, y + ty, m_width, h)); + context->clip(IntRect(m_x + tx, y + ty, m_logicalWidth, h)); context->drawHighlightForText(font, TextRun(characters, length, textRenderer()->allowTabs(), textPos(), m_toAdd, direction() == RTL, m_dirOverride || style->visuallyOrdered()), IntPoint(m_x + tx, y + ty), h, c, style->colorSpace(), sPos, ePos); @@ -675,8 +675,8 @@ void InlineTextBox::paintCustomHighlight(int tx, int ty, const AtomicString& typ return; RootInlineBox* r = root(); - FloatRect rootRect(tx + r->x(), ty + selectionTop(), r->width(), selectionHeight()); - FloatRect textRect(tx + x(), rootRect.y(), width(), rootRect.height()); + FloatRect rootRect(tx + r->x(), ty + selectionTop(), r->logicalWidth(), selectionHeight()); + FloatRect textRect(tx + x(), rootRect.y(), logicalWidth(), rootRect.height()); page->chrome()->client()->paintCustomHighlight(renderer()->node(), type, textRect, rootRect, true, false); } @@ -691,11 +691,11 @@ void InlineTextBox::paintDecoration(GraphicsContext* context, int tx, int ty, in if (m_truncation == cFullTruncation) return; - int width = m_width; + int width = m_logicalWidth; if (m_truncation != cNoTruncation) { width = toRenderText(renderer())->width(m_start, m_truncation, textPos(), m_firstLine); if (direction() == RTL) - tx += (m_width - width); + tx += (m_logicalWidth - width); } // Get the text decoration colors. @@ -775,7 +775,7 @@ static GraphicsContext::TextCheckingLineStyle textCheckingLineStyleForMarkerType return GraphicsContext::TextCheckingSpellingLineStyle; case DocumentMarker::Grammar: return GraphicsContext::TextCheckingGrammarLineStyle; - case DocumentMarker::Replacement: + case DocumentMarker::CorrectionIndicator: return GraphicsContext::TextCheckingReplacementLineStyle; default: ASSERT_NOT_REACHED(); @@ -793,7 +793,7 @@ void InlineTextBox::paintSpellingOrGrammarMarker(GraphicsContext* pt, int tx, in return; int start = 0; // start of line to draw, relative to tx - int width = m_width; // how much line to draw + int width = m_logicalWidth; // how much line to draw // Determine whether we need to measure text bool markerSpansWholeBox = true; @@ -837,11 +837,11 @@ void InlineTextBox::paintSpellingOrGrammarMarker(GraphicsContext* pt, int tx, in // we pin to two pixels under the baseline. int lineThickness = cMisspellingLineThickness; int baseline = renderer()->style(m_firstLine)->font().ascent(); - int descent = height() - baseline; + int descent = logicalHeight() - baseline; int underlineOffset; if (descent <= (2 + lineThickness)) { // Place the underline at the very bottom of the text in small/medium fonts. - underlineOffset = height() - lineThickness; + underlineOffset = logicalHeight() - lineThickness; } else { // In larger fonts, though, place the underline up near the baseline to prevent a big gap. underlineOffset = baseline + 2; @@ -872,7 +872,7 @@ void InlineTextBox::paintTextMatchMarker(GraphicsContext* pt, int tx, int ty, co renderer()->theme()->platformInactiveTextSearchHighlightColor(); pt->save(); updateGraphicsContext(pt, color, color, 0, style->colorSpace()); // Don't draw text at all! - pt->clip(IntRect(tx + m_x, ty + y, m_width, h)); + pt->clip(IntRect(tx + m_x, ty + y, m_logicalWidth, h)); pt->drawHighlightForText(font, run, IntPoint(m_x + tx, y + ty), h, color, style->colorSpace(), sPos, ePos); pt->restore(); } @@ -913,6 +913,7 @@ void InlineTextBox::paintDocumentMarkers(GraphicsContext* pt, int tx, int ty, Re case DocumentMarker::Grammar: case DocumentMarker::Spelling: case DocumentMarker::Replacement: + case DocumentMarker::CorrectionIndicator: case DocumentMarker::RejectedCorrection: if (background) continue; @@ -946,10 +947,11 @@ void InlineTextBox::paintDocumentMarkers(GraphicsContext* pt, int tx, int ty, Re case DocumentMarker::TextMatch: paintTextMatchMarker(pt, tx, ty, marker, style, font); break; - case DocumentMarker::Replacement: + case DocumentMarker::CorrectionIndicator: computeRectForReplacementMarker(tx, ty, marker, style, font); paintSpellingOrGrammarMarker(pt, tx, ty, marker, style, font, false); break; + case DocumentMarker::Replacement: case DocumentMarker::RejectedCorrection: break; default: @@ -969,7 +971,7 @@ void InlineTextBox::paintCompositionUnderline(GraphicsContext* ctx, int tx, int return; int start = 0; // start of line to draw, relative to tx - int width = m_width; // how much line to draw + int width = m_logicalWidth; // how much line to draw bool useWholeWidth = true; unsigned paintStart = m_start; unsigned paintEnd = end() + 1; // end points at the last char, not past it @@ -995,7 +997,7 @@ void InlineTextBox::paintCompositionUnderline(GraphicsContext* ctx, int tx, int // If there's not enough space the underline will touch or overlap characters. int lineThickness = 1; int baseline = renderer()->style(m_firstLine)->font().ascent(); - if (underline.thick && height() - baseline >= 2) + if (underline.thick && logicalHeight() - baseline >= 2) lineThickness = 2; // We need to have some space between underlines of subsequent clauses, because some input methods do not use different underline styles for those. @@ -1005,7 +1007,7 @@ void InlineTextBox::paintCompositionUnderline(GraphicsContext* ctx, int tx, int ctx->setStrokeColor(underline.color, renderer()->style()->colorSpace()); ctx->setStrokeThickness(lineThickness); - ctx->drawLineForText(IntPoint(tx + start, ty + height() - lineThickness), width, textRenderer()->document()->printing()); + ctx->drawLineForText(IntPoint(tx + start, ty + logicalHeight() - lineThickness), width, textRenderer()->document()->printing()); } int InlineTextBox::caretMinOffset() const |