Closed Bug 828138 Opened 11 years ago Closed 11 years ago

clean up some selection related stuff

Categories

(Core :: DOM: Selection, defect)

defect
Not set
normal

Tracking

()

RESOLVED FIXED
mozilla21

People

(Reporter: tbsaunde, Assigned: tbsaunde)

References

Details

Attachments

(4 files)

      No description provided.
Attachment #699553 - Flags: review?(ehsan)
Comment on attachment 699552 [details] [diff] [review]
remove nsISelectionPrivate::SetPresShell()

Review of attachment 699552 [details] [diff] [review]:
-----------------------------------------------------------------

Nobody was using this?  Huh!
Attachment #699552 - Flags: review?(ehsan) → review+
Attachment #699553 - Flags: review?(ehsan) → review+
Comment on attachment 699554 [details] [diff] [review]
outparamdel Selection::GetPresContext()

Review of attachment 699554 [details] [diff] [review]:
-----------------------------------------------------------------

r=me with the nit below.

::: layout/generic/nsSelection.cpp
@@ +5065,1 @@
>    nsIPresShell *shell = mFrameSelection->GetShell();

You could simplify this even further by doing this instead of all of the above:

nsIPresShell *shell = GetPresShell();
Attachment #699554 - Flags: review?(ehsan) → review+
Comment on attachment 699555 [details] [diff] [review]
nsIPresShell::GetCurrentSelection() should return Selection*

> 
>-  virtual nsISelection* GetCurrentSelection(SelectionType aType) = 0;
>+  virtual mozilla::Selection* GetCurrentSelection(SelectionType aType) = 0;

You're changing an interface, so update IID.
I hope no binary addons are using this stuff.



>+  int32_t rangeCount = origSelection->GetRangeCount();
>   for (int32_t i = 0; i < rangeCount; ++i) {
>-    nsCOMPtr<nsIDOMRange> range;
>-    origSelection->GetRangeAt(i, getter_AddRefs(range));
>-    if (range) {
>-      CloneRangeToSelection(range, aDoc, selection);
>-    }
>+      CloneRangeToSelection(origSelection->GetRangeAt(i), aDoc, selection);
So GetRangeAt(i) can't return null? I guess not
Attachment #699555 - Flags: review?(bugs) → review+
(In reply to Olli Pettay [:smaug] from comment #8)
> Comment on attachment 699555 [details] [diff] [review]
> nsIPresShell::GetCurrentSelection() should return Selection*
> 
> > 
> >-  virtual nsISelection* GetCurrentSelection(SelectionType aType) = 0;
> >+  virtual mozilla::Selection* GetCurrentSelection(SelectionType aType) = 0;
> 
> You're changing an interface, so update IID.
> I hope no binary addons are using this stuff.

sure, though I think this might actually be binary compatable.

> >+  int32_t rangeCount = origSelection->GetRangeCount();
> >   for (int32_t i = 0; i < rangeCount; ++i) {
> >-    nsCOMPtr<nsIDOMRange> range;
> >-    origSelection->GetRangeAt(i, getter_AddRefs(range));
> >-    if (range) {
> >-      CloneRangeToSelection(range, aDoc, selection);
> >-    }
> >+      CloneRangeToSelection(origSelection->GetRangeAt(i), aDoc, selection);
> So GetRangeAt(i) can't return null? I guess not

not unless we put null ranges into a selection.  Of course it will return null if the index is < 0 or >= # of ranges, but we know that isn't the case here.
Please check whether it is possible to have null in range array.
(In reply to Olli Pettay [:smaug] from comment #10)
> Please check whether it is possible to have null in range array.

it seems like everyone null checks before adding to the array.
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: