diff --git a/mozilla/layout/generic/nsSelection.cpp b/mozilla/layout/generic/nsSelection.cpp index 141e79b25dc..105fda4b822 100644 --- a/mozilla/layout/generic/nsSelection.cpp +++ b/mozilla/layout/generic/nsSelection.cpp @@ -20,6 +20,7 @@ * the Initial Developer. All Rights Reserved. * * Contributor(s): + * Mats Palmgren * * Alternatively, the contents of this file may be used under the terms of * either of the GNU General Public License Version 2 or later (the "GPL"), @@ -1322,6 +1323,47 @@ nsSelection::MoveCaret(PRUint32 aKeycode, PRBool aContinueSelection, nsSelection SetDesiredX(desiredX); } + PRInt32 caretStyle = nsContentUtils::GetIntPref("layout.selection.caret_style", 0); +#ifdef XP_MACOSX + if (caretStyle == 0) { + caretStyle = 2; // put caret at the selection edge in the |aKeycode| direction + } +#endif + + if (!isCollapsed && !aContinueSelection && caretStyle == 2) { + switch (aKeycode){ + case nsIDOMKeyEvent::DOM_VK_LEFT : + case nsIDOMKeyEvent::DOM_VK_UP : + if (mDomSelections[index]->GetDirection() == eDirPrevious) { //f,a + offsetused = mDomSelections[index]->FetchFocusOffset(); + weakNodeUsed = mDomSelections[index]->FetchFocusNode(); + } + else { + offsetused = mDomSelections[index]->FetchAnchorOffset(); + weakNodeUsed = mDomSelections[index]->FetchAnchorNode(); + } + result = mDomSelections[index]->Collapse(weakNodeUsed, offsetused); + mDomSelections[index]->ScrollIntoView(); + mHint = HINTRIGHT; + return NS_OK; + + case nsIDOMKeyEvent::DOM_VK_RIGHT : + case nsIDOMKeyEvent::DOM_VK_DOWN : + if (mDomSelections[index]->GetDirection() == eDirPrevious) { //f,a + offsetused = mDomSelections[index]->FetchAnchorOffset(); + weakNodeUsed = mDomSelections[index]->FetchAnchorNode(); + } + else { + offsetused = mDomSelections[index]->FetchFocusOffset(); + weakNodeUsed = mDomSelections[index]->FetchFocusNode(); + } + result = mDomSelections[index]->Collapse(weakNodeUsed, offsetused); + mDomSelections[index]->ScrollIntoView(); + mHint = HINTLEFT; + return NS_OK; + } + } + nsCOMPtr caret; result = mShell->GetCaret(getter_AddRefs(caret)); if (NS_FAILED(result) || !caret) @@ -5658,7 +5700,7 @@ nsTypedSelection::Collapse(nsIDOMNode* aParentNode, PRInt32 aOffset) const char *tagString; content->Tag()->GetUTF8String(&tagString); - printf ("Sel. Collapse to %p %s %d\n", content, tagString, aOffset); + printf ("Sel. Collapse to %p %s %d\n", content.get(), tagString, aOffset); } else { printf ("Sel. Collapse set to null parent.\n"); @@ -6446,7 +6488,7 @@ nsTypedSelection::Extend(nsIDOMNode* aParentNode, PRInt32 aOffset) const char *tagString; content->Tag()->GetUTF8String(&tagString); - printf ("Sel. Extend to %p %s %d\n", content, tagString, aOffset); + printf ("Sel. Extend to %p %s %d\n", content.get(), tagString, aOffset); } else { printf ("Sel. Extend set to null parent.\n"); diff --git a/mozilla/modules/libpref/src/init/all.js b/mozilla/modules/libpref/src/init/all.js index 34f403c878c..2f99fcba042 100644 --- a/mozilla/modules/libpref/src/init/all.js +++ b/mozilla/modules/libpref/src/init/all.js @@ -928,6 +928,12 @@ pref("bidi.characterset", 1); pref("layout.word_select.eat_space_to_next_word", false); pref("layout.word_select.stop_at_punctuation", true); +// controls caret style during text selection +// 0 = use platform default +// 1 = caret moves and blinks as when there is no selection +// 2 = caret moves to selection edge and is not visible during selection +pref("layout.selection.caret_style", 0); + // pref to control whether or not to replace backslashes with Yen signs // in documents encoded in one of Japanese legacy encodings (EUC-JP, // Shift_JIS, ISO-2022-JP)