Skip to content
Snippets Groups Projects
Commit 0ea37698 authored by James Teh's avatar James Teh
Browse files

Bug 1771060: Make use of the line cursor in IsLocalAccAtLineStart to improve...

Bug 1771060: Make use of the line cursor in IsLocalAccAtLineStart to improve performance. r=jfkthame

For block frames, nsLineIterator doesn't use the line cursor, so switch to nsBlockInFlowLineIterator.
We don't actually care about the line number here anyway.

Differential Revision: https://phabricator.services.mozilla.com/D147237
parent 2f9c4491
No related branches found
No related tags found
No related merge requests found
...@@ -175,6 +175,7 @@ class NotificationController final : public EventQueue, ...@@ -175,6 +175,7 @@ class NotificationController final : public EventQueue,
"A text node is not visible"); "A text node is not visible");
mTextHash.Insert(aTextNode); mTextHash.Insert(aTextNode);
ScheduleProcessing(); ScheduleProcessing();
} }
......
...@@ -17,6 +17,7 @@ ...@@ -17,6 +17,7 @@
#include "mozilla/intl/WordBreaker.h" #include "mozilla/intl/WordBreaker.h"
#include "mozilla/StaticPrefs_layout.h" #include "mozilla/StaticPrefs_layout.h"
#include "nsAccUtils.h" #include "nsAccUtils.h"
#include "nsBlockFrame.h"
#include "nsContentUtils.h" #include "nsContentUtils.h"
#include "nsIAccessiblePivot.h" #include "nsIAccessiblePivot.h"
#include "nsILineIterator.h" #include "nsILineIterator.h"
...@@ -182,6 +183,22 @@ static bool IsLocalAccAtLineStart(LocalAccessible* aAcc) { ...@@ -182,6 +183,22 @@ static bool IsLocalAccAtLineStart(LocalAccessible* aAcc) {
// same line, so we're at the start. // same line, so we're at the start.
return true; return true;
} }
if (nsBlockFrame* block = do_QueryFrame(thisBlock)) {
// If we have a block frame, it's faster for us to use
// BlockInFlowLineIterator because it uses the line cursor.
bool found = false;
block->SetupLineCursorForQuery();
nsBlockInFlowLineIterator prevIt(block, prevLineFrame, &found);
if (!found) {
// Error; play it safe.
return true;
}
found = false;
nsBlockInFlowLineIterator thisIt(block, thisLineFrame, &found);
// if the lines are different, that means there's nothing before us on the
// same line, so we're at the start.
return !found || prevIt.GetLine() != thisIt.GetLine();
}
nsAutoLineIterator it = prevBlock->GetLineIterator(); nsAutoLineIterator it = prevBlock->GetLineIterator();
MOZ_ASSERT(it, "GetLineIterator impl in line-container blocks is infallible"); MOZ_ASSERT(it, "GetLineIterator impl in line-container blocks is infallible");
int32_t prevLineNum = it->FindLineContaining(prevLineFrame); int32_t prevLineNum = it->FindLineContaining(prevLineFrame);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment