[SCM] WebKit Debian packaging branch, debian/experimental, updated. upstream/1.3.3-9427-gc2be6fc

hyatt at apple.com hyatt at apple.com
Wed Dec 22 14:56:34 UTC 2010


The following commit has been merged in the debian/experimental branch:
commit 8388d184f67f4ae448040eb3a0ee880a657c3c11
Author: hyatt at apple.com <hyatt at apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date:   Mon Oct 25 20:06:04 2010 +0000

    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.
    
    
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@70482 268f45cc-cd09-0410-ab3c-d52691b4dbfc

diff --git a/LayoutTests/ChangeLog b/LayoutTests/ChangeLog
index bc7bc34..39b54a6 100644
--- a/LayoutTests/ChangeLog
+++ b/LayoutTests/ChangeLog
@@ -1,3 +1,26 @@
+2010-10-25  David Hyatt  <hyatt at apple.com>
+
+        Reviewed by Dan Bernstein.
+
+        https://bugs.webkit.org/show_bug.cgi?id=48257
+
+        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.
+
 2010-10-25  Chang Shu  <chang.shu at nokia.com>
 
         Reviewed by Antonio Gomes.
diff --git a/LayoutTests/fast/blockflow/english-bt-text.html b/LayoutTests/fast/blockflow/english-bt-text.html
new file mode 100644
index 0000000..9327efc
--- /dev/null
+++ b/LayoutTests/fast/blockflow/english-bt-text.html
@@ -0,0 +1,3 @@
+<html style="-webkit-writing-mode: horizontal-bt"><body style="border:2px solid black; height:500px">
+<div style="margin-bottom:1em; height:200px;border:2px solid maroon"><div style="float:right;width:100px;height:100px;background-color:lime"></div>
+Here is some text in a horizontal-bt block flow.  The block direction is bottom-to-top.<br>This line should also be horizontal.</div></body></html>
diff --git a/LayoutTests/fast/blockflow/english-rl-text.html b/LayoutTests/fast/blockflow/english-rl-text.html
new file mode 100644
index 0000000..758864c
--- /dev/null
+++ b/LayoutTests/fast/blockflow/english-rl-text.html
@@ -0,0 +1,3 @@
+<html style="-webkit-writing-mode: vertical-rl"><body style="border:2px solid black; width:500px">
+<div style="margin-right:1em; width:200px;border:2px solid maroon"><div style="float:right;width:100px;height:100px;background-color:lime"></div>
+Here is some text in a vertical-rl block flow.  The block direction is right-to-left.<br>This line should also be vertical.</div></body></html>
diff --git a/LayoutTests/platform/mac/fast/blockflow/english-bt-text-expected.checksum b/LayoutTests/platform/mac/fast/blockflow/english-bt-text-expected.checksum
new file mode 100644
index 0000000..ecce2bd
--- /dev/null
+++ b/LayoutTests/platform/mac/fast/blockflow/english-bt-text-expected.checksum
@@ -0,0 +1 @@
+0b31200048273801e17725c5f5114ce9
\ No newline at end of file
diff --git a/LayoutTests/platform/mac/fast/blockflow/english-bt-text-expected.png b/LayoutTests/platform/mac/fast/blockflow/english-bt-text-expected.png
new file mode 100644
index 0000000..61df2df
Binary files /dev/null and b/LayoutTests/platform/mac/fast/blockflow/english-bt-text-expected.png differ
diff --git a/LayoutTests/platform/mac/fast/blockflow/english-bt-text-expected.txt b/LayoutTests/platform/mac/fast/blockflow/english-bt-text-expected.txt
new file mode 100644
index 0000000..42c2814
--- /dev/null
+++ b/LayoutTests/platform/mac/fast/blockflow/english-bt-text-expected.txt
@@ -0,0 +1,13 @@
+layer at (0,0) size 800x600
+  RenderView at (0,0) size 800x600
+layer at (0,0) size 800x600
+  RenderBlock {HTML} at (0,0) size 800x600
+    RenderBody {BODY} at (8,8) size 784x504 [border: (2px solid #000000)]
+      RenderBlock {DIV} at (2,18) size 780x204 [border: (2px solid #800000)]
+        RenderBlock (floating) {DIV} at (678,2) size 100x100 [bgcolor=#00FF00]
+        RenderText {#text} at (2,2) size 531x18
+          text run at (2,2) width 300: "Here is some text in a horizontal-bt block flow. "
+          text run at (302,2) width 231: "The block direction is bottom-to-top."
+        RenderBR {BR} at (533,6) size 0x0
+        RenderText {#text} at (2,20) size 220x18
+          text run at (2,20) width 220: "This line should also be horizontal."
diff --git a/LayoutTests/platform/mac/fast/blockflow/english-rl-text-expected.checksum b/LayoutTests/platform/mac/fast/blockflow/english-rl-text-expected.checksum
new file mode 100644
index 0000000..05260f8
--- /dev/null
+++ b/LayoutTests/platform/mac/fast/blockflow/english-rl-text-expected.checksum
@@ -0,0 +1 @@
+57b207ac9f5b0d0eef5a6f6195202ad9
\ No newline at end of file
diff --git a/LayoutTests/platform/mac/fast/blockflow/english-rl-text-expected.png b/LayoutTests/platform/mac/fast/blockflow/english-rl-text-expected.png
new file mode 100644
index 0000000..bc7f545
Binary files /dev/null and b/LayoutTests/platform/mac/fast/blockflow/english-rl-text-expected.png differ
diff --git a/LayoutTests/platform/mac/fast/blockflow/english-rl-text-expected.txt b/LayoutTests/platform/mac/fast/blockflow/english-rl-text-expected.txt
new file mode 100644
index 0000000..4e71c04
--- /dev/null
+++ b/LayoutTests/platform/mac/fast/blockflow/english-rl-text-expected.txt
@@ -0,0 +1,14 @@
+layer at (0,0) size 800x600
+  RenderView at (0,0) size 800x600
+layer at (0,0) size 785x600
+  RenderBlock {HTML} at (0,0) size 785x600
+    RenderBody {BODY} at (8,8) size 504x584 [border: (2px solid #000000)]
+      RenderBlock {DIV} at (18,2) size 204x580 [border: (2px solid #800000)]
+        RenderBlock (floating) {DIV} at (2,478) size 100x100 [bgcolor=#00FF00]
+        RenderText {#text} at (2,2) size 417x18
+          text run at (2,2) width 417: "Here is some text in a vertical-rl block flow. "
+          text run at (2,419) width 34: "The"
+          text run at (20,2) width 318: "block direction is right-to-left."
+        RenderBR {BR} at (34,320) size 0x0
+        RenderText {#text} at (38,2) size 324x18
+          text run at (38,2) width 324: "This line should also be vertical."
diff --git a/WebCore/ChangeLog b/WebCore/ChangeLog
index 1d45203..0635ec4 100644
--- a/WebCore/ChangeLog
+++ b/WebCore/ChangeLog
@@ -1,3 +1,45 @@
+2010-10-25  David Hyatt  <hyatt at apple.com>
+
+        Reviewed by Dan Bernstein.
+
+        https://bugs.webkit.org/show_bug.cgi?id=48257
+
+        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):
+
 2010-10-25  Ben Murdoch  <benm at google.com>
 
         Reviewed by Steve Block.
diff --git a/WebCore/rendering/InlineBox.cpp b/WebCore/rendering/InlineBox.cpp
index 2028d4e..c8236b1 100644
--- a/WebCore/rendering/InlineBox.cpp
+++ b/WebCore/rendering/InlineBox.cpp
@@ -23,7 +23,7 @@
 #include "HitTestResult.h"
 #include "InlineFlowBox.h"
 #include "RenderArena.h"
-#include "RenderBox.h"
+#include "RenderBlock.h"
 #include "RootInlineBox.h"
 
 using namespace std;
@@ -279,6 +279,18 @@ int InlineBox::placeEllipsisBox(bool, int, int, int, bool&)
     return -1;
 }
 
+void InlineBox::adjustForFlippedBlocksWritingMode(IntPoint& point)
+{
+    if (!renderer()->style()->isFlippedBlocksWritingMode())
+        return;
+    
+    RenderBlock* block = root()->block();
+    if (block->style()->isHorizontalWritingMode())
+        point.setY(block->height() - height() - point.y());
+    else
+        point.setX(block->width() - width() - point.x());
+}
+
 } // namespace WebCore
 
 #ifndef NDEBUG
diff --git a/WebCore/rendering/InlineBox.h b/WebCore/rendering/InlineBox.h
index 2c31579..c3f89e0 100644
--- a/WebCore/rendering/InlineBox.h
+++ b/WebCore/rendering/InlineBox.h
@@ -290,6 +290,8 @@ public:
         return 0;
     }
 
+    void adjustForFlippedBlocksWritingMode(IntPoint&);
+
 private:
     InlineBox* m_next; // The next element on the same line as us.
     InlineBox* m_prev; // The previous element on the same line as us.
diff --git a/WebCore/rendering/InlineFlowBox.cpp b/WebCore/rendering/InlineFlowBox.cpp
index a051a37..ae48ab3 100644
--- a/WebCore/rendering/InlineFlowBox.cpp
+++ b/WebCore/rendering/InlineFlowBox.cpp
@@ -809,8 +809,10 @@ void InlineFlowBox::paintBoxDecorations(PaintInfo& paintInfo, int tx, int ty)
     }
     
     // Move x/y to our coordinates.
-    tx += x;
-    ty += y;
+    IntPoint localPoint(x, y);
+    adjustForFlippedBlocksWritingMode(localPoint);
+    tx += localPoint.x();
+    ty += localPoint.y();
     
     GraphicsContext* context = paintInfo.context;
     
@@ -887,8 +889,10 @@ void InlineFlowBox::paintMask(PaintInfo& paintInfo, int tx, int ty)
     }
     
     // Move x/y to our coordinates.
-    tx += x;
-    ty += y;
+    IntPoint localPoint(x, y);
+    adjustForFlippedBlocksWritingMode(localPoint);
+    tx += localPoint.x();
+    ty += localPoint.y();
 
     const NinePieceImage& maskNinePieceImage = renderer()->style()->maskBoxImage();
     StyleImage* maskBoxImage = renderer()->style()->maskBoxImage().image();
diff --git a/WebCore/rendering/InlineTextBox.cpp b/WebCore/rendering/InlineTextBox.cpp
index 9c89d58..10d2f0c 100644
--- a/WebCore/rendering/InlineTextBox.cpp
+++ b/WebCore/rendering/InlineTextBox.cpp
@@ -346,7 +346,7 @@ FloatSize InlineTextBox::applyShadowToGraphicsContext(GraphicsContext* context,
 }
 
 static void paintTextWithShadows(GraphicsContext* context, const Font& font, const TextRun& textRun, int startOffset, int endOffset, int truncationPoint, const IntPoint& textOrigin,
-                                 int x, int y, int w, int h, const ShadowData* shadow, bool stroked, bool vertical)
+                                 const IntRect& boxRect, const ShadowData* shadow, bool stroked, bool vertical)
 {
     Color fillColor = context->fillColor();
     ColorSpace fillColorSpace = context->fillColorSpace();
@@ -357,7 +357,7 @@ static void paintTextWithShadows(GraphicsContext* context, const Font& font, con
     do {
         IntSize extraOffset;
         if (shadow)
-            extraOffset = roundedIntSize(InlineTextBox::applyShadowToGraphicsContext(context, shadow, FloatRect(x, y, w, h), stroked, opaque, vertical));
+            extraOffset = roundedIntSize(InlineTextBox::applyShadowToGraphicsContext(context, shadow, boxRect, stroked, opaque, vertical));
         else if (!opaque)
             context->setFillColor(fillColor, fillColorSpace);
 
@@ -431,9 +431,15 @@ void InlineTextBox::paint(PaintInfo& paintInfo, int tx, int ty)
 
     RenderStyle* styleToUse = renderer()->style(m_firstLine);
     int baseline = styleToUse->font().ascent();
-    ty -= styleToUse->isFlippedLinesWritingMode() ? baseline : 0;
-    IntPoint textOrigin(m_x + tx, m_y + ty + baseline);
+    ty -= styleToUse->isHorizontalWritingMode() ? 0 : baseline;
     
+    IntPoint boxOrigin(m_x, m_y);
+    adjustForFlippedBlocksWritingMode(boxOrigin);
+    boxOrigin.move(tx, ty);
+    
+    IntPoint textOrigin = IntPoint(boxOrigin.x(), boxOrigin.y() + baseline);
+    IntRect boxRect(boxOrigin, IntSize(logicalWidth(), logicalHeight()));
+
     if (m_isVertical) {
         context->save();
         context->translate(textOrigin.x(), textOrigin.y());
@@ -459,14 +465,14 @@ void InlineTextBox::paint(PaintInfo& paintInfo, int tx, int ty)
 #endif
 
         if (containsComposition && !useCustomUnderlines)
-            paintCompositionBackground(context, tx, ty, styleToUse, font,
+            paintCompositionBackground(context, boxOrigin, styleToUse, font,
                 renderer()->frame()->editor()->compositionStart(),
                 renderer()->frame()->editor()->compositionEnd());
 
-        paintDocumentMarkers(context, tx, ty, styleToUse, font, true);
+        paintDocumentMarkers(context, boxOrigin, styleToUse, font, true);
 
         if (haveSelection && !useCustomUnderlines)
-            paintSelection(context, tx, ty, styleToUse, font);
+            paintSelection(context, boxOrigin, styleToUse, font);
     }
 
     // 2. Now paint the foreground, including text and decorations like underline/overline (in quirks mode only).
@@ -560,9 +566,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, logicalWidth(), logicalHeight(), textShadow, textStrokeWidth > 0, m_isVertical);
+            paintTextWithShadows(context, font, textRun, 0, length, length, textOrigin, boxRect, textShadow, textStrokeWidth > 0, m_isVertical);
         } else
-            paintTextWithShadows(context, font, textRun, ePos, sPos, length, textOrigin, m_x + tx, m_y + ty, logicalWidth(), logicalHeight(), textShadow, textStrokeWidth > 0, m_isVertical);
+            paintTextWithShadows(context, font, textRun, ePos, sPos, length, textOrigin, boxRect, textShadow, textStrokeWidth > 0, m_isVertical);
 
         if (textStrokeWidth > 0)
             context->restore();
@@ -574,7 +580,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, logicalWidth(), logicalHeight(), selectionShadow, selectionStrokeWidth > 0, m_isVertical);
+        paintTextWithShadows(context, font, textRun, sPos, ePos, length, textOrigin, boxRect, selectionShadow, selectionStrokeWidth > 0, m_isVertical);
 
         if (selectionStrokeWidth > 0)
             context->restore();
@@ -583,11 +589,11 @@ void InlineTextBox::paint(PaintInfo& paintInfo, int tx, int ty)
     // Paint decorations
     if (d != TDNONE && paintInfo.phase != PaintPhaseSelection) {
         updateGraphicsContext(context, textFillColor, textStrokeColor, textStrokeWidth, styleToUse->colorSpace());
-        paintDecoration(context, tx, ty, d, textShadow);
+        paintDecoration(context, boxOrigin, d, textShadow);
     }
 
     if (paintInfo.phase == PaintPhaseForeground) {
-        paintDocumentMarkers(context, tx, ty, styleToUse, font, false);
+        paintDocumentMarkers(context, boxOrigin, styleToUse, font, false);
 
         if (useCustomUnderlines) {
             const Vector<CompositionUnderline>& underlines = renderer()->frame()->editor()->customCompositionUnderlines();
@@ -604,7 +610,7 @@ void InlineTextBox::paint(PaintInfo& paintInfo, int tx, int ty)
                 
                 if (underline.startOffset <= end()) {
                     // underline intersects this run.  Paint it.
-                    paintCompositionUnderline(context, tx, ty, underline);
+                    paintCompositionUnderline(context, boxOrigin, underline);
                     if (underline.endOffset > end() + 1)
                         // underline also runs into the next run. Bail now, no more marker advancement.
                         break;
@@ -637,7 +643,7 @@ void InlineTextBox::selectionStartEnd(int& sPos, int& ePos)
     ePos = min(endPos - m_start, (int)m_len);
 }
 
-void InlineTextBox::paintSelection(GraphicsContext* context, int tx, int ty, RenderStyle* style, const Font& font)
+void InlineTextBox::paintSelection(GraphicsContext* context, const IntPoint& boxOrigin, RenderStyle* style, const Font& font)
 {
     // See if we have a selection to paint at all.
     int sPos, ePos;
@@ -657,8 +663,7 @@ void InlineTextBox::paintSelection(GraphicsContext* context, int tx, int ty, Ren
 
     context->save();
     updateGraphicsContext(context, c, c, 0, style->colorSpace());  // Don't draw text at all!
-    int y = selectionTop();
-    int h = selectionHeight();
+    
     // If the text is truncated, let the thing being painted in the truncation
     // draw its own highlight.
     int length = m_truncation != cNoTruncation ? m_truncation : m_len;
@@ -670,14 +675,17 @@ void InlineTextBox::paintSelection(GraphicsContext* context, int tx, int ty, Ren
         ePos = length;
     }
 
-    context->clip(IntRect(m_x + tx, y + ty, m_logicalWidth, h));
+    int deltaY = logicalTop() - selectionTop();
+    int selHeight = selectionHeight();
+    IntPoint localOrigin(boxOrigin.x(), boxOrigin.y() - deltaY);
+    context->clip(IntRect(localOrigin, IntSize(m_logicalWidth, selHeight)));
     context->drawHighlightForText(font, TextRun(characters, length, textRenderer()->allowTabs(), textPos(), m_toAdd, 
                                   !isLeftToRightDirection(), m_dirOverride || style->visuallyOrdered()),
-                                  IntPoint(m_x + tx, y + ty), h, c, style->colorSpace(), sPos, ePos);
+                                  localOrigin, selHeight, c, style->colorSpace(), sPos, ePos);
     context->restore();
 }
 
-void InlineTextBox::paintCompositionBackground(GraphicsContext* context, int tx, int ty, RenderStyle* style, const Font& font, int startPos, int endPos)
+void InlineTextBox::paintCompositionBackground(GraphicsContext* context, const IntPoint& boxOrigin, RenderStyle* style, const Font& font, int startPos, int endPos)
 {
     int offset = m_start;
     int sPos = max(startPos - offset, 0);
@@ -692,11 +700,12 @@ void InlineTextBox::paintCompositionBackground(GraphicsContext* context, int tx,
     
     updateGraphicsContext(context, c, c, 0, style->colorSpace()); // Don't draw text at all!
 
-    int y = selectionTop();
-    int h = selectionHeight();
+    int deltaY = logicalTop() - selectionTop();
+    int selHeight = selectionHeight();
+    IntPoint localOrigin(boxOrigin.x(), boxOrigin.y() - deltaY);
     context->drawHighlightForText(font, TextRun(textRenderer()->text()->characters() + m_start, m_len, textRenderer()->allowTabs(), textPos(), m_toAdd,
                                   !isLeftToRightDirection(), m_dirOverride || style->visuallyOrdered()),
-                                  IntPoint(m_x + tx, y + ty), h, c, style->colorSpace(), sPos, ePos);
+                                  localOrigin, selHeight, c, style->colorSpace(), sPos, ePos);
     context->restore();
 }
 
@@ -720,19 +729,18 @@ void InlineTextBox::paintCustomHighlight(int tx, int ty, const AtomicString& typ
 
 #endif
 
-void InlineTextBox::paintDecoration(GraphicsContext* context, int tx, int ty, int deco, const ShadowData* shadow)
+void InlineTextBox::paintDecoration(GraphicsContext* context, const IntPoint& boxOrigin, int deco, const ShadowData* shadow)
 {
-    tx += m_x;
-    ty += m_y;
-
     if (m_truncation == cFullTruncation)
         return;
 
+    IntPoint localOrigin = boxOrigin;
+
     int width = m_logicalWidth;
     if (m_truncation != cNoTruncation) {
         width = toRenderText(renderer())->width(m_start, m_truncation, textPos(), m_firstLine);
         if (!isLeftToRightDirection())
-            tx += (m_logicalWidth - width);
+            localOrigin.move(m_logicalWidth - width, 0);
     }
     
     // Get the text decoration colors.
@@ -752,9 +760,9 @@ void InlineTextBox::paintDecoration(GraphicsContext* context, int tx, int ty, in
     int extraOffset = 0;
     if (!linesAreOpaque && shadow && shadow->next()) {
         context->save();
-        IntRect clipRect(tx, ty, width, baseline + 2);
+        IntRect clipRect(localOrigin, IntSize(width, baseline + 2));
         for (const ShadowData* s = shadow; s; s = s->next()) {
-            IntRect shadowRect(tx, ty, width, baseline + 2);
+            IntRect shadowRect(localOrigin, IntSize(width, baseline + 2));
             shadowRect.inflate(s->blur());
             int shadowX = m_isVertical ? s->y() : s->x();
             int shadowY = m_isVertical ? -s->x() : s->y();
@@ -765,7 +773,7 @@ void InlineTextBox::paintDecoration(GraphicsContext* context, int tx, int ty, in
         context->save();
         context->clip(clipRect);
         extraOffset += baseline + 2;
-        ty += extraOffset;
+        localOrigin.move(0, extraOffset);
         setClip = true;
     }
 
@@ -776,7 +784,7 @@ void InlineTextBox::paintDecoration(GraphicsContext* context, int tx, int ty, in
         if (shadow) {
             if (!shadow->next()) {
                 // The last set of lines paints normally inside the clip.
-                ty -= extraOffset;
+                localOrigin.move(0, -extraOffset);
                 extraOffset = 0;
             }
             int shadowX = m_isVertical ? shadow->y() : shadow->x();
@@ -790,17 +798,17 @@ void InlineTextBox::paintDecoration(GraphicsContext* context, int tx, int ty, in
             context->setStrokeColor(underline, colorSpace);
             context->setStrokeStyle(SolidStroke);
             // Leave one pixel of white between the baseline and the underline.
-            context->drawLineForText(IntPoint(tx, ty + baseline + 1), width, isPrinting);
+            context->drawLineForText(IntPoint(localOrigin.x(), localOrigin.y() + baseline + 1), width, isPrinting);
         }
         if (deco & OVERLINE) {
             context->setStrokeColor(overline, colorSpace);
             context->setStrokeStyle(SolidStroke);
-            context->drawLineForText(IntPoint(tx, ty), width, isPrinting);
+            context->drawLineForText(localOrigin, width, isPrinting);
         }
         if (deco & LINE_THROUGH) {
             context->setStrokeColor(linethrough, colorSpace);
             context->setStrokeStyle(SolidStroke);
-            context->drawLineForText(IntPoint(tx, ty + 2 * baseline / 3), width, isPrinting);
+            context->drawLineForText(IntPoint(localOrigin.x(), localOrigin.y() + 2 * baseline / 3), width, isPrinting);
         }
     } while (shadow);
 
@@ -825,7 +833,7 @@ static GraphicsContext::TextCheckingLineStyle textCheckingLineStyleForMarkerType
     }
 }
 
-void InlineTextBox::paintSpellingOrGrammarMarker(GraphicsContext* pt, int tx, int ty, const DocumentMarker& marker, RenderStyle* style, const Font& font, bool grammar)
+void InlineTextBox::paintSpellingOrGrammarMarker(GraphicsContext* pt, const IntPoint& boxOrigin, const DocumentMarker& marker, RenderStyle* style, const Font& font, bool grammar)
 {
     // Never print spelling/grammar markers (5327887)
     if (textRenderer()->document()->printing())
@@ -854,18 +862,19 @@ void InlineTextBox::paintSpellingOrGrammarMarker(GraphicsContext* pt, int tx, in
             endPosition = min<int>(endPosition, m_truncation);
 
         // Calculate start & width
-        IntPoint startPoint(tx + m_x, ty + selectionTop());
+        int deltaY = logicalTop() - selectionTop();
+        int selHeight = selectionHeight();
+        IntPoint startPoint(boxOrigin.x(), boxOrigin.y() - deltaY);
         TextRun run(textRenderer()->text()->characters() + m_start, m_len, textRenderer()->allowTabs(), textPos(), m_toAdd, !isLeftToRightDirection(), m_dirOverride || style->visuallyOrdered());
-        int h = selectionHeight();
-        
-        IntRect markerRect = enclosingIntRect(font.selectionRectForText(run, startPoint, h, startPosition, endPosition));
+         
+        IntRect markerRect = enclosingIntRect(font.selectionRectForText(run, startPoint, selHeight, startPosition, endPosition));
         start = markerRect.x() - startPoint.x();
         width = markerRect.width();
         
         // Store rendered rects for bad grammar markers, so we can hit-test against it elsewhere in order to
         // display a toolTip. We don't do this for misspelling markers.
         if (grammar) {
-            markerRect.move(-tx, -ty);
+            markerRect.move(-boxOrigin.x(), -boxOrigin.y());
             markerRect = renderer()->localToAbsoluteQuad(FloatRect(markerRect)).enclosingBoundingBox();
             renderer()->document()->markers()->setRenderedRectForMarker(renderer()->node(), marker, markerRect);
         }
@@ -888,22 +897,22 @@ void InlineTextBox::paintSpellingOrGrammarMarker(GraphicsContext* pt, int tx, in
         // In larger fonts, though, place the underline up near the baseline to prevent a big gap.
         underlineOffset = baseline + 2;
     }
-    pt->drawLineForTextChecking(IntPoint(tx + m_x + start, ty + m_y + underlineOffset), width, textCheckingLineStyleForMarkerType(marker.type));
+    pt->drawLineForTextChecking(IntPoint(boxOrigin.x() + start, boxOrigin.y() + underlineOffset), width, textCheckingLineStyleForMarkerType(marker.type));
 }
 
-void InlineTextBox::paintTextMatchMarker(GraphicsContext* pt, int tx, int ty, const DocumentMarker& marker, RenderStyle* style, const Font& font)
+void InlineTextBox::paintTextMatchMarker(GraphicsContext* pt, const IntPoint& boxOrigin, const DocumentMarker& marker, RenderStyle* style, const Font& font)
 {
     // Use same y positioning and height as for selection, so that when the selection and this highlight are on
     // the same word there are no pieces sticking out.
-    int y = selectionTop();
-    int h = selectionHeight();
-    
+    int deltaY = logicalTop() - selectionTop();
+    int selHeight = selectionHeight();
+
     int sPos = max(marker.startOffset - m_start, (unsigned)0);
     int ePos = min(marker.endOffset - m_start, (unsigned)m_len);    
     TextRun run(textRenderer()->text()->characters() + m_start, m_len, textRenderer()->allowTabs(), textPos(), m_toAdd, !isLeftToRightDirection(), m_dirOverride || style->visuallyOrdered());
     
     // Always compute and store the rect associated with this marker. The computed rect is in absolute coordinates.
-    IntRect markerRect = enclosingIntRect(font.selectionRectForText(run, IntPoint(m_x, y), h, sPos, ePos));
+    IntRect markerRect = enclosingIntRect(font.selectionRectForText(run, IntPoint(m_x, selectionTop()), selHeight, sPos, ePos));
     markerRect = renderer()->localToAbsoluteQuad(FloatRect(markerRect)).enclosingBoundingBox();
     renderer()->document()->markers()->setRenderedRectForMarker(renderer()->node(), marker, markerRect);
     
@@ -914,13 +923,13 @@ 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_logicalWidth, h));
-        pt->drawHighlightForText(font, run, IntPoint(m_x + tx, y + ty), h, color, style->colorSpace(), sPos, ePos);
+        pt->clip(IntRect(boxOrigin.x(), boxOrigin.y() - deltaY, m_logicalWidth, selHeight));
+        pt->drawHighlightForText(font, run, IntPoint(boxOrigin.x(), boxOrigin.y() - deltaY), selHeight, color, style->colorSpace(), sPos, ePos);
         pt->restore();
     }
 }
 
-void InlineTextBox::computeRectForReplacementMarker(int /*tx*/, int /*ty*/, const DocumentMarker& marker, RenderStyle* style, const Font& font)
+void InlineTextBox::computeRectForReplacementMarker(const DocumentMarker& marker, RenderStyle* style, const Font& font)
 {
     // Replacement markers are not actually drawn, but their rects need to be computed for hit testing.
     int y = selectionTop();
@@ -937,7 +946,7 @@ void InlineTextBox::computeRectForReplacementMarker(int /*tx*/, int /*ty*/, cons
     renderer()->document()->markers()->setRenderedRectForMarker(renderer()->node(), marker, markerRect);
 }
     
-void InlineTextBox::paintDocumentMarkers(GraphicsContext* pt, int tx, int ty, RenderStyle* style, const Font& font, bool background)
+void InlineTextBox::paintDocumentMarkers(GraphicsContext* pt, const IntPoint& boxOrigin, RenderStyle* style, const Font& font, bool background)
 {
     if (!renderer()->node())
         return;
@@ -981,17 +990,17 @@ void InlineTextBox::paintDocumentMarkers(GraphicsContext* pt, int tx, int ty, Re
         // marker intersects this run.  Paint it.
         switch (marker.type) {
             case DocumentMarker::Spelling:
-                paintSpellingOrGrammarMarker(pt, tx, ty, marker, style, font, false);
+                paintSpellingOrGrammarMarker(pt, boxOrigin, marker, style, font, false);
                 break;
             case DocumentMarker::Grammar:
-                paintSpellingOrGrammarMarker(pt, tx, ty, marker, style, font, true);
+                paintSpellingOrGrammarMarker(pt, boxOrigin, marker, style, font, true);
                 break;
             case DocumentMarker::TextMatch:
-                paintTextMatchMarker(pt, tx, ty, marker, style, font);
+                paintTextMatchMarker(pt, boxOrigin, marker, style, font);
                 break;
             case DocumentMarker::CorrectionIndicator:
-                computeRectForReplacementMarker(tx, ty, marker, style, font);
-                paintSpellingOrGrammarMarker(pt, tx, ty, marker, style, font, false);
+                computeRectForReplacementMarker(marker, style, font);
+                paintSpellingOrGrammarMarker(pt, boxOrigin, marker, style, font, false);
                 break;
             case DocumentMarker::Replacement:
             case DocumentMarker::RejectedCorrection:
@@ -1004,11 +1013,8 @@ void InlineTextBox::paintDocumentMarkers(GraphicsContext* pt, int tx, int ty, Re
 }
 
 
-void InlineTextBox::paintCompositionUnderline(GraphicsContext* ctx, int tx, int ty, const CompositionUnderline& underline)
+void InlineTextBox::paintCompositionUnderline(GraphicsContext* ctx, const IntPoint& boxOrigin, const CompositionUnderline& underline)
 {
-    tx += m_x;
-    ty += m_y;
-
     if (m_truncation == cFullTruncation)
         return;
     
@@ -1049,7 +1055,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 + logicalHeight() - lineThickness), width, textRenderer()->document()->printing());
+    ctx->drawLineForText(IntPoint(boxOrigin.x() + start, boxOrigin.y() + logicalHeight() - lineThickness), width, textRenderer()->document()->printing());
 }
 
 int InlineTextBox::caretMinOffset() const
diff --git a/WebCore/rendering/InlineTextBox.h b/WebCore/rendering/InlineTextBox.h
index 175c5fe..9c4c72f 100644
--- a/WebCore/rendering/InlineTextBox.h
+++ b/WebCore/rendering/InlineTextBox.h
@@ -140,19 +140,19 @@ private:
                       // denote no truncation (the whole run paints) and full truncation (nothing paints at all).
 
 protected:
-    void paintCompositionBackground(GraphicsContext*, int tx, int ty, RenderStyle*, const Font&, int startPos, int endPos);
-    void paintDocumentMarkers(GraphicsContext*, int tx, int ty, RenderStyle*, const Font&, bool background);
-    void paintCompositionUnderline(GraphicsContext*, int tx, int ty, const CompositionUnderline&);
+    void paintCompositionBackground(GraphicsContext*, const IntPoint& boxOrigin, RenderStyle*, const Font&, int startPos, int endPos);
+    void paintDocumentMarkers(GraphicsContext*, const IntPoint& boxOrigin, RenderStyle*, const Font&, bool background);
+    void paintCompositionUnderline(GraphicsContext*, const IntPoint& boxOrigin, const CompositionUnderline&);
 #if PLATFORM(MAC)
     void paintCustomHighlight(int tx, int ty, const AtomicString& type);
 #endif
 
 private:
-    void paintDecoration(GraphicsContext*, int tx, int ty, int decoration, const ShadowData*);
-    void paintSelection(GraphicsContext*, int tx, int ty, RenderStyle*, const Font&);
-    void paintSpellingOrGrammarMarker(GraphicsContext*, int tx, int ty, const DocumentMarker&, RenderStyle*, const Font&, bool grammar);
-    void paintTextMatchMarker(GraphicsContext*, int tx, int ty, const DocumentMarker&, RenderStyle*, const Font&);
-    void computeRectForReplacementMarker(int tx, int ty, const DocumentMarker&, RenderStyle*, const Font&);
+    void paintDecoration(GraphicsContext*, const IntPoint& boxOrigin, int decoration, const ShadowData*);
+    void paintSelection(GraphicsContext*, const IntPoint& boxOrigin, RenderStyle*, const Font&);
+    void paintSpellingOrGrammarMarker(GraphicsContext*, const IntPoint& boxOrigin, const DocumentMarker&, RenderStyle*, const Font&, bool grammar);
+    void paintTextMatchMarker(GraphicsContext*, const IntPoint& boxOrigin, const DocumentMarker&, RenderStyle*, const Font&);
+    void computeRectForReplacementMarker(const DocumentMarker&, RenderStyle*, const Font&);
 };
 
 inline RenderText* InlineTextBox::textRenderer() const
diff --git a/WebCore/rendering/RenderBlock.cpp b/WebCore/rendering/RenderBlock.cpp
index 771c6d7..56099aa 100644
--- a/WebCore/rendering/RenderBlock.cpp
+++ b/WebCore/rendering/RenderBlock.cpp
@@ -2269,8 +2269,10 @@ void RenderBlock::paintChildren(PaintInfo& paintInfo, int tx, int ty)
             }
         }
 
+        IntPoint childPoint(tx, ty);
+        adjustForFlippedBlocksWritingMode(child, childPoint);
         if (!child->hasSelfPaintingLayer() && !child->isFloating())
-            child->paint(info, tx, ty);
+            child->paint(info, childPoint.x(), childPoint.y());
 
         // Check for page-break-after: always, and if it's set, break and bail.
         bool checkAfterAlways = !childrenInline() && (usePrintRect && child->style()->pageBreakAfter() == PBALWAYS);
@@ -2403,18 +2405,19 @@ void RenderBlock::paintFloats(PaintInfo& paintInfo, int tx, int ty, bool preserv
         if (r->m_shouldPaint && !r->m_renderer->hasSelfPaintingLayer()) {
             PaintInfo currentPaintInfo(paintInfo);
             currentPaintInfo.phase = preservePhase ? paintInfo.phase : PaintPhaseBlockBackground;
-            int currentTX = tx + r->left() - r->m_renderer->x() + r->m_renderer->marginLeft();
-            int currentTY = ty + r->top() - r->m_renderer->y() + r->m_renderer->marginTop();
-            r->m_renderer->paint(currentPaintInfo, currentTX, currentTY);
+            IntPoint childPoint(tx + r->left() + r->m_renderer->marginLeft() - r->m_renderer->x(),
+                                ty + r->top() + r->m_renderer->marginTop() - r->m_renderer->y());
+            adjustForFlippedBlocksWritingMode(r->m_renderer, childPoint);
+            r->m_renderer->paint(currentPaintInfo, childPoint.x(), childPoint.y());
             if (!preservePhase) {
                 currentPaintInfo.phase = PaintPhaseChildBlockBackgrounds;
-                r->m_renderer->paint(currentPaintInfo, currentTX, currentTY);
+                r->m_renderer->paint(currentPaintInfo, childPoint.x(), childPoint.y());
                 currentPaintInfo.phase = PaintPhaseFloat;
-                r->m_renderer->paint(currentPaintInfo, currentTX, currentTY);
+                r->m_renderer->paint(currentPaintInfo, childPoint.x(), childPoint.y());
                 currentPaintInfo.phase = PaintPhaseForeground;
-                r->m_renderer->paint(currentPaintInfo, currentTX, currentTY);
+                r->m_renderer->paint(currentPaintInfo, childPoint.x(), childPoint.y());
                 currentPaintInfo.phase = PaintPhaseOutline;
-                r->m_renderer->paint(currentPaintInfo, currentTX, currentTY);
+                r->m_renderer->paint(currentPaintInfo, childPoint.x(), childPoint.y());
             }
         }
     }
diff --git a/WebCore/rendering/RenderBox.cpp b/WebCore/rendering/RenderBox.cpp
index 5a95e0b..48ec384 100644
--- a/WebCore/rendering/RenderBox.cpp
+++ b/WebCore/rendering/RenderBox.cpp
@@ -3188,4 +3188,17 @@ void RenderBox::blockDirectionOverflow(bool isLineVertical, int& logicalTopLayou
     }
 }
 
+void RenderBox::adjustForFlippedBlocksWritingMode(RenderBox* child, IntPoint& point)
+{
+    if (!style()->isFlippedBlocksWritingMode())
+        return;
+    
+    // The child is going to add in its x() and y(), so we have to make sure it ends up in
+    // the right place.
+    if (style()->isHorizontalWritingMode())
+        point.move(0, height() - child->height() - child->y() - child->y());
+    else
+        point.move(width() - child->width() - child->x() - child->x(), 0);
+}
+
 } // namespace WebCore
diff --git a/WebCore/rendering/RenderBox.h b/WebCore/rendering/RenderBox.h
index 39ab16b..4a745e5 100644
--- a/WebCore/rendering/RenderBox.h
+++ b/WebCore/rendering/RenderBox.h
@@ -377,6 +377,8 @@ public:
     virtual int lineHeight(bool firstLine, LineDirectionMode, LinePositionMode = PositionOnContainingLine) const;
     virtual int baselinePosition(bool firstLine, LineDirectionMode, LinePositionMode = PositionOnContainingLine) const;
 
+    void adjustForFlippedBlocksWritingMode(RenderBox* child, IntPoint&);
+
 protected:
     virtual void styleWillChange(StyleDifference, const RenderStyle* newStyle);
     virtual void styleDidChange(StyleDifference, const RenderStyle* oldStyle);
diff --git a/WebCore/rendering/style/RenderStyle.h b/WebCore/rendering/style/RenderStyle.h
index 7056b1d..9aae33f 100644
--- a/WebCore/rendering/style/RenderStyle.h
+++ b/WebCore/rendering/style/RenderStyle.h
@@ -754,6 +754,7 @@ public:
     WritingMode writingMode() const { return static_cast<WritingMode>(inherited_flags.m_writingMode); }
     bool isHorizontalWritingMode() const { return writingMode() == TopToBottomWritingMode || writingMode() == BottomToTopWritingMode; }
     bool isFlippedLinesWritingMode() const { return writingMode() == LeftToRightWritingMode || writingMode() == BottomToTopWritingMode; }
+    bool isFlippedBlocksWritingMode() const { return writingMode() == RightToLeftWritingMode || writingMode() == BottomToTopWritingMode; }
 
     ESpeak speak() { return static_cast<ESpeak>(rareInheritedData->speak); }
         

-- 
WebKit Debian packaging



More information about the Pkg-webkit-commits mailing list