Changeset 93334 in webkit


Ignore:
Timestamp:
Aug 18, 2011 12:28:33 PM (13 years ago)
Author:
leviw@chromium.org
Message:

Switch RenderTextControl* to new layout types
https://bugs.webkit.org/show_bug.cgi?id=66250

Reviewed by Eric Seidel.

Convertikng the RenderTextControl* classes to use the LayoutUnit abstraction.

No new tests as no change in behavior.

  • rendering/LayoutTypes.h:

(WebCore::layoutMod): Added a function to perform the modulo operation on LayoutUnits.

  • rendering/RenderTextControl.cpp:

(WebCore::RenderTextControl::hitInnerTextElement):

  • rendering/RenderTextControl.h:
  • rendering/RenderTextControlMultiLine.cpp:

(WebCore::RenderTextControlMultiLine::preferredContentWidth):
(WebCore::RenderTextControlMultiLine::baselinePosition):

  • rendering/RenderTextControlMultiLine.h:
  • rendering/RenderTextControlSingleLine.cpp:

(WebCore::RenderTextControlSingleLine::layout):
(WebCore::RenderTextControlSingleLine::controlClipRect):
(WebCore::RenderTextControlSingleLine::preferredContentWidth):
(WebCore::RenderTextControlSingleLine::scrollWidth):
(WebCore::RenderTextControlSingleLine::scrollHeight):
(WebCore::RenderTextControlSingleLine::scrollLeft):
(WebCore::RenderTextControlSingleLine::scrollTop):
(WebCore::RenderTextControlSingleLine::setScrollLeft):
(WebCore::RenderTextControlSingleLine::setScrollTop):

  • rendering/RenderTextControlSingleLine.h:
