Changeset 115691 in webkit


Ignore:
Timestamp:
Apr 30, 2012 5:06:37 PM (12 years ago)
Author:
leviw@chromium.org
Message:

Add absoluteValue method for LayoutUnits to allow overloading abs()
https://bugs.webkit.org/show_bug.cgi?id=85214

Reviewed by Eric Seidel.

Adding an absoluteValue free inline function that operates on LayoutUnits, which
allows us to have one function signature for ints or FractionalLayoutUnits. We
can't simply add a FractionalLayoutUnit flavor of abs because it confuses
some compilers due to the implicit FractionalLayoutUnit constructors that take
ints and floats.

No new tests. No change in behavior.

  • page/SpatialNavigation.cpp:

(WebCore::distanceDataForNode):

  • rendering/LayoutTypes.h:

(WebCore::absoluteValue):
(WebCore):

  • rendering/RenderBlockLineLayout.cpp:

(WebCore::RenderBlock::checkPaginationAndFloatsAtEndLine):

  • rendering/RenderLineBoxList.cpp:

(WebCore::RenderLineBoxList::rangeIntersectsRect):

  • rendering/RenderObject.cpp:

(WebCore::RenderObject::repaintAfterLayoutIfNeeded):

Location:
trunk/Source/WebCore
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r115689 r115691  
     12012-04-30  Levi Weintraub  <leviw@chromium.org>
     2
     3        Add absoluteValue method for LayoutUnits to allow overloading abs()
     4        https://bugs.webkit.org/show_bug.cgi?id=85214
     5
     6        Reviewed by Eric Seidel.
     7
     8        Adding an absoluteValue free inline function that operates on LayoutUnits, which
     9        allows us to have one function signature for ints or FractionalLayoutUnits. We
     10        can't simply add a FractionalLayoutUnit flavor of abs because it confuses
     11        some compilers due to the implicit FractionalLayoutUnit constructors that take
     12        ints and floats.
     13
     14        No new tests. No change in behavior.
     15
     16        * page/SpatialNavigation.cpp:
     17        (WebCore::distanceDataForNode):
     18        * rendering/LayoutTypes.h:
     19        (WebCore::absoluteValue):
     20        (WebCore):
     21        * rendering/RenderBlockLineLayout.cpp:
     22        (WebCore::RenderBlock::checkPaginationAndFloatsAtEndLine):
     23        * rendering/RenderLineBoxList.cpp:
     24        (WebCore::RenderLineBoxList::rangeIntersectsRect):
     25        * rendering/RenderObject.cpp:
     26        (WebCore::RenderObject::repaintAfterLayoutIfNeeded):
     27
    1282012-04-30  Levi Weintraub  <leviw@chromium.org>
    229
  • trunk/Source/WebCore/page/SpatialNavigation.cpp

    r111243 r115691  
    646646    case FocusDirectionLeft:
    647647        sameAxisDistance = exitPoint.x() - entryPoint.x();
    648         otherAxisDistance = abs(exitPoint.y() - entryPoint.y());
     648        otherAxisDistance = absoluteValue(exitPoint.y() - entryPoint.y());
    649649        break;
    650650    case FocusDirectionUp:
    651651        sameAxisDistance = exitPoint.y() - entryPoint.y();
    652         otherAxisDistance = abs(exitPoint.x() - entryPoint.x());
     652        otherAxisDistance = absoluteValue(exitPoint.x() - entryPoint.x());
    653653        break;
    654654    case FocusDirectionRight:
    655655        sameAxisDistance = entryPoint.x() - exitPoint.x();
    656         otherAxisDistance = abs(entryPoint.y() - exitPoint.y());
     656        otherAxisDistance = absoluteValue(entryPoint.y() - exitPoint.y());
    657657        break;
    658658    case FocusDirectionDown:
    659659        sameAxisDistance = entryPoint.y() - exitPoint.y();
    660         otherAxisDistance = abs(entryPoint.x() - exitPoint.x());
     660        otherAxisDistance = absoluteValue(entryPoint.x() - exitPoint.x());
    661661        break;
    662662    default:
  • trunk/Source/WebCore/rendering/LayoutTypes.h

    r113665 r115691  
    144144}
    145145
     146inline LayoutUnit absoluteValue(const LayoutUnit& value)
     147{
     148    return abs(value);
     149}
     150
    146151inline LayoutSize toLayoutSize(const LayoutPoint& p)
    147152{
  • trunk/Source/WebCore/rendering/RenderBlockLineLayout.cpp

    r114032 r115691  
    17581758        lastLine = nextLine;
    17591759
    1760     LayoutUnit logicalBottom = lastLine->lineBottomWithLeading() + abs(lineDelta);
     1760    LayoutUnit logicalBottom = lastLine->lineBottomWithLeading() + absoluteValue(lineDelta);
    17611761
    17621762    const FloatingObjectSet& floatingObjectSet = m_floatingObjects->set();
  • trunk/Source/WebCore/rendering/RenderDeprecatedFlexibleBox.cpp

    r115687 r115691  
    559559                        }
    560560                    }
    561                 } while (abs(groupRemainingSpace) >= 1);
     561                } while (absoluteValue(groupRemainingSpace) >= 1);
    562562            }
    563563
     
    810810                        }
    811811                    }
    812                 } while (abs(groupRemainingSpace) >= 1);
     812                } while (absoluteValue(groupRemainingSpace) >= 1);
    813813            }
    814814
  • trunk/Source/WebCore/rendering/RenderLineBoxList.cpp

    r115343 r115691  
    156156    LayoutUnit physicalStart = block->flipForWritingMode(logicalTop);
    157157    LayoutUnit physicalEnd = block->flipForWritingMode(logicalBottom);
    158     LayoutUnit physicalExtent = abs(physicalEnd - physicalStart);
     158    LayoutUnit physicalExtent = absoluteValue(physicalEnd - physicalStart);
    159159    physicalStart = min(physicalStart, physicalEnd);
    160160   
  • trunk/Source/WebCore/rendering/RenderObject.cpp

    r115343 r115691  
    14301430    RenderStyle* outlineStyle = outlineStyleForRepaint();
    14311431    LayoutUnit ow = outlineStyle->outlineSize();
    1432     LayoutUnit width = abs(newOutlineBox.width() - oldOutlineBox.width());
     1432    LayoutUnit width = absoluteValue(newOutlineBox.width() - oldOutlineBox.width());
    14331433    if (width) {
    14341434        LayoutUnit shadowLeft;
     
    14491449        }
    14501450    }
    1451     LayoutUnit height = abs(newOutlineBox.height() - oldOutlineBox.height());
     1451    LayoutUnit height = absoluteValue(newOutlineBox.height() - oldOutlineBox.height());
    14521452    if (height) {
    14531453        LayoutUnit shadowTop;
Note: See TracChangeset for help on using the changeset viewer.