mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 899931 - Part f: Cleanup nsListControlFrame::GetIndexFromDOMEvent; r=dzbarsky
This commit is contained in:
parent
aba0c83a1c
commit
12dfce76ee
@ -619,41 +619,6 @@ nsListControlFrame::GetContentInsertionFrame() {
|
||||
return GetOptionsContainer()->GetContentInsertionFrame();
|
||||
}
|
||||
|
||||
//---------------------------------------------------------
|
||||
// Starts at the passed in content object and walks up the
|
||||
// parent heierarchy looking for the nsIDOMHTMLOptionElement
|
||||
//---------------------------------------------------------
|
||||
nsIContent *
|
||||
nsListControlFrame::GetOptionFromContent(nsIContent *aContent)
|
||||
{
|
||||
for (nsIContent* content = aContent; content; content = content->GetParent()) {
|
||||
if (content->IsHTML(nsGkAtoms::option)) {
|
||||
return content;
|
||||
}
|
||||
}
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------
|
||||
// Finds the index of the hit frame's content in the list
|
||||
// of option elements
|
||||
//---------------------------------------------------------
|
||||
int32_t
|
||||
nsListControlFrame::GetIndexFromContent(nsIContent *aContent)
|
||||
{
|
||||
nsCOMPtr<nsIDOMHTMLOptionElement> option;
|
||||
option = do_QueryInterface(aContent);
|
||||
if (option) {
|
||||
int32_t retval;
|
||||
option->GetIndex(&retval);
|
||||
if (retval >= 0) {
|
||||
return retval;
|
||||
}
|
||||
}
|
||||
return kNothingSelected;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------
|
||||
bool
|
||||
nsListControlFrame::ExtendedSelection(int32_t aStartIndex,
|
||||
@ -1802,12 +1767,17 @@ nsListControlFrame::GetIndexFromDOMEvent(nsIDOMEvent* aMouseEvent,
|
||||
}
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIContent> content = PresContext()->EventStateManager()->
|
||||
GetEventTargetContent(nullptr);
|
||||
nsRefPtr<dom::HTMLOptionElement> option;
|
||||
for (nsCOMPtr<nsIContent> content =
|
||||
PresContext()->EventStateManager()->GetEventTargetContent(nullptr);
|
||||
content && !option;
|
||||
content = content->GetParent()) {
|
||||
option = dom::HTMLOptionElement::FromContent(content);
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIContent> optionContent = GetOptionFromContent(content);
|
||||
if (optionContent) {
|
||||
aCurIndex = GetIndexFromContent(optionContent);
|
||||
if (option) {
|
||||
option->GetIndex(&aCurIndex);
|
||||
MOZ_ASSERT(aCurIndex >= 0);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
@ -1819,7 +1789,7 @@ nsListControlFrame::GetIndexFromDOMEvent(nsIDOMEvent* aMouseEvent,
|
||||
|
||||
// If the event coordinate is above the first option frame, then target the
|
||||
// first option frame
|
||||
nsCOMPtr<nsIContent> firstOption = GetOptionContent(0);
|
||||
nsRefPtr<dom::HTMLOptionElement> firstOption = GetOption(0);
|
||||
NS_ASSERTION(firstOption, "Can't find first option that's supposed to be there");
|
||||
nsIFrame* optionFrame = firstOption->GetPrimaryFrame();
|
||||
if (optionFrame) {
|
||||
@ -1831,7 +1801,7 @@ nsListControlFrame::GetIndexFromDOMEvent(nsIDOMEvent* aMouseEvent,
|
||||
}
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIContent> lastOption = GetOptionContent(numOptions - 1);
|
||||
nsRefPtr<dom::HTMLOptionElement> lastOption = GetOption(numOptions - 1);
|
||||
// If the event coordinate is below the last option frame, then target the
|
||||
// last option frame
|
||||
NS_ASSERTION(lastOption, "Can't find last option that's supposed to be there");
|
||||
|
@ -321,7 +321,6 @@ protected:
|
||||
|
||||
// Utility methods
|
||||
nsresult GetSizeAttribute(uint32_t *aSize);
|
||||
nsIContent* GetOptionFromContent(nsIContent *aContent);
|
||||
|
||||
/**
|
||||
* Sets the mSelectedIndex and mOldSelectedIndex from figuring out what
|
||||
@ -338,7 +337,6 @@ protected:
|
||||
already_AddRefed<nsIContent> GetOptionContent(int32_t aIndex) const;
|
||||
|
||||
bool CheckIfAllFramesHere();
|
||||
int32_t GetIndexFromContent(nsIContent *aContent);
|
||||
bool IsLeftButton(nsIDOMEvent* aMouseEvent);
|
||||
|
||||
// guess at a row height based on our own style.
|
||||
|
Loading…
Reference in New Issue
Block a user