зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1690342 - P4: Implement IPC attributed text getter. r=morgan DONTBUILD
Differential Revision: https://phabricator.services.mozilla.com/D103802
This commit is contained in:
Родитель
b9559d486e
Коммит
cb03a1923c
|
@ -8,6 +8,8 @@
|
|||
|
||||
#include "DocAccessibleChild.h"
|
||||
#include "HyperTextAccessibleWrap.h"
|
||||
#include "nsPersistentProperties.h"
|
||||
#include "nsAccUtils.h"
|
||||
|
||||
#define UNIQUE_ID(acc) \
|
||||
!acc || acc->Document() == acc ? 0 \
|
||||
|
@ -201,6 +203,30 @@ DocAccessiblePlatformExtChild::RecvAttributedTextForRange(
|
|||
const uint64_t& aID, const int32_t& aStartOffset,
|
||||
const uint64_t& aEndContainer, const int32_t& aEndOffset,
|
||||
nsTArray<TextAttributesRun>* aAttributes) {
|
||||
HyperTextAccessibleWrap* acc = IdToHyperTextAccessibleWrap(aID);
|
||||
HyperTextAccessibleWrap* endContainer =
|
||||
IdToHyperTextAccessibleWrap(aEndContainer);
|
||||
if (!acc || !endContainer) {
|
||||
return IPC_OK();
|
||||
}
|
||||
|
||||
nsTArray<nsString> texts;
|
||||
nsTArray<Accessible*> containers;
|
||||
nsTArray<nsCOMPtr<nsIPersistentProperties>> props;
|
||||
|
||||
acc->AttributedTextForRange(texts, props, containers, aStartOffset,
|
||||
endContainer, aEndOffset);
|
||||
|
||||
MOZ_ASSERT(texts.Length() == props.Length() &&
|
||||
texts.Length() == containers.Length());
|
||||
|
||||
for (size_t i = 0; i < texts.Length(); i++) {
|
||||
nsTArray<Attribute> textAttrArray;
|
||||
nsAccUtils::PersistentPropertiesToArray(props.ElementAt(i), &textAttrArray);
|
||||
aAttributes->AppendElement(TextAttributesRun(
|
||||
texts.ElementAt(i), UNIQUE_ID(containers.ElementAt(i)), textAttrArray));
|
||||
}
|
||||
|
||||
return IPC_OK();
|
||||
}
|
||||
|
||||
|
|
|
@ -489,9 +489,26 @@ NSAttributedString* GeckoTextMarkerRange::AttributedText() const {
|
|||
[[[NSMutableAttributedString alloc] init] autorelease];
|
||||
|
||||
if (mStart.mContainer.IsProxy() && mEnd.mContainer.IsProxy()) {
|
||||
NSAttributedString* substr =
|
||||
[[[NSAttributedString alloc] initWithString:Text()] autorelease];
|
||||
[str appendAttributedString:substr];
|
||||
nsTArray<TextAttributesRun> textAttributesRuns;
|
||||
DocAccessibleParent* ipcDoc = mStart.mContainer.AsProxy()->Document();
|
||||
Unused << ipcDoc->GetPlatformExtension()->SendAttributedTextForRange(
|
||||
mStart.mContainer.AsProxy()->ID(), mStart.mOffset,
|
||||
mEnd.mContainer.AsProxy()->ID(), mEnd.mOffset, &textAttributesRuns);
|
||||
|
||||
for (size_t i = 0; i < textAttributesRuns.Length(); i++) {
|
||||
nsTArray<Attribute>& attributes =
|
||||
textAttributesRuns.ElementAt(i).TextAttributes();
|
||||
ProxyAccessible* container =
|
||||
ipcDoc->GetAccessible(textAttributesRuns.ElementAt(i).ContainerID());
|
||||
|
||||
NSAttributedString* substr = [[[NSAttributedString alloc]
|
||||
initWithString:nsCocoaUtils::ToNSString(
|
||||
textAttributesRuns.ElementAt(i).Text())
|
||||
attributes:StringAttributesFromAttributes(attributes, container)]
|
||||
autorelease];
|
||||
|
||||
[str appendAttributedString:substr];
|
||||
}
|
||||
} else if (auto htWrap = mStart.ContainerAsHyperTextWrap()) {
|
||||
nsTArray<nsString> texts;
|
||||
nsTArray<Accessible*> containers;
|
||||
|
|
|
@ -49,4 +49,3 @@ skip-if = os == 'mac' && debug # Bug 1664577
|
|||
[browser_aria_busy.js]
|
||||
[browser_aria_controls_flowto.js]
|
||||
[browser_attributed_text.js]
|
||||
skip-if = os != 'mac' || e10s
|
||||
|
|
Загрузка…
Ссылка в новой задаче