2001-09-28 20:14:13 +00:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
2012-05-21 11:12:37 +00:00
|
|
|
/* 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/. */
|
1999-05-13 00:54:03 +00:00
|
|
|
#ifndef nsILineIterator_h___
|
|
|
|
#define nsILineIterator_h___
|
|
|
|
|
2008-10-30 19:17:59 +00:00
|
|
|
#include "nscore.h"
|
|
|
|
#include "nsCoord.h"
|
2014-09-01 03:36:37 +00:00
|
|
|
#include "mozilla/Attributes.h"
|
2008-10-30 19:17:59 +00:00
|
|
|
|
|
|
|
class nsIFrame;
|
|
|
|
struct nsRect;
|
1999-05-13 00:54:03 +00:00
|
|
|
|
1999-10-12 23:26:41 +00: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 19:17:59 +00: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 00:54:03 +00:00
|
|
|
public:
|
2008-10-30 19:17:59 +00:00
|
|
|
virtual void DisposeLineIterator() = 0;
|
1999-05-13 00:54:03 +00:00
|
|
|
|
2008-10-30 19:17:59 +00:00
|
|
|
/**
|
|
|
|
* The number of lines in the block
|
|
|
|
*/
|
2012-08-22 15:56:38 +00:00
|
|
|
virtual int32_t GetNumLines() = 0;
|
1999-05-13 00:54:03 +00:00
|
|
|
|
2008-10-30 19:17:59 +00:00
|
|
|
/**
|
|
|
|
* The prevailing direction of lines.
|
|
|
|
*
|
2011-10-17 14:59:28 +00:00
|
|
|
* @return true if the CSS direction property for the block is
|
|
|
|
* "rtl", otherwise false
|
2008-10-30 19:17:59 +00:00
|
|
|
*/
|
2011-09-29 06:19:26 +00:00
|
|
|
virtual bool GetDirection() = 0;
|
1999-05-13 00:54:03 +00: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
|
2012-07-30 14:20:58 +00:00
|
|
|
// aFirstFrameOnLine will be nullptr and aNumFramesOnLine will be
|
1999-10-12 23:26:41 +00: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.
|
2012-08-22 15:56:38 +00:00
|
|
|
NS_IMETHOD GetLine(int32_t aLineNumber,
|
1999-05-13 00:54:03 +00:00
|
|
|
nsIFrame** aFirstFrameOnLine,
|
2012-08-22 15:56:38 +00:00
|
|
|
int32_t* aNumFramesOnLine,
|
1999-10-12 23:26:41 +00:00
|
|
|
nsRect& aLineBounds,
|
2012-08-22 15:56:38 +00:00
|
|
|
uint32_t* aLineFlags) = 0;
|
1999-05-13 00:54:03 +00:00
|
|
|
|
2008-10-30 19:17:59 +00:00
|
|
|
/**
|
|
|
|
* Given a frame that's a child of the block, find which line its on
|
2011-09-07 02:57:46 +00:00
|
|
|
* and return that line index, as long as it's at least as big as
|
|
|
|
* aStartLine. Returns -1 if the frame cannot be found on lines
|
|
|
|
* starting with aStartLine.
|
2008-10-30 19:17:59 +00:00
|
|
|
*/
|
2012-08-22 15:56:38 +00:00
|
|
|
virtual int32_t FindLineContaining(nsIFrame* aFrame,
|
|
|
|
int32_t aStartLine = 0) = 0;
|
2008-10-30 19:17:59 +00:00
|
|
|
|
1999-05-13 00:54:03 +00: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.
|
2012-08-22 15:56:38 +00:00
|
|
|
NS_IMETHOD FindFrameAt(int32_t aLineNumber,
|
1999-05-13 00:54:03 +00:00
|
|
|
nscoord aX,
|
|
|
|
nsIFrame** aFrameFound,
|
2011-09-29 06:19:26 +00:00
|
|
|
bool* aXIsBeforeFirstFrame,
|
|
|
|
bool* aXIsAfterLastFrame) = 0;
|
2000-05-11 01:04:39 +00:00
|
|
|
|
|
|
|
// Give the line iterator implementor a chance todo something more complicated than
|
|
|
|
// nsIFrame::GetNextSibling()
|
2012-08-22 15:56:38 +00:00
|
|
|
NS_IMETHOD GetNextSiblingOnLine(nsIFrame*& aFrame, int32_t aLineNumber) = 0;
|
2001-03-21 01:16:22 +00:00
|
|
|
|
|
|
|
// Check whether visual and logical order of frames within a line are identical.
|
|
|
|
// If not, return the first and last visual frames
|
2012-08-22 15:56:38 +00:00
|
|
|
NS_IMETHOD CheckLineOrder(int32_t aLine,
|
2011-09-29 06:19:26 +00:00
|
|
|
bool *aIsReordered,
|
2001-03-21 01:16:22 +00:00
|
|
|
nsIFrame **aFirstVisual,
|
|
|
|
nsIFrame **aLastVisual) = 0;
|
1999-05-13 00:54:03 +00:00
|
|
|
};
|
|
|
|
|
2008-10-30 19:17:59 +00:00
|
|
|
class nsAutoLineIterator
|
|
|
|
{
|
2008-10-28 06:49:14 +00:00
|
|
|
public:
|
2012-07-30 14:20:58 +00:00
|
|
|
nsAutoLineIterator() : mRawPtr(nullptr) { }
|
2014-09-01 03:36:37 +00:00
|
|
|
MOZ_IMPLICIT nsAutoLineIterator(nsILineIterator *i) : mRawPtr(i) { }
|
2005-11-11 14:36:26 +00:00
|
|
|
|
2008-10-30 19:17:59 +00: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 06:49:14 +00:00
|
|
|
|
1999-05-13 00:54:03 +00:00
|
|
|
#endif /* nsILineIterator_h___ */
|