Open Bug 676519 Opened 13 years ago Updated 2 years ago

Refactor the common code between nsHTMLTextAreaElement and nsHTMLInputElement into a common base class

Categories

(Core :: DOM: Core & HTML, defect, P5)

defect

Tracking

()

People

(Reporter: ehsan.akhgari, Unassigned)

Details

There are tons of methods in these two classes which are basically copies of each other, except for the extra check in nsHTMLInputElement to make sure that we're dealing with a text input element.  These methods can probably be refactored into a common base class.
I guess we could have a nsTextControlElement class that would inherit from nsITextControlElement and actually implement it. nsHTMLInputElement and nsHTMLTextAreaElement would inherit from nsTextControlElement instead of nsITextControlElement.
Does that make sense?
OS: Mac OS X → All
Hardware: x86 → All
(In reply to Mounir Lamouri (:volkmar) from comment #1)
> I guess we could have a nsTextControlElement class that would inherit from
> nsITextControlElement and actually implement it. nsHTMLInputElement and
> nsHTMLTextAreaElement would inherit from nsTextControlElement instead of
> nsITextControlElement.
> Does that make sense?

Yeah.  We just need to decide how to handle the case of input elements which are not text controls somehow.  The current way that we do this is sucky and makes my eyes bleed every time that I read nsHTMLInputElement.cpp.  WebKit also does something like this (they have a class called HTMLTextFormControlElement).  I wish there was a better way for modeling this in C++ :(
Priority: -- → P5
Severity: normal → S3
You need to log in before you can comment on or make changes to this bug.