зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1397577 - Avoid using GetChildAt() in HTMLEditor::GetSelectedOrParentTableElement(); r=smaug
This commit is contained in:
Родитель
11fb78d647
Коммит
2231e4a948
|
@ -923,6 +923,19 @@ Selection::FocusOffset()
|
|||
return mAnchorFocusRange->StartOffset();
|
||||
}
|
||||
|
||||
nsIContent*
|
||||
Selection::GetChildAtAnchorOffset()
|
||||
{
|
||||
if (!mAnchorFocusRange)
|
||||
return nullptr;
|
||||
|
||||
if (GetDirection() == eDirNext) {
|
||||
return mAnchorFocusRange->GetChildAtStartOffset();
|
||||
}
|
||||
|
||||
return mAnchorFocusRange->GetChildAtEndOffset();
|
||||
}
|
||||
|
||||
static nsresult
|
||||
CompareToRangeStart(nsINode* aCompareNode, int32_t aCompareOffset,
|
||||
nsRange* aRange, int32_t* aCmp)
|
||||
|
|
|
@ -171,6 +171,8 @@ public:
|
|||
nsINode* GetFocusNode();
|
||||
uint32_t FocusOffset();
|
||||
|
||||
nsIContent* GetChildAtAnchorOffset();
|
||||
|
||||
/*
|
||||
* IsCollapsed -- is the whole selection just one point, or unset?
|
||||
*/
|
||||
|
|
|
@ -3201,8 +3201,7 @@ HTMLEditor::GetSelectedOrParentTableElement(nsAString& aTagName,
|
|||
|
||||
// Get child of anchor node, if exists
|
||||
if (anchorNode->HasChildNodes()) {
|
||||
int32_t anchorOffset = selection->AnchorOffset();
|
||||
nsINode* selectedNode = anchorNode->GetChildAt(anchorOffset);
|
||||
nsINode* selectedNode = selection->GetChildAtAnchorOffset();
|
||||
if (!selectedNode) {
|
||||
selectedNode = anchorNode;
|
||||
// If anchor doesn't have a child, we can't be selecting a table element,
|
||||
|
|
Загрузка…
Ссылка в новой задаче