163594 patch by mloiselle@yahoo.com r+sr=roc+moz HR is highlighted by single click in browser (horizontal ruler) (select)

This commit is contained in:
cbiesinger%web.de 2003-04-03 19:25:25 +00:00
parent 1cabc01e87
commit 752bca3b4a

View File

@ -51,6 +51,8 @@
#include "nsCSSRendering.h"
#include "nsLayoutAtoms.h"
#include "nsILookAndFeel.h"
#include "nsIEventStateManager.h"
#include "nsIView.h"
// default hr thickness in pixels
#define DEFAULT_THICKNESS 3
@ -70,6 +72,14 @@ public:
PRUint32 aFlags);
NS_IMETHOD GetFrameType(nsIAtom** aType) const;
NS_IMETHOD
GetContentAndOffsetsFromPoint(nsIPresContext* aPresContenxt,
const nsPoint& aPoint,
nsIContent ** aNewContent,
PRInt32& aContentOffset,
PRInt32& aContentOffsetEnd,
PRBool& aBeginFrameContent);
virtual PRBool CanPaintBackground() { return PR_FALSE; }
protected:
@ -358,3 +368,51 @@ HRuleFrame::GetFrameType(nsIAtom** aType) const
NS_ADDREF(*aType);
return NS_OK;
}
NS_IMETHODIMP
HRuleFrame::GetContentAndOffsetsFromPoint(nsIPresContext* aPresContext,
const nsPoint& aPoint,
nsIContent ** aNewContent,
PRInt32& aContentOffset,
PRInt32& aContentOffsetEnd,
PRBool& aBeginFrameContent)
{
nsresult rv = NS_ERROR_FAILURE;
if (!aNewContent) return NS_ERROR_NULL_POINTER;
if (!mContent) return NS_ERROR_NULL_POINTER;
nsIView *view = nsnull;
rv = GetClosestViewForFrame(aPresContext, this, &view);
if (NS_FAILED(rv)) return rv;
nsRect thisRect;
rv = GetRect(thisRect);
if (NS_FAILED(rv)) return rv;
nsPoint offsetPoint;
GetOffsetFromView(aPresContext, offsetPoint, &view);
thisRect.x = offsetPoint.x;
thisRect.y = offsetPoint.y;
rv = mContent->GetParent(*aNewContent);
if (!*aNewContent) return rv;
rv = (*aNewContent)->IndexOf(mContent, aContentOffset);
if (NS_FAILED(rv)) return rv;
if (aContentOffset < 0) return NS_ERROR_FAILURE;
aBeginFrameContent = PR_TRUE;
aContentOffsetEnd = aContentOffset;
if (thisRect.Contains(aPoint))
{
nsCOMPtr<nsIPresShell> shell;
aPresContext->GetShell(getter_AddRefs(shell));
if (!shell) return NS_ERROR_FAILURE;
PRInt16 isEditor = 0;
shell->GetSelectionFlags(&isEditor);
isEditor = isEditor == nsISelectionDisplay::DISPLAY_ALL;
if (isEditor) aContentOffsetEnd++; // this allows a single click to select the HR but only in Editor mode
}
return NS_OK;
}