Changeset 157366 in webkit


Ignore:
Timestamp:
Oct 13, 2013 4:05:33 AM (11 years ago)
Author:
Antti Koivisto
Message:

Make absoluteQuads/Rects functions return Vectors
https://bugs.webkit.org/show_bug.cgi?id=122722

Reviewed by Andreas Kling.

  • dom/Document.cpp:

(WebCore::Document::adjustFloatQuadsForScrollAndAbsoluteZoomAndFrameScale):
(WebCore::Document::adjustFloatRectForScrollAndAbsoluteZoomAndFrameScale):

Take RenderStyle instead of RenderObject

  • dom/Document.h:
  • dom/Element.cpp:

(WebCore::Element::getClientRects):
(WebCore::Element::getBoundingClientRect):

  • dom/Range.cpp:

(WebCore::Range::textRects):
(WebCore::Range::textQuads):
(WebCore::Range::getBorderAndTextQuads):

Adapt to the changes.

  • rendering/RenderObject.h:


Removed unnecessary adjustFloatQuad/RectForAbsoluteZoom functions, inline code to
adjustFloatQuads/RectForScrollAndAbsoluteZoomAndFrameScale.

  • rendering/RenderText.cpp:

(WebCore::RenderText::absoluteRects):
(WebCore::RenderText::absoluteRectsForRange):
(WebCore::RenderText::absoluteQuadsClippedToEllipsis):
(WebCore::RenderText::absoluteQuads):
(WebCore::RenderText::absoluteQuadsForRange):

  • rendering/RenderText.h:
  • rendering/RenderTextLineBoxes.cpp:

(WebCore::RenderTextLineBoxes::absoluteRects):
(WebCore::RenderTextLineBoxes::absoluteRectsForRange):
(WebCore::RenderTextLineBoxes::absoluteQuads):
(WebCore::RenderTextLineBoxes::absoluteQuadsForRange):

  • rendering/RenderTextLineBoxes.h:


Use return value instead of an out-arg, except for the virtual versions.

Location:
trunk/Source/WebCore
Files:
11 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r157365 r157366  
     12013-10-13  Antti Koivisto  <antti@apple.com>
     2
     3        Make absoluteQuads/Rects functions return Vectors
     4        https://bugs.webkit.org/show_bug.cgi?id=122722
     5
     6        Reviewed by Andreas Kling.
     7
     8        * dom/Document.cpp:
     9        (WebCore::Document::adjustFloatQuadsForScrollAndAbsoluteZoomAndFrameScale):
     10        (WebCore::Document::adjustFloatRectForScrollAndAbsoluteZoomAndFrameScale):
     11           
     12            Take RenderStyle instead of RenderObject
     13
     14        * dom/Document.h:
     15        * dom/Element.cpp:
     16        (WebCore::Element::getClientRects):
     17        (WebCore::Element::getBoundingClientRect):
     18        * dom/Range.cpp:
     19        (WebCore::Range::textRects):
     20        (WebCore::Range::textQuads):
     21        (WebCore::Range::getBorderAndTextQuads):
     22           
     23            Adapt to the changes.
     24
     25        * rendering/RenderObject.h:
     26       
     27            Removed unnecessary adjustFloatQuad/RectForAbsoluteZoom functions, inline code to
     28            adjustFloatQuads/RectForScrollAndAbsoluteZoomAndFrameScale.
     29
     30        * rendering/RenderText.cpp:
     31        (WebCore::RenderText::absoluteRects):
     32        (WebCore::RenderText::absoluteRectsForRange):
     33        (WebCore::RenderText::absoluteQuadsClippedToEllipsis):
     34        (WebCore::RenderText::absoluteQuads):
     35        (WebCore::RenderText::absoluteQuadsForRange):
     36        * rendering/RenderText.h:
     37        * rendering/RenderTextLineBoxes.cpp:
     38        (WebCore::RenderTextLineBoxes::absoluteRects):
     39        (WebCore::RenderTextLineBoxes::absoluteRectsForRange):
     40        (WebCore::RenderTextLineBoxes::absoluteQuads):
     41        (WebCore::RenderTextLineBoxes::absoluteQuadsForRange):
     42        * rendering/RenderTextLineBoxes.h:
     43       
     44            Use return value instead of an out-arg, except for the virtual versions.
     45
    1462013-10-13  Andreas Kling  <akling@apple.com>
    247
  • trunk/Source/WebCore/accessibility/AccessibilityRenderObject.cpp

    r157362 r157366  
    791791#endif
    792792    if (obj->isText())
    793         toRenderText(obj)->absoluteQuadsClippedToEllipsis(quads);
     793        quads = toRenderText(obj)->absoluteQuadsClippedToEllipsis();
    794794    else if (isWebArea() || isSeamlessWebArea() || isSVGRoot)
    795795        obj->absoluteQuads(quads);
  • trunk/Source/WebCore/dom/Document.cpp

    r157364 r157366  
    56705670}
    56715671
    5672 void Document::adjustFloatQuadsForScrollAndAbsoluteZoomAndFrameScale(Vector<FloatQuad>& quads, RenderObject* renderer)
     5672void Document::adjustFloatQuadsForScrollAndAbsoluteZoomAndFrameScale(Vector<FloatQuad>& quads, const RenderStyle& style)
    56735673{
    56745674    if (!view())
    56755675        return;
    56765676
     5677    float zoom = style.effectiveZoom();
    56775678    float inverseFrameScale = 1;
    56785679    if (frame())
     
    56825683    for (size_t i = 0; i < quads.size(); ++i) {
    56835684        quads[i].move(-visibleContentRect.x(), -visibleContentRect.y());
    5684         adjustFloatQuadForAbsoluteZoom(quads[i], renderer);
     5685        if (zoom != 1)
     5686            quads[i].scale(1 / zoom, 1 / zoom);
    56855687        if (inverseFrameScale != 1)
    56865688            quads[i].scale(inverseFrameScale, inverseFrameScale);
     
    56885690}
    56895691
    5690 void Document::adjustFloatRectForScrollAndAbsoluteZoomAndFrameScale(FloatRect& rect, RenderObject* renderer)
     5692void Document::adjustFloatRectForScrollAndAbsoluteZoomAndFrameScale(FloatRect& rect, const RenderStyle& style)
    56915693{
    56925694    if (!view())
    56935695        return;
    56945696
     5697    float zoom = style.effectiveZoom();
    56955698    float inverseFrameScale = 1;
    56965699    if (frame())
     
    56995702    LayoutRect visibleContentRect = view()->visibleContentRect();
    57005703    rect.move(-visibleContentRect.x(), -visibleContentRect.y());
    5701     adjustFloatRectForAbsoluteZoom(rect, renderer);
     5704    if (zoom != 1)
     5705        rect.scale(1 / zoom);
    57025706    if (inverseFrameScale != 1)
    57035707        rect.scale(inverseFrameScale);
  • trunk/Source/WebCore/dom/Document.h

    r157363 r157366  
    11401140#endif
    11411141
    1142     void adjustFloatQuadsForScrollAndAbsoluteZoomAndFrameScale(Vector<FloatQuad>&, RenderObject*);
    1143     void adjustFloatRectForScrollAndAbsoluteZoomAndFrameScale(FloatRect&, RenderObject*);
     1142    void adjustFloatQuadsForScrollAndAbsoluteZoomAndFrameScale(Vector<FloatQuad>&, const RenderStyle&);
     1143    void adjustFloatRectForScrollAndAbsoluteZoomAndFrameScale(FloatRect&, const RenderStyle&);
    11441144
    11451145    bool hasActiveParser();
  • trunk/Source/WebCore/dom/Element.cpp

    r157363 r157366  
    964964    Vector<FloatQuad> quads;
    965965    renderBoxModelObject->absoluteQuads(quads);
    966     document().adjustFloatQuadsForScrollAndAbsoluteZoomAndFrameScale(quads, renderBoxModelObject);
     966    document().adjustFloatQuadsForScrollAndAbsoluteZoomAndFrameScale(quads, *renderBoxModelObject->style());
    967967    return ClientRectList::create(quads);
    968968}
     
    995995        result.unite(quads[i].boundingBox());
    996996
    997     document().adjustFloatRectForScrollAndAbsoluteZoomAndFrameScale(result, renderer());
     997    document().adjustFloatRectForScrollAndAbsoluteZoomAndFrameScale(result, *renderer()->style());
    998998    return ClientRect::create(result);
    999999}
  • trunk/Source/WebCore/dom/Range.cpp

    r157308 r157366  
    16151615            int startOffset = node == startContainer ? m_start.offset() : 0;
    16161616            int endOffset = node == endContainer ? m_end.offset() : numeric_limits<int>::max();
    1617             toRenderText(r)->absoluteRectsForRange(rects, startOffset, endOffset, useSelectionHeight, &isFixed);
     1617            rects.appendVector(toRenderText(r)->absoluteRectsForRange(startOffset, endOffset, useSelectionHeight, &isFixed));
    16181618        } else
    16191619            continue;
     
    16511651            int startOffset = node == startContainer ? m_start.offset() : 0;
    16521652            int endOffset = node == endContainer ? m_end.offset() : numeric_limits<int>::max();
    1653             toRenderText(r)->absoluteQuadsForRange(quads, startOffset, endOffset, useSelectionHeight, &isFixed);
     1653            quads.appendVector(toRenderText(r)->absoluteQuadsForRange(startOffset, endOffset, useSelectionHeight, &isFixed));
    16541654        } else
    16551655            continue;
     
    19321932                Vector<FloatQuad> elementQuads;
    19331933                renderBoxModelObject->absoluteQuads(elementQuads);
    1934                 ownerDocument().adjustFloatQuadsForScrollAndAbsoluteZoomAndFrameScale(elementQuads, renderBoxModelObject);
     1934                ownerDocument().adjustFloatQuadsForScrollAndAbsoluteZoomAndFrameScale(elementQuads, *renderBoxModelObject->style());
    19351935
    19361936                quads.appendVector(elementQuads);
     
    19381938        } else if (node->isTextNode()) {
    19391939            if (RenderObject* renderer = toText(node)->renderer()) {
    1940                 RenderText* renderText = toRenderText(renderer);
     1940                const RenderText& renderText = toRenderText(*renderer);
    19411941                int startOffset = (node == startContainer) ? m_start.offset() : 0;
    19421942                int endOffset = (node == endContainer) ? m_end.offset() : INT_MAX;
    19431943               
    1944                 Vector<FloatQuad> textQuads;
    1945                 renderText->absoluteQuadsForRange(textQuads, startOffset, endOffset);
    1946                 ownerDocument().adjustFloatQuadsForScrollAndAbsoluteZoomAndFrameScale(textQuads, renderText);
     1944                auto textQuads = renderText.absoluteQuadsForRange(startOffset, endOffset);
     1945                ownerDocument().adjustFloatQuadsForScrollAndAbsoluteZoomAndFrameScale(textQuads, *renderText.style());
    19471946
    19481947                quads.appendVector(textQuads);
  • trunk/Source/WebCore/rendering/RenderObject.h

    r157349 r157366  
    11741174#endif
    11751175
    1176 inline void adjustFloatQuadForAbsoluteZoom(FloatQuad& quad, RenderObject* renderer)
    1177 {
    1178     float zoom = renderer->style()->effectiveZoom();
    1179     if (zoom != 1)
    1180         quad.scale(1 / zoom, 1 / zoom);
    1181 }
    1182 
    1183 inline void adjustFloatRectForAbsoluteZoom(FloatRect& rect, RenderObject* renderer)
    1184 {
    1185     float zoom = renderer->style()->effectiveZoom();
    1186     if (zoom != 1)
    1187         rect.scale(1 / zoom, 1 / zoom);
    1188 }
    1189 
    11901176} // namespace WebCore
    11911177
  • trunk/Source/WebCore/rendering/RenderText.cpp

    r157362 r157366  
    22 * (C) 1999 Lars Knoll (knoll@kde.org)
    33 * (C) 2000 Dirk Mueller (mueller@kde.org)
    4  * Copyright (C) 2004, 2005, 2006, 2007 Apple Inc. All rights reserved.
     4 * Copyright (C) 2004, 2005, 2006, 2007, 2013 Apple Inc. All rights reserved.
    55 * Copyright (C) 2006 Andrew Wellington (proton@wiretapped.net)
    66 * Copyright (C) 2006 Graham Dennis (graham.dennis@gmail.com)
     
    261261void RenderText::absoluteRects(Vector<IntRect>& rects, const LayoutPoint& accumulatedOffset) const
    262262{
    263     for (InlineTextBox* box = firstTextBox(); box; box = box->nextTextBox())
    264         rects.append(enclosingIntRect(FloatRect(accumulatedOffset + box->topLeft(), box->size())));
    265 }
    266 
    267 void RenderText::absoluteRectsForRange(Vector<IntRect>& rects, unsigned start, unsigned end, bool useSelectionHeight, bool* wasFixed)
     263    rects.appendVector(m_lineBoxes.absoluteRects(accumulatedOffset));
     264}
     265
     266Vector<IntRect> RenderText::absoluteRectsForRange(unsigned start, unsigned end, bool useSelectionHeight, bool* wasFixed) const
    268267{
    269268    // Work around signed/unsigned issues. This function takes unsigneds, and is often passed UINT_MAX
     
    277276    end = min(end, static_cast<unsigned>(INT_MAX));
    278277   
    279     m_lineBoxes.absoluteRectsForRange(*this, rects, start, end, useSelectionHeight, wasFixed);
    280 }
    281 
    282 void RenderText::absoluteQuadsClippedToEllipsis(Vector<FloatQuad>& quads) const
    283 {
    284     return m_lineBoxes.absoluteQuads(*this, quads, nullptr, RenderTextLineBoxes::ClipToEllipsis);
     278    return m_lineBoxes.absoluteRectsForRange(*this, start, end, useSelectionHeight, wasFixed);
     279}
     280
     281Vector<FloatQuad> RenderText::absoluteQuadsClippedToEllipsis() const
     282{
     283    return m_lineBoxes.absoluteQuads(*this, nullptr, RenderTextLineBoxes::ClipToEllipsis);
    285284}
    286285
    287286void RenderText::absoluteQuads(Vector<FloatQuad>& quads, bool* wasFixed) const
    288287{
    289     return m_lineBoxes.absoluteQuads(*this, quads, wasFixed, RenderTextLineBoxes::NoClipping);
    290 }
    291 
    292 void RenderText::absoluteQuadsForRange(Vector<FloatQuad>& quads, unsigned start, unsigned end, bool useSelectionHeight, bool* wasFixed)
     288    quads.appendVector(m_lineBoxes.absoluteQuads(*this, wasFixed, RenderTextLineBoxes::NoClipping));
     289}
     290
     291Vector<FloatQuad> RenderText::absoluteQuadsForRange(unsigned start, unsigned end, bool useSelectionHeight, bool* wasFixed) const
    293292{
    294293    // Work around signed/unsigned issues. This function takes unsigneds, and is often passed UINT_MAX
     
    302301    end = min(end, static_cast<unsigned>(INT_MAX));
    303302   
    304     m_lineBoxes.absoluteQuadsForRange(*this, quads, start, end, useSelectionHeight, wasFixed);
     303    return m_lineBoxes.absoluteQuadsForRange(*this, start, end, useSelectionHeight, wasFixed);
    305304}
    306305
  • trunk/Source/WebCore/rendering/RenderText.h

    r157362 r157366  
    22 * (C) 1999 Lars Knoll (knoll@kde.org)
    33 * (C) 2000 Dirk Mueller (mueller@kde.org)
    4  * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights reserved.
     4 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2013 Apple Inc. All rights reserved.
    55 *
    66 * This library is free software; you can redistribute it and/or
     
    6464
    6565    virtual void absoluteRects(Vector<IntRect>&, const LayoutPoint& accumulatedOffset) const OVERRIDE FINAL;
    66     void absoluteRectsForRange(Vector<IntRect>&, unsigned startOffset = 0, unsigned endOffset = UINT_MAX, bool useSelectionHeight = false, bool* wasFixed = 0);
     66    Vector<IntRect> absoluteRectsForRange(unsigned startOffset = 0, unsigned endOffset = UINT_MAX, bool useSelectionHeight = false, bool* wasFixed = nullptr) const;
    6767
    6868    virtual void absoluteQuads(Vector<FloatQuad>&, bool* wasFixed) const OVERRIDE FINAL;
    69     void absoluteQuadsForRange(Vector<FloatQuad>&, unsigned startOffset = 0, unsigned endOffset = UINT_MAX, bool useSelectionHeight = false, bool* wasFixed = 0);
    70 
    71     void absoluteQuadsClippedToEllipsis(Vector<FloatQuad>&) const;
     69    Vector<FloatQuad> absoluteQuadsForRange(unsigned startOffset = 0, unsigned endOffset = UINT_MAX, bool useSelectionHeight = false, bool* wasFixed = nullptr) const;
     70
     71    Vector<FloatQuad> absoluteQuadsClippedToEllipsis() const;
    7272
    7373    virtual VisiblePosition positionForPoint(const LayoutPoint&) OVERRIDE;
  • trunk/Source/WebCore/rendering/RenderTextLineBoxes.cpp

    r157362 r157366  
    448448}
    449449
    450 void RenderTextLineBoxes::absoluteRects(Vector<IntRect>& rects, const LayoutPoint& accumulatedOffset) const
    451 {
     450Vector<IntRect> RenderTextLineBoxes::absoluteRects(const LayoutPoint& accumulatedOffset) const
     451{
     452    Vector<IntRect> rects;
    452453    for (auto box = m_first; box; box = box->nextTextBox())
    453454        rects.append(enclosingIntRect(FloatRect(accumulatedOffset + box->topLeft(), box->size())));
     455    return rects;
    454456}
    455457
     
    474476}
    475477
    476 void RenderTextLineBoxes::absoluteRectsForRange(const RenderText& renderer, Vector<IntRect>& rects, unsigned start, unsigned end, bool useSelectionHeight, bool* wasFixed) const
    477 {
     478Vector<IntRect> RenderTextLineBoxes::absoluteRectsForRange(const RenderText& renderer, unsigned start, unsigned end, bool useSelectionHeight, bool* wasFixed) const
     479{
     480    Vector<IntRect> rects;
    478481    for (auto box = m_first; box; box = box->nextTextBox()) {
    479482        // Note: box->end() returns the index of the last character, not the index past it
     
    498501            rects.append(renderer.localToAbsoluteQuad(rect, 0, wasFixed).enclosingBoundingBox());
    499502    }
    500 }
    501 
    502 void RenderTextLineBoxes::absoluteQuads(const RenderText& renderer, Vector<FloatQuad>& quads, bool* wasFixed, ClippingOption option) const
    503 {
     503    return rects;
     504}
     505
     506Vector<FloatQuad> RenderTextLineBoxes::absoluteQuads(const RenderText& renderer, bool* wasFixed, ClippingOption option) const
     507{
     508    Vector<FloatQuad> quads;
    504509    for (auto box = m_first; box; box = box->nextTextBox()) {
    505510        FloatRect boundaries = box->calculateBoundaries();
     
    516521        quads.append(renderer.localToAbsoluteQuad(boundaries, 0, wasFixed));
    517522    }
    518 }
    519 
    520 void RenderTextLineBoxes::absoluteQuadsForRange(const RenderText& renderer, Vector<FloatQuad>& quads, unsigned start, unsigned end, bool useSelectionHeight, bool* wasFixed) const
    521 {
     523    return quads;
     524}
     525
     526Vector<FloatQuad> RenderTextLineBoxes::absoluteQuadsForRange(const RenderText& renderer, unsigned start, unsigned end, bool useSelectionHeight, bool* wasFixed) const
     527{
     528    Vector<FloatQuad> quads;
    522529    for (auto box = m_first; box; box = box->nextTextBox()) {
    523530        // Note: box->end() returns the index of the last character, not the index past it
     
    541548            quads.append(renderer.localToAbsoluteQuad(rect, 0, wasFixed));
    542549    }
     550    return quads;
    543551}
    544552
  • trunk/Source/WebCore/rendering/RenderTextLineBoxes.h

    r157362 r157366  
    6767    LayoutRect visualOverflowBoundingBox(const RenderText&) const;
    6868
    69     void absoluteRects(Vector<IntRect>&, const LayoutPoint& accumulatedOffset) const;
    70     void absoluteRectsForRange(const RenderText&, Vector<IntRect>&, unsigned start, unsigned end, bool useSelectionHeight, bool* wasFixed) const;
     69    Vector<IntRect> absoluteRects(const LayoutPoint& accumulatedOffset) const;
     70    Vector<IntRect> absoluteRectsForRange(const RenderText&, unsigned start, unsigned end, bool useSelectionHeight, bool* wasFixed) const;
    7171    enum ClippingOption { NoClipping, ClipToEllipsis };
    72     void absoluteQuads(const RenderText&, Vector<FloatQuad>&, bool* wasFixed, ClippingOption) const;
    73     void absoluteQuadsForRange(const RenderText&, Vector<FloatQuad>&, unsigned start, unsigned end, bool useSelectionHeight, bool* wasFixed) const;
     72    Vector<FloatQuad> absoluteQuads(const RenderText&, bool* wasFixed, ClippingOption) const;
     73    Vector<FloatQuad> absoluteQuadsForRange(const RenderText&, unsigned start, unsigned end, bool useSelectionHeight, bool* wasFixed) const;
    7474
    7575    void dirtyAll();
Note: See TracChangeset for help on using the changeset viewer.