Bug 987718 - Part 1: Add FirstAndLastRectCollector to nsLayoutUtils; r=roc

This commit is contained in:
Morris Tseng 2014-06-04 22:53:00 +02:00
parent 45fd37cea2
commit 3aa22d4895
2 changed files with 29 additions and 0 deletions

View File

@ -3231,6 +3231,20 @@ void nsLayoutUtils::RectListBuilder::AddRect(const nsRect& aRect) {
mRectList->Append(rect);
}
nsLayoutUtils::FirstAndLastRectCollector::FirstAndLastRectCollector()
: mSeenFirstRect(false)
{
}
void nsLayoutUtils::FirstAndLastRectCollector::AddRect(const nsRect& aRect) {
if (!mSeenFirstRect) {
mSeenFirstRect = true;
mFirstRect = aRect;
}
mLastRect = aRect;
}
nsIFrame* nsLayoutUtils::GetContainingBlockForClientRect(nsIFrame* aFrame)
{
return aFrame->PresContext()->PresShell()->GetRootFrame();

View File

@ -1009,6 +1009,21 @@ public:
virtual void AddRect(const nsRect& aRect);
};
/**
* SelectionCaret draws carets base on range. The carets are at begin
* and end position of range's client rects. This class help us to
* collect first and last rect for drawing carets.
*/
struct FirstAndLastRectCollector : public RectCallback {
nsRect mFirstRect;
nsRect mLastRect;
bool mSeenFirstRect;
FirstAndLastRectCollector();
virtual void AddRect(const nsRect& aRect);
};
static nsIFrame* GetContainingBlockForClientRect(nsIFrame* aFrame);
enum {