зеркало из https://github.com/mozilla/gecko-dev.git
Backed out 2 changesets (bug 1343275)
Backed out changeset 32e54e6e8c02 (bug 1343275) Backed out changeset 6fc55ce02ba5 (bug 1343275) MozReview-Commit-ID: 7K7Swi7UxGr
This commit is contained in:
Родитель
1ee826b44c
Коммит
b17c16a304
|
@ -7063,11 +7063,7 @@ nsContentUtils::GetSelectionInTextControl(Selection* aSelection,
|
||||||
{
|
{
|
||||||
MOZ_ASSERT(aSelection && aRoot);
|
MOZ_ASSERT(aSelection && aRoot);
|
||||||
|
|
||||||
// We don't care which end of this selection is anchor and which is focus. In
|
if (!aSelection->RangeCount()) {
|
||||||
// fact, we explicitly want to know which is the _start_ and which is the
|
|
||||||
// _end_, not anchor vs focus.
|
|
||||||
const nsRange* range = aSelection->GetAnchorFocusRange();
|
|
||||||
if (!range) {
|
|
||||||
// Nothing selected
|
// Nothing selected
|
||||||
aOutStartOffset = aOutEndOffset = 0;
|
aOutStartOffset = aOutEndOffset = 0;
|
||||||
return;
|
return;
|
||||||
|
@ -7075,10 +7071,10 @@ nsContentUtils::GetSelectionInTextControl(Selection* aSelection,
|
||||||
|
|
||||||
// All the node pointers here are raw pointers for performance. We shouldn't
|
// All the node pointers here are raw pointers for performance. We shouldn't
|
||||||
// be doing anything in this function that invalidates the node tree.
|
// be doing anything in this function that invalidates the node tree.
|
||||||
nsINode* startParent = range->GetStartParent();
|
nsINode* anchorNode = aSelection->GetAnchorNode();
|
||||||
uint32_t startOffset = range->StartOffset();
|
uint32_t anchorOffset = aSelection->AnchorOffset();
|
||||||
nsINode* endParent = range->GetEndParent();
|
nsINode* focusNode = aSelection->GetFocusNode();
|
||||||
uint32_t endOffset = range->EndOffset();
|
uint32_t focusOffset = aSelection->FocusOffset();
|
||||||
|
|
||||||
// We have at most two children, consisting of an optional text node followed
|
// We have at most two children, consisting of an optional text node followed
|
||||||
// by an optional <br>.
|
// by an optional <br>.
|
||||||
|
@ -7086,10 +7082,10 @@ nsContentUtils::GetSelectionInTextControl(Selection* aSelection,
|
||||||
nsIContent* firstChild = aRoot->GetFirstChild();
|
nsIContent* firstChild = aRoot->GetFirstChild();
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
nsCOMPtr<nsIContent> lastChild = aRoot->GetLastChild();
|
nsCOMPtr<nsIContent> lastChild = aRoot->GetLastChild();
|
||||||
NS_ASSERTION(startParent == aRoot || startParent == firstChild ||
|
NS_ASSERTION(anchorNode == aRoot || anchorNode == firstChild ||
|
||||||
startParent == lastChild, "Unexpected startParent");
|
anchorNode == lastChild, "Unexpected anchorNode");
|
||||||
NS_ASSERTION(endParent == aRoot || endParent == firstChild ||
|
NS_ASSERTION(focusNode == aRoot || focusNode == firstChild ||
|
||||||
endParent == lastChild, "Unexpected endParent");
|
focusNode == lastChild, "Unexpected focusNode");
|
||||||
// firstChild is either text or a <br> (hence an element).
|
// firstChild is either text or a <br> (hence an element).
|
||||||
MOZ_ASSERT_IF(firstChild,
|
MOZ_ASSERT_IF(firstChild,
|
||||||
firstChild->IsNodeOfType(nsINode::eTEXT) || firstChild->IsElement());
|
firstChild->IsNodeOfType(nsINode::eTEXT) || firstChild->IsElement());
|
||||||
|
@ -7098,25 +7094,25 @@ nsContentUtils::GetSelectionInTextControl(Selection* aSelection,
|
||||||
// non-virtual.
|
// non-virtual.
|
||||||
if (!firstChild || firstChild->IsElement()) {
|
if (!firstChild || firstChild->IsElement()) {
|
||||||
// No text node, so everything is 0
|
// No text node, so everything is 0
|
||||||
startOffset = endOffset = 0;
|
anchorOffset = focusOffset = 0;
|
||||||
} else {
|
} else {
|
||||||
// First child is text. If the start/end is already in the text node,
|
// First child is text. If the anchor/focus is already in the text node,
|
||||||
// or the start of the root node, no change needed. If it's in the root
|
// or the start of the root node, no change needed. If it's in the root
|
||||||
// node but not the start, or in the trailing <br>, we need to set the
|
// node but not the start, or in the trailing <br>, we need to set the
|
||||||
// offset to the end.
|
// offset to the end.
|
||||||
if ((startParent == aRoot && startOffset != 0) ||
|
if ((anchorNode == aRoot && anchorOffset != 0) ||
|
||||||
(startParent != aRoot && startParent != firstChild)) {
|
(anchorNode != aRoot && anchorNode != firstChild)) {
|
||||||
startOffset = firstChild->Length();
|
anchorOffset = firstChild->Length();
|
||||||
}
|
}
|
||||||
if ((endParent == aRoot && endOffset != 0) ||
|
if ((focusNode == aRoot && focusOffset != 0) ||
|
||||||
(endParent != aRoot && endParent != firstChild)) {
|
(focusNode != aRoot && focusNode != firstChild)) {
|
||||||
endOffset = firstChild->Length();
|
focusOffset = firstChild->Length();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
MOZ_ASSERT(startOffset <= endOffset);
|
// Make sure aOutStartOffset <= aOutEndOffset.
|
||||||
aOutStartOffset = startOffset;
|
aOutStartOffset = std::min(anchorOffset, focusOffset);
|
||||||
aOutEndOffset = endOffset;
|
aOutEndOffset = std::max(anchorOffset, focusOffset);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -224,8 +224,6 @@ public:
|
||||||
void SetScrollableFrame(nsIScrollableFrame *aScrollableFrame);
|
void SetScrollableFrame(nsIScrollableFrame *aScrollableFrame);
|
||||||
nsFrameSelection* GetConstFrameSelection()
|
nsFrameSelection* GetConstFrameSelection()
|
||||||
{ return mFrameSelection; }
|
{ return mFrameSelection; }
|
||||||
// Will return null if !mFrameSelection.
|
|
||||||
Selection* GetSelection(SelectionType aSelectionType);
|
|
||||||
|
|
||||||
//NSISELECTIONCONTROLLER INTERFACES
|
//NSISELECTIONCONTROLLER INTERFACES
|
||||||
NS_IMETHOD SetDisplaySelection(int16_t toggle) override;
|
NS_IMETHOD SetDisplaySelection(int16_t toggle) override;
|
||||||
|
@ -308,16 +306,6 @@ nsTextInputSelectionImpl::SetScrollableFrame(nsIScrollableFrame *aScrollableFram
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Selection*
|
|
||||||
nsTextInputSelectionImpl::GetSelection(SelectionType aSelectionType)
|
|
||||||
{
|
|
||||||
if (!mFrameSelection) {
|
|
||||||
return nullptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
return mFrameSelection->GetSelection(aSelectionType);
|
|
||||||
}
|
|
||||||
|
|
||||||
NS_IMETHODIMP
|
NS_IMETHODIMP
|
||||||
nsTextInputSelectionImpl::SetDisplaySelection(int16_t aToggle)
|
nsTextInputSelectionImpl::SetDisplaySelection(int16_t aToggle)
|
||||||
{
|
{
|
||||||
|
@ -1596,12 +1584,21 @@ nsTextEditorState::GetSelectionRange(int32_t* aSelectionStart,
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Selection* sel = mSelCon->GetSelection(SelectionType::eNormal);
|
nsISelectionController* selCon = GetSelectionController();
|
||||||
if (NS_WARN_IF(!sel)) {
|
|
||||||
|
nsCOMPtr<nsISelection> selection;
|
||||||
|
nsresult rv = selCon->GetSelection(nsISelectionController::SELECTION_NORMAL,
|
||||||
|
getter_AddRefs(selection));
|
||||||
|
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||||
|
aRv.Throw(rv);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (NS_WARN_IF(!selection)) {
|
||||||
aRv.Throw(NS_ERROR_FAILURE);
|
aRv.Throw(NS_ERROR_FAILURE);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
dom::Selection* sel = selection->AsSelection();
|
||||||
mozilla::dom::Element* root = GetRootNode();
|
mozilla::dom::Element* root = GetRootNode();
|
||||||
if (NS_WARN_IF(!root)) {
|
if (NS_WARN_IF(!root)) {
|
||||||
aRv.Throw(NS_ERROR_UNEXPECTED);
|
aRv.Throw(NS_ERROR_UNEXPECTED);
|
||||||
|
@ -1624,12 +1621,21 @@ nsTextEditorState::GetSelectionDirection(ErrorResult& aRv)
|
||||||
return GetSelectionProperties().GetDirection();
|
return GetSelectionProperties().GetDirection();
|
||||||
}
|
}
|
||||||
|
|
||||||
Selection* sel = mSelCon->GetSelection(SelectionType::eNormal);
|
nsISelectionController* selCon = GetSelectionController();
|
||||||
if (NS_WARN_IF(!sel)) {
|
|
||||||
|
nsCOMPtr<nsISelection> selection;
|
||||||
|
nsresult rv = selCon->GetSelection(nsISelectionController::SELECTION_NORMAL,
|
||||||
|
getter_AddRefs(selection));
|
||||||
|
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||||
|
aRv.Throw(rv);
|
||||||
|
return nsITextControlFrame::eForward; // Doesn't really matter
|
||||||
|
}
|
||||||
|
if (NS_WARN_IF(!selection)) {
|
||||||
aRv.Throw(NS_ERROR_FAILURE);
|
aRv.Throw(NS_ERROR_FAILURE);
|
||||||
return nsITextControlFrame::eForward; // Doesn't really matter
|
return nsITextControlFrame::eForward; // Doesn't really matter
|
||||||
}
|
}
|
||||||
|
|
||||||
|
dom::Selection* sel = selection->AsSelection();
|
||||||
nsDirection direction = sel->GetSelectionDirection();
|
nsDirection direction = sel->GetSelectionDirection();
|
||||||
if (direction == eDirNext) {
|
if (direction == eDirNext) {
|
||||||
return nsITextControlFrame::eForward;
|
return nsITextControlFrame::eForward;
|
||||||
|
|
Загрузка…
Ссылка в новой задаче