Skip to content

Commit

Permalink
Use left/right instead of left/width for simple text runs
Browse files Browse the repository at this point in the history
https://bugs.webkit.org/show_bug.cgi?id=123465

Reviewed by Andreas Kling.

This simplifies the code a bit.

* rendering/SimpleLineLayout.cpp:
(WebCore::SimpleLineLayout::adjustRunOffsets):
(WebCore::SimpleLineLayout::create):
* rendering/SimpleLineLayout.h:
(WebCore::SimpleLineLayout::Run::Run):
* rendering/SimpleLineLayoutResolver.h:
(WebCore::SimpleLineLayout::RunResolver::Run::rect):



Canonical link: https://commits.webkit.org/141594@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@158225 268f45cc-cd09-0410-ab3c-d52691b4dbfc
  • Loading branch information
anttijk committed Oct 29, 2013
1 parent 0466da4 commit 07f341e
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 11 deletions.
17 changes: 17 additions & 0 deletions Source/WebCore/ChangeLog
@@ -1,3 +1,20 @@
2013-10-29 Antti Koivisto <antti@apple.com>

Use left/right instead of left/width for simple text runs
https://bugs.webkit.org/show_bug.cgi?id=123465

Reviewed by Andreas Kling.

This simplifies the code a bit.

* rendering/SimpleLineLayout.cpp:
(WebCore::SimpleLineLayout::adjustRunOffsets):
(WebCore::SimpleLineLayout::create):
* rendering/SimpleLineLayout.h:
(WebCore::SimpleLineLayout::Run::Run):
* rendering/SimpleLineLayoutResolver.h:
(WebCore::SimpleLineLayout::RunResolver::Run::rect):

2013-10-29 Tim Horton <timothy_horton@apple.com>

Try fixing the Mac build (though I have no idea why
Expand Down
13 changes: 5 additions & 8 deletions Source/WebCore/rendering/SimpleLineLayout.cpp
Expand Up @@ -227,10 +227,8 @@ static void adjustRunOffsets(Vector<Run, 4>& lineRuns, ETextAlign textAlign, flo
{
float lineLeft = computeLineLeft(textAlign, availableWidth - lineWidth);
for (unsigned i = 0; i < lineRuns.size(); ++i) {
float adjustedLeft = floor(lineLeft + lineRuns[i].left);
float adjustedRight = ceil(lineLeft + lineRuns[i].left + lineRuns[i].width);
lineRuns[i].left = adjustedLeft;
lineRuns[i].width = adjustedRight - adjustedLeft;
lineRuns[i].left = floor(lineLeft + lineRuns[i].left);
lineRuns[i].right = ceil(lineLeft + lineRuns[i].right);
}
}

Expand Down Expand Up @@ -293,15 +291,14 @@ std::unique_ptr<Layout> create(RenderBlockFlow& flow)
ASSERT(previousWasSpaceBetweenWords);
// Include space to the end of the previous run.
lineRuns.last().textLength++;
lineRuns.last().width += wordTrailingSpaceWidth;
lineRuns.last().right += wordTrailingSpaceWidth;
// Start a new run on the same line.
float previousRight = lineRuns.last().left + lineRuns.last().width;
lineRuns.append(Run(wordStartOffset + 1, previousRight));
lineRuns.append(Run(wordStartOffset + 1, lineRuns.last().right));
}

lineWidth.commit();

lineRuns.last().width = lineWidth.committedWidth() - lineRuns.last().left;
lineRuns.last().right = lineWidth.committedWidth();
lineRuns.last().textLength = wordEndOffset - lineRuns.last().textOffset;

lineEndOffset = wordEndOffset;
Expand Down
4 changes: 2 additions & 2 deletions Source/WebCore/rendering/SimpleLineLayout.h
Expand Up @@ -48,14 +48,14 @@ struct Run {
, textLength(0)
, isEndOfLine(false)
, left(left)
, width(0)
, right(left)
{ }

unsigned textOffset;
unsigned textLength : 31;
unsigned isEndOfLine : 1;
float left;
float width;
float right;
};

struct Layout {
Expand Down
2 changes: 1 addition & 1 deletion Source/WebCore/rendering/SimpleLineLayoutResolver.h
Expand Up @@ -131,7 +131,7 @@ inline LayoutRect RunResolver::Run::rect() const
auto& run = m_iterator.simpleRun();

LayoutPoint linePosition(run.left, resolver.m_lineHeight * m_iterator.lineIndex() + resolver.m_baseline - resolver.m_ascent);
LayoutSize lineSize(run.width, resolver.m_ascent + resolver.m_descent);
LayoutSize lineSize(run.right - run.left, resolver.m_ascent + resolver.m_descent);
return LayoutRect(linePosition + resolver.m_contentOffset, lineSize);
}

Expand Down

0 comments on commit 07f341e

Please sign in to comment.