summaryrefslogtreecommitdiffstats
path: root/WebCore
diff options
context:
space:
mode:
authorShimeng (Simon) Wang <swang@google.com>2010-07-09 13:47:45 -0700
committerShimeng (Simon) Wang <swang@google.com>2010-07-12 11:44:09 -0700
commit23e9dd818a876304304944c844be7625f63383c4 (patch)
treecf597d37d02f29235800e3e522a64884c1167b52 /WebCore
parent53451870e9ac7ef67aa76fdd8c1cf47eafaa8763 (diff)
downloadexternal_webkit-23e9dd818a876304304944c844be7625f63383c4.zip
external_webkit-23e9dd818a876304304944c844be7625f63383c4.tar.gz
external_webkit-23e9dd818a876304304944c844be7625f63383c4.tar.bz2
Fix issue: 2741016 and refactor visible width logic in android layout.
The site is not reflowed, because for some RenderBlock, the m_visibleWidth is set twice before layout; the current logic will think the visibleWidth is not changed, hence no relayout children and no reflow. The logic is refactored to to make it modularlized. issue: 2741016 Change-Id: I1f433e263add974c0981c332ad4ea092ddb395e0
Diffstat (limited to 'WebCore')
-rw-r--r--WebCore/rendering/RenderBlock.cpp10
-rw-r--r--WebCore/rendering/RenderBox.cpp31
-rw-r--r--WebCore/rendering/RenderBox.h12
-rw-r--r--WebCore/rendering/RenderFlexibleBox.cpp10
-rw-r--r--WebCore/rendering/RenderTable.cpp16
-rw-r--r--WebCore/rendering/RenderTableCell.cpp9
-rw-r--r--WebCore/rendering/RenderTableCell.h7
-rw-r--r--WebCore/rendering/RenderTextControlSingleLine.cpp9
-rw-r--r--WebCore/rendering/RenderView.cpp3
9 files changed, 45 insertions, 62 deletions
diff --git a/WebCore/rendering/RenderBlock.cpp b/WebCore/rendering/RenderBlock.cpp
index 58c5842..dd1e8e5 100644
--- a/WebCore/rendering/RenderBlock.cpp
+++ b/WebCore/rendering/RenderBlock.cpp
@@ -1136,10 +1136,6 @@ void RenderBlock::layoutBlock(bool relayoutChildren)
int oldWidth = width();
int oldColumnWidth = desiredColumnWidth();
-#ifdef ANDROID_LAYOUT
- int oldVisibleWidth = m_visibleWidth;
-#endif
-
calcWidth();
calcColumnWidth();
@@ -1149,11 +1145,7 @@ void RenderBlock::layoutBlock(bool relayoutChildren)
relayoutChildren = true;
#ifdef ANDROID_LAYOUT
- const Settings* settings = document()->settings();
- ASSERT(settings);
- if (oldVisibleWidth != m_visibleWidth
- && settings->layoutAlgorithm() == Settings::kLayoutFitColumnToScreen)
- relayoutChildren = true;
+ checkAndSetRelayoutChildren(&relayoutChildren);
#endif
clearFloats();
diff --git a/WebCore/rendering/RenderBox.cpp b/WebCore/rendering/RenderBox.cpp
index f337a9a..d4c691f 100644
--- a/WebCore/rendering/RenderBox.cpp
+++ b/WebCore/rendering/RenderBox.cpp
@@ -75,6 +75,7 @@ RenderBox::RenderBox(Node* node)
: RenderBoxModelObject(node)
#ifdef ANDROID_LAYOUT
, m_visibleWidth(0)
+ , m_isVisibleWidthChangedBeforeLayout(false)
#endif
, m_marginLeft(0)
, m_marginRight(0)
@@ -1286,16 +1287,32 @@ void RenderBox::repaintDuringLayoutIfMoved(const IntRect& rect)
}
}
+#ifdef ANDROID_LAYOUT
+void RenderBox::setVisibleWidth(int newWidth) {
+ const Settings* settings = document()->settings();
+ ASSERT(settings);
+ if (settings->layoutAlgorithm() != Settings::kLayoutFitColumnToScreen
+ || m_visibleWidth == newWidth)
+ return;
+ m_isVisibleWidthChangedBeforeLayout = true;
+ m_visibleWidth = newWidth;
+}
+
+bool RenderBox::checkAndSetRelayoutChildren(bool* relayoutChildren) {
+ if (m_isVisibleWidthChangedBeforeLayout) {
+ m_isVisibleWidthChangedBeforeLayout = false;
+ *relayoutChildren = true;
+ return true;
+ }
+ return false;
+}
+#endif
+
void RenderBox::calcWidth()
{
#ifdef ANDROID_LAYOUT
- if (view()->frameView()) {
- const Settings* settings = document()->settings();
- ASSERT(settings);
- if (settings->layoutAlgorithm() == Settings::kLayoutFitColumnToScreen) {
- m_visibleWidth = view()->frameView()->textWrapWidth();
- }
- }
+ if (view()->frameView())
+ setVisibleWidth(view()->frameView()->textWrapWidth());
#endif
if (isPositioned()) {
diff --git a/WebCore/rendering/RenderBox.h b/WebCore/rendering/RenderBox.h
index 3e95cea..e02f77a 100644
--- a/WebCore/rendering/RenderBox.h
+++ b/WebCore/rendering/RenderBox.h
@@ -297,6 +297,10 @@ public:
bool shrinkToAvoidFloats() const;
virtual bool avoidsFloats() const;
+#ifdef ANDROID_LAYOUT
+ int getVisibleWidth() const { return m_visibleWidth; }
+#endif
+
protected:
virtual void styleWillChange(StyleDifference, const RenderStyle* newStyle);
virtual void styleDidChange(StyleDifference, const RenderStyle* oldStyle);
@@ -355,7 +359,8 @@ private:
protected:
#ifdef ANDROID_LAYOUT
- int m_visibleWidth;
+ void setVisibleWidth(int newWidth);
+ bool checkAndSetRelayoutChildren(bool* relayoutChildren);
#endif
int m_marginLeft;
@@ -378,6 +383,11 @@ protected:
private:
// Used to store state between styleWillChange and styleDidChange
static bool s_hadOverflowClip;
+
+#ifdef ANDROID_LAYOUT
+ int m_visibleWidth;
+ bool m_isVisibleWidthChangedBeforeLayout;
+#endif
};
inline RenderBox* toRenderBox(RenderObject* object)
diff --git a/WebCore/rendering/RenderFlexibleBox.cpp b/WebCore/rendering/RenderFlexibleBox.cpp
index d0222cb..695bd31 100644
--- a/WebCore/rendering/RenderFlexibleBox.cpp
+++ b/WebCore/rendering/RenderFlexibleBox.cpp
@@ -219,10 +219,6 @@ void RenderFlexibleBox::layoutBlock(bool relayoutChildren)
int previousWidth = width();
int previousHeight = height();
- #ifdef ANDROID_LAYOUT
- int previousVisibleWidth = m_visibleWidth;
-#endif
-
calcWidth();
calcHeight();
@@ -234,11 +230,7 @@ void RenderFlexibleBox::layoutBlock(bool relayoutChildren)
relayoutChildren = true;
#ifdef ANDROID_LAYOUT
- const Settings* settings = document()->settings();
- ASSERT(settings);
- if (previousVisibleWidth != m_visibleWidth
- && settings->layoutAlgorithm() == Settings::kLayoutFitColumnToScreen)
- relayoutChildren = true;
+ checkAndSetRelayoutChildren(&relayoutChildren);
#endif
setHeight(0);
diff --git a/WebCore/rendering/RenderTable.cpp b/WebCore/rendering/RenderTable.cpp
index 65a0cde..52fc326 100644
--- a/WebCore/rendering/RenderTable.cpp
+++ b/WebCore/rendering/RenderTable.cpp
@@ -203,13 +203,8 @@ void RenderTable::removeChild(RenderObject* oldChild)
void RenderTable::calcWidth()
{
#ifdef ANDROID_LAYOUT
- if (view()->frameView()) {
- const Settings* settings = document()->settings();
- ASSERT(settings);
- if (settings->layoutAlgorithm() == Settings::kLayoutFitColumnToScreen) {
- m_visibleWidth = view()->frameView()->textWrapWidth();
- }
- }
+ if (view()->frameView())
+ setVisibleWidth(view()->frameView()->textWrapWidth());
#endif
if (isPositioned())
@@ -274,17 +269,14 @@ void RenderTable::layout()
#ifdef ANDROID_LAYOUT
bool relayoutChildren = false;
- int oldVisibleWidth = m_visibleWidth;
#endif
int oldWidth = width();
calcWidth();
#ifdef ANDROID_LAYOUT
- if (oldVisibleWidth != m_visibleWidth
- && document()->settings()->layoutAlgorithm() == Settings::kLayoutFitColumnToScreen)
- relayoutChildren = true;
- else if (document()->settings()->layoutAlgorithm() == Settings::kLayoutSSR) {
+ if (!checkAndSetRelayoutChildren(&relayoutChildren)
+ && document()->settings()->layoutAlgorithm() == Settings::kLayoutSSR) {
// if the width of a table is wider than its container width, or it has a nested table,
// we will render it with single column.
int cw = containingBlockWidthForContent();
diff --git a/WebCore/rendering/RenderTableCell.cpp b/WebCore/rendering/RenderTableCell.cpp
index 11f3b52..c0532cf 100644
--- a/WebCore/rendering/RenderTableCell.cpp
+++ b/WebCore/rendering/RenderTableCell.cpp
@@ -152,13 +152,8 @@ void RenderTableCell::calcPrefWidths()
void RenderTableCell::calcWidth()
{
#ifdef ANDROID_LAYOUT
- if (view()->frameView()) {
- const Settings* settings = document()->settings();
- ASSERT(settings);
- if (settings->layoutAlgorithm() == Settings::kLayoutFitColumnToScreen) {
- m_visibleWidth = view()->frameView()->textWrapWidth();
- }
- }
+ if (view()->frameView())
+ setVisibleWidth(view()->frameView()->textWrapWidth());
#endif
}
diff --git a/WebCore/rendering/RenderTableCell.h b/WebCore/rendering/RenderTableCell.h
index a5a1edd..b6622f4 100644
--- a/WebCore/rendering/RenderTableCell.h
+++ b/WebCore/rendering/RenderTableCell.h
@@ -55,13 +55,6 @@ public:
virtual void calcPrefWidths();
-#if PLATFORM(ANDROID)
-#ifdef ANDROID_LAYOUT
- // RenderTableSection needs to access this in setCellWidths()
- int getVisibleWidth() { return m_visibleWidth; }
-#endif
-#endif
-
void updateWidth(int);
int borderLeft() const;
diff --git a/WebCore/rendering/RenderTextControlSingleLine.cpp b/WebCore/rendering/RenderTextControlSingleLine.cpp
index 84ed8aa..b6c2916 100644
--- a/WebCore/rendering/RenderTextControlSingleLine.cpp
+++ b/WebCore/rendering/RenderTextControlSingleLine.cpp
@@ -216,20 +216,13 @@ void RenderTextControlSingleLine::layout()
int oldHeight = height();
calcHeight();
-#ifdef ANDROID_LAYOUT
- int oldVisibleWidth = m_visibleWidth;
-#endif
-
int oldWidth = width();
calcWidth();
bool relayoutChildren = oldHeight != height() || oldWidth != width();
#ifdef ANDROID_LAYOUT
- if (oldVisibleWidth != m_visibleWidth
- && document()->settings()->layoutAlgorithm() == Settings::kLayoutFitColumnToScreen) {
- relayoutChildren = true;
- }
+ checkAndSetRelayoutChildren(&relayoutChildren);
#endif
RenderBox* innerTextRenderer = innerTextElement()->renderBox();
diff --git a/WebCore/rendering/RenderView.cpp b/WebCore/rendering/RenderView.cpp
index e77f6c7..eb920a2 100644
--- a/WebCore/rendering/RenderView.cpp
+++ b/WebCore/rendering/RenderView.cpp
@@ -90,10 +90,9 @@ void RenderView::calcWidth()
if (!printing() && m_frameView)
setWidth(viewWidth());
#ifdef ANDROID_LAYOUT
+ setVisibleWidth(m_frameView->textWrapWidth());
const Settings * settings = document()->settings();
ASSERT(settings);
- if (settings->layoutAlgorithm() == Settings::kLayoutFitColumnToScreen)
- m_visibleWidth = m_frameView->textWrapWidth();
if (settings->useWideViewport() && settings->viewportWidth() == -1 && width() < minPrefWidth())
setWidth(m_minPrefWidth);
#endif