|
|
Created:
6 years, 7 months ago by mlamouri (slow - plz ping) Modified:
6 years, 6 months ago CC:
blink-reviews, jamesr, dglazkov+blink, Donn Denman, jdduke (slow) Base URL:
https://chromium.googlesource.com/chromium/blink.git@master Visibility:
Public. |
DescriptionExtend WebSurroundingText to accept a WebRange.
This will make it possible to get the text surrounding the
current selection by calling WebFrame::selectionRange() and
passing that range to WebSurroundingText.
BUG=330238
Committed: https://src.chromium.org/viewvc/blink?view=rev&revision=176168
Patch Set 1 #Patch Set 2 : #Patch Set 3 : use unsigned #Patch Set 4 : Don't use VisiblePosition #Patch Set 5 : rebase and use int #
Total comments: 1
Patch Set 6 : use websurroundingtext #
Total comments: 6
Patch Set 7 : review comments #Messages
Total messages: 24 (0 generated)
jochen@, let me know if you want someone else to review the core/editing/ changes.
On 2014/05/21 13:37:21, Mounir Lamouri wrote: > jochen@, let me know if you want someone else to review the core/editing/ > changes. I'd recommend tkent@
tkent@, could you have a look at this CL please? :)
+yosin and yutak because this is editing-related.
Could you tell us how will you use this new API for better understanding of this patch? Can we use two |Position| for specifying range rather than using |VisibleSelection|? To support shadow DOM tree, we would like to use |Position|. Thanks in advance. -yosi
On 2014/05/22 09:03:34, yosi wrote: > Could you tell us how will you use this new API for better understanding of this > patch? See https://codereview.chromium.org/292113008/ such as the linked bug. > Can we use two |Position| for specifying range rather than using > |VisibleSelection|? > To support shadow DOM tree, we would like to use |Position|. Hmm, I'm not sure how using |Position| is related to this change. I'm splitting VisibleSelection into two VisiblePositions, to follow the current flow of the code. We could have a ctor taking two |Position| in which case, VisibleSelection would be split into two |Position| instead of two |VisiblePosition|. My change sounds orthogonal to that and not incompatible, doesn't it?
On 2014/05/22 09:34:21, Mounir Lamouri wrote: > On 2014/05/22 09:03:34, yosi wrote: > > Could you tell us how will you use this new API for better understanding of > this > > patch? > > See https://codereview.chromium.org/292113008/ such as the linked bug. > > > Can we use two |Position| for specifying range rather than using > > |VisibleSelection|? > > To support shadow DOM tree, we would like to use |Position|. > > Hmm, I'm not sure how using |Position| is related to this change. I'm splitting > VisibleSelection into two VisiblePositions, to follow the current flow of the > code. We could have a ctor taking two |Position| in which case, VisibleSelection > would be split into two |Position| instead of two |VisiblePosition|. My change > sounds orthogonal to that and not incompatible, doesn't it? We would like to reduce usage of |VisibleSelection|, because VisibleSelection ctor does some canonicalizataion. Also, in SurroundingText, you use visibleStart() and visibleEnd(). These functions can cause layout update, so we would like to avoid to use unless we really need. It seems two |Positions| for SurroundingText is enough, and call site in WebLocalFrame can be simpler as: SurroundingText surroundingText(frame()->selection().start(), frame()->selection().end())
On 2014/05/22 09:57:35, yosi wrote: > On 2014/05/22 09:34:21, Mounir Lamouri wrote: > > On 2014/05/22 09:03:34, yosi wrote: > > > Could you tell us how will you use this new API for better understanding of > > this > > > patch? > > > > See https://codereview.chromium.org/292113008/ such as the linked bug. > > > > > Can we use two |Position| for specifying range rather than using > > > |VisibleSelection|? > > > To support shadow DOM tree, we would like to use |Position|. > > > > Hmm, I'm not sure how using |Position| is related to this change. I'm > splitting > > VisibleSelection into two VisiblePositions, to follow the current flow of the > > code. We could have a ctor taking two |Position| in which case, > VisibleSelection > > would be split into two |Position| instead of two |VisiblePosition|. My change > > sounds orthogonal to that and not incompatible, doesn't it? > > We would like to reduce usage of |VisibleSelection|, because VisibleSelection > ctor does some canonicalizataion. Also, in SurroundingText, you use > visibleStart() and visibleEnd(). These functions can cause layout update, so we > would like to avoid to use unless we really need. > > It seems two |Positions| for SurroundingText is enough, and call site in > WebLocalFrame can be simpler as: > SurroundingText surroundingText(frame()->selection().start(), > frame()->selection().end()) SurroundingText is currently using VisiblePosition. I guess we would want it to use Position intsead in that case. It seems that converting everything from VisiblePosition to Position is another work, isn't?
> SurroundingText is currently using VisiblePosition. I guess we would want it to > use Position intsead in that case. It seems that converting everything from > VisiblePosition to Position is another work, isn't? Agreed. Editing team will change SurroundingText and BackwardCharacterIterator to use Position. However, I would like to hear from yutak@, he is working on BackwardsCharacterIterator now. He might have another point of view or better solution for both end.
On 2014/05/23 01:04:02, yosi wrote: > > SurroundingText is currently using VisiblePosition. I guess we would want it > to > > use Position intsead in that case. It seems that converting everything from > > VisiblePosition to Position is another work, isn't? > Agreed. Editing team will change SurroundingText and BackwardCharacterIterator > to use Position. > > However, I would like to hear from yutak@, he is working on > BackwardsCharacterIterator now. He might have another point of view or better > solution for both end. I had a look with regards to use Position instead of VisiblePosition but I blocked when I had to change endDocument() and startOfDocument(). Those methods are currently related to VisibleUnits/VisiblePosition and using Position instead doesn't seem trivial to me. Furthermore, in the Chromium side of the review, I was asked if SurroundingText could use unsigned instead of int. What do you think? PTAL
I have rebased this CL on top of https://codereview.chromium.org/307353002/ which makes SurroundingText depending on Position instead of VisiblePosition. Yosi and Yuta, could you PTAL?
I have rebased the CL on top of https://codereview.chromium.org/307353002/ and changed the exposed WebFrame API to use |int| instead of |unsigned| because of review comments on the content/ side of things.
https://codereview.chromium.org/294073005/diff/80001/public/web/WebFrame.h File public/web/WebFrame.h (right): https://codereview.chromium.org/294073005/diff/80001/public/web/WebFrame.h#ne... public/web/WebFrame.h:484: virtual WebString textSurroundingSelection(int maxLength, int* startOffset, int* endOffset) const = 0; 1. We usually use non-const references for output arguments, instead of non-const pointers. 2. I'm not sure why we need to add this method to WebFrame. Is there any reason you cannot extend WebSurroundingText interface?
On 2014/06/06 02:20:08, Yuta Kitamura wrote: > https://codereview.chromium.org/294073005/diff/80001/public/web/WebFrame.h > File public/web/WebFrame.h (right): > > https://codereview.chromium.org/294073005/diff/80001/public/web/WebFrame.h#ne... > public/web/WebFrame.h:484: virtual WebString textSurroundingSelection(int > maxLength, int* startOffset, int* endOffset) const = 0; > 1. We usually use non-const references for output arguments, > instead of non-const pointers. Interesting. Isn't that the opposite in Chromium? > 2. I'm not sure why we need to add this method to WebFrame. > Is there any reason you cannot extend WebSurroundingText > interface? I could use WebSurroundingText but I would have to initialize it with a WebFrame because I want the text surrounding the selection. Would that work for you?
On 2014/06/09 10:39:27, Mounir Lamouri wrote: > https://codereview.chromium.org/294073005/diff/80001/public/web/WebFrame.h#ne... > > public/web/WebFrame.h:484: virtual WebString textSurroundingSelection(int > > maxLength, int* startOffset, int* endOffset) const = 0; > > 1. We usually use non-const references for output arguments, > > instead of non-const pointers. > > Interesting. Isn't that the opposite in Chromium? Yes. The Blink API uses Blink style, which isn't the same as Chromium style (yet!).
On 2014/06/09 10:39:27, Mounir Lamouri wrote: > On 2014/06/06 02:20:08, Yuta Kitamura wrote: > > 2. I'm not sure why we need to add this method to WebFrame. > > Is there any reason you cannot extend WebSurroundingText > > interface? > > I could use WebSurroundingText but I would have to initialize it with a WebFrame > because I want the text surrounding the selection. Would that work for you? I think it's possible to implement it in WebSurroundingText without adding the dependency to WebFrame, since the embedders can obtain a WebRange object from WebFrame::selectionRange() and pass it to the WebSurroundText initializer.
I have splitted this CL to have the editing/ changes (the core) separated from the interface changes. I kept this CL for the interface (WebSurroundingText) changes only. See this CL for the editing/ changes: https://codereview.chromium.org/323983006 Yuta-san, can you PTAL? :)
Now that https://codereview.chromium.org/323983006 has landed, this should be ready to land. Tamura-san and Yuta-san, could you have a look?
https://codereview.chromium.org/294073005/diff/100001/Source/web/WebSurroundi... File Source/web/WebSurroundingText.cpp (right): https://codereview.chromium.org/294073005/diff/100001/Source/web/WebSurroundi... Source/web/WebSurroundingText.cpp:53: const Range* range = webRange.constUnwrap<Range>(); nit: You can simplify the code like: if (RefPtrWillBeRawPtr<Range> range = static_cast<PassRefPtrWillBeRawPtr<Range> >(webRange)) m_private.reset(new SurroundingText(*range, maxLength)); https://codereview.chromium.org/294073005/diff/100001/public/web/WebRange.h File public/web/WebRange.h (right): https://codereview.chromium.org/294073005/diff/100001/public/web/WebRange.h#n... public/web/WebRange.h:85: template<typename T> T* unwrap() You don't need it. We already have |operator PassRefPtrWillBeRawPtr<>()|. You can get a Rage object with: RefPtrWillBeRawPtr<Range> range = static_cast<PassRefPtrWillBeRawPtr<Range> >(webRange); WebNode and WebDOMEvent need it because storage type and wanted type are mismatched. e.g. The storage of WebDocument is WebPrivatePtr<Node> inherited from WebNode, but WebDocument needs Document* instead of Node*. https://codereview.chromium.org/294073005/diff/100001/public/web/WebSurroundi... File public/web/WebSurroundingText.h (right): https://codereview.chromium.org/294073005/diff/100001/public/web/WebSurroundi... public/web/WebSurroundingText.h:44: // WebSurroundingText is a Blink API that gives access to the SurroundingText API. Nit: I recommend to wrap code comments in 80 columns.
Since this patch is mostly about web/ interface, I'd like to leave the actual review to Kent-san who is a web/ OWNER. As far as I can see, this patch LGTM as long as Kent-san's comments are addressed.
Comments applied. PTAL. https://codereview.chromium.org/294073005/diff/100001/Source/web/WebSurroundi... File Source/web/WebSurroundingText.cpp (right): https://codereview.chromium.org/294073005/diff/100001/Source/web/WebSurroundi... Source/web/WebSurroundingText.cpp:53: const Range* range = webRange.constUnwrap<Range>(); On 2014/06/13 01:15:37, tkent wrote: > nit: You can simplify the code like: > > if (RefPtrWillBeRawPtr<Range> range = static_cast<PassRefPtrWillBeRawPtr<Range> > >(webRange)) > m_private.reset(new SurroundingText(*range, maxLength)); Done. https://codereview.chromium.org/294073005/diff/100001/public/web/WebRange.h File public/web/WebRange.h (right): https://codereview.chromium.org/294073005/diff/100001/public/web/WebRange.h#n... public/web/WebRange.h:85: template<typename T> T* unwrap() On 2014/06/13 01:15:37, tkent wrote: > You don't need it. > We already have |operator PassRefPtrWillBeRawPtr<>()|. You can get a Rage > object with: > RefPtrWillBeRawPtr<Range> range = static_cast<PassRefPtrWillBeRawPtr<Range> > >(webRange); > > WebNode and WebDOMEvent need it because storage type and wanted type are > mismatched. e.g. The storage of WebDocument is WebPrivatePtr<Node> inherited > from WebNode, but WebDocument needs Document* instead of Node*. > Done. https://codereview.chromium.org/294073005/diff/100001/public/web/WebSurroundi... File public/web/WebSurroundingText.h (right): https://codereview.chromium.org/294073005/diff/100001/public/web/WebSurroundi... public/web/WebSurroundingText.h:44: // WebSurroundingText is a Blink API that gives access to the SurroundingText API. On 2014/06/13 01:15:37, tkent wrote: > Nit: I recommend to wrap code comments in 80 columns. Done. I've also changed the rest of the comments in this file to match.
lgtm
CQ is trying da patch. Follow status at https://chromium-status.appspot.com/cq/mlamouri@chromium.org/294073005/120001
Message was sent while issue was closed.
Change committed as 176168 |