RESOLVED FIXED65647
Use RenderedPosition instead of getInlineBoxAndOffset in Editor and AccessibilityObject
https://bugs.webkit.org/show_bug.cgi?id=65647
Summary Use RenderedPosition instead of getInlineBoxAndOffset in Editor and Accessibi...
Ryosuke Niwa
Reported 2011-08-03 15:17:51 PDT
Since RenderedPosition has been added by r92286, we should encapsulate the use of getInlineBoxAndOffset by RenderedPosition.
Attachments
cleanup (7.05 KB, patch)
2011-08-03 15:28 PDT, Ryosuke Niwa
no flags
cleanup; fixed a bug (7.05 KB, patch)
2011-08-03 15:32 PDT, Ryosuke Niwa
no flags
cleanup; fixed another bug (8.49 KB, patch)
2011-08-03 16:32 PDT, Ryosuke Niwa
no flags
Fixed per comment (8.57 KB, patch)
2011-08-04 19:07 PDT, Ryosuke Niwa
no flags
Merged two absoluteRects (8.46 KB, patch)
2011-08-04 19:33 PDT, Ryosuke Niwa
no flags
Ryosuke Niwa
Comment 1 2011-08-03 15:28:17 PDT
Ryosuke Niwa
Comment 2 2011-08-03 15:32:56 PDT
Created attachment 102841 [details] cleanup; fixed a bug
WebKit Review Bot
Comment 3 2011-08-03 15:57:16 PDT
Comment on attachment 102841 [details] cleanup; fixed a bug Attachment 102841 [details] did not pass chromium-ews (chromium-xvfb): Output: http://queues.webkit.org/results/9301237 New failing tests: editing/inserting/caret-position.html fast/text/international/thai-cursor-position.html platform/chromium-mac/editing/input/ime-candidate-window-position.html
Ryosuke Niwa
Comment 4 2011-08-03 16:32:26 PDT
Created attachment 102855 [details] cleanup; fixed another bug
Hajime Morrita
Comment 5 2011-08-03 21:36:13 PDT
Comment on attachment 102855 [details] cleanup; fixed another bug View in context: https://bugs.webkit.org/attachment.cgi?id=102855&action=review > Source/WebCore/accessibility/AccessibilityObject.cpp:295 > + if (tempPosition.isNull() || tempPosition.isNull()) What is this for? > Source/WebCore/editing/Editor.cpp:2739 > + if (startCaretRect == LayoutRect() || endCaretRect == LayoutRect()) One "if" for each of both startCaretRect and endCaretRect looks more obvious - There is no need to compute both if the first one is empty. > Source/WebCore/editing/RenderedPosition.cpp:40 > +static inline RenderObject* rendererFromPosition(const Position& position) This might be better to a part of Position class. ... or we can even have Position::getInlineBoxAndOffsetAndRenderer(). Another idea is to define VisibilityPosition::toRendered() and Position::toRendered(EAffinity) > Source/WebCore/editing/RenderedPosition.cpp:104 > +LayoutRect RenderedPosition::absoluteRect(int& extraWidthToEndOfLine) Code duplication between two absoluteRect()s. Why not just making the out parameter optional? (As you know, pointer would allow that.) > Source/WebCore/editing/RenderedPosition.h:53 > + LayoutRect absoluteRect(); const? > Source/WebCore/editing/RenderedPosition.h:54 > + LayoutRect absoluteRect(int& extraWidthToEndOfLine); const?
Ryosuke Niwa
Comment 6 2011-08-03 22:11:12 PDT
Comment on attachment 102855 [details] cleanup; fixed another bug View in context: https://bugs.webkit.org/attachment.cgi?id=102855&action=review >> Source/WebCore/accessibility/AccessibilityObject.cpp:295 >> + if (tempPosition.isNull() || tempPosition.isNull()) > > What is this for? It's hard to tell but I'm preserving the original code that checked !tempPosition.deepEquivalent().deprecatedNode() below. >> Source/WebCore/editing/Editor.cpp:2739 > > One "if" for each of both startCaretRect and endCaretRect looks more obvious - There is no need to compute both if the first one is empty. Good point. Will do. >> Source/WebCore/editing/RenderedPosition.cpp:40 >> +static inline RenderObject* rendererFromPosition(const Position& position) > > This might be better to a part of Position class. > ... or we can even have Position::getInlineBoxAndOffsetAndRenderer(). > > Another idea is to define VisibilityPosition::toRendered() and Position::toRendered(EAffinity) Right. In fact, we might be able to replace deprecatedNode with this function.
Ryosuke Niwa
Comment 7 2011-08-04 19:07:49 PDT
Created attachment 103022 [details] Fixed per comment
Hajime Morrita
Comment 8 2011-08-04 19:15:28 PDT
Comment on attachment 103022 [details] Fixed per comment View in context: https://bugs.webkit.org/attachment.cgi?id=103022&action=review > Source/WebCore/editing/RenderedPosition.cpp:40 > +static inline RenderObject* rendererFromPosition(const Position& position) Why not Position::renderer()? > Source/WebCore/editing/RenderedPosition.cpp:95 > +LayoutRect RenderedPosition::absoluteRect() const Could you just call RenderedPosition::absoluteRect(int& extraWidthToEndOfLine) instead of having almost dupliated code?
Ryosuke Niwa
Comment 9 2011-08-04 19:22:46 PDT
(In reply to comment #8) > (From update of attachment 103022 [details]) > View in context: https://bugs.webkit.org/attachment.cgi?id=103022&action=review > > > Source/WebCore/editing/RenderedPosition.cpp:40 > > +static inline RenderObject* rendererFromPosition(const Position& position) > > Why not Position::renderer()? Because I don't think Position should be aware of renderer. Also, any code that calls such a function is likely to be broken with first-letter. As the whole point of RenderedPosition being isolating such such compelxity and dependency, I don't think I want to add such a method to Position. > > Source/WebCore/editing/RenderedPosition.cpp:95 > > +LayoutRect RenderedPosition::absoluteRect() const > > Could you just call RenderedPosition::absoluteRect(int& extraWidthToEndOfLine) instead of having almost dupliated code? Sure. Will do.
Ryosuke Niwa
Comment 10 2011-08-04 19:33:05 PDT
Created attachment 103023 [details] Merged two absoluteRects
WebKit Review Bot
Comment 11 2011-08-04 23:26:34 PDT
Comment on attachment 103023 [details] Merged two absoluteRects Clearing flags on attachment: 103023 Committed r92451: <http://trac.webkit.org/changeset/92451>
WebKit Review Bot
Comment 12 2011-08-04 23:26:39 PDT
All reviewed patches have been landed. Closing bug.
Note You need to log in before you can comment on or make changes to this bug.