Commit 887f359e authored by mitz@apple.com's avatar mitz@apple.com

Reviewed by Dave Hyatt.

        - remove file-static BidiRun variables from bidi.cpp

        * platform/text/BidiResolver.h:
        (WebCore::BidiResolver::): Initialize m_logicallyLastRun.
        (WebCore::BidiResolver::logicallyLastRun): Added.
        (WebCore::BidiResolver::runCount): Made unsigned.
        (WebCore::::reverseRuns): Changed ints to unsigned.
        (WebCore::::createBidiRunsForLine): Made this function set
        m_logicallyLastRun.
        * rendering/RenderBlock.h:
        * rendering/bidi.cpp:
        (WebCore::BidiState::addRun): Removed setting of sLogicallyLastBidiRun.
        (WebCore::RenderBlock::constructLine): Removed unused start parameter
        and added run count and first and last run parameters. Replaced end
        parameter with lastLine boolean and endObject pointer.
        (WebCore::RenderBlock::computeHorizontalPositionsForLine): Added first
        and logically last run parameters.
        (WebCore::RenderBlock::computeVerticalPositionsForLine): Added firstRun
        parameter.
        (WebCore::RenderBlock::bidiReorderLine): Removed setting of static
        variables.
        (WebCore::RenderBlock::layoutInlineChildren): Changed to use BidiState
        accessors instead of file statics.



