Update patches

This commit is contained in:
Laura Hausmann 2023-10-30 23:43:00 +01:00
parent 9705c1089d
commit 8ed20a09c2
Signed by untrusted user: zotan
GPG key ID: D044E84C5BE01605

View file

@ -0,0 +1,119 @@
diff --git a/layout/generic/nsIFrame.cpp b/layout/generic/nsIFrame.cpp
index 3a336b25278ae..448a96fb0ae9b 100644
--- a/layout/generic/nsIFrame.cpp
+++ b/layout/generic/nsIFrame.cpp
@@ -8879,6 +8879,60 @@ nsresult nsIFrame::PeekOffsetForParagraph(PeekOffsetStruct* aPos) {
return NS_OK;
}
+nsresult nsIFrame::PeekOffsetForLineEdgeLogical(PeekOffsetStruct* aPos) {
+ nsIFrame* frame = this;
+ nsContentAndOffset blockFrameOrBR;
+ blockFrameOrBR.mContent = nullptr;
+ bool reachedLimit = frame->IsBlockOutside() || IsEditingHost(frame);
+
+ auto traverse = [&aPos](nsIFrame* current) {
+ return aPos->mDirection == eDirPrevious ? current->GetPrevSibling()
+ : current->GetNextSibling();
+ };
+
+ // Go through containing frames until reaching a block frame.
+ // In each step, search the previous (or next) siblings for the closest
+ // "stop frame" (a block frame or a BRFrame).
+ // If found, set it to be the selection boundary and abort.
+ while (!reachedLimit) {
+ nsIFrame* parent = frame->GetParent();
+ // Treat a frame associated with the root content as if it were a block
+ // frame.
+ if (!frame->mContent || !frame->mContent->GetParent()) {
+ reachedLimit = true;
+ break;
+ }
+
+ if (aPos->mDirection == eDirNext) {
+ // Try to find our own line-break before looking at our siblings.
+ blockFrameOrBR = FindLineBreakInText(frame, eDirNext);
+ }
+
+ nsIFrame* sibling = traverse(frame);
+ while (sibling && !blockFrameOrBR.mContent) {
+ blockFrameOrBR = FindLineBreakingFrame(sibling, aPos->mDirection);
+ sibling = traverse(sibling);
+ }
+ if (blockFrameOrBR.mContent) {
+ aPos->mResultContent = blockFrameOrBR.mContent;
+ aPos->mContentOffset = blockFrameOrBR.mOffset;
+ break;
+ }
+ frame = parent;
+ reachedLimit = frame && (frame->IsBlockOutside() || IsEditingHost(frame));
+ }
+
+ if (reachedLimit) { // no "stop frame" found
+ aPos->mResultContent = frame->GetContent();
+ if (aPos->mDirection == eDirPrevious) {
+ aPos->mContentOffset = 0;
+ } else if (aPos->mResultContent) {
+ aPos->mContentOffset = aPos->mResultContent->GetChildCount();
+ }
+ }
+ return NS_OK;
+}
+
// Determine movement direction relative to frame
static bool IsMovingInFrameDirection(const nsIFrame* frame,
nsDirection aDirection, bool aVisual) {
@@ -9202,7 +9256,7 @@ nsresult nsIFrame::PeekOffsetForLine(PeekOffsetStruct* aPos) {
return result;
}
-nsresult nsIFrame::PeekOffsetForLineEdge(PeekOffsetStruct* aPos) {
+nsresult nsIFrame::PeekOffsetForLineEdgeVisual(PeekOffsetStruct* aPos) {
// Adjusted so that the caret can't get confused when content changes
nsIFrame* frame = AdjustFrameForSelectionStyles(this);
Element* editingHost = frame->GetContent()->GetEditingHost();
@@ -9316,7 +9370,12 @@ nsresult nsIFrame::PeekOffset(PeekOffsetStruct* aPos) {
return PeekOffsetForLine(aPos);
case eSelectBeginLine:
case eSelectEndLine:
- return PeekOffsetForLineEdge(aPos);
+ if (StaticPrefs::dom_input_logical_textarea_caret_movement_style()) {
+ return PeekOffsetForLineEdgeLogical(aPos);
+ }
+ else {
+ return PeekOffsetForLineEdgeVisual(aPos);
+ }
case eSelectParagraph:
return PeekOffsetForParagraph(aPos);
default: {
diff --git a/layout/generic/nsIFrame.h b/layout/generic/nsIFrame.h
index 80c3504e1af36..af55881b95f95 100644
--- a/layout/generic/nsIFrame.h
+++ b/layout/generic/nsIFrame.h
@@ -3867,7 +3867,8 @@ class nsIFrame : public nsQueryFrame {
int32_t aOffset);
nsresult PeekOffsetForWord(mozilla::PeekOffsetStruct* aPos, int32_t aOffset);
nsresult PeekOffsetForLine(mozilla::PeekOffsetStruct* aPos);
- nsresult PeekOffsetForLineEdge(mozilla::PeekOffsetStruct* aPos);
+ nsresult PeekOffsetForLineEdgeLogical(mozilla::PeekOffsetStruct* aPos);
+ nsresult PeekOffsetForLineEdgeVisual(mozilla::PeekOffsetStruct* aPos);
/**
* Search for the first paragraph boundary before or after the given position
diff --git a/modules/libpref/init/StaticPrefList.yaml b/modules/libpref/init/StaticPrefList.yaml
index 7ec9237d9f26d..715059de80314 100644
--- a/modules/libpref/init/StaticPrefList.yaml
+++ b/modules/libpref/init/StaticPrefList.yaml
@@ -2773,6 +2773,12 @@
value: true
mirror: always
+# Textarea caret movement style. Disable this to restore previous behavior (visual movement).
+- name: dom.input.logical_textarea_caret_movement_style
+ type: bool
+ value: true
+ mirror: always
+
# How often to check for CPOW timeouts (ms). CPOWs are only timed
# out by the hang monitor.
- name: dom.ipc.cpow.timeout