Kaydet (Commit) 07c66519 authored tarafından Colomban Wendling's avatar Colomban Wendling

GTK: Ensure styles are valid when retrieving them for accessibility purposes

üst a31a43ef
......@@ -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);
......
......@@ -73,6 +73,12 @@ private:
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);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment