Changeset 194775 in webkit


Ignore:
Timestamp:
Jan 8, 2016 12:05:08 PM (8 years ago)
Author:
Alan Bujtas
Message:

Hovering link on http://help.apple.com/appletv/#/ does not show text underline.
https://bugs.webkit.org/show_bug.cgi?id=152906
<rdar://problem/23339617>

Reviewed by Simon Fraser.

GraphicsContext::computeLineBoundsAndAntialiasingModeForText() always integral ceils the origin y position to offset underline text.
This additional visual overflow offset is not taken into account by visualOverflowForDecorations().
Unfortunately we can't compute the exact same offset value while collecting repaint rects, because
computeLineBoundsAndAntialiasingModeForText() uses CTM scaling before adjusting the offset position.
Use 1px (css) bottom offset to cover this underling overflow.

Source/WebCore:

Test: fast/css3-text/css3-text-decoration/text-underline-position/underline-visual-overflow-with-subpixel-position.html

  • platform/graphics/GraphicsContext.cpp:

(WebCore::GraphicsContext::computeLineBoundsAndAntialiasingModeForText):

  • rendering/SimpleLineLayoutResolver.cpp: Add visual overflow to simple line layout.

(WebCore::SimpleLineLayout::RunResolver::Run::rect):
(WebCore::SimpleLineLayout::RunResolver::RunResolver):

  • rendering/SimpleLineLayoutResolver.h:
  • style/InlineTextBoxStyle.cpp:

(WebCore::visualOverflowForDecorations):

LayoutTests:

  • fast/css3-text/css3-text-decoration/text-underline-position/underline-visual-overflow-with-subpixel-position-expected.txt: Added.
  • fast/css3-text/css3-text-decoration/text-underline-position/underline-visual-overflow-with-subpixel-position.html: Added.