Location:
trunk/Source/WebCore
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r93333 r93334  
     12011-08-18  Levi Weintraub  <leviw@chromium.org>
     2
     3        Switch RenderTextControl* to new layout types
     4        https://bugs.webkit.org/show_bug.cgi?id=66250
     5
     6        Reviewed by Eric Seidel.
     7
     8        Convertikng the RenderTextControl* classes to use the LayoutUnit abstraction.
     9
     10        No new tests as no change in behavior.
     11
     12        * rendering/LayoutTypes.h:
     13        (WebCore::layoutMod): Added a function to perform the modulo operation on LayoutUnits.
     14        * rendering/RenderTextControl.cpp:
     15        (WebCore::RenderTextControl::hitInnerTextElement):
     16        * rendering/RenderTextControl.h:
     17        * rendering/RenderTextControlMultiLine.cpp:
     18        (WebCore::RenderTextControlMultiLine::preferredContentWidth):
     19        (WebCore::RenderTextControlMultiLine::baselinePosition):
     20        * rendering/RenderTextControlMultiLine.h:
     21        * rendering/RenderTextControlSingleLine.cpp:
     22        (WebCore::RenderTextControlSingleLine::layout):
     23        (WebCore::RenderTextControlSingleLine::controlClipRect):
     24        (WebCore::RenderTextControlSingleLine::preferredContentWidth):
     25        (WebCore::RenderTextControlSingleLine::scrollWidth):
     26        (WebCore::RenderTextControlSingleLine::scrollHeight):
     27        (WebCore::RenderTextControlSingleLine::scrollLeft):
     28        (WebCore::RenderTextControlSingleLine::scrollTop):
     29        (WebCore::RenderTextControlSingleLine::setScrollLeft):
     30        (WebCore::RenderTextControlSingleLine::setScrollTop):
     31        * rendering/RenderTextControlSingleLine.h:
     32
    1332011-08-18  Levi Weintraub  <leviw@chromium.org>
    234
  • trunk/Source/WebCore/rendering/LayoutTypes.h

    r92998 r93334  
    9292}
    9393
     94inline LayoutUnit layoutMod(const LayoutUnit& numerator, const LayoutUnit& denominator)
     95{
     96    return numerator % denominator;
     97}
     98
    9499} // namespace WebCore
    95100
  • trunk/Source/WebCore/rendering/RenderTextControl.cpp

    r91879 r93334  
    300300void RenderTextControl::hitInnerTextElement(HitTestResult& result, const LayoutPoint& pointInContainer, const LayoutPoint& accumulatedOffset)
    301301{
    302     IntPoint adjustedLocation = accumulatedOffset + location();
     302    LayoutPoint adjustedLocation = accumulatedOffset + location();
    303303    HTMLElement* innerText = innerTextElement();
    304304    result.setInnerNode(innerText);
  • trunk/Source/WebCore/rendering/RenderTextControl.h

    r91014 r93334  
    6464    static bool hasValidAvgCharWidth(AtomicString family);
    6565    virtual float getAvgCharWidth(AtomicString family);
    66     virtual int preferredContentWidth(float charWidth) const = 0;
     66    virtual LayoutUnit preferredContentWidth(float charWidth) const = 0;
    6767    virtual void adjustControlHeightBasedOnLineHeight(LayoutUnit lineHeight) = 0;
    6868    virtual RenderStyle* textBaseStyle() const = 0;
  • trunk/Source/WebCore/rendering/RenderTextControlMultiLine.cpp

    r91014 r93334  
    6565}
    6666
    67 int RenderTextControlMultiLine::preferredContentWidth(float charWidth) const
     67LayoutUnit RenderTextControlMultiLine::preferredContentWidth(float charWidth) const
    6868{
    6969    int factor = static_cast<HTMLTextAreaElement*>(node())->cols();
    70     return static_cast<int>(ceilf(charWidth * factor)) + scrollbarThickness();
     70    return static_cast<LayoutUnit>(ceilf(charWidth * factor)) + scrollbarThickness();
    7171}
    7272
     
    7676}
    7777
    78 int RenderTextControlMultiLine::baselinePosition(FontBaseline baselineType, bool firstLine, LineDirectionMode direction, LinePositionMode linePositionMode) const
     78LayoutUnit RenderTextControlMultiLine::baselinePosition(FontBaseline baselineType, bool firstLine, LineDirectionMode direction, LinePositionMode linePositionMode) const
    7979{
    8080    return RenderBox::baselinePosition(baselineType, firstLine, direction, linePositionMode);
  • trunk/Source/WebCore/rendering/RenderTextControlMultiLine.h

    r91014 r93334  
    3838
    3939    virtual float getAvgCharWidth(AtomicString family);
    40     virtual int preferredContentWidth(float charWidth) const;
    41     virtual void adjustControlHeightBasedOnLineHeight(int lineHeight);
    42     virtual int baselinePosition(FontBaseline, bool firstLine, LineDirectionMode, LinePositionMode = PositionOnContainingLine) const;
     40    virtual LayoutUnit preferredContentWidth(float charWidth) const;
     41    virtual void adjustControlHeightBasedOnLineHeight(LayoutUnit lineHeight);
     42    virtual LayoutUnit baselinePosition(FontBaseline, bool firstLine, LineDirectionMode, LinePositionMode = PositionOnContainingLine) const;
    4343
    4444    virtual void updateFromElement();
  • trunk/Source/WebCore/rendering/RenderTextControlSingleLine.cpp

    r92589 r93334  
    266266    if (!container && currentHeight != contentHeight()) {
    267267        LayoutUnit heightDiff = currentHeight - contentHeight();
    268         innerTextRenderer->setY(innerTextRenderer->y() - (heightDiff / 2 + heightDiff % 2));
     268        innerTextRenderer->setY(innerTextRenderer->y() - (heightDiff / 2 + layoutMod(heightDiff, 2)));
    269269    } else if (inputElement()->isSearchField() && containerRenderer && containerRenderer->height() > contentHeight()) {
    270270        // A quirk for find-in-page box on Safari Windows.
    271271        // http://webkit.org/b/63157
    272272        LayoutUnit heightDiff = containerRenderer->height() - contentHeight();
    273         containerRenderer->setY(containerRenderer->y() - (heightDiff / 2 + heightDiff % 2));
     273        containerRenderer->setY(containerRenderer->y() - (heightDiff / 2 + layoutMod(heightDiff, 2)));
    274274    }
    275275
     
    371371}
    372372
    373 IntRect RenderTextControlSingleLine::controlClipRect(const IntPoint& additionalOffset) const
     373LayoutRect RenderTextControlSingleLine::controlClipRect(const LayoutPoint& additionalOffset) const
    374374{
    375375    ASSERT(hasControlClip());
    376     IntRect clipRect = IntRect(containerElement()->renderBox()->frameRect());
     376    LayoutRect clipRect = LayoutRect(containerElement()->renderBox()->frameRect());
    377377    clipRect.moveBy(additionalOffset);
    378378    return clipRect;
     
    391391}
    392392
    393 int RenderTextControlSingleLine::preferredContentWidth(float charWidth) const
     393LayoutUnit RenderTextControlSingleLine::preferredContentWidth(float charWidth) const
    394394{
    395395    int factor;
     
    398398        factor = 20;
    399399
    400     int result = static_cast<int>(ceilf(charWidth * factor));
     400    LayoutUnit result = static_cast<LayoutUnit>(ceiledLayoutUnit(charWidth * factor));
    401401
    402402    float maxCharWidth = 0.f;
     
    720720}
    721721
    722 int RenderTextControlSingleLine::scrollWidth() const
     722LayoutUnit RenderTextControlSingleLine::scrollWidth() const
    723723{
    724724    if (innerTextElement())
     
    727727}
    728728
    729 int RenderTextControlSingleLine::scrollHeight() const
     729LayoutUnit RenderTextControlSingleLine::scrollHeight() const
    730730{
    731731    if (innerTextElement())
     
    734734}
    735735
    736 int RenderTextControlSingleLine::scrollLeft() const
     736LayoutUnit RenderTextControlSingleLine::scrollLeft() const
    737737{
    738738    if (innerTextElement())
     
    741741}
    742742
    743 int RenderTextControlSingleLine::scrollTop() const
     743LayoutUnit RenderTextControlSingleLine::scrollTop() const
    744744{
    745745    if (innerTextElement())
     
    748748}
    749749
    750 void RenderTextControlSingleLine::setScrollLeft(int newLeft)
     750void RenderTextControlSingleLine::setScrollLeft(LayoutUnit newLeft)
    751751{
    752752    if (innerTextElement())
     
    754754}
    755755
    756 void RenderTextControlSingleLine::setScrollTop(int newTop)
     756void RenderTextControlSingleLine::setScrollTop(LayoutUnit newTop)
    757757{
    758758    if (innerTextElement())
  • trunk/Source/WebCore/rendering/RenderTextControlSingleLine.h

    r91014 r93334  
    5252private:
    5353    virtual bool hasControlClip() const;
    54     virtual IntRect controlClipRect(const IntPoint&) const;
     54    virtual LayoutRect controlClipRect(const LayoutPoint&) const;
    5555    virtual bool isTextField() const { return true; }
    5656
     
    6363
    6464    // Subclassed to forward to our inner div.
    65     virtual int scrollLeft() const;
    66     virtual int scrollTop() const;
    67     virtual int scrollWidth() const;
    68     virtual int scrollHeight() const;
    69     virtual void setScrollLeft(int);
    70     virtual void setScrollTop(int);
     65    virtual LayoutUnit scrollLeft() const;
     66    virtual LayoutUnit scrollTop() const;
     67    virtual LayoutUnit scrollWidth() const;
     68    virtual LayoutUnit scrollHeight() const;
     69    virtual void setScrollLeft(LayoutUnit);
     70    virtual void setScrollTop(LayoutUnit);
    7171    virtual bool scroll(ScrollDirection, ScrollGranularity, float multiplier = 1, Node** stopNode = 0);
    7272    virtual bool logicalScroll(ScrollLogicalDirection, ScrollGranularity, float multiplier = 1, Node** stopNode = 0);
     
    7474    int textBlockWidth() const;
    7575    virtual float getAvgCharWidth(AtomicString family);
    76     virtual int preferredContentWidth(float charWidth) const;
     76    virtual LayoutUnit preferredContentWidth(float charWidth) const;
    7777    virtual void adjustControlHeightBasedOnLineHeight(LayoutUnit lineHeight);
    7878
Note: See TracChangeset for help on using the changeset viewer.