Closed Bug 50998 Opened 25 years ago Closed 23 years ago

XP impl of GetAveCharWidth and remove ifdef _win32 in GfxText

Categories

(Core :: Layout: Form Controls, defect, P2)

defect

Tracking

()

RESOLVED FIXED
Future

People

(Reporter: rods, Assigned: john)

References

Details

(Whiteboard: [FIX])

Attachments

(6 files, 6 obsolete files)

I need to remove the ifdef _WIN32 in nsGfxTextControlFrame2.cpp and implement a cross platform GetAveCharWidth
Status: NEW → ASSIGNED
Priority: P3 → P2
Target Milestone: --- → Future
Engineering reminder. Reassigning to rods.
QA Contact: ckritzer → rods
Blocks: 36146
This really needs to be done for this release
Priority: P2 → P1
Target Milestone: Future → ---
I am all for that r=rods
looks ok to me. sr=buster. rod, are there other places that need this, or is this sufficient?
Other than the OS/2 impl that is it, it is good to go.
Opps, good catch. r=rods
Target Milestone: --- → mozilla1.0.1
Target Milestone: mozilla1.0.1 → Future
Priority: P1 → P2
OK, so the way to fix this is to make GetAveCharWidth work on all our ports using a cross-platform GetAveCharWidth. People can replace them with Real Ones at a later date if the platform supports them (I'll put big comments in there saying it's fake and that they should use a platform-specific one if available). Taking.
Status: ASSIGNED → NEW
Er, taking again
Assignee: rods → jkeiser
Status: NEW → ASSIGNED
jkeiser, it's diffcult for us to implement all GetAve for beos/QT/mac/photon. i'd better to add it on nsIFontMetrics first, then ask people who know the platform implement it. i know only qt, so i have implent the one for qt. what do you think?
Attached patch qt implementation (obsolete) — Splinter Review
in all 10 toolkit: implemented already: windows os/2 xlib gtk not implemented yet: mac, photon, beos, QT the patch is for QT. And we still need *****Mac, BeOS, Photon*******. if you can do it, we need ur help. Thanks. when we get patchs for all 3, we can get to change the nsIFontMetrics ...
Rick: for the rest of them, you can just do the same thing we do for GTK, namely measure the character 'x'. I think that is a better XP implementation (and faster) than the one in nsTextControlFrame anyway. And it will keep our platforms relatively similar to each other. If there is a real AveCharWidth call on the platform of course, it is better to use that.
Attached patch Mac implSplinter Review
using 'x'
Attached patch photon impl (obsolete) — Splinter Review
there was a mAveCharWidth = mSpaceWidth already. adding GetAveCharWidth only
Attached patch beos implSplinter Review
using 'x'
removed the #if (_WIN32) || ...
terribly sorry that i can't find all the build env for these platforms to test these patch . add some masters of gfx. HELP needed: 1. pls check the code and check whether better impl exists. i am not familiar with most these platforms. 2. i dont have env to test them. pls kindly test them if u do. thanks!
These patches look alright to me, sr=rbs on all. There is a remaining cleanup of #if defined(_WIN32) || defined(XP_OS2) in mozilla/layout/html/forms/src/nsGfxTextControlFrame.cpp While there, also saw a code that computes 'NSToCoordRound(p2t)' too many times (caming from the patch in bug 99948): // round to a multiple of p2t nscoord rest = internalPadding%NSToCoordRound(p2t); if( rest < NSToCoordRound(p2t) - rest) { internalPadding = internalPadding - rest; } else { internalPadding = internalPadding + NSToCoordRound(p2t) - rest; } While you are there, mind cleaning up that code a little bit, e.g., use: nscoord t = NSToCoordRound(p2t); nscoord rest = internalPadding % t; if( rest < t - rest) { // same as rest < half-of-pixel internalPadding -= rest; // round down } else { internalPadding += t - rest; // round up }
OS: Windows NT → All
Hardware: PC → All
thanks, rbs. About nsGfxTextControlFrame.cpp: Do u mean nsTextControlFrame.cpp? The file is why i fix this bug. pls refer to #92980. Tnanks for ur comments about NSToCoordRound. i will do it in #92980's patch.
> Do u mean nsTextControlFrame.cpp? Yes. I typed one of the old names. > The file is why i fix this bug. pls refer to #92980. > Tnanks for ur comments about NSToCoordRound. i will do it in #92980's patch. OK.
Blocks: 92980
Comment on attachment 98566 [details] [diff] [review] qt implementation fm.widht won't compile--fm.width is better :)
Attached patch Fix nsTextFrameSplinter Review
This makes nsTextFrame use GetAveCharWidth() always instead of guessing that the average width is 10 :) nsTextControlFrame will get its update when Rick checks in his patch to that bug.
Comment on attachment 99462 [details] [diff] [review] photon impl hm... currently, mAveCharWidth of the photon port contains the width of a space rather than an 'x' like the other ports. as that variable is currently unused, I would change it to match the others.
Comment on attachment 98566 [details] [diff] [review] qt implementation + PRUnichar averageX = (PRUnichar)'x'; use QChar here, because that's what fm.width takes.
r=biesi on all patches if my comments are addressed (and the width typo gets fixed) however, you might want to get r=sergei_d@fi.tartu.ee or r=arougthopher@lizardland.net for the BeOS patch instead, as they are the ports maintainers, afaik
rbs, could you sr the "Fix nsTextFrame" patch as well? It seems best to get it checked in now or it will be one of those "yeah, we need to do that but we won't until Gecko 3.0" things :)
Comment on attachment 99540 [details] [diff] [review] Fix nsTextFrame sr=rbs
Attachment #99540 - Flags: superreview+
Comment on attachment 98566 [details] [diff] [review] qt implementation >Index: nsFontMetricsQT.h >=================================================================== >RCS file: /cvsroot/mozilla/gfx/src/qt/nsFontMetricsQT.h,v >retrieving revision 1.8 >diff -u -r1.8 nsFontMetricsQT.h >--- nsFontMetricsQT.h 30 Oct 2001 22:57:49 -0000 1.8 >+++ nsFontMetricsQT.h 10 Sep 2002 09:17:04 -0000 >@@ -138,6 +138,7 @@ > NS_IMETHOD GetMaxAscent(nscoord &aAscent); > NS_IMETHOD GetMaxDescent(nscoord &aDescent); > NS_IMETHOD GetMaxAdvance(nscoord &aAdvance); >+ NS_IMETHOD GetAveCharWidth(nscoord &aAveCharWidth); > NS_IMETHOD GetFont(const nsFont *&aFont); > NS_IMETHOD GetLangGroup(nsIAtom** aLangGroup); > NS_IMETHOD GetFontHandle(nsFontHandle &aHandle); >@@ -201,6 +202,7 @@ > nscoord mMaxAscent; > nscoord mMaxDescent; > nscoord mMaxAdvance; >+ nscoord mAveCharWidth; > nscoord mXHeight; > nscoord mSuperscriptOffset; > nscoord mSubscriptOffset; >Index: nsFontMetricsQT.cpp >=================================================================== >RCS file: /cvsroot/mozilla/gfx/src/qt/nsFontMetricsQT.cpp,v >retrieving revision 1.25 >diff -u -r1.25 nsFontMetricsQT.cpp >--- nsFontMetricsQT.cpp 7 Sep 2002 17:10:09 -0000 1.25 >+++ nsFontMetricsQT.cpp 10 Sep 2002 09:17:05 -0000 >@@ -644,6 +644,7 @@ > mMaxAscent = 0; > mMaxDescent = 0; > mMaxAdvance = 0; >+ mAveCharWidth = 0; > mXHeight = 0; > mSuperscriptOffset = 0; > mSubscriptOffset = 0; >@@ -913,6 +914,9 @@ > mEmHeight = nscoord(fm.height() * f); > mMaxAdvance = nscoord(fm.maxWidth() * f); > >+ PRUnichar averageX = (PRUnichar)'x'; >+ mAveCharWidth = nscoord(fm.width(averageX) * f); >+ > mEmAscent = mMaxAscent; > mEmDescent = mMaxDescent; > >@@ -1022,6 +1026,12 @@ > NS_IMETHODIMP nsFontMetricsQT::GetMaxAdvance(nscoord &aAdvance) > { > aAdvance = mMaxAdvance; >+ return NS_OK; >+} >+ >+NS_IMETHODIMP nsFontMetricsQT::GetAveCharWidth(nscoord &aAveCharWidth) >+{ >+ aAveCharWidth = mAveCharWidth; > return NS_OK; > } >
Attached patch new qt impl ( widht -> width ) (obsolete) — Splinter Review
Attachment #98566 - Attachment is obsolete: true
Attachment #99603 - Attachment is obsolete: true
Attachment #99463 - Flags: review+
Comment on attachment 99463 [details] [diff] [review] beos impl seems ok. Ohh, and i missed when AveCharWidth changed to "x" width instead of Finnish developer name-based :)
ok, new patches look good to me. r=biesi on all non-obsolete patches here. looks like you're ready to checkin.
I will check in. I don't think Rick has cvs access yet.
Whiteboard: [FIX]
Attachment #99462 - Attachment is obsolete: true
Fix checked in. Let's see what this does to ports before resolving ;)
Well, that went alarmingly smoothly. Yippee, fix checked in to stay!
Status: ASSIGNED → RESOLVED
Closed: 23 years ago
Resolution: --- → FIXED
Blocks: 166758
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: