Changeset 70482 in webkit


Ignore:
Timestamp:
Oct 25, 2010 1:06:04 PM (13 years ago)
Author:
hyatt@apple.com
Message:

https://bugs.webkit.org/show_bug.cgi?id=48257

Reviewed by Dan Bernstein.

WebCore:

Make "rl" and "bt" writing-modes work for blocks and lines. InlineTextBox is refactored to compute the correct
top left corner and left baseline edge once so that can be passed down to all the painting functions instead of
tx and ty.

adjustment helpers have been added that can be called before painting children or lines and that fix up
the coordinates from flipped to physical.

Added fast/blockflow/english-rl-text.html and fast/blockflow/english-bt-text.html

  • rendering/InlineBox.cpp:

(WebCore::InlineBox::adjustForFlippedBlocksWritingMode):

  • rendering/InlineBox.h:
  • rendering/InlineFlowBox.cpp:

(WebCore::InlineFlowBox::paintBoxDecorations):
(WebCore::InlineFlowBox::paintMask):

  • rendering/InlineTextBox.cpp:

(WebCore::paintTextWithShadows):
(WebCore::InlineTextBox::paint):
(WebCore::InlineTextBox::paintSelection):
(WebCore::InlineTextBox::paintCompositionBackground):
(WebCore::InlineTextBox::paintDecoration):
(WebCore::InlineTextBox::paintSpellingOrGrammarMarker):
(WebCore::InlineTextBox::paintTextMatchMarker):
(WebCore::InlineTextBox::computeRectForReplacementMarker):
(WebCore::InlineTextBox::paintDocumentMarkers):
(WebCore::InlineTextBox::paintCompositionUnderline):

  • rendering/InlineTextBox.h:
  • rendering/RenderBlock.cpp:

(WebCore::RenderBlock::paintChildren):
(WebCore::RenderBlock::paintFloats):

  • rendering/RenderBox.cpp:

(WebCore::RenderBox::adjustForFlippedBlocksWritingMode):

  • rendering/RenderBox.h:
  • rendering/style/RenderStyle.h:

(WebCore::InheritedFlags::isFlippedBlocksWritingMode):

LayoutTests:

Make "rl" and "bt" writing-modes work for blocks and lines. InlineTextBox is refactored to compute the correct
top left corner and left baseline edge once so that can be passed down to all the painting functions instead of
tx and ty.

adjustment helpers have been added that can be called before painting children or lines and that fix up
the coordinates from flipped to physical.

Added fast/blockflow/english-rl-text.html and fast/blockflow/english-bt-text.html

  • fast/blockflow/english-bt-text.html: Added.
  • fast/blockflow/english-rl-text.html: Added.
  • platform/mac/fast/blockflow/english-bt-text-expected.checksum: Added.
  • platform/mac/fast/blockflow/english-bt-text-expected.png: Added.
  • platform/mac/fast/blockflow/english-bt-text-expected.txt: Added.
  • platform/mac/fast/blockflow/english-rl-text-expected.checksum: Added.
  • platform/mac/fast/blockflow/english-rl-text-expected.png: Added.
  • platform/mac/fast/blockflow/english-rl-text-expected.txt: Added.
