https://bugs.webkit.org/show_bug.cgi?id=127154
Reviewed by David Hyatt.
I modified MidpointState to behave like a class, updated the call sites also.
No new tests, no behavior change.
* platform/text/BidiResolver.h:
(WebCore::MidpointState::reset):
(WebCore::MidpointState::startIgnoringSpaces):
(WebCore::MidpointState::stopIgnoringSpaces):
(WebCore::MidpointState::midpoints):
(WebCore::MidpointState::numMidpoints):
(WebCore::MidpointState::currentMidpoint):
(WebCore::MidpointState::incrementCurrentMidpoint):
(WebCore::MidpointState::decreaseNumMidpoints):
(WebCore::MidpointState::betweenMidpoints):
(WebCore::MidpointState::setBetweenMidpoints):
(WebCore::MidpointState::addMidpoint): Renamed from deprecatedAddMidpoint, since now
its private, we no longer need to discourage callers from using it.
* rendering/InlineIterator.h:
(WebCore::IsolateTracker::addFakeRunIfNecessary):
* rendering/RenderBlockLineLayout.cpp:
(WebCore::RenderBlockFlow::appendRunsForObject):
(WebCore::constructBidiRunsForLine):
* rendering/line/BreakingContextInlineHeaders.h:
(WebCore::checkMidpoints):
* rendering/line/TrailingObjects.cpp:
(WebCore::TrailingObjects::updateMidpointsForTrailingBoxes):
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@162472
268f45cc-cd09-0410-ab3c-
d52691b4dbfc
+2014-01-21 Zoltan Horvath <zoltan@webkit.org>
+
+ Since MidpointState is a class, it should behave like a class
+ https://bugs.webkit.org/show_bug.cgi?id=127154
+
+ Reviewed by David Hyatt.
+
+ I modified MidpointState to behave like a class, updated the call sites also.
+
+ No new tests, no behavior change.
+
+ * platform/text/BidiResolver.h:
+ (WebCore::MidpointState::reset):
+ (WebCore::MidpointState::startIgnoringSpaces):
+ (WebCore::MidpointState::stopIgnoringSpaces):
+ (WebCore::MidpointState::midpoints):
+ (WebCore::MidpointState::numMidpoints):
+ (WebCore::MidpointState::currentMidpoint):
+ (WebCore::MidpointState::incrementCurrentMidpoint):
+ (WebCore::MidpointState::decreaseNumMidpoints):
+ (WebCore::MidpointState::betweenMidpoints):
+ (WebCore::MidpointState::setBetweenMidpoints):
+ (WebCore::MidpointState::addMidpoint): Renamed from deprecatedAddMidpoint, since now
+ its private, we no longer need to discourage callers from using it.
+ * rendering/InlineIterator.h:
+ (WebCore::IsolateTracker::addFakeRunIfNecessary):
+ * rendering/RenderBlockLineLayout.cpp:
+ (WebCore::RenderBlockFlow::appendRunsForObject):
+ (WebCore::constructBidiRunsForLine):
+ * rendering/line/BreakingContextInlineHeaders.h:
+ (WebCore::checkMidpoints):
+ * rendering/line/TrailingObjects.cpp:
+ (WebCore::TrailingObjects::updateMidpointsForTrailingBoxes):
+
2014-01-21 Commit Queue <commit-queue@webkit.org>
Unreviewed, rolling out r162452.
void reset()
{
- numMidpoints = 0;
- currentMidpoint = 0;
- betweenMidpoints = false;
+ m_numMidpoints = 0;
+ m_currentMidpoint = 0;
+ m_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> midpoints;
- unsigned numMidpoints;
- unsigned currentMidpoint;
- bool betweenMidpoints;
-
void startIgnoringSpaces(const Iterator& midpoint)
{
- ASSERT(!(numMidpoints % 2));
- deprecatedAddMidpoint(midpoint);
+ ASSERT(!(m_numMidpoints % 2));
+ addMidpoint(midpoint);
}
void stopIgnoringSpaces(const Iterator& midpoint)
{
- ASSERT(numMidpoints % 2);
- deprecatedAddMidpoint(midpoint);
+ ASSERT(m_numMidpoints % 2);
+ addMidpoint(midpoint);
}
// When ignoring spaces, this needs to be called for objects that need line boxes such as RenderInlines or
stopIgnoringSpaces(midpoint);
startIgnoringSpaces(midpoint);
}
+
+ Vector<Iterator>& midpoints() { return m_midpoints; }
+ const unsigned& numMidpoints() const { return m_numMidpoints; }
+ const unsigned& currentMidpoint() const { return m_currentMidpoint; }
+ void incrementCurrentMidpoint() { ++m_currentMidpoint; }
+ void decreaseNumMidpoints() { --m_numMidpoints; }
+ const bool& betweenMidpoints() const { return m_betweenMidpoints; }
+ void setBetweenMidpoints(bool betweenMidpoint) { m_betweenMidpoints = betweenMidpoint; }
private:
- void deprecatedAddMidpoint(const Iterator& midpoint)
+ // 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;
+
+ void addMidpoint(const Iterator& midpoint)
{
- if (midpoints.size() <= numMidpoints)
- midpoints.grow(numMidpoints + 10);
+ if (m_midpoints.size() <= m_numMidpoints)
+ m_midpoints.grow(m_numMidpoints + 10);
- Iterator* midpointsIterator = midpoints.data();
- midpointsIterator[numMidpoints++] = midpoint;
+ Iterator* midpointsIterator = m_midpoints.data();
+ midpointsIterator[m_numMidpoints++] = midpoint;
}
};
// For now, if we enter an isolate between midpoints, we increment our current midpoint or else
// we'll leave the isolate and ignore the content that follows.
MidpointState<InlineIterator>& midpointState = resolver.midpointState();
- if (midpointState.betweenMidpoints && midpointState.midpoints[midpointState.currentMidpoint].renderer() == &obj) {
- midpointState.betweenMidpoints = false;
- ++midpointState.currentMidpoint;
+ if (midpointState.betweenMidpoints() && midpointState.midpoints()[midpointState.currentMidpoint()].renderer() == &obj) {
+ midpointState.setBetweenMidpoints(false);
+ midpointState.incrementCurrentMidpoint();
}
}
return;
LineMidpointState& lineMidpointState = resolver.midpointState();
- bool haveNextMidpoint = (lineMidpointState.currentMidpoint < lineMidpointState.numMidpoints);
+ bool haveNextMidpoint = (lineMidpointState.currentMidpoint() < lineMidpointState.numMidpoints());
InlineIterator nextMidpoint;
if (haveNextMidpoint)
- nextMidpoint = lineMidpointState.midpoints[lineMidpointState.currentMidpoint];
- if (lineMidpointState.betweenMidpoints) {
+ nextMidpoint = lineMidpointState.midpoints()[lineMidpointState.currentMidpoint()];
+ if (lineMidpointState.betweenMidpoints()) {
if (!(haveNextMidpoint && nextMidpoint.renderer() == obj))
return;
// This is a new start point. Stop ignoring objects and
// adjust our start.
- lineMidpointState.betweenMidpoints = false;
+ lineMidpointState.setBetweenMidpoints(false);
start = nextMidpoint.offset();
- lineMidpointState.currentMidpoint++;
+ lineMidpointState.incrementCurrentMidpoint();
if (start < end)
return appendRunsForObject(runs, start, end, obj, resolver);
} else {
// 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.offset() + 1) <= end) {
- lineMidpointState.betweenMidpoints = true;
- lineMidpointState.currentMidpoint++;
+ lineMidpointState.setBetweenMidpoints(true);
+ lineMidpointState.incrementCurrentMidpoint();
if (nextMidpoint.offset() != UINT_MAX) { // UINT_MAX means stop at the object and don't include any of it.
if (static_cast<int>(nextMidpoint.offset() + 1) > start)
runs.addRun(createRun(start, nextMidpoint.offset() + 1, obj, resolver));
segmentMarker->m_startsSegment = true;
bidiRuns.addRun(segmentMarker);
// Do not collapse midpoints between segments
- topResolver.midpointState().betweenMidpoints = false;
+ topResolver.midpointState().setBetweenMidpoints(false);
}
if (segmentStart == segmentEnd)
continue;
// 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.renderer() && lineMidpointState.numMidpoints && !(lineMidpointState.numMidpoints % 2)) {
- InlineIterator* midpoints = lineMidpointState.midpoints.data();
- InlineIterator& endpoint = midpoints[lineMidpointState.numMidpoints - 2];
- const InlineIterator& startpoint = midpoints[lineMidpointState.numMidpoints - 1];
+ if (lBreak.renderer() && 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.numMidpoints--;
+ lineMidpointState.decreaseNumMidpoints();
if (endpoint.renderer()->style().collapseWhiteSpace() && endpoint.renderer()->isText())
endpoint.setOffset(endpoint.offset() - 1);
}
// 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.numMidpoints % 2) {
+ if (lineMidpointState.numMidpoints() % 2) {
// Find the trailing space object's midpoint.
- int trailingSpaceMidpoint = lineMidpointState.numMidpoints - 1;
- for ( ; trailingSpaceMidpoint > 0 && lineMidpointState.midpoints[trailingSpaceMidpoint].renderer() != m_whitespace; --trailingSpaceMidpoint) { }
+ int trailingSpaceMidpoint = lineMidpointState.numMidpoints() - 1;
+ for ( ; trailingSpaceMidpoint > 0 && lineMidpointState.midpoints()[trailingSpaceMidpoint].renderer() != m_whitespace; --trailingSpaceMidpoint) { }
ASSERT(trailingSpaceMidpoint >= 0);
if (collapseFirstSpace == CollapseFirstSpace)
- lineMidpointState.midpoints[trailingSpaceMidpoint].setOffset(lineMidpointState.midpoints[trailingSpaceMidpoint].offset() -1);
+ lineMidpointState.midpoints()[trailingSpaceMidpoint].setOffset(lineMidpointState.midpoints()[trailingSpaceMidpoint].offset() -1);
// Now make sure every single trailingPositionedBox following the trailingSpaceMidpoint properly stops and starts
// ignoring spaces.
size_t currentMidpoint = trailingSpaceMidpoint + 1;
for (size_t i = 0; i < m_boxes.size(); ++i) {
- if (currentMidpoint >= lineMidpointState.numMidpoints) {
+ if (currentMidpoint >= lineMidpointState.numMidpoints()) {
// We don't have a midpoint for this box yet.
lineMidpointState.ensureLineBoxInsideIgnoredSpaces(m_boxes[i]);
} else {
- ASSERT(lineMidpointState.midpoints[currentMidpoint].renderer() == m_boxes[i]);
- ASSERT(lineMidpointState.midpoints[currentMidpoint + 1].renderer() == m_boxes[i]);
+ ASSERT(lineMidpointState.midpoints()[currentMidpoint].renderer() == m_boxes[i]);
+ ASSERT(lineMidpointState.midpoints()[currentMidpoint + 1].renderer() == m_boxes[i]);
}
currentMidpoint += 2;
}