Closed Bug 1053779 Opened 10 years ago Closed 10 years ago

Clean up nsEditor::CreateHTMLContent, ReplaceContainer, CloneAttributes

Categories

(Core :: DOM: Editor, enhancement)

enhancement
Not set
normal

Tracking

()

RESOLVED FIXED
mozilla34

People

(Reporter: ayg, Assigned: ayg)

References

Details

Attachments

(3 files)

No description provided.
Attachment #8473068 - Flags: review?(ehsan) → review+
Comment on attachment 8473074 [details] [diff] [review] Patch part 2 -- Clean up nsEditor::ReplaceContainer Review of attachment 8473074 [details] [diff] [review]: ----------------------------------------------------------------- ::: editor/libeditor/html/nsTableEditor.cpp @@ +1957,5 @@ > nsAutoSelectionReset selectionResetter(selection, this); > > // Set to the opposite of current type > nsCOMPtr<nsIAtom> atom = nsEditor::GetTag(aSourceCell); > + nsCOMPtr<nsIAtom> newCellType = atom == nsEditProperty::td Nit: nsIAtom*.
Attachment #8473074 - Flags: review?(ehsan) → review+
Comment on attachment 8473119 [details] [diff] [review] Patch part 3 -- Clean up nsEditor::CloneAttributes Review of attachment 8473119 [details] [diff] [review]: ----------------------------------------------------------------- ::: editor/libeditor/base/nsEditor.cpp @@ +2245,5 @@ > + // Clear existing attributes > + nsRefPtr<nsDOMAttributeMap> destAttributes = aDest->Attributes(); > + while (nsRefPtr<Attr> attr = destAttributes->Item(0)) { > + if (destInBody) { > + RemoveAttribute(static_cast<nsIDOMElement*>(GetAsDOMNode(aDest)), These static casts are unfortunately not safe because nsIDOMElement is not builtinclass. Please QI instead.
Attachment #8473119 - Flags: review?(ehsan) → review+
(In reply to :Ehsan Akhgari (not reading bugmail, needinfo? me!) from comment #5) > These static casts are unfortunately not safe because nsIDOMElement is not > builtinclass. Please QI instead. Hrm? aDest is an Element, and every Element is an nsIDOMElement, isn't it? I understand why nsIDOMElement can't be cast to Element, because maybe someone passed in a weird made-up user class, but I thought the other way was safe, just like nsINode to nsIDOMNode is safe.
Flags: needinfo?(ehsan)
Hmm, I was worried about this function which is exposed to JS consumers: <http://mxr.mozilla.org/mozilla-central/source/editor/nsIEditor.idl#398> But on a second look, the other overload of CloneAttributes will return early if you pass it such made up JS objects. So, I guess this is actually fine. Sorry for the confusion, this stuff is hard to reason about. :/
Flags: needinfo?(ehsan)
Flags: qe-verify-
Depends on: 1402469
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: