Changeset 128317 in webkit


Ignore:
Timestamp:
Sep 12, 2012 8:47:37 AM (12 years ago)
Author:
commit-queue@webkit.org
Message:

Text Autosizing: Don't autosize text in constrained height elements.
https://bugs.webkit.org/show_bug.cgi?id=96143

Patch by John Mellor <johnme@chromium.org> on 2012-09-12
Reviewed by Julien Chaffraix.

Source/WebCore:

Autosizing text within constained height elements usually goes badly,
as the autosized text will wrap onto more lines, hence it will become
taller and often overflow its container, breaking the page's layout.

This patch disables autosizing for blocks with a fixed height ancestor
(or which are fixed height themselves), unless the lowest such ancestor
(or one of the ancestors in between it and the text block) has
overflow-y:auto/scroll, in which case the height isn't really fixed.

Tests: fast/text-autosizing/constrained-and-overflow-auto-ancestor.html

fast/text-autosizing/constrained-and-overflow-hidden-ancestor.html
fast/text-autosizing/constrained-and-overflow-paged-x-ancestor.html
fast/text-autosizing/constrained-and-overflow-scroll-ancestor.html
fast/text-autosizing/constrained-height-ancestor.html
fast/text-autosizing/constrained-maxheight-ancestor.html
fast/text-autosizing/constrained-maxheight.html
fast/text-autosizing/constrained-percent-maxheight.html
fast/text-autosizing/constrained-percent-of-viewport-maxheight.html
fast/text-autosizing/constrained-then-overflow-ancestors.html
fast/text-autosizing/constrained-then-overflow-then-positioned-ancestors.html
fast/text-autosizing/constrained-then-position-absolute-ancestors.html
fast/text-autosizing/constrained-then-position-fixed-ancestors.html
fast/text-autosizing/constrained-within-overflow-ancestor.html

  • rendering/TextAutosizer.cpp:

(WebCore::TextAutosizer::processBox):

Skips boxes for which contentHeightIsConstrained returns true.

(WebCore::TextAutosizer::contentHeightIsConstrained):

Walks up the render tree until it finds either a constrained height
or overflow-y:auto/scroll ancestor.

LayoutTests:

Added tests with various kinds, orders and nestings of constrained
height, overflow-y and positioned elements.

  • fast/text-autosizing/constrained-and-overflow-auto-ancestor-expected.html: Added.
  • fast/text-autosizing/constrained-and-overflow-auto-ancestor.html: Added.
  • fast/text-autosizing/constrained-and-overflow-hidden-ancestor-expected.html: Added.
  • fast/text-autosizing/constrained-and-overflow-hidden-ancestor.html: Added.
  • fast/text-autosizing/constrained-and-overflow-paged-x-ancestor-expected.html: Added.
  • fast/text-autosizing/constrained-and-overflow-paged-x-ancestor.html: Added.
  • fast/text-autosizing/constrained-and-overflow-scroll-ancestor-expected.html: Added.
  • fast/text-autosizing/constrained-and-overflow-scroll-ancestor.html: Added.
  • fast/text-autosizing/constrained-height-ancestor-expected.html: Added.
  • fast/text-autosizing/constrained-height-ancestor.html: Added.
  • fast/text-autosizing/constrained-maxheight-ancestor-expected.html: Added.
  • fast/text-autosizing/constrained-maxheight-ancestor.html: Added.
  • fast/text-autosizing/constrained-maxheight-expected.html: Added.
  • fast/text-autosizing/constrained-maxheight.html: Added.
  • fast/text-autosizing/constrained-percent-maxheight-expected.html: Added.
  • fast/text-autosizing/constrained-percent-maxheight.html: Added.
  • fast/text-autosizing/constrained-percent-of-viewport-maxheight-expected.html: Added.
  • fast/text-autosizing/constrained-percent-of-viewport-maxheight.html: Added.
  • fast/text-autosizing/constrained-then-overflow-ancestors-expected.html: Added.
  • fast/text-autosizing/constrained-then-overflow-ancestors.html: Added.
  • fast/text-autosizing/constrained-then-overflow-then-positioned-ancestors-expected.html: Added.
  • fast/text-autosizing/constrained-then-overflow-then-positioned-ancestors.html: Added.
  • fast/text-autosizing/constrained-then-position-absolute-ancestors-expected.html: Added.
  • fast/text-autosizing/constrained-then-position-absolute-ancestors.html: Added.
  • fast/text-autosizing/constrained-then-position-fixed-ancestors-expected.html: Added.
  • fast/text-autosizing/constrained-then-position-fixed-ancestors.html: Added.
  • fast/text-autosizing/constrained-within-overflow-ancestor-expected.html: Added.
  • fast/text-autosizing/constrained-within-overflow-ancestor.html: Added.
Location:
trunk
Files:
28 added
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r128314 r128317  
     12012-09-12  John Mellor  <johnme@chromium.org>
     2
     3        Text Autosizing: Don't autosize text in constrained height elements.
     4        https://bugs.webkit.org/show_bug.cgi?id=96143
     5
     6        Reviewed by Julien Chaffraix.
     7
     8        Added tests with various kinds, orders and nestings of constrained
     9        height, overflow-y and positioned elements.
     10
     11        * fast/text-autosizing/constrained-and-overflow-auto-ancestor-expected.html: Added.
     12        * fast/text-autosizing/constrained-and-overflow-auto-ancestor.html: Added.
     13        * fast/text-autosizing/constrained-and-overflow-hidden-ancestor-expected.html: Added.
     14        * fast/text-autosizing/constrained-and-overflow-hidden-ancestor.html: Added.
     15        * fast/text-autosizing/constrained-and-overflow-paged-x-ancestor-expected.html: Added.
     16        * fast/text-autosizing/constrained-and-overflow-paged-x-ancestor.html: Added.
     17        * fast/text-autosizing/constrained-and-overflow-scroll-ancestor-expected.html: Added.
     18        * fast/text-autosizing/constrained-and-overflow-scroll-ancestor.html: Added.
     19        * fast/text-autosizing/constrained-height-ancestor-expected.html: Added.
     20        * fast/text-autosizing/constrained-height-ancestor.html: Added.
     21        * fast/text-autosizing/constrained-maxheight-ancestor-expected.html: Added.
     22        * fast/text-autosizing/constrained-maxheight-ancestor.html: Added.
     23        * fast/text-autosizing/constrained-maxheight-expected.html: Added.
     24        * fast/text-autosizing/constrained-maxheight.html: Added.
     25        * fast/text-autosizing/constrained-percent-maxheight-expected.html: Added.
     26        * fast/text-autosizing/constrained-percent-maxheight.html: Added.
     27        * fast/text-autosizing/constrained-percent-of-viewport-maxheight-expected.html: Added.
     28        * fast/text-autosizing/constrained-percent-of-viewport-maxheight.html: Added.
     29        * fast/text-autosizing/constrained-then-overflow-ancestors-expected.html: Added.
     30        * fast/text-autosizing/constrained-then-overflow-ancestors.html: Added.
     31        * fast/text-autosizing/constrained-then-overflow-then-positioned-ancestors-expected.html: Added.
     32        * fast/text-autosizing/constrained-then-overflow-then-positioned-ancestors.html: Added.
     33        * fast/text-autosizing/constrained-then-position-absolute-ancestors-expected.html: Added.
     34        * fast/text-autosizing/constrained-then-position-absolute-ancestors.html: Added.
     35        * fast/text-autosizing/constrained-then-position-fixed-ancestors-expected.html: Added.
     36        * fast/text-autosizing/constrained-then-position-fixed-ancestors.html: Added.
     37        * fast/text-autosizing/constrained-within-overflow-ancestor-expected.html: Added.
     38        * fast/text-autosizing/constrained-within-overflow-ancestor.html: Added.
     39
    1402012-09-12  Adam Klein  <adamk@chromium.org>
    241
  • trunk/Source/WebCore/ChangeLog

    r128316 r128317  
     12012-09-12  John Mellor  <johnme@chromium.org>
     2
     3        Text Autosizing: Don't autosize text in constrained height elements.
     4        https://bugs.webkit.org/show_bug.cgi?id=96143
     5
     6        Reviewed by Julien Chaffraix.
     7
     8        Autosizing text within constained height elements usually goes badly,
     9        as the autosized text will wrap onto more lines, hence it will become
     10        taller and often overflow its container, breaking the page's layout.
     11
     12        This patch disables autosizing for blocks with a fixed height ancestor
     13        (or which are fixed height themselves), unless the lowest such ancestor
     14        (or one of the ancestors in between it and the text block) has
     15        overflow-y:auto/scroll, in which case the height isn't really fixed.
     16
     17        Tests: fast/text-autosizing/constrained-and-overflow-auto-ancestor.html
     18               fast/text-autosizing/constrained-and-overflow-hidden-ancestor.html
     19               fast/text-autosizing/constrained-and-overflow-paged-x-ancestor.html
     20               fast/text-autosizing/constrained-and-overflow-scroll-ancestor.html
     21               fast/text-autosizing/constrained-height-ancestor.html
     22               fast/text-autosizing/constrained-maxheight-ancestor.html
     23               fast/text-autosizing/constrained-maxheight.html
     24               fast/text-autosizing/constrained-percent-maxheight.html
     25               fast/text-autosizing/constrained-percent-of-viewport-maxheight.html
     26               fast/text-autosizing/constrained-then-overflow-ancestors.html
     27               fast/text-autosizing/constrained-then-overflow-then-positioned-ancestors.html
     28               fast/text-autosizing/constrained-then-position-absolute-ancestors.html
     29               fast/text-autosizing/constrained-then-position-fixed-ancestors.html
     30               fast/text-autosizing/constrained-within-overflow-ancestor.html
     31
     32        * rendering/TextAutosizer.cpp:
     33        (WebCore::TextAutosizer::processBox):
     34
     35            Skips boxes for which contentHeightIsConstrained returns true.
     36
     37        (WebCore::TextAutosizer::contentHeightIsConstrained):
     38
     39            Walks up the render tree until it finds either a constrained height
     40            or overflow-y:auto/scroll ancestor.
     41
    1422012-09-12  Mark Pilgrim  <pilgrim@chromium.org>
    243
  • trunk/Source/WebCore/rendering/TextAutosizer.cpp

    r126438 r128317  
    7878}
    7979
     80static bool contentHeightIsConstrained(const RenderBox* box)
     81{
     82    // FIXME: Propagate constrainedness down the tree, to avoid inefficiently walking back up from each box.
     83    // FIXME: This code needs to take into account vertical writing modes.
     84    // FIXME: Consider additional heuristics, such as ignoring fixed heights if the content is already overflowing before autosizing kicks in.
     85    for (const RenderBox* container = box; container; container = container->containingBlock()) {
     86        RenderStyle* style = container->style();
     87        if (style->overflowY() >= OSCROLL)
     88            return false;
     89        if (style->height().isSpecified() || style->maxHeight().isSpecified())
     90            return true;
     91    }
     92    return false;
     93}
     94
    8095void TextAutosizer::processBox(RenderBox* box, const IntSize& windowSize, const IntSize& layoutSize)
    8196{
     97    if (contentHeightIsConstrained(box))
     98        return;
     99
    82100    int logicalWindowWidth = box->isHorizontalWritingMode() ? windowSize.width() : windowSize.height();
    83101    int logicalLayoutWidth = box->isHorizontalWritingMode() ? layoutSize.width() : layoutSize.height();
Note: See TracChangeset for help on using the changeset viewer.