Changeset 159192 in webkit


Ignore:
Timestamp:
Nov 13, 2013 5:25:32 AM (10 years ago)
Author:
Antti Koivisto
Message:

Support overflow-wrap:break-word on simple line path
https://bugs.webkit.org/show_bug.cgi?id=124206

Source/WebCore:

Reviewed by Andreas Kling.

Pure text documents are rendered with break-word. It is also common in discussion board type sites.

This also makes many <textarea>'s rendered using the simple line path.

Tests: fast/forms/basic-textareas-quirks-simple-lines.html

fast/forms/linebox-overflow-in-textarea-padding-simple-lines.html
fast/forms/negativeLineHeight-simple-lines.html
fast/forms/textAreaLineHeight-simple-lines.html

  • rendering/RenderBlock.cpp:

(WebCore::RenderBlock::updateShapeInsideInfoAfterStyleChange):
(WebCore::RenderBlock::markShapeInsideDescendantsForLayout):

Invalidate the cached line layout mode on shape-inside style change.

  • rendering/SimpleLineLayout.cpp:

(WebCore::SimpleLineLayout::canUseForText):
(WebCore::SimpleLineLayout::canUseFor):
(WebCore::SimpleLineLayout::createTextRuns):

LayoutTests:

Reviewed by Andreas Kling.

Force these to use line boxes, add ref test versions comparing the paths.

  • fast/forms/basic-textareas-quirks-simple-lines-expected.html: Added.
  • fast/forms/basic-textareas-quirks-simple-lines.html: Added.
  • fast/forms/basic-textareas-quirks.html:
  • fast/forms/linebox-overflow-in-textarea-padding-simple-lines-expected.html: Added.
  • fast/forms/linebox-overflow-in-textarea-padding-simple-lines.html: Added.
  • fast/forms/linebox-overflow-in-textarea-padding.html:
  • fast/forms/negativeLineHeight-simple-lines-expected.html: Added.
  • fast/forms/negativeLineHeight-simple-lines.html: Added.
  • fast/forms/negativeLineHeight.html:
  • fast/forms/textAreaLineHeight-simple-lines-expected.html: Added.
  • fast/forms/textAreaLineHeight-simple-lines.html: Added.
  • fast/forms/textAreaLineHeight.html:
  • fast/parser/entity-comment-in-textarea.html: Made this independent of line layout mode.
  • fast/replaced/width100percent-textarea.html:
  • platform/mac/fast/parser/entity-comment-in-textarea-expected.txt:
