Closed Bug 545775 Opened 15 years ago Closed 14 years ago

Text editor in ASUS Forum doesn't work.

Categories

(Core :: DOM: Editor, defect, P2)

x86_64
Windows 7
defect

Tracking

()

RESOLVED FIXED
mozilla2.0b1
Tracking Status
blocking2.0 --- final+

People

(Reporter: streetwolf52, Assigned: masayuki)

References

()

Details

(Keywords: regression)

Attachments

(8 files, 10 obsolete files)

42.03 KB, patch
Details | Diff | Splinter Review
7.94 KB, patch
ehsan.akhgari
: review+
Details | Diff | Splinter Review
11.90 KB, patch
ehsan.akhgari
: review+
Details | Diff | Splinter Review
7.90 KB, patch
ehsan.akhgari
: review+
Details | Diff | Splinter Review
13.47 KB, patch
masayuki
: review+
Details | Diff | Splinter Review
11.20 KB, patch
ehsan.akhgari
: review+
Details | Diff | Splinter Review
4.72 KB, patch
ehsan.akhgari
: review+
Details | Diff | Splinter Review
635 bytes, patch
roc
: review+
Details | Diff | Splinter Review
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.3a2pre) Gecko/20100211 Minefield/3.7a2pre Firefox/3.6 Build Identifier: 20100211050928 When starting a new reply or topic the editor in the ASUS Forum does not work properly. It appears it uses the FreeTextBox HTML editor for ASP.NET. If you use the 'Quote and Reply' option the editor works fine. Reproducible: Always Steps to Reproduce: 1. Post a new reply or topic in the ASUS forum. Registration is required. 2. Try to enter text in the editor. 3. Actual Results: Text does not appear. Expected Results: Text should appear and all functions should work. Sometimes I can get one character to appear.
Version: unspecified → Trunk
Component: General → JavaScript Engine
BTW.... Works fine in IE8
Summary: Text editor in Forum doesn't work → Text editor in ASUS Forum doesn't work.
Does it work in Firefox 3.6?
Confirmed in FF 3.7. This site also works fine in IE6. I'll try to test it in 3.6 later if I can.
Status: UNCONFIRMED → NEW
Ever confirmed: true
Works fine in 3.6. Tried Trunk with a new profile and it still doesn't work.
Excellent. Can you hunt down the trunk nightlies that bracket the regression and post their revision ids (from about:buildconfig) here?
I'll get on it tomorrow first thing.
Awesome. Thank you!
I haven't had time to check all the nightlies, but here's what I got so far (I'm assuming the revision you want is the part that says "Built from"): OK 20091214 http://hg.mozilla.org/mozilla-central/rev/44c392db6672 bad 20091218 http://hg.mozilla.org/mozilla-central/rev/58359ad70d1b Gary, I hope this helps narrow it down for you so you have less work to do.
Warner, that's exactly the info I want, yeah. 4-day range based on those changeset ids: http://hg.mozilla.org/mozilla-central/pushloghtml?fromchange=44c392db6672&tochange=58359ad70d1b Lots of stuff in there, unfortunately...
That would be this range: http://hg.mozilla.org/mozilla-central/pushloghtml?fromchange=dba2abb7db57&tochange=cdb87287a747 You said you tested with a new profile, so I assume you don't have the HTML5 parser enabled. In which case nothing in the range jumps out at me. :( I guess I'll see if I can reproduce locally...
It fails to work either way, enabled or disabled.
So this thing actually needs a whole bunch of personal information... If either one of you has a "throwaway" account, want to mail me the login info for it? If not I guess I'll set one up...
Boris, sent you an email. Happy hunting.
The first bad revision is: changeset: 36324:b20cff5e2157 user: Masayuki Nakano <masayuki@d-toybox.com> date: Thu Dec 17 13:46:30 2009 +0900 summary: Bug 535041 Crash [@ nsContentUtils::IsInSameAnonymousTree] r=Olli In the failing build, the editor has no mRootContent for a bit and probably fails to init properly...
Blocks: 535041
blocking2.0: --- → ?
Component: JavaScript Engine → Editor
Keywords: regression
QA Contact: general → editor
see url for minimal test case of http://vip.asus.com/forum/default.aspx?SLanguage=en-us seems the root element replacing cannot be handled correctly.
Attached patch Patch v1.0 (obsolete) — Splinter Review
I'll create automated test for this bug ASAP.
Assignee: nobody → masayuki
Status: NEW → ASSIGNED
Attached patch Patch v2.0 (obsolete) — Splinter Review
Attachment #426819 - Attachment is obsolete: true
Why do you need to check for a null aContainer in ContentAppended? Also, why is it ok to bail out if a textnode followed by an element is appended?
(In reply to comment #19) > Why do you need to check for a null aContainer in ContentAppended? I'm not sure whether aContainer must not be null. Is that guaranteed? > Also, why is it ok to bail out if a textnode followed by an element is > appended? Because mRootElement must be a body element or the document root node or an anonymous div element. Is there a case that a text node can be root node?
> I'm not sure whether aContainer must not be null. Is that guaranteed? http://hg.mozilla.org/mozilla-central/annotate/ed7d1a491a8e/content/base/public/nsIMutationObserver.h#l180 says: 180 * @param aContainer The container that had new children appended. Is never 181 * null. So yes, it is guaranteed. > Is there a case that a text node can be root node? No, but why should a <body> not be a root node just because there's some whitespace before it?
Attached file Patch v2.0 + testcases (obsolete) —
Sorry for the delay. I'll check the bz's comment. The automated tests cannot pass yet. The *first* test failed at IME state checking. And 5th test failed, the editor isn't editable and there is unknown br node. I'll check it next week.
Attachment #426821 - Attachment is obsolete: true
Attached patch Patch v2.0 + testcases (obsolete) — Splinter Review
sorry for the spam.
Attachment #429107 - Attachment is obsolete: true
Note for my self: Need to get nsIEditor and should check whether the root element of it is expected or not.
I need to fix bug 544277 first, that is one of the causes of test failure.
blocking2.0: ? → final+
Priority: -- → P2
Might I inquire when this will land on Trunk.
Masayuki, with bug 544277 fixed, is this patch ready for review?
No, the patch failed some tests, I need more work.
Attached patch Patch v3.0 (obsolete) — Splinter Review
This fixes most part of this bug. However, there are still two problems. 1. Caret isn't visible when set focus to the editor. 2. First character of IME composition is forcedly committed.
Attachment #429108 - Attachment is obsolete: true
Attached patch Patch v4.0Splinter Review
The basic concept is that nsHTMLEditor should store the best mRootElement every time. The patch checks whether a better root element is inserted or appended to the DOM tree. If it's inserted or appended, this patch reintialize the selection and caret. For simplizing the code, this patch moves the mutation event handler from nsEditor to nsHTMLEditor. This should helps the plain text editor's footprint and performance.
Attachment #450019 - Attachment is obsolete: true
Attachment #450990 - Flags: review?(ehsan)
NOTE: I want to test the patch with latest code, but tryserver aborts the transaction today... > pushing to ssh://hg.mozilla.org/try/ > searching for changes > remote: adding changesets > remote: adding manifests > remote: adding file changes > remote: added 1 changesets with 0 changes to 7 files (+1 heads) > remote: pulling from /repo/hg/mozilla/try > remote: searching for changes > remote: adding changesets > remote: adding manifests > remote: adding file changes > remote: transaction abort! > remote: rollback completed > remote: abort: Permission denied: /repo/hg/mozilla/try_vcview/.hg/store/data/editor/libeditor/html/tests/test__root__element__replacement.html.i > remote: warning: changegroup.z_push_to_vcview hook exited with status 255 The patch worked fine on trysever a week ago.
okay, tryserver is back now. I posted the patch to it.
(In reply to comment #31) > NOTE: I want to test the patch with latest code, but tryserver aborts the > transaction today... > > > pushing to ssh://hg.mozilla.org/try/ > > searching for changes > > remote: adding changesets > > remote: adding manifests > > remote: adding file changes > > remote: added 1 changesets with 0 changes to 7 files (+1 heads) > > remote: pulling from /repo/hg/mozilla/try > > remote: searching for changes > > remote: adding changesets > > remote: adding manifests > > remote: adding file changes > > remote: transaction abort! > > remote: rollback completed > > remote: abort: Permission denied: /repo/hg/mozilla/try_vcview/.hg/store/data/editor/libeditor/html/tests/test__root__element__replacement.html.i > > remote: warning: changegroup.z_push_to_vcview hook exited with status 255 > > The patch worked fine on trysever a week ago. You might want to file a releng bug about that.
Comment on attachment 450990 [details] [diff] [review] Patch v4.0 So, I have two questions about this patch: 1. Is it safe to move the mutation observer to the HTML editor? Does this handle mutations to the textnode under a textarea correctly? 2. This patch contains a bunch of refactoring, which makes seeing the actual approach to fixing the problem extremely hard. Could you describe what your approach to the fix was, sans the refactorings? Are the refactorings necessary for the fix? If not, then could you please split them in a separate patch? This is needed for branch, and in its current form, this patch really scares me for branch consideration.
nsPlaintextEditor doesn't use the mutation event. I'm not sure why many features of nsHTMLEditor has been implemented in nsEditor rather than nsHTMLEditor. O.K., I'll post separated patches, but I don't want to separate bugs because I tested this patch well. And this shouldn't be needed on branch because this is a regression of bug 535041.
(In reply to comment #35) > nsPlaintextEditor doesn't use the mutation event. I'm not sure why many > features of nsHTMLEditor has been implemented in nsEditor rather than > nsHTMLEditor. But the ContentInserted and ContentRemoved methods do things which seem relevant to the plaintext editor as well... > O.K., I'll post separated patches, but I don't want to separate bugs because I > tested this patch well. Great, thanks! > And this shouldn't be needed on branch because this is a regression of bug > 535041. Ah, you're right; sorry. I took this for bug 543077! :-)
(In reply to comment #36) > (In reply to comment #35) > > nsPlaintextEditor doesn't use the mutation event. I'm not sure why many > > features of nsHTMLEditor has been implemented in nsEditor rather than > > nsHTMLEditor. > > But the ContentInserted and ContentRemoved methods do things which seem > relevant to the plaintext editor as well... mRootElement is initialized by nsEditor::Init() called by nsTextEditorState::PrepareEditor(). http://mxr.mozilla.org/mozilla-central/source/content/html/content/src/nsTextEditorState.cpp#1157 Then, the root node is anonymous div. http://mxr.mozilla.org/mozilla-central/source/content/html/content/src/nsTextEditorState.cpp#1439 And this is never modified when the editor is alive. So, nsEditor::ContentInserted() does nothing. And nsEditor::ContentRemoved()'s element == mRootElement always false. The mutation observer was implemented for bug 335856 which is a HTML editor bug like this.
This patch separates the GetRootElement() to nsEditor::GetRootElement() and nsHTMLEditor::GetRootElement(). This makes clearer.
Attachment #451258 - Flags: review?(ehsan)
This patch guarantees the result of GetPIDOMEventTarget() is current event target which listens the events.
Attachment #451259 - Flags: review?(ehsan)
This patch moves selection and caret initializing code from nsEditorEventListener::Focus() to nsEditor. The new method will be called when the editor root element will be replaced.
Attachment #451260 - Flags: review?(ehsan)
This patch moves the mutation observer from nsEditor to nsHTMLEditor. By this patch, the next patch can fix this bug by changing only nsHTMLEditor.
Attachment #451261 - Flags: review?(ehsan)
Attached patch Patch v4.0 pat.5 fix this bug (obsolete) — Splinter Review
Just fix this bug.
Attachment #451262 - Flags: review?(ehsan)
Attachment #450990 - Flags: review?(ehsan)
Attached patch Patch v4.0 pat.5 fix this bug (obsolete) — Splinter Review
sorry for the spam.
Attachment #451262 - Attachment is obsolete: true
Attachment #451263 - Flags: review?(ehsan)
Attachment #451262 - Flags: review?(ehsan)
Attachment #451258 - Flags: review?(ehsan) → review+
Comment on attachment 451259 [details] [diff] [review] Patch v4.0 part.2 Refactor GetPIDOMEventTarget() This is definitely an improvement over what we have right now, but let's put plaintext editor's GetPIDOMEventTarget logic in nsPlaintextEditor, now that we're putting the rest in nsHTMLEditor.
Attachment #451259 - Flags: review?(ehsan) → review-
Attachment #451260 - Flags: review?(ehsan) → review+
(In reply to comment #37) > (In reply to comment #36) > > (In reply to comment #35) > > > nsPlaintextEditor doesn't use the mutation event. I'm not sure why many > > > features of nsHTMLEditor has been implemented in nsEditor rather than > > > nsHTMLEditor. > > > > But the ContentInserted and ContentRemoved methods do things which seem > > relevant to the plaintext editor as well... > > mRootElement is initialized by nsEditor::Init() called by > nsTextEditorState::PrepareEditor(). > http://mxr.mozilla.org/mozilla-central/source/content/html/content/src/nsTextEditorState.cpp#1157 > Then, the root node is anonymous div. > http://mxr.mozilla.org/mozilla-central/source/content/html/content/src/nsTextEditorState.cpp#1439 So, as of bug 534785, a plaintext editor control now can be initialized multiple times (i.e., sequences of Init, PreDestroy, Init, PreDestroy, ... calls). Given that, mRootElement can actually change. How does that affect your assessment above?
Attachment #451261 - Flags: review?(ehsan)
Comment on attachment 451263 [details] [diff] [review] Patch v4.0 pat.5 fix this bug >+void >+nsHTMLEditor::ResetRootElementAndEventTarget() >+{ >+ // Need to remove the event listeners first because BeginningOfDocument >+ // could set a new root (and event target is set by InstallEventListeners()) >+ // and we won't be able to remove them from the old event target then. >+ RemoveEventListeners(); >+ mRootElement = nsnull; >+ nsresult rv = InstallEventListeners(); >+ if (NS_FAILED(rv) || !mRootElement) { >+ return; >+ } Could you add a warning here? >+ rv = BeginningOfDocument(); >+ if (NS_FAILED(rv)) { >+ return; >+ } Please use: NS_ENSURE_SUCCESS(rv, ) >+nsINode* >+nsHTMLEditor::GetFocusedNode() >+{ >+ if (!HasFocus()) { >+ return nsnull; >+ } >+ >+ nsIFocusManager* fm = nsFocusManager::GetFocusManager(); >+ NS_ASSERTION(fm, "Focus manager is null"); >+ nsCOMPtr<nsIDOMElement> focusedElement; >+ fm->GetFocusedElement(getter_AddRefs(focusedElement)); >+ if (focusedElement) { >+ nsCOMPtr<nsINode> node = do_QueryInterface(focusedElement); >+ return node; >+ } >+ >+ nsCOMPtr<nsIDocument> doc = do_QueryReferent(mDocWeak); >+ return doc; >+} The way that this function returns the pointer after releasing it is not safe. The returned pointers can be dangling. >+SimpleTest.waitForFocus(runTest, window); You can drop window here. >+ is(content.nodeType, 3, >+ "the content of body isn't text node -- " + kTest.description); Can you use the named constant instead of 3 here?
Attachment #451263 - Flags: review?(ehsan) → review-
(In reply to comment #45) > So, as of bug 534785, a plaintext editor control now can be initialized > multiple times (i.e., sequences of Init, PreDestroy, Init, PreDestroy, ... > calls). > > Given that, mRootElement can actually change. How does that affect your > assessment above? PreDestroy() uninstalls the mutation observer. So, my patch shouldn't change any behavior of the case. If the root element is replaced druing Init() and PreDestroy(), my patch is wrong. However, mRootElement shouldn't be replaced at that time because it's only reset in Init() and GetRoot(). But GetRoot() doesn't have code for plaintext editor. The logic is for HTML editor.
Attachment #451261 - Flags: review+
I'm not sure this is better than the previous one because the boundary of nsEditor and nsPlaintextEditor isn't clear. This patch needs to change nsEditor::InstallEventListener() too. Ideally, we should unify nsEditor and nsPlaintextEditor in future.
Attachment #451259 - Attachment is obsolete: true
Attachment #451544 - Flags: review?(ehsan)
Attached patch Patch v4.1 pat.5 fix this bug (obsolete) — Splinter Review
Attachment #451263 - Attachment is obsolete: true
Attachment #451546 - Flags: review?(ehsan)
Attachment #451544 - Flags: review?(ehsan) → review+
Comment on attachment 451546 [details] [diff] [review] Patch v4.1 pat.5 fix this bug Looks good, but it would be great if you can address my first two nits in comment 46 before landing.
Attachment #451546 - Flags: review?(ehsan) → review+
(In reply to comment #51) > (From update of attachment 451546 [details] [diff] [review]) > Looks good, but it would be great if you can address my first two nits in > comment 46 before landing. Oops, sorry. I'll post the patch soon.
Sorry, using NS_ENSURE_* for them.
Attachment #451546 - Attachment is obsolete: true
Attachment #451640 - Flags: review?(ehsan)
Comment on attachment 451640 [details] [diff] [review] Patch v4.2 part.5 fix this bug Thanks! The reasons that I think we should use NS_ENSURE macros here is that they are easier to read, and they print a warning to the console if their condition is not satisfied in debug builds.
Attachment #451640 - Flags: review?(ehsan) → review+
There still is a problem with editing on the Asus site. 1. There is no insert cursor in the text area until you start typing 2. More importantly when you submit what you typed you get a response that indicates nothing was typed in.
Status: RESOLVED → REOPENED
Resolution: FIXED → ---
Sorry, there is a mistake. mRootElement is initialized by BeginningOfDocument() (it calls GetRoot()). For future changes, ResetRootElementAndEventTarget() should call GetRoot() directly. And I'm not sure the second issue. It should be out of scope of this bug if this patch doesn't fix it.
Attachment #451980 - Flags: review?(ehsan)
Attachment #451980 - Flags: review?(ehsan) → review+
Ugh, the patch creates new assertions on crashtests. > ###!!! ASSERTION: No first node!: 'mFirst', file m:/mozilla-o/src/content/base/src/nsContentIterator.cpp, line 920 > xul!nsFilteredContentIterator::First+0x0000000000000082 (m:\mozilla-o\src\editor\txtsvc\src\nsfilteredcontentiterator.cpp, line 180) > xul!nsTextServicesDocument::FirstTextNode+0x0000000000000022 (m:\mozilla-o\src\editor\txtsvc\src\nstextservicesdocument.cpp, line 3445) > xul!nsTextServicesDocument::FirstBlock+0x0000000000000056 (m:\mozilla-o\src\editor\txtsvc\src\nstextservicesdocument.cpp, line 509) > xul!nsTextServicesDocument::InitWithEditor+0x0000000000000245 (m:\mozilla-o\src\editor\txtsvc\src\nstextservicesdocument.cpp, line 228) > xul!mozInlineSpellChecker::SetEnableRealTimeSpell+0x0000000000000338 (m:\mozilla-o\src\extensions\spellcheck\src\mozinlinespellchecker.cpp, line 742) > xul!nsEditor::SyncRealTimeSpell+0x000000000000007B (m:\mozilla-o\src\editor\libeditor\base\nseditor.cpp, line 1289) > xul!nsHTMLEditor::ResetRootElementAndEventTarget+0x0000000000000251 (m:\mozilla-o\src\editor\libeditor\html\nshtmleditor.cpp, line 5901) When we create a content iterator with empty body document, the iterator outputs the assertion at First(). I think that the iterator user cannot check whether the iterator has contents or not. Therefore, I think that it isn't good behavior. http://mxr.mozilla.org/mozilla-central/source/content/base/src/nsContentIterator.cpp#920
Attachment #452271 - Flags: review?(roc)
Status: REOPENED → RESOLVED
Closed: 14 years ago14 years ago
Resolution: --- → FIXED
(In reply to comment #56) > There still is a problem with editing on the Asus site. > > 1. There is no insert cursor in the text area until you start typing > > 2. More importantly when you submit what you typed you get a response that > indicates nothing was typed in. FYI BOTH problems were fixed with this update. Good job.
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: