Auto merge of #5858 - pgonda:tabindex-focus-flag, r=jdm

Added support for the tabindex field, also added its correct defaults (-2 TODOs for things not supported in Servo yet).  Also added tabindex logic into Element::is_focusable_area.

<!-- Reviewable:start -->
[<img src="https://reviewable.io/review_button.png" height=40 alt="Review on Reviewable"/>](https://reviewable.io/reviews/servo/servo/5858)
<!-- Reviewable:end -->
This commit is contained in:
bors-servo 2015-05-20 14:34:31 -05:00
commit fada39164c
6 changed files with 80 additions and 16 deletions

View file

@ -54,7 +54,7 @@ use dom::htmltablecellelement::{HTMLTableCellElement, HTMLTableCellElementHelper
use dom::htmltablerowelement::{HTMLTableRowElement, HTMLTableRowElementHelpers};
use dom::htmltablesectionelement::{HTMLTableSectionElement, HTMLTableSectionElementHelpers};
use dom::htmltextareaelement::{HTMLTextAreaElement, RawLayoutHTMLTextAreaElementHelpers};
use dom::node::{CLICK_IN_PROGRESS, LayoutNodeHelpers, Node, NodeHelpers, NodeTypeId};
use dom::node::{CLICK_IN_PROGRESS, LayoutNodeHelpers, Node, NodeHelpers, NodeTypeId, SEQUENTIALLY_FOCUSABLE};
use dom::node::{document_from_node, NodeDamage};
use dom::node::{window_from_node};
use dom::nodelist::NodeList;
@ -757,9 +757,11 @@ impl<'a> FocusElementHelpers for JSRef<'a, Element> {
return false;
}
// TODO: Check whether the element is being rendered (i.e. not hidden).
// TODO: Check the tabindex focus flag.
// https://html.spec.whatwg.org/multipage/#specially-focusable
let node: JSRef<Node> = NodeCast::from_ref(self);
if node.get_flag(SEQUENTIALLY_FOCUSABLE) {
return true;
}
// https://html.spec.whatwg.org/multipage/#specially-focusable
match node.type_id() {
NodeTypeId::Element(ElementTypeId::HTMLElement(HTMLElementTypeId::HTMLAnchorElement)) |
NodeTypeId::Element(ElementTypeId::HTMLElement(HTMLElementTypeId::HTMLInputElement)) |
@ -979,6 +981,9 @@ impl<'a> AttributeHandlers for JSRef<'a, Element> {
self.attrs.borrow_mut().remove(idx);
attr.r().set_owner(None);
if attr.r().namespace() == &ns!("") {
vtable_for(&NodeCast::from_ref(self)).after_remove_attr(attr.r().name());
}
let node: JSRef<Node> = NodeCast::from_ref(self);
if node.is_in_doc() {