Changeset 114079 in webkit


Ignore:
Timestamp:
Apr 12, 2012 9:19:42 PM (12 years ago)
Author:
leviw@chromium.org
Message:

Prepare functions in LengthFunctions.h for LayoutUnits
https://bugs.webkit.org/show_bug.cgi?id=83726

Reviewed by Eric Seidel.

Preparing the functions that live in LengthFunctions for sub-pixel layout, which entails
using and returning LayoutUnits instead of integers. There are a number of rendering
classes that are laid out using integers -- see https://trac.webkit.org/wiki/LayoutUnit
for details -- so this also adds integer-specific versions of the length functions for
explicit use in those classes.

No new tests. No change in behavior.

  • css/LengthFunctions.h:

(WebCore): Using LayoutUnits for sub-pixel precision and adding integer-specific versions
of minimumValueForLength and valueForLength that truncate.

  • css/LengthFunctions.cpp:

(WebCore):

  • dom/Document.cpp:

(WebCore::Document::pageSizeAndMarginsInPixels): Document sizes are integral.

  • rendering/RenderFrameSet.cpp:

(WebCore::RenderFrameSet::layOutAxis): The frame tree continues to be integral.

  • rendering/RenderMarquee.cpp:

(WebCore::RenderMarquee::timerFired): RenderMarquee scrolling uses integral values.

  • rendering/RenderTableSection.cpp:

(WebCore::RenderTableSection::calcRowLogicalHeight): Table layout is integral.

Location:
trunk/Source/WebCore
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r114078 r114079  
     12012-04-12  Levi Weintraub  <leviw@chromium.org>
     2
     3        Prepare functions in LengthFunctions.h for LayoutUnits
     4        https://bugs.webkit.org/show_bug.cgi?id=83726
     5
     6        Reviewed by Eric Seidel.
     7
     8        Preparing the functions that live in LengthFunctions for sub-pixel layout, which entails
     9        using and returning LayoutUnits instead of integers. There are a number of rendering
     10        classes that are laid out using integers -- see https://trac.webkit.org/wiki/LayoutUnit
     11        for details -- so this also adds integer-specific versions of the length functions for
     12        explicit use in those classes.
     13
     14        No new tests. No change in behavior.
     15
     16        * css/LengthFunctions.h:
     17        (WebCore): Using LayoutUnits for sub-pixel precision and adding integer-specific versions
     18        of minimumValueForLength and valueForLength that truncate.
     19        * css/LengthFunctions.cpp:
     20        (WebCore):
     21        * dom/Document.cpp:
     22        (WebCore::Document::pageSizeAndMarginsInPixels): Document sizes are integral.
     23        * rendering/RenderFrameSet.cpp:
     24        (WebCore::RenderFrameSet::layOutAxis): The frame tree continues to be integral.
     25        * rendering/RenderMarquee.cpp:
     26        (WebCore::RenderMarquee::timerFired): RenderMarquee scrolling uses integral values.
     27        * rendering/RenderTableSection.cpp:
     28        (WebCore::RenderTableSection::calcRowLogicalHeight): Table layout is integral.
     29
    1302012-04-12  Sheriff Bot  <webkit.review.bot@gmail.com>
    231
  • trunk/Source/WebCore/css/LengthFunctions.cpp

    r113824 r114079  
    3030namespace WebCore {
    3131
    32 int minimumValueForLength(const Length& length, int maximumValue, RenderView* renderView, bool roundPercentages)
     32int minimumIntValueForLength(const Length& length, LayoutUnit maximumValue, RenderView* renderView, bool roundPercentages)
     33{
     34    return static_cast<int>(minimumValueForLength(length, maximumValue, renderView, roundPercentages));
     35}
     36
     37int intValueForLength(const Length& length, LayoutUnit maximumValue, RenderView* renderView, bool roundPercentages)
     38{
     39    return static_cast<int>(valueForLength(length, maximumValue, renderView, roundPercentages));
     40}
     41
     42LayoutUnit minimumValueForLength(const Length& length, LayoutUnit maximumValue, RenderView* renderView, bool roundPercentages)
    3343{
    3444    switch (length.type()) {
     
    3747    case Percent:
    3848        if (roundPercentages)
    39             return static_cast<int>(round(maximumValue * length.percent() / 100.0f));
     49            return static_cast<LayoutUnit>(round(maximumValue * length.percent() / 100.0f));
    4050        // Don't remove the extra cast to float. It is needed for rounding on 32-bit Intel machines that use the FPU stack.
    41         return static_cast<int>(static_cast<float>(maximumValue * length.percent() / 100.0f));
     51        return static_cast<LayoutUnit>(static_cast<float>(maximumValue * length.percent() / 100.0f));
    4252    case Calculated:
    4353        return length.nonNanCalculatedValue(maximumValue);
    4454    case ViewportPercentageWidth:
    4555        if (renderView)
    46             return static_cast<int>(renderView->viewportSize().width() * length.viewportPercentageLength() / 100.0f);
    47         return 0;
     56            return static_cast<LayoutUnit>(renderView->viewportSize().width() * length.viewportPercentageLength() / 100.0f);
     57        return ZERO_LAYOUT_UNIT;
    4858    case ViewportPercentageHeight:
    4959        if (renderView)
    50             return static_cast<int>(renderView->viewportSize().height() * length.viewportPercentageLength() / 100.0f);
    51         return 0;
     60            return static_cast<LayoutUnit>(renderView->viewportSize().height() * length.viewportPercentageLength() / 100.0f);
     61        return ZERO_LAYOUT_UNIT;
    5262    case ViewportPercentageMin:
    5363        if (renderView) {
    5464            IntSize viewportSize = renderView->viewportSize();
    55             return static_cast<int>(std::min(viewportSize.width(), viewportSize.height()) * length.viewportPercentageLength() / 100.0f);
     65            return static_cast<LayoutUnit>(std::min(viewportSize.width(), viewportSize.height()) * length.viewportPercentageLength() / 100.0f);
    5666        }
    57         return 0;
     67        return ZERO_LAYOUT_UNIT;
    5868    case Auto:
    59         return 0;
     69        return ZERO_LAYOUT_UNIT;
    6070    case Relative:
    6171    case Intrinsic:
     
    6373    case Undefined:
    6474        ASSERT_NOT_REACHED();
    65         return 0;
     75        return ZERO_LAYOUT_UNIT;
    6676    }
    6777    ASSERT_NOT_REACHED();
    68     return 0;
     78    return ZERO_LAYOUT_UNIT;
    6979}
    7080
    71 int valueForLength(const Length& length, int maximumValue, RenderView* renderView, bool roundPercentages)
     81LayoutUnit valueForLength(const Length& length, LayoutUnit maximumValue, RenderView* renderView, bool roundPercentages)
    7282{
    7383    switch (length.type()) {
     
    8494    case Relative:
    8595        ASSERT_NOT_REACHED();
    86         return 0;
     96        return ZERO_LAYOUT_UNIT;
    8797    case Intrinsic:
    8898        ASSERT_NOT_REACHED();
    89         return 0;
     99        return ZERO_LAYOUT_UNIT;
    90100    case MinIntrinsic:
    91101        ASSERT_NOT_REACHED();
    92         return 0;
     102        return ZERO_LAYOUT_UNIT;
    93103    case Undefined:
    94104        ASSERT_NOT_REACHED();
    95         return 0;
     105        return ZERO_LAYOUT_UNIT;
    96106    }
    97107    ASSERT_NOT_REACHED();
    98     return 0;
     108    return ZERO_LAYOUT_UNIT;
    99109}
    100110
    101111// FIXME: when subpixel layout is supported this copy of floatValueForLength() can be removed. See bug 71143.
    102 float floatValueForLength(const Length& length, int maximumValue, RenderView* renderView)
     112float floatValueForLength(const Length& length, LayoutUnit maximumValue, RenderView* renderView)
    103113{
    104114    switch (length.type()) {
  • trunk/Source/WebCore/css/LengthFunctions.h

    r112472 r114079  
    2525#define LengthFunctions_h
    2626
     27#include "LayoutTypes.h"
     28
    2729namespace WebCore {
    2830
     
    3032struct Length;
    3133
    32 int minimumValueForLength(const Length&, int maximumValue, RenderView* = 0, bool roundPercentages = false);
    33 int valueForLength(const Length&, int maximumValue, RenderView* = 0, bool roundPercentages = false);
    34 float floatValueForLength(const Length&, int maximumValue, RenderView* = 0);
     34int minimumIntValueForLength(const Length&, LayoutUnit maximumValue, RenderView* = 0, bool roundPercentages = false);
     35int intValueForLength(const Length&, LayoutUnit maximumValue, RenderView* = 0, bool roundPercentages = false);
     36LayoutUnit minimumValueForLength(const Length&, LayoutUnit maximumValue, RenderView* = 0, bool roundPercentages = false);
     37LayoutUnit valueForLength(const Length&, LayoutUnit maximumValue, RenderView* = 0, bool roundPercentages = false);
     38float floatValueForLength(const Length&, LayoutUnit maximumValue, RenderView* = 0);
    3539float floatValueForLength(const Length&, float maximumValue, RenderView* = 0);
    3640
  • trunk/Source/WebCore/dom/Document.cpp

    r114059 r114079  
    18511851    // The percentage is calculated with respect to the width even for margin top and bottom.
    18521852    // http://www.w3.org/TR/CSS2/box.html#margin-properties
    1853     marginTop = style->marginTop().isAuto() ? marginTop : valueForLength(style->marginTop(), width, view);
    1854     marginRight = style->marginRight().isAuto() ? marginRight : valueForLength(style->marginRight(), width, view);
    1855     marginBottom = style->marginBottom().isAuto() ? marginBottom : valueForLength(style->marginBottom(), width, view);
    1856     marginLeft = style->marginLeft().isAuto() ? marginLeft : valueForLength(style->marginLeft(), width, view);
     1853    marginTop = style->marginTop().isAuto() ? marginTop : intValueForLength(style->marginTop(), width, view);
     1854    marginRight = style->marginRight().isAuto() ? marginRight : intValueForLength(style->marginRight(), width, view);
     1855    marginBottom = style->marginBottom().isAuto() ? marginBottom : intValueForLength(style->marginBottom(), width, view);
     1856    marginLeft = style->marginLeft().isAuto() ? marginLeft : intValueForLength(style->marginLeft(), width, view);
    18571857}
    18581858
  • trunk/Source/WebCore/rendering/RenderFrameSet.cpp

    r111126 r114079  
    216216        // Count the number of columns/rows which are fixed -> countFixed
    217217        if (grid[i].isFixed()) {
    218             gridLayout[i] = max(grid[i].value(), 0);
     218            gridLayout[i] = max(grid[i].intValue(), 0);
    219219            totalFixed += gridLayout[i];
    220220            countFixed++;
     
    224224        // Count the number of columns/rows which are percentages -> countPercent
    225225        if (grid[i].isPercent()) {
    226             gridLayout[i] = max(valueForLength(grid[i], availableLen), 0);
     226            gridLayout[i] = max(intValueForLength(grid[i], availableLen), 0);
    227227            totalPercent += gridLayout[i];
    228228            countPercent++;
     
    232232        // Count the number of columns/rows which are relative -> countRelative
    233233        if (grid[i].isRelative()) {
    234             totalRelative += max(grid[i].value(), 1);
     234            totalRelative += max(grid[i].intValue(), 1);
    235235            countRelative++;
    236236        }           
     
    277277        for (int i = 0; i < gridLen; ++i) {
    278278            if (grid[i].isRelative()) {
    279                 gridLayout[i] = (max(grid[i].value(), 1) * remainingRelative) / totalRelative;
     279                gridLayout[i] = (max(grid[i].intValue(), 1) * remainingRelative) / totalRelative;
    280280                remainingLen -= gridLayout[i];
    281281                lastRelative = i;
  • trunk/Source/WebCore/rendering/RenderMarquee.cpp

    r113665 r114079  
    290290        bool positive = range > 0;
    291291        int clientSize = (isHorizontal() ? m_layer->renderBox()->clientWidth() : m_layer->renderBox()->clientHeight());
    292         int increment = abs(valueForLength(m_layer->renderer()->style()->marqueeIncrement(), clientSize));
     292        int increment = abs(intValueForLength(m_layer->renderer()->style()->marqueeIncrement(), clientSize));
    293293        int currentPos = (isHorizontal() ? m_layer->scrollXOffset() : m_layer->scrollYOffset());
    294294        newPos =  currentPos + (addIncrement ? increment : -increment);
  • trunk/Source/WebCore/rendering/RenderTableSection.cpp

    r113738 r114079  
    335335
    336336        // Our base size is the biggest logical height from our cells' styles (excluding row spanning cells).
    337         m_rowPos[r + 1] = max(m_rowPos[r] + minimumValueForLength(m_grid[r].logicalHeight, 0, viewRenderer), 0);
     337        m_rowPos[r + 1] = max(m_rowPos[r] + minimumIntValueForLength(m_grid[r].logicalHeight, 0, viewRenderer), 0);
    338338
    339339        Row& row = m_grid[r].row;
Note: See TracChangeset for help on using the changeset viewer.