Skip to content

Commit

Permalink
Revert "Treat any HTML element with a tabindex attribute as interacti…
Browse files Browse the repository at this point in the history
…ve content"

This reverts commit 7920b6e.

It turns out that this change is not web compatible. In addition to
reverting the original change, we will seek to change the spec to
reflect this web reality.

Only the changes to Blink code are fully reverted. The tests are kept,
but adapted to reflect this change. A comment update is also kept.

Original change's description:
> Treat any HTML element with a tabindex attribute as interactive content
>
> According to the HTML Standard [1]:
>
> > An element with the tabindex attribute specified is interactive
> > content.
>
> In a subsequent review [2], this clause is reaffirmed by the editor of
> HTML. Thus, we implement this accordingly.
>
> This commit also adds comprehensive testing for all kinds of interactive
> content, which have differential treatment by the <label> element
> relative to other elements.
>
> [1]: https://html.spec.whatwg.org/C/#the-tabindex-attribute
> [2]: whatwg/html#5414
>
> Fixed: 1065048
> Change-Id: I8deff810fead2c9170e18dd4d06dc642f68e6742
> Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2122369
> Commit-Queue: Timothy Gu <timothygu@chromium.org>
> Reviewed-by: Kent Tamura <tkent@chromium.org>
> Reviewed-by: Mason Freed <masonfreed@chromium.org>
> Cr-Commit-Position: refs/heads/master@{#757590}

Bug: 1065048
Change-Id: Ic32dbb9ac8eafb9b92a131fde71c5459029260e2
Fixed: 1069615
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2146089
Reviewed-by: Kent Tamura <tkent@chromium.org>
Reviewed-by: Mason Freed <masonfreed@chromium.org>
Commit-Queue: Timothy Gu <timothygu@chromium.org>
Cr-Commit-Position: refs/heads/master@{#758568}
  • Loading branch information
TimothyGu authored and Commit Bot committed Apr 13, 2020
1 parent 2d3f45b commit 0ef2cae
Show file tree
Hide file tree
Showing 8 changed files with 16 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1989,8 +1989,7 @@ void HTMLInputElement::SetShouldRevealPassword(bool value) {
}

bool HTMLInputElement::IsInteractiveContent() const {
return input_type_->IsInteractiveContent() ||
HTMLElement::IsInteractiveContent();
return input_type_->IsInteractiveContent();
}

scoped_refptr<ComputedStyle> HTMLInputElement::CustomStyleForLayoutObject() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -582,7 +582,7 @@ bool HTMLAnchorElement::WillRespondToMouseClickEvents() {
}

bool HTMLAnchorElement::IsInteractiveContent() const {
return IsLink() || HTMLElement::IsInteractiveContent();
return IsLink();
}

Node::InsertionNotificationRequest HTMLAnchorElement::InsertedInto(
Expand Down
2 changes: 1 addition & 1 deletion third_party/blink/renderer/core/html/html_element.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1374,7 +1374,7 @@ LabelsNodeList* HTMLElement::labels() {
}

bool HTMLElement::IsInteractiveContent() const {
return FastHasAttribute(html_names::kTabindexAttr);
return false;
}

void HTMLElement::DefaultEventHandler(Event& event) {
Expand Down
3 changes: 1 addition & 2 deletions third_party/blink/renderer/core/html/html_image_element.cc
Original file line number Diff line number Diff line change
Expand Up @@ -667,8 +667,7 @@ Image* HTMLImageElement::ImageContents() {
}

bool HTMLImageElement::IsInteractiveContent() const {
return FastHasAttribute(html_names::kUsemapAttr) ||
HTMLElement::IsInteractiveContent();
return FastHasAttribute(html_names::kUsemapAttr);
}

FloatSize HTMLImageElement::DefaultDestinationSize(
Expand Down
3 changes: 1 addition & 2 deletions third_party/blink/renderer/core/html/html_object_element.cc
Original file line number Diff line number Diff line change
Expand Up @@ -408,8 +408,7 @@ HTMLFormElement* HTMLObjectElement::formOwner() const {
}

bool HTMLObjectElement::IsInteractiveContent() const {
return FastHasAttribute(html_names::kUsemapAttr) ||
HTMLElement::IsInteractiveContent();
return FastHasAttribute(html_names::kUsemapAttr);
}

bool HTMLObjectElement::UseFallbackContent() const {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3998,8 +3998,7 @@ void HTMLMediaElement::MediaSourceOpened(WebMediaSource* web_media_source) {
}

bool HTMLMediaElement::IsInteractiveContent() const {
return FastHasAttribute(html_names::kControlsAttr) ||
HTMLElement::IsInteractiveContent();
return FastHasAttribute(html_names::kControlsAttr);
}

void HTMLMediaElement::Trace(Visitor* visitor) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,17 +19,6 @@
<select></select>
<textarea></textarea>
<video controls></video>

<div tabindex=""></div>

<!-- These are interesting in that even without tabindex, they could become
interactive with the addition/removal of an attribute. -->
<a tabindex=""></a>
<audio tabindex=""></audio>
<img tabindex="">
<input type=hidden tabindex="">
<object tabindex=""></object>
<video tabindex=""></video>
</template>

<script>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,16 @@
<input type=hidden>
<object></object>
<video></video>

<!-- These are considered interactive content for the purpose of <label> in a
previous version of the HTML Standard, but no longer. -->
<a tabindex=""></a>
<audio tabindex=""></audio>
<div tabindex=""></div>
<img tabindex="">
<input type=hidden tabindex="">
<object tabindex=""></object>
<video tabindex=""></video>
</template>

<script>
Expand Down

0 comments on commit 0ef2cae

Please sign in to comment.