Bug 1597916 - Allow frameless containers when dispatching text removed events. r=Jamie

This reverts the change I made in bug 1572811, and instead fixes a much
more narrow case when the inner table frame is mid-construction.

Differential Revision: https://phabricator.services.mozilla.com/D58570

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Eitan Isaacson 2020-01-13 01:02:51 +00:00
Родитель 8b09f8ec79
Коммит c676e8c521
4 изменённых файлов: 67 добавлений и 18 удалений

Просмотреть файл

@ -192,9 +192,7 @@ bool NotificationController::QueueMutationEvent(AccTreeMutationEvent* aEvent) {
// It is not possible to have a text change event for something other than a
// hyper text accessible.
// If the accessible doesn't have a frame, we are probably mid frame
// destruction bail early.
if (!container->IsHyperText() || !container->GetFrame()) {
if (!container->IsHyperText()) {
return true;
}

Просмотреть файл

@ -428,17 +428,17 @@ void HTMLTableAccessible::Summary(nsString& aSummary) {
}
uint32_t HTMLTableAccessible::ColCount() const {
nsTableWrapperFrame* tableFrame = do_QueryFrame(mContent->GetPrimaryFrame());
nsTableWrapperFrame* tableFrame = GetTableWrapperFrame();
return tableFrame ? tableFrame->GetColCount() : 0;
}
uint32_t HTMLTableAccessible::RowCount() {
nsTableWrapperFrame* tableFrame = do_QueryFrame(mContent->GetPrimaryFrame());
nsTableWrapperFrame* tableFrame = GetTableWrapperFrame();
return tableFrame ? tableFrame->GetRowCount() : 0;
}
uint32_t HTMLTableAccessible::SelectedCellCount() {
nsTableWrapperFrame* tableFrame = do_QueryFrame(mContent->GetPrimaryFrame());
nsTableWrapperFrame* tableFrame = GetTableWrapperFrame();
if (!tableFrame) return 0;
uint32_t count = 0, rowCount = RowCount(), colCount = ColCount();
@ -475,7 +475,7 @@ uint32_t HTMLTableAccessible::SelectedRowCount() {
}
void HTMLTableAccessible::SelectedCells(nsTArray<Accessible*>* aCells) {
nsTableWrapperFrame* tableFrame = do_QueryFrame(mContent->GetPrimaryFrame());
nsTableWrapperFrame* tableFrame = GetTableWrapperFrame();
if (!tableFrame) return;
uint32_t rowCount = RowCount(), colCount = ColCount();
@ -495,7 +495,7 @@ void HTMLTableAccessible::SelectedCells(nsTArray<Accessible*>* aCells) {
}
void HTMLTableAccessible::SelectedCellIndices(nsTArray<uint32_t>* aCells) {
nsTableWrapperFrame* tableFrame = do_QueryFrame(mContent->GetPrimaryFrame());
nsTableWrapperFrame* tableFrame = GetTableWrapperFrame();
if (!tableFrame) return;
uint32_t rowCount = RowCount(), colCount = ColCount();
@ -525,7 +525,7 @@ void HTMLTableAccessible::SelectedRowIndices(nsTArray<uint32_t>* aRows) {
}
Accessible* HTMLTableAccessible::CellAt(uint32_t aRowIdx, uint32_t aColIdx) {
nsTableWrapperFrame* tableFrame = do_QueryFrame(mContent->GetPrimaryFrame());
nsTableWrapperFrame* tableFrame = GetTableWrapperFrame();
if (!tableFrame) return nullptr;
nsIContent* cellContent = tableFrame->GetCellAt(aRowIdx, aColIdx);
@ -545,7 +545,7 @@ Accessible* HTMLTableAccessible::CellAt(uint32_t aRowIdx, uint32_t aColIdx) {
}
int32_t HTMLTableAccessible::CellIndexAt(uint32_t aRowIdx, uint32_t aColIdx) {
nsTableWrapperFrame* tableFrame = do_QueryFrame(mContent->GetPrimaryFrame());
nsTableWrapperFrame* tableFrame = GetTableWrapperFrame();
if (!tableFrame) return -1;
int32_t cellIndex = tableFrame->GetIndexByRowAndColumn(aRowIdx, aColIdx);
@ -565,7 +565,7 @@ int32_t HTMLTableAccessible::CellIndexAt(uint32_t aRowIdx, uint32_t aColIdx) {
}
int32_t HTMLTableAccessible::ColIndexAt(uint32_t aCellIdx) {
nsTableWrapperFrame* tableFrame = do_QueryFrame(mContent->GetPrimaryFrame());
nsTableWrapperFrame* tableFrame = GetTableWrapperFrame();
if (!tableFrame) return -1;
int32_t rowIdx = -1, colIdx = -1;
@ -582,7 +582,7 @@ int32_t HTMLTableAccessible::ColIndexAt(uint32_t aCellIdx) {
}
int32_t HTMLTableAccessible::RowIndexAt(uint32_t aCellIdx) {
nsTableWrapperFrame* tableFrame = do_QueryFrame(mContent->GetPrimaryFrame());
nsTableWrapperFrame* tableFrame = GetTableWrapperFrame();
if (!tableFrame) return -1;
int32_t rowIdx = -1, colIdx = -1;
@ -601,7 +601,7 @@ int32_t HTMLTableAccessible::RowIndexAt(uint32_t aCellIdx) {
void HTMLTableAccessible::RowAndColIndicesAt(uint32_t aCellIdx,
int32_t* aRowIdx,
int32_t* aColIdx) {
nsTableWrapperFrame* tableFrame = do_QueryFrame(mContent->GetPrimaryFrame());
nsTableWrapperFrame* tableFrame = GetTableWrapperFrame();
if (tableFrame) {
tableFrame->GetRowAndColumnByIndex(aCellIdx, aRowIdx, aColIdx);
if (*aRowIdx == -1 || *aColIdx == -1) {
@ -614,7 +614,7 @@ void HTMLTableAccessible::RowAndColIndicesAt(uint32_t aCellIdx,
}
uint32_t HTMLTableAccessible::ColExtentAt(uint32_t aRowIdx, uint32_t aColIdx) {
nsTableWrapperFrame* tableFrame = do_QueryFrame(mContent->GetPrimaryFrame());
nsTableWrapperFrame* tableFrame = GetTableWrapperFrame();
if (!tableFrame) return 0;
uint32_t colExtent = tableFrame->GetEffectiveColSpanAt(aRowIdx, aColIdx);
@ -630,7 +630,7 @@ uint32_t HTMLTableAccessible::ColExtentAt(uint32_t aRowIdx, uint32_t aColIdx) {
}
uint32_t HTMLTableAccessible::RowExtentAt(uint32_t aRowIdx, uint32_t aColIdx) {
nsTableWrapperFrame* tableFrame = do_QueryFrame(mContent->GetPrimaryFrame());
nsTableWrapperFrame* tableFrame = GetTableWrapperFrame();
if (!tableFrame) return 0;
return tableFrame->GetEffectiveRowSpanAt(aRowIdx, aColIdx);
@ -661,7 +661,7 @@ bool HTMLTableAccessible::IsRowSelected(uint32_t aRowIdx) {
}
bool HTMLTableAccessible::IsCellSelected(uint32_t aRowIdx, uint32_t aColIdx) {
nsTableWrapperFrame* tableFrame = do_QueryFrame(mContent->GetPrimaryFrame());
nsTableWrapperFrame* tableFrame = GetTableWrapperFrame();
if (!tableFrame) return false;
nsTableCellFrame* cellFrame = tableFrame->GetCellFrameAt(aRowIdx, aColIdx);
@ -701,7 +701,7 @@ nsresult HTMLTableAccessible::AddRowOrColumnToSelection(
int32_t aIndex, TableSelection aTarget) {
bool doSelectRow = (aTarget == TableSelection::Row);
nsTableWrapperFrame* tableFrame = do_QueryFrame(mContent->GetPrimaryFrame());
nsTableWrapperFrame* tableFrame = GetTableWrapperFrame();
if (!tableFrame) return NS_OK;
uint32_t count = 0;
@ -729,7 +729,7 @@ nsresult HTMLTableAccessible::AddRowOrColumnToSelection(
nsresult HTMLTableAccessible::RemoveRowsOrColumnsFromSelection(
int32_t aIndex, TableSelection aTarget, bool aIsOuter) {
nsTableWrapperFrame* tableFrame = do_QueryFrame(mContent->GetPrimaryFrame());
nsTableWrapperFrame* tableFrame = GetTableWrapperFrame();
if (!tableFrame) return NS_OK;
PresShell* presShell = mDoc->PresShellPtr();
@ -784,6 +784,16 @@ void HTMLTableAccessible::Description(nsString& aDescription) {
#endif
}
nsTableWrapperFrame* HTMLTableAccessible::GetTableWrapperFrame() const {
nsTableWrapperFrame* tableFrame = do_QueryFrame(mContent->GetPrimaryFrame());
if (tableFrame &&
tableFrame->GetChildList(nsIFrame::kPrincipalList).FirstChild()) {
return tableFrame;
}
return nullptr;
}
////////////////////////////////////////////////////////////////////////////////
// HTMLCaptionAccessible
////////////////////////////////////////////////////////////////////////////////

Просмотреть файл

@ -198,6 +198,12 @@ class HTMLTableAccessible : public HyperTextAccessibleWrap,
#ifdef SHOW_LAYOUT_HEURISTIC
nsString mLayoutHeuristic;
#endif
private:
/**
* Get table wrapper frame, or return null if there is no inner table.
*/
nsTableWrapperFrame* GetTableWrapperFrame() const;
};
/**

Просмотреть файл

@ -281,6 +281,32 @@
] });
}
// Test that we get a text removed event when removing generated content from a button
async function testCSSGeneratedContentRemovedFromButton() {
let msg = "testCSSGeneratedContentRemovedFromButton";
info(msg);
testAccessibleTree("c13", { SECTION: [
{ role: ROLE_PUSHBUTTON, name: "beforego",
children: [{ STATICTEXT: [] }, { TEXT_LEAF: [] }] }
] });
let events = waitForOrderedEvents([
[EVENT_HIDE, evt => evt.accessible.name == "before"],
[EVENT_TEXT_REMOVED, evt => evt.accessible.role == ROLE_PUSHBUTTON],
[EVENT_SHOW, evt => evt.DOMNode.tagName == "HR"],
[EVENT_REORDER, "c13"],
], msg);
getNode("b13").click();
await events;
testAccessibleTree("c13", { SECTION: [
{ role: ROLE_PUSHBUTTON, name: "go",
children: [{ TEXT_LEAF: [] }] },
{ SEPARATOR: [] }
] });
}
async function doTest() {
await hideDivFromInsideSpan();
@ -306,6 +332,8 @@
await embedBecomesOuterDoc();
await testCSSGeneratedContentRemovedFromButton();
SimpleTest.finish();
}
@ -371,6 +399,13 @@
<iframe id="iframe"></iframe>
</div>
<div id="c13">
<style>
.before::before { content: 'before' }
</style>
<button id="b13" class="before" onclick="this.className = ''; this.insertAdjacentElement('afterend', document.createElement('hr'))">go</button>
</div>
<div id="eventdump"></div>
</body>
</html>