Commit 8388d184 authored by hyatt@apple.com's avatar hyatt@apple.com
Browse files

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
parent 2ffbd60a
2010-10-25 David Hyatt <hyatt@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@nokia.com>
 
Reviewed by Antonio Gomes.
<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>
<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>
0b31200048273801e17725c5f5114ce9
\ No newline at end of file
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."
57b207ac9f5b0d0eef5a6f6195202ad9
\ No newline at end of file
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."
2010-10-25 David Hyatt <hyatt@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@google.com>
 
Reviewed by Steve Block.
......@@ -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
......
......@@ -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.
......
......@@ -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();
......
This diff is collapsed.
......@@ -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
......
......@@ -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());
}
}
}
......
......@@ -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
......@@ -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);
......
......@@ -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); }
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment