Changeset 120017 in webkit


Ignore:
Timestamp:
Jun 11, 2012 4:14:38 PM (12 years ago)
Author:
jchaffraix@webkit.org
Message:

Account for margin after when laying out <legend> element
https://bugs.webkit.org/show_bug.cgi?id=35981

Reviewed by Abhishek Arya.

Source/WebCore:

Tests: fast/forms/legend-after-margin-horizontal-writing-mode.html

fast/forms/legend-after-margin-vertical-writing-mode.html
fast/forms/legend-after-margin-with-before-border-horizontal-mode.html
fast/forms/legend-small-after-margin-before-border-horizontal-mode.html

The existing code would ignore margin after when layouting out the <legend>. This
change only adds the code to handle the margin after, the margin before is still
ignored as it's not obvious how it should be working.

  • rendering/RenderFieldset.cpp:

(WebCore::RenderFieldset::layoutSpecialExcludedChild):
Split the code in 2 code paths to reflect how we position and size. Those are covered by the
tests above.

LayoutTests:

  • fast/forms/legend-after-margin-horizontal-writing-mode-expected.html: Added.
  • fast/forms/legend-after-margin-horizontal-writing-mode.html: Added.
  • fast/forms/legend-after-margin-vertical-writing-mode-expected.html: Added.
  • fast/forms/legend-after-margin-vertical-writing-mode.html: Added.
  • fast/forms/legend-after-margin-with-before-border-horizontal-mode-expected.html: Added.
  • fast/forms/legend-after-margin-with-before-border-horizontal-mode.html: Added.
  • fast/forms/legend-small-after-margin-before-border-horizontal-mode-expected.html: Added.
  • fast/forms/legend-small-after-margin-before-border-horizontal-mode.html: Added.
Location:
trunk
Files:
8 added
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r120013 r120017  
     12012-06-11  Julien Chaffraix  <jchaffraix@webkit.org>
     2
     3        Account for margin after when laying out <legend> element
     4        https://bugs.webkit.org/show_bug.cgi?id=35981
     5
     6        Reviewed by Abhishek Arya.
     7
     8        * fast/forms/legend-after-margin-horizontal-writing-mode-expected.html: Added.
     9        * fast/forms/legend-after-margin-horizontal-writing-mode.html: Added.
     10        * fast/forms/legend-after-margin-vertical-writing-mode-expected.html: Added.
     11        * fast/forms/legend-after-margin-vertical-writing-mode.html: Added.
     12        * fast/forms/legend-after-margin-with-before-border-horizontal-mode-expected.html: Added.
     13        * fast/forms/legend-after-margin-with-before-border-horizontal-mode.html: Added.
     14        * fast/forms/legend-small-after-margin-before-border-horizontal-mode-expected.html: Added.
     15        * fast/forms/legend-small-after-margin-before-border-horizontal-mode.html: Added.
     16
    1172012-06-05  Eric Uhrhane <ericu@chromium.org>
    218
  • trunk/Source/WebCore/ChangeLog

    r120016 r120017  
     12012-06-11  Julien Chaffraix  <jchaffraix@webkit.org>
     2
     3        Account for margin after when laying out <legend> element
     4        https://bugs.webkit.org/show_bug.cgi?id=35981
     5
     6        Reviewed by Abhishek Arya.
     7
     8        Tests: fast/forms/legend-after-margin-horizontal-writing-mode.html
     9               fast/forms/legend-after-margin-vertical-writing-mode.html
     10               fast/forms/legend-after-margin-with-before-border-horizontal-mode.html
     11               fast/forms/legend-small-after-margin-before-border-horizontal-mode.html
     12
     13        The existing code would ignore margin after when layouting out the <legend>. This
     14        change only adds the code to handle the margin after, the margin before is still
     15        ignored as it's not obvious how it should be working.
     16
     17        * rendering/RenderFieldset.cpp:
     18        (WebCore::RenderFieldset::layoutSpecialExcludedChild):
     19        Split the code in 2 code paths to reflect how we position and size. Those are covered by the
     20        tests above.
     21
    1222012-06-11  James Robinson  <jamesr@chromium.org>
    223
  • trunk/Source/WebCore/rendering/RenderFieldset.cpp

    r113665 r120017  
    102102        setLogicalLeftForChild(legend, logicalLeft);
    103103
    104         LayoutUnit b = borderBefore();
    105         LayoutUnit h = logicalHeightForChild(legend);
    106         setLogicalTopForChild(legend, max<LayoutUnit>((b - h) / 2, 0));
    107         setLogicalHeight(max(b, h) + paddingBefore());
     104        LayoutUnit fieldsetBorderBefore = borderBefore();
     105        LayoutUnit legendLogicalHeight = logicalHeightForChild(legend);
     106
     107        LayoutUnit legendLogicalTop;
     108        LayoutUnit collapsedLegendExtent;
     109        // FIXME: We need to account for the legend's margin before too.
     110        if (fieldsetBorderBefore > legendLogicalHeight) {
     111            // The <legend> is smaller than the associated fieldset before border
     112            // so the latter determines positioning of the <legend>. The sizing depends
     113            // on the legend's margins as we want to still follow the author's cues.
     114            // Firefox completely ignores the margins in this case which seems wrong.
     115            legendLogicalTop = (fieldsetBorderBefore - legendLogicalHeight) / 2;
     116            collapsedLegendExtent = max<LayoutUnit>(fieldsetBorderBefore, legendLogicalTop + legendLogicalHeight + marginAfterForChild(legend));
     117        } else
     118            collapsedLegendExtent = legendLogicalHeight + marginAfterForChild(legend);
     119
     120        setLogicalTopForChild(legend, legendLogicalTop);
     121        setLogicalHeight(paddingBefore() + collapsedLegendExtent);
    108122    }
    109123    return legend;
Note: See TracChangeset for help on using the changeset viewer.