Commit cbdae682 authored by antti@apple.com's avatar antti@apple.com

Text on simple lines sometimes paints one pixel off

https://bugs.webkit.org/show_bug.cgi?id=124200

Reviewed by Andreas Kling.

Source/WebCore: 

Test: fast/text/line-runs-simple-lines.html

* rendering/SimpleLineLayout.cpp:
(WebCore::SimpleLineLayout::adjustRunOffsets):
        
    Don't round on run construction time.

(WebCore::SimpleLineLayout::createTextRuns):
* rendering/SimpleLineLayoutResolver.h:
(WebCore::SimpleLineLayout::RunResolver::Run::rect):
        
    Instead round when generating rects.

(WebCore::SimpleLineLayout::RunResolver::Run::baseline):
        
    Provide the baseline (used by painting) as unrounded FloatPoint.

LayoutTests: 

* fast/text/line-runs-rounding-simple-lines-expected.html: Added.
* fast/text/line-runs-rounding-simple-lines.html: Added.



git-svn-id: http://svn.webkit.org/repository/webkit/trunk@159105 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent e5720746
2013-11-12 Antti Koivisto <antti@apple.com>
Text on simple lines sometimes paints one pixel off
https://bugs.webkit.org/show_bug.cgi?id=124200
Reviewed by Andreas Kling.
* fast/text/line-runs-rounding-simple-lines-expected.html: Added.
* fast/text/line-runs-rounding-simple-lines.html: Added.
2013-11-12 Zan Dobersek <zdobersek@igalia.com>
JSC bindings generator should generate deletable JSC functions
......
<script>
if (window.internals)
internals.settings.setSimpleLineLayoutEnabled(false);
</script>
<style>
div { font-size: 11px; font-family: '.LucidaGrandeUI'; }
</style>
<div>Lorem ipsum dolor</div>
<div>Lorem ipsum dolor</div>
<style>
div { font-size: 11px; font-family: '.LucidaGrandeUI'; }
</style>
<div>Lorem ipsum dolor</div>
<div>Lorem ipsum dolor</div>
2013-11-12 Antti Koivisto <antti@apple.com>
Text on simple lines sometimes paints one pixel off
https://bugs.webkit.org/show_bug.cgi?id=124200
Reviewed by Andreas Kling.
Test: fast/text/line-runs-simple-lines.html
* rendering/SimpleLineLayout.cpp:
(WebCore::SimpleLineLayout::adjustRunOffsets):
Don't round on run construction time.
(WebCore::SimpleLineLayout::createTextRuns):
* rendering/SimpleLineLayoutResolver.h:
(WebCore::SimpleLineLayout::RunResolver::Run::rect):
Instead round when generating rects.
(WebCore::SimpleLineLayout::RunResolver::Run::baseline):
Provide the baseline (used by painting) as unrounded FloatPoint.
2013-11-11 Andreas Kling <akling@apple.com>
Elements with class names automatically get unique ElementData.
......
......@@ -260,12 +260,13 @@ static float computeLineLeft(ETextAlign textAlign, float remainingWidth)
return 0;
}
static void adjustRunOffsets(Vector<Run, 4>& lineRuns, ETextAlign textAlign, float lineWidth, float availableWidth)
static void adjustRunOffsets(Vector<Run, 4>& lineRuns, float adjustment)
{
float lineLeft = computeLineLeft(textAlign, availableWidth - lineWidth);
if (!adjustment)
return;
for (unsigned i = 0; i < lineRuns.size(); ++i) {
lineRuns[i].left = floor(lineLeft + lineRuns[i].left);
lineRuns[i].right = ceil(lineLeft + lineRuns[i].right);
lineRuns[i].left += adjustment;
lineRuns[i].right += adjustment;
}
}
......@@ -381,7 +382,8 @@ void createTextRuns(Layout::RunVector& runs, unsigned& lineCount, RenderBlockFlo
lineRuns.last().isEndOfLine = true;
adjustRunOffsets(lineRuns, textAlign, lineWidth.committedWidth(), lineWidth.availableWidth());
float lineLeft = computeLineLeft(textAlign, lineWidth.availableWidth() - lineWidth.committedWidth());
adjustRunOffsets(lineRuns, lineLeft);
for (unsigned i = 0; i < lineRuns.size(); ++i)
runs.append(lineRuns[i]);
......
......@@ -45,7 +45,7 @@ public:
explicit Run(const Iterator&);
LayoutRect rect() const;
LayoutPoint baseline() const;
FloatPoint baseline() const;
String text() const;
unsigned lineIndex() const;
......@@ -130,18 +130,18 @@ inline LayoutRect RunResolver::Run::rect() const
auto& resolver = m_iterator.resolver();
auto& run = m_iterator.simpleRun();
LayoutPoint linePosition(run.left, resolver.m_lineHeight * m_iterator.lineIndex() + resolver.m_baseline - resolver.m_ascent);
LayoutSize lineSize(run.right - run.left, resolver.m_ascent + resolver.m_descent);
LayoutPoint linePosition(floor(run.left), resolver.m_lineHeight * m_iterator.lineIndex() + resolver.m_baseline - resolver.m_ascent);
LayoutSize lineSize(ceil(run.right) - floor(run.left), resolver.m_ascent + resolver.m_descent);
return LayoutRect(linePosition + resolver.m_contentOffset, lineSize);
}
inline LayoutPoint RunResolver::Run::baseline() const
inline FloatPoint RunResolver::Run::baseline() const
{
auto& resolver = m_iterator.resolver();
auto& run = m_iterator.simpleRun();
float baselineY = resolver.m_lineHeight * m_iterator.lineIndex() + resolver.m_baseline;
return LayoutPoint(run.left, baselineY) + resolver.m_contentOffset;
return FloatPoint(run.left, baselineY) + resolver.m_contentOffset;
}
inline String RunResolver::Run::text() const
......
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