Changeset 157366 in webkit
- Timestamp:
- Oct 13, 2013 4:05:33 AM (11 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 11 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r157365 r157366 1 2013-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 1 46 2013-10-13 Andreas Kling <akling@apple.com> 2 47 -
trunk/Source/WebCore/accessibility/AccessibilityRenderObject.cpp
r157362 r157366 791 791 #endif 792 792 if (obj->isText()) 793 toRenderText(obj)->absoluteQuadsClippedToEllipsis(quads);793 quads = toRenderText(obj)->absoluteQuadsClippedToEllipsis(); 794 794 else if (isWebArea() || isSeamlessWebArea() || isSVGRoot) 795 795 obj->absoluteQuads(quads); -
trunk/Source/WebCore/dom/Document.cpp
r157364 r157366 5670 5670 } 5671 5671 5672 void Document::adjustFloatQuadsForScrollAndAbsoluteZoomAndFrameScale(Vector<FloatQuad>& quads, RenderObject* renderer)5672 void Document::adjustFloatQuadsForScrollAndAbsoluteZoomAndFrameScale(Vector<FloatQuad>& quads, const RenderStyle& style) 5673 5673 { 5674 5674 if (!view()) 5675 5675 return; 5676 5676 5677 float zoom = style.effectiveZoom(); 5677 5678 float inverseFrameScale = 1; 5678 5679 if (frame()) … … 5682 5683 for (size_t i = 0; i < quads.size(); ++i) { 5683 5684 quads[i].move(-visibleContentRect.x(), -visibleContentRect.y()); 5684 adjustFloatQuadForAbsoluteZoom(quads[i], renderer); 5685 if (zoom != 1) 5686 quads[i].scale(1 / zoom, 1 / zoom); 5685 5687 if (inverseFrameScale != 1) 5686 5688 quads[i].scale(inverseFrameScale, inverseFrameScale); … … 5688 5690 } 5689 5691 5690 void Document::adjustFloatRectForScrollAndAbsoluteZoomAndFrameScale(FloatRect& rect, RenderObject* renderer)5692 void Document::adjustFloatRectForScrollAndAbsoluteZoomAndFrameScale(FloatRect& rect, const RenderStyle& style) 5691 5693 { 5692 5694 if (!view()) 5693 5695 return; 5694 5696 5697 float zoom = style.effectiveZoom(); 5695 5698 float inverseFrameScale = 1; 5696 5699 if (frame()) … … 5699 5702 LayoutRect visibleContentRect = view()->visibleContentRect(); 5700 5703 rect.move(-visibleContentRect.x(), -visibleContentRect.y()); 5701 adjustFloatRectForAbsoluteZoom(rect, renderer); 5704 if (zoom != 1) 5705 rect.scale(1 / zoom); 5702 5706 if (inverseFrameScale != 1) 5703 5707 rect.scale(inverseFrameScale); -
trunk/Source/WebCore/dom/Document.h
r157363 r157366 1140 1140 #endif 1141 1141 1142 void adjustFloatQuadsForScrollAndAbsoluteZoomAndFrameScale(Vector<FloatQuad>&, RenderObject*);1143 void adjustFloatRectForScrollAndAbsoluteZoomAndFrameScale(FloatRect&, RenderObject*);1142 void adjustFloatQuadsForScrollAndAbsoluteZoomAndFrameScale(Vector<FloatQuad>&, const RenderStyle&); 1143 void adjustFloatRectForScrollAndAbsoluteZoomAndFrameScale(FloatRect&, const RenderStyle&); 1144 1144 1145 1145 bool hasActiveParser(); -
trunk/Source/WebCore/dom/Element.cpp
r157363 r157366 964 964 Vector<FloatQuad> quads; 965 965 renderBoxModelObject->absoluteQuads(quads); 966 document().adjustFloatQuadsForScrollAndAbsoluteZoomAndFrameScale(quads, renderBoxModelObject);966 document().adjustFloatQuadsForScrollAndAbsoluteZoomAndFrameScale(quads, *renderBoxModelObject->style()); 967 967 return ClientRectList::create(quads); 968 968 } … … 995 995 result.unite(quads[i].boundingBox()); 996 996 997 document().adjustFloatRectForScrollAndAbsoluteZoomAndFrameScale(result, renderer());997 document().adjustFloatRectForScrollAndAbsoluteZoomAndFrameScale(result, *renderer()->style()); 998 998 return ClientRect::create(result); 999 999 } -
trunk/Source/WebCore/dom/Range.cpp
r157308 r157366 1615 1615 int startOffset = node == startContainer ? m_start.offset() : 0; 1616 1616 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)); 1618 1618 } else 1619 1619 continue; … … 1651 1651 int startOffset = node == startContainer ? m_start.offset() : 0; 1652 1652 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)); 1654 1654 } else 1655 1655 continue; … … 1932 1932 Vector<FloatQuad> elementQuads; 1933 1933 renderBoxModelObject->absoluteQuads(elementQuads); 1934 ownerDocument().adjustFloatQuadsForScrollAndAbsoluteZoomAndFrameScale(elementQuads, renderBoxModelObject);1934 ownerDocument().adjustFloatQuadsForScrollAndAbsoluteZoomAndFrameScale(elementQuads, *renderBoxModelObject->style()); 1935 1935 1936 1936 quads.appendVector(elementQuads); … … 1938 1938 } else if (node->isTextNode()) { 1939 1939 if (RenderObject* renderer = toText(node)->renderer()) { 1940 RenderText* renderText = toRenderText(renderer);1940 const RenderText& renderText = toRenderText(*renderer); 1941 1941 int startOffset = (node == startContainer) ? m_start.offset() : 0; 1942 1942 int endOffset = (node == endContainer) ? m_end.offset() : INT_MAX; 1943 1943 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()); 1947 1946 1948 1947 quads.appendVector(textQuads); -
trunk/Source/WebCore/rendering/RenderObject.h
r157349 r157366 1174 1174 #endif 1175 1175 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 1190 1176 } // namespace WebCore 1191 1177 -
trunk/Source/WebCore/rendering/RenderText.cpp
r157362 r157366 2 2 * (C) 1999 Lars Knoll (knoll@kde.org) 3 3 * (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. 5 5 * Copyright (C) 2006 Andrew Wellington (proton@wiretapped.net) 6 6 * Copyright (C) 2006 Graham Dennis (graham.dennis@gmail.com) … … 261 261 void RenderText::absoluteRects(Vector<IntRect>& rects, const LayoutPoint& accumulatedOffset) const 262 262 { 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 266 Vector<IntRect> RenderText::absoluteRectsForRange(unsigned start, unsigned end, bool useSelectionHeight, bool* wasFixed) const 268 267 { 269 268 // Work around signed/unsigned issues. This function takes unsigneds, and is often passed UINT_MAX … … 277 276 end = min(end, static_cast<unsigned>(INT_MAX)); 278 277 279 m_lineBoxes.absoluteRectsForRange(*this, rects, start, end, useSelectionHeight, wasFixed);280 } 281 282 void RenderText::absoluteQuadsClippedToEllipsis(Vector<FloatQuad>& quads) const283 { 284 return m_lineBoxes.absoluteQuads(*this, quads,nullptr, RenderTextLineBoxes::ClipToEllipsis);278 return m_lineBoxes.absoluteRectsForRange(*this, start, end, useSelectionHeight, wasFixed); 279 } 280 281 Vector<FloatQuad> RenderText::absoluteQuadsClippedToEllipsis() const 282 { 283 return m_lineBoxes.absoluteQuads(*this, nullptr, RenderTextLineBoxes::ClipToEllipsis); 285 284 } 286 285 287 286 void RenderText::absoluteQuads(Vector<FloatQuad>& quads, bool* wasFixed) const 288 287 { 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 291 Vector<FloatQuad> RenderText::absoluteQuadsForRange(unsigned start, unsigned end, bool useSelectionHeight, bool* wasFixed) const 293 292 { 294 293 // Work around signed/unsigned issues. This function takes unsigneds, and is often passed UINT_MAX … … 302 301 end = min(end, static_cast<unsigned>(INT_MAX)); 303 302 304 m_lineBoxes.absoluteQuadsForRange(*this, quads, start, end, useSelectionHeight, wasFixed);303 return m_lineBoxes.absoluteQuadsForRange(*this, start, end, useSelectionHeight, wasFixed); 305 304 } 306 305 -
trunk/Source/WebCore/rendering/RenderText.h
r157362 r157366 2 2 * (C) 1999 Lars Knoll (knoll@kde.org) 3 3 * (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. 5 5 * 6 6 * This library is free software; you can redistribute it and/or … … 64 64 65 65 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; 67 67 68 68 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; 72 72 73 73 virtual VisiblePosition positionForPoint(const LayoutPoint&) OVERRIDE; -
trunk/Source/WebCore/rendering/RenderTextLineBoxes.cpp
r157362 r157366 448 448 } 449 449 450 void RenderTextLineBoxes::absoluteRects(Vector<IntRect>& rects, const LayoutPoint& accumulatedOffset) const 451 { 450 Vector<IntRect> RenderTextLineBoxes::absoluteRects(const LayoutPoint& accumulatedOffset) const 451 { 452 Vector<IntRect> rects; 452 453 for (auto box = m_first; box; box = box->nextTextBox()) 453 454 rects.append(enclosingIntRect(FloatRect(accumulatedOffset + box->topLeft(), box->size()))); 455 return rects; 454 456 } 455 457 … … 474 476 } 475 477 476 void RenderTextLineBoxes::absoluteRectsForRange(const RenderText& renderer, Vector<IntRect>& rects, unsigned start, unsigned end, bool useSelectionHeight, bool* wasFixed) const 477 { 478 Vector<IntRect> RenderTextLineBoxes::absoluteRectsForRange(const RenderText& renderer, unsigned start, unsigned end, bool useSelectionHeight, bool* wasFixed) const 479 { 480 Vector<IntRect> rects; 478 481 for (auto box = m_first; box; box = box->nextTextBox()) { 479 482 // Note: box->end() returns the index of the last character, not the index past it … … 498 501 rects.append(renderer.localToAbsoluteQuad(rect, 0, wasFixed).enclosingBoundingBox()); 499 502 } 500 } 501 502 void RenderTextLineBoxes::absoluteQuads(const RenderText& renderer, Vector<FloatQuad>& quads, bool* wasFixed, ClippingOption option) const 503 { 503 return rects; 504 } 505 506 Vector<FloatQuad> RenderTextLineBoxes::absoluteQuads(const RenderText& renderer, bool* wasFixed, ClippingOption option) const 507 { 508 Vector<FloatQuad> quads; 504 509 for (auto box = m_first; box; box = box->nextTextBox()) { 505 510 FloatRect boundaries = box->calculateBoundaries(); … … 516 521 quads.append(renderer.localToAbsoluteQuad(boundaries, 0, wasFixed)); 517 522 } 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 526 Vector<FloatQuad> RenderTextLineBoxes::absoluteQuadsForRange(const RenderText& renderer, unsigned start, unsigned end, bool useSelectionHeight, bool* wasFixed) const 527 { 528 Vector<FloatQuad> quads; 522 529 for (auto box = m_first; box; box = box->nextTextBox()) { 523 530 // Note: box->end() returns the index of the last character, not the index past it … … 541 548 quads.append(renderer.localToAbsoluteQuad(rect, 0, wasFixed)); 542 549 } 550 return quads; 543 551 } 544 552 -
trunk/Source/WebCore/rendering/RenderTextLineBoxes.h
r157362 r157366 67 67 LayoutRect visualOverflowBoundingBox(const RenderText&) const; 68 68 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; 71 71 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; 74 74 75 75 void dirtyAll();
Note: See TracChangeset
for help on using the changeset viewer.