Commit 1a5ffd8e authored by hyatt@apple.com's avatar hyatt@apple.com

2009-06-13 David Hyatt <hyatt@apple.com>

        Reviewed by Darin Adler.

        Cleanup of the new MidpointState class.  Turn it into a struct instead.  Fix a mistaken
        assertion removal and some unintentional whitespace changes.

        * platform/text/BidiResolver.h:
        (WebCore::MidpointState::reset):
        * rendering/RenderBlock.h:
        * rendering/bidi.cpp:
        (WebCore::BidiRun::operator delete):
        (WebCore::chopMidpointsAt):
        (WebCore::checkMidpoints):
        (WebCore::addMidpoint):
        (WebCore::appendRunsForObject):
        (WebCore::RenderBlock::findNextLineBreak):



git-svn-id: http://svn.webkit.org/repository/webkit/trunk@44650 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent b3466afc
2009-06-13 David Hyatt <hyatt@apple.com>
Reviewed by Darin Adler.
Cleanup of the new MidpointState class. Turn it into a struct instead. Fix a mistaken
assertion removal and some unintentional whitespace changes.
* platform/text/BidiResolver.h:
(WebCore::MidpointState::reset):
* rendering/RenderBlock.h:
* rendering/bidi.cpp:
(WebCore::BidiRun::operator delete):
(WebCore::chopMidpointsAt):
(WebCore::checkMidpoints):
(WebCore::addMidpoint):
(WebCore::appendRunsForObject):
(WebCore::RenderBlock::findNextLineBreak):
2009-06-12 David Hyatt <hyatt@apple.com>
Reviewed by Dan Bernstein.
......@@ -29,9 +29,7 @@
namespace WebCore {
template <class Iterator> class MidpointState
{
public:
template <class Iterator> struct MidpointState {
MidpointState()
{
reset();
......@@ -39,18 +37,18 @@ public:
void reset()
{
m_numMidpoints = 0;
m_currentMidpoint = 0;
m_betweenMidpoints = false;
numMidpoints = 0;
currentMidpoint = 0;
betweenMidpoints = false;
}
// The goal is to reuse the line state across multiple
// lines so we just keep an array around for midpoints and never clear it across multiple
// lines. We track the number of items and position using the two other variables.
Vector<Iterator> m_midpoints;
unsigned m_numMidpoints;
unsigned m_currentMidpoint;
bool m_betweenMidpoints;
Vector<Iterator> midpoints;
unsigned numMidpoints;
unsigned currentMidpoint;
bool betweenMidpoints;
};
// The BidiStatus at a given position (typically the end of a line) can
......
......@@ -24,6 +24,7 @@
#ifndef RenderBlock_h
#define RenderBlock_h
#include "DeprecatedPtrList.h"
#include "GapRects.h"
#include "RenderBox.h"
......
......@@ -136,7 +136,7 @@ void BidiRun::operator delete(void* ptr, size_t sz)
#ifndef NDEBUG
bidiRunCounter.decrement();
#endif
//ASSERT(inBidiRunDestroy);
ASSERT(inBidiRunDestroy);
// Stash size where destroy() can find it.
*(size_t*)ptr = sz;
......@@ -318,13 +318,13 @@ ALWAYS_INLINE Direction InlineIterator::direction() const
static void chopMidpointsAt(LineMidpointState& lineMidpointState, RenderObject* obj, unsigned pos)
{
if (!lineMidpointState.m_numMidpoints)
if (!lineMidpointState.numMidpoints)
return;
InlineIterator* midpoints = lineMidpointState.m_midpoints.data();
for (int i = lineMidpointState.m_numMidpoints - 1; i >= 0; i--) {
InlineIterator* midpoints = lineMidpointState.midpoints.data();
for (int i = lineMidpointState.numMidpoints - 1; i >= 0; i--) {
const InlineIterator& point = midpoints[i];
if (point.obj == obj && point.pos == pos) {
lineMidpointState.m_numMidpoints = i;
lineMidpointState.numMidpoints = i;
break;
}
}
......@@ -335,16 +335,16 @@ static void checkMidpoints(LineMidpointState& lineMidpointState, InlineIterator&
// Check to see if our last midpoint is a start point beyond the line break. If so,
// shave it off the list, and shave off a trailing space if the previous end point doesn't
// preserve whitespace.
if (lBreak.obj && lineMidpointState.m_numMidpoints && !(lineMidpointState.m_numMidpoints % 2)) {
InlineIterator* midpoints = lineMidpointState.m_midpoints.data();
InlineIterator& endpoint = midpoints[lineMidpointState.m_numMidpoints - 2];
const InlineIterator& startpoint = midpoints[lineMidpointState.m_numMidpoints - 1];
if (lBreak.obj && lineMidpointState.numMidpoints && !(lineMidpointState.numMidpoints % 2)) {
InlineIterator* midpoints = lineMidpointState.midpoints.data();
InlineIterator& endpoint = midpoints[lineMidpointState.numMidpoints - 2];
const InlineIterator& startpoint = midpoints[lineMidpointState.numMidpoints - 1];
InlineIterator currpoint = endpoint;
while (!currpoint.atEnd() && currpoint != startpoint && currpoint != lBreak)
currpoint.increment();
if (currpoint == lBreak) {
// We hit the line break before the start point. Shave off the start point.
lineMidpointState.m_numMidpoints--;
lineMidpointState.numMidpoints--;
if (endpoint.obj->style()->collapseWhiteSpace()) {
if (endpoint.obj->isText()) {
// Don't shave a character off the endpoint if it was from a soft hyphen.
......@@ -366,11 +366,11 @@ static void checkMidpoints(LineMidpointState& lineMidpointState, InlineIterator&
static void addMidpoint(LineMidpointState& lineMidpointState, const InlineIterator& midpoint)
{
if (lineMidpointState.m_midpoints.size() <= lineMidpointState.m_numMidpoints)
lineMidpointState.m_midpoints.grow(lineMidpointState.m_numMidpoints + 10);
if (lineMidpointState.midpoints.size() <= lineMidpointState.numMidpoints)
lineMidpointState.midpoints.grow(lineMidpointState.numMidpoints + 10);
InlineIterator* midpoints = lineMidpointState.m_midpoints.data();
midpoints[lineMidpointState.m_numMidpoints++] = midpoint;
InlineIterator* midpoints = lineMidpointState.midpoints.data();
midpoints[lineMidpointState.numMidpoints++] = midpoint;
}
static void appendRunsForObject(int start, int end, RenderObject* obj, InlineBidiResolver& resolver)
......@@ -380,18 +380,18 @@ static void appendRunsForObject(int start, int end, RenderObject* obj, InlineBid
return;
LineMidpointState& lineMidpointState = resolver.midpointState();
bool haveNextMidpoint = (lineMidpointState.m_currentMidpoint < lineMidpointState.m_numMidpoints);
bool haveNextMidpoint = (lineMidpointState.currentMidpoint < lineMidpointState.numMidpoints);
InlineIterator nextMidpoint;
if (haveNextMidpoint)
nextMidpoint = lineMidpointState.m_midpoints[lineMidpointState.m_currentMidpoint];
if (lineMidpointState.m_betweenMidpoints) {
nextMidpoint = lineMidpointState.midpoints[lineMidpointState.currentMidpoint];
if (lineMidpointState.betweenMidpoints) {
if (!(haveNextMidpoint && nextMidpoint.obj == obj))
return;
// This is a new start point. Stop ignoring objects and
// adjust our start.
lineMidpointState.m_betweenMidpoints = false;
lineMidpointState.betweenMidpoints = false;
start = nextMidpoint.pos;
lineMidpointState.m_currentMidpoint++;
lineMidpointState.currentMidpoint++;
if (start < end)
return appendRunsForObject(start, end, obj, resolver);
} else {
......@@ -403,8 +403,8 @@ static void appendRunsForObject(int start, int end, RenderObject* obj, InlineBid
// An end midpoint has been encountered within our object. We
// need to go ahead and append a run with our endpoint.
if (static_cast<int>(nextMidpoint.pos + 1) <= end) {
lineMidpointState.m_betweenMidpoints = true;
lineMidpointState.m_currentMidpoint++;
lineMidpointState.betweenMidpoints = true;
lineMidpointState.currentMidpoint++;
if (nextMidpoint.pos != UINT_MAX) { // UINT_MAX means stop at the object and don't include any of it.
if (static_cast<int>(nextMidpoint.pos + 1) > start)
resolver.addRun(new (obj->renderArena())
......@@ -1817,9 +1817,9 @@ InlineIterator RenderBlock::findNextLineBreak(InlineBidiResolver& resolver, bool
else
beforeSoftHyphen = InlineIterator(0, last, last->isText() ? toRenderText(last)->textLength() - 1 : 0);
// Two consecutive soft hyphens. Avoid overlapping midpoints.
if (lineMidpointState.m_numMidpoints && lineMidpointState.m_midpoints[lineMidpointState.m_numMidpoints - 1].obj == o &&
lineMidpointState.m_midpoints[lineMidpointState.m_numMidpoints - 1].pos == pos)
lineMidpointState.m_numMidpoints--;
if (lineMidpointState.numMidpoints && lineMidpointState.midpoints[lineMidpointState.numMidpoints - 1].obj == o &&
lineMidpointState.midpoints[lineMidpointState.numMidpoints - 1].pos == pos)
lineMidpointState.numMidpoints--;
else
addMidpoint(lineMidpointState, beforeSoftHyphen);
......@@ -2142,9 +2142,9 @@ InlineIterator RenderBlock::findNextLineBreak(InlineBidiResolver& resolver, bool
// This object is either going to be part of the last midpoint, or it is going
// to be the actual endpoint. In both cases we just decrease our pos by 1 level to
// exclude the space, allowing it to - in effect - collapse into the newline.
if (lineMidpointState.m_numMidpoints % 2) {
InlineIterator* midpoints = lineMidpointState.m_midpoints.data();
midpoints[lineMidpointState.m_numMidpoints - 1].pos--;
if (lineMidpointState.numMidpoints % 2) {
InlineIterator* midpoints = lineMidpointState.midpoints.data();
midpoints[lineMidpointState.numMidpoints - 1].pos--;
}
//else if (lBreak.pos > 0)
// lBreak.pos--;
......
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