From 7b4eaeec7f131b23c42eb0e558cfba078dfd1334 Mon Sep 17 00:00:00 2001 From: "bzbarsky%mit.edu" Date: Wed, 11 Sep 2002 01:58:59 +0000 Subject: [PATCH] Fix offsetTop/offsetLeft to not be confused by table borders. Bugs 163923 and 119167, r=sicking, sr=jst git-svn-id: svn://10.0.0.236/trunk@129196 18797224-902f-48f8-a5cc-f745e15eee43 --- .../html/content/src/nsGenericHTMLElement.cpp | 28 +++++++++++++------ 1 file changed, 20 insertions(+), 8 deletions(-) diff --git a/mozilla/content/html/content/src/nsGenericHTMLElement.cpp b/mozilla/content/html/content/src/nsGenericHTMLElement.cpp index d5e23d77bc4..85e86354bc0 100644 --- a/mozilla/content/html/content/src/nsGenericHTMLElement.cpp +++ b/mozilla/content/html/content/src/nsGenericHTMLElement.cpp @@ -735,19 +735,31 @@ nsGenericHTMLElement::GetOffsetRect(nsRect& aRect, // And subtract out the border for the parent if (parent) { - border = nsnull; + PRBool includeBorder = PR_TRUE; // set to false if border-box sizing is used + const nsStylePosition* position = nsnull; + parent->GetStyleData(eStyleStruct_Position, (const nsStyleStruct*&)position); + if (position && position->mBoxSizing == NS_STYLE_BOX_SIZING_BORDER) { + includeBorder = PR_FALSE; + } + + if (includeBorder) { + border = nsnull; - parent->GetStyleData(eStyleStruct_Border, (const nsStyleStruct*&)border); - if (border) { - if (eStyleUnit_Coord == border->mBorder.GetLeftUnit()) { - origin.x -= border->mBorder.GetLeft(coord).GetCoordValue(); - } - if (eStyleUnit_Coord == border->mBorder.GetTopUnit()) { - origin.y -= border->mBorder.GetTop(coord).GetCoordValue(); + parent->GetStyleData(eStyleStruct_Border, (const nsStyleStruct*&)border); + if (border) { + if (eStyleUnit_Coord == border->mBorder.GetLeftUnit()) { + origin.x -= border->mBorder.GetLeft(coord).GetCoordValue(); + } + if (eStyleUnit_Coord == border->mBorder.GetTopUnit()) { + origin.y -= border->mBorder.GetTop(coord).GetCoordValue(); + } } } } + // XXX We should really consider subtracting out padding for + // content-box sizing, but we should see what IE does.... + // Get the scale from that Presentation Context float scale; context->GetTwipsToPixels(&scale);