Re: NSTypesetter problem
Re: NSTypesetter problem
- Subject: Re: NSTypesetter problem
- From: chaitanya pandit <email@hidden>
- Date: Thu, 4 Dec 2008 16:15:45 +0530
Hi,
Okay so i have been debugging the problem for some time now and i find
a weird thing happening.
Usually, the proposed rect that is passed to the text container in the
lineFragmentRectForProposedRect: method has either very large width or
extends to the right edge of the text container.
But i observed that some times i get a proposed like X=25; Y=18;
Width=120; Height=14 even though i didn't return this as the remaining
rect in the last call. I don't understand why it's X=25 instead of
being 0.
Also Some times i get a NSZeroRect as the proposed rect.
Do you have any idea as in which cases the typesetter might call with
such a proposed rect?
Also considering the above mentioned rect, say my container width is
400, but there is a hole in the text container that will intersect the
proposed rect say the square hole has X=55; and Width=50
In this case should i divide proposed rect as:
rectToReturn : X=25; Y=18; Width=30; Height=14 rectRemained = X=105;
Y=18; Width=15; Height=14
Or the rectRemained should extend till the right edge of the text
container.
I'd appreciate any help.
Thanks,
Chaitanya
On 26-Nov-08, at 12:55 AM, Aki Inoue wrote:
The recursive invocation of layout is being trigged because the info
between layout manager and text view got out of sync.
Does it still reproduce when you remove your overridden method ?
Also, I wonder if the infinite recursion is related to the initial
recursive layout invocation at all.
Can you provide the bt of the final infinite recursion ?
Aki
On 2008/11/25, at 1:19, chaitanya pandit wrote:
Actually i'm doing nothing special in setLineFragmentRect... i
simply note the fragment and call super's setLineFragmentRect...
What i observed is that the a new typesetter gets initialized only
when i try to edit the text, and then it goes in to an infinite loop
On 25-Nov-08, at 12:35 AM, Aki Inoue wrote:
NSATSTypesetter trying to create a new instance is a normal
behavior.
When the typesetter detects it's being invoked to layout
recursively, it instantiates a copy.
The real culprit here is probably at #15 -[TTypesetter
setLineFragmentRect:forGlyphRange:usedRect:baselineOffset:]
that's triggering the recursive layout.
Aki
On 2008/11/23, at 22:45, chaitanya pandit wrote:
In my application i have an NSTextView with custom
NSTextContainer and also a custom NSTypesetter, i have a problem
with displaying HTML stuff in the textView.
I copied and pasted the entire contents of an html page ( it was
news.google.com to be precise), it displays it fine, but whenever
i try to edit the text contents, my app goes into an infinite loop.
While debugging i observed a very weird thing, a new typesetter
is getting initialized within the
"layoutCharactersInRange:forLayoutManager:maximumNumberOfLineFragments
" method.
Any idea about what might be going wrong?
I'd appreciate any help.
Here is the trace(note the #0):
#0 0x00077a35 in -[TTypesetter init] at TTypesetter.m:25
#1 0x907691a9 in -[NSATSTypesetter
layoutCharactersInRange:forLayoutManager:maximumNumberOfLineFragments
:]
#2 0x00077c08 in -[TTypesetter
layoutCharactersInRange:forLayoutManager:maximumNumberOfLineFragments
:] at TTypesetter.m:95
#3 0x90455f77 in -[NSLayoutManager(NSPrivate)
_fillLayoutHoleForCharacterRange:desiredNumberOfLines:isSoft:]
#4 0x905953b6 in _NSFastFillAllLayoutHolesForGlyphRange
#5 0x9051e0ba in -[NSLayoutManager(NSPrivate)
_firstPassGlyphRangeForBoundingRect:inTextContainer:okToFillHoles:]
#6 0x9051cff1 in -[NSLayoutManager(NSPrivate)
_glyphRangeForBoundingRect:inTextContainer:fast:okToFillHoles:]
#7 0x9051ce27 in -[NSLayoutManager
glyphRangeForBoundingRect:inTextContainer:]
#8 0x9051c35e in -[NSTextView
setNeedsDisplayInRect:avoidAdditionalLayout:]
#9 0x9051be8b in -[NSTextView setNeedsDisplayInRect:]
#10 0x903be662 in -[NSView setNeedsDisplay:]
#11 0x9051cb82 in -[NSTextView textContainerOrigin]
#12 0x90521b8f in -[NSLayoutManager(NSPrivate)
_resizeTextViewForTextContainer:]
#13 0x90406ed0 in -[NSLayoutManager(NSPrivate)
_updateUsageForTextContainer:addingUsedRect:]
#14 0x9045be46 in -[NSLayoutManager
setLineFragmentRect:forGlyphRange:usedRect:]
#15 0x00078688 in -[TTypesetter
setLineFragmentRect:forGlyphRange:usedRect:baselineOffset:] at
TTypesetter.m:325
#16 0x90420776 in -[NSATSTypesetter
_layoutLineFragmentStartingWithGlyphAtIndex:characterIndex:atPoint:renderingContext
:]
#17 0x904583db in -[NSATSTypesetter layoutParagraphAtPoint:]
#18 0x00077ba8 in -[TTypesetter layoutParagraphAtPoint:] at
TTypesetter.m:86
#19 0x90400bcd in -[NSTypesetter
_layoutGlyphsInLayoutManager:startingAtGlyphIndex:maxNumberOfLineFragments:maxCharacterIndex:nextGlyphIndex:nextCharacterIndex
:]
#20 0x909ed6f6 in -[NSTypesetter
layoutCharactersInRange:forLayoutManager:maximumNumberOfLineFragments
:]
#21 0x90769238 in -[NSATSTypesetter
layoutCharactersInRange:forLayoutManager:maximumNumberOfLineFragments
:]
#22 0x00077c08 in -[TTypesetter
layoutCharactersInRange:forLayoutManager:maximumNumberOfLineFragments
:] at TTypesetter.m:95
#23 0x90455f77 in -[NSLayoutManager(NSPrivate)
_fillLayoutHoleForCharacterRange:desiredNumberOfLines:isSoft:]
#24 0x905953b6 in _NSFastFillAllLayoutHolesForGlyphRange
#25 0x90548225 in -[NSTextView(NSPrivate)
_ensureLayoutCompleteToEndOfCharacterRange:]
#26 0x90547c81 in -[NSTextView(NSSharing) didChangeText]
#27 0x90543ea2 in -[NSTextView insertText:replacementRange:]
#28 0x905433d3 in -[NSTextView insertText:]
#29 0x90542efa in -
[NSKeyBindingManager(NSKeyBindingManager_MultiClients)
flushTextForClient:]
#30 0x9054144f in -[NSTSMInputContext interpretKeyEvents:]
#31 0x90540f1a in -[NSView interpretKeyEvents:]
#32 0x90540e2a in -[NSTextView keyDown:]
#33 0x904b13a5 in -[NSWindow sendEvent:]
#34 0x9047d311 in -[NSApplication sendEvent:]
#35 0x903dad0f in -[NSApplication run]
#36 0x903a7f14 in NSApplicationMain
#37 0x000029b0 in main at main.m:12
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the
list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden