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
This commit is contained in:
Robert O'Callahan 2014-08-06 17:19:27 +12:00
Родитель f500f71adb
Коммит 2489dc1f01
36 изменённых файлов: 273 добавлений и 194 удалений

Просмотреть файл

@ -12,6 +12,7 @@
#include "nsAccUtils.h"
#include "nsCoreUtils.h"
#include "nsEventShell.h"
#include "nsFrameSelection.h"
#include "nsIAccessibleTypes.h"
#include "nsIDOMDocument.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<nsFrameSelection> frameSelection = FrameSelection();
return frameSelection &&
frameSelection->GetHint() == nsFrameSelection::HINTLEFT;
frameSelection->GetHint() == CARET_ASSOCIATE_BEFORE;
}
inline already_AddRefed<nsFrameSelection>

Просмотреть файл

@ -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);

Просмотреть файл

@ -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;

Просмотреть файл

@ -17,6 +17,7 @@
#include "nsNameSpaceManager.h"
#include "nsServiceManagerUtils.h"
#include "nsWinUtils.h"
#include "nsRange.h"
#include "nsAutoPtr.h"

Просмотреть файл

@ -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;

Просмотреть файл

@ -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
}
}
}

Просмотреть файл

@ -40,6 +40,7 @@
#include "nsWindowMemoryReporter.h"
#include "WindowNamedPropertiesHandler.h"
#include "nsFrameSelection.h"
#include "nsISelectionListener.h"
// Helper Classes
#include "nsJSUtils.h"

Просмотреть файл

@ -440,8 +440,8 @@ ContentEventHandler::ExpandToClusterBoundary(nsIContent* aContent,
nsRefPtr<nsFrameSelection> 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) {

Просмотреть файл

@ -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"

Просмотреть файл

@ -22,11 +22,6 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=674770
<pre id="test">
<script type="application/javascript">
if (!navigator.platform.startsWith("Linux")) {
SimpleTest.expectAssertions(1);
}
/** Test for Bug 674770 **/
SimpleTest.waitForExplicitFinish();
SimpleTest.waitForFocus(function() {
SpecialPowers.setBoolPref("middlemouse.paste", true);

Просмотреть файл

@ -0,0 +1,22 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#ifndef CaretAssociationHint_h___
#define CaretAssociationHint_h___
namespace mozilla {
/**
* Hint whether a caret is associated with the content before a
* given character offset (ASSOCIATE_BEFORE), or with the content after a given
* character offset (ASSOCIATE_AFTER).
*/
enum CaretAssociationHint {
CARET_ASSOCIATE_BEFORE,
CARET_ASSOCIATE_AFTER
};
}
#endif

Просмотреть файл

@ -29,6 +29,7 @@
#include "mozilla/Preferences.h"
#include "mozilla/TouchEvents.h"
#include "TouchCaret.h"
#include "nsFrameSelection.h"
using namespace mozilla;
@ -322,7 +323,7 @@ FindFirstNodeWithFrame(nsIDocument* aDocument,
nsCOMPtr<nsIContent> startContent = do_QueryInterface(startNode);
nsCOMPtr<nsIContent> endContent = do_QueryInterface(endNode);
nsFrameSelection::HINT hintStart =
CaretAssociationHint hintStart =
nsFrameSelection::GetHintForPosition(startContent, offset);
nsIFrame* startFrame = aFrameSelection->GetFrameForNodeOffset(startContent,
offset,
@ -546,20 +547,20 @@ CompareRangeWithContentOffset(nsRange* aRange,
MOZ_ASSERT(aDragMode != SelectionCarets::NONE);
nsINode* node = nullptr;
int32_t nodeOffset = 0;
nsFrameSelection::HINT hint = nsFrameSelection::HINTLEFT;
CaretAssociationHint hint;
nsDirection dir;
if (aDragMode == SelectionCarets::START_FRAME) {
// Check previous character of end node offset
node = aRange->GetEndParent();
nodeOffset = aRange->EndOffset();
hint = nsFrameSelection::HINTLEFT;
hint = CARET_ASSOCIATE_BEFORE;
dir = eDirPrevious;
} else {
// Check next character of start node offset
node = aRange->GetStartParent();
nodeOffset = aRange->StartOffset();
hint = nsFrameSelection::HINTRIGHT;
hint = CARET_ASSOCIATE_AFTER;
dir = eDirNext;
}
nsCOMPtr<nsIContent> content = do_QueryInterface(node);
@ -649,7 +650,7 @@ SelectionCarets::DragSelection(const nsPoint &movePoint)
offsets.EndOffset(),
true,
false,
offsets.associateWithNext);
offsets.associate);
if (!weakScrollable.IsAlive()) {
return nsEventStatus_eConsumeNoDefault;
}
@ -693,7 +694,7 @@ SelectionCarets::GetCaretYCenterPosition()
}
int32_t offset;
nsFrameSelection::HINT hint =
CaretAssociationHint hint =
nsFrameSelection::GetHintForPosition(node, nodeOffset);
nsIFrame* theFrame =
fs->GetFrameForNodeOffset(node, nodeOffset, hint, &offset);

Просмотреть файл

@ -287,7 +287,7 @@ TouchCaret::MoveCaret(const nsPoint& movePoint)
offsets.EndOffset(),
false,
false,
offsets.associateWithNext);
offsets.associate);
if (!weakScrollable.IsAlive()) {
return;

Просмотреть файл

@ -10,7 +10,6 @@
#include "nsISelectionListener.h"
#include "nsIScrollObserver.h"
#include "nsIWeakReferenceUtils.h"
#include "nsFrameSelection.h"
#include "nsITimer.h"
#include "mozilla/EventForwards.h"
#include "mozilla/TouchEvents.h"

Просмотреть файл

@ -0,0 +1,14 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#ifndef WordMovementType_h___
#define WordMovementType_h___
namespace mozilla {
enum EWordMovementType { eStartWord, eEndWord, eDefaultBehavior };
}
#endif

Просмотреть файл

@ -17,6 +17,7 @@ XPIDL_MODULE = 'layout_base'
EXPORTS += [
'ActiveLayerTracker.h',
'CaretAssociationHint.h',
'DisplayItemClip.h',
'DisplayListClipState.h',
'FrameLayerBuilder.h',
@ -52,6 +53,7 @@ EXPORTS += [
'StackArena.h',
'Units.h',
'UnitTransforms.h',
'WordMovementType.h',
]
EXPORTS.mozilla += [

Просмотреть файл

@ -121,7 +121,7 @@ nsCaret::nsCaret()
, mKeyboardRTL(false)
, mLastBidiLevel(0)
, mLastContentOffset(0)
, mLastHint(nsFrameSelection::HINTLEFT)
, mLastHint(CARET_ASSOCIATE_BEFORE)
{
}
@ -597,11 +597,11 @@ void nsCaret::StopBlinking()
}
bool
nsCaret::DrawAtPositionWithHint(nsIDOMNode* aNode,
int32_t aOffset,
nsFrameSelection::HINT aFrameHint,
uint8_t aBidiLevel,
bool aInvalidate)
nsCaret::DrawAtPositionWithHint(nsIDOMNode* aNode,
int32_t aOffset,
CaretAssociationHint aFrameHint,
uint8_t aBidiLevel,
bool aInvalidate)
{
nsCOMPtr<nsIContent> contentNode = do_QueryInterface(aNode);
if (!contentNode)
@ -664,13 +664,13 @@ IsBidiUI()
}
nsresult
nsCaret::GetCaretFrameForNodeOffset(nsFrameSelection* aFrameSelection,
nsIContent* aContentNode,
int32_t aOffset,
nsFrameSelection::HINT aFrameHint,
uint8_t aBidiLevel,
nsIFrame** aReturnFrame,
int32_t* aReturnOffset)
nsCaret::GetCaretFrameForNodeOffset(nsFrameSelection* aFrameSelection,
nsIContent* aContentNode,
int32_t aOffset,
CaretAssociationHint aFrameHint,
uint8_t aBidiLevel,
nsIFrame** aReturnFrame,
int32_t* aReturnOffset)
{
if (!aFrameSelection)
return NS_ERROR_FAILURE;
@ -974,7 +974,7 @@ void nsCaret::DrawCaret(bool aInvalidate)
nsCOMPtr<nsIDOMNode> node;
int32_t offset;
nsFrameSelection::HINT hint;
CaretAssociationHint hint;
uint8_t bidiLevel;
if (!mDrawn)
@ -990,7 +990,7 @@ void nsCaret::DrawCaret(bool aInvalidate)
bool hintRight;
privateSelection->GetInterlinePosition(&hintRight);//translate hint.
hint = hintRight ? nsFrameSelection::HINTRIGHT : nsFrameSelection::HINTLEFT;
hint = hintRight ? CARET_ASSOCIATE_AFTER : CARET_ASSOCIATE_BEFORE;
// get the node and offset, which is where we want the caret to draw
domSelection->GetFocusNode(getter_AddRefs(node));

Просмотреть файл

@ -13,11 +13,19 @@
#include "nsCoord.h"
#include "nsISelectionListener.h"
#include "nsIWeakReferenceUtils.h"
#include "nsFrameSelection.h"
#include "CaretAssociationHint.h"
#include "nsPoint.h"
#include "nsRect.h"
class nsRenderingContext;
class nsDisplayListBuilder;
class nsFrameSelection;
class nsIContent;
class nsIDOMNode;
class nsIFrame;
class nsINode;
class nsIPresShell;
class nsITimer;
class nsRenderingContext;
//-----------------------------------------------------------------------------
class nsCaret : public nsISelectionListener
@ -31,6 +39,8 @@ class nsCaret : public nsISelectionListener
public:
NS_DECL_ISUPPORTS
typedef mozilla::CaretAssociationHint CaretAssociationHint;
nsresult Init(nsIPresShell *inPresShell);
void Terminate();
@ -142,7 +152,7 @@ class nsCaret : public nsISelectionListener
static nsresult GetCaretFrameForNodeOffset(nsFrameSelection* aFrameSelection,
nsIContent* aContentNode,
int32_t aOffset,
nsFrameSelection::HINT aFrameHint,
CaretAssociationHint aFrameHint,
uint8_t aBidiLevel,
nsIFrame** aReturnFrame,
int32_t* aReturnOffset);
@ -160,7 +170,7 @@ protected:
bool DrawAtPositionWithHint(nsIDOMNode* aNode,
int32_t aOffset,
nsFrameSelection::HINT aFrameHint,
CaretAssociationHint aFrameHint,
uint8_t aBidiLevel,
bool aInvalidate);
@ -233,7 +243,7 @@ protected:
// actually drawn (anon <BR> in text control)
int32_t mLastContentOffset; // the offset for the last request
nsFrameSelection::HINT mLastHint; // the hint associated with the last request, see also
CaretAssociationHint mLastHint; // the hint associated with the last request, see also
// mLastBidiLevel below
};

Просмотреть файл

@ -10,11 +10,13 @@
* used during painting and hit testing
*/
#include "mozilla/dom/TabChild.h"
#include "mozilla/layers/PLayerTransaction.h"
#include "nsDisplayList.h"
#include <stdint.h>
#include <algorithm>
#include "mozilla/dom/TabChild.h"
#include "mozilla/layers/PLayerTransaction.h"
#include "nsCSSRendering.h"
#include "nsRenderingContext.h"
#include "nsISelectionController.h"
@ -56,9 +58,8 @@
#include "UnitTransforms.h"
#include "LayersLogging.h"
#include "FrameLayerBuilder.h"
#include <stdint.h>
#include <algorithm>
#include "nsCaret.h"
#include "nsISelection.h"
using namespace mozilla;
using namespace mozilla::layers;

Просмотреть файл

@ -84,6 +84,8 @@
#include "nsIContentViewer.h"
#include "LayersLogging.h"
#include "mozilla/Preferences.h"
#include "nsFrameSelection.h"
#include "FrameLayerBuilder.h"
#ifdef MOZ_XUL
#include "nsXULPopupManager.h"

Просмотреть файл

@ -119,6 +119,7 @@
#include "nsSVGEffects.h"
#include "SVGFragmentIdentifier.h"
#include "nsArenaMemoryStats.h"
#include "nsFrameSelection.h"
#include "nsPerformance.h"
#include "nsRefreshDriver.h"
@ -2433,7 +2434,8 @@ PresShell::CompleteMove(bool aForward, bool aExtend)
nsIFrame::CaretPosition pos =
frame->GetExtremeCaretPosition(!aForward);
mSelection->HandleClick(pos.mResultContent, pos.mContentOffset,
pos.mContentOffset, aExtend, false, aForward);
pos.mContentOffset, aExtend, false,
aForward ? CARET_ASSOCIATE_AFTER : CARET_ASSOCIATE_BEFORE);
if (limiter) {
// HandleClick resets ancestorLimiter, so set it again.
mSelection->SetAncestorLimiter(limiter);
@ -2656,6 +2658,19 @@ PresShell::RestoreRootScrollPosition()
}
}
void
PresShell::MaybeReleaseCapturingContent()
{
nsRefPtr<nsFrameSelection> frameSelection = FrameSelection();
if (frameSelection) {
frameSelection->SetDragState(false);
}
if (gCaptureInfo.mContent &&
gCaptureInfo.mContent->OwnerDoc() == mDocument) {
SetCapturingContent(nullptr, 0);
}
}
void
PresShell::BeginLoad(nsIDocument *aDocument)
{

Просмотреть файл

@ -30,7 +30,6 @@
#include "nsAutoPtr.h"
#include "nsIWidget.h"
#include "nsStyleSet.h"
#include "nsFrameSelection.h"
#include "nsContentUtils.h" // For AddScriptBlocker().
#include "nsRefreshDriver.h"
#include "mozilla/Attributes.h"
@ -546,17 +545,7 @@ protected:
// Utility method to restore the root scrollframe state
void RestoreRootScrollPosition();
void MaybeReleaseCapturingContent()
{
nsRefPtr<nsFrameSelection> frameSelection = FrameSelection();
if (frameSelection) {
frameSelection->SetDragState(false);
}
if (gCaptureInfo.mContent &&
gCaptureInfo.mContent->OwnerDoc() == mDocument) {
SetCapturingContent(nullptr, 0);
}
}
void MaybeReleaseCapturingContent();
nsresult HandleRetargetedEvent(mozilla::WidgetEvent* aEvent,
nsEventStatus* aStatus,

Просмотреть файл

@ -2,6 +2,7 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "nsImageFrame.h"
#include "nsIFormControlFrame.h"
#include "nsPresContext.h"
@ -10,6 +11,7 @@
#include "nsFormControlFrame.h"
#include "nsLayoutUtils.h"
#include "mozilla/MouseEvents.h"
#include "nsIContent.h"
using namespace mozilla;

Просмотреть файл

@ -22,6 +22,7 @@
#include "nsIFrameInlines.h"
#include "mozilla/ArrayUtils.h"
#include "mozilla/Likely.h"
#include "nsISelection.h"
namespace mozilla {
namespace css {

Просмотреть файл

@ -208,7 +208,7 @@ nsIFrame::ContentOffsets BRFrame::CalcContentOffsetsFromFramePoint(nsPoint aPoin
if (offsets.content) {
offsets.offset = offsets.content->IndexOf(mContent);
offsets.secondaryOffset = offsets.offset;
offsets.associateWithNext = true;
offsets.associate = CARET_ASSOCIATE_AFTER;
}
return offsets;
}

Просмотреть файл

@ -49,6 +49,7 @@
#include "TextOverflow.h"
#include "nsIFrameInlines.h"
#include "CounterStyleManager.h"
#include "nsISelection.h"
#include "nsBidiPresUtils.h"

Просмотреть файл

@ -2817,7 +2817,7 @@ nsFrame::HandlePress(nsPresContext* aPresContext,
return fc->HandleClick(offsets.content, offsets.StartOffset(),
offsets.EndOffset(), false, false,
offsets.associateWithNext);
offsets.associate);
}
// Let Ctrl/Cmd+mouse down do table selection instead of drag initiation
@ -2890,7 +2890,7 @@ nsFrame::HandlePress(nsPresContext* aPresContext,
// weakFrame checks.
rv = fc->HandleClick(offsets.content, offsets.StartOffset(),
offsets.EndOffset(), mouseEvent->IsShift(), control,
offsets.associateWithNext);
offsets.associate);
if (NS_FAILED(rv))
return rv;
@ -2948,8 +2948,7 @@ nsFrame::SelectByTypeAtPoint(nsPresContext* aPresContext,
PresContext()->GetPresShell()->ConstFrameSelection();
nsIFrame* theFrame = frameSelection->
GetFrameForNodeOffset(offsets.content, offsets.offset,
nsFrameSelection::HINT(offsets.associateWithNext),
&offset);
offsets.associate, &offset);
if (!theFrame)
return NS_ERROR_FAILURE;
@ -3071,14 +3070,14 @@ nsFrame::PeekBackwardAndForward(nsSelectionAmount aAmountBack,
rv = frameSelection->HandleClick(startpos.mResultContent,
startpos.mContentOffset, startpos.mContentOffset,
false, (aSelectFlags & SELECT_ACCUMULATE),
nsFrameSelection::HINTRIGHT);
CARET_ASSOCIATE_AFTER);
if (NS_FAILED(rv))
return rv;
rv = frameSelection->HandleClick(endpos.mResultContent,
endpos.mContentOffset, endpos.mContentOffset,
true, false,
nsFrameSelection::HINTLEFT);
CARET_ASSOCIATE_BEFORE);
if (NS_FAILED(rv))
return rv;
@ -3198,7 +3197,7 @@ HandleFrameSelection(nsFrameSelection* aFrameSelection,
aOffsets.EndOffset(),
aFrameSelection->IsShiftDownInDelayedCaretData(),
false,
aOffsets.associateWithNext);
aOffsets.associate);
if (NS_FAILED(rv)) {
return rv;
}
@ -3633,7 +3632,7 @@ nsIFrame::ContentOffsets OffsetsForSingleFrame(nsIFrame* aFrame, nsPoint aPoint)
if (aFrame->GetNextContinuation() || aFrame->GetPrevContinuation()) {
offsets.offset = range.start;
offsets.secondaryOffset = range.end;
offsets.associateWithNext = true;
offsets.associate = CARET_ASSOCIATE_AFTER;
return offsets;
}
@ -3657,7 +3656,8 @@ nsIFrame::ContentOffsets OffsetsForSingleFrame(nsIFrame* aFrame, nsPoint aPoint)
else
offsets.secondaryOffset = range.start;
}
offsets.associateWithNext = (offsets.offset == range.start);
offsets.associate =
offsets.offset == range.start ? CARET_ASSOCIATE_AFTER : CARET_ASSOCIATE_BEFORE;
return offsets;
}
@ -3717,7 +3717,7 @@ nsIFrame::ContentOffsets nsIFrame::GetContentOffsetsFromPoint(nsPoint aPoint,
offsets.content = closest.frame->GetContent();
offsets.offset = 0;
offsets.secondaryOffset = 0;
offsets.associateWithNext = true;
offsets.associate = CARET_ASSOCIATE_AFTER;
return offsets;
}
@ -3732,7 +3732,8 @@ nsIFrame::ContentOffsets nsIFrame::GetContentOffsetsFromPoint(nsPoint aPoint,
else
offsets.offset = range.start;
offsets.secondaryOffset = offsets.offset;
offsets.associateWithNext = (offsets.offset == range.start);
offsets.associate = offsets.offset == range.start ?
CARET_ASSOCIATE_AFTER : CARET_ASSOCIATE_BEFORE;
return offsets;
}
@ -5892,7 +5893,8 @@ nsFrame::GetNextPrevLineFromeBlockFrame(nsPresContext* aPresContext,
aPos->mResultFrame = nullptr;
aPos->mResultContent = nullptr;
aPos->mAttachForward = (aPos->mDirection == eDirNext);
aPos->mAttach =
aPos->mDirection == eDirNext ? CARET_ASSOCIATE_AFTER : CARET_ASSOCIATE_BEFORE;
nsAutoLineIterator it = aBlockFrame->GetLineIterator();
if (!it)
@ -6024,11 +6026,11 @@ nsFrame::GetNextPrevLineFromeBlockFrame(nsPresContext* aPresContext,
{
aPos->mResultContent = parent;
aPos->mContentOffset = parent->IndexOf(content);
aPos->mAttachForward = false;
aPos->mAttach = CARET_ASSOCIATE_BEFORE;
if ((point.x - offset.x+ tempRect.x)>tempRect.width)
{
aPos->mContentOffset++;//go to end of this frame
aPos->mAttachForward = true;
aPos->mAttach = CARET_ASSOCIATE_AFTER;
}
//result frame is the result frames parent.
aPos->mResultFrame = resultFrame->GetParent();
@ -6048,7 +6050,7 @@ nsFrame::GetNextPrevLineFromeBlockFrame(nsPresContext* aPresContext,
resultFrame->GetContentOffsetsFromPoint(point - offset);
aPos->mResultContent = offsets.content;
aPos->mContentOffset = offsets.offset;
aPos->mAttachForward = offsets.associateWithNext;
aPos->mAttach = offsets.associate;
if (offsets.content)
{
bool selectable;
@ -6092,7 +6094,7 @@ nsFrame::GetNextPrevLineFromeBlockFrame(nsPresContext* aPresContext,
resultFrame->GetContentOffsetsFromPoint(point - offset);
aPos->mResultContent = offsets.content;
aPos->mContentOffset = offsets.offset;
aPos->mAttachForward = offsets.associateWithNext;
aPos->mAttach = offsets.associate;
if (offsets.content)
{
bool selectable;
@ -6101,9 +6103,9 @@ nsFrame::GetNextPrevLineFromeBlockFrame(nsPresContext* aPresContext,
{
found = true;
if (resultFrame == farStoppingFrame)
aPos->mAttachForward = false;
aPos->mAttach = CARET_ASSOCIATE_BEFORE;
else
aPos->mAttachForward = true;
aPos->mAttach = CARET_ASSOCIATE_AFTER;
break;
}
}
@ -6124,7 +6126,8 @@ nsFrame::GetNextPrevLineFromeBlockFrame(nsPresContext* aPresContext,
//we need to jump to new block frame.
aPos->mAmount = eSelectLine;
aPos->mStartOffset = 0;
aPos->mAttachForward = !(aPos->mDirection == eDirNext);
aPos->mAttach = aPos->mDirection == eDirNext ?
CARET_ASSOCIATE_BEFORE : CARET_ASSOCIATE_AFTER;
if (aPos->mDirection == eDirPrevious)
aPos->mStartOffset = -1;//start from end
return aBlockFrame->PeekOffset(aPos);
@ -6607,7 +6610,8 @@ nsIFrame::PeekOffset(nsPeekOffsetStruct* aPos)
--aPos->mContentOffset;
}
aPos->mResultFrame = targetFrame.frame;
aPos->mAttachForward = (aPos->mContentOffset == range.start);
aPos->mAttach = aPos->mContentOffset == range.start ?
CARET_ASSOCIATE_AFTER : CARET_ASSOCIATE_BEFORE;
if (!range.content)
return NS_ERROR_FAILURE;
return NS_OK;
@ -8594,7 +8598,7 @@ nsIFrame::ContentOffsets::ContentOffsets(const ContentOffsets& rhs)
: content(rhs.content),
offset(rhs.offset),
secondaryOffset(rhs.secondaryOffset),
associateWithNext(rhs.associateWithNext)
associate(rhs.associate)
{
}

Просмотреть файл

@ -14,8 +14,10 @@
#include "nsISelectionController.h"
#include "nsITableCellLayout.h"
#include "nsIDOMElement.h"
#include "nsRange.h"
#include "WordMovementType.h"
#include "CaretAssociationHint.h"
class nsRange;
class nsTableOuterFrame;
// IID for the nsFrameSelection interface
@ -50,8 +52,6 @@ struct SelectionDetails
class nsIPresShell;
class nsIScrollableFrame;
enum EWordMovementType { eStartWord, eEndWord, eDefaultBehavior };
/** PeekOffsetStruct is used to group various arguments (both input and output)
* that are passed to nsFrame::PeekOffset(). See below for the description of
* individual arguments.
@ -66,22 +66,7 @@ struct MOZ_STACK_CLASS nsPeekOffsetStruct
bool aScrollViewStop,
bool aIsKeyboardSelect,
bool aVisual,
EWordMovementType aWordMovementType = eDefaultBehavior)
: mAmount(aAmount)
, mDirection(aDirection)
, mStartOffset(aStartOffset)
, mDesiredX(aDesiredX)
, mWordMovementType(aWordMovementType)
, mJumpLines(aJumpLines)
, mScrollViewStop(aScrollViewStop)
, mIsKeyboardSelect(aIsKeyboardSelect)
, mVisual(aVisual)
, mResultContent()
, mResultFrame(nullptr)
, mContentOffset(0)
, mAttachForward(false)
{
}
mozilla::EWordMovementType aWordMovementType = mozilla::eDefaultBehavior);
// Note: Most arguments (input and output) are only used with certain values
// of mAmount. These values are indicated for each argument below.
@ -117,7 +102,7 @@ struct MOZ_STACK_CLASS nsPeekOffsetStruct
// or to use the default beahvior, which is a combination of
// direction and the platform-based pref
// "layout.word_select.eat_space_to_next_word"
EWordMovementType mWordMovementType;
mozilla::EWordMovementType mWordMovementType;
// mJumpLines: Whether to allow jumping across line boundaries.
// Used with: eSelectCharacter, eSelectWord.
@ -152,7 +137,7 @@ struct MOZ_STACK_CLASS nsPeekOffsetStruct
// false means "the end of the frame logically before the caret",
// true means "the beginning of the frame logically after the caret".
// Used with: eSelectLine, eSelectBeginLine, eSelectEndLine.
bool mAttachForward;
mozilla::CaretAssociationHint mAttach;
};
struct nsPrevNextBidiLevels
@ -188,7 +173,8 @@ class nsIScrollableFrame;
class nsFrameSelection MOZ_FINAL {
public:
enum HINT { HINTLEFT = 0, HINTRIGHT = 1}; //end of this line or beginning of next
typedef mozilla::CaretAssociationHint CaretAssociateHint;
/*interfaces for addref and release and queryinterface*/
NS_INLINE_DECL_CYCLE_COLLECTING_NATIVE_REFCOUNTING(nsFrameSelection)
@ -220,7 +206,7 @@ public:
uint32_t aContentEndOffset,
bool aContinueSelection,
bool aMultipleSelection,
bool aHint);
CaretAssociateHint aHint);
/** HandleDrag extends the selection to contain the frame closest to aPoint.
* @param aPresContext is the context to use when figuring out what frame contains the point.
@ -387,10 +373,10 @@ public:
* @param aOffset offset into above node.
* @param aReturnOffset will contain offset into frame.
*/
virtual nsIFrame* GetFrameForNodeOffset(nsIContent *aNode,
int32_t aOffset,
HINT aHint,
int32_t *aReturnOffset) const;
virtual nsIFrame* GetFrameForNodeOffset(nsIContent* aNode,
int32_t aOffset,
CaretAssociateHint aHint,
int32_t* aReturnOffset) const;
/**
* Scrolling then moving caret placement code in common to text areas and
@ -409,8 +395,8 @@ public:
bool aExtend,
nsIScrollableFrame* aScrollableFrame);
void SetHint(HINT aHintRight) { mHint = aHintRight; }
HINT GetHint() const { return mHint; }
void SetHint(CaretAssociateHint aHintRight) { mHint = aHintRight; }
CaretAssociateHint GetHint() const { return mHint; }
/** SetCaretBidiLevel sets the caret bidi level
* @param aLevel the caret bidi level
@ -597,15 +583,15 @@ public:
void DisconnectFromPresShell();
nsresult ClearNormalSelection();
static HINT GetHintForPosition(nsIContent* aContent, int32_t aOffset);
static CaretAssociateHint GetHintForPosition(nsIContent* aContent, int32_t aOffset);
private:
~nsFrameSelection() {}
~nsFrameSelection();
nsresult TakeFocus(nsIContent *aNewFocus,
uint32_t aContentOffset,
uint32_t aContentEndOffset,
HINT aHint,
CaretAssociateHint aHint,
bool aContinueSelection,
bool aMultipleSelection);
@ -613,11 +599,11 @@ private:
nsIContent *aNode,
uint32_t aContentOffset,
uint32_t aKeycode,
HINT aHint);
CaretAssociateHint aHint);
void BidiLevelFromClick(nsIContent *aNewFocus, uint32_t aContentOffset);
nsPrevNextBidiLevels GetPrevNextBidiLevels(nsIContent *aNode,
uint32_t aContentOffset,
HINT aHint,
CaretAssociateHint aHint,
bool aJumpLines) const;
bool AdjustForMaintainedSelection(nsIContent *aContent, int32_t aOffset);
@ -710,7 +696,7 @@ private:
int16_t mSelectionChangeReason; // reason for notifications of selection changing
int16_t mDisplaySelection; //for visual display purposes.
HINT mHint; //hint to tell if the selection is at the end of this line or beginning of next
CaretAssociateHint mHint; //hint to tell if the selection is at the end of this line or beginning of next
uint8_t mCaretBidiLevel;
int32_t mDesiredX;

Просмотреть файл

@ -36,6 +36,7 @@
#include "gfx3DMatrix.h"
#include "nsLayoutUtils.h"
#include "nsFrameState.h"
#include "CaretAssociationHint.h"
#ifdef ACCESSIBILITY
#include "mozilla/a11y/AccTypes.h"
@ -1256,10 +1257,10 @@ public:
// numerical order, as opposed to wanting the primary and secondary offsets
int32_t StartOffset() { return std::min(offset, secondaryOffset); }
int32_t EndOffset() { return std::max(offset, secondaryOffset); }
// This boolean indicates whether the associated content is before or after
// This value indicates whether the associated content is before or after
// the offset; the most visible use is to allow the caret to know which line
// to display on.
bool associateWithNext;
mozilla::CaretAssociationHint associate;
};
enum {
IGNORE_SELECTION_STYLE = 0x01,

Просмотреть файл

@ -106,6 +106,31 @@ static void printRange(nsRange *aDomRange);
//#define DEBUG_TABLE_SELECTION 1
nsPeekOffsetStruct::nsPeekOffsetStruct(nsSelectionAmount aAmount,
nsDirection aDirection,
int32_t aStartOffset,
nscoord aDesiredX,
bool aJumpLines,
bool aScrollViewStop,
bool aIsKeyboardSelect,
bool aVisual,
EWordMovementType aWordMovementType)
: mAmount(aAmount)
, mDirection(aDirection)
, mStartOffset(aStartOffset)
, mDesiredX(aDesiredX)
, mWordMovementType(aWordMovementType)
, mJumpLines(aJumpLines)
, mScrollViewStop(aScrollViewStop)
, mIsKeyboardSelect(aIsKeyboardSelect)
, mVisual(aVisual)
, mResultContent()
, mResultFrame(nullptr)
, mContentOffset(0)
, mAttach(CARET_ASSOCIATE_BEFORE)
{
}
struct CachedOffsetForFrame {
CachedOffsetForFrame()
: mCachedFrameOffset(0, 0) // nsPoint ctor
@ -333,7 +358,7 @@ nsFrameSelection::nsFrameSelection()
mMouseDoubleDownState = false;
mHint = HINTLEFT;
mHint = CARET_ASSOCIATE_BEFORE;
mCaretBidiLevel = BIDI_LEVEL_UNDEFINED;
mDragSelectingCells = false;
mSelectingTableCellMode = 0;
@ -364,6 +389,9 @@ nsFrameSelection::nsFrameSelection()
mDelayedMouseEventClickCount = 0;
}
nsFrameSelection::~nsFrameSelection()
{
}
NS_IMPL_CYCLE_COLLECTION_CLASS(nsFrameSelection)
@ -688,17 +716,17 @@ GetCellParent(nsINode *aDomNode)
return nullptr;
}
nsFrameSelection::HINT
CaretAssociationHint
nsFrameSelection::GetHintForPosition(nsIContent* aContent, int32_t aOffset)
{
HINT hint = HINTLEFT;
CaretAssociateHint hint = CARET_ASSOCIATE_BEFORE;
if (!aContent || aOffset < 1) {
return hint;
}
const nsTextFragment* text = aContent->GetText();
if (text && text->CharAt(aOffset - 1) == '\n') {
// Attach the caret to the next line if needed
hint = HINTRIGHT;
hint = CARET_ASSOCIATE_AFTER;
}
return hint;
}
@ -821,7 +849,7 @@ nsFrameSelection::MoveCaret(uint32_t aKeycode,
sel->Collapse(anchorFocusRange->GetStartParent(),
anchorFocusRange->StartOffset());
}
mHint = HINTRIGHT;
mHint = CARET_ASSOCIATE_AFTER;
sel->ScrollIntoView(nsISelectionController::SELECTION_FOCUS_REGION,
nsIPresShell::ScrollAxis(),
nsIPresShell::ScrollAxis(), scrollFlags);
@ -837,7 +865,7 @@ nsFrameSelection::MoveCaret(uint32_t aKeycode,
sel->Collapse(anchorFocusRange->GetEndParent(),
anchorFocusRange->EndOffset());
}
mHint = HINTLEFT;
mHint = CARET_ASSOCIATE_BEFORE;
sel->ScrollIntoView(nsISelectionController::SELECTION_FOCUS_REGION,
nsIPresShell::ScrollAxis(),
nsIPresShell::ScrollAxis(), scrollFlags);
@ -861,7 +889,7 @@ nsFrameSelection::MoveCaret(uint32_t aKeycode,
nsBidiLevel baseLevel = nsBidiPresUtils::GetFrameBaseLevel(frame);
HINT tHint(mHint); //temporary variable so we dont set mHint until it is necessary
CaretAssociateHint tHint(mHint); //temporary variable so we dont set mHint until it is necessary
switch (aKeycode){
case nsIDOMKeyEvent::DOM_VK_RIGHT :
InvalidateDesiredX();
@ -907,19 +935,19 @@ nsFrameSelection::MoveCaret(uint32_t aKeycode,
{
// For left/right, PeekOffset() sets pos.mResultFrame correctly, but does not set pos.mAttachForward,
// so determine the hint here based on the result frame and offset:
// If we're at the end of a text frame, set the hint to HINTLEFT to indicate that we
// If we're at the end of a text frame, set the hint to ASSOCIATE_BEFORE to indicate that we
// want the caret displayed at the end of this frame, not at the beginning of the next one.
theFrame = pos.mResultFrame;
theFrame->GetOffsets(frameStart, frameEnd);
currentOffset = pos.mContentOffset;
if (frameEnd == currentOffset && !(frameStart == 0 && frameEnd == 0))
tHint = HINTLEFT;
tHint = CARET_ASSOCIATE_BEFORE;
else
tHint = HINTRIGHT;
tHint = CARET_ASSOCIATE_AFTER;
} else {
// For up/down and home/end, pos.mResultFrame might not be set correctly, or not at all.
// In these cases, get the frame based on the content and hint returned by PeekOffset().
tHint = (HINT)pos.mAttachForward;
tHint = pos.mAttach;
theFrame = GetFrameForNodeOffset(pos.mResultContent, pos.mContentOffset,
tHint, &currentOffset);
if (!theFrame)
@ -958,7 +986,7 @@ nsFrameSelection::MoveCaret(uint32_t aKeycode,
sel->Collapse(sel->GetFocusNode(), sel->FocusOffset());
// Note: 'frame' might be dead here.
if (!isBRFrame) {
mHint = HINTLEFT; // We're now at the end of the frame to the left.
mHint = CARET_ASSOCIATE_BEFORE; // We're now at the end of the frame to the left.
}
result = NS_OK;
}
@ -1081,12 +1109,7 @@ Selection::SetInterlinePosition(bool aHintRight, ErrorResult& aRv)
aRv.Throw(NS_ERROR_NOT_INITIALIZED); // Can't do selection
return;
}
nsFrameSelection::HINT hint;
if (aHintRight)
hint = nsFrameSelection::HINTRIGHT;
else
hint = nsFrameSelection::HINTLEFT;
mFrameSelection->SetHint(hint);
mFrameSelection->SetHint(aHintRight ? CARET_ASSOCIATE_AFTER : CARET_ASSOCIATE_BEFORE);
}
NS_IMETHODIMP
@ -1107,7 +1130,7 @@ Selection::GetInterlinePosition(ErrorResult& aRv)
aRv.Throw(NS_ERROR_NOT_INITIALIZED); // Can't do selection
return false;
}
return (mFrameSelection->GetHint() == nsFrameSelection::HINTRIGHT);
return mFrameSelection->GetHint() == CARET_ASSOCIATE_AFTER;
}
nsPrevNextBidiLevels
@ -1119,10 +1142,10 @@ nsFrameSelection::GetPrevNextBidiLevels(nsIContent *aNode,
}
nsPrevNextBidiLevels
nsFrameSelection::GetPrevNextBidiLevels(nsIContent *aNode,
uint32_t aContentOffset,
HINT aHint,
bool aJumpLines) const
nsFrameSelection::GetPrevNextBidiLevels(nsIContent* aNode,
uint32_t aContentOffset,
CaretAssociateHint aHint,
bool aJumpLines) const
{
// Get the level of the frames on each side
nsIFrame *currentFrame;
@ -1269,11 +1292,11 @@ nsFrameSelection::MaintainSelection(nsSelectionAmount aAmount)
* @param aKeycode is the keyboard event that moved the caret to the new position
* @param aHint is the hint indicating in what logical direction the caret moved
*/
void nsFrameSelection::BidiLevelFromMove(nsIPresShell* aPresShell,
nsIContent *aNode,
uint32_t aContentOffset,
uint32_t aKeycode,
HINT aHint)
void nsFrameSelection::BidiLevelFromMove(nsIPresShell* aPresShell,
nsIContent* aNode,
uint32_t aContentOffset,
uint32_t aKeycode,
CaretAssociateHint aHint)
{
switch (aKeycode) {
@ -1284,10 +1307,8 @@ void nsFrameSelection::BidiLevelFromMove(nsIPresShell* aPresShell,
nsPrevNextBidiLevels levels = GetPrevNextBidiLevels(aNode, aContentOffset,
aHint, false);
if (HINTLEFT == aHint)
SetCaretBidiLevel(levels.mLevelBefore);
else
SetCaretBidiLevel(levels.mLevelAfter);
SetCaretBidiLevel(aHint == CARET_ASSOCIATE_BEFORE ?
levels.mLevelBefore : levels.mLevelAfter);
break;
}
/*
@ -1373,12 +1394,12 @@ nsFrameSelection::AdjustForMaintainedSelection(nsIContent *aContent,
nsresult
nsFrameSelection::HandleClick(nsIContent *aNewFocus,
uint32_t aContentOffset,
uint32_t aContentEndOffset,
bool aContinueSelection,
bool aMultipleSelection,
bool aHint)
nsFrameSelection::HandleClick(nsIContent* aNewFocus,
uint32_t aContentOffset,
uint32_t aContentEndOffset,
bool aContinueSelection,
bool aMultipleSelection,
CaretAssociateHint aHint)
{
if (!aNewFocus)
return NS_ERROR_INVALID_ARG;
@ -1401,7 +1422,7 @@ nsFrameSelection::HandleClick(nsIContent *aNewFocus,
AdjustForMaintainedSelection(aNewFocus, aContentOffset))
return NS_OK; //shift clicked to maintained selection. rejected.
return TakeFocus(aNewFocus, aContentOffset, aContentEndOffset, HINT(aHint),
return TakeFocus(aNewFocus, aContentOffset, aContentEndOffset, aHint,
aContinueSelection, aMultipleSelection);
}
@ -1449,7 +1470,8 @@ nsFrameSelection::HandleDrag(nsIFrame *aFrame, nsPoint aPoint)
amount = eSelectEndLine;
int32_t offset;
nsIFrame* frame = GetFrameForNodeOffset(offsets.content, offsets.offset, HINTRIGHT, &offset);
nsIFrame* frame = GetFrameForNodeOffset(offsets.content, offsets.offset,
CARET_ASSOCIATE_AFTER, &offset);
if (frame && amount == eSelectWord && direction == eDirPrevious) {
// To avoid selecting the previous word when at start of word,
@ -1472,7 +1494,7 @@ nsFrameSelection::HandleDrag(nsIFrame *aFrame, nsPoint aPoint)
}
HandleClick(offsets.content, offsets.offset, offsets.offset,
true, false, offsets.associateWithNext);
true, false, offsets.associate);
}
nsresult
@ -1501,12 +1523,12 @@ nsFrameSelection::StopAutoScrollTimer()
hard to go from nodes to frames, easy the other way!
*/
nsresult
nsFrameSelection::TakeFocus(nsIContent *aNewFocus,
uint32_t aContentOffset,
uint32_t aContentEndOffset,
HINT aHint,
bool aContinueSelection,
bool aMultipleSelection)
nsFrameSelection::TakeFocus(nsIContent* aNewFocus,
uint32_t aContentOffset,
uint32_t aContentEndOffset,
CaretAssociateHint aHint,
bool aContinueSelection,
bool aMultipleSelection)
{
if (!aNewFocus)
return NS_ERROR_NULL_POINTER;
@ -1725,10 +1747,10 @@ nsFrameSelection::RepaintSelection(SelectionType aType) const
}
nsIFrame*
nsFrameSelection::GetFrameForNodeOffset(nsIContent *aNode,
int32_t aOffset,
HINT aHint,
int32_t *aReturnOffset) const
nsFrameSelection::GetFrameForNodeOffset(nsIContent* aNode,
int32_t aOffset,
CaretAssociateHint aHint,
int32_t* aReturnOffset) const
{
if (!aNode || !aReturnOffset || !mShell)
return nullptr;
@ -1745,15 +1767,16 @@ nsFrameSelection::GetFrameForNodeOffset(nsIContent *aNode,
int32_t childIndex = 0;
int32_t numChildren = theNode->GetChildCount();
if (aHint == HINTLEFT)
if (aHint == CARET_ASSOCIATE_BEFORE)
{
if (aOffset > 0)
childIndex = aOffset - 1;
else
childIndex = aOffset;
}
else // HINTRIGHT
else
{
NS_ASSERTION(aHint == CARET_ASSOCIATE_AFTER, "unknown direction");
if (aOffset >= numChildren)
{
if (numChildren > 0)
@ -1844,7 +1867,7 @@ nsFrameSelection::GetFrameForNodeOffset(nsIContent *aNode,
return nullptr;
// find the child frame containing the offset we want
returnFrame->GetChildFrameContainingOffset(*aReturnOffset, aHint == HINTRIGHT,
returnFrame->GetChildFrameContainingOffset(*aReturnOffset, aHint == CARET_ASSOCIATE_AFTER,
&aOffset, &returnFrame);
return returnFrame;
}
@ -1901,7 +1924,7 @@ nsFrameSelection::CommonPageMove(bool aForward,
// place the caret
HandleClick(offsets.content, offsets.offset,
offsets.offset, aExtend, false, true);
offsets.offset, aExtend, false, CARET_ASSOCIATE_AFTER);
}
nsresult
@ -1984,7 +2007,7 @@ nsFrameSelection::SelectAll()
}
int32_t numChildren = rootContent->GetChildCount();
PostReason(nsISelectionListener::NO_REASON);
return TakeFocus(rootContent, 0, numChildren, HINTLEFT, false, false);
return TakeFocus(rootContent, 0, numChildren, CARET_ASSOCIATE_BEFORE, false, false);
}
//////////END FRAMESELECTION
@ -2977,7 +3000,7 @@ nsFrameSelection::SetAncestorLimiter(nsIContent *aLimiter)
ClearNormalSelection();
if (mAncestorLimiter) {
PostReason(nsISelectionListener::NO_REASON);
TakeFocus(mAncestorLimiter, 0, 0, HINTLEFT, false, false);
TakeFocus(mAncestorLimiter, 0, 0, CARET_ASSOCIATE_BEFORE, false, false);
}
}
}
@ -3918,7 +3941,7 @@ Selection::GetPrimaryFrameForFocusNode(nsIFrame** aReturnFrame,
if (!aOffsetUsed)
aOffsetUsed = &frameOffset;
nsFrameSelection::HINT hint = mFrameSelection->GetHint();
CaretAssociationHint hint = mFrameSelection->GetHint();
if (aVisual) {
uint8_t caretBidiLevel = mFrameSelection->GetCaretBidiLevel();
@ -5374,7 +5397,7 @@ Selection::GetSelectionEndPointGeometry(SelectionRegion aRegion, nsRect* aRect)
// Return the rect relative to the frame, with zero width.
if (isText) {
aRect->x = pt.x;
} else if (mFrameSelection->GetHint() == nsFrameSelection::HINTLEFT) {
} else if (mFrameSelection->GetHint() == CARET_ASSOCIATE_BEFORE) {
// It's the frame's right edge we're interested in.
aRect->x = frame->GetRect().width;
}
@ -5801,18 +5824,6 @@ Selection::SelectionLanguageChange(bool aLangRTL)
// the cursor is at a frame boundary, so use GetPrevNextBidiLevels to find the level of the characters
// before and after the cursor
nsCOMPtr<nsIContent> focusContent = do_QueryInterface(GetFocusNode());
/*
nsFrameSelection::HINT hint;
if ((focusOffset == frameStart && level) // beginning of an RTL frame
|| (focusOffset == frameEnd && !level)) { // end of an LTR frame
hint = nsFrameSelection::HINTRIGHT;
}
else { // end of an RTL frame or beginning of an LTR frame
hint = nsFrameSelection::HINTLEFT;
}
mFrameSelection->SetHint(hint);
*/
nsPrevNextBidiLevels levels = mFrameSelection->
GetPrevNextBidiLevels(focusContent, focusOffset, false);

Просмотреть файл

@ -6294,7 +6294,8 @@ nsTextFrame::GetCharacterOffsetAtFramePointInternal(nsPoint aPoint,
offsets.content = GetContent();
offsets.offset = offsets.secondaryOffset = selectedOffset;
offsets.associateWithNext = mContentOffset == offsets.offset;
offsets.associate =
mContentOffset == offsets.offset ? CARET_ASSOCIATE_AFTER : CARET_ASSOCIATE_BEFORE;
return offsets;
}

Просмотреть файл

@ -39,6 +39,7 @@
#include "SVGPathElement.h"
#include "SVGTextPathElement.h"
#include "nsLayoutUtils.h"
#include "nsFrameSelection.h"
#include <algorithm>
#include <cmath>
#include <limits>
@ -4050,7 +4051,7 @@ SVGTextFrame::SelectSubString(nsIContent* aContent,
nsRefPtr<nsFrameSelection> frameSelection = GetFrameSelection();
frameSelection->HandleClick(content, charnum, charnum + nchars,
false, false, false);
false, false, CARET_ASSOCIATE_BEFORE);
return NS_OK;
}

Просмотреть файл

@ -44,6 +44,7 @@
#include "nsDisplayList.h"
#include "ImageLayers.h"
#include "ImageContainer.h"
#include "nsIContent.h"
#include "nsContentUtils.h"

Просмотреть файл

@ -5,12 +5,14 @@
#include "nsListItemFrame.h"
#include <algorithm>
#include "nsCOMPtr.h"
#include "nsNameSpaceManager.h"
#include "nsGkAtoms.h"
#include "nsDisplayList.h"
#include "nsBoxLayout.h"
#include <algorithm>
#include "nsIContent.h"
nsListItemFrame::nsListItemFrame(nsIPresShell* aPresShell,
nsStyleContext* aContext,

Просмотреть файл

@ -7,6 +7,7 @@
#include "nsITreeBoxObject.h"
#include "imgIRequest.h"
#include "imgIContainer.h"
#include "nsIContent.h"
NS_IMPL_ISUPPORTS(nsTreeImageListener, imgINotificationObserver)