mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 1176453 - Do not increment the cluster counter for input elements with label. r=kats
This commit is contained in:
parent
de2b97708c
commit
3d095d1f4a
@ -173,7 +173,7 @@ HasTouchListener(nsIContent* aContent)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static bool
|
static bool
|
||||||
IsElementClickable(nsIFrame* aFrame, nsIAtom* stopAt = nullptr)
|
IsElementClickable(nsIFrame* aFrame, nsIAtom* stopAt = nullptr, nsAutoString* aLabelTargetId = nullptr)
|
||||||
{
|
{
|
||||||
// Input events propagate up the content tree so we'll follow the content
|
// Input events propagate up the content tree so we'll follow the content
|
||||||
// ancestors to look for elements accepting the click.
|
// ancestors to look for elements accepting the click.
|
||||||
@ -188,8 +188,13 @@ IsElementClickable(nsIFrame* aFrame, nsIAtom* stopAt = nullptr)
|
|||||||
if (content->IsAnyOfHTMLElements(nsGkAtoms::button,
|
if (content->IsAnyOfHTMLElements(nsGkAtoms::button,
|
||||||
nsGkAtoms::input,
|
nsGkAtoms::input,
|
||||||
nsGkAtoms::select,
|
nsGkAtoms::select,
|
||||||
nsGkAtoms::textarea,
|
nsGkAtoms::textarea)) {
|
||||||
nsGkAtoms::label)) {
|
return true;
|
||||||
|
}
|
||||||
|
if (content->IsHTMLElement(nsGkAtoms::label)) {
|
||||||
|
if (aLabelTargetId) {
|
||||||
|
content->GetAttr(kNameSpaceID_None, nsGkAtoms::_for, *aLabelTargetId);
|
||||||
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -320,6 +325,22 @@ SubtractFromExposedRegion(nsRegion* aExposedRegion, const nsRegion& aRegion)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Search in the list of frames aCandidates if the element with the id "aLabelTargetId"
|
||||||
|
// is present.
|
||||||
|
static bool IsElementPresent(nsTArray<nsIFrame*>& aCandidates, const nsAutoString& aLabelTargetId)
|
||||||
|
{
|
||||||
|
for (uint32_t i = 0; i < aCandidates.Length(); ++i) {
|
||||||
|
nsIFrame* f = aCandidates[i];
|
||||||
|
nsIContent* aContent = f->GetContent();
|
||||||
|
if (aContent && aContent->IsElement()) {
|
||||||
|
if (aContent->GetID() && aLabelTargetId == nsAtomString(aContent->GetID())) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
static nsIFrame*
|
static nsIFrame*
|
||||||
GetClosest(nsIFrame* aRoot, const nsPoint& aPointRelativeToRootFrame,
|
GetClosest(nsIFrame* aRoot, const nsPoint& aPointRelativeToRootFrame,
|
||||||
const nsRect& aTargetRect, const EventRadiusPrefs* aPrefs,
|
const nsRect& aTargetRect, const EventRadiusPrefs* aPrefs,
|
||||||
@ -351,7 +372,8 @@ GetClosest(nsIFrame* aRoot, const nsPoint& aPointRelativeToRootFrame,
|
|||||||
SubtractFromExposedRegion(&exposedRegion, region);
|
SubtractFromExposedRegion(&exposedRegion, region);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!IsElementClickable(f, nsGkAtoms::body)) {
|
nsAutoString labelTargetId;
|
||||||
|
if (!IsElementClickable(f, nsGkAtoms::body, &labelTargetId)) {
|
||||||
PET_LOG(" candidate %p was not clickable\n", f);
|
PET_LOG(" candidate %p was not clickable\n", f);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@ -366,7 +388,13 @@ GetClosest(nsIFrame* aRoot, const nsPoint& aPointRelativeToRootFrame,
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
(*aElementsInCluster)++;
|
// If the first clickable ancestor of f is a label element
|
||||||
|
// and "for" attribute is present in label element, search the frame list for the "for" element
|
||||||
|
// If this element is present in the current list, do not count the frame in
|
||||||
|
// the cluster elements counter
|
||||||
|
if (labelTargetId.IsEmpty() || !IsElementPresent(aCandidates, labelTargetId)) {
|
||||||
|
(*aElementsInCluster)++;
|
||||||
|
}
|
||||||
|
|
||||||
// distance is in appunits
|
// distance is in appunits
|
||||||
float distance = ComputeDistanceFromRegion(aPointRelativeToRootFrame, region);
|
float distance = ComputeDistanceFromRegion(aPointRelativeToRootFrame, region);
|
||||||
|
Loading…
Reference in New Issue
Block a user