Location:
trunk
Files:
8 added
11 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r70481 r70482  
     12010-10-25  David Hyatt  <hyatt@apple.com>
     2
     3        Reviewed by Dan Bernstein.
     4
     5        https://bugs.webkit.org/show_bug.cgi?id=48257
     6
     7        Make "rl" and "bt" writing-modes work for blocks and lines.  InlineTextBox is refactored to compute the correct
     8        top left corner and left baseline edge once so that can be passed down to all the painting functions instead of
     9        tx and ty.
     10       
     11        adjustment helpers have been added that can be called before painting children or lines and that fix up
     12        the coordinates from flipped to physical.
     13       
     14        Added fast/blockflow/english-rl-text.html and fast/blockflow/english-bt-text.html
     15        * fast/blockflow/english-bt-text.html: Added.
     16        * fast/blockflow/english-rl-text.html: Added.
     17        * platform/mac/fast/blockflow/english-bt-text-expected.checksum: Added.
     18        * platform/mac/fast/blockflow/english-bt-text-expected.png: Added.
     19        * platform/mac/fast/blockflow/english-bt-text-expected.txt: Added.
     20        * platform/mac/fast/blockflow/english-rl-text-expected.checksum: Added.
     21        * platform/mac/fast/blockflow/english-rl-text-expected.png: Added.
     22        * platform/mac/fast/blockflow/english-rl-text-expected.txt: Added.
     23
    1242010-10-25  Chang Shu  <chang.shu@nokia.com>
    225
  • trunk/WebCore/ChangeLog

    r70478 r70482  
     12010-10-25  David Hyatt  <hyatt@apple.com>
     2
     3        Reviewed by Dan Bernstein.
     4
     5        https://bugs.webkit.org/show_bug.cgi?id=48257
     6
     7        Make "rl" and "bt" writing-modes work for blocks and lines.  InlineTextBox is refactored to compute the correct
     8        top left corner and left baseline edge once so that can be passed down to all the painting functions instead of
     9        tx and ty.
     10       
     11        adjustment helpers have been added that can be called before painting children or lines and that fix up
     12        the coordinates from flipped to physical.
     13       
     14        Added fast/blockflow/english-rl-text.html and fast/blockflow/english-bt-text.html
     15
     16        * rendering/InlineBox.cpp:
     17        (WebCore::InlineBox::adjustForFlippedBlocksWritingMode):
     18        * rendering/InlineBox.h:
     19        * rendering/InlineFlowBox.cpp:
     20        (WebCore::InlineFlowBox::paintBoxDecorations):
     21        (WebCore::InlineFlowBox::paintMask):
     22        * rendering/InlineTextBox.cpp:
     23        (WebCore::paintTextWithShadows):
     24        (WebCore::InlineTextBox::paint):
     25        (WebCore::InlineTextBox::paintSelection):
     26        (WebCore::InlineTextBox::paintCompositionBackground):
     27        (WebCore::InlineTextBox::paintDecoration):
     28        (WebCore::InlineTextBox::paintSpellingOrGrammarMarker):
     29        (WebCore::InlineTextBox::paintTextMatchMarker):
     30        (WebCore::InlineTextBox::computeRectForReplacementMarker):
     31        (WebCore::InlineTextBox::paintDocumentMarkers):
     32        (WebCore::InlineTextBox::paintCompositionUnderline):
     33        * rendering/InlineTextBox.h:
     34        * rendering/RenderBlock.cpp:
     35        (WebCore::RenderBlock::paintChildren):
     36        (WebCore::RenderBlock::paintFloats):
     37        * rendering/RenderBox.cpp:
     38        (WebCore::RenderBox::adjustForFlippedBlocksWritingMode):
     39        * rendering/RenderBox.h:
     40        * rendering/style/RenderStyle.h:
     41        (WebCore::InheritedFlags::isFlippedBlocksWritingMode):
     42
    1432010-10-25  Ben Murdoch  <benm@google.com>
    244
  • trunk/WebCore/rendering/InlineBox.cpp

    r70172 r70482  
    2424#include "InlineFlowBox.h"
    2525#include "RenderArena.h"
    26 #include "RenderBox.h"
     26#include "RenderBlock.h"
    2727#include "RootInlineBox.h"
    2828
     
    280280}
    281281
     282void InlineBox::adjustForFlippedBlocksWritingMode(IntPoint& point)
     283{
     284    if (!renderer()->style()->isFlippedBlocksWritingMode())
     285        return;
     286   
     287    RenderBlock* block = root()->block();
     288    if (block->style()->isHorizontalWritingMode())
     289        point.setY(block->height() - height() - point.y());
     290    else
     291        point.setX(block->width() - width() - point.x());
     292}
     293
    282294} // namespace WebCore
    283295
  • trunk/WebCore/rendering/InlineBox.h

    r70356 r70482  
    291291    }
    292292
     293    void adjustForFlippedBlocksWritingMode(IntPoint&);
     294
    293295private:
    294296    InlineBox* m_next; // The next element on the same line as us.
  • trunk/WebCore/rendering/InlineFlowBox.cpp

    r70356 r70482  
    810810   
    811811    // Move x/y to our coordinates.
    812     tx += x;
    813     ty += y;
     812    IntPoint localPoint(x, y);
     813    adjustForFlippedBlocksWritingMode(localPoint);
     814    tx += localPoint.x();
     815    ty += localPoint.y();
    814816   
    815817    GraphicsContext* context = paintInfo.context;
     
    888890   
    889891    // Move x/y to our coordinates.
    890     tx += x;
    891     ty += y;
     892    IntPoint localPoint(x, y);
     893    adjustForFlippedBlocksWritingMode(localPoint);
     894    tx += localPoint.x();
     895    ty += localPoint.y();
    892896
    893897    const NinePieceImage& maskNinePieceImage = renderer()->style()->maskBoxImage();
  • trunk/WebCore/rendering/InlineTextBox.cpp

    r70456 r70482  
    347347
    348348static void paintTextWithShadows(GraphicsContext* context, const Font& font, const TextRun& textRun, int startOffset, int endOffset, int truncationPoint, const IntPoint& textOrigin,
    349                                  int x, int y, int w, int h, const ShadowData* shadow, bool stroked, bool vertical)
     349                                 const IntRect& boxRect, const ShadowData* shadow, bool stroked, bool vertical)
    350350{
    351351    Color fillColor = context->fillColor();
     
    358358        IntSize extraOffset;
    359359        if (shadow)
    360             extraOffset = roundedIntSize(InlineTextBox::applyShadowToGraphicsContext(context, shadow, FloatRect(x, y, w, h), stroked, opaque, vertical));
     360            extraOffset = roundedIntSize(InlineTextBox::applyShadowToGraphicsContext(context, shadow, boxRect, stroked, opaque, vertical));
    361361        else if (!opaque)
    362362            context->setFillColor(fillColor, fillColorSpace);
     
    432432    RenderStyle* styleToUse = renderer()->style(m_firstLine);
    433433    int baseline = styleToUse->font().ascent();
    434     ty -= styleToUse->isFlippedLinesWritingMode() ? baseline : 0;
    435     IntPoint textOrigin(m_x + tx, m_y + ty + baseline);
    436    
     434    ty -= styleToUse->isHorizontalWritingMode() ? 0 : baseline;
     435   
     436    IntPoint boxOrigin(m_x, m_y);
     437    adjustForFlippedBlocksWritingMode(boxOrigin);
     438    boxOrigin.move(tx, ty);
     439   
     440    IntPoint textOrigin = IntPoint(boxOrigin.x(), boxOrigin.y() + baseline);
     441    IntRect boxRect(boxOrigin, IntSize(logicalWidth(), logicalHeight()));
     442
    437443    if (m_isVertical) {
    438444        context->save();
     
    460466
    461467        if (containsComposition && !useCustomUnderlines)
    462             paintCompositionBackground(context, tx, ty, styleToUse, font,
     468            paintCompositionBackground(context, boxOrigin, styleToUse, font,
    463469                renderer()->frame()->editor()->compositionStart(),
    464470                renderer()->frame()->editor()->compositionEnd());
    465471
    466         paintDocumentMarkers(context, tx, ty, styleToUse, font, true);
     472        paintDocumentMarkers(context, boxOrigin, styleToUse, font, true);
    467473
    468474        if (haveSelection && !useCustomUnderlines)
    469             paintSelection(context, tx, ty, styleToUse, font);
     475            paintSelection(context, boxOrigin, styleToUse, font);
    470476    }
    471477
     
    561567        if (!paintSelectedTextSeparately || ePos <= sPos) {
    562568            // FIXME: Truncate right-to-left text correctly.
    563             paintTextWithShadows(context, font, textRun, 0, length, length, textOrigin, m_x + tx, m_y + ty, logicalWidth(), logicalHeight(), textShadow, textStrokeWidth > 0, m_isVertical);
     569            paintTextWithShadows(context, font, textRun, 0, length, length, textOrigin, boxRect, textShadow, textStrokeWidth > 0, m_isVertical);
    564570        } else
    565             paintTextWithShadows(context, font, textRun, ePos, sPos, length, textOrigin, m_x + tx, m_y + ty, logicalWidth(), logicalHeight(), textShadow, textStrokeWidth > 0, m_isVertical);
     571            paintTextWithShadows(context, font, textRun, ePos, sPos, length, textOrigin, boxRect, textShadow, textStrokeWidth > 0, m_isVertical);
    566572
    567573        if (textStrokeWidth > 0)
     
    575581
    576582        updateGraphicsContext(context, selectionFillColor, selectionStrokeColor, selectionStrokeWidth, styleToUse->colorSpace());
    577         paintTextWithShadows(context, font, textRun, sPos, ePos, length, textOrigin, m_x + tx, m_y + ty, logicalWidth(), logicalHeight(), selectionShadow, selectionStrokeWidth > 0, m_isVertical);
     583        paintTextWithShadows(context, font, textRun, sPos, ePos, length, textOrigin, boxRect, selectionShadow, selectionStrokeWidth > 0, m_isVertical);
    578584
    579585        if (selectionStrokeWidth > 0)
     
    584590    if (d != TDNONE && paintInfo.phase != PaintPhaseSelection) {
    585591        updateGraphicsContext(context, textFillColor, textStrokeColor, textStrokeWidth, styleToUse->colorSpace());
    586         paintDecoration(context, tx, ty, d, textShadow);
     592        paintDecoration(context, boxOrigin, d, textShadow);
    587593    }
    588594
    589595    if (paintInfo.phase == PaintPhaseForeground) {
    590         paintDocumentMarkers(context, tx, ty, styleToUse, font, false);
     596        paintDocumentMarkers(context, boxOrigin, styleToUse, font, false);
    591597
    592598        if (useCustomUnderlines) {
     
    605611                if (underline.startOffset <= end()) {
    606612                    // underline intersects this run.  Paint it.
    607                     paintCompositionUnderline(context, tx, ty, underline);
     613                    paintCompositionUnderline(context, boxOrigin, underline);
    608614                    if (underline.endOffset > end() + 1)
    609615                        // underline also runs into the next run. Bail now, no more marker advancement.
     
    638644}
    639645
    640 void InlineTextBox::paintSelection(GraphicsContext* context, int tx, int ty, RenderStyle* style, const Font& font)
     646void InlineTextBox::paintSelection(GraphicsContext* context, const IntPoint& boxOrigin, RenderStyle* style, const Font& font)
    641647{
    642648    // See if we have a selection to paint at all.
     
    658664    context->save();
    659665    updateGraphicsContext(context, c, c, 0, style->colorSpace());  // Don't draw text at all!
    660     int y = selectionTop();
    661     int h = selectionHeight();
     666   
    662667    // If the text is truncated, let the thing being painted in the truncation
    663668    // draw its own highlight.
     
    671676    }
    672677
    673     context->clip(IntRect(m_x + tx, y + ty, m_logicalWidth, h));
     678    int deltaY = logicalTop() - selectionTop();
     679    int selHeight = selectionHeight();
     680    IntPoint localOrigin(boxOrigin.x(), boxOrigin.y() - deltaY);
     681    context->clip(IntRect(localOrigin, IntSize(m_logicalWidth, selHeight)));
    674682    context->drawHighlightForText(font, TextRun(characters, length, textRenderer()->allowTabs(), textPos(), m_toAdd,
    675683                                  !isLeftToRightDirection(), m_dirOverride || style->visuallyOrdered()),
    676                                   IntPoint(m_x + tx, y + ty), h, c, style->colorSpace(), sPos, ePos);
     684                                  localOrigin, selHeight, c, style->colorSpace(), sPos, ePos);
    677685    context->restore();
    678686}
    679687
    680 void InlineTextBox::paintCompositionBackground(GraphicsContext* context, int tx, int ty, RenderStyle* style, const Font& font, int startPos, int endPos)
     688void InlineTextBox::paintCompositionBackground(GraphicsContext* context, const IntPoint& boxOrigin, RenderStyle* style, const Font& font, int startPos, int endPos)
    681689{
    682690    int offset = m_start;
     
    693701    updateGraphicsContext(context, c, c, 0, style->colorSpace()); // Don't draw text at all!
    694702
    695     int y = selectionTop();
    696     int h = selectionHeight();
     703    int deltaY = logicalTop() - selectionTop();
     704    int selHeight = selectionHeight();
     705    IntPoint localOrigin(boxOrigin.x(), boxOrigin.y() - deltaY);
    697706    context->drawHighlightForText(font, TextRun(textRenderer()->text()->characters() + m_start, m_len, textRenderer()->allowTabs(), textPos(), m_toAdd,
    698707                                  !isLeftToRightDirection(), m_dirOverride || style->visuallyOrdered()),
    699                                   IntPoint(m_x + tx, y + ty), h, c, style->colorSpace(), sPos, ePos);
     708                                  localOrigin, selHeight, c, style->colorSpace(), sPos, ePos);
    700709    context->restore();
    701710}
     
    721730#endif
    722731
    723 void InlineTextBox::paintDecoration(GraphicsContext* context, int tx, int ty, int deco, const ShadowData* shadow)
    724 {
    725     tx += m_x;
    726     ty += m_y;
    727 
     732void InlineTextBox::paintDecoration(GraphicsContext* context, const IntPoint& boxOrigin, int deco, const ShadowData* shadow)
     733{
    728734    if (m_truncation == cFullTruncation)
    729735        return;
     736
     737    IntPoint localOrigin = boxOrigin;
    730738
    731739    int width = m_logicalWidth;
     
    733741        width = toRenderText(renderer())->width(m_start, m_truncation, textPos(), m_firstLine);
    734742        if (!isLeftToRightDirection())
    735             tx += (m_logicalWidth - width);
     743            localOrigin.move(m_logicalWidth - width, 0);
    736744    }
    737745   
     
    753761    if (!linesAreOpaque && shadow && shadow->next()) {
    754762        context->save();
    755         IntRect clipRect(tx, ty, width, baseline + 2);
     763        IntRect clipRect(localOrigin, IntSize(width, baseline + 2));
    756764        for (const ShadowData* s = shadow; s; s = s->next()) {
    757             IntRect shadowRect(tx, ty, width, baseline + 2);
     765            IntRect shadowRect(localOrigin, IntSize(width, baseline + 2));
    758766            shadowRect.inflate(s->blur());
    759767            int shadowX = m_isVertical ? s->y() : s->x();
     
    766774        context->clip(clipRect);
    767775        extraOffset += baseline + 2;
    768         ty += extraOffset;
     776        localOrigin.move(0, extraOffset);
    769777        setClip = true;
    770778    }
     
    777785            if (!shadow->next()) {
    778786                // The last set of lines paints normally inside the clip.
    779                 ty -= extraOffset;
     787                localOrigin.move(0, -extraOffset);
    780788                extraOffset = 0;
    781789            }
     
    791799            context->setStrokeStyle(SolidStroke);
    792800            // Leave one pixel of white between the baseline and the underline.
    793             context->drawLineForText(IntPoint(tx, ty + baseline + 1), width, isPrinting);
     801            context->drawLineForText(IntPoint(localOrigin.x(), localOrigin.y() + baseline + 1), width, isPrinting);
    794802        }
    795803        if (deco & OVERLINE) {
    796804            context->setStrokeColor(overline, colorSpace);
    797805            context->setStrokeStyle(SolidStroke);
    798             context->drawLineForText(IntPoint(tx, ty), width, isPrinting);
     806            context->drawLineForText(localOrigin, width, isPrinting);
    799807        }
    800808        if (deco & LINE_THROUGH) {
    801809            context->setStrokeColor(linethrough, colorSpace);
    802810            context->setStrokeStyle(SolidStroke);
    803             context->drawLineForText(IntPoint(tx, ty + 2 * baseline / 3), width, isPrinting);
     811            context->drawLineForText(IntPoint(localOrigin.x(), localOrigin.y() + 2 * baseline / 3), width, isPrinting);
    804812        }
    805813    } while (shadow);
     
    826834}
    827835
    828 void InlineTextBox::paintSpellingOrGrammarMarker(GraphicsContext* pt, int tx, int ty, const DocumentMarker& marker, RenderStyle* style, const Font& font, bool grammar)
     836void InlineTextBox::paintSpellingOrGrammarMarker(GraphicsContext* pt, const IntPoint& boxOrigin, const DocumentMarker& marker, RenderStyle* style, const Font& font, bool grammar)
    829837{
    830838    // Never print spelling/grammar markers (5327887)
     
    855863
    856864        // Calculate start & width
    857         IntPoint startPoint(tx + m_x, ty + selectionTop());
     865        int deltaY = logicalTop() - selectionTop();
     866        int selHeight = selectionHeight();
     867        IntPoint startPoint(boxOrigin.x(), boxOrigin.y() - deltaY);
    858868        TextRun run(textRenderer()->text()->characters() + m_start, m_len, textRenderer()->allowTabs(), textPos(), m_toAdd, !isLeftToRightDirection(), m_dirOverride || style->visuallyOrdered());
    859         int h = selectionHeight();
    860        
    861         IntRect markerRect = enclosingIntRect(font.selectionRectForText(run, startPoint, h, startPosition, endPosition));
     869         
     870        IntRect markerRect = enclosingIntRect(font.selectionRectForText(run, startPoint, selHeight, startPosition, endPosition));
    862871        start = markerRect.x() - startPoint.x();
    863872        width = markerRect.width();
     
    866875        // display a toolTip. We don't do this for misspelling markers.
    867876        if (grammar) {
    868             markerRect.move(-tx, -ty);
     877            markerRect.move(-boxOrigin.x(), -boxOrigin.y());
    869878            markerRect = renderer()->localToAbsoluteQuad(FloatRect(markerRect)).enclosingBoundingBox();
    870879            renderer()->document()->markers()->setRenderedRectForMarker(renderer()->node(), marker, markerRect);
     
    889898        underlineOffset = baseline + 2;
    890899    }
    891     pt->drawLineForTextChecking(IntPoint(tx + m_x + start, ty + m_y + underlineOffset), width, textCheckingLineStyleForMarkerType(marker.type));
    892 }
    893 
    894 void InlineTextBox::paintTextMatchMarker(GraphicsContext* pt, int tx, int ty, const DocumentMarker& marker, RenderStyle* style, const Font& font)
     900    pt->drawLineForTextChecking(IntPoint(boxOrigin.x() + start, boxOrigin.y() + underlineOffset), width, textCheckingLineStyleForMarkerType(marker.type));
     901}
     902
     903void InlineTextBox::paintTextMatchMarker(GraphicsContext* pt, const IntPoint& boxOrigin, const DocumentMarker& marker, RenderStyle* style, const Font& font)
    895904{
    896905    // Use same y positioning and height as for selection, so that when the selection and this highlight are on
    897906    // the same word there are no pieces sticking out.
    898     int y = selectionTop();
    899     int h = selectionHeight();
    900    
     907    int deltaY = logicalTop() - selectionTop();
     908    int selHeight = selectionHeight();
     909
    901910    int sPos = max(marker.startOffset - m_start, (unsigned)0);
    902911    int ePos = min(marker.endOffset - m_start, (unsigned)m_len);   
     
    904913   
    905914    // Always compute and store the rect associated with this marker. The computed rect is in absolute coordinates.
    906     IntRect markerRect = enclosingIntRect(font.selectionRectForText(run, IntPoint(m_x, y), h, sPos, ePos));
     915    IntRect markerRect = enclosingIntRect(font.selectionRectForText(run, IntPoint(m_x, selectionTop()), selHeight, sPos, ePos));
    907916    markerRect = renderer()->localToAbsoluteQuad(FloatRect(markerRect)).enclosingBoundingBox();
    908917    renderer()->document()->markers()->setRenderedRectForMarker(renderer()->node(), marker, markerRect);
     
    915924        pt->save();
    916925        updateGraphicsContext(pt, color, color, 0, style->colorSpace());  // Don't draw text at all!
    917         pt->clip(IntRect(tx + m_x, ty + y, m_logicalWidth, h));
    918         pt->drawHighlightForText(font, run, IntPoint(m_x + tx, y + ty), h, color, style->colorSpace(), sPos, ePos);
     926        pt->clip(IntRect(boxOrigin.x(), boxOrigin.y() - deltaY, m_logicalWidth, selHeight));
     927        pt->drawHighlightForText(font, run, IntPoint(boxOrigin.x(), boxOrigin.y() - deltaY), selHeight, color, style->colorSpace(), sPos, ePos);
    919928        pt->restore();
    920929    }
    921930}
    922931
    923 void InlineTextBox::computeRectForReplacementMarker(int /*tx*/, int /*ty*/, const DocumentMarker& marker, RenderStyle* style, const Font& font)
     932void InlineTextBox::computeRectForReplacementMarker(const DocumentMarker& marker, RenderStyle* style, const Font& font)
    924933{
    925934    // Replacement markers are not actually drawn, but their rects need to be computed for hit testing.
     
    938947}
    939948   
    940 void InlineTextBox::paintDocumentMarkers(GraphicsContext* pt, int tx, int ty, RenderStyle* style, const Font& font, bool background)
     949void InlineTextBox::paintDocumentMarkers(GraphicsContext* pt, const IntPoint& boxOrigin, RenderStyle* style, const Font& font, bool background)
    941950{
    942951    if (!renderer()->node())
     
    982991        switch (marker.type) {
    983992            case DocumentMarker::Spelling:
    984                 paintSpellingOrGrammarMarker(pt, tx, ty, marker, style, font, false);
     993                paintSpellingOrGrammarMarker(pt, boxOrigin, marker, style, font, false);
    985994                break;
    986995            case DocumentMarker::Grammar:
    987                 paintSpellingOrGrammarMarker(pt, tx, ty, marker, style, font, true);
     996                paintSpellingOrGrammarMarker(pt, boxOrigin, marker, style, font, true);
    988997                break;
    989998            case DocumentMarker::TextMatch:
    990                 paintTextMatchMarker(pt, tx, ty, marker, style, font);
     999                paintTextMatchMarker(pt, boxOrigin, marker, style, font);
    9911000                break;
    9921001            case DocumentMarker::CorrectionIndicator:
    993                 computeRectForReplacementMarker(tx, ty, marker, style, font);
    994                 paintSpellingOrGrammarMarker(pt, tx, ty, marker, style, font, false);
     1002                computeRectForReplacementMarker(marker, style, font);
     1003                paintSpellingOrGrammarMarker(pt, boxOrigin, marker, style, font, false);
    9951004                break;
    9961005            case DocumentMarker::Replacement:
     
    10051014
    10061015
    1007 void InlineTextBox::paintCompositionUnderline(GraphicsContext* ctx, int tx, int ty, const CompositionUnderline& underline)
    1008 {
    1009     tx += m_x;
    1010     ty += m_y;
    1011 
     1016void InlineTextBox::paintCompositionUnderline(GraphicsContext* ctx, const IntPoint& boxOrigin, const CompositionUnderline& underline)
     1017{
    10121018    if (m_truncation == cFullTruncation)
    10131019        return;
     
    10501056    ctx->setStrokeColor(underline.color, renderer()->style()->colorSpace());
    10511057    ctx->setStrokeThickness(lineThickness);
    1052     ctx->drawLineForText(IntPoint(tx + start, ty + logicalHeight() - lineThickness), width, textRenderer()->document()->printing());
     1058    ctx->drawLineForText(IntPoint(boxOrigin.x() + start, boxOrigin.y() + logicalHeight() - lineThickness), width, textRenderer()->document()->printing());
    10531059}
    10541060
  • trunk/WebCore/rendering/InlineTextBox.h

    r70263 r70482  
    141141
    142142protected:
    143     void paintCompositionBackground(GraphicsContext*, int tx, int ty, RenderStyle*, const Font&, int startPos, int endPos);
    144     void paintDocumentMarkers(GraphicsContext*, int tx, int ty, RenderStyle*, const Font&, bool background);
    145     void paintCompositionUnderline(GraphicsContext*, int tx, int ty, const CompositionUnderline&);
     143    void paintCompositionBackground(GraphicsContext*, const IntPoint& boxOrigin, RenderStyle*, const Font&, int startPos, int endPos);
     144    void paintDocumentMarkers(GraphicsContext*, const IntPoint& boxOrigin, RenderStyle*, const Font&, bool background);
     145    void paintCompositionUnderline(GraphicsContext*, const IntPoint& boxOrigin, const CompositionUnderline&);
    146146#if PLATFORM(MAC)
    147147    void paintCustomHighlight(int tx, int ty, const AtomicString& type);
     
    149149
    150150private:
    151     void paintDecoration(GraphicsContext*, int tx, int ty, int decoration, const ShadowData*);
    152     void paintSelection(GraphicsContext*, int tx, int ty, RenderStyle*, const Font&);
    153     void paintSpellingOrGrammarMarker(GraphicsContext*, int tx, int ty, const DocumentMarker&, RenderStyle*, const Font&, bool grammar);
    154     void paintTextMatchMarker(GraphicsContext*, int tx, int ty, const DocumentMarker&, RenderStyle*, const Font&);
    155     void computeRectForReplacementMarker(int tx, int ty, const DocumentMarker&, RenderStyle*, const Font&);
     151    void paintDecoration(GraphicsContext*, const IntPoint& boxOrigin, int decoration, const ShadowData*);
     152    void paintSelection(GraphicsContext*, const IntPoint& boxOrigin, RenderStyle*, const Font&);
     153    void paintSpellingOrGrammarMarker(GraphicsContext*, const IntPoint& boxOrigin, const DocumentMarker&, RenderStyle*, const Font&, bool grammar);
     154    void paintTextMatchMarker(GraphicsContext*, const IntPoint& boxOrigin, const DocumentMarker&, RenderStyle*, const Font&);
     155    void computeRectForReplacementMarker(const DocumentMarker&, RenderStyle*, const Font&);
    156156};
    157157
  • trunk/WebCore/rendering/RenderBlock.cpp

    r70170 r70482  
    22702270        }
    22712271
     2272        IntPoint childPoint(tx, ty);
     2273        adjustForFlippedBlocksWritingMode(child, childPoint);
    22722274        if (!child->hasSelfPaintingLayer() && !child->isFloating())
    2273             child->paint(info, tx, ty);
     2275            child->paint(info, childPoint.x(), childPoint.y());
    22742276
    22752277        // Check for page-break-after: always, and if it's set, break and bail.
     
    24042406            PaintInfo currentPaintInfo(paintInfo);
    24052407            currentPaintInfo.phase = preservePhase ? paintInfo.phase : PaintPhaseBlockBackground;
    2406             int currentTX = tx + r->left() - r->m_renderer->x() + r->m_renderer->marginLeft();
    2407             int currentTY = ty + r->top() - r->m_renderer->y() + r->m_renderer->marginTop();
    2408             r->m_renderer->paint(currentPaintInfo, currentTX, currentTY);
     2408            IntPoint childPoint(tx + r->left() + r->m_renderer->marginLeft() - r->m_renderer->x(),
     2409                                ty + r->top() + r->m_renderer->marginTop() - r->m_renderer->y());
     2410            adjustForFlippedBlocksWritingMode(r->m_renderer, childPoint);
     2411            r->m_renderer->paint(currentPaintInfo, childPoint.x(), childPoint.y());
    24092412            if (!preservePhase) {
    24102413                currentPaintInfo.phase = PaintPhaseChildBlockBackgrounds;
    2411                 r->m_renderer->paint(currentPaintInfo, currentTX, currentTY);
     2414                r->m_renderer->paint(currentPaintInfo, childPoint.x(), childPoint.y());
    24122415                currentPaintInfo.phase = PaintPhaseFloat;
    2413                 r->m_renderer->paint(currentPaintInfo, currentTX, currentTY);
     2416                r->m_renderer->paint(currentPaintInfo, childPoint.x(), childPoint.y());
    24142417                currentPaintInfo.phase = PaintPhaseForeground;
    2415                 r->m_renderer->paint(currentPaintInfo, currentTX, currentTY);
     2418                r->m_renderer->paint(currentPaintInfo, childPoint.x(), childPoint.y());
    24162419                currentPaintInfo.phase = PaintPhaseOutline;
    2417                 r->m_renderer->paint(currentPaintInfo, currentTX, currentTY);
     2420                r->m_renderer->paint(currentPaintInfo, childPoint.x(), childPoint.y());
    24182421            }
    24192422        }
  • trunk/WebCore/rendering/RenderBox.cpp

    r70356 r70482  
    31893189}
    31903190
     3191void RenderBox::adjustForFlippedBlocksWritingMode(RenderBox* child, IntPoint& point)
     3192{
     3193    if (!style()->isFlippedBlocksWritingMode())
     3194        return;
     3195   
     3196    // The child is going to add in its x() and y(), so we have to make sure it ends up in
     3197    // the right place.
     3198    if (style()->isHorizontalWritingMode())
     3199        point.move(0, height() - child->height() - child->y() - child->y());
     3200    else
     3201        point.move(width() - child->width() - child->x() - child->x(), 0);
     3202}
     3203
    31913204} // namespace WebCore
  • trunk/WebCore/rendering/RenderBox.h

    r70356 r70482  
    378378    virtual int baselinePosition(bool firstLine, LineDirectionMode, LinePositionMode = PositionOnContainingLine) const;
    379379
     380    void adjustForFlippedBlocksWritingMode(RenderBox* child, IntPoint&);
     381
    380382protected:
    381383    virtual void styleWillChange(StyleDifference, const RenderStyle* newStyle);
  • trunk/WebCore/rendering/style/RenderStyle.h

    r70330 r70482  
    755755    bool isHorizontalWritingMode() const { return writingMode() == TopToBottomWritingMode || writingMode() == BottomToTopWritingMode; }
    756756    bool isFlippedLinesWritingMode() const { return writingMode() == LeftToRightWritingMode || writingMode() == BottomToTopWritingMode; }
     757    bool isFlippedBlocksWritingMode() const { return writingMode() == RightToLeftWritingMode || writingMode() == BottomToTopWritingMode; }
    757758
    758759    ESpeak speak() { return static_cast<ESpeak>(rareInheritedData->speak); }
Note: See TracChangeset for help on using the changeset viewer.