On Thu, 19 Jun 2025 04:02:30 GMT, Prasanta Sadhukhan <psadhuk...@openjdk.org> wrote:
>> getVisibleEditorRect() return the bounds of the text editor and the return >> value is used to to set-size/paint the >> `javax.swing.text.View` of this text editor component. >> "the allocation" refers to what allocated area the view needs to paint, it >> seems to be a common phrase used in context of View class which says >> >>> "The view gets its allocation from the parent at paint time, so it must be >>> prepared to redo layout if the allocated area is different from what it is >>> prepared to deal with. " >> >> In that regard, probably getAllocatedViewRect() would have been better >> choice of the method name > > getVisibleEditorRect() return the bounds of the text editor and the return > value is used to to set-size/paint the > `javax.swing.text.View` of this text editor component. > "the allocation" refers to what allocated area the view needs to paint, it > seems to be a common phrase used in context of View class which says > >> "The view gets its allocation from the parent at paint time, so it must be >> prepared to redo layout if the allocated area is different from what it is >> prepared to deal with. " > > In that regard, probably getAllocatedViewRect() would have been better choice > of the method name The term _allocation_ is commonly used in [javax.swing.text.View](https://docs.oracle.com/en/java/javase/24/docs/api/java.desktop/javax/swing/text/View.html) and its subclasses, for example, <q cite="https://docs.oracle.com/en/java/javase/24/docs/api/java.desktop/javax/swing/text/View.html">The view gets its *allocation* from the parent at paint time,</q> and <q cite="https://docs.oracle.com/en/java/javase/24/docs/api/java.desktop/javax/swing/text/View.html">While a view may render into its entire *allocation*, typically a view does not.</q> (Emphasis mine.) The `View` class has a method [`getChildAllocation`](https://docs.oracle.com/en/java/javase/24/docs/api/java.desktop/javax/swing/text/View.html#getChildAllocation(int,java.awt.Shape)). Essentially, the allocation for text view means the **size and position** of the view. In this case, the returned rectangle is used an allocation for the root view to perform painting. https://github.com/openjdk/jdk/blob/0dce98b71648f270dca7395e7ab5451011b14b45/src/java.desktop/share/classes/javax/swing/plaf/basic/BasicTextUI.java#L767-L771 I do **not** think this method should explain what the *allocation* means; it may point to the `View` class. ------------- PR Review Comment: https://git.openjdk.org/jdk/pull/25850#discussion_r2156547023