From 0efb95265db8d22d3ff818acb6cf52214e33afc2 Mon Sep 17 00:00:00 2001 From: "roc+%cs.cmu.edu" Date: Wed, 26 Apr 2006 01:57:22 +0000 Subject: [PATCH] Bug 330305. Rename nsSelection to nsFrameSelection, and deCOMtaminate it, removing nsIFrameSelection. patch by Marc Liddell, r+sr=roc git-svn-id: svn://10.0.0.236/trunk@195411 18797224-902f-48f8-a5cc-f745e15eee43 --- .../base/public/nsISelectionPrivate.idl | 7 +- .../content/base/src/nsDocumentEncoder.cpp | 1 - .../events/src/nsEventListenerManager.cpp | 1 - .../events/src/nsEventStateManager.cpp | 73 +-- .../content/events/src/nsEventStateManager.h | 3 - .../html/document/src/nsHTMLDocument.cpp | 2 +- mozilla/dom/src/base/nsGlobalWindow.cpp | 8 +- .../libeditor/html/nsHTMLDataTransfer.cpp | 1 - .../libeditor/text/nsTextEditRulesBidi.cpp | 15 +- mozilla/layout/base/Makefile.in | 1 - mozilla/layout/base/nsCaret.cpp | 56 +-- mozilla/layout/base/nsCaret.h | 6 +- mozilla/layout/base/nsICaret.h | 4 +- mozilla/layout/base/nsIFrameSelection.h | 462 ------------------ 14 files changed, 78 insertions(+), 562 deletions(-) diff --git a/mozilla/content/base/public/nsISelectionPrivate.idl b/mozilla/content/base/public/nsISelectionPrivate.idl index 3c10e5ce717..d6a9e96c498 100644 --- a/mozilla/content/base/public/nsISelectionPrivate.idl +++ b/mozilla/content/base/public/nsISelectionPrivate.idl @@ -39,16 +39,17 @@ #include "nsISelectionListener.idl" #include "nsIEnumerator.idl" -interface nsIFrameSelection; interface nsIDOMRange; interface nsISelectionListener; %{C++ +class nsFrameSelection; class nsIFrame; class nsIPresShell; struct nsPoint; %} +[ptr] native nsFrameSelection(nsFrameSelection); [ptr] native nsIFrame(nsIFrame); [ptr] native nsIPresShell(nsIPresShell); [ref] native nsPointRef(nsPoint); @@ -78,7 +79,7 @@ interface nsISelectionPrivate : nsISupports /* Table selection stuff We should probably move this and table-related - items in nsIFrameSelection to a + items in nsFrameSelection to a new nsITableSelection interface */ const long TABLESELECTION_NONE = 0; @@ -113,6 +114,6 @@ interface nsISelectionPrivate : nsISupports /* getFrameSelection * Returnes a reference to the frame selection associated with this selection */ - [noscript] nsIFrameSelection getFrameSelection(); + [noscript] nsFrameSelection getFrameSelection(); }; diff --git a/mozilla/content/base/src/nsDocumentEncoder.cpp b/mozilla/content/base/src/nsDocumentEncoder.cpp index 480930e0d86..ebf7ff56e05 100644 --- a/mozilla/content/base/src/nsDocumentEncoder.cpp +++ b/mozilla/content/base/src/nsDocumentEncoder.cpp @@ -69,7 +69,6 @@ #include "nsITextContent.h" #include "nsIEnumerator.h" #include "nsISelectionPrivate.h" -#include "nsIFrameSelection.h" #include "nsISupportsArray.h" #include "nsIParserService.h" #include "nsIScriptContext.h" diff --git a/mozilla/content/events/src/nsEventListenerManager.cpp b/mozilla/content/events/src/nsEventListenerManager.cpp index 5b3300b9af0..5de0effb833 100644 --- a/mozilla/content/events/src/nsEventListenerManager.cpp +++ b/mozilla/content/events/src/nsEventListenerManager.cpp @@ -40,7 +40,6 @@ #include "nsDOMEvent.h" #include "nsEventListenerManager.h" #include "nsICaret.h" -#include "nsIFrameSelection.h" #include "nsIDOMNSEvent.h" #include "nsIDOMEventListener.h" #include "nsIDOMMouseListener.h" diff --git a/mozilla/content/events/src/nsEventStateManager.cpp b/mozilla/content/events/src/nsEventStateManager.cpp index 3eb6522e510..f30d09cb616 100644 --- a/mozilla/content/events/src/nsEventStateManager.cpp +++ b/mozilla/content/events/src/nsEventStateManager.cpp @@ -77,7 +77,7 @@ #include "nsIBaseWindow.h" #include "nsIScrollableView.h" #include "nsISelection.h" -#include "nsIFrameSelection.h" +#include "nsFrameSelection.h" #include "nsIDeviceContext.h" #include "nsIPrivateDOMEvent.h" #include "nsIDOMWindowInternal.h" @@ -1324,12 +1324,11 @@ nsEventStateManager::FireContextClick() FillInEventFromGestureDown(&event); // stop selection tracking, we're in control now - nsCOMPtr frameSel; - GetSelection(mCurrentTarget, mPresContext, getter_AddRefs(frameSel)); - if (frameSel) { - PRBool mouseDownState = PR_TRUE; - frameSel->GetMouseDownState(&mouseDownState); - if (mouseDownState) { + if (mCurrentTarget) + { + nsFrameSelection* frameSel = mCurrentTarget->GetFrameSelection(); + + if (frameSel && frameSel->GetMouseDownState()) { // note that this can cause selection changed events to fire if we're in // a text field, which will null out mCurrentTarget frameSel->SetMouseDownState(PR_FALSE); @@ -1414,25 +1413,6 @@ nsEventStateManager::StopTrackingDragGesture() mGestureDownFrameOwner = nsnull; } - -// -// GetSelection -// -// Helper routine to get an nsIFrameSelection from the given frame -// -void -nsEventStateManager::GetSelection(nsIFrame* inFrame, - nsPresContext* inPresContext, - nsIFrameSelection** outSelection) -{ - if (!inFrame || !outSelection) { - NS_ERROR("Invalid call"); - return; - } - *outSelection = inFrame->GetFrameSelection(); - NS_IF_ADDREF(*outSelection); -} - void nsEventStateManager::FillInEventFromGestureDown(nsMouseEvent* aEvent) { @@ -1482,12 +1462,10 @@ nsEventStateManager::GenerateDragGesture(nsPresContext* aPresContext, // Check if selection is tracking drag gestures, if so // don't interfere! - nsCOMPtr frameSel; - GetSelection ( mCurrentTarget, aPresContext, getter_AddRefs(frameSel) ); - if ( frameSel ) { - PRBool mouseDownState = PR_TRUE; - frameSel->GetMouseDownState(&mouseDownState); - if (mouseDownState) { + if (mCurrentTarget) + { + nsFrameSelection* frameSel = mCurrentTarget->GetFrameSelection(); + if (frameSel && frameSel->GetMouseDownState()) { StopTrackingDragGesture(); return; } @@ -4580,14 +4558,15 @@ nsEventStateManager::GetDocSelectionLocation(nsIContent **aStartContent, nsIPresShell *shell; shell = mPresContext->GetPresShell(); - nsIFrameSelection *frameSelection = nsnull; + nsFrameSelection *frameSelection = nsnull; if (shell) frameSelection = shell->FrameSelection(); nsCOMPtr domSelection; - if (frameSelection) - rv = frameSelection->GetSelection(nsISelectionController::SELECTION_NORMAL, - getter_AddRefs(domSelection)); + if (frameSelection) { + domSelection = frameSelection-> + GetSelection(nsISelectionController::SELECTION_NORMAL); + } nsCOMPtr startNode, endNode; PRBool isCollapsed = PR_FALSE; @@ -4624,6 +4603,9 @@ nsEventStateManager::GetDocSelectionLocation(nsIContent **aStartContent, } } } + else { + rv = NS_ERROR_INVALID_ARG; + } nsIFrame *startFrame = nsnull; if (startContent) { @@ -4932,10 +4914,8 @@ nsEventStateManager::MoveCaretToFocus() nsCOMPtr rangeDoc(do_QueryInterface(mDocument)); if (rangeDoc) { - nsCOMPtr domSelection; - shell->FrameSelection()-> - GetSelection(nsISelectionController::SELECTION_NORMAL, - getter_AddRefs(domSelection)); + nsISelection* domSelection = shell->FrameSelection()-> + GetSelection(nsISelectionController::SELECTION_NORMAL); if (domSelection) { nsCOMPtr currentFocusNode(do_QueryInterface(mCurrentFocus)); // First clear the selection @@ -4993,19 +4973,20 @@ nsEventStateManager::SetContentCaretVisible(nsIPresShell* aPresShell, nsCOMPtr caret; aPresShell->GetCaret(getter_AddRefs(caret)); - nsCOMPtr frameSelection; + nsFrameSelection* frameSelection = nsnull; if (aFocusedContent) { nsIFrame *focusFrame = aPresShell->GetPrimaryFrameFor(aFocusedContent); - - GetSelection(focusFrame, mPresContext, getter_AddRefs(frameSelection)); + + if (focusFrame) + frameSelection = focusFrame->GetFrameSelection(); } - nsIFrameSelection *docFrameSelection = aPresShell->FrameSelection(); + nsFrameSelection *docFrameSelection = aPresShell->FrameSelection(); if (docFrameSelection && caret && (frameSelection == docFrameSelection || !aFocusedContent)) { - nsCOMPtr domSelection; - docFrameSelection->GetSelection(nsISelectionController::SELECTION_NORMAL, getter_AddRefs(domSelection)); + nsISelection* domSelection = docFrameSelection-> + GetSelection(nsISelectionController::SELECTION_NORMAL); if (domSelection) { // First, tell the caret which selection to use caret->SetCaretDOMSelection(domSelection); diff --git a/mozilla/content/events/src/nsEventStateManager.h b/mozilla/content/events/src/nsEventStateManager.h index a10372e6f1c..761578a8b96 100644 --- a/mozilla/content/events/src/nsEventStateManager.h +++ b/mozilla/content/events/src/nsEventStateManager.h @@ -52,7 +52,6 @@ class nsIScrollableView; class nsIPresShell; -class nsIFrameSelection; class nsIDocShell; class nsIDocShellTreeNode; class nsIDocShellTreeItem; @@ -277,8 +276,6 @@ protected: nsresult GetDocSelectionLocation(nsIContent **start, nsIContent **end, nsIFrame **startFrame, PRUint32 *startOffset); - void GetSelection ( nsIFrame* inFrame, nsPresContext* inPresContext, nsIFrameSelection** outSelection ) ; - // To be called before and after you fire an event, to update booleans and // such void BeforeDispatchEvent() { ++mDOMEventLevel; } diff --git a/mozilla/content/html/document/src/nsHTMLDocument.cpp b/mozilla/content/html/document/src/nsHTMLDocument.cpp index 83e346d60d2..00040df6771 100644 --- a/mozilla/content/html/document/src/nsHTMLDocument.cpp +++ b/mozilla/content/html/document/src/nsHTMLDocument.cpp @@ -104,7 +104,7 @@ #include "nsIFile.h" #include "nsIEventListenerManager.h" #include "nsISelectElement.h" -#include "nsIFrameSelection.h" +#include "nsFrameSelection.h" #include "nsISelectionPrivate.h"//for toStringwithformat code #include "nsICharsetDetector.h" diff --git a/mozilla/dom/src/base/nsGlobalWindow.cpp b/mozilla/dom/src/base/nsGlobalWindow.cpp index 0e276e0899c..9feea7a3307 100644 --- a/mozilla/dom/src/base/nsGlobalWindow.cpp +++ b/mozilla/dom/src/base/nsGlobalWindow.cpp @@ -111,7 +111,6 @@ #include "nsIScrollableView.h" #include "nsISelectionController.h" #include "nsISelection.h" -#include "nsIFrameSelection.h" #include "nsIPrompt.h" #include "nsIWebNavigation.h" #include "nsIWebBrowser.h" @@ -4560,9 +4559,12 @@ nsGlobalWindow::GetSelection(nsISelection** aSelection) if (!presShell) return NS_OK; + + *aSelection = presShell->GetCurrentSelection(nsISelectionController::SELECTION_NORMAL); + + NS_IF_ADDREF(*aSelection); - return presShell->FrameSelection()-> - GetSelection(nsISelectionController::SELECTION_NORMAL, aSelection); + return NS_OK; } // Non-scriptable version of window.find(), part of nsIDOMWindowInternal diff --git a/mozilla/editor/libeditor/html/nsHTMLDataTransfer.cpp b/mozilla/editor/libeditor/html/nsHTMLDataTransfer.cpp index 4f1d556bcdd..3ccce19df9a 100644 --- a/mozilla/editor/libeditor/html/nsHTMLDataTransfer.cpp +++ b/mozilla/editor/libeditor/html/nsHTMLDataTransfer.cpp @@ -64,7 +64,6 @@ #include "nsIDOMHTMLImageElement.h" #include "nsISelectionController.h" #include "nsIFileChannel.h" -#include "nsIFrameSelection.h" // For TABLESELECTION_ defines #include "nsICSSLoader.h" #include "nsICSSStyleSheet.h" diff --git a/mozilla/editor/libeditor/text/nsTextEditRulesBidi.cpp b/mozilla/editor/libeditor/text/nsTextEditRulesBidi.cpp index 2cf588301f9..a5da9d133de 100644 --- a/mozilla/editor/libeditor/text/nsTextEditRulesBidi.cpp +++ b/mozilla/editor/libeditor/text/nsTextEditRulesBidi.cpp @@ -43,7 +43,7 @@ #include "nsPresContext.h" #include "nsIFrame.h" #include "nsISelectionPrivate.h" -#include "nsIFrameSelection.h" +#include "nsFrameSelection.h" // Test for distance between caret and text that will be deleted nsresult @@ -73,9 +73,7 @@ nsTextEditRules::CheckBidiLevelForDeletion(nsISelection *aSelection, nsCOMPtr content = do_QueryInterface(aSelNode); if (!content) return NS_ERROR_NULL_POINTER; - - nsIFrame *frameBefore; - nsIFrame *frameAfter; + PRUint8 levelBefore; PRUint8 levelAfter; @@ -83,13 +81,16 @@ nsTextEditRules::CheckBidiLevelForDeletion(nsISelection *aSelection, if (!privateSelection) return NS_ERROR_NULL_POINTER; - nsCOMPtr frameSelection; + nsCOMPtr frameSelection; privateSelection->GetFrameSelection(getter_AddRefs(frameSelection)); if (!frameSelection) return NS_ERROR_NULL_POINTER; - frameSelection->GetPrevNextBidiLevels(context, content, aSelOffset, PR_TRUE, - &frameBefore, &frameAfter, &levelBefore, &levelAfter); + nsPrevNextBidiLevels levels = frameSelection-> + GetPrevNextBidiLevels(content, aSelOffset, PR_TRUE); + + levelBefore = levels.mLevelBefore; + levelAfter = levels.mLevelAfter; PRUint8 currentCursorLevel; res = shell->GetCaretBidiLevel(¤tCursorLevel); diff --git a/mozilla/layout/base/Makefile.in b/mozilla/layout/base/Makefile.in index 9f867a07dd1..5d74699a1f7 100644 --- a/mozilla/layout/base/Makefile.in +++ b/mozilla/layout/base/Makefile.in @@ -103,7 +103,6 @@ EXPORTS = \ nsFrameTraversal.h \ nsICaret.h \ nsIDocumentViewer.h \ - nsIFrameSelection.h \ nsIFrameTraversal.h \ nsIImageMap.h \ nsILayoutDebugger.h \ diff --git a/mozilla/layout/base/nsCaret.cpp b/mozilla/layout/base/nsCaret.cpp index ec32ec3b391..ae835173fed 100644 --- a/mozilla/layout/base/nsCaret.cpp +++ b/mozilla/layout/base/nsCaret.cpp @@ -46,7 +46,7 @@ #include "nsIComponentManager.h" #include "nsIServiceManager.h" -#include "nsIFrameSelection.h" +#include "nsFrameSelection.h" #include "nsIFrame.h" #include "nsIDOMNode.h" #include "nsIDOMRange.h" @@ -90,7 +90,7 @@ nsCaret::nsCaret() , mReadOnly(PR_FALSE) , mShowDuringSelection(PR_FALSE) , mLastContentOffset(0) -, mLastHint(nsIFrameSelection::HINTLEFT) +, mLastHint(nsFrameSelection::HINTLEFT) #ifdef IBMBIDI , mLastBidiLevel(0) , mKeyboardRTL(PR_FALSE) @@ -315,21 +315,16 @@ NS_IMETHODIMP nsCaret::GetCaretCoordinates(EViewCoordinates aRelativeToType, nsIFrame* theFrame = nsnull; PRInt32 theFrameOffset = 0; - nsCOMPtr frameSelection; + nsCOMPtr frameSelection; privateSelection->GetFrameSelection(getter_AddRefs(frameSelection)); - nsIFrameSelection::HINT hint; - frameSelection->GetHint(&hint); - PRUint8 bidiLevel; nsCOMPtr presShell = do_QueryReferent(mPresShell); presShell->GetCaretBidiLevel(&bidiLevel); - err = GetCaretFrameForNodeOffset(contentNode, - focusOffset, hint, - bidiLevel, - &theFrame, - &theFrameOffset); + err = GetCaretFrameForNodeOffset(contentNode, focusOffset, + frameSelection->GetHint(), bidiLevel, + &theFrame, &theFrameOffset); if (NS_FAILED(err) || !theFrame) return err; @@ -417,7 +412,7 @@ NS_IMETHODIMP nsCaret::DrawAtPosition(nsIDOMNode* aNode, PRInt32 aOffset) presShell->GetCaretBidiLevel(&bidiLevel); // XXX we need to do more work here to get the correct hint. - nsresult rv = DrawAtPositionWithHint(aNode, aOffset, nsIFrameSelection::HINTLEFT, bidiLevel) ? + nsresult rv = DrawAtPositionWithHint(aNode, aOffset, nsFrameSelection::HINTLEFT, bidiLevel) ? NS_OK : NS_ERROR_FAILURE; ToggleDrawnStatus(); return rv; @@ -566,7 +561,7 @@ nsresult nsCaret::StopBlinking() PRBool nsCaret::DrawAtPositionWithHint(nsIDOMNode* aNode, PRInt32 aOffset, - nsIFrameSelection::HINT aFrameHint, + nsFrameSelection::HINT aFrameHint, PRUint8 aBidiLevel) { nsCOMPtr contentNode = do_QueryInterface(aNode); @@ -619,7 +614,7 @@ nsCaret::DrawAtPositionWithHint(nsIDOMNode* aNode, NS_IMETHODIMP nsCaret::GetCaretFrameForNodeOffset(nsIContent* aContentNode, PRInt32 aOffset, - nsIFrameSelection::HINT aFrameHint, + nsFrameSelection::HINT aFrameHint, PRUint8 aBidiLevel, nsIFrame** aReturnFrame, PRInt32* aReturnOffset) @@ -634,16 +629,15 @@ nsCaret::GetCaretFrameForNodeOffset(nsIContent* aContentNode, if (!privateSelection) return NS_ERROR_FAILURE; - nsCOMPtr frameSelection; + nsCOMPtr frameSelection; privateSelection->GetFrameSelection(getter_AddRefs(frameSelection)); nsIFrame* theFrame = nsnull; PRInt32 theFrameOffset = 0; - nsresult rv = frameSelection->GetFrameForNodeOffset(aContentNode, aOffset, - aFrameHint, &theFrame, - &theFrameOffset); - if (NS_FAILED(rv) || !theFrame) + theFrame = frameSelection->GetFrameForNodeOffset(aContentNode, aOffset, + aFrameHint, &theFrameOffset); + if (!theFrame) return NS_ERROR_FAILURE; // Mamdouh : modification of the caret to work at rtl and ltr with Bidi @@ -671,11 +665,17 @@ nsCaret::GetCaretFrameForNodeOffset(nsIContent* aContentNode, theFrame->GetOffsets(start, end); if (start == 0 || end == 0 || start == theFrameOffset || end == theFrameOffset) { + nsPrevNextBidiLevels levels = frameSelection-> + GetPrevNextBidiLevels(aContentNode, aOffset, PR_FALSE); + /* Boundary condition, we need to know the Bidi levels of the characters before and after the caret */ - if (NS_SUCCEEDED(frameSelection->GetPrevNextBidiLevels(presContext, aContentNode, aOffset, PR_FALSE, - &frameBefore, &frameAfter, - &levelBefore, &levelAfter))) + if (levels.mFrameBefore || levels.mFrameAfter) { + frameBefore = levels.mFrameBefore; + frameAfter = levels.mFrameAfter; + levelBefore = levels.mLevelBefore; + levelAfter = levels.mLevelAfter; + if ((levelBefore != levelAfter) || (aBidiLevel != levelBefore)) { aBidiLevel = PR_MAX(aBidiLevel, PR_MIN(levelBefore, levelAfter)); // rule c3 @@ -702,7 +702,7 @@ nsCaret::GetCaretFrameForNodeOffset(nsIContent* aContentNode, PRUint8 baseLevel = NS_GET_BASE_LEVEL(frameAfter); if (baseLevel != levelAfter) { - if (NS_SUCCEEDED(frameSelection->GetFrameFromLevel(presContext, frameAfter, eDirNext, baseLevel, &theFrame))) + if (NS_SUCCEEDED(frameSelection->GetFrameFromLevel(frameAfter, eDirNext, baseLevel, &theFrame))) { theFrame->GetOffsets(start, end); levelAfter = NS_GET_EMBEDDING_LEVEL(theFrame); @@ -740,7 +740,7 @@ nsCaret::GetCaretFrameForNodeOffset(nsIContent* aContentNode, PRUint8 baseLevel = NS_GET_BASE_LEVEL(frameBefore); if (baseLevel != levelBefore) { - if (NS_SUCCEEDED(frameSelection->GetFrameFromLevel(presContext, frameBefore, eDirPrevious, baseLevel, &theFrame))) + if (NS_SUCCEEDED(frameSelection->GetFrameFromLevel(frameBefore, eDirPrevious, baseLevel, &theFrame))) { theFrame->GetOffsets(start, end); levelBefore = NS_GET_EMBEDDING_LEVEL(theFrame); @@ -757,7 +757,7 @@ nsCaret::GetCaretFrameForNodeOffset(nsIContent* aContentNode, && !((levelBefore ^ levelAfter) & 1) // before and after have the same parity && ((aBidiLevel ^ levelAfter) & 1)) // caret has different parity { - if (NS_SUCCEEDED(frameSelection->GetFrameFromLevel(presContext, frameAfter, eDirNext, aBidiLevel, &theFrame))) + if (NS_SUCCEEDED(frameSelection->GetFrameFromLevel(frameAfter, eDirNext, aBidiLevel, &theFrame))) { theFrame->GetOffsets(start, end); levelAfter = NS_GET_EMBEDDING_LEVEL(theFrame); @@ -771,7 +771,7 @@ nsCaret::GetCaretFrameForNodeOffset(nsIContent* aContentNode, && !((levelBefore ^ levelAfter) & 1) // before and after have the same parity && ((aBidiLevel ^ levelAfter) & 1)) // caret has different parity { - if (NS_SUCCEEDED(frameSelection->GetFrameFromLevel(presContext, frameBefore, eDirPrevious, aBidiLevel, &theFrame))) + if (NS_SUCCEEDED(frameSelection->GetFrameFromLevel(frameBefore, eDirPrevious, aBidiLevel, &theFrame))) { theFrame->GetOffsets(start, end); levelBefore = NS_GET_EMBEDDING_LEVEL(theFrame); @@ -928,7 +928,7 @@ void nsCaret::DrawCaret() nsCOMPtr node; PRInt32 offset; - nsIFrameSelection::HINT hint; + nsFrameSelection::HINT hint; PRUint8 bidiLevel; if (!mDrawn) @@ -944,7 +944,7 @@ void nsCaret::DrawCaret() PRBool hintRight; privateSelection->GetInterlinePosition(&hintRight);//translate hint. - hint = hintRight ? nsIFrameSelection::HINTRIGHT : nsIFrameSelection::HINTLEFT; + hint = hintRight ? nsFrameSelection::HINTRIGHT : nsFrameSelection::HINTLEFT; // get the node and offset, which is where we want the caret to draw domSelection->GetFocusNode(getter_AddRefs(node)); diff --git a/mozilla/layout/base/nsCaret.h b/mozilla/layout/base/nsCaret.h index d7cf641b19a..73327cb71ca 100644 --- a/mozilla/layout/base/nsCaret.h +++ b/mozilla/layout/base/nsCaret.h @@ -116,7 +116,7 @@ class nsCaret : public nsICaret, NS_IMETHOD GetCaretFrameForNodeOffset(nsIContent* aContentNode, PRInt32 aOffset, - nsIFrameSelection::HINT aFrameHint, + nsFrameSelection::HINT aFrameHint, PRUint8 aBidiLevel, nsIFrame** aReturnFrame, PRInt32* aReturnOffset); @@ -135,7 +135,7 @@ class nsCaret : public nsICaret, nsIView **outRelativeView); PRBool DrawAtPositionWithHint(nsIDOMNode* aNode, PRInt32 aOffset, - nsIFrameSelection::HINT aFrameHint, + nsFrameSelection::HINT aFrameHint, PRUint8 aBidiLevel); PRBool MustDrawCaret(); void DrawCaret(); @@ -180,7 +180,7 @@ protected: // actually drawn (anon
in text control) PRInt32 mLastContentOffset; // the offset for the last request - nsIFrameSelection::HINT mLastHint; // the hint associated with the last request, see also + nsFrameSelection::HINT mLastHint; // the hint associated with the last request, see also // mLastBidiLevel below #ifdef IBMBIDI diff --git a/mozilla/layout/base/nsICaret.h b/mozilla/layout/base/nsICaret.h index 7878abc4d82..a5a8243ecdf 100644 --- a/mozilla/layout/base/nsICaret.h +++ b/mozilla/layout/base/nsICaret.h @@ -44,7 +44,7 @@ #include "nsISupports.h" #include "nsCOMPtr.h" #include "nsCoord.h" -#include "nsIFrameSelection.h" +#include "nsFrameSelection.h" struct nsRect; struct nsPoint; @@ -134,7 +134,7 @@ public: **/ NS_IMETHOD GetCaretFrameForNodeOffset(nsIContent* aContentNode, PRInt32 aOffset, - nsIFrameSelection::HINT aFrameHint, + nsFrameSelection::HINT aFrameHint, PRUint8 aBidiLevel, nsIFrame** aReturnFrame, PRInt32* aReturnOffset) = 0; diff --git a/mozilla/layout/base/nsIFrameSelection.h b/mozilla/layout/base/nsIFrameSelection.h index 4000e3d155d..e69de29bb2d 100644 --- a/mozilla/layout/base/nsIFrameSelection.h +++ b/mozilla/layout/base/nsIFrameSelection.h @@ -1,462 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is mozilla.org code. - * - * The Initial Developer of the Original Code is - * Netscape Communications Corporation. - * Portions created by the Initial Developer are Copyright (C) 1998 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * - * 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"), - * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the MPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the MPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -/* - * !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! - * NOTE!! This is not a general class, but specific to layout and frames. - * Consumers looking for the general selection interface should look at - * nsISelection. - */ - -#ifndef nsIFrameSelection_h___ -#define nsIFrameSelection_h___ - -#include "nsISupports.h" -#include "nsIFrame.h" -#include "nsISelection.h" -#include "nsIContent.h" -#include "nsCOMPtr.h" -#include "nsISelectionController.h" - -class nsIPresShell; - -// IID for the nsIFrameSelection interface -// cdfa6280-eba6-4938-9406-427818da8ce3 -#define NS_IFRAMESELECTION_IID \ -{ 0xcdfa6280, 0xeba6, 0x4938, \ - { 0x94, 0x06, 0x42, 0x78, 0x18, 0xda, 0x8c, 0xe3 } } - -//---------------------------------------------------------------------- - -// Selection interface - -struct SelectionDetails -{ - PRInt32 mStart; - PRInt32 mEnd; - SelectionType mType; - SelectionDetails *mNext; -}; - -/*PeekOffsetStruct - * @param mShell is used to get the PresContext useful for measuring text etc. - * @param mDesiredX is the "desired" location of the new caret - * @param mAmount eWord, eCharacter, eLine - * @param mDirection enum defined in this file to be eForward or eBackward - * @param mStartOffset start offset to start the peek. 0 == beginning -1 = end - * @param mResultContent content that actually is the next/previous - * @param mResultOffset offset for result content - * @param mResultFrame resulting frame for peeking - * @param mEatingWS boolean to tell us the state of our search for Next/Prev - * @param mPreferLeft true = prev line end, false = next line begin - * @param mJumpLines if this is true then it's ok to cross lines while peeking - * @param mScrollViewStop if this is true then stop peeking across scroll view boundary -*/ -struct nsPeekOffsetStruct -{ - void SetData(nsIPresShell *aShell, - nscoord aDesiredX, - nsSelectionAmount aAmount, - nsDirection aDirection, - PRInt32 aStartOffset, - PRBool aEatingWS, - PRBool aPreferLeft, - PRBool aJumpLines, - PRBool aScrollViewStop, - PRBool aIsKeyboardSelect, - PRBool aVisual) - { - mShell=aShell; - mDesiredX=aDesiredX; - mAmount=aAmount; - mDirection=aDirection; - mStartOffset=aStartOffset; - mEatingWS=aEatingWS; - mPreferLeft=aPreferLeft; - mJumpLines = aJumpLines; - mScrollViewStop = aScrollViewStop; - mIsKeyboardSelect = aIsKeyboardSelect; - mVisual = aVisual; - } - nsIPresShell *mShell; - nscoord mDesiredX; - nsSelectionAmount mAmount; - nsDirection mDirection; - PRInt32 mStartOffset; - nsCOMPtr mResultContent; - PRInt32 mContentOffset; - PRInt32 mContentOffsetEnd; - nsIFrame *mResultFrame; - PRBool mEatingWS; - PRBool mPreferLeft; - PRBool mJumpLines; - PRBool mScrollViewStop; - PRBool mIsKeyboardSelect; - PRBool mVisual; -}; - -class nsIScrollableView; - - -class nsIFrameSelection : public nsISupports { -public: - NS_DECLARE_STATIC_IID_ACCESSOR(NS_IFRAMESELECTION_IID) - enum HINT { HINTLEFT = 0, HINTRIGHT = 1}; //end of this line or beginning of next - - /** Init will initialize the frame selector with the necessary pres shell to - * be used by most of the methods - * @param aShell is the parameter to be used for most of the other calls for callbacks etc - * @param aLimiter limits the selection to nodes with aLimiter parents - */ - NS_IMETHOD Init(nsIPresShell *aShell, nsIContent *aLimiter) = 0; //default since this isn't used for embedding - - /* SetScrollableView sets the scroll view - * @param aScrollView is the scroll view for this selection. - */ - NS_IMETHOD SetScrollableView(nsIScrollableView *aScrollView) =0; - - /* GetScrollableView gets the current scroll view - * @param aScrollView is the scroll view for this selection. - */ - NS_IMETHOD GetScrollableView(nsIScrollableView **aScrollView) =0; - - /** ShutDown will be called when the owner of the frame selection is shutting down - * this should be the time to release all member variable interfaces. all methods - * called after ShutDown should return NS_ERROR_FAILURE - */ - NS_IMETHOD ShutDown() = 0; - - /** HandleKeyEvent will accept an event. - *