Location:
trunk
Files:
2 added
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r194771 r194775  
     12016-01-08  Zalan Bujtas  <zalan@apple.com>
     2
     3        Hovering link on http://help.apple.com/appletv/#/ does not show text underline.
     4        https://bugs.webkit.org/show_bug.cgi?id=152906
     5        <rdar://problem/23339617>
     6
     7        Reviewed by Simon Fraser.
     8
     9        GraphicsContext::computeLineBoundsAndAntialiasingModeForText() always integral ceils the origin y position to offset underline text.
     10        This additional visual overflow offset is not taken into account by visualOverflowForDecorations().
     11        Unfortunately we can't compute the exact same offset value while collecting repaint rects, because
     12        computeLineBoundsAndAntialiasingModeForText() uses CTM scaling before adjusting the offset position.
     13        Use 1px (css) bottom offset to cover this underling overflow.
     14
     15        * fast/css3-text/css3-text-decoration/text-underline-position/underline-visual-overflow-with-subpixel-position-expected.txt: Added.
     16        * fast/css3-text/css3-text-decoration/text-underline-position/underline-visual-overflow-with-subpixel-position.html: Added.
     17
    1182016-01-08  Brady Eidson  <beidson@apple.com>
    219
  • trunk/Source/WebCore/ChangeLog

    r194771 r194775  
     12016-01-08  Zalan Bujtas  <zalan@apple.com>
     2
     3        Hovering link on http://help.apple.com/appletv/#/ does not show text underline.
     4        https://bugs.webkit.org/show_bug.cgi?id=152906
     5        <rdar://problem/23339617>
     6
     7        Reviewed by Simon Fraser.
     8
     9        GraphicsContext::computeLineBoundsAndAntialiasingModeForText() always integral ceils the origin y position to offset underline text.
     10        This additional visual overflow offset is not taken into account by visualOverflowForDecorations().
     11        Unfortunately we can't compute the exact same offset value while collecting repaint rects, because
     12        computeLineBoundsAndAntialiasingModeForText() uses CTM scaling before adjusting the offset position.
     13        Use 1px (css) bottom offset to cover this underling overflow.
     14
     15        Test: fast/css3-text/css3-text-decoration/text-underline-position/underline-visual-overflow-with-subpixel-position.html
     16
     17        * platform/graphics/GraphicsContext.cpp:
     18        (WebCore::GraphicsContext::computeLineBoundsAndAntialiasingModeForText):
     19        * rendering/SimpleLineLayoutResolver.cpp: Add visual overflow to simple line layout.
     20        (WebCore::SimpleLineLayout::RunResolver::Run::rect):
     21        (WebCore::SimpleLineLayout::RunResolver::RunResolver):
     22        * rendering/SimpleLineLayoutResolver.h:
     23        * style/InlineTextBoxStyle.cpp:
     24        (WebCore::visualOverflowForDecorations):
     25
    1262016-01-08  Brady Eidson  <beidson@apple.com>
    227
  • trunk/Source/WebCore/platform/graphics/GraphicsContext.cpp

    r194757 r194775  
    996996    FloatPoint origin = point;
    997997    float thickness = std::max(strokeThickness(), 0.5f);
    998 
    999     if (!printing) {
    1000         AffineTransform transform = getCTM(GraphicsContext::DefinitelyIncludeDeviceScale);
     998    if (printing)
     999        return FloatRect(origin, FloatSize(width, thickness));
     1000
     1001    AffineTransform transform = getCTM(GraphicsContext::DefinitelyIncludeDeviceScale);
     1002    // Just compute scale in x dimension, assuming x and y scales are equal.
     1003    float scale = transform.b() ? sqrtf(transform.a() * transform.a() + transform.b() * transform.b()) : transform.a();
     1004    if (scale < 1.0) {
    10011005        // This code always draws a line that is at least one-pixel line high,
    10021006        // which tends to visually overwhelm text at small scales. To counter this
    10031007        // effect, an alpha is applied to the underline color when text is at small scales.
    1004 
    1005         // Just compute scale in x dimension, assuming x and y scales are equal.
    1006         float scale = transform.b() ? sqrtf(transform.a() * transform.a() + transform.b() * transform.b()) : transform.a();
    1007         if (scale < 1.0) {
    1008             static const float minimumUnderlineAlpha = 0.4f;
    1009             float shade = scale > minimumUnderlineAlpha ? scale : minimumUnderlineAlpha;
    1010             int alpha = color.alpha() * shade;
    1011             color = Color(color.red(), color.green(), color.blue(), alpha);
    1012         }
    1013 
    1014         FloatPoint devicePoint = transform.mapPoint(point);
    1015         FloatPoint deviceOrigin = FloatPoint(roundf(devicePoint.x()), ceilf(devicePoint.y()));
    1016         if (auto inverse = transform.inverse())
    1017             origin = inverse.value().mapPoint(deviceOrigin);
    1018     }
    1019     return FloatRect(origin.x(), origin.y(), width, thickness);
    1020 }
    1021 
    1022 }
     1008        static const float minimumUnderlineAlpha = 0.4f;
     1009        float shade = scale > minimumUnderlineAlpha ? scale : minimumUnderlineAlpha;
     1010        int alpha = color.alpha() * shade;
     1011        color = Color(color.red(), color.green(), color.blue(), alpha);
     1012    }
     1013
     1014    FloatPoint devicePoint = transform.mapPoint(point);
     1015    // Visual overflow might occur here due to integral roundf/ceilf. visualOverflowForDecorations adjusts the overflow value for underline decoration.
     1016    FloatPoint deviceOrigin = FloatPoint(roundf(devicePoint.x()), ceilf(devicePoint.y()));
     1017    if (auto inverse = transform.inverse())
     1018        origin = inverse.value().mapPoint(deviceOrigin);
     1019    return FloatRect(origin, FloatSize(width, thickness));
     1020}
     1021
     1022}
  • trunk/Source/WebCore/rendering/SimpleLineLayoutResolver.cpp

    r189030 r194775  
    2727#include "SimpleLineLayoutResolver.h"
    2828
     29#include "InlineTextBoxStyle.h"
    2930#include "RenderBlockFlow.h"
    3031#include "RenderObject.h"
     
    5556    float baseline = computeBaselinePosition();
    5657    FloatPoint position = linePosition(run.logicalLeft, baseline - resolver.m_ascent);
    57     FloatSize size = lineSize(run.logicalLeft, run.logicalRight, resolver.m_ascent + resolver.m_descent);
     58    FloatSize size = lineSize(run.logicalLeft, run.logicalRight, resolver.m_ascent + resolver.m_descent + resolver.m_visualOverflowOffset);
    5859    bool moveLineBreakToBaseline = false;
    5960    if (run.start == run.end && m_iterator != resolver.begin() && m_iterator.inQuirksMode()) {
     
    119120    , m_ascent(flow.style().fontCascade().fontMetrics().ascent())
    120121    , m_descent(flow.style().fontCascade().fontMetrics().descent())
     122    , m_visualOverflowOffset(visualOverflowForDecorations(flow.style(), nullptr).bottom)
    121123    , m_inQuirksMode(flow.document().inQuirksMode())
    122124{
  • trunk/Source/WebCore/rendering/SimpleLineLayoutResolver.h

    r189030 r194775  
    124124    const float m_ascent;
    125125    const float m_descent;
     126    const float m_visualOverflowOffset;
    126127    const bool m_inQuirksMode;
    127128};
  • trunk/Source/WebCore/style/InlineTextBoxStyle.cpp

    r194447 r194775  
    124124    // These metrics must match where underlines get drawn.
    125125    if (decoration & TextDecorationUnderline) {
    126         float underlineOffset = computeUnderlineOffset(lineStyle.textUnderlinePosition(), lineStyle.fontMetrics(), inlineTextBox, strokeThickness);
     126        // Compensate for the integral ceiling in GraphicsContext::computeLineBoundsAndAntialiasingModeForText()
     127        int underlineOffset = 1;
     128        underlineOffset += computeUnderlineOffset(lineStyle.textUnderlinePosition(), lineStyle.fontMetrics(), inlineTextBox, strokeThickness);
    127129        if (decorationStyle == TextDecorationStyleWavy) {
    128130            extendIntToFloat(overflowResult.bottom, underlineOffset + wavyOffset + controlPointDistance + strokeThickness - height);
Note: See TracChangeset for help on using the changeset viewer.