From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: "T.V Raman" Newsgroups: gmane.emacs.bugs Subject: bug#32348: 27.0.50; EWW/SHR: Please add support for hiding DOM nodes with aria-hidden=true Date: Wed, 15 Aug 2018 19:23:11 -0700 Message-ID: References: <874lg5y9c7.fsf@gmail.com> <23402.64973.657426.239435@retriever.mtv.corp.google.com> <87a7pnxk6r.fsf@gmail.com> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: blaine.gmane.org 1534386143 16586 195.159.176.226 (16 Aug 2018 02:22:23 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Thu, 16 Aug 2018 02:22:23 +0000 (UTC) User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.0.50 (gnu/linux) Cc: 32348@debbugs.gnu.org To: Noam Postavsky Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Thu Aug 16 04:22:19 2018 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1fq7vW-0004CQ-V8 for geb-bug-gnu-emacs@m.gmane.org; Thu, 16 Aug 2018 04:22:19 +0200 Original-Received: from localhost ([::1]:53131 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fq7xb-0004fu-Tb for geb-bug-gnu-emacs@m.gmane.org; Wed, 15 Aug 2018 22:24:27 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:41396) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fq7xT-0004fl-Nv for bug-gnu-emacs@gnu.org; Wed, 15 Aug 2018 22:24:23 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fq7xL-0005v8-Kd for bug-gnu-emacs@gnu.org; Wed, 15 Aug 2018 22:24:17 -0400 Original-Received: from debbugs.gnu.org ([208.118.235.43]:47183) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fq7xC-0005sG-5C for bug-gnu-emacs@gnu.org; Wed, 15 Aug 2018 22:24:04 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1fq7xC-0002Au-0W for bug-gnu-emacs@gnu.org; Wed, 15 Aug 2018 22:24:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: "T.V Raman" Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Thu, 16 Aug 2018 02:24:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 32348 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch Original-Received: via spool by 32348-submit@debbugs.gnu.org id=B32348.15343862038315 (code B ref 32348); Thu, 16 Aug 2018 02:24:01 +0000 Original-Received: (at 32348) by debbugs.gnu.org; 16 Aug 2018 02:23:23 +0000 Original-Received: from localhost ([127.0.0.1]:52201 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1fq7wY-0002A2-N7 for submit@debbugs.gnu.org; Wed, 15 Aug 2018 22:23:22 -0400 Original-Received: from mail-pf1-f180.google.com ([209.85.210.180]:45450) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1fq7wX-00029p-8m for 32348@debbugs.gnu.org; Wed, 15 Aug 2018 22:23:21 -0400 Original-Received: by mail-pf1-f180.google.com with SMTP id i26-v6so1287861pfo.12 for <32348@debbugs.gnu.org>; Wed, 15 Aug 2018 19:23:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=from:to:cc:subject:references:date:in-reply-to:message-id :user-agent:mime-version; bh=YDnbpyKrsGMPSamGEN4vWyOxqchVpda/gpZcAogAWwg=; b=Njfav1e008DwRjM2utR0gwkcLeHc6gVHQzH7Ck82uruHD1jjbgrWHFiqrUokkUHlVu FsUb/Py8/gSNSRq4zaCyrwsh8dsWolC/EtanIUspA1cZzZBihO9dDm3pmX4rY+LmRLqN Lfn2kpxYdp5iZ5U9+yFBf54OnjLCZnx+qW18AO6FfK2zhZWuJGaVOsv167HHY8EMTRri BejqTAwyZvhH1KStYjF36ZBVztdzZZn+NU4kZcBrqkCjcScH2BrWgG/z5DBJTj+QkiKo enp0T85Baq3z4yuaXAzZ3wXcE75q8p8RVoLp1f0k+OE0nRWMqBNyzh7ftrccCat4bjL/ IYkA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:references:date:in-reply-to :message-id:user-agent:mime-version; bh=YDnbpyKrsGMPSamGEN4vWyOxqchVpda/gpZcAogAWwg=; b=bZFdrcI/4XjKsylB3R2gJu6XFYFY0RUz27xt5cHXeXjoZWY3ml4LclH5mIIPI9QFV8 RwDhKf4hoeHqc0f4p4ywElXRK1q3It6Pm5UBpNx/2y1rJuTBSUGQUxjtfb6lASaxnTjT nmHAVtKmk7URw+SJ7GA7uMpKJ02bDyUxRXyNB2yPQs1oPYn0PMg49Hjr/Oj9ySf3axzT H7XyyipnFoIldAn8S7ksR9sXELKt6dZASAtMcrOMfdFC2v9Xmv3p1vQPmd4i6yfyUeCC qiG2SqrG8CvLbEwQ6zt4B98ZDmrA7RfZkAkYkKB3WUcwUd6fqsuoe1ikhr+3yVR40JO+ 5yFA== X-Gm-Message-State: AOUpUlE6EBnxZgYuKLmArSiSSm4WOdnE72meNgSt0Mv4h+5qcYgOUuHi MJQR5siJxHSGE4XHAEEe7Cs7FQ== X-Google-Smtp-Source: AA+uWPyG86/ShYzFjnzOJGskgv1EUbxHZ19o5Q2JGcsnMlE3p4BEDbnN/rokRATZWSgo1M5zQ5HUIQ== X-Received: by 2002:a63:ae42:: with SMTP id e2-v6mr24578727pgp.351.1534386194718; Wed, 15 Aug 2018 19:23:14 -0700 (PDT) Original-Received: from raman-glaptop (c-24-4-174-65.hsd1.ca.comcast.net. [24.4.174.65]) by smtp.gmail.com with ESMTPSA id n9-v6sm40450423pfg.21.2018.08.15.19.23.12 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 15 Aug 2018 19:23:13 -0700 (PDT) In-Reply-To: <87a7pnxk6r.fsf@gmail.com> (Noam Postavsky's message of "Wed, 15 Aug 2018 19:51:40 -0400") X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 208.118.235.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.org gmane.emacs.bugs:149522 Archived-At: Noam Postavsky writes: Yes, please go ahead and push to Master. Re the comment about including in eww's readable, it gets rid of the zillion "share with" links on sites like the BBc. > "T.V Raman" writes: > >> Another place to leverage aria-hidden might be in EWW's "readable" >> command. Note that in general those nodes are shown on screen but are >> useless for the most part -- and usually inoperable under EWW. As an >> example, articles from the BBC for instance use these nodes to add >> buttons for "share via messenger" etc. > > Unless the "readable" command is actually giving bad results for > real-world pages (is it?), I wouldn't start complicating the heuristic > with more checks. It doesn't even check for display:none at the moment. > > I've updated my previous patch with some more documentation, so that > someone who doesn't know anything about "aria-hidden" (e.g., me, before > this thread) could have some chance of figuring out what it's good for. > I'll push to master in a few days. > > From ead5619e844fced271866349fd34990641bf75c6 Mon Sep 17 00:00:00 2001 > From: Noam Postavsky > Date: Tue, 7 Aug 2018 20:40:56 -0400 > Subject: [PATCH v2] Optionally skip rendering of tags with aria-hidden > (Bug#32348) > > * lisp/net/shr.el (shr-discard-aria-hidden): New option. > (shr-descend): Suppress aria-hidden=true tags if it's set. > * doc/misc/eww.texi (Advanced): Document shr-discard-aria-hidden. > * etc/NEWS: Announce it. > > fixup! shr: Allow skipping tags with aria-hidden (Bug#32348) > --- > doc/misc/eww.texi | 10 ++++++++++ > etc/NEWS | 3 +++ > lisp/net/shr.el | 12 +++++++++++- > 3 files changed, 24 insertions(+), 1 deletion(-) > > diff --git a/doc/misc/eww.texi b/doc/misc/eww.texi > index 43adc2eda0..bd5aef6a8a 100644 > --- a/doc/misc/eww.texi > +++ b/doc/misc/eww.texi > @@ -262,6 +262,16 @@ Advanced > variables @code{shr-color-visible-distance-min} and > @code{shr-color-visible-luminance-min} to get a better contrast. > > +@vindex shr-discard-aria-hidden > +@cindex aria-hidden > + The HTML attribute @code{aria-hidden} is meant to tell screen > +readers to ignore a tag's contents. You can customize the variable > +@code{shr-discard-aria-hidden} to tell @code{shr} to ignore such tags. > +This can be useful when using a screen reader on the output of > +@code{shr} (e.g., on EWW buffer text). Or even when not using a > +screen reader, since web authors often put this tag on non-essential > +decorative content. > + > @cindex Desktop Support > @cindex Saving Sessions > In addition to maintaining the history at run-time, EWW will also > diff --git a/etc/NEWS b/etc/NEWS > index 60951dfac0..d2e111fd60 100644 > --- a/etc/NEWS > +++ b/etc/NEWS > @@ -396,6 +396,9 @@ and its value has been changed to Duck Duck Go. > 'shr-selected-link' face to give the user feedback that the command > has been executed. > > ++++ > +*** New option 'shr-discard-aria-hidden'. > + > ** Htmlfontify > > *** The functions 'hfy-color', 'hfy-color-vals' and > diff --git a/lisp/net/shr.el b/lisp/net/shr.el > index edea7cb297..0fbaf6f211 100644 > --- a/lisp/net/shr.el > +++ b/lisp/net/shr.el > @@ -68,6 +68,14 @@ shr-use-fonts > :group 'shr > :type 'boolean) > > +(defcustom shr-discard-aria-hidden nil > + "If non-nil, don't render tags with `aria-hidden=\"true\"'. > +This attribute is meant to tell screen readers to ignore the > +tag's content." > + :version "27.1" > + :group 'shr > + :type 'boolean) > + > (defcustom shr-use-colors t > "If non-nil, respect color specifications in the HTML." > :version "26.1" > @@ -509,7 +517,9 @@ shr-descend > shr-stylesheet)) > (setq style nil))) > ;; If we have a display:none, then just ignore this part of the DOM. > - (unless (equal (cdr (assq 'display shr-stylesheet)) "none") > + (unless (or (equal (cdr (assq 'display shr-stylesheet)) "none") > + (and shr-discard-aria-hidden > + (equal (dom-attr dom 'aria-hidden) "true"))) > ;; We don't use shr-indirect-call here, since shr-descend is > ;; the central bit of shr.el, and should be as fast as > ;; possible. Having one more level of indirection with its --