DOES NOT ADDREF

- * @param aGuiEvent is the event that should be dealt with by aFocusFrame - * @param aFrame is the frame that MAY handle the event - */ - NS_IMETHOD HandleTextEvent(nsGUIEvent *aGuiEvent) = 0; - - /** HandleKeyEvent will accept an event and a PresContext. - *

DOES NOT ADDREF

- * @param aGuiEvent is the event that should be dealt with by aFocusFrame - * @param aFrame is the frame that MAY handle the event - */ - NS_IMETHOD HandleKeyEvent(nsPresContext* aPresContext, nsGUIEvent *aGuiEvent) = 0; - - /** HandleClick will take the focus to the new frame at the new offset and - * will either extend the selection from the old anchor, or replace the old anchor. - * the old anchor and focus position may also be used to deselect things - * @param aNewfocus is the content that wants the focus - * @param aContentOffset is the content offset of the parent aNewFocus - * @param aContentOffsetEnd is the content offset of the parent aNewFocus and is specified different - * when you need to select to and include both start and end points - * @param aContinueSelection is the flag that tells the selection to keep the old anchor point or not. - * @param aMultipleSelection will tell the frame selector to replace /or not the old selection. - * cannot coexist with aContinueSelection - * @param aHint will tell the selection which direction geometrically to actually show the caret on. - * 1 = end of this line 0 = beginning of this line - */ - NS_IMETHOD HandleClick(nsIContent *aNewFocus, PRUint32 aContentOffset, PRUint32 aContentEndOffset , - PRBool aContinueSelection, PRBool aMultipleSelection, PRBool aHint) = 0; - - /** 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. - * @param aFrame is the parent of all frames to use when searching for the closest frame to the point. - * @param aPoint is relative to aFrame - */ - NS_IMETHOD HandleDrag(nsPresContext *aPresContext, nsIFrame *aFrame, nsPoint& aPoint) = 0; - - /** HandleTableSelection will set selection to a table, cell, etc - * depending on information contained in aFlags - * @param aParentContent is the paretent of either a table or cell that user clicked or dragged the mouse in - * @param aContentOffset is the offset of the table or cell - * @param aTarget indicates what to select (defined in nsISelectionPrivate.idl/nsISelectionPrivate.h): - * TABLESELECTION_CELL We should select a cell (content points to the cell) - * TABLESELECTION_ROW We should select a row (content points to any cell in row) - * TABLESELECTION_COLUMN We should select a row (content points to any cell in column) - * TABLESELECTION_TABLE We should select a table (content points to the table) - * TABLESELECTION_ALLCELLS We should select all cells (content points to any cell in table) - * @param aMouseEvent passed in so we can get where event occurred and what keys are pressed - */ - NS_IMETHOD HandleTableSelection(nsIContent *aParentContent, PRInt32 aContentOffset, PRInt32 aTarget, nsMouseEvent *aMouseEvent) = 0; - - /** StartAutoScrollTimer is responsible for scrolling views so that aPoint is always - * visible, and for selecting any frame that contains aPoint. The timer will also reset - * itself to fire again if we have not scrolled to the end of the document. - * @param aPresContext is the context to use when figuring out what frame contains the point. - * @param aView is view to use when searching for the closest frame to the point, - * which is the view that is capturing the mouse - * @param aPoint is relative to the view. - * @param aDelay is the timer's interval. - */ - NS_IMETHOD StartAutoScrollTimer(nsPresContext *aPresContext, nsIView* aFrame, nsPoint& aPoint, PRUint32 aDelay) = 0; - - /** StopAutoScrollTimer stops any active auto scroll timer. - */ - NS_IMETHOD StopAutoScrollTimer() = 0; - - /** EnableFrameNotification - * mutch like start batching, except all dirty calls are ignored. no notifications will go - * out until enableNotifications with a PR_TRUE is called - */ - NS_IMETHOD EnableFrameNotification(PRBool aEnable) = 0; - - /** Lookup Selection - * returns in frame coordinates the selection beginning and ending with the type of selection given - * @param aContent is the content asking - * @param aContentOffset is the starting content boundary - * @param aContentLength is the length of the content piece asking - * @param aReturnDetails linkedlist of return values for the selection. - * @param aSlowCheck will check using slow method with no shortcuts - */ - NS_IMETHOD LookUpSelection(nsIContent *aContent, PRInt32 aContentOffset, PRInt32 aContentLength, - SelectionDetails **aReturnDetails, PRBool aSlowCheck) = 0; - - /** SetMouseDownState(PRBool); - * sets the mouse state to aState for resons of drag state. - * @param aState is the new state of mousedown - */ - NS_IMETHOD SetMouseDownState(PRBool aState)=0; - - /** GetMouseDownState(PRBool *); - * gets the mouse state to aState for resons of drag state. - * @param aState will hold the state of mousedown - */ - NS_IMETHOD GetMouseDownState(PRBool *aState)=0; - - /** - if we are in table cell selection mode. aka ctrl click in table cell - */ - NS_IMETHOD GetTableCellSelection(PRBool *aState)=0; - - /** GetSelection - * no query interface for selection. must use this method now. - * @param aSelectionType enum value defined in nsISelection for the seleciton you want. - */ - NS_IMETHOD GetSelection(SelectionType aSelectionType, nsISelection **aSelection)=0; - - /** - * ScrollSelectionIntoView scrolls a region of the selection, - * so that it is visible in the scrolled view. - * - * @param aType the selection to scroll into view. - * @param aRegion the region inside the selection to scroll into view. - * @param aIsSynchronous when PR_TRUE, scrolls the selection into view - * at some point after the method returns.request which is processed - */ - NS_IMETHOD ScrollSelectionIntoView(SelectionType aSelectionType, SelectionRegion aRegion, PRBool aIsSynchronous)=0; - - /** RepaintSelection repaints the selected frames that are inside the selection - * specified by aSelectionType. - * @param aSelectionType enum value defined in nsISelection for the seleciton you want. - */ - NS_IMETHOD RepaintSelection(nsPresContext* aPresContext, SelectionType aSelectionType)=0; - - /** GetFrameForNodeOffset given a node and its child offset, return the nsIFrame and - * the offset into that frame. - * @param aNode input parameter for the node to look at - * @param aOffset offset into above node. - * @param aReturnFrame will contain the return frame. MUST NOT BE NULL or will return error - * @param aReturnOffset will contain offset into frame. - */ - NS_IMETHOD GetFrameForNodeOffset(nsIContent *aNode, PRInt32 aOffset, HINT aHint, nsIFrame **aReturnFrame, PRInt32 *aReturnOffset)=0; - - NS_IMETHOD GetHint(HINT *aHint)=0; - NS_IMETHOD SetHint(HINT aHint)=0; - - /** CharacterMove will generally be called from the nsiselectioncontroller implementations. - * the effect being the selection will move one character left or right. - * @param aForward move forward in document. - * @param aExtend continue selection - */ - NS_IMETHOD CharacterMove(PRBool aForward, PRBool aExtend)=0; - - /** WordMove will generally be called from the nsiselectioncontroller implementations. - * the effect being the selection will move one word left or right. - * @param aForward move forward in document. - * @param aExtend continue selection - */ - NS_IMETHOD WordMove(PRBool aForward, PRBool aExtend)=0; - - /** LineMove will generally be called from the nsiselectioncontroller implementations. - * the effect being the selection will move one line up or down. - * @param aForward move forward in document. - * @param aExtend continue selection - */ - NS_IMETHOD LineMove(PRBool aForward, PRBool aExtend)=0; - - /** IntraLineMove will generally be called from the nsiselectioncontroller implementations. - * the effect being the selection will move to beginning or end of line - * @param aForward move forward in document. - * @param aExtend continue selection - */ - NS_IMETHOD IntraLineMove(PRBool aForward, PRBool aExtend)=0; - - /** - * Scrolling then moving caret placement code in common to text areas and - * content areas should be located in the implementer - * This method will accept the following parameters and perform the scroll - * and caret movement. It remains for the caller to call the final - * ScrollCaretIntoView if that called wants to be sure the caret is always - * visible. - * - * @param aForward if PR_TRUE, scroll forward if not scroll backward - * - * @param aExtend if PR_TRUE, extend selection to the new point - * - * @param aScrollableView the view that needs the scrolling - * - * @param aFrameSel the nsIFrameSelection of the caller. - * - * @return always NS_OK - */ - NS_IMETHOD CommonPageMove(PRBool aForward, - PRBool aExtend, - nsIScrollableView *aScrollableView, - nsIFrameSelection *aFrameSel)=0; - - /** Select All will generally be called from the nsiselectioncontroller implementations. - * it will select the whole doc - */ - NS_IMETHOD SelectAll()=0; - - /** Sets/Gets The display selection enum. - */ - NS_IMETHOD SetDisplaySelection(PRInt16 aState)=0; - NS_IMETHOD GetDisplaySelection(PRInt16 *aState)=0; - - /** Allow applications to specify how we should place the caret - * when the user clicks over an existing selection. A aDelay - * value of PR_TRUE means delay clearing the selection and - * placing the caret until MouseUp, when the user clicks over - * an existing selection. This is especially useful when applications - * want to support Drag & Drop of the current selection. A value - * of PR_FALSE means place the caret immediately. If the application - * never calls this method, the nsIFrameSelection implementation - * assumes the default value is PR_TRUE. - * @param aDelay PR_TRUE if we should delay caret placement. - */ - NS_IMETHOD SetDelayCaretOverExistingSelection(PRBool aDelay)=0; - - /** Get the current delay caret setting. If aDelay contains - * a return value of PR_TRUE, the caret is placed on MouseUp - * when clicking over an existing selection. If PR_FALSE, - * the selection is cleared and caret is placed immediately - * in all cases. - * @param aDelay will contain the return value. - */ - NS_IMETHOD GetDelayCaretOverExistingSelection(PRBool *aDelay)=0; - - /** If we are delaying caret placement til MouseUp (see - * Set/GetDelayCaretOverExistingSelection()), this method - * can be used to store the data received during the MouseDown - * so that we can place the caret during the MouseUp event. - * @aMouseEvent the event received by the selection MouseDown - * handling method. A NULL value can be use to tell this method - * that any data is storing is no longer valid. - */ - NS_IMETHOD SetDelayedCaretData(nsMouseEvent *aMouseEvent)=0; - - /** Get the delayed MouseDown event data necessary to place the - * caret during MouseUp processing. - * @aMouseEvent will contain a pointer to the event received - * by the selection during MouseDown processing. It can be NULL - * if the data is no longer valid. - */ - NS_IMETHOD GetDelayedCaretData(nsMouseEvent **aMouseEvent)=0; - - - /** Get the content node that limits the selection - * When searching up a nodes for parents, as in a text edit field - * in an browser page, we must stop at this node else we reach into the - * parent page, which is very bad! - */ - NS_IMETHOD GetLimiter(nsIContent **aLimiterContent)=0; - - /** This will tell the frame selection that a double click has been pressed - * so it can track abort future drags if inside the same selection - * @aDoubleDown has the double click down happened - */ - NS_IMETHOD SetMouseDoubleDown(PRBool aDoubleDown)=0; - - /** This will return whether the double down flag was set. - * @aDoubleDown is the return boolean value - */ - NS_IMETHOD GetMouseDoubleDown(PRBool *aDoubleDown)=0; - - /** - * MaintainSelection will track the current selection as being "sticky". - * Dragging or extending selection will never allow for a subset - * (or the whole) of the maintained selection to become unselected. - * Primary use: double click selecting then dragging on second click - */ - NS_IMETHOD MaintainSelection()=0; - -#ifdef IBMBIDI - /** GetPrevNextBidiLevels will return the frames and associated Bidi levels of the characters - * logically before and after a (collapsed) selection. - * @param aPresContext is the context to use - * @param aNode is the node containing the selection - * @param aContentOffset is the offset of the selection in the node - * @param aJumpLines If PR_TRUE, look across line boundaries. - * If PR_FALSE, behave as if there were base-level frames at line edges. - * @param aPrevFrame will hold the frame of the character before the selection - * @param aNextFrame will hold the frame of the character after the selection - * @param aPrevLevel will hold the Bidi level of the character before the selection - * @param aNextLevel will hold the Bidi level of the character after the selection - * - * At the beginning and end of each line there is assumed to be a frame with Bidi level equal to the - * paragraph embedding level. In these cases aPrevFrame and aNextFrame respectively will return nsnull. - */ - NS_IMETHOD GetPrevNextBidiLevels(nsPresContext *aPresContext, nsIContent *aNode, PRUint32 aContentOffset, PRBool aJumpLines, - nsIFrame **aPrevFrame, nsIFrame **aNextFrame, PRUint8 *aPrevLevel, PRUint8 *aNextLevel)=0; - - /** GetFrameFromLevel will scan in a given direction - * until it finds a frame with a Bidi level less than or equal to a given level. - * It will return the last frame before this. - * @param aPresContext is the context to use - * @param aFrameIn is the frame to start from - * @param aDirection is the direction to scan - * @param aBidiLevel is the level to search for - * @param aFrameOut will hold the frame returned - */ - NS_IMETHOD GetFrameFromLevel(nsPresContext *aPresContext, nsIFrame *aFrameIn, nsDirection aDirection, PRUint8 aBidiLevel, - nsIFrame **aFrameOut)=0; - -#endif // IBMBIDI -}; - -NS_DEFINE_STATIC_IID_ACCESSOR(nsIFrameSelection, NS_IFRAMESELECTION_IID) - -#endif /* nsIFrameSelection_h___ */