зеркало из https://github.com/mozilla/gecko-dev.git
Bug 619996, part d: use nsHTMLSelectElement::FromContent in nsListControlFrame; r=bz
This commit is contained in:
Родитель
42492be6e2
Коммит
b4da50351a
|
@ -79,7 +79,7 @@
|
|||
#ifdef ACCESSIBILITY
|
||||
#include "nsAccessibilityService.h"
|
||||
#endif
|
||||
#include "nsISelectElement.h"
|
||||
#include "nsHTMLSelectElement.h"
|
||||
#include "nsIPrivateDOMEvent.h"
|
||||
#include "nsCSSRendering.h"
|
||||
#include "nsITheme.h"
|
||||
|
@ -285,10 +285,8 @@ void nsListControlFrame::PaintFocus(nsIRenderingContext& aRC, nsPoint aPt)
|
|||
|
||||
nsCOMPtr<nsIContent> focusedContent;
|
||||
|
||||
nsCOMPtr<nsIDOMHTMLSelectElement> selectDOMElement(do_QueryInterface(mContent));
|
||||
NS_ASSERTION(selectDOMElement, "Can't be null");
|
||||
|
||||
nsCOMPtr<nsISelectElement> selectElement(do_QueryInterface(mContent));
|
||||
nsRefPtr<nsHTMLSelectElement> selectElement =
|
||||
nsHTMLSelectElement::FromContent(mContent);
|
||||
NS_ASSERTION(selectElement, "Can't be null");
|
||||
|
||||
// If we have a selected index then get that child frame
|
||||
|
@ -299,20 +297,17 @@ void nsListControlFrame::PaintFocus(nsIRenderingContext& aRC, nsPoint aPt)
|
|||
childframe = focusedContent->GetPrimaryFrame();
|
||||
}
|
||||
} else {
|
||||
nsCOMPtr<nsIDOMHTMLSelectElement> selectHTMLElement(do_QueryInterface(mContent));
|
||||
NS_ASSERTION(selectElement, "Can't be null");
|
||||
|
||||
// Since there isn't a selected item we need to show a focus ring around the first
|
||||
// non-disabled item and skip all the option group elements (nodes)
|
||||
nsCOMPtr<nsIDOMNode> node;
|
||||
|
||||
PRUint32 length;
|
||||
selectHTMLElement->GetLength(&length);
|
||||
selectElement->GetLength(&length);
|
||||
if (length) {
|
||||
// find the first non-disabled item
|
||||
PRBool isDisabled = PR_TRUE;
|
||||
for (PRInt32 i=0;i<PRInt32(length) && isDisabled;i++) {
|
||||
if (NS_FAILED(selectDOMElement->Item(i, getter_AddRefs(node))) || !node) {
|
||||
for (PRUint32 i = 0; i < length && isDisabled; i++) {
|
||||
if (NS_FAILED(selectElement->Item(i, getter_AddRefs(node))) || !node) {
|
||||
break;
|
||||
}
|
||||
if (NS_FAILED(selectElement->IsOptionDisabled(i, &isDisabled))) {
|
||||
|
@ -1521,7 +1516,8 @@ nsListControlFrame::SetOptionsSelectedFromFrame(PRInt32 aStartIndex,
|
|||
PRBool aValue,
|
||||
PRBool aClearAll)
|
||||
{
|
||||
nsCOMPtr<nsISelectElement> selectElement(do_QueryInterface(mContent));
|
||||
nsRefPtr<nsHTMLSelectElement> selectElement =
|
||||
nsHTMLSelectElement::FromContent(mContent);
|
||||
PRBool wasChanged = PR_FALSE;
|
||||
#ifdef DEBUG
|
||||
nsresult rv =
|
||||
|
@ -1552,18 +1548,25 @@ nsListControlFrame::ToggleOptionSelectedFromFrame(PRInt32 aIndex)
|
|||
}
|
||||
|
||||
PRBool value = PR_FALSE;
|
||||
nsresult rv = option->GetSelected(&value);
|
||||
#ifdef DEBUG
|
||||
nsresult rv =
|
||||
#endif
|
||||
option->GetSelected(&value);
|
||||
|
||||
NS_ASSERTION(NS_SUCCEEDED(rv), "GetSelected failed");
|
||||
nsCOMPtr<nsISelectElement> selectElement(do_QueryInterface(mContent));
|
||||
nsRefPtr<nsHTMLSelectElement> selectElement =
|
||||
nsHTMLSelectElement::FromContent(mContent);
|
||||
PRBool wasChanged = PR_FALSE;
|
||||
rv = selectElement->SetOptionsSelectedByIndex(aIndex,
|
||||
aIndex,
|
||||
!value,
|
||||
PR_FALSE,
|
||||
PR_FALSE,
|
||||
PR_TRUE,
|
||||
&wasChanged);
|
||||
#ifdef DEBUG
|
||||
rv =
|
||||
#endif
|
||||
selectElement->SetOptionsSelectedByIndex(aIndex,
|
||||
aIndex,
|
||||
!value,
|
||||
PR_FALSE,
|
||||
PR_FALSE,
|
||||
PR_TRUE,
|
||||
&wasChanged);
|
||||
|
||||
NS_ASSERTION(NS_SUCCEEDED(rv), "SetSelected failed");
|
||||
|
||||
|
@ -1845,7 +1848,8 @@ nsListControlFrame::GetHeightOfARow()
|
|||
nsresult
|
||||
nsListControlFrame::IsOptionDisabled(PRInt32 anIndex, PRBool &aIsDisabled)
|
||||
{
|
||||
nsCOMPtr<nsISelectElement> sel(do_QueryInterface(mContent));
|
||||
nsRefPtr<nsHTMLSelectElement> sel =
|
||||
nsHTMLSelectElement::FromContent(mContent);
|
||||
if (sel) {
|
||||
sel->IsOptionDisabled(anIndex, &aIsDisabled);
|
||||
return NS_OK;
|
||||
|
|
Загрузка…
Ссылка в новой задаче