|
From: CVS C. to T. <the...@li...> - 2012-02-23 22:39:48
|
Revision: 674
http://themis.svn.sourceforge.net/themis/?rev=674&view=rev
Author: mark_hellegers
Date: 2012-02-23 22:39:42 +0000 (Thu, 23 Feb 2012)
Log Message:
-----------
Moved rendering of the table row to its own Layout function.
Removed no longer needed variables.
Modified Paths:
--------------
trunk/themis/modules/CSSRenderer/BlockDisplayView.cpp
trunk/themis/modules/CSSRenderer/CSSView.cpp
trunk/themis/modules/CSSRenderer/CSSView.hpp
trunk/themis/modules/CSSRenderer/InlineDisplayView.cpp
trunk/themis/modules/CSSRenderer/NoneDisplayView.cpp
trunk/themis/modules/CSSRenderer/TableCellDisplayView.cpp
trunk/themis/modules/CSSRenderer/TableDisplayView.cpp
trunk/themis/modules/CSSRenderer/TableRowDisplayView.cpp
Modified: trunk/themis/modules/CSSRenderer/BlockDisplayView.cpp
===================================================================
--- trunk/themis/modules/CSSRenderer/BlockDisplayView.cpp 2012-02-22 23:40:32 UTC (rev 673)
+++ trunk/themis/modules/CSSRenderer/BlockDisplayView.cpp 2012-02-23 22:39:42 UTC (rev 674)
@@ -60,9 +60,6 @@
mDisplay = true;
mBlock = true;
- mTable = false;
- mTableRow = false;
- mTableCell = false;
}
Modified: trunk/themis/modules/CSSRenderer/CSSView.cpp
===================================================================
--- trunk/themis/modules/CSSRenderer/CSSView.cpp 2012-02-22 23:40:32 UTC (rev 673)
+++ trunk/themis/modules/CSSRenderer/CSSView.cpp 2012-02-23 22:39:42 UTC (rev 674)
@@ -663,90 +663,48 @@
unsigned int length = mChildren.size();
BPoint startingPoint = mEndPoint;
float maxRight = 0;
- if (!mTableRow) {
- for (unsigned int i = 0; i < length; i++) {
- CSSView * childView = mChildren[i];
- // Only layout those children that are actually displayed.
- if (childView->IsDisplayed()) {
- if (childView->IsBlock()) {
- // Blocks have their own rect, so start at the left of the parent rect and just below the previous block.
- startingPoint = BPoint(restRect.left, restRect.top);
- // previousChildIsBlock = true;
- // startingPoint.PrintToStream();
- }
- // Do the layout for the child.
- childView->Layout(restRect, startingPoint);
- BRect rect2 = childView->Bounds();
- mEndPoint = childView->GetEndPoint();
- // Set the top of the remaining rect to the bottom of the child,
- // because the space above is already taken by the child.
- restRect.top = rect2.bottom;
- if (rect2.right > restRect.right) {
- // The child used more space than was available. We can use that space now as well
- // for any remaining children.
- restRect.right = rect2.right;
- mRect.right = rect2.right;
- }
- // What is the maximum horizontal space being taken up by one of the children?
- if (rect2.right > maxRight) {
- maxRight = rect2.right;
- }
-
- if (childView->IsBlock()) {
- // The next child will have to start at the left of the parent rect and just below this block.
- startingPoint = BPoint(restRect.left, restRect.top);
- // previousChildIsBlock = true;
- // startingPoint.PrintToStream();
- }
- else {
- // We can start where we left off.
- startingPoint = mEndPoint;
- // previousChildIsBlock = false;
- // printf("Starting at: ");
- // mEndPoint.PrintToStream();
- }
+ for (unsigned int i = 0; i < length; i++) {
+ CSSView * childView = mChildren[i];
+ // Only layout those children that are actually displayed.
+ if (childView->IsDisplayed()) {
+ if (childView->IsBlock()) {
+ // Blocks have their own rect, so start at the left of the parent rect and just below the previous block.
+ startingPoint = BPoint(restRect.left, restRect.top);
+ // previousChildIsBlock = true;
+ // startingPoint.PrintToStream();
}
- }
- }
- else {
- BRect restRowRect = restRect;
- float maxBottom = restRowRect.top;
- for (unsigned int i = 0; i < length; i++) {
- CSSView * childView = mChildren[i];
- // Only layout those children that are actually displayed.
- if (childView->IsDisplayed()) {
- // Don't care if the child is a block or not, children will be positioned next to each other.
- startingPoint = BPoint(restRowRect.left, restRowRect.top);
- // Do the layout for the child.
- childView->Layout(restRowRect, startingPoint);
- BRect rect2 = childView->Bounds();
- mEndPoint = childView->GetEndPoint();
- // Set the top of the remaining rect to the bottom of the child,
- // because the space above is already taken by the child.
- restRect.top = rect2.bottom;
- if (rect2.right > restRect.right) {
- // The child used more space than was available. We can use that space now as well
- // for any remaining children.
- restRect.right = rect2.right;
- mRect.right = rect2.right;
- restRowRect.right = rect2.right;
- }
- // What is the maximum horizontal space being taken up by one of the children?
- if (rect2.right > maxRight) {
- maxRight = rect2.right;
- }
- // What is the maximum vertical space being taken up by one of the children?
- if (rect2.bottom > maxBottom) {
- maxBottom = rect2.bottom;
- }
- // Make sure the next child starts to the right of this one.
- restRowRect.left = rect2.right;
+ // Do the layout for the child.
+ childView->Layout(restRect, startingPoint);
+ BRect rect2 = childView->Bounds();
+ mEndPoint = childView->GetEndPoint();
+ // Set the top of the remaining rect to the bottom of the child,
+ // because the space above is already taken by the child.
+ restRect.top = rect2.bottom;
+ if (rect2.right > restRect.right) {
+ // The child used more space than was available. We can use that space now as well
+ // for any remaining children.
+ restRect.right = rect2.right;
+ mRect.right = rect2.right;
}
+ // What is the maximum horizontal space being taken up by one of the children?
+ if (rect2.right > maxRight) {
+ maxRight = rect2.right;
+ }
+
+ if (childView->IsBlock()) {
+ // The next child will have to start at the left of the parent rect and just below this block.
+ startingPoint = BPoint(restRect.left, restRect.top);
+ // previousChildIsBlock = true;
+ // startingPoint.PrintToStream();
+ }
+ else {
+ // We can start where we left off.
+ startingPoint = mEndPoint;
+ // previousChildIsBlock = false;
+// printf("Starting at: ");
+// mEndPoint.PrintToStream();
+ }
}
- if (maxBottom > 0) {
- // Only set it in case we found something.
- restRect.top = maxBottom;
- }
}
if (maxRight > 0) {
// Only set it in case we found something.
Modified: trunk/themis/modules/CSSRenderer/CSSView.hpp
===================================================================
--- trunk/themis/modules/CSSRenderer/CSSView.hpp 2012-02-22 23:40:32 UTC (rev 673)
+++ trunk/themis/modules/CSSRenderer/CSSView.hpp 2012-02-23 22:39:42 UTC (rev 674)
@@ -71,40 +71,37 @@
class CSSView : public BHandler {
private:
- vector<CSSView *> mChildren;
TNodePtr mNode;
CSSStyleContainer * mStyleSheets;
CSSRendererView * mBaseView;
- vector<BRect> mRects;
- BRect mRect;
- BPoint mEndPoint;
vector<TextBox> mTextBoxes;
float mLineHeight;
float mBottomMargin;
float mSpaceWidth;
BFont * mFont;
bool mInheritedFont;
- float mMarginBottom;
- float mMarginRight;
bool mClickable;
string mHref;
string mName;
rgb_color mColor;
- string mListStyleType;
string mBorderStyle;
- float mBorderWidth;
- BRect mListStyleRect;
int32 mSiteId;
int32 mUrlId;
void RetrieveLink(bool aVisible = true);
protected:
+ vector<CSSView *> mChildren;
+ vector<BRect> mRects;
+ BRect mRect;
+ BPoint mEndPoint;
+ float mBorderWidth;
+ float mMarginBottom;
+ float mMarginRight;
+ BRect mListStyleRect;
+ string mListStyleType;
bool mDisplay;
bool mBlock;
- bool mTable;
- bool mTableRow;
- bool mTableCell;
void ApplyStyle(const TElementPtr aElement,
const CSSStyleDeclarationPtr aStyle);
Modified: trunk/themis/modules/CSSRenderer/InlineDisplayView.cpp
===================================================================
--- trunk/themis/modules/CSSRenderer/InlineDisplayView.cpp 2012-02-22 23:40:32 UTC (rev 673)
+++ trunk/themis/modules/CSSRenderer/InlineDisplayView.cpp 2012-02-23 22:39:42 UTC (rev 674)
@@ -60,9 +60,6 @@
mDisplay = true;
mBlock = false;
- mTable = false;
- mTableRow = false;
- mTableCell = false;
}
Modified: trunk/themis/modules/CSSRenderer/NoneDisplayView.cpp
===================================================================
--- trunk/themis/modules/CSSRenderer/NoneDisplayView.cpp 2012-02-22 23:40:32 UTC (rev 673)
+++ trunk/themis/modules/CSSRenderer/NoneDisplayView.cpp 2012-02-23 22:39:42 UTC (rev 674)
@@ -60,9 +60,6 @@
mDisplay = false;
mBlock = false;
- mTable = false;
- mTableRow = false;
- mTableCell = false;
}
Modified: trunk/themis/modules/CSSRenderer/TableCellDisplayView.cpp
===================================================================
--- trunk/themis/modules/CSSRenderer/TableCellDisplayView.cpp 2012-02-22 23:40:32 UTC (rev 673)
+++ trunk/themis/modules/CSSRenderer/TableCellDisplayView.cpp 2012-02-23 22:39:42 UTC (rev 674)
@@ -60,9 +60,6 @@
mDisplay = true;
mBlock = false;
- mTable = false;
- mTableRow = false;
- mTableCell = true;
}
Modified: trunk/themis/modules/CSSRenderer/TableDisplayView.cpp
===================================================================
--- trunk/themis/modules/CSSRenderer/TableDisplayView.cpp 2012-02-22 23:40:32 UTC (rev 673)
+++ trunk/themis/modules/CSSRenderer/TableDisplayView.cpp 2012-02-23 22:39:42 UTC (rev 674)
@@ -59,10 +59,7 @@
aFont) {
mDisplay = true;
- mBlock = false;
- mTable = true;
- mTableRow = false;
- mTableCell = false;
+ mBlock = true;
}
Modified: trunk/themis/modules/CSSRenderer/TableRowDisplayView.cpp
===================================================================
--- trunk/themis/modules/CSSRenderer/TableRowDisplayView.cpp 2012-02-22 23:40:32 UTC (rev 673)
+++ trunk/themis/modules/CSSRenderer/TableRowDisplayView.cpp 2012-02-23 22:39:42 UTC (rev 674)
@@ -60,9 +60,6 @@
mDisplay = true;
mBlock = false;
- mTable = false;
- mTableRow = true;
- mTableCell = false;
}
@@ -73,6 +70,85 @@
void TableRowDisplayView :: Layout(BRect aRect,
BPoint aStartingPoint) {
- CSSView::Layout(aRect, aStartingPoint);
+ mRect = aRect;
+ // Always set the top of the rect to the one from the starting point as that is definitely correct.
+ mRect.top = aStartingPoint.y;
+ BRect restRect = mRect;
+ // If we are drawing a border around this element, make sure there is less space for the content.
+ restRect.InsetBy(mBorderWidth, mBorderWidth);
+ // Set the endpoint to the starting point, as that is the minimum endpoint
+ mEndPoint = aStartingPoint;
+ // Assume we don't need any horizontal space. The children will determine the space needed.
+// mRect.right = mRect.left;
+ // In case we need to draw something before drawing any children, move the children.
+ if (mListStyleType == "square") {
+ mListStyleRect.left = restRect.left + 2;
+ mListStyleRect.right = restRect.left + 7;
+ mListStyleRect.top = restRect.top + 2;
+ mListStyleRect.bottom = restRect.top + 7;
+ restRect.left += 12;
+ mEndPoint.x += 12;
+ }
+ // Layout the children.
+ unsigned int length = mChildren.size();
+ BPoint startingPoint = mEndPoint;
+ float maxRight = 0;
+ BRect restRowRect = restRect;
+ float maxBottom = restRowRect.top;
+ for (unsigned int i = 0; i < length; i++) {
+ CSSView * childView = mChildren[i];
+ // Only layout those children that are actually displayed.
+ if (childView->IsDisplayed()) {
+ // Don't care if the child is a block or not, children will be positioned next to each other.
+ startingPoint = BPoint(restRowRect.left, restRowRect.top);
+ // Do the layout for the child.
+ childView->Layout(restRowRect, startingPoint);
+ BRect rect2 = childView->Bounds();
+ mEndPoint = childView->GetEndPoint();
+ // Set the top of the remaining rect to the bottom of the child,
+ // because the space above is already taken by the child.
+ restRect.top = rect2.bottom;
+ if (rect2.right > restRect.right) {
+ // The child used more space than was available. We can use that space now as well
+ // for any remaining children.
+ restRect.right = rect2.right;
+ mRect.right = rect2.right;
+ restRowRect.right = rect2.right;
+ }
+ // What is the maximum horizontal space being taken up by one of the children?
+ if (rect2.right > maxRight) {
+ maxRight = rect2.right;
+ }
+ // What is the maximum vertical space being taken up by one of the children?
+ if (rect2.bottom > maxBottom) {
+ maxBottom = rect2.bottom;
+ }
+ // Make sure the next child starts to the right of this one.
+ restRowRect.left = rect2.right;
+ }
+ }
+ if (maxBottom > 0) {
+ // Only set it in case we found something.
+ restRect.top = maxBottom;
+ }
+
+ if (maxRight > 0) {
+ // Only set it in case we found something.
+ mRect.right = maxRight;
+ }
+ else {
+ mRect.right = mRect.left;
+ }
+ mRect.bottom = restRect.top;
+ mRects.push_back(mRect);
+// mRect.PrintToStream();
+
+ // Add any margins
+ mEndPoint.Set(mEndPoint.x + mMarginRight, mEndPoint.y + mMarginBottom);
+
+ mRect.bottom = restRect.top + mMarginBottom;
+ mRect.right += mMarginRight;
+ //mRect.right = restRect.right;
+
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|