From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Noam Postavsky 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:51:40 -0400 Message-ID: <87a7pnxk6r.fsf@gmail.com> References: <874lg5y9c7.fsf@gmail.com> <23402.64973.657426.239435@retriever.mtv.corp.google.com> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Trace: blaine.gmane.org 1534377009 2579 195.159.176.226 (15 Aug 2018 23:50:09 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Wed, 15 Aug 2018 23:50:09 +0000 (UTC) User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.1 (gnu/linux) Cc: 32348@debbugs.gnu.org To: "T.V Raman" Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Thu Aug 16 01:50:05 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 1fq5YC-0000Vq-SS for geb-bug-gnu-emacs@m.gmane.org; Thu, 16 Aug 2018 01:50:05 +0200 Original-Received: from localhost ([::1]:52707 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fq5aH-0002Pb-Ky for geb-bug-gnu-emacs@m.gmane.org; Wed, 15 Aug 2018 19:52:13 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:46695) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fq5aA-0002PT-IV for bug-gnu-emacs@gnu.org; Wed, 15 Aug 2018 19:52:07 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fq5a6-00035l-HQ for bug-gnu-emacs@gnu.org; Wed, 15 Aug 2018 19:52:06 -0400 Original-Received: from debbugs.gnu.org ([208.118.235.43]:47120) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fq5a6-00035d-Be for bug-gnu-emacs@gnu.org; Wed, 15 Aug 2018 19:52:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1fq5a5-0002y4-O0 for bug-gnu-emacs@gnu.org; Wed, 15 Aug 2018 19:52:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Noam Postavsky Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Wed, 15 Aug 2018 23:52: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.153437711011389 (code B ref 32348); Wed, 15 Aug 2018 23:52:01 +0000 Original-Received: (at 32348) by debbugs.gnu.org; 15 Aug 2018 23:51:50 +0000 Original-Received: from localhost ([127.0.0.1]:52138 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1fq5Zt-0002xc-Nt for submit@debbugs.gnu.org; Wed, 15 Aug 2018 19:51:50 -0400 Original-Received: from mail-it0-f47.google.com ([209.85.214.47]:40679) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1fq5Zs-0002xN-G3 for 32348@debbugs.gnu.org; Wed, 15 Aug 2018 19:51:48 -0400 Original-Received: by mail-it0-f47.google.com with SMTP id h23-v6so4318700ita.5 for <32348@debbugs.gnu.org>; Wed, 15 Aug 2018 16:51:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:references:date:in-reply-to:message-id :user-agent:mime-version; bh=DEpLBpZnhidn8l8BFixK6HkiosavZ2iiJVZPNBkUkR4=; b=YIAStqtHCiLK9geju5ksOoBMufvWHKCcpifRolGwH/8OCKxIfv+0aSxa4Fu5Ti+IDp dh30mLeMNlic91/OhtydF2HWmFUO4PjDn2ycWhvdKXw8xzzZwq90ulXUqbVQ2jqm/h3Y IWmQ0I0RQZL5oxVxTa1dRLNc8aex0C/fEDRVYIbr3/a3IsR00OIBww44ec/Dw+eJJdvL G2DM4+0X4aBLcGolvLw5JhIQkkw5XWeymxGDNnA92E3IZCNlkPfSeDBIPhcClwmyF0k/ AWFcrF18rrvD8GnS7sI6rrbS0XHNsiXJBH5wbb0jhZb9uU0hKJxS5iEWBa+/2+bcdka3 WK6Q== 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=DEpLBpZnhidn8l8BFixK6HkiosavZ2iiJVZPNBkUkR4=; b=sFycee62BMlGVW9n9LzoqjTCXSukokkJD+V9hfApzdgTRIJTsmGYTs9JDVmphRBMcV Wa3gnY3tBEG4gXgf4tz3cGKiM7MDbR+KQQco65OwS4IC+Y/aEo6uot7gnsuOdoubd70Z JqaOo/QPZ22VcjdWCu8F9FV9hUAgxe2D/Bta3VxQaft39fU4Pn2eoaV2ouzHQKDOLVHh uV1xjVTuP06SHjsV1SIGl9clGuNereOrIvXp64utYmFJ6MWeWCtNaB4rb2/CS2NiFhmb hmBval0UXTRUZXU+y5BCXtR4J7bqZsdqRNa+xE2YA91zJqqVOd8TKA7JOfJLBOxeze97 CVXA== X-Gm-Message-State: AOUpUlHlBpobrKOOBCfwpQmMi5pg/hceTeT7QfJ0AdS4Zm7ixvykYmLi Z7Fh24Pt7Wq0JQapbsZBftQjOWb1 X-Google-Smtp-Source: AA+uWPzDS3j08Cbvtg6IJIErJeEBcsm2tvT/T1DBBXj2mgx0kpF4HnuXHsRCInHxLQxt1Lq8khv7xw== X-Received: by 2002:a24:9343:: with SMTP id y64-v6mr19713676itd.33.1534377102561; Wed, 15 Aug 2018 16:51:42 -0700 (PDT) Original-Received: from zebian (cbl-45-2-119-34.yyz.frontiernetworks.ca. [45.2.119.34]) by smtp.googlemail.com with ESMTPSA id c2-v6sm9015648iob.41.2018.08.15.16.51.41 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 15 Aug 2018 16:51:41 -0700 (PDT) In-Reply-To: <23402.64973.657426.239435@retriever.mtv.corp.google.com> (T. V. Raman's message of "Wed, 8 Aug 2018 07:27:25 -0700") 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:149518 Archived-At: --=-=-= Content-Type: text/plain "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. --=-=-= Content-Type: text/x-diff Content-Disposition: inline; filename=v2-0001-Optionally-skip-rendering-of-tags-with-aria-hidde.patch Content-Description: patch >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 -- 2.11.0 --=-=-=--