Changeset 109267 in webkit


Ignore:
Timestamp:
Feb 29, 2012 2:44:33 PM (12 years ago)
Author:
hyatt@apple.com
Message:

Source/WebCore: https://bugs.webkit.org/show_bug.cgi?id=79940
<rdar://problem/10080189>

Add support in WebKit for an intra-line character grid for Japanese text layout.

Patch logicalLeftOffsetForLine and logicalRightOffsetForLine in order to get the
basic edge snapping grid functionality up and running. See all the FIXMEs in the function for
some of the issues that still have to be dealt with for it to really work well.

Reviewed by Dan Bernstein.

Added new tests in fast/line-grid.

  • rendering/RenderBlock.cpp:

(WebCore::RenderBlock::logicalLeftOffsetForLine):
(WebCore::RenderBlock::logicalRightOffsetForLine):

LayoutTests: https://bugs.webkit.org/show_bug.cgi?id=79940
<rdar://problem/10080189>

Add support in WebKit for an intra-line character grid for Japanese text layout.

New tests for basic left and right alignment of lines in the presence of
floating and positioned objects as well as objects with margins and borders.

Reviewed by Dan Bernstein.

  • fast/line-grid/line-align-left-edges.html: Added.
  • fast/line-grid/line-align-right-edges.html: Added.
  • platform/mac/fast/line-grid/line-align-left-edges-expected.png: Added.
  • platform/mac/fast/line-grid/line-align-left-edges-expected.txt: Added.
  • platform/mac/fast/line-grid/line-align-right-edges-expected.png: Added.
  • platform/mac/fast/line-grid/line-align-right-edges-expected.txt: Added.
