From 3bfe67cad5bcdbac351c8aebac2282a6563ccd0d Mon Sep 17 00:00:00 2001 From: kipp Date: Sat, 25 Apr 1998 18:40:01 +0000 Subject: [PATCH] Repaired cursor discovery logic to handle A tag oddities git-svn-id: svn://10.0.0.236/trunk@654 18797224-902f-48f8-a5cc-f745e15eee43 --- .../layout/generic/nsHTMLContainerFrame.cpp | 34 +++++++++++++++---- .../html/base/src/nsHTMLContainerFrame.cpp | 34 +++++++++++++++---- 2 files changed, 56 insertions(+), 12 deletions(-) diff --git a/mozilla/layout/generic/nsHTMLContainerFrame.cpp b/mozilla/layout/generic/nsHTMLContainerFrame.cpp index 4b4aad7cea5..7ea228ca7b2 100644 --- a/mozilla/layout/generic/nsHTMLContainerFrame.cpp +++ b/mozilla/layout/generic/nsHTMLContainerFrame.cpp @@ -30,7 +30,6 @@ #include "nsIDocument.h" #include "nsIURL.h" -static NS_DEFINE_IID(kStyleMoleculeSID, NS_STYLEMOLECULE_SID); static NS_DEFINE_IID(kStyleBorderSID, NS_STYLEBORDER_SID); static NS_DEFINE_IID(kStyleColorSID, NS_STYLECOLOR_SID); @@ -136,16 +135,39 @@ NS_METHOD nsHTMLContainerFrame::GetCursorAt(nsIPresContext& aPresContext, nsIFrame** aFrame, PRInt32& aCursor) { - nsStyleMolecule* mol = (nsStyleMolecule*) - mStyleContext->GetData(kStyleMoleculeSID); - if (mol->cursor != NS_STYLE_CURSOR_INHERIT) { + // Get my cursor + nsStyleColor* styleColor = (nsStyleColor*) + mStyleContext->GetData(kStyleColorSID); + PRInt32 myCursor = styleColor->mCursor; + + // Get child's cursor, if any + nsresult rv = nsContainerFrame::GetCursorAt(aPresContext, aPoint, aFrame, + aCursor); + if (NS_OK != rv) return rv; + if (aCursor != NS_STYLE_CURSOR_INHERIT) { + nsIAtom* tag = mContent->GetTag(); + if (nsHTMLAtoms::a == tag) { + // Anchor tags override their child cursors in some cases. + if ((NS_STYLE_CURSOR_IBEAM == aCursor) && + (NS_STYLE_CURSOR_INHERIT != myCursor)) { + aCursor = myCursor; + } + } + NS_RELEASE(tag); + return rv; + } + + if (NS_STYLE_CURSOR_INHERIT != myCursor) { // If this container has a particular cursor, use it, otherwise // let the child decide. *aFrame = this; - aCursor = (PRInt32)mol->cursor; + aCursor = myCursor; return NS_OK; } - return nsContainerFrame::GetCursorAt(aPresContext, aPoint, aFrame, aCursor); + + // No specific cursor for us + aCursor = NS_STYLE_CURSOR_INHERIT; + return NS_OK; } #if 0 diff --git a/mozilla/layout/html/base/src/nsHTMLContainerFrame.cpp b/mozilla/layout/html/base/src/nsHTMLContainerFrame.cpp index 4b4aad7cea5..7ea228ca7b2 100644 --- a/mozilla/layout/html/base/src/nsHTMLContainerFrame.cpp +++ b/mozilla/layout/html/base/src/nsHTMLContainerFrame.cpp @@ -30,7 +30,6 @@ #include "nsIDocument.h" #include "nsIURL.h" -static NS_DEFINE_IID(kStyleMoleculeSID, NS_STYLEMOLECULE_SID); static NS_DEFINE_IID(kStyleBorderSID, NS_STYLEBORDER_SID); static NS_DEFINE_IID(kStyleColorSID, NS_STYLECOLOR_SID); @@ -136,16 +135,39 @@ NS_METHOD nsHTMLContainerFrame::GetCursorAt(nsIPresContext& aPresContext, nsIFrame** aFrame, PRInt32& aCursor) { - nsStyleMolecule* mol = (nsStyleMolecule*) - mStyleContext->GetData(kStyleMoleculeSID); - if (mol->cursor != NS_STYLE_CURSOR_INHERIT) { + // Get my cursor + nsStyleColor* styleColor = (nsStyleColor*) + mStyleContext->GetData(kStyleColorSID); + PRInt32 myCursor = styleColor->mCursor; + + // Get child's cursor, if any + nsresult rv = nsContainerFrame::GetCursorAt(aPresContext, aPoint, aFrame, + aCursor); + if (NS_OK != rv) return rv; + if (aCursor != NS_STYLE_CURSOR_INHERIT) { + nsIAtom* tag = mContent->GetTag(); + if (nsHTMLAtoms::a == tag) { + // Anchor tags override their child cursors in some cases. + if ((NS_STYLE_CURSOR_IBEAM == aCursor) && + (NS_STYLE_CURSOR_INHERIT != myCursor)) { + aCursor = myCursor; + } + } + NS_RELEASE(tag); + return rv; + } + + if (NS_STYLE_CURSOR_INHERIT != myCursor) { // If this container has a particular cursor, use it, otherwise // let the child decide. *aFrame = this; - aCursor = (PRInt32)mol->cursor; + aCursor = myCursor; return NS_OK; } - return nsContainerFrame::GetCursorAt(aPresContext, aPoint, aFrame, aCursor); + + // No specific cursor for us + aCursor = NS_STYLE_CURSOR_INHERIT; + return NS_OK; } #if 0