Closed
Bug 214843
Opened 22 years ago
Closed 21 years ago
Space doesn't scroll when link's child has focus
Categories
(Core :: DOM: UI Events & Focus Handling, defect)
Tracking
()
RESOLVED
FIXED
People
(Reporter: jruderman, Assigned: nian.liu)
References
()
Details
Attachments
(4 files, 3 obsolete files)
458 bytes,
text/html
|
Details | |
1.50 KB,
patch
|
aaronlev
:
review+
jst
:
superreview+
|
Details | Diff | Splinter Review |
2.75 KB,
patch
|
Details | Diff | Splinter Review | |
5.36 KB,
text/html
|
Details |
Steps to reproduce:
1. Load the testcase.
2. Drag or middle-click the link labelled "bold in link (broken)".
3. Press spacebar.
Result: nothing happens
Expected: page scrolls down
This could be a dup of bug 65917 (except that it's marked as a style system bug)
or bug 102663.
Reporter | ||
Comment 1•22 years ago
|
||
Reporter | ||
Comment 2•21 years ago
|
||
*** Bug 229064 has been marked as a duplicate of this bug. ***
Assignee | ||
Comment 3•21 years ago
|
||
the reason is that once there is any element between <a> and </a>, the focused
element is set to that element. navigate the node tree can solve this problem.
however, i'm not sure whether it will bring other issues. whatever, i'll post
patch later.
jst, saari and Aaron, any comments on that?
Assignee | ||
Comment 4•21 years ago
|
||
Assignee | ||
Comment 5•21 years ago
|
||
Assignee | ||
Updated•21 years ago
|
Attachment #147114 -
Flags: review?(saari)
Assignee | ||
Comment 6•21 years ago
|
||
fix bug of space should also work when there is no focus element in previous
patch
Attachment #147113 -
Attachment is obsolete: true
Attachment #147114 -
Attachment is obsolete: true
Assignee | ||
Comment 7•21 years ago
|
||
wrong attachment in previous patch
Attachment #147203 -
Attachment is obsolete: true
Assignee | ||
Updated•21 years ago
|
Attachment #147204 -
Flags: review?(aaronleventhal)
Comment 8•21 years ago
|
||
Comment on attachment 147204 [details] [diff] [review]
patch for 214843
Couldn't the <a> also be a grandparent? Maybe you want something like this:
// Check to see if linked
for (nsIContent *findAnchorAncestor = child; findAnchorAncestor;
findAnchorAncestor = findAnchorAncestor->GetParent()) {
nsCOMPtr<nsIDOMHTMLAnchorElement> anchor =
do_QueryInterface(findAnchorAncestor);
if (anchor) {
break; // Found an anchor
}
}
if (!findAnchorAncestor) {
...
Assignee | ||
Comment 9•21 years ago
|
||
well, i think the while loop can find the grandparent, too. correct me if i made
any mistake.
Comment 10•21 years ago
|
||
Comment on attachment 147204 [details] [diff] [review]
patch for 214843
Sorry Neo, I missed thta in your patch. Not enough coffee or something.
Attachment #147204 -
Flags: review?(aaronleventhal) → review+
Assignee | ||
Updated•21 years ago
|
Attachment #147204 -
Flags: superreview?(jst)
Comment 11•21 years ago
|
||
Comment on attachment 147204 [details] [diff] [review]
patch for 214843
>-
>- if (focusedElement) {
>- nsAutoString tagName;
>- focusedElement->GetTagName(tagName);
>+ PRBool isA = PR_FALSE;
>+ if (focusedElement){
>+ while (focusedElement != nsnull) {
>+ nsAutoString tagName;
>+ focusedElement->GetTagName(tagName);
>
>- // if the focused element is a link then we do want space to
>- // scroll down.
>- if (tagName != NS_LITERAL_STRING("A"))
>+ // if the focused element is a link then we do want space to
>+ // scroll down. focused element may be an element in a link,
>+ // we need to check the parent node too.
>+ if (tagName == NS_LITERAL_STRING("A")) {
>+ isA = PR_TRUE;
>+ break;
>+ }
>+
>+ nsCOMPtr<nsIDOMNode> parentNode;
>+ focusedElement->GetParentNode(getter_AddRefs(parentNode));
>+ focusedElement = do_QueryInterface(parentNode);
>+ }
>+ if ( !isA )
> return NS_OK;
This would work, but it only fixes part of the problem, it doesn't fix the
problem for XLinks. How about making that loop look like this to take care of
both problems:
PRBool isLink = PR_FALSE;
nsCOMPtr<nsIContent> focusedContent = do_QueryInterface(focusedElement);
nsIContent *content = focusedContent;
// if the focused element is a link then we do want space to
// scroll down. focused element may be an element in a link,
// we need to check the parent node too.
while (content) {
if (content->Tag() == nsHTMLTags::a &&
content->IsContentOfType(nsIContent::eHTML)) {
isLink = PR_TRUE;
break;
}
if (content->HasAttr(kNameSpaceID_XLink, nsHTMLAtoms::type)) {
nsAutoString type;
content->GetAttr(kNameSpaceID_XLink, nsHTMLAtoms::type);
isLink = type.Equals(NS_LITERAL_STRING("simple"));
if (isLink) {
break;
}
}
content = content->GetParent();
}
if (!isLink)
return NS_OK;
sr=jst with tha change.
Attachment #147204 -
Flags: superreview?(jst) → superreview+
Comment 12•21 years ago
|
||
If we're going to do that, I suggest we encapsulate that logic in a method
somewhere, such as nsIContent->IsLinked().
We use similar checks in accessibility, find as you type, the focus code and
probably elsewhere, and we're adding lots of code each time. Also, what happens
when there's some new kind of link?
Comment 13•21 years ago
|
||
Aaron, I agree that it's lame to spread this code around, and I would love to
put it in a centralized place, but a method like that does IMO not belong in
nsIContent. If we'd have a singleton nsIContentUtils or somesuch, that would be
where this should go, but we don't yet, so there's no place yet to put a helper
like this.
Feel free to file a followup bug on centralizing the code to figure out if an
element is a link or not, but until then, I'd like us to proceed with the
proposal in this bug.
Assignee | ||
Comment 14•21 years ago
|
||
jst,
i'm not familla with XML. so could you help me explain why we just need consider
"simple" type with name space "xmlns:xlink", why not others such as "extended"?
Comment 15•21 years ago
|
||
Comment 16•21 years ago
|
||
attachment 147954 [details] [diff] [review] has been checked in.
Status: NEW → RESOLVED
Closed: 21 years ago
Resolution: --- → FIXED
Comment 17•21 years ago
|
||
Why do we need this loop at all? Surely it's up to those elements that want to
prevent space from scrolling to take steps to prevent it? Unfortunately it looks
like only textboxes and textareas do at the moment...
Assignee | ||
Comment 18•21 years ago
|
||
neil,
could you make a test case to break it?
thanks in advance and best regards,
Liu, Nian
Comment 19•21 years ago
|
||
You can't toggle the checkboxes with the space bar because the page scrolls.
Assignee | ||
Comment 20•21 years ago
|
||
my test result is that checkbox is toggled with page scroll. for input element
with type "textarea", it works fine( space is consumed by input element ).
Neil, seems that you have an idea where "textarea" consumes the space. where is it?
Comment 21•21 years ago
|
||
textarea actually uses nsPlaintextEditor.cpp to do its editing, the function
that handles keypresses is nsPlaintextEditor::HandleKeyPress which calls
aKeyEvent->PreventDefault() to stops the space key from scrolling the page. I
believe we need to do this for all elements that need to prevent scrolling. Then
we can get rid of this special code in the xbl prototype handler.
Assignee | ||
Comment 22•21 years ago
|
||
there are several things.
1.for checkbox. patch code got executed before nsHTMLInputElement::DoSetChecked.
so we can't use aEvent->PreventDefault() to stop propagation.
2.for textarea. there is an nsTextEditorKeyListener binded with it. so
aEvent->PreDefault() works.
i think the root cause is that Frame should get the event before
nsGenericHTMLElement::HandleDOMEvent
Comment 23•21 years ago
|
||
DoSetChecked gets called on key up...
Comment 24•20 years ago
|
||
Comment on attachment 147114 [details] [diff] [review]
patch for 214843
cancel obsolete review request
Attachment #147114 -
Flags: review?(saari)
Updated•6 years ago
|
Component: Event Handling → User events and focus handling
You need to log in
before you can comment on or make changes to this bug.
Description
•