Changeset 53839 in webkit


Ignore:
Timestamp:
Jan 25, 2010 10:00:47 PM (14 years ago)
Author:
mitz@apple.com
Message:

<rdar://problem/7573493> Error with line break inside ?&raquo; pair of characters.
https://bugs.webkit.org/show_bug.cgi?id=17475

Reviewed by Darin Adler.

WebCore:

Test: fast/text/line-break-after-question-mark.html

Instead of unconditionally allowing lines to break after a question mark, which was intended
to mimic Internet Explorer, apply the Unicode line breaking behavior after a question mark,
with one exception in the ASCII range to match IE, namely not allowing a line break between
a question mark and a vertical line.

  • rendering/break_lines.cpp:

(WebCore::shouldBreakAfter): Added a next character parameter. Changed to consult a table
for the question mark case in order to keep it fast and not require a text break iterator in
the ASCII case.
(WebCore::nextBreakablePosition): Pass the next character to shouldBreakAfter.

LayoutTests:

  • fast/text/line-break-after-question-mark-expected.txt: Added.
  • fast/text/line-break-after-question-mark.html: Added.
  • fast/text/script-tests/line-break-after-question-mark.js: Added.

():

  • platform/mac/tables/mozilla/bugs/bug6674-expected.checksum: Updated.
  • platform/mac/tables/mozilla/bugs/bug6674-expected.png: Updated.
  • platform/mac/tables/mozilla/bugs/bug6674-expected.txt: Updated.