Location:
trunk
Files:
6 added
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r109262 r109267  
     12012-02-29  David Hyatt  <hyatt@apple.com>
     2
     3        https://bugs.webkit.org/show_bug.cgi?id=79940
     4        <rdar://problem/10080189>
     5       
     6        Add support in WebKit for an intra-line character grid for Japanese text layout.
     7       
     8        New tests for basic left and right alignment of lines in the presence of
     9        floating and positioned objects as well as objects with margins and borders.
     10
     11        Reviewed by Dan Bernstein.
     12
     13        * fast/line-grid/line-align-left-edges.html: Added.
     14        * fast/line-grid/line-align-right-edges.html: Added.
     15        * platform/mac/fast/line-grid/line-align-left-edges-expected.png: Added.
     16        * platform/mac/fast/line-grid/line-align-left-edges-expected.txt: Added.
     17        * platform/mac/fast/line-grid/line-align-right-edges-expected.png: Added.
     18        * platform/mac/fast/line-grid/line-align-right-edges-expected.txt: Added.
     19
    1202012-02-29  Adam Klein  <adamk@chromium.org>
    221
  • trunk/Source/WebCore/ChangeLog

    r109265 r109267  
     12012-02-29  David Hyatt  <hyatt@apple.com>
     2
     3        https://bugs.webkit.org/show_bug.cgi?id=79940
     4        <rdar://problem/10080189>
     5       
     6        Add support in WebKit for an intra-line character grid for Japanese text layout.
     7       
     8        Patch logicalLeftOffsetForLine and logicalRightOffsetForLine in order to get the
     9        basic edge snapping grid functionality up and running. See all the FIXMEs in the function for
     10        some of the issues that still have to be dealt with for it to really work well.
     11
     12        Reviewed by Dan Bernstein.
     13
     14        Added new tests in fast/line-grid.
     15
     16        * rendering/RenderBlock.cpp:
     17        (WebCore::RenderBlock::logicalLeftOffsetForLine):
     18        (WebCore::RenderBlock::logicalRightOffsetForLine):
     19
    1202012-02-29  Anders Carlsson  <andersca@apple.com>
    221
  • trunk/Source/WebCore/rendering/RenderBlock.cpp

    r109142 r109267  
    38673867        left += textIndentOffset();
    38683868
     3869    if (style()->lineAlign() == LineAlignNone)
     3870        return left;
     3871   
     3872    // Push in our left offset so that it is aligned with the character grid.
     3873    LayoutState* layoutState = view()->layoutState();
     3874    if (!layoutState)
     3875        return left;
     3876
     3877    RenderBlock* lineGrid = layoutState->lineGrid();
     3878    if (!lineGrid || lineGrid->style()->writingMode() != style()->writingMode())
     3879        return left;
     3880
     3881    // FIXME: Should letter-spacing apply? This is complicated since it doesn't apply at the edge?
     3882    float maxCharWidth = lineGrid->style()->font().primaryFont()->maxCharWidth();
     3883    if (!maxCharWidth)
     3884        return left;
     3885
     3886    LayoutUnit lineGridOffset = lineGrid->isHorizontalWritingMode() ? layoutState->lineGridOffset().width(): layoutState->lineGridOffset().height();
     3887    LayoutUnit layoutOffset = lineGrid->isHorizontalWritingMode() ? layoutState->layoutOffset().width() : layoutState->layoutOffset().height();
     3888   
     3889    // Push in to the nearest character width (truncated so that we pixel snap left).
     3890    // FIXME: Should be patched when subpixel layout lands, since this calculation doesn't have to pixel snap
     3891    // any more (https://bugs.webkit.org/show_bug.cgi?id=79946).
     3892    // FIXME: This is wrong for RTL (https://bugs.webkit.org/show_bug.cgi?id=79945).
     3893    // FIXME: This doesn't work with columns or regions (https://bugs.webkit.org/show_bug.cgi?id=79942).
     3894    // FIXME: This doesn't work when the inline position of the object isn't set ahead of time.
     3895    // FIXME: Dynamic changes to the font or to the inline position need to result in a deep relayout.
     3896    // (https://bugs.webkit.org/show_bug.cgi?id=79944)
     3897    float remainder = fmodf(maxCharWidth - fmodf(left + layoutOffset - lineGridOffset, maxCharWidth), maxCharWidth);
     3898    left += remainder;
    38693899    return left;
    38703900}
     
    38863916        right -= textIndentOffset();
    38873917   
     3918    if (style()->lineAlign() == LineAlignNone)
     3919        return right;
     3920   
     3921    // Push in our right offset so that it is aligned with the character grid.
     3922    LayoutState* layoutState = view()->layoutState();
     3923    if (!layoutState)
     3924        return right;
     3925
     3926    RenderBlock* lineGrid = layoutState->lineGrid();
     3927    if (!lineGrid || lineGrid->style()->writingMode() != style()->writingMode())
     3928        return right;
     3929
     3930    // FIXME: Should letter-spacing apply? This is complicated since it doesn't apply at the edge?
     3931    float maxCharWidth = lineGrid->style()->font().primaryFont()->maxCharWidth();
     3932    if (!maxCharWidth)
     3933        return right;
     3934
     3935    LayoutUnit lineGridOffset = lineGrid->isHorizontalWritingMode() ? layoutState->lineGridOffset().width(): layoutState->lineGridOffset().height();
     3936    LayoutUnit layoutOffset = lineGrid->isHorizontalWritingMode() ? layoutState->layoutOffset().width() : layoutState->layoutOffset().height();
     3937   
     3938    // Push in to the nearest character width (truncated so that we pixel snap right).
     3939    // FIXME: Should be patched when subpixel layout lands, since this calculation doesn't have to pixel snap
     3940    // any more (https://bugs.webkit.org/show_bug.cgi?id=79946).
     3941    // FIXME: This is wrong for RTL (https://bugs.webkit.org/show_bug.cgi?id=79945).
     3942    // FIXME: This doesn't work with columns or regions (https://bugs.webkit.org/show_bug.cgi?id=79942).
     3943    // FIXME: This doesn't work when the inline position of the object isn't set ahead of time.
     3944    // FIXME: Dynamic changes to the font or to the inline position need to result in a deep relayout.
     3945    // (https://bugs.webkit.org/show_bug.cgi?id=79944)
     3946    float remainder = fmodf(fmodf(right + layoutOffset - lineGridOffset, maxCharWidth), maxCharWidth);
     3947    right -= ceilf(remainder);
    38883948    return right;
    38893949}
Note: See TracChangeset for help on using the changeset viewer.