Location:
trunk
Files:
8 added
12 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r159183 r159192  
     12013-11-12  Antti Koivisto  <antti@apple.com>
     2
     3        Support overflow-wrap:break-word on simple line path
     4        https://bugs.webkit.org/show_bug.cgi?id=124206
     5
     6        Reviewed by Andreas Kling.
     7       
     8        Force these to use line boxes, add ref test versions comparing the paths.
     9
     10        * fast/forms/basic-textareas-quirks-simple-lines-expected.html: Added.
     11        * fast/forms/basic-textareas-quirks-simple-lines.html: Added.
     12        * fast/forms/basic-textareas-quirks.html:
     13        * fast/forms/linebox-overflow-in-textarea-padding-simple-lines-expected.html: Added.
     14        * fast/forms/linebox-overflow-in-textarea-padding-simple-lines.html: Added.
     15        * fast/forms/linebox-overflow-in-textarea-padding.html:
     16        * fast/forms/negativeLineHeight-simple-lines-expected.html: Added.
     17        * fast/forms/negativeLineHeight-simple-lines.html: Added.
     18        * fast/forms/negativeLineHeight.html:
     19        * fast/forms/textAreaLineHeight-simple-lines-expected.html: Added.
     20        * fast/forms/textAreaLineHeight-simple-lines.html: Added.
     21        * fast/forms/textAreaLineHeight.html:
     22        * fast/parser/entity-comment-in-textarea.html: Made this independent of line layout mode.
     23        * fast/replaced/width100percent-textarea.html:
     24        * platform/mac/fast/parser/entity-comment-in-textarea-expected.txt:
     25
    1262013-11-13  Thiago de Barros Lacerda  <thiago.lacerda@openbossa.org>
    227
  • trunk/LayoutTests/fast/forms/basic-textareas-quirks.html

    r52502 r159192  
     1<script>
     2if (window.internals)
     3    internals.settings.setSimpleLineLayoutEnabled(false);
     4</script>
    15<html><head><style>
    26div {
  • trunk/LayoutTests/fast/forms/linebox-overflow-in-textarea-padding.html

    r41690 r159192  
     1<script>
     2if (window.internals)
     3    internals.settings.setSimpleLineLayoutEnabled(false);
     4</script>
    15<style>
    26textarea, #foo {
  • trunk/LayoutTests/fast/forms/negativeLineHeight.html

    r11995 r159192  
    11<html lang="en">
    22<head>
     3<script>
     4if (window.internals)
     5    internals.settings.setSimpleLineLayoutEnabled(false);
     6</script>
    37        <style type="text/css">
    48                .p {                   
  • trunk/LayoutTests/fast/forms/textAreaLineHeight.html

    r11995 r159192  
    33<html lang="en">
    44<head>
     5<script>
     6if (window.internals)
     7    internals.settings.setSimpleLineLayoutEnabled(false);
     8</script>
    59        <meta http-equiv="content-type" content="text/html; charset=utf-8">
    610        <title>StyledTA</title>
  • trunk/LayoutTests/fast/parser/entity-comment-in-textarea.html

    r34831 r159192  
    22<body>
    33<textarea>
    4 &lt;!-- </textarea> --&gt;
     4&lt;!--</textarea> --&gt;
    55This should be outside the textarea.
    66</textarea>
  • trunk/LayoutTests/fast/replaced/width100percent-textarea.html

    r124410 r159192  
    77<body>
    88<script>
     9if (window.internals)
     10    internals.settings.setSimpleLineLayoutEnabled(false);
    911if (window.testRunner)
    1012    testRunner.display();
  • trunk/LayoutTests/platform/mac-mountainlion/fast/parser/entity-comment-in-textarea-expected.txt

    r158029 r159192  
    99  RenderTextControl {TEXTAREA} at (2,2) size 161x32 [bgcolor=#FFFFFF] [border: (1px solid #000000)]
    1010    RenderBlock {DIV} at (3,3) size 155x13
    11       RenderText {#text} at (0,0) size 29x13
     11      RenderText {#text} at (0,0) size 25x13
    1212        text run at (0,0) width 25: "<!--"
    13         text run at (24,0) width 5: " "
  • trunk/LayoutTests/platform/mac/fast/parser/entity-comment-in-textarea-expected.txt

    r158029 r159192  
    99  RenderTextControl {TEXTAREA} at (2,2) size 161x32 [bgcolor=#FFFFFF] [border: (1px solid #000000)]
    1010    RenderBlock {DIV} at (3,3) size 155x13
    11       RenderText {#text} at (0,0) size 29x13
     11      RenderText {#text} at (0,0) size 26x13
    1212        text run at (0,0) width 26: "<!--"
    13         text run at (25,0) width 4: " "
  • trunk/Source/WebCore/ChangeLog

    r159191 r159192  
     12013-11-12  Antti Koivisto  <antti@apple.com>
     2
     3        Support overflow-wrap:break-word on simple line path
     4        https://bugs.webkit.org/show_bug.cgi?id=124206
     5
     6        Reviewed by Andreas Kling.
     7
     8        Pure text documents are rendered with break-word. It is also common in discussion board type sites.
     9       
     10        This also makes many <textarea>'s rendered using the simple line path.
     11
     12        Tests: fast/forms/basic-textareas-quirks-simple-lines.html
     13               fast/forms/linebox-overflow-in-textarea-padding-simple-lines.html
     14               fast/forms/negativeLineHeight-simple-lines.html
     15               fast/forms/textAreaLineHeight-simple-lines.html
     16
     17        * rendering/RenderBlock.cpp:
     18        (WebCore::RenderBlock::updateShapeInsideInfoAfterStyleChange):
     19        (WebCore::RenderBlock::markShapeInsideDescendantsForLayout):
     20       
     21            Invalidate the cached line layout mode on shape-inside style change.
     22
     23        * rendering/SimpleLineLayout.cpp:
     24        (WebCore::SimpleLineLayout::canUseForText):
     25        (WebCore::SimpleLineLayout::canUseFor):
     26        (WebCore::SimpleLineLayout::createTextRuns):
     27
    1282013-11-13  Andreas Kling  <akling@apple.com>
    229
  • trunk/Source/WebCore/rendering/RenderBlock.cpp

    r159154 r159192  
    14201420        ShapeInsideInfo* shapeInsideInfo = ensureShapeInsideInfo();
    14211421        shapeInsideInfo->dirtyShapeSize();
    1422     } else {
     1422    } else
    14231423        setShapeInsideInfo(nullptr);
    1424         markShapeInsideDescendantsForLayout();
    1425     }
     1424    markShapeInsideDescendantsForLayout();
    14261425}
    14271426
     
    14531452    if (childrenInline()) {
    14541453        setNeedsLayout();
     1454        invalidateLineLayoutPath();
    14551455        return;
    14561456    }
  • trunk/Source/WebCore/rendering/SimpleLineLayout.cpp

    r159105 r159192  
    3030#include "Frame.h"
    3131#include "GraphicsContext.h"
     32#include "HTMLTextFormControlElement.h"
    3233#include "HitTestLocation.h"
    3334#include "HitTestRequest.h"
     
    3940#include "RenderStyle.h"
    4041#include "RenderText.h"
     42#include "RenderTextControl.h"
    4143#include "RenderView.h"
    4244#include "Settings.h"
     
    5355static bool canUseForText(const CharacterType* text, unsigned length, const SimpleFontData& fontData)
    5456{
     57    // FIXME: <textarea maxlength=0> generates empty text node.
     58    if (!length)
     59        return false;
    5560    for (unsigned i = 0; i < length; ++i) {
    5661        UChar character = text[i];
     
    114119    if (flow.parent()->isDeprecatedFlexibleBox())
    115120        return false;
     121    // FIXME: Implementation of wrap=hard looks into lineboxes.
     122    if (flow.parent()->isTextArea() && flow.parent()->element()->fastHasAttribute(HTMLNames::wrapAttr))
     123        return false;
     124    // FIXME: Placeholders do something strange.
     125    if (flow.parent()->isTextControl() && toRenderTextControl(*flow.parent()).textFormControlElement().placeholderElement())
     126        return false;
    116127    // These tests only works during layout. Outside layout this function may give false positives.
    117128    if (flow.view().layoutState()) {
     
    166177        return false;
    167178    if (style.hasTextCombine())
    168         return false;
    169     if (style.overflowWrap() != NormalOverflowWrap)
    170179        return false;
    171180    if (style.backgroundClip() == TextFillBox)
     
    283292    bool preserveNewline = style.preserveNewline();
    284293    bool wrapLines = style.autoWrap();
     294    bool breakWordOnOverflow = style.overflowWrap() == BreakOverflowWrap && (wrapLines || preserveNewline);
    285295
    286296    const CharacterType* text = textRenderer.text()->getCharacters<CharacterType>();
     
    363373            }
    364374
     375            if (!lineWidth.fitsOnLine() && breakWordOnOverflow) {
     376                // Backtrack and start measuring character-by-character.
     377                lineWidth.addUncommittedWidth(-lineWidth.uncommittedWidth());
     378                unsigned splitEnd = wordStart;
     379                for (; splitEnd < wordEnd; ++splitEnd) {
     380                    float charWidth = textWidth(textRenderer, text, textLength, splitEnd, splitEnd + 1, 0, font, tabWidth);
     381                    lineWidth.addUncommittedWidth(charWidth);
     382                    if (!lineWidth.fitsOnLine() && splitEnd > lineStart)
     383                        break;
     384                    lineWidth.commit();
     385                }
     386                lineRuns.last().end = splitEnd;
     387                lineRuns.last().right = lineWidth.committedWidth();
     388                lineEnd = splitEnd;
     389                // To match line boxes, set single-space-only line width to zero.
     390                if (text[lineRuns.last().start] == ' ' && lineRuns.last().start + 1 == lineRuns.last().end)
     391                    lineRuns.last().right = lineRuns.last().left;
     392                break;
     393            }
     394
    365395            lineWidth.commit();
    366396
     
    372402                wordEnd = skipWhitespaces(text, wordEnd, textLength, preserveNewline);
    373403
    374             if (wrapLines && !lineWidth.fitsOnLine()) {
     404            if (!lineWidth.fitsOnLine() && wrapLines) {
    375405                // The first run on the line overflows.
    376406                ASSERT(lineRuns.size() == 1);
Note: See TracChangeset for help on using the changeset viewer.