RESOLVED FIXED 62478
RenderText::absoluteRectsForRange() and absoluteQuadsForRange() have nearly duplicate code
https://bugs.webkit.org/show_bug.cgi?id=62478
Summary RenderText::absoluteRectsForRange() and absoluteQuadsForRange() have nearly d...
David Kilzer (:ddkilzer)
Reported 2011-06-10 14:16:03 PDT
* SUMMARY In RenderText::absoluteRectsForRange(), the following code is used in an else clause: IntRect r = box->selectionRect(0, 0, start, realEnd); if (!r.isEmpty()) { if (!useSelectionHeight) { In RenderText::absoluteQuadsForRange(), the same code uses a slightly different check: IntRect r = box->selectionRect(0, 0, start, realEnd); if (r.height()) { if (!useSelectionHeight) { It seems like these methods should be using the same check, and it would be great if the duplicate code could be extracted into a local static method.
Attachments
Patch (8.41 KB, patch)
2011-07-25 17:30 PDT, Emil A Eklund
no flags
Patch for landing (9.19 KB, patch)
2011-07-26 10:05 PDT, Emil A Eklund
no flags
Simon Fraser (smfr)
Comment 1 2011-06-10 14:17:00 PDT
Emil A Eklund
Comment 2 2011-07-25 17:30:30 PDT
Simon Fraser (smfr)
Comment 3 2011-07-25 17:33:00 PDT
Comment on attachment 101949 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=101949&action=review > Source/WebCore/rendering/RenderText.cpp:281 > + // change the height and y position because selectionRect uses selection-specific values Please change this to use sentence case and end with a period. > Source/WebCore/rendering/RenderText.cpp:324 > + if (!rect.size().isZero()) Don't we have rect.isEmpty()? > Source/WebCore/rendering/RenderText.cpp:405 > + if (!rect.size().isZero()) Ditto.
Emil A Eklund
Comment 4 2011-07-26 10:05:36 PDT
Created attachment 102019 [details] Patch for landing
Emil A Eklund
Comment 5 2011-07-26 10:07:58 PDT
Thanks for the quick review. (In reply to comment #3) > (From update of attachment 101949 [details]) > View in context: https://bugs.webkit.org/attachment.cgi?id=101949&action=review > > > Source/WebCore/rendering/RenderText.cpp:281 > > + // change the height and y position because selectionRect uses selection-specific values > > Please change this to use sentence case and end with a period. Done. > > > Source/WebCore/rendering/RenderText.cpp:324 > > + if (!rect.size().isZero()) > > Don't we have rect.isEmpty()? We do but I want to check for zero as opposed to empty here as we have a couple of tests that expect getClientRects to return a rect with a zero width. Added FloatRect::isZero that calls FloatSize::isZero and changed the code in RenderText to use that method.
WebKit Review Bot
Comment 6 2011-07-26 10:47:19 PDT
Comment on attachment 102019 [details] Patch for landing Clearing flags on attachment: 102019 Committed r91763: <http://trac.webkit.org/changeset/91763>
WebKit Review Bot
Comment 7 2011-07-26 10:47:26 PDT
All reviewed patches have been landed. Closing bug.
Simon Fraser (smfr)
Comment 9 2011-08-04 14:58:44 PDT
Comment on attachment 102019 [details] Patch for landing View in context: https://bugs.webkit.org/attachment.cgi?id=102019&action=review > Source/WebCore/rendering/RenderText.cpp:407 > + FloatRect rect = absoluteQuadForTextBox(box, start, end, useSelectionHeight); > + if (!rect.isZero()) > + quads.append(localToAbsoluteQuad(rect)); This is wrong. It converts local to absolute twice.
Note You need to log in before you can comment on or make changes to this bug.