2001-09-29 00:14:13 +04:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
|
|
/* ***** BEGIN LICENSE BLOCK *****
|
2004-04-18 18:30:37 +04:00
|
|
|
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
1999-05-13 04:54:03 +04:00
|
|
|
*
|
2004-04-18 18:30:37 +04:00
|
|
|
* 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/
|
1999-05-13 04:54:03 +04:00
|
|
|
*
|
2001-09-29 00:14:13 +04:00
|
|
|
* 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.
|
1999-05-13 04:54:03 +04:00
|
|
|
*
|
|
|
|
* The Original Code is Mozilla Communicator client code.
|
|
|
|
*
|
2004-04-18 18:30:37 +04:00
|
|
|
* The Initial Developer of the Original Code is
|
2001-09-29 00:14:13 +04:00
|
|
|
* Netscape Communications Corporation.
|
|
|
|
* Portions created by the Initial Developer are Copyright (C) 1998
|
|
|
|
* the Initial Developer. All Rights Reserved.
|
1999-11-06 06:40:37 +03:00
|
|
|
*
|
2001-09-29 00:14:13 +04:00
|
|
|
* Contributor(s):
|
|
|
|
*
|
|
|
|
* Alternatively, the contents of this file may be used under the terms of
|
2004-04-18 18:30:37 +04:00
|
|
|
* 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"),
|
2001-09-29 00:14:13 +04:00
|
|
|
* 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
|
2004-04-18 18:30:37 +04:00
|
|
|
* use your version of this file under the terms of the MPL, indicate your
|
2001-09-29 00:14:13 +04:00
|
|
|
* 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
|
2004-04-18 18:30:37 +04:00
|
|
|
* the terms of any one of the MPL, the GPL or the LGPL.
|
2001-09-29 00:14:13 +04:00
|
|
|
*
|
|
|
|
* ***** END LICENSE BLOCK ***** */
|
1999-05-13 04:54:03 +04:00
|
|
|
#ifndef nsILineIterator_h___
|
|
|
|
#define nsILineIterator_h___
|
|
|
|
|
2008-10-30 22:17:59 +03:00
|
|
|
#include "nscore.h"
|
|
|
|
#include "nsCoord.h"
|
|
|
|
|
|
|
|
class nsIFrame;
|
|
|
|
struct nsRect;
|
1999-05-13 04:54:03 +04:00
|
|
|
|
1999-10-13 03:26:41 +04:00
|
|
|
// Line Flags (see GetLine below)
|
|
|
|
|
|
|
|
// This bit is set when the line is wrapping up a block frame. When
|
|
|
|
// clear, it means that the line contains inline elements.
|
|
|
|
#define NS_LINE_FLAG_IS_BLOCK 0x1
|
|
|
|
|
|
|
|
// This bit is set when the line ends in some sort of break.
|
|
|
|
#define NS_LINE_FLAG_ENDS_IN_BREAK 0x4
|
|
|
|
|
2008-10-30 22:17:59 +03:00
|
|
|
/**
|
|
|
|
* Line iterator API.
|
|
|
|
*
|
|
|
|
* Lines are numbered from 0 to N, where 0 is the top line and N is
|
|
|
|
* the bottom line.
|
|
|
|
*
|
|
|
|
* Obtain this interface from frames via nsIFrame::GetLineIterator.
|
|
|
|
* When you are finished using the iterator, call DisposeLineIterator()
|
|
|
|
* to destroy the iterator if appropriate.
|
|
|
|
*/
|
|
|
|
class nsILineIterator
|
|
|
|
{
|
|
|
|
protected:
|
|
|
|
~nsILineIterator() { }
|
|
|
|
|
1999-05-13 04:54:03 +04:00
|
|
|
public:
|
2008-10-30 22:17:59 +03:00
|
|
|
virtual void DisposeLineIterator() = 0;
|
1999-05-13 04:54:03 +04:00
|
|
|
|
2008-10-30 22:17:59 +03:00
|
|
|
/**
|
|
|
|
* The number of lines in the block
|
|
|
|
*/
|
|
|
|
virtual PRInt32 GetNumLines() = 0;
|
1999-05-13 04:54:03 +04:00
|
|
|
|
2008-10-30 22:17:59 +03:00
|
|
|
/**
|
|
|
|
* The prevailing direction of lines.
|
|
|
|
*
|
|
|
|
* @return PR_TRUE if the CSS direction property for the block is
|
|
|
|
* "rtl", otherwise PR_FALSE
|
|
|
|
*/
|
|
|
|
virtual PRBool GetDirection() = 0;
|
1999-05-13 04:54:03 +04:00
|
|
|
|
|
|
|
// Return structural information about a line. aFirstFrameOnLine is
|
|
|
|
// the first frame on the line and aNumFramesOnLine is the number of
|
|
|
|
// frames that are on the line. If the line-number is invalid then
|
|
|
|
// aFirstFrameOnLine will be nsnull and aNumFramesOnLine will be
|
1999-10-13 03:26:41 +04:00
|
|
|
// zero.
|
|
|
|
//
|
|
|
|
// For valid line numbers, aLineBounds is set to the bounding box of
|
|
|
|
// the line (which is based on the in-flow position of the frames on
|
|
|
|
// the line; if a frame was moved because of relative positioning
|
|
|
|
// then its coordinates may be outside the line bounds).
|
|
|
|
//
|
|
|
|
// In addition, aLineFlags will contain flag information about the
|
|
|
|
// line.
|
1999-05-13 04:54:03 +04:00
|
|
|
NS_IMETHOD GetLine(PRInt32 aLineNumber,
|
|
|
|
nsIFrame** aFirstFrameOnLine,
|
|
|
|
PRInt32* aNumFramesOnLine,
|
1999-10-13 03:26:41 +04:00
|
|
|
nsRect& aLineBounds,
|
|
|
|
PRUint32* aLineFlags) = 0;
|
1999-05-13 04:54:03 +04:00
|
|
|
|
2008-10-30 22:17:59 +03:00
|
|
|
/**
|
|
|
|
* Given a frame that's a child of the block, find which line its on
|
|
|
|
* and return that line index. Returns -1 if the frame cannot be found.
|
|
|
|
*/
|
|
|
|
virtual PRInt32 FindLineContaining(nsIFrame* aFrame) = 0;
|
|
|
|
|
1999-05-13 04:54:03 +04:00
|
|
|
// Given a line number and an X coordinate, find the frame on the
|
|
|
|
// line that is nearest to the X coordinate. The
|
|
|
|
// aXIsBeforeFirstFrame and aXIsAfterLastFrame flags are updated
|
|
|
|
// appropriately.
|
|
|
|
NS_IMETHOD FindFrameAt(PRInt32 aLineNumber,
|
|
|
|
nscoord aX,
|
|
|
|
nsIFrame** aFrameFound,
|
|
|
|
PRBool* aXIsBeforeFirstFrame,
|
|
|
|
PRBool* aXIsAfterLastFrame) = 0;
|
2000-05-11 05:04:39 +04:00
|
|
|
|
|
|
|
// Give the line iterator implementor a chance todo something more complicated than
|
|
|
|
// nsIFrame::GetNextSibling()
|
2000-06-17 02:28:10 +04:00
|
|
|
NS_IMETHOD GetNextSiblingOnLine(nsIFrame*& aFrame, PRInt32 aLineNumber) = 0;
|
2001-03-21 04:16:22 +03:00
|
|
|
|
|
|
|
#ifdef IBMBIDI
|
|
|
|
// Check whether visual and logical order of frames within a line are identical.
|
|
|
|
// If not, return the first and last visual frames
|
|
|
|
NS_IMETHOD CheckLineOrder(PRInt32 aLine,
|
|
|
|
PRBool *aIsReordered,
|
|
|
|
nsIFrame **aFirstVisual,
|
|
|
|
nsIFrame **aLastVisual) = 0;
|
|
|
|
#endif
|
1999-05-13 04:54:03 +04:00
|
|
|
};
|
|
|
|
|
2008-10-30 22:17:59 +03:00
|
|
|
class nsAutoLineIterator
|
|
|
|
{
|
2008-10-28 09:49:14 +03:00
|
|
|
public:
|
2008-10-30 22:17:59 +03:00
|
|
|
nsAutoLineIterator() : mRawPtr(nsnull) { }
|
|
|
|
nsAutoLineIterator(nsILineIterator *i) : mRawPtr(i) { }
|
2005-11-11 17:36:26 +03:00
|
|
|
|
2008-10-30 22:17:59 +03:00
|
|
|
~nsAutoLineIterator() {
|
|
|
|
if (mRawPtr)
|
|
|
|
mRawPtr->DisposeLineIterator();
|
|
|
|
}
|
|
|
|
|
|
|
|
operator nsILineIterator*() { return mRawPtr; }
|
|
|
|
nsILineIterator* operator->() { return mRawPtr; }
|
|
|
|
|
|
|
|
nsILineIterator* operator=(nsILineIterator* i) {
|
|
|
|
if (i == mRawPtr)
|
|
|
|
return i;
|
|
|
|
|
|
|
|
if (mRawPtr)
|
|
|
|
mRawPtr->DisposeLineIterator();
|
|
|
|
|
|
|
|
mRawPtr = i;
|
|
|
|
return i;
|
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
|
|
|
nsILineIterator* mRawPtr;
|
|
|
|
};
|
2008-10-28 09:49:14 +03:00
|
|
|
|
1999-05-13 04:54:03 +04:00
|
|
|
#endif /* nsILineIterator_h___ */
|