From ae6a16193ae376b364833160e165522accc7c957 Mon Sep 17 00:00:00 2001 From: Robert O'Callahan Date: Wed, 6 Aug 2014 17:19:27 +1200 Subject: [PATCH] Bug 1048752. Part 16: Move nsFrameSelection::HINT to CaretAssociationHint.h. r=tn This patch started an attempt to remove nsFrameSelection.h from nsCaret.h and metastasized into a rather large refactoring patch that removed it from some other header files as well, and changed nsFrameSelection::HINT into a global-scope enum with better names. I also converted bools into CaretAssociationHint in a few places where that was appropriate, but there are still some more places (GetChildFrameContainingOffset) where bools need to be converted. I figured this patch was big enough already. --HG-- extra : rebase_source : cc618ef60e707e1360644340a2648de389383da0 --- accessible/base/SelectionManager.cpp | 1 + accessible/generic/HyperTextAccessible-inl.h | 3 +- accessible/generic/HyperTextAccessible.cpp | 2 +- accessible/generic/HyperTextAccessible.h | 13 +- accessible/windows/sdn/sdnAccessible.cpp | 1 + accessible/xpcom/xpcAccessibleTextRange.cpp | 4 +- .../html/content/src/nsTextEditorState.cpp | 5 +- dom/base/nsGlobalWindow.cpp | 1 + dom/events/ContentEventHandler.cpp | 4 +- dom/plugins/base/nsPluginInstanceOwner.cpp | 1 + .../html/tests/test_bug674770-1.html | 5 - layout/base/CaretAssociationHint.h | 22 +++ layout/base/SelectionCarets.cpp | 13 +- layout/base/TouchCaret.cpp | 2 +- layout/base/TouchCaret.h | 1 - layout/base/WordMovementType.h | 14 ++ layout/base/moz.build | 2 + layout/base/nsCaret.cpp | 30 ++-- layout/base/nsCaret.h | 20 ++- layout/base/nsDisplayList.cpp | 13 +- layout/base/nsLayoutUtils.cpp | 2 + layout/base/nsPresShell.cpp | 17 +- layout/base/nsPresShell.h | 13 +- layout/forms/nsImageControlFrame.cpp | 2 + layout/generic/TextOverflow.cpp | 1 + layout/generic/nsBRFrame.cpp | 2 +- layout/generic/nsBlockFrame.cpp | 1 + layout/generic/nsFrame.cpp | 46 +++--- layout/generic/nsFrameSelection.h | 56 +++---- layout/generic/nsIFrame.h | 5 +- layout/generic/nsSelection.cpp | 153 ++++++++++-------- layout/generic/nsTextFrame.cpp | 3 +- layout/svg/SVGTextFrame.cpp | 3 +- layout/xul/nsImageBoxFrame.cpp | 1 + layout/xul/nsListItemFrame.cpp | 4 +- layout/xul/tree/nsTreeImageListener.cpp | 1 + 36 files changed, 273 insertions(+), 194 deletions(-) create mode 100644 layout/base/CaretAssociationHint.h create mode 100644 layout/base/WordMovementType.h diff --git a/accessible/base/SelectionManager.cpp b/accessible/base/SelectionManager.cpp index 1c3788036a0..d846e356bc8 100644 --- a/accessible/base/SelectionManager.cpp +++ b/accessible/base/SelectionManager.cpp @@ -12,6 +12,7 @@ #include "nsAccUtils.h" #include "nsCoreUtils.h" #include "nsEventShell.h" +#include "nsFrameSelection.h" #include "nsIAccessibleTypes.h" #include "nsIDOMDocument.h" diff --git a/accessible/generic/HyperTextAccessible-inl.h b/accessible/generic/HyperTextAccessible-inl.h index f47a0e20094..81e42153683 100644 --- a/accessible/generic/HyperTextAccessible-inl.h +++ b/accessible/generic/HyperTextAccessible-inl.h @@ -14,6 +14,7 @@ #include "nsIEditor.h" #include "nsIPersistentProperties2.h" #include "nsIPlaintextEditor.h" +#include "nsFrameSelection.h" namespace mozilla { namespace a11y { @@ -143,7 +144,7 @@ HyperTextAccessible::IsCaretAtEndOfLine() const { nsRefPtr frameSelection = FrameSelection(); return frameSelection && - frameSelection->GetHint() == nsFrameSelection::HINTLEFT; + frameSelection->GetHint() == CARET_ASSOCIATE_BEFORE; } inline already_AddRefed diff --git a/accessible/generic/HyperTextAccessible.cpp b/accessible/generic/HyperTextAccessible.cpp index 738d3b00f0f..cac3b749eb1 100644 --- a/accessible/generic/HyperTextAccessible.cpp +++ b/accessible/generic/HyperTextAccessible.cpp @@ -1269,7 +1269,7 @@ HyperTextAccessible::CaretLineNumber() int32_t returnOffsetUnused; uint32_t caretOffset = domSel->FocusOffset(); - nsFrameSelection::HINT hint = frameSelection->GetHint(); + CaretAssociationHint hint = frameSelection->GetHint(); nsIFrame *caretFrame = frameSelection->GetFrameForNodeOffset(caretContent, caretOffset, hint, &returnOffsetUnused); NS_ENSURE_TRUE(caretFrame, -1); diff --git a/accessible/generic/HyperTextAccessible.h b/accessible/generic/HyperTextAccessible.h index 7dfd652c6ad..99f4a833832 100644 --- a/accessible/generic/HyperTextAccessible.h +++ b/accessible/generic/HyperTextAccessible.h @@ -9,11 +9,22 @@ #include "AccessibleWrap.h" #include "nsIAccessibleTypes.h" #include "xpcAccessibleHyperText.h" +#include "nsDirection.h" +#include "WordMovementType.h" +#include "nsIFrame.h" -#include "nsFrameSelection.h" #include "nsISelectionController.h" +class nsFrameSelection; +class nsRange; +class nsIWidget; + namespace mozilla { + +namespace dom { +class Selection; +} + namespace a11y { class TextRange; diff --git a/accessible/windows/sdn/sdnAccessible.cpp b/accessible/windows/sdn/sdnAccessible.cpp index ad3a5fe8dc6..046d734c3a8 100644 --- a/accessible/windows/sdn/sdnAccessible.cpp +++ b/accessible/windows/sdn/sdnAccessible.cpp @@ -17,6 +17,7 @@ #include "nsNameSpaceManager.h" #include "nsServiceManagerUtils.h" #include "nsWinUtils.h" +#include "nsRange.h" #include "nsAutoPtr.h" diff --git a/accessible/xpcom/xpcAccessibleTextRange.cpp b/accessible/xpcom/xpcAccessibleTextRange.cpp index 51226e4f866..8f278979c73 100644 --- a/accessible/xpcom/xpcAccessibleTextRange.cpp +++ b/accessible/xpcom/xpcAccessibleTextRange.cpp @@ -8,8 +8,8 @@ #include "HyperTextAccessible.h" #include "TextRange.h" - - #include "nsIMutableArray.h" +#include "nsIMutableArray.h" +#include "nsComponentManagerUtils.h" using namespace mozilla; using namespace mozilla::a11y; diff --git a/content/html/content/src/nsTextEditorState.cpp b/content/html/content/src/nsTextEditorState.cpp index 9bb4f03f98e..7989c94e035 100644 --- a/content/html/content/src/nsTextEditorState.cpp +++ b/content/html/content/src/nsTextEditorState.cpp @@ -45,6 +45,7 @@ #include "mozilla/dom/ScriptSettings.h" #include "mozilla/dom/HTMLInputElement.h" #include "nsNumberControlFrame.h" +#include "nsFrameSelection.h" using namespace mozilla; using namespace mozilla::dom; @@ -546,7 +547,7 @@ nsTextInputSelectionImpl::CompleteMove(bool aForward, bool aExtend) // make the caret be either at the very beginning (0) or the very end int32_t offset = 0; - nsFrameSelection::HINT hint = nsFrameSelection::HINTLEFT; + CaretAssociationHint hint = CARET_ASSOCIATE_BEFORE; if (aForward) { offset = parentDIV->GetChildCount(); @@ -561,7 +562,7 @@ nsTextInputSelectionImpl::CompleteMove(bool aForward, bool aExtend) if (child->Tag() == nsGkAtoms::br) { --offset; - hint = nsFrameSelection::HINTRIGHT; // for Bug 106855 + hint = CARET_ASSOCIATE_AFTER; // for Bug 106855 } } } diff --git a/dom/base/nsGlobalWindow.cpp b/dom/base/nsGlobalWindow.cpp index cea15c8e38b..302deea54bb 100644 --- a/dom/base/nsGlobalWindow.cpp +++ b/dom/base/nsGlobalWindow.cpp @@ -40,6 +40,7 @@ #include "nsWindowMemoryReporter.h" #include "WindowNamedPropertiesHandler.h" #include "nsFrameSelection.h" +#include "nsISelectionListener.h" // Helper Classes #include "nsJSUtils.h" diff --git a/dom/events/ContentEventHandler.cpp b/dom/events/ContentEventHandler.cpp index 5fcffd9d9d1..65f48d9a3ff 100644 --- a/dom/events/ContentEventHandler.cpp +++ b/dom/events/ContentEventHandler.cpp @@ -440,8 +440,8 @@ ContentEventHandler::ExpandToClusterBoundary(nsIContent* aContent, nsRefPtr fs = mPresShell->FrameSelection(); int32_t offsetInFrame; - nsFrameSelection::HINT hint = - aForward ? nsFrameSelection::HINTLEFT : nsFrameSelection::HINTRIGHT; + CaretAssociationHint hint = + aForward ? CARET_ASSOCIATE_BEFORE : CARET_ASSOCIATE_AFTER; nsIFrame* frame = fs->GetFrameForNodeOffset(aContent, int32_t(*aXPOffset), hint, &offsetInFrame); if (!frame) { diff --git a/dom/plugins/base/nsPluginInstanceOwner.cpp b/dom/plugins/base/nsPluginInstanceOwner.cpp index 98d56d562e5..a1edf28dd58 100644 --- a/dom/plugins/base/nsPluginInstanceOwner.cpp +++ b/dom/plugins/base/nsPluginInstanceOwner.cpp @@ -55,6 +55,7 @@ using mozilla::DefaultXDisplay; #include "mozilla/MouseEvents.h" #include "mozilla/TextEvents.h" #include "mozilla/dom/HTMLObjectElementBinding.h" +#include "nsFrameSelection.h" #include "nsContentCID.h" #include "nsWidgetsCID.h" diff --git a/editor/libeditor/html/tests/test_bug674770-1.html b/editor/libeditor/html/tests/test_bug674770-1.html index b422d2ee176..f202a909897 100644 --- a/editor/libeditor/html/tests/test_bug674770-1.html +++ b/editor/libeditor/html/tests/test_bug674770-1.html @@ -22,11 +22,6 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=674770