> 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 11 additional commits since the 
last revision:

 - Merge remote-tracking branch 'origin/master' into 8380790
 - 8380790: adding new test
   
   I was worried this PR might uninstall the hypertext support object 
prematurely. But this test passes without any further intervention. (Maybe the 
hypertext support object IS being uninstalled, but that's OK because a 
replacement is lazily installed the next time we check.)
 - 8380790: trivial formatting cleanup
 - 8380790: trivial formatting cleanup
 - 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
 - ... and 1 more: https://git.openjdk.org/jdk/compare/0c39a937...42ee8ad3

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

Changes:
  - all: https://git.openjdk.org/jdk/pull/30401/files
  - new: https://git.openjdk.org/jdk/pull/30401/files/ecf42005..42ee8ad3

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

  Stats: 57434 lines in 382 files changed: 4125 ins; 52578 del; 731 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