Bug 377575 - Table resize information tooltip location is misplaced, patch by Mathieu Fenniak <mfenniak-moz@mathieu.fenniak.net>, r=glazou, sr=jst, a1.9=dbaron

This commit is contained in:
philringnalda@gmail.com 2007-08-25 22:53:38 -07:00
parent b032759693
commit 53c2650e67
3 changed files with 6 additions and 70 deletions

View File

@ -162,6 +162,8 @@ nsHTMLEditor::nsHTMLEditor()
, mSnapToGridEnabled(PR_FALSE)
, mIsInlineTableEditingEnabled(PR_TRUE)
, mGridSize(0)
, mInfoXIncrement(20)
, mInfoYIncrement(20)
{
}

View File

@ -908,7 +908,6 @@ protected:
void SetFinalSize(PRInt32 aX, PRInt32 aY);
void DeleteRefToAnonymousNode(nsIDOMNode * aNode);
void SetResizeIncrements(PRInt32 aX, PRInt32 aY, PRInt32 aW, PRInt32 aH, PRBool aPreserveRatio);
void SetInfoIncrements(PRInt8 aX, PRInt8 aY);
/* ABSOLUTE POSITIONING */

View File

@ -519,13 +519,6 @@ nsHTMLEditor::HideShadowAndInfo()
mResizingInfo->SetAttribute(NS_LITERAL_STRING("class"), NS_LITERAL_STRING("hidden"));
}
void
nsHTMLEditor::SetInfoIncrements(PRInt8 aX, PRInt8 aY)
{
mInfoXIncrement = aX;
mInfoYIncrement = aY;
}
nsresult
nsHTMLEditor::StartResizing(nsIDOMElement *aHandle)
{
@ -565,35 +558,27 @@ nsHTMLEditor::StartResizing(nsIDOMElement *aHandle)
aHandle->GetAttribute(NS_LITERAL_STRING("anonlocation"), locationStr);
if (locationStr.Equals(kTopLeft)) {
SetResizeIncrements(1, 1, -1, -1, preserveRatio);
SetInfoIncrements(20, 20);
}
else if (locationStr.Equals(kTop)) {
SetResizeIncrements(0, 1, 0, -1, PR_FALSE);
SetInfoIncrements(0, 20);
}
else if (locationStr.Equals(kTopRight)) {
SetResizeIncrements(0, 1, 1, -1, preserveRatio);
SetInfoIncrements(-20, 20);
}
else if (locationStr.Equals(kLeft)) {
SetResizeIncrements(1, 0, -1, 0, PR_FALSE);
SetInfoIncrements(20, 20);
}
else if (locationStr.Equals(kRight)) {
SetResizeIncrements(0, 0, 1, 0, PR_FALSE);
SetInfoIncrements(-20, 0);
}
else if (locationStr.Equals(kBottomLeft)) {
SetResizeIncrements(1, 0, -1, 1, preserveRatio);
SetInfoIncrements(20, -20);
}
else if (locationStr.Equals(kBottom)) {
SetResizeIncrements(0, 0, 0, 1, PR_FALSE);
SetInfoIncrements(0, -20);
}
else if (locationStr.Equals(kBottomRight)) {
SetResizeIncrements(0, 0, 1, 1, preserveRatio);
SetInfoIncrements(-20, -20);
}
// make the shadow appear
@ -696,62 +681,12 @@ nsHTMLEditor::SetResizingInfoPosition(PRInt32 aX, PRInt32 aY, PRInt32 aW, PRInt3
nsCOMPtr<nsIDOMDocument> domdoc;
nsEditor::GetDocument(getter_AddRefs(domdoc));
nsCOMPtr<nsIDocument> doc (do_QueryInterface(domdoc));
if (!doc)
return NS_ERROR_UNEXPECTED;
// get the root content
nsCOMPtr<nsIDOMNSHTMLElement> nsElement = do_QueryInterface(doc->GetRootContent());
if (!nsElement) {return NS_ERROR_NULL_POINTER; }
// let's get the size of the document
PRInt32 w, h;
nsElement->GetOffsetWidth(&w);
nsElement->GetOffsetHeight(&h);
if (mInfoXIncrement < 0)
aX = w - aX ;
if (mInfoYIncrement < 0)
aY = h - aY;
NS_NAMED_LITERAL_STRING(rightStr, "right");
NS_NAMED_LITERAL_STRING(leftStr, "left");
NS_NAMED_LITERAL_STRING(topStr, "top");
NS_NAMED_LITERAL_STRING(bottomStr, "bottom");
mHTMLCSSUtils->SetCSSPropertyPixels(mResizingInfo,
(mInfoXIncrement < 0) ? rightStr : leftStr,
aX + PR_ABS(mInfoXIncrement));
mHTMLCSSUtils->SetCSSPropertyPixels(mResizingInfo,
(mInfoYIncrement < 0) ? bottomStr : topStr,
aY + PR_ABS(mInfoYIncrement));
mHTMLCSSUtils->RemoveCSSProperty(mResizingInfo,
(mInfoXIncrement >= 0) ? rightStr : leftStr);
mHTMLCSSUtils->RemoveCSSProperty(mResizingInfo,
(mInfoYIncrement >= 0) ? bottomStr : topStr);
// let's make sure the info box does not go beyond the limits of the viewport
nsAutoString value;
float f;
nsCOMPtr<nsIAtom> unit;
if (mInfoXIncrement < 0) {
mHTMLCSSUtils->GetComputedProperty(mResizingInfo, nsEditProperty::cssLeft, value);
mHTMLCSSUtils->ParseLength(value, &f, getter_AddRefs(unit));
if (f <= 0) {
mHTMLCSSUtils->SetCSSPropertyPixels(mResizingInfo, leftStr, 0);
mHTMLCSSUtils->RemoveCSSProperty(mResizingInfo,
rightStr);
}
}
if (mInfoYIncrement < 0) {
mHTMLCSSUtils->GetComputedProperty(mResizingInfo, nsEditProperty::cssTop, value);
mHTMLCSSUtils->ParseLength(value, &f, getter_AddRefs(unit));
if (f <= 0) {
mHTMLCSSUtils->SetCSSPropertyPixels(mResizingInfo, topStr, 0);
mHTMLCSSUtils->RemoveCSSProperty(mResizingInfo,
bottomStr);
}
}
mHTMLCSSUtils->SetCSSPropertyPixels(mResizingInfo, leftStr,
aX + mInfoXIncrement);
mHTMLCSSUtils->SetCSSPropertyPixels(mResizingInfo, topStr,
aY + mInfoYIncrement);
nsCOMPtr<nsIDOMNode> textInfo;
nsresult res = mResizingInfo->GetFirstChild(getter_AddRefs(textInfo));