Location:
trunk
Files:
3 added
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r53838 r53839  
     12010-01-25  Dan Bernstein  <mitz@apple.com>
     2
     3        Reviewed by Darin Adler.
     4
     5        <rdar://problem/7573493> Error with line break inside ?&raquo; pair of characters.
     6        https://bugs.webkit.org/show_bug.cgi?id=17475
     7
     8        * fast/text/line-break-after-question-mark-expected.txt: Added.
     9        * fast/text/line-break-after-question-mark.html: Added.
     10        * fast/text/script-tests/line-break-after-question-mark.js: Added.
     11        ():
     12        * platform/mac/tables/mozilla/bugs/bug6674-expected.checksum: Updated.
     13        * platform/mac/tables/mozilla/bugs/bug6674-expected.png: Updated.
     14        * platform/mac/tables/mozilla/bugs/bug6674-expected.txt: Updated.
     15
    1162010-01-25  Peter Kasting  <pkasting@google.com>
    217
  • trunk/LayoutTests/platform/mac/tables/mozilla/bugs/bug6674-expected.checksum

    r38297 r53839  
    1 3f34db6f20f905bc879d38c647d510d9
     122929675c6aaf2593671667a807689e9
  • trunk/LayoutTests/platform/mac/tables/mozilla/bugs/bug6674-expected.txt

    r30635 r53839  
    11layer at (0,0) size 800x600
    22  RenderView at (0,0) size 800x600
    3 layer at (0,0) size 800x160
    4   RenderBlock {HTML} at (0,0) size 800x160
    5     RenderBody {BODY} at (8,8) size 784x144
    6       RenderTable {TABLE} at (0,0) size 96x52 [border: (1px outset #808080)]
    7         RenderTableSection {TBODY} at (1,1) size 94x50
    8           RenderTableRow {TR} at (0,2) size 94x46
    9             RenderTableCell {TD} at (2,2) size 90x46 [border: (1px inset #808080)] [r=0 c=0 rs=1 cs=1]
    10               RenderBlock {DIV} at (2,2) size 86x42 [border: (3px dotted #00FF00)]
    11                 RenderText {#text} at (3,3) size 107x36
    12                   text run at (3,3) width 71: "Truncated?"
    13                   text run at (3,21) width 107: " It should not be!"
    14       RenderBlock {P} at (0,68) size 784x18
     3layer at (0,0) size 800x124
     4  RenderBlock {HTML} at (0,0) size 800x124
     5    RenderBody {BODY} at (8,8) size 784x108
     6      RenderTable {TABLE} at (0,0) size 96x34 [border: (1px outset #808080)]
     7        RenderTableSection {TBODY} at (1,1) size 94x32
     8          RenderTableRow {TR} at (0,2) size 94x28
     9            RenderTableCell {TD} at (2,2) size 90x28 [border: (1px inset #808080)] [r=0 c=0 rs=1 cs=1]
     10              RenderBlock {DIV} at (2,2) size 86x24 [border: (3px dotted #00FF00)]
     11                RenderText {#text} at (3,3) size 178x18
     12                  text run at (3,3) width 178: "Truncated? It should not be!"
     13      RenderBlock {P} at (0,50) size 784x18
    1514        RenderText {#text} at (0,0) size 738x18
    1615          text run at (0,0) width 463: "According to the rules of CSS, the text above should spill right out of the "
    1716          text run at (463,0) width 275: "table, as it does in the table-less case below:"
    18       RenderBlock {DIV} at (0,102) size 86x42 [border: (3px dotted #00FF00)]
    19         RenderText {#text} at (3,3) size 107x36
    20           text run at (3,3) width 71: "Truncated?"
    21           text run at (3,21) width 107: " It should not be!"
     17      RenderBlock {DIV} at (0,84) size 86x24 [border: (3px dotted #00FF00)]
     18        RenderText {#text} at (3,3) size 178x18
     19          text run at (3,3) width 178: "Truncated? It should not be!"
  • trunk/WebCore/ChangeLog

    r53838 r53839  
     12010-01-25  Dan Bernstein  <mitz@apple.com>
     2
     3        Reviewed by Darin Adler.
     4
     5        <rdar://problem/7573493> Error with line break inside ?&raquo; pair of characters.
     6        https://bugs.webkit.org/show_bug.cgi?id=17475
     7
     8        Test: fast/text/line-break-after-question-mark.html
     9
     10        Instead of unconditionally allowing lines to break after a question mark, which was intended
     11        to mimic Internet Explorer, apply the Unicode line breaking behavior after a question mark,
     12        with one exception in the ASCII range to match IE, namely not allowing a line break between
     13        a question mark and a vertical line.
     14
     15        * rendering/break_lines.cpp:
     16        (WebCore::shouldBreakAfter): Added a next character parameter. Changed to consult a table
     17        for the question mark case in order to keep it fast and not require a text break iterator in
     18        the ASCII case.
     19        (WebCore::nextBreakablePosition): Pass the next character to shouldBreakAfter.
     20
    1212010-01-25  Peter Kasting  <pkasting@google.com>
    222
  • trunk/WebCore/rendering/break_lines.cpp

    r42230 r53839  
    11/*
    2  * Copyright (C) 2005, 2007 Apple Inc. All rights reserved.
     2 * Copyright (C) 2005, 2007, 2010 Apple Inc. All rights reserved.
    33 *
    4  * This library is free software; you can redistribute it and/or
    5  * modify it under the terms of the GNU Library General Public
    6  * License as published by the Free Software Foundation; either
    7  * version 2 of the License, or (at your option) any later version.
     4 * Redistribution and use in source and binary forms, with or without
     5 * modification, are permitted provided that the following conditions
     6 * are met:
     7 * 1. Redistributions of source code must retain the above copyright
     8 *    notice, this list of conditions and the following disclaimer.
     9 * 2. Redistributions in binary form must reproduce the above copyright
     10 *    notice, this list of conditions and the following disclaimer in the
     11 *    documentation and/or other materials provided with the distribution.
    812 *
    9  * This library is distributed in the hope that it will be useful,
    10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
    11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    12  * Library General Public License for more details.
    13  *
    14  * You should have received a copy of the GNU Library General Public License
    15  * along with this library; see the file COPYING.LIB.  If not, write to
    16  * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
    17  * Boston, MA 02110-1301, USA.
    18  *
     13 * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
     14 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
     15 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
     16 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
     17 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
     18 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
     19 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
     20 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
     21 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
     22 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
     23 * THE POSSIBILITY OF SUCH DAMAGE.
    1924 */
    2025
     
    4550}
    4651
    47 static inline bool shouldBreakAfter(UChar ch)
     52// This differs from the Unicode algorithm only in that Unicode does not break
     53// between a question mark and a vertical line (U+007C).
     54static const unsigned char internetExplorerLineBreaksAfterQuestionMarkTable[0x80] = {
     55    1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, // \t
     56    1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
     57    1, 0, 0, 1, 1, 1, 1, 0, 1, 0, 1, 1, 0, 1, 0, 0, // ! " ' ) , . /
     58    1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 1, 1, 1, 0, // : ; ?
     59    1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
     60    1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, // ]
     61    1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
     62    1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1  // }
     63};
     64
     65static const size_t internetExplorerLineBreaksAfterQuestionMarkTableSize = sizeof(internetExplorerLineBreaksAfterQuestionMarkTable) / sizeof(*internetExplorerLineBreaksAfterQuestionMarkTable);
     66
     67static inline bool shouldBreakAfter(UChar ch, UChar nextCh)
    4868{
    49     // Match WinIE's breaking strategy, which is to always allow breaks after hyphens and question marks.
    50     // FIXME: it appears that IE behavior is more complex, see <http://bugs.webkit.org/show_bug.cgi?id=17475>.
    5169    switch (ch) {
     70        // For a question mark preceding a non-ASCII characters, defer to the Unicode algorithm by returning false.
     71        // For ASCII characters, use a lookup table for enhanced speed and for compatibility with Internet Explorer.
     72        case '?':
     73            return nextCh <= internetExplorerLineBreaksAfterQuestionMarkTableSize && internetExplorerLineBreaksAfterQuestionMarkTable[nextCh];
     74        // Internet Explorer always allows breaking after a hyphen.
    5275        case '-':
    53         case '?':
    5476        case softHyphen:
    5577        // FIXME: cases for ideographicComma and ideographicFullStop are a workaround for an issue in Unicode 5.0
     
    89111        UChar ch = str[i];
    90112
    91         if (isBreakableSpace(ch, treatNoBreakSpaceAsBreak) || shouldBreakAfter(lastCh))
     113        if (isBreakableSpace(ch, treatNoBreakSpaceAsBreak) || shouldBreakAfter(lastCh, ch))
    92114            return i;
    93115
Note: See TracChangeset for help on using the changeset viewer.