зеркало из https://github.com/mozilla/pjs.git
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:
Родитель
6eb7b4a58a
Коммит
5fcd33af27
|
@ -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,
|
return mInner.HandleDOMEvent(aPresContext, aEvent, aDOMEvent,
|
||||||
aFlags, aEventStatus);
|
aFlags, aEventStatus);
|
||||||
}
|
}
|
||||||
|
|
|
@ -96,6 +96,9 @@ const char * kMozDropdownActive = "-moz-dropdown-active";
|
||||||
|
|
||||||
const PRInt32 kSizeNotSet = -1;
|
const PRInt32 kSizeNotSet = -1;
|
||||||
|
|
||||||
|
// static class data member for Bug 32920
|
||||||
|
nsComboboxControlFrame * nsComboboxControlFrame::mFocused = nsnull;
|
||||||
|
|
||||||
nsresult
|
nsresult
|
||||||
NS_NewComboboxControlFrame(nsIPresShell* aPresShell, nsIFrame** aNewFrame, PRUint32 aStateFlags)
|
NS_NewComboboxControlFrame(nsIPresShell* aPresShell, nsIFrame** aNewFrame, PRUint32 aStateFlags)
|
||||||
{
|
{
|
||||||
|
@ -248,6 +251,7 @@ nsComboboxControlFrame::nsComboboxControlFrame()
|
||||||
mItemDisplayWidth = 0;
|
mItemDisplayWidth = 0;
|
||||||
|
|
||||||
mGoodToGo = PR_FALSE;
|
mGoodToGo = PR_FALSE;
|
||||||
|
|
||||||
//Shrink the area around it's contents
|
//Shrink the area around it's contents
|
||||||
//SetFlags(NS_BLOCK_SHRINK_WRAP);
|
//SetFlags(NS_BLOCK_SHRINK_WRAP);
|
||||||
|
|
||||||
|
@ -487,7 +491,11 @@ nsComboboxControlFrame::GetHorizontalInsidePadding(nsIPresContext* aPresContext,
|
||||||
void
|
void
|
||||||
nsComboboxControlFrame::SetFocus(PRBool aOn, PRBool aRepaint)
|
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
|
void
|
||||||
|
@ -2453,26 +2461,30 @@ nsComboboxControlFrame::Paint(nsIPresContext* aPresContext,
|
||||||
nsCOMPtr<nsIEventStateManager> stateManager;
|
nsCOMPtr<nsIEventStateManager> stateManager;
|
||||||
nsresult rv = mPresContext->GetEventStateManager(getter_AddRefs(stateManager));
|
nsresult rv = mPresContext->GetEventStateManager(getter_AddRefs(stateManager));
|
||||||
if (NS_SUCCEEDED(rv)) {
|
if (NS_SUCCEEDED(rv)) {
|
||||||
nsCOMPtr<nsIContent> content;
|
if (NS_SUCCEEDED(rv) && !nsFormFrame::GetDisabled(this) && mFocused == this) {
|
||||||
rv = stateManager->GetFocusedContent(getter_AddRefs(content));
|
|
||||||
if (NS_SUCCEEDED(rv) && !nsFormFrame::GetDisabled(this) && content && content.get() == mContent) {
|
|
||||||
aRenderingContext.SetLineStyle(nsLineStyle_kDotted);
|
aRenderingContext.SetLineStyle(nsLineStyle_kDotted);
|
||||||
aRenderingContext.SetColor(0);
|
aRenderingContext.SetColor(0);
|
||||||
//aRenderingContext.DrawRect(clipRect);
|
} else {
|
||||||
float p2t;
|
const nsStyleColor* myColor = (const nsStyleColor*)mStyleContext->GetStyleData(eStyleStruct_Color);
|
||||||
aPresContext->GetPixelsToTwips(&p2t);
|
aRenderingContext.SetColor(myColor->mBackgroundColor);
|
||||||
nscoord onePixel = NSIntPixelsToTwips(1, p2t);
|
aRenderingContext.SetLineStyle(nsLineStyle_kSolid);
|
||||||
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.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);
|
aRenderingContext.PopState(clipEmpty);
|
||||||
|
|
|
@ -28,8 +28,8 @@
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef DEBUG_rods
|
#ifdef DEBUG_rods
|
||||||
#define DO_REFLOW_DEBUG
|
//#define DO_REFLOW_DEBUG
|
||||||
#define DO_REFLOW_COUNTER
|
//#define DO_REFLOW_COUNTER
|
||||||
//#define DO_UNCONSTRAINED_CHECK
|
//#define DO_UNCONSTRAINED_CHECK
|
||||||
//#define DO_PIXELS
|
//#define DO_PIXELS
|
||||||
//#define DO_NEW_REFLOW
|
//#define DO_NEW_REFLOW
|
||||||
|
@ -268,6 +268,10 @@ protected:
|
||||||
|
|
||||||
PRPackedBool mGoodToGo;
|
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
|
#ifdef DO_REFLOW_COUNTER
|
||||||
PRInt32 mReflowId;
|
PRInt32 mReflowId;
|
||||||
#endif
|
#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,
|
return mInner.HandleDOMEvent(aPresContext, aEvent, aDOMEvent,
|
||||||
aFlags, aEventStatus);
|
aFlags, aEventStatus);
|
||||||
}
|
}
|
||||||
|
|
|
@ -505,12 +505,6 @@ select:-moz-dummy-option {
|
||||||
-moz-user-select: none;
|
-moz-user-select: none;
|
||||||
}
|
}
|
||||||
|
|
||||||
:focus:-moz-display-comboboxcontrol-frame {
|
|
||||||
background-color: Highlight;
|
|
||||||
color: HighlightText;
|
|
||||||
-moz-outline: 1px dotted HighlightText;
|
|
||||||
}
|
|
||||||
|
|
||||||
option {
|
option {
|
||||||
min-height: 1em;
|
min-height: 1em;
|
||||||
display: block;
|
display: block;
|
||||||
|
|
|
@ -96,6 +96,9 @@ const char * kMozDropdownActive = "-moz-dropdown-active";
|
||||||
|
|
||||||
const PRInt32 kSizeNotSet = -1;
|
const PRInt32 kSizeNotSet = -1;
|
||||||
|
|
||||||
|
// static class data member for Bug 32920
|
||||||
|
nsComboboxControlFrame * nsComboboxControlFrame::mFocused = nsnull;
|
||||||
|
|
||||||
nsresult
|
nsresult
|
||||||
NS_NewComboboxControlFrame(nsIPresShell* aPresShell, nsIFrame** aNewFrame, PRUint32 aStateFlags)
|
NS_NewComboboxControlFrame(nsIPresShell* aPresShell, nsIFrame** aNewFrame, PRUint32 aStateFlags)
|
||||||
{
|
{
|
||||||
|
@ -248,6 +251,7 @@ nsComboboxControlFrame::nsComboboxControlFrame()
|
||||||
mItemDisplayWidth = 0;
|
mItemDisplayWidth = 0;
|
||||||
|
|
||||||
mGoodToGo = PR_FALSE;
|
mGoodToGo = PR_FALSE;
|
||||||
|
|
||||||
//Shrink the area around it's contents
|
//Shrink the area around it's contents
|
||||||
//SetFlags(NS_BLOCK_SHRINK_WRAP);
|
//SetFlags(NS_BLOCK_SHRINK_WRAP);
|
||||||
|
|
||||||
|
@ -487,7 +491,11 @@ nsComboboxControlFrame::GetHorizontalInsidePadding(nsIPresContext* aPresContext,
|
||||||
void
|
void
|
||||||
nsComboboxControlFrame::SetFocus(PRBool aOn, PRBool aRepaint)
|
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
|
void
|
||||||
|
@ -2453,26 +2461,30 @@ nsComboboxControlFrame::Paint(nsIPresContext* aPresContext,
|
||||||
nsCOMPtr<nsIEventStateManager> stateManager;
|
nsCOMPtr<nsIEventStateManager> stateManager;
|
||||||
nsresult rv = mPresContext->GetEventStateManager(getter_AddRefs(stateManager));
|
nsresult rv = mPresContext->GetEventStateManager(getter_AddRefs(stateManager));
|
||||||
if (NS_SUCCEEDED(rv)) {
|
if (NS_SUCCEEDED(rv)) {
|
||||||
nsCOMPtr<nsIContent> content;
|
if (NS_SUCCEEDED(rv) && !nsFormFrame::GetDisabled(this) && mFocused == this) {
|
||||||
rv = stateManager->GetFocusedContent(getter_AddRefs(content));
|
|
||||||
if (NS_SUCCEEDED(rv) && !nsFormFrame::GetDisabled(this) && content && content.get() == mContent) {
|
|
||||||
aRenderingContext.SetLineStyle(nsLineStyle_kDotted);
|
aRenderingContext.SetLineStyle(nsLineStyle_kDotted);
|
||||||
aRenderingContext.SetColor(0);
|
aRenderingContext.SetColor(0);
|
||||||
//aRenderingContext.DrawRect(clipRect);
|
} else {
|
||||||
float p2t;
|
const nsStyleColor* myColor = (const nsStyleColor*)mStyleContext->GetStyleData(eStyleStruct_Color);
|
||||||
aPresContext->GetPixelsToTwips(&p2t);
|
aRenderingContext.SetColor(myColor->mBackgroundColor);
|
||||||
nscoord onePixel = NSIntPixelsToTwips(1, p2t);
|
aRenderingContext.SetLineStyle(nsLineStyle_kSolid);
|
||||||
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.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);
|
aRenderingContext.PopState(clipEmpty);
|
||||||
|
|
|
@ -28,8 +28,8 @@
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef DEBUG_rods
|
#ifdef DEBUG_rods
|
||||||
#define DO_REFLOW_DEBUG
|
//#define DO_REFLOW_DEBUG
|
||||||
#define DO_REFLOW_COUNTER
|
//#define DO_REFLOW_COUNTER
|
||||||
//#define DO_UNCONSTRAINED_CHECK
|
//#define DO_UNCONSTRAINED_CHECK
|
||||||
//#define DO_PIXELS
|
//#define DO_PIXELS
|
||||||
//#define DO_NEW_REFLOW
|
//#define DO_NEW_REFLOW
|
||||||
|
@ -268,6 +268,10 @@ protected:
|
||||||
|
|
||||||
PRPackedBool mGoodToGo;
|
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
|
#ifdef DO_REFLOW_COUNTER
|
||||||
PRInt32 mReflowId;
|
PRInt32 mReflowId;
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -505,12 +505,6 @@ select:-moz-dummy-option {
|
||||||
-moz-user-select: none;
|
-moz-user-select: none;
|
||||||
}
|
}
|
||||||
|
|
||||||
:focus:-moz-display-comboboxcontrol-frame {
|
|
||||||
background-color: Highlight;
|
|
||||||
color: HighlightText;
|
|
||||||
-moz-outline: 1px dotted HighlightText;
|
|
||||||
}
|
|
||||||
|
|
||||||
option {
|
option {
|
||||||
min-height: 1em;
|
min-height: 1em;
|
||||||
display: block;
|
display: block;
|
||||||
|
|
Загрузка…
Ссылка в новой задаче