mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 935254 - getTextAt broken for list items, r=tbsaunde
This commit is contained in:
parent
e04ac8799a
commit
9ac1ccac2d
@ -658,30 +658,15 @@ HyperTextAccessible::FindOffset(int32_t aOffset, nsDirection aDirection,
|
||||
// Turn the resulting node and offset into a hyperTextOffset
|
||||
// If finalAccessible is nullptr, then DOMPointToHypertextOffset() searched
|
||||
// through the hypertext children without finding the node/offset position.
|
||||
int32_t hyperTextOffset;
|
||||
int32_t hyperTextOffset = 0;
|
||||
Accessible* finalAccessible =
|
||||
DOMPointToHypertextOffset(pos.mResultContent, pos.mContentOffset,
|
||||
&hyperTextOffset, aDirection == eDirNext);
|
||||
|
||||
if (!finalAccessible && aDirection == eDirPrevious) {
|
||||
// If we reached the end during search, this means we didn't find the DOM point
|
||||
// and we're actually at the start of the paragraph
|
||||
hyperTextOffset = 0;
|
||||
}
|
||||
else if (aAmount == eSelectBeginLine) {
|
||||
Accessible* firstChild = mChildren.SafeElementAt(0, nullptr);
|
||||
// For line selection with needsStart, set start of line exactly to line break
|
||||
if (pos.mContentOffset == 0 && firstChild &&
|
||||
firstChild->Role() == roles::STATICTEXT &&
|
||||
static_cast<int32_t>(nsAccUtils::TextLength(firstChild)) == hyperTextOffset) {
|
||||
// XXX Bullet hack -- we should remove this once list bullets use anonymous content
|
||||
hyperTextOffset = 0;
|
||||
}
|
||||
if (aWordMovementType != eStartWord && aAmount != eSelectBeginLine &&
|
||||
hyperTextOffset > 0) {
|
||||
-- hyperTextOffset;
|
||||
}
|
||||
}
|
||||
if (!finalAccessible && aDirection == eDirPrevious)
|
||||
return 0;
|
||||
|
||||
return hyperTextOffset;
|
||||
}
|
||||
|
@ -432,7 +432,7 @@ protected:
|
||||
* Return an offset corresponding to the given direction and selection amount
|
||||
* relative the given offset. A helper used to find word or line boundaries.
|
||||
*/
|
||||
int32_t FindOffset(int32_t aOffset, nsDirection aDirection,
|
||||
virtual int32_t FindOffset(int32_t aOffset, nsDirection aDirection,
|
||||
nsSelectionAmount aAmount,
|
||||
EWordMovementType aWordMovementType = eDefaultBehavior);
|
||||
|
||||
|
@ -7,6 +7,7 @@
|
||||
#include "HTMLListAccessible.h"
|
||||
|
||||
#include "DocAccessible.h"
|
||||
#include "nsAccUtils.h"
|
||||
#include "Role.h"
|
||||
#include "States.h"
|
||||
|
||||
@ -97,6 +98,33 @@ HTMLLIAccessible::GetBounds(int32_t* aX, int32_t* aY,
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
int32_t
|
||||
HTMLLIAccessible::FindOffset(int32_t aOffset, nsDirection aDirection,
|
||||
nsSelectionAmount aAmount,
|
||||
EWordMovementType aWordMovementType)
|
||||
{
|
||||
Accessible* child = GetChildAtOffset(aOffset);
|
||||
if (!child)
|
||||
return -1;
|
||||
|
||||
if (child != mBullet) {
|
||||
if (aDirection == eDirPrevious &&
|
||||
(aAmount == eSelectBeginLine || aAmount == eSelectLine))
|
||||
return 0;
|
||||
|
||||
return HyperTextAccessible::FindOffset(aOffset, aDirection,
|
||||
aAmount, aWordMovementType);
|
||||
}
|
||||
|
||||
if (aDirection == eDirPrevious)
|
||||
return 0;
|
||||
|
||||
if (aAmount == eSelectEndLine || aAmount == eSelectLine)
|
||||
return CharacterCount();
|
||||
|
||||
return nsAccUtils::TextLength(child);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// HTMLLIAccessible: public
|
||||
|
||||
|
@ -55,7 +55,12 @@ public:
|
||||
virtual a11y::role NativeRole();
|
||||
virtual uint64_t NativeState();
|
||||
|
||||
// nsHTMLLIAccessible
|
||||
// HyperTextAccessible
|
||||
virtual int32_t FindOffset(int32_t aOffset, nsDirection aDirection,
|
||||
nsSelectionAmount aAmount,
|
||||
EWordMovementType aWordMovementType) MOZ_OVERRIDE;
|
||||
|
||||
// HTMLLIAccessible
|
||||
void UpdateBullet(bool aHasBullet);
|
||||
|
||||
protected:
|
||||
|
@ -79,7 +79,8 @@ const COORDTYPE_PARENT_RELATIVE = nsIAccessibleCoordinateType.COORDTYPE_PARENT_R
|
||||
|
||||
const kEmbedChar = String.fromCharCode(0xfffc);
|
||||
|
||||
const kDiscBulletText = String.fromCharCode(0x2022) + " ";
|
||||
const kDiscBulletChar = String.fromCharCode(0x2022);
|
||||
const kDiscBulletText = kDiscBulletChar + " ";
|
||||
const kCircleBulletText = String.fromCharCode(0x25e6) + " ";
|
||||
const kSquareBulletText = String.fromCharCode(0x25aa) + " ";
|
||||
|
||||
|
@ -108,6 +108,12 @@
|
||||
BOUNDARY_LINE_START,
|
||||
[ [ 0, 3, "foo\n", 0, 4 ], [ 4, 4, "", 4, 4 ] ]);
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
// list items
|
||||
|
||||
testTextAtOffset([ "li1" ], BOUNDARY_LINE_START,
|
||||
[ [ 0, 5, kDiscBulletChar + "Item", 0, 5 ] ]);
|
||||
|
||||
SimpleTest.finish();
|
||||
}
|
||||
|
||||
@ -166,5 +172,9 @@ two words
|
||||
|
||||
<iframe id="ht_2" src="data:text/html,<div contentEditable='true'>foo<br/></div>"></iframe>
|
||||
<iframe id="ht_3" src="data:text/html,<div contentEditable='true'>foo<br/><br/></div>"></iframe>
|
||||
|
||||
<ul>
|
||||
<li id="li1">Item</li>
|
||||
</ul>
|
||||
</body>
|
||||
</html>
|
||||
|
Loading…
Reference in New Issue
Block a user