> If we made n-many calls to 
> textPane.getAccessibleContext().getAccessibleText() then we'd add n-many 
> DocumentListeners to the HTMLDocument.
> 
> These listeners are very light, but even so: after thousands of listeners it 
> may start to degrade performance.
> 
> ---------
> - [x] I confirm that I make this contribution in accordance with the [OpenJDK 
> Interim AI Policy](https://openjdk.org/legal/ai).

Jeremy Wood has updated the pull request with a new target base due to a merge 
or a rebase. The incremental webrev excludes the unrelated changes brought in 
by the merge/rebase. The pull request contains seven additional commits since 
the last revision:

 - 8380790: reduce number of DocumentListeners
   
   This converts JEditorPaneAccessibleHypertextSupport from a field inside the 
AccessibleContext to a client property inside the JEditorPane. The 
AccessibleContext may be discarded and recreated as needed, but this lets us 
keep track of the JEditorPaneAccessibleHypertextSupport so we can uninstall its 
listeners when the Document changes.
   
   This brings us to change #2:
   Refactor JEditorPaneAccessibleHypertextSupport so it's constructor does NOT 
add an anonymous DocumentListener. Instead we can leverage the fact that 
JEditorPaneAccessibleHypertextSupport is already a DocumentListener, and just 
override its DocumentListener methods. This makes it easy for us to uninstall 
the DocumentListener logic.
 - Merge branch 'master' into 8380790
 - 8380790: make sure new Documents get axText listener
   
   This is in response to:
   https://github.com/openjdk/jdk/pull/30401#issuecomment-4144874584
   
   My current output from this test resembles:
   2 listeners  at "A"
        javax.swing.plaf.basic.BasicTextUI$UpdateHandler 0x165938a8
        javax.swing.text.DefaultCaret$Handler 0x13ad4587
   5 listeners  at "B"
        javax.swing.JEditorPane$JEditorPaneAccessibleHypertextSupport$1 
0x408dfc5d
        javax.swing.JEditorPane$JEditorPaneAccessibleHypertextSupport 0x6badfa89
        javax.swing.JEditorPane$AccessibleJEditorPaneHTML 0x8542bca
        javax.swing.plaf.basic.BasicTextUI$UpdateHandler 0x165938a8
        javax.swing.text.DefaultCaret$Handler 0x13ad4587
   4 listeners  at "C"
        javax.swing.JEditorPane$AccessibleJEditorPaneHTML 0x8542bca
        javax.swing.text.html.AccessibleHTML$DocumentHandler 0x2343eccf
        javax.swing.plaf.basic.BasicTextUI$UpdateHandler 0x165938a8
        javax.swing.text.DefaultCaret$Handler 0x13ad4587
   6 listeners  at "D"
        javax.swing.JEditorPane$JEditorPaneAccessibleHypertextSupport$1 
0x13117e17
        javax.swing.JEditorPane$JEditorPaneAccessibleHypertextSupport 0x491f0df7
        javax.swing.JEditorPane$AccessibleJEditorPaneHTML 0x8542bca
        javax.swing.text.html.AccessibleHTML$DocumentHandler 0x2343eccf
        javax.swing.plaf.basic.BasicTextUI$UpdateHandler 0x165938a8
        javax.swing.text.DefaultCaret$Handler 0x13ad4587
   
   I'm surprised at each point there are a different number of 
DocumentListeners, but this confirms that a new 
JEditorPane$JEditorPaneAccessibleHypertextSupport$1 is being added after 
setDocument(..)
 - 8377938: remove regtesthelpers & PassFailJFrame
   
   This is in response to:
   https://github.com/openjdk/jdk/pull/30401#discussion_r2997114800
 - 8380790: remove "/manual" from run tag
   
   This is in response to:
   https://github.com/openjdk/jdk/pull/30401#discussion_r2990839770
 - 8380790: add unit test
 - 8380790: reuse JEditorPaneAccessibleHypertextSupport
   
   getAccessibleText() is the only place JEditorPaneAccessibleHypertextSupport 
is constructed.
   
   (I don't see why JEditorPaneAccessibleHypertextSupport was written as a 
separate class. Ideally I'd consider flattening it into 
AccessibleJEditorPaneHTML. But since it's already released as a protected 
class: I don't want to risk refactoring it away in case some developers have 
dependencies around it.)

-------------

Changes:
  - all: https://git.openjdk.org/jdk/pull/30401/files
  - new: https://git.openjdk.org/jdk/pull/30401/files/e7b1c7aa..7d8d45e1

Webrevs:
 - full: https://webrevs.openjdk.org/?repo=jdk&pr=30401&range=04
 - incr: https://webrevs.openjdk.org/?repo=jdk&pr=30401&range=03-04

  Stats: 136087 lines in 3284 files changed: 73527 ins; 34402 del; 28158 mod
  Patch: https://git.openjdk.org/jdk/pull/30401.diff
  Fetch: git fetch https://git.openjdk.org/jdk.git pull/30401/head:pull/30401

PR: https://git.openjdk.org/jdk/pull/30401

Reply via email to