From c18e8e3fbc8ae7d5d27b2a74f838ee3617395d12 Mon Sep 17 00:00:00 2001 From: "caillon%redhat.com" Date: Tue, 18 May 2004 17:52:05 +0000 Subject: [PATCH] Patch for bug 239785: "only first part blinks for elements split into multiple lines" Contributed by Michal Ceresna r=caillon, sr=roc git-svn-id: svn://10.0.0.236/trunk@156537 18797224-902f-48f8-a5cc-f745e15eee43 --- .../inspector/base/src/inFlasher.cpp | 49 ++++++++++++------- .../extensions/inspector/base/src/inFlasher.h | 3 +- 2 files changed, 33 insertions(+), 19 deletions(-) diff --git a/mozilla/extensions/inspector/base/src/inFlasher.cpp b/mozilla/extensions/inspector/base/src/inFlasher.cpp index 07fa472a73f..8864caf0f13 100644 --- a/mozilla/extensions/inspector/base/src/inFlasher.cpp +++ b/mozilla/extensions/inspector/base/src/inFlasher.cpp @@ -166,29 +166,37 @@ inFlasher::DrawElementOutline(nsIDOMElement* aElement) nsCOMPtr window = inLayoutUtils::GetWindowFor(aElement); if (!window) return NS_OK; nsCOMPtr presShell = inLayoutUtils::GetPresShellFor(window); - nsIFrame* frame = inLayoutUtils::GetFrameFor(aElement, presShell); - if (!frame) return NS_OK; nsCOMPtr presContext; presShell->GetPresContext(getter_AddRefs(presContext)); - nsCOMPtr rcontext; - presShell->CreateRenderingContext(frame, getter_AddRefs(rcontext)); - // get view bounds in case this frame is being scrolled - nsRect rect = frame->GetRect(); - nsPoint origin = inLayoutUtils::GetClientOrigin(presContext, frame); - rect.x = origin.x; - rect.y = origin.y; - mCSSUtils->AdjustRectForMargins(frame, rect); - float p2t; p2t = presContext->PixelsToTwips(); - if (mInvert) { - rcontext->InvertRect(rect.x, rect.y, rect.width, rect.height); - } + PRBool isFirstFrame = PR_TRUE; + nsCOMPtr rcontext; + nsIFrame* frame = inLayoutUtils::GetFrameFor(aElement, presShell); + while (frame) { + if (!rcontext) { + presShell->CreateRenderingContext(frame, getter_AddRefs(rcontext)); + } + // get view bounds in case this frame is being scrolled + nsRect rect = frame->GetRect(); + nsPoint origin = inLayoutUtils::GetClientOrigin(presContext, frame); + rect.MoveTo(origin); + mCSSUtils->AdjustRectForMargins(frame, rect); - DrawOutline(rect.x, rect.y, rect.width, rect.height, p2t, rcontext); + if (mInvert) { + rcontext->InvertRect(rect); + } + + frame->GetNextInFlow(&frame); + + PRBool isLastFrame = (frame == nsnull); + DrawOutline(rect.x, rect.y, rect.width, rect.height, p2t, rcontext, + isFirstFrame, isLastFrame); + isFirstFrame = PR_FALSE; + } return NS_OK; } @@ -222,14 +230,19 @@ inFlasher::ScrollElementIntoView(nsIDOMElement *aElement) void inFlasher::DrawOutline(nscoord aX, nscoord aY, nscoord aWidth, nscoord aHeight, - float aP2T, nsIRenderingContext* aRenderContext) + float aP2T, nsIRenderingContext* aRenderContext, + PRBool aDrawBegin, PRBool aDrawEnd) { aRenderContext->SetColor(mColor); DrawLine(aX, aY, aWidth, DIR_HORIZONTAL, BOUND_OUTER, aP2T, aRenderContext); - DrawLine(aX, aY, aHeight, DIR_VERTICAL, BOUND_OUTER, aP2T, aRenderContext); + if (aDrawBegin) { + DrawLine(aX, aY, aHeight, DIR_VERTICAL, BOUND_OUTER, aP2T, aRenderContext); + } DrawLine(aX, aY+aHeight, aWidth, DIR_HORIZONTAL, BOUND_INNER, aP2T, aRenderContext); - DrawLine(aX+aWidth, aY, aHeight, DIR_VERTICAL, BOUND_INNER, aP2T, aRenderContext); + if (aDrawEnd) { + DrawLine(aX+aWidth, aY, aHeight, DIR_VERTICAL, BOUND_INNER, aP2T, aRenderContext); + } } void diff --git a/mozilla/extensions/inspector/base/src/inFlasher.h b/mozilla/extensions/inspector/base/src/inFlasher.h index 6ce4bea1194..42e0a28dc38 100644 --- a/mozilla/extensions/inspector/base/src/inFlasher.h +++ b/mozilla/extensions/inspector/base/src/inFlasher.h @@ -63,7 +63,8 @@ public: protected: void DrawOutline(nscoord aX, nscoord aY, nscoord aWidth, nscoord aHeight, - float aP2T, nsIRenderingContext* aRenderContext); + float aP2T, nsIRenderingContext* aRenderContext, + PRBool aDrawBegin, PRBool aDrawEnd); void DrawLine(nscoord aX, nscoord aY, nscoord aLength, PRBool aDir, PRBool aBounds, float aP2T, nsIRenderingContext* aRenderContext);