git-svn-id: http://svn.webkit.org/repository/webkit/trunk@30575 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 81bf662c
2008-02-25 Dan Bernstein <mitz@apple.com>
Reviewed by Dave Hyatt.
- remove file-static BidiRun variables from bidi.cpp
* platform/text/BidiResolver.h:
(WebCore::BidiResolver::): Initialize m_logicallyLastRun.
(WebCore::BidiResolver::logicallyLastRun): Added.
(WebCore::BidiResolver::runCount): Made unsigned.
(WebCore::::reverseRuns): Changed ints to unsigned.
(WebCore::::createBidiRunsForLine): Made this function set
m_logicallyLastRun.
* rendering/RenderBlock.h:
* rendering/bidi.cpp:
(WebCore::BidiState::addRun): Removed setting of sLogicallyLastBidiRun.
(WebCore::RenderBlock::constructLine): Removed unused start parameter
and added run count and first and last run parameters. Replaced end
parameter with lastLine boolean and endObject pointer.
(WebCore::RenderBlock::computeHorizontalPositionsForLine): Added first
and logically last run parameters.
(WebCore::RenderBlock::computeVerticalPositionsForLine): Added firstRun
parameter.
(WebCore::RenderBlock::bidiReorderLine): Removed setting of static
variables.
(WebCore::RenderBlock::layoutInlineChildren): Changed to use BidiState
accessors instead of file statics.
2008-02-25 Rodney Dawes <dobey@wayofthemonkey.com>
Reviewed by Jon Honeycutt.
/*
* Copyright (C) 2000 Lars Knoll (knoll@kde.org)
* Copyright (C) 2003, 2004, 2006, 2007 Apple Inc. All right reserved.
* Copyright (C) 2003, 2004, 2006, 2007, 2008 Apple Inc. All right reserved.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
......@@ -109,6 +109,7 @@ public :
, emptyRun(true)
, m_firstRun(0)
, m_lastRun(0)
, m_logicallyLastRun(0)
, m_runCount(0)
{
}
......@@ -134,14 +135,15 @@ public :
Run* firstRun() const { return m_firstRun; }
Run* lastRun() const { return m_lastRun; }
int runCount() const { return m_runCount; }
Run* logicallyLastRun() const { return m_logicallyLastRun; }
unsigned runCount() const { return m_runCount; }
void addRun(Run*);
void deleteRuns();
protected:
void appendRun();
void reverseRuns(int start, int end);
void reverseRuns(unsigned start, unsigned end);
Iterator current;
Iterator sor;
......@@ -157,7 +159,8 @@ protected:
Run* m_firstRun;
Run* m_lastRun;
int m_runCount;
Run* m_logicallyLastRun;
unsigned m_runCount;
};
template <class Iterator, class Run>
......@@ -323,18 +326,18 @@ void BidiResolver<Iterator, Run>::deleteRuns()
}
template <class Iterator, class Run>
void BidiResolver<Iterator, Run>::reverseRuns(int start, int end)
void BidiResolver<Iterator, Run>::reverseRuns(unsigned start, unsigned end)
{
if (start >= end)
return;
ASSERT(start >= 0 && end < m_runCount);
ASSERT(end < m_runCount);
// Get the item before the start of the runs to reverse and put it in
// |beforeStart|. |curr| should point to the first run to reverse.
Run* curr = m_firstRun;
Run* beforeStart = 0;
int i = 0;
unsigned i = 0;
while (i < start) {
i++;
beforeStart = curr;
......@@ -772,6 +775,8 @@ void BidiResolver<Iterator, Run>::createBidiRunsForLine(const Iterator& start, c
}
}
m_logicallyLastRun = m_lastRun;
// reorder line according to run structure...
// do not reverse for visually ordered web sites
if (!visualOrder) {
......@@ -796,22 +801,22 @@ void BidiResolver<Iterator, Run>::createBidiRunsForLine(const Iterator& start, c
if (!(levelLow % 2))
levelLow++;
int count = runCount() - 1;
unsigned count = runCount() - 1;
while (levelHigh >= levelLow) {
int i = 0;
unsigned i = 0;
Run* currRun = firstRun();
while (i < count) {
while (i < count && currRun && currRun->m_level < levelHigh) {
i++;
currRun = currRun->next();
}
int start = i;
unsigned start = i;
while (i <= count && currRun && currRun->m_level >= levelHigh) {
i++;
currRun = currRun->next();
}
int end = i-1;
unsigned end = i - 1;
reverseRuns(start, end);
}
levelHigh--;
......
......@@ -4,7 +4,7 @@
* Copyright (C) 1999 Lars Knoll (knoll@kde.org)
* (C) 1999 Antti Koivisto (koivisto@kde.org)
* (C) 2007 David Smith (catfish.man@gmail.com)
* Copyright (C) 2003, 2004, 2005, 2006 Apple Computer, Inc.
* Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008 Apple Computer, Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
......@@ -138,10 +138,10 @@ public:
int skipWhitespace(BidiIterator&, BidiState&);
void fitBelowFloats(int widthToFit, int& availableWidth);
BidiIterator findNextLineBreak(BidiIterator& start, BidiState& info);
RootInlineBox* constructLine(const BidiIterator& start, const BidiIterator& end);
RootInlineBox* constructLine(unsigned runCount, BidiRun* firstRun, BidiRun* lastRun, bool lastLine, RenderObject* endObject);
InlineFlowBox* createLineBoxes(RenderObject*);
void computeHorizontalPositionsForLine(RootInlineBox*, bool reachedEnd);
void computeVerticalPositionsForLine(RootInlineBox*);
void computeHorizontalPositionsForLine(RootInlineBox*, BidiRun* firstRun, BidiRun* logicallyLastRun, bool reachedEnd);
void computeVerticalPositionsForLine(RootInlineBox*, BidiRun*);
void checkLinesForOverflow();
void deleteEllipsisLineBoxes();
void checkLinesForTextOverflow();
......@@ -156,7 +156,7 @@ public:
void paintEllipsisBoxes(PaintInfo&, int tx, int ty);
void paintSelection(PaintInfo&, int tx, int ty);
void paintCaret(PaintInfo&, CaretType);
void insertFloatingObject(RenderObject*);
void removeFloatingObject(RenderObject*);
......
......@@ -72,12 +72,6 @@ public:
unsigned int pos;
};
// Used to track a list of chained bidi runs.
static BidiRun* sFirstBidiRun;
static BidiRun* sLastBidiRun;
static BidiRun* sLogicallyLastBidiRun;
static int sBidiRunCount;
// Midpoint globals. The goal is not to do any allocation when dealing with
// these midpoints, so we just keep an array around and never clear it. We track
// the number of items and position using the two other variables.
......@@ -367,8 +361,6 @@ inline void BidiState::addRun(BidiRun* bidiRun)
m_lastRun->m_next = bidiRun;
m_lastRun = bidiRun;
m_runCount++;
sLogicallyLastBidiRun = bidiRun;
}
static void chopMidpointsAt(RenderObject* obj, unsigned pos)
......@@ -562,17 +554,16 @@ InlineFlowBox* RenderBlock::createLineBoxes(RenderObject* obj)
return result;
}
RootInlineBox* RenderBlock::constructLine(const BidiIterator& start, const BidiIterator& end)
RootInlineBox* RenderBlock::constructLine(unsigned runCount, BidiRun* firstRun, BidiRun* lastRun, bool lastLine, RenderObject* endObject)
{
if (!sFirstBidiRun)
return 0; // We had no runs. Don't make a root inline box at all. The line is empty.
ASSERT(firstRun);
InlineFlowBox* parentBox = 0;
for (BidiRun* r = sFirstBidiRun; r; r = r->next()) {
for (BidiRun* r = firstRun; r; r = r->next()) {
// Create a box for our object.
bool isOnlyRun = (sBidiRunCount == 1);
if (sBidiRunCount == 2 && !r->obj->isListMarker())
isOnlyRun = ((style()->direction() == RTL) ? sLastBidiRun : sFirstBidiRun)->obj->isListMarker();
bool isOnlyRun = (runCount == 1);
if (runCount == 2 && !r->obj->isListMarker())
isOnlyRun = ((style()->direction() == RTL) ? lastRun : firstRun)->obj->isListMarker();
r->box = r->obj->createInlineBox(r->obj->isPositioned(), false, isOnlyRun);
if (r->box) {
// If we have no parent box yet, or if the run is not simply a sibling,
......@@ -604,10 +595,6 @@ RootInlineBox* RenderBlock::constructLine(const BidiIterator& start, const BidiI
// paint borders/margins/padding. This knowledge will ultimately be used when
// we determine the horizontal positions and widths of all the inline boxes on
// the line.
RenderObject* endObject = 0;
bool lastLine = !end.obj;
if (end.obj && end.pos == 0)
endObject = end.obj;
lastLineBox()->determineSpacingForFlowBoxes(lastLine, endObject);
// Now mark the line boxes as being constructed.
......@@ -617,7 +604,7 @@ RootInlineBox* RenderBlock::constructLine(const BidiIterator& start, const BidiI
return lastRootBox();
}
void RenderBlock::computeHorizontalPositionsForLine(RootInlineBox* lineBox, bool reachedEnd)
void RenderBlock::computeHorizontalPositionsForLine(RootInlineBox* lineBox, BidiRun* firstRun, BidiRun* logicallyLastRun, bool reachedEnd)
{
// First determine our total width.
int availableWidth = lineWidth(m_height);
......@@ -627,7 +614,7 @@ void RenderBlock::computeHorizontalPositionsForLine(RootInlineBox* lineBox, bool
unsigned numSpaces = 0;
ETextAlign textAlign = style()->textAlign();
for (r = sFirstBidiRun; r; r = r->next()) {
for (r = firstRun; r; r = r->next()) {
if (!r->box || r->obj->isPositioned() || r->box->isLineBreak())
continue; // Positioned objects are only participating to figure out their
// correct static x position. They have no effect on the width.
......@@ -664,10 +651,9 @@ void RenderBlock::computeHorizontalPositionsForLine(RootInlineBox* lineBox, bool
totWidth += r->box->width();
}
if (totWidth > availableWidth && sLogicallyLastBidiRun->obj->style(m_firstLine)->autoWrap() &&
sLogicallyLastBidiRun->obj->style(m_firstLine)->breakOnlyAfterWhiteSpace() &&
!sLogicallyLastBidiRun->compact) {
sLogicallyLastBidiRun->box->setWidth(sLogicallyLastBidiRun->box->width() - totWidth + availableWidth);
if (totWidth > availableWidth && logicallyLastRun->obj->style(m_firstLine)->autoWrap()
&& logicallyLastRun->obj->style(m_firstLine)->breakOnlyAfterWhiteSpace() && !logicallyLastRun->compact) {
logicallyLastRun->box->setWidth(logicallyLastRun->box->width() - totWidth + availableWidth);
totWidth = availableWidth;
}
......@@ -709,7 +695,7 @@ void RenderBlock::computeHorizontalPositionsForLine(RootInlineBox* lineBox, bool
}
if (numSpaces) {
for (r = sFirstBidiRun; r; r = r->next()) {
for (r = firstRun; r; r = r->next()) {
if (!r->box)
continue;
......@@ -745,7 +731,7 @@ void RenderBlock::computeHorizontalPositionsForLine(RootInlineBox* lineBox, bool
lineBox->setHorizontalOverflowPositions(leftPosition, rightPosition);
}
void RenderBlock::computeVerticalPositionsForLine(RootInlineBox* lineBox)
void RenderBlock::computeVerticalPositionsForLine(RootInlineBox* lineBox, BidiRun* firstRun)
{
lineBox->verticallyAlignBoxes(m_height);
lineBox->setBlockHeight(m_height);
......@@ -756,7 +742,7 @@ void RenderBlock::computeVerticalPositionsForLine(RootInlineBox* lineBox)
m_overflowHeight = bottomOfLine;
// Now make sure we place replaced render objects correctly.
for (BidiRun* r = sFirstBidiRun; r; r = r->next()) {
for (BidiRun* r = firstRun; r; r = r->next()) {
if (!r->box)
continue; // Skip runs with no line boxes.
......@@ -781,10 +767,6 @@ void RenderBlock::bidiReorderLine(const BidiIterator& start, const BidiIterator&
}
bidi.createBidiRunsForLine(start, end, style()->visuallyOrdered(), previousLineBrokeCleanly);
sFirstBidiRun = bidi.firstRun();
sLastBidiRun = bidi.lastRun();
sBidiRunCount = bidi.runCount();
}
static void buildCompactRuns(RenderObject* compactObj, BidiState& bidi)
......@@ -975,16 +957,16 @@ void RenderBlock::layoutInlineChildren(bool relayoutChildren, int& repaintTop, i
// inline flow boxes.
RootInlineBox* lineBox = 0;
if (sBidiRunCount) {
lineBox = constructLine(start, end);
if (bidi.runCount()) {
lineBox = constructLine(bidi.runCount(), bidi.firstRun(), bidi.lastRun(), !end.obj, end.obj && !end.pos ? end.obj : 0);
if (lineBox) {
lineBox->setEndsWithBreak(previousLineBrokeCleanly);
// Now we position all of our text runs horizontally.
computeHorizontalPositionsForLine(lineBox, end.atEnd());
computeHorizontalPositionsForLine(lineBox, bidi.firstRun(), bidi.logicallyLastRun(), end.atEnd());
// Now position our text runs vertically.
computeVerticalPositionsForLine(lineBox);
computeVerticalPositionsForLine(lineBox, bidi.firstRun());
#if ENABLE(SVG)
// Special SVG text layout code
......
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