Branch: refs/heads/master Author: Colomban Wendling ban@herbesfolles.org Committer: Colomban Wendling ban@herbesfolles.org Date: Tue, 20 Dec 2016 20:45:29 UTC Commit: 07c665197f8130b293007a7e3d7a58cf51af18fb https://github.com/geany/geany/commit/07c665197f8130b293007a7e3d7a58cf51af18...
Log Message: ----------- GTK: Ensure styles are valid when retrieving them for accessibility purposes
Modified Paths: -------------- scintilla/gtk/ScintillaGTKAccessible.cxx scintilla/gtk/ScintillaGTKAccessible.h
Modified: scintilla/gtk/ScintillaGTKAccessible.cxx 7 lines changed, 4 insertions(+), 3 deletions(-) =================================================================== @@ -478,7 +478,7 @@ void ScintillaGTKAccessible::GetCharacterExtents(int charOffset, } else if (nextByteOffset > byteOffset) { /* maybe next position was on the next line or something. * just compute the expected character width */ - int style = sci->pdoc->StyleAt(byteOffset); + int style = StyleAt(byteOffset, true); int len = nextByteOffset - byteOffset; char *ch = new char[len + 1]; sci->pdoc->GetCharRange(ch, byteOffset, len); @@ -556,13 +556,14 @@ AtkAttributeSet *ScintillaGTKAccessible::GetRunAttributes(int charOffset, int *s
g_return_val_if_fail(byteOffset <= length, NULL);
- const char style = sci->pdoc->StyleAt(byteOffset); + const char style = StyleAt(byteOffset, true); // compute the range for this style Position startByte = byteOffset; + // when going backwards, we know the style is already computed while (startByte > 0 && sci->pdoc->StyleAt((startByte) - 1) == style) (startByte)--; Position endByte = byteOffset + 1; - while (endByte < length && sci->pdoc->StyleAt(endByte) == style) + while (endByte < length && StyleAt(endByte, true) == style) (endByte)++;
CharacterRangeFromByteRange(startByte, endByte, startChar, endChar);
Modified: scintilla/gtk/ScintillaGTKAccessible.h 6 lines changed, 6 insertions(+), 0 deletions(-) =================================================================== @@ -73,6 +73,12 @@ class ScintillaGTKAccessible { return sci->pdoc->MovePositionOutsideChar(pos + 1, 1, true); }
+ int StyleAt(Position position, bool ensureStyle = false) { + if (ensureStyle) + sci->pdoc->EnsureStyledTo(position); + return sci->pdoc->StyleAt(position); + } + // For AtkText gchar *GetTextRangeUTF8(Position startByte, Position endByte); gchar *GetText(int startChar, int endChar);
-------------- This E-Mail was brought to you by github_commit_mail.py (Source: https://github.com/geany/infrastructure).