Focus rect is now drawn and erased directly via C++ code. Focus comes from "SetFocus" being set

on the content node which calls the frame. The frame is notified of Blur via thecontent node
watching for NS_CONTENT_BLUR events.
The rule we are removing from html.css is responsible for drawing in the focus,
but it causes the combobox, the dropdown and all the options to have their style reresolved.
Bug 32920, r=attinasi, b=buster
This commit is contained in:
rods%netscape.com 2000-10-04 13:39:07 +00:00
Родитель 057220774a
Коммит 965ad980fb
8 изменённых файлов: 96 добавлений и 52 удалений

Просмотреть файл

@ -1440,6 +1440,18 @@ nsHTMLSelectElement::HandleDOMEvent(nsIPresContext* aPresContext,
}
}
// Must notify the frame that the blur event occurred
// NOTE: At this point EventStateManager has not yet set the
/// new content as having focus so this content is still considered
// the focused element. So the ComboboxControlFrame tracks the focus
// at a class level (Bug 32920)
if ((nsEventStatus_eIgnore == *aEventStatus) &&
!(aFlags & NS_EVENT_FLAG_CAPTURE) &&
(aEvent->message == NS_BLUR_CONTENT) &&
formControlFrame != nsnull) {
formControlFrame->SetFocus(PR_FALSE, PR_TRUE);
}
return mInner.HandleDOMEvent(aPresContext, aEvent, aDOMEvent,
aFlags, aEventStatus);
}

Просмотреть файл

@ -96,6 +96,9 @@ const char * kMozDropdownActive = "-moz-dropdown-active";
const PRInt32 kSizeNotSet = -1;
// static class data member for Bug 32920
nsComboboxControlFrame * nsComboboxControlFrame::mFocused = nsnull;
nsresult
NS_NewComboboxControlFrame(nsIPresShell* aPresShell, nsIFrame** aNewFrame, PRUint32 aStateFlags)
{
@ -248,6 +251,7 @@ nsComboboxControlFrame::nsComboboxControlFrame()
mItemDisplayWidth = 0;
mGoodToGo = PR_FALSE;
//Shrink the area around it's contents
//SetFlags(NS_BLOCK_SHRINK_WRAP);
@ -487,7 +491,11 @@ nsComboboxControlFrame::GetHorizontalInsidePadding(nsIPresContext* aPresContext,
void
nsComboboxControlFrame::SetFocus(PRBool aOn, PRBool aRepaint)
{
//XXX: TODO Implement focus for combobox.
mFocused = aOn?this:nsnull;
// Thiis is needed on a temporary basis. It causes the focus
// rect to be drawn. This is much faster than ReResolvingStyle
// Bug 32920
Invalidate(mPresContext, nsRect(0,0,mRect.width,mRect.height), PR_TRUE);
}
void
@ -2453,26 +2461,30 @@ nsComboboxControlFrame::Paint(nsIPresContext* aPresContext,
nsCOMPtr<nsIEventStateManager> stateManager;
nsresult rv = mPresContext->GetEventStateManager(getter_AddRefs(stateManager));
if (NS_SUCCEEDED(rv)) {
nsCOMPtr<nsIContent> content;
rv = stateManager->GetFocusedContent(getter_AddRefs(content));
if (NS_SUCCEEDED(rv) && !nsFormFrame::GetDisabled(this) && content && content.get() == mContent) {
if (NS_SUCCEEDED(rv) && !nsFormFrame::GetDisabled(this) && mFocused == this) {
aRenderingContext.SetLineStyle(nsLineStyle_kDotted);
aRenderingContext.SetColor(0);
//aRenderingContext.DrawRect(clipRect);
float p2t;
aPresContext->GetPixelsToTwips(&p2t);
nscoord onePixel = NSIntPixelsToTwips(1, p2t);
clipRect.width -= onePixel;
clipRect.height -= onePixel;
aRenderingContext.DrawLine(clipRect.x, clipRect.y,
clipRect.x+clipRect.width, clipRect.y);
aRenderingContext.DrawLine(clipRect.x+clipRect.width, clipRect.y,
clipRect.x+clipRect.width, clipRect.y+clipRect.height);
aRenderingContext.DrawLine(clipRect.x+clipRect.width, clipRect.y+clipRect.height,
clipRect.x, clipRect.y+clipRect.height);
aRenderingContext.DrawLine(clipRect.x, clipRect.y+clipRect.height,
clipRect.x, clipRect.y);
} else {
const nsStyleColor* myColor = (const nsStyleColor*)mStyleContext->GetStyleData(eStyleStruct_Color);
aRenderingContext.SetColor(myColor->mBackgroundColor);
aRenderingContext.SetLineStyle(nsLineStyle_kSolid);
}
//aRenderingContext.DrawRect(clipRect);
float p2t;
aPresContext->GetPixelsToTwips(&p2t);
nscoord onePixel = NSIntPixelsToTwips(1, p2t);
clipRect.width -= onePixel;
clipRect.height -= onePixel;
aRenderingContext.DrawLine(clipRect.x, clipRect.y,
clipRect.x+clipRect.width, clipRect.y);
aRenderingContext.DrawLine(clipRect.x+clipRect.width, clipRect.y,
clipRect.x+clipRect.width, clipRect.y+clipRect.height);
aRenderingContext.DrawLine(clipRect.x+clipRect.width, clipRect.y+clipRect.height,
clipRect.x, clipRect.y+clipRect.height);
aRenderingContext.DrawLine(clipRect.x, clipRect.y+clipRect.height,
clipRect.x, clipRect.y);
aRenderingContext.DrawLine(clipRect.x, clipRect.y+clipRect.height,
clipRect.x, clipRect.y);
}
/////////////////////
aRenderingContext.PopState(clipEmpty);

Просмотреть файл

@ -28,8 +28,8 @@
#endif
#ifdef DEBUG_rods
#define DO_REFLOW_DEBUG
#define DO_REFLOW_COUNTER
//#define DO_REFLOW_DEBUG
//#define DO_REFLOW_COUNTER
//#define DO_UNCONSTRAINED_CHECK
//#define DO_PIXELS
//#define DO_NEW_REFLOW
@ -268,6 +268,10 @@ protected:
PRPackedBool mGoodToGo;
// static class data member for Bug 32920
// only one control can be focused at a time
static nsComboboxControlFrame * mFocused;
#ifdef DO_REFLOW_COUNTER
PRInt32 mReflowId;
#endif

Просмотреть файл

@ -1440,6 +1440,18 @@ nsHTMLSelectElement::HandleDOMEvent(nsIPresContext* aPresContext,
}
}
// Must notify the frame that the blur event occurred
// NOTE: At this point EventStateManager has not yet set the
/// new content as having focus so this content is still considered
// the focused element. So the ComboboxControlFrame tracks the focus
// at a class level (Bug 32920)
if ((nsEventStatus_eIgnore == *aEventStatus) &&
!(aFlags & NS_EVENT_FLAG_CAPTURE) &&
(aEvent->message == NS_BLUR_CONTENT) &&
formControlFrame != nsnull) {
formControlFrame->SetFocus(PR_FALSE, PR_TRUE);
}
return mInner.HandleDOMEvent(aPresContext, aEvent, aDOMEvent,
aFlags, aEventStatus);
}

Просмотреть файл

@ -505,12 +505,6 @@ select:-moz-dummy-option {
-moz-user-select: none;
}
:focus:-moz-display-comboboxcontrol-frame {
background-color: Highlight;
color: HighlightText;
-moz-outline: 1px dotted HighlightText;
}
option {
min-height: 1em;
display: block;

Просмотреть файл

@ -96,6 +96,9 @@ const char * kMozDropdownActive = "-moz-dropdown-active";
const PRInt32 kSizeNotSet = -1;
// static class data member for Bug 32920
nsComboboxControlFrame * nsComboboxControlFrame::mFocused = nsnull;
nsresult
NS_NewComboboxControlFrame(nsIPresShell* aPresShell, nsIFrame** aNewFrame, PRUint32 aStateFlags)
{
@ -248,6 +251,7 @@ nsComboboxControlFrame::nsComboboxControlFrame()
mItemDisplayWidth = 0;
mGoodToGo = PR_FALSE;
//Shrink the area around it's contents
//SetFlags(NS_BLOCK_SHRINK_WRAP);
@ -487,7 +491,11 @@ nsComboboxControlFrame::GetHorizontalInsidePadding(nsIPresContext* aPresContext,
void
nsComboboxControlFrame::SetFocus(PRBool aOn, PRBool aRepaint)
{
//XXX: TODO Implement focus for combobox.
mFocused = aOn?this:nsnull;
// Thiis is needed on a temporary basis. It causes the focus
// rect to be drawn. This is much faster than ReResolvingStyle
// Bug 32920
Invalidate(mPresContext, nsRect(0,0,mRect.width,mRect.height), PR_TRUE);
}
void
@ -2453,26 +2461,30 @@ nsComboboxControlFrame::Paint(nsIPresContext* aPresContext,
nsCOMPtr<nsIEventStateManager> stateManager;
nsresult rv = mPresContext->GetEventStateManager(getter_AddRefs(stateManager));
if (NS_SUCCEEDED(rv)) {
nsCOMPtr<nsIContent> content;
rv = stateManager->GetFocusedContent(getter_AddRefs(content));
if (NS_SUCCEEDED(rv) && !nsFormFrame::GetDisabled(this) && content && content.get() == mContent) {
if (NS_SUCCEEDED(rv) && !nsFormFrame::GetDisabled(this) && mFocused == this) {
aRenderingContext.SetLineStyle(nsLineStyle_kDotted);
aRenderingContext.SetColor(0);
//aRenderingContext.DrawRect(clipRect);
float p2t;
aPresContext->GetPixelsToTwips(&p2t);
nscoord onePixel = NSIntPixelsToTwips(1, p2t);
clipRect.width -= onePixel;
clipRect.height -= onePixel;
aRenderingContext.DrawLine(clipRect.x, clipRect.y,
clipRect.x+clipRect.width, clipRect.y);
aRenderingContext.DrawLine(clipRect.x+clipRect.width, clipRect.y,
clipRect.x+clipRect.width, clipRect.y+clipRect.height);
aRenderingContext.DrawLine(clipRect.x+clipRect.width, clipRect.y+clipRect.height,
clipRect.x, clipRect.y+clipRect.height);
aRenderingContext.DrawLine(clipRect.x, clipRect.y+clipRect.height,
clipRect.x, clipRect.y);
} else {
const nsStyleColor* myColor = (const nsStyleColor*)mStyleContext->GetStyleData(eStyleStruct_Color);
aRenderingContext.SetColor(myColor->mBackgroundColor);
aRenderingContext.SetLineStyle(nsLineStyle_kSolid);
}
//aRenderingContext.DrawRect(clipRect);
float p2t;
aPresContext->GetPixelsToTwips(&p2t);
nscoord onePixel = NSIntPixelsToTwips(1, p2t);
clipRect.width -= onePixel;
clipRect.height -= onePixel;
aRenderingContext.DrawLine(clipRect.x, clipRect.y,
clipRect.x+clipRect.width, clipRect.y);
aRenderingContext.DrawLine(clipRect.x+clipRect.width, clipRect.y,
clipRect.x+clipRect.width, clipRect.y+clipRect.height);
aRenderingContext.DrawLine(clipRect.x+clipRect.width, clipRect.y+clipRect.height,
clipRect.x, clipRect.y+clipRect.height);
aRenderingContext.DrawLine(clipRect.x, clipRect.y+clipRect.height,
clipRect.x, clipRect.y);
aRenderingContext.DrawLine(clipRect.x, clipRect.y+clipRect.height,
clipRect.x, clipRect.y);
}
/////////////////////
aRenderingContext.PopState(clipEmpty);

Просмотреть файл

@ -28,8 +28,8 @@
#endif
#ifdef DEBUG_rods
#define DO_REFLOW_DEBUG
#define DO_REFLOW_COUNTER
//#define DO_REFLOW_DEBUG
//#define DO_REFLOW_COUNTER
//#define DO_UNCONSTRAINED_CHECK
//#define DO_PIXELS
//#define DO_NEW_REFLOW
@ -268,6 +268,10 @@ protected:
PRPackedBool mGoodToGo;
// static class data member for Bug 32920
// only one control can be focused at a time
static nsComboboxControlFrame * mFocused;
#ifdef DO_REFLOW_COUNTER
PRInt32 mReflowId;
#endif

Просмотреть файл

@ -505,12 +505,6 @@ select:-moz-dummy-option {
-moz-user-select: none;
}
:focus:-moz-display-comboboxcontrol-frame {
background-color: Highlight;
color: HighlightText;
-moz-outline: 1px dotted HighlightText;
}
option {
min-height: 1em;
display: block;