Changeset 82144 in webkit


Ignore:
Timestamp:
Mar 28, 2011 12:44:19 PM (13 years ago)
Author:
hyatt@apple.com
Message:

https://bugs.webkit.org/show_bug.cgi?id=57221, memory corruption/crashes when positioned objects
occur at the end of a line.

Reviewed by Simon Fraser and Darin Adler.

The old code and new code for dealing with a trailing space object midpoint manipulated a raw
array instead of the Vector. Otherwise this corruption would have been caught prior to check-in.

I have patched the code to only go through the Vector and to make it handle the case that led to
the corruption. Trailing positioned objects can occur both prior to and following the trailing space
object's midpoint, so we have to be prepared to deal with both cases.

This is already tested by fast/block/positioning/052.html, and that test now properly progresses
like the other positioning tests did.

Source/WebCore:

  • rendering/RenderBlockLineLayout.cpp:

(WebCore::RenderBlock::findNextLineBreak):

LayoutTests:

  • platform/mac/fast/block/positioning/052-expected.txt:
Location:
trunk
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r82135 r82144  
     12011-03-28  David Hyatt  <hyatt@apple.com>
     2
     3        Reviewed by Simon Fraser and Darin Adler.
     4
     5        https://bugs.webkit.org/show_bug.cgi?id=57221, memory corruption/crashes when positioned objects
     6        occur at the end of a line.
     7       
     8        The old code and new code for dealing with a trailing space object midpoint manipulated a raw
     9        array instead of the Vector. Otherwise this corruption would have been caught prior to check-in.
     10       
     11        I have patched the code to only go through the Vector and to make it handle the case that led to
     12        the corruption. Trailing positioned objects can occur both prior to and following the trailing space
     13        object's midpoint, so we have to be prepared to deal with both cases.
     14       
     15        This is already tested by fast/block/positioning/052.html, and that test now properly progresses
     16        like the other positioning tests did.
     17
     18        * platform/mac/fast/block/positioning/052-expected.txt:
     19
    1202011-03-28  Sergio Villar Senin  <svillar@igalia.com>
    221
  • trunk/LayoutTests/platform/mac/fast/block/positioning/052-expected.txt

    r25970 r82144  
    66      RenderBlock {DIV} at (0,0) size 784x18
    77        RenderText {#text} at (0,0) size 0x0
    8 layer at (108,8) size 39x18
    9   RenderInline (relative positioned) {SPAN} at (0,0) size 39x18
    10     RenderText {#text} at (0,0) size 39x18
    11       text run at (0,0) width 39: "Hello "
     8layer at (108,8) size 35x18
     9  RenderInline (relative positioned) {SPAN} at (0,0) size 35x18
     10    RenderText {#text} at (0,0) size 35x18
     11      text run at (0,0) width 35: "Hello"
    1212layer at (158,58) size 35x18
    1313  RenderBlock (positioned) {DIV} at (50,50) size 35x18 [color=#FFFFFF] [bgcolor=#008000]
  • trunk/Source/WebCore/ChangeLog

    r82138 r82144  
     12011-03-28  David Hyatt  <hyatt@apple.com>
     2
     3        Reviewed by Simon Fraser and Darin Adler.
     4
     5        https://bugs.webkit.org/show_bug.cgi?id=57221, memory corruption/crashes when positioned objects
     6        occur at the end of a line.
     7       
     8        The old code and new code for dealing with a trailing space object midpoint manipulated a raw
     9        array instead of the Vector. Otherwise this corruption would have been caught prior to check-in.
     10       
     11        I have patched the code to only go through the Vector and to make it handle the case that led to
     12        the corruption. Trailing positioned objects can occur both prior to and following the trailing space
     13        object's midpoint, so we have to be prepared to deal with both cases.
     14       
     15        This is already tested by fast/block/positioning/052.html, and that test now properly progresses
     16        like the other positioning tests did.
     17
     18        * rendering/RenderBlockLineLayout.cpp:
     19        (WebCore::RenderBlock::findNextLineBreak):
     20
    1212011-03-28  Andrei Popescu  <andreip@google.com>
    222
  • trunk/Source/WebCore/rendering/RenderBlockLineLayout.cpp

    r82105 r82144  
    16391639                // then start ignoring spaces again.
    16401640                if (isInlineType || o->container()->isRenderInline()) {
    1641                     ignoreStart.obj = o;
    1642                     ignoreStart.pos = 0;
    16431641                    if (ignoringSpaces) {
     1642                        ignoreStart.obj = o;
     1643                        ignoreStart.pos = 0;
    16441644                        addMidpoint(lineMidpointState, ignoreStart); // Stop ignoring spaces.
    16451645                        addMidpoint(lineMidpointState, ignoreStart); // Start ignoring again.
     
    21182118        // exclude the space, allowing it to - in effect - collapse into the newline.
    21192119        if (lineMidpointState.numMidpoints % 2) {
    2120             InlineIterator* midpoints = lineMidpointState.midpoints.data();
    2121             midpoints[lineMidpointState.numMidpoints - trailingPositionedBoxes.size() * 2 - 1].pos--;
     2120            // Find the trailing space object's midpoint.
     2121            int trailingSpaceMidpoint = lineMidpointState.numMidpoints - 1;
     2122            for ( ; trailingSpaceMidpoint >= 0 && lineMidpointState.midpoints[trailingSpaceMidpoint].obj != trailingSpaceObject; --trailingSpaceMidpoint) { }
     2123            ASSERT(trailingSpaceMidpoint >= 0);
     2124            lineMidpointState.midpoints[trailingSpaceMidpoint].pos--;
     2125
     2126            // Now make sure every single trailingPositionedBox following the trailingSpaceMidpoint properly stops and starts
     2127            // ignoring spaces.
     2128            size_t currentMidpoint = trailingSpaceMidpoint + 1;
     2129            for (size_t i = 0; i < trailingPositionedBoxes.size(); ++i) {
     2130                if (currentMidpoint >= lineMidpointState.numMidpoints) {
     2131                    // We don't have a midpoint for this box yet.
     2132                    InlineIterator ignoreStart(this, trailingPositionedBoxes[i], 0);
     2133                    addMidpoint(lineMidpointState, ignoreStart); // Stop ignoring.
     2134                    addMidpoint(lineMidpointState, ignoreStart); // Start ignoring again.
     2135                } else {
     2136                    ASSERT(lineMidpointState.midpoints[currentMidpoint].obj == trailingPositionedBoxes[i]);
     2137                    ASSERT(lineMidpointState.midpoints[currentMidpoint + 1].obj == trailingPositionedBoxes[i]);
     2138                }
     2139                currentMidpoint += 2;
     2140            }
    21222141        } else if (!lBreak.obj && trailingSpaceObject->isText()) {
    21232142            // Add a new end midpoint that stops right at the very end.
Note: See TracChangeset for help on using the changeset viewer.