зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1341588
Part 2 - Add StringifiedSelection() to simplify code. r=mtseng
MozReview-Commit-ID: 1tRG8WY13ok --HG-- extra : rebase_source : 97cd124299059b082583d503bcbf56da15db08e3
This commit is contained in:
Родитель
5ee24f0a0a
Коммит
8ccfd5c8a6
|
@ -811,6 +811,14 @@ AccessibleCaretManager::GetFrameSelection() const
|
|||
}
|
||||
}
|
||||
|
||||
nsAutoString
|
||||
AccessibleCaretManager::StringifiedSelection() const
|
||||
{
|
||||
nsAutoString str;
|
||||
GetSelection()->Stringify(str);
|
||||
return str;
|
||||
}
|
||||
|
||||
Element*
|
||||
AccessibleCaretManager::GetEditingHostForFrame(nsIFrame* aFrame) const
|
||||
{
|
||||
|
@ -957,8 +965,7 @@ AccessibleCaretManager::ExtendPhoneNumberSelection(const nsAString& aDirection)
|
|||
// we can compare them with the modified ones later.
|
||||
nsINode* oldFocusNode = selection->GetFocusNode();
|
||||
uint32_t oldFocusOffset = selection->FocusOffset();
|
||||
nsAutoString oldSelectedText;
|
||||
selection->Stringify(oldSelectedText);
|
||||
nsAutoString oldSelectedText = StringifiedSelection();
|
||||
|
||||
// Extend the selection by one char.
|
||||
selection->Modify(NS_LITERAL_STRING("extend"),
|
||||
|
@ -979,8 +986,7 @@ AccessibleCaretManager::ExtendPhoneNumberSelection(const nsAString& aDirection)
|
|||
// returned by stringify() won't have a new line at the beginning or the
|
||||
// end of the string. Therefore, if either focus node or offset is
|
||||
// changed, but selected text is not changed, we're done, too.
|
||||
nsAutoString selectedText;
|
||||
selection->Stringify(selectedText);
|
||||
nsAutoString selectedText = StringifiedSelection();
|
||||
nsAutoString phoneRegex(NS_LITERAL_STRING("(^\\+)?[0-9 ,\\-.()*#pw]{1,30}$"));
|
||||
|
||||
if (!nsContentUtils::IsPatternMatching(selectedText, phoneRegex, doc) ||
|
||||
|
|
|
@ -187,6 +187,7 @@ protected:
|
|||
dom::Element* GetEditingHostForFrame(nsIFrame* aFrame) const;
|
||||
dom::Selection* GetSelection() const;
|
||||
already_AddRefed<nsFrameSelection> GetFrameSelection() const;
|
||||
nsAutoString StringifiedSelection() const;
|
||||
|
||||
// Get the union of all the child frame scrollable overflow rects for aFrame,
|
||||
// which is used as a helper function to restrict the area where the caret can
|
||||
|
|
Загрузка…
Ссылка в новой задаче