From 458fe99083710c7a7c117fdd4553efc31370327f Mon Sep 17 00:00:00 2001 From: "daniel%glazman.org" Date: Wed, 20 Oct 2004 15:24:11 +0000 Subject: [PATCH] fixes inconsistent selection schemes in HTML tables; b=261385, r=Neil, sr=roc --- content/base/src/nsSelection.cpp | 11 +++++++---- layout/generic/nsSelection.cpp | 11 +++++++---- 2 files changed, 14 insertions(+), 8 deletions(-) diff --git a/content/base/src/nsSelection.cpp b/content/base/src/nsSelection.cpp index b589610d0694..3aa80800d409 100644 --- a/content/base/src/nsSelection.cpp +++ b/content/base/src/nsSelection.cpp @@ -1290,7 +1290,7 @@ GetCellParent(nsIDOMNode *aDomNode) while(current) { tag = GetTag(current); - if (tag == nsHTMLAtoms::td) + if (tag == nsHTMLAtoms::td || tag == nsHTMLAtoms::th) return current; if (NS_FAILED(ParentOffset(current,getter_AddRefs(parent),&childOffset)) || !parent) return 0; @@ -3111,7 +3111,8 @@ nsSelection::FrameOrParentHasSpecialSelectionStyle(nsIFrame* aFrame, PRUint8 aSe static PRBool IsCell(nsIContent *aContent) { - return (aContent->Tag() == nsHTMLAtoms::td && + return ((aContent->Tag() == nsHTMLAtoms::td || + aContent->Tag() == nsHTMLAtoms::th) && aContent->IsContentOfType(nsIContent::eHTML)); } @@ -5961,7 +5962,8 @@ nsTypedSelection::FixupSelectionPoints(nsIDOMRange *aRange , nsDirection *aDir, dirtystart = PR_TRUE; cellMode = PR_FALSE; } - else if (atom == nsHTMLAtoms::td) //you are in "cell" mode put selection to end of cell + else if (atom == nsHTMLAtoms::td || + atom == nsHTMLAtoms::th) //you are in "cell" mode put selection to end of cell { cellMode = PR_TRUE; result = ParentOffset(tempNode, getter_AddRefs(startNode), &startOffset); @@ -6002,7 +6004,8 @@ nsTypedSelection::FixupSelectionPoints(nsIDOMRange *aRange , nsDirection *aDir, else found = PR_FALSE; //didnt find the right cell yet } - else if (atom == nsHTMLAtoms::td) //you are in "cell" mode put selection to end of cell + else if (atom == nsHTMLAtoms::td || + atom == nsHTMLAtoms::th) //you are in "cell" mode put selection to end of cell { result = ParentOffset(tempNode, getter_AddRefs(endNode), &endOffset); if (NS_FAILED(result)) diff --git a/layout/generic/nsSelection.cpp b/layout/generic/nsSelection.cpp index b589610d0694..3aa80800d409 100644 --- a/layout/generic/nsSelection.cpp +++ b/layout/generic/nsSelection.cpp @@ -1290,7 +1290,7 @@ GetCellParent(nsIDOMNode *aDomNode) while(current) { tag = GetTag(current); - if (tag == nsHTMLAtoms::td) + if (tag == nsHTMLAtoms::td || tag == nsHTMLAtoms::th) return current; if (NS_FAILED(ParentOffset(current,getter_AddRefs(parent),&childOffset)) || !parent) return 0; @@ -3111,7 +3111,8 @@ nsSelection::FrameOrParentHasSpecialSelectionStyle(nsIFrame* aFrame, PRUint8 aSe static PRBool IsCell(nsIContent *aContent) { - return (aContent->Tag() == nsHTMLAtoms::td && + return ((aContent->Tag() == nsHTMLAtoms::td || + aContent->Tag() == nsHTMLAtoms::th) && aContent->IsContentOfType(nsIContent::eHTML)); } @@ -5961,7 +5962,8 @@ nsTypedSelection::FixupSelectionPoints(nsIDOMRange *aRange , nsDirection *aDir, dirtystart = PR_TRUE; cellMode = PR_FALSE; } - else if (atom == nsHTMLAtoms::td) //you are in "cell" mode put selection to end of cell + else if (atom == nsHTMLAtoms::td || + atom == nsHTMLAtoms::th) //you are in "cell" mode put selection to end of cell { cellMode = PR_TRUE; result = ParentOffset(tempNode, getter_AddRefs(startNode), &startOffset); @@ -6002,7 +6004,8 @@ nsTypedSelection::FixupSelectionPoints(nsIDOMRange *aRange , nsDirection *aDir, else found = PR_FALSE; //didnt find the right cell yet } - else if (atom == nsHTMLAtoms::td) //you are in "cell" mode put selection to end of cell + else if (atom == nsHTMLAtoms::td || + atom == nsHTMLAtoms::th) //you are in "cell" mode put selection to end of cell { result = ParentOffset(tempNode, getter_AddRefs(endNode), &endOffset); if (NS_FAILED(result))