Diff
Modified: trunk/Source/WebCore/ChangeLog (167443 => 167444)
--- trunk/Source/WebCore/ChangeLog 2014-04-17 18:26:58 UTC (rev 167443)
+++ trunk/Source/WebCore/ChangeLog 2014-04-17 18:48:15 UTC (rev 167444)
@@ -1,3 +1,41 @@
+2014-04-17 David Hyatt <hy...@apple.com>
+
+ [New Multicolumn] columnNumberForOffset is not patched for new multicolumn code yet.
+ https://bugs.webkit.org/show_bug.cgi?id=131740
+
+ Reviewed by Enrica Casucci.
+
+ I took the opportunity to clean this code up while adding support for the new columns.
+ columnNumberForOffset only applied for paginated RenderViews and was really about
+ pages and not columns. It also only returns an actual page number if the columns are
+ block progressed (e.g., right-to-left vertical Japanese books).
+
+ Therefore I renamed columnNumberForOffset to pageNumberForBlockProgressionOffset and
+ moved it to RenderView.
+
+ I also renamed the member variable of SelectionRect to be pageNumber instead of
+ columnNumber in order to make it more obvious that this isn't about columns per se
+ (since the fact that we implemented RenderView's pagination mode using columns is an
+ implementation detail).
+
+ * dom/Range.cpp:
+ (WebCore::coalesceSelectionRects):
+ (WebCore::Range::collectSelectionRects):
+ * platform/ios/SelectionRect.h:
+ (WebCore::SelectionRect::pageNumber):
+ (WebCore::SelectionRect::columnNumber): Deleted.
+ * rendering/RenderImage.cpp:
+ (WebCore::RenderImage::collectSelectionRects):
+ * rendering/RenderObject.cpp:
+ (WebCore::RenderObject::collectSelectionRects):
+ (WebCore::RenderObject::columnNumberForOffset): Deleted.
+ * rendering/RenderObject.h:
+ * rendering/RenderText.cpp:
+ (WebCore::RenderText::collectSelectionRects):
+ * rendering/RenderView.cpp:
+ (WebCore::RenderView::pageNumberForBlockProgressionOffset):
+ * rendering/RenderView.h:
+
2014-04-16 Brent Fulgham <bfulg...@apple.com>
[Win] A few final cleanups to the DataObject classes.
Modified: trunk/Source/WebCore/dom/Range.cpp (167443 => 167444)
--- trunk/Source/WebCore/dom/Range.cpp 2014-04-17 18:26:58 UTC (rev 167443)
+++ trunk/Source/WebCore/dom/Range.cpp 2014-04-17 18:48:15 UTC (rev 167444)
@@ -1711,7 +1711,7 @@
static SelectionRect coalesceSelectionRects(const SelectionRect& original, const SelectionRect& previous)
{
- SelectionRect result(unionRect(previous.rect(), original.rect()), original.isHorizontal(), original.columnNumber());
+ SelectionRect result(unionRect(previous.rect(), original.rect()), original.isHorizontal(), original.pageNumber());
result.setDirection(original.containsStart() || original.containsEnd() ? original.direction() : previous.direction());
result.setContainsStart(previous.containsStart() || original.containsStart());
result.setContainsEnd(previous.containsEnd() || original.containsEnd());
@@ -1823,7 +1823,7 @@
lineBottom = currentRectBottom;
} else {
lastLineBottom = lineBottom;
- if (currentRectTop <= lastLineBottom && i && rects[i].columnNumber() == rects[i - 1].columnNumber()) {
+ if (currentRectTop <= lastLineBottom && i && rects[i].pageNumber() == rects[i - 1].pageNumber()) {
lastLineTop = lineTop;
lineBottom = lastLineTop;
} else {
@@ -1914,13 +1914,13 @@
// For iBooks, the interior lines may cross multiple horizontal pages.
interiorUnionRect.unite(currentRect.rect());
} else {
- unionedRects.append(SelectionRect(interiorUnionRect, currentRect.isHorizontal(), currentRect.columnNumber()));
+ unionedRects.append(SelectionRect(interiorUnionRect, currentRect.isHorizontal(), currentRect.pageNumber()));
interiorUnionRect = currentRect.rect();
}
} else {
// Processing last line.
if (!interiorUnionRect.isEmpty()) {
- unionedRects.append(SelectionRect(interiorUnionRect, currentRect.isHorizontal(), currentRect.columnNumber()));
+ unionedRects.append(SelectionRect(interiorUnionRect, currentRect.isHorizontal(), currentRect.pageNumber()));
interiorUnionRect = IntRect();
}
Modified: trunk/Source/WebCore/platform/ios/SelectionRect.h (167443 => 167444)
--- trunk/Source/WebCore/platform/ios/SelectionRect.h 2014-04-17 18:26:58 UTC (rev 167443)
+++ trunk/Source/WebCore/platform/ios/SelectionRect.h 2014-04-17 18:48:15 UTC (rev 167444)
@@ -62,7 +62,7 @@
bool isHorizontal() const { return m_isHorizontal; }
bool isInFixedPosition() const { return m_isInFixedPosition; }
bool isRubyText() const { return m_isRubyText; }
- int columnNumber() const { return m_columnNumber; }
+ int pageNumber() const { return m_pageNumber; }
void setRect(const IntRect& rect) { m_rect = rect; }
@@ -125,7 +125,7 @@
bool m_isHorizontal;
bool m_isInFixedPosition;
bool m_isRubyText;
- int m_columnNumber;
+ int m_pageNumber;
};
} // namespace WebCore
Modified: trunk/Source/WebCore/rendering/RenderImage.cpp (167443 => 167444)
--- trunk/Source/WebCore/rendering/RenderImage.cpp 2014-04-17 18:26:58 UTC (rev 167443)
+++ trunk/Source/WebCore/rendering/RenderImage.cpp 2014-04-17 18:48:15 UTC (rev 167444)
@@ -112,7 +112,7 @@
// FIXME: We should consider either making SelectionRect a struct or better organize its optional fields into
// an auxiliary struct to simplify its initialization.
- rects.append(SelectionRect(absoluteBounds, containingBlock->style().direction(), lineExtentBounds.x(), lineExtentBounds.maxX(), lineExtentBounds.maxY(), 0, false /* line break */, isFirstOnLine, isLastOnLine, false /* contains start */, false /* contains end */, containingBlock->style().isHorizontalWritingMode(), isFixed, false /* ruby text */, columnNumberForOffset(absoluteBounds.x())));
+ rects.append(SelectionRect(absoluteBounds, containingBlock->style().direction(), lineExtentBounds.x(), lineExtentBounds.maxX(), lineExtentBounds.maxY(), 0, false /* line break */, isFirstOnLine, isLastOnLine, false /* contains start */, false /* contains end */, containingBlock->style().isHorizontalWritingMode(), isFixed, false /* ruby text */, view().pageNumberForBlockProgressionOffset(absoluteBounds.x())));
}
#endif
Modified: trunk/Source/WebCore/rendering/RenderObject.cpp (167443 => 167444)
--- trunk/Source/WebCore/rendering/RenderObject.cpp 2014-04-17 18:26:58 UTC (rev 167443)
+++ trunk/Source/WebCore/rendering/RenderObject.cpp 2014-04-17 18:48:15 UTC (rev 167444)
@@ -1086,26 +1086,6 @@
graphicsContext->endTransparencyLayer();
}
-// FIXME: Make this return an unsigned integer?
-int RenderObject::columnNumberForOffset(int offset)
-{
- int columnNumber = 0;
- RenderBlock* containingBlock = this->containingBlock();
- RenderView& view = containingBlock->view();
- const Pagination& pagination = view.frameView().frame().page()->pagination();
- if (pagination.mode == Pagination::Unpaginated)
- return columnNumber;
-
- ColumnInfo* columnInfo = view.columnInfo();
- if (columnInfo && !columnInfo->progressionIsInline()) {
- if (!columnInfo->progressionIsReversed())
- columnNumber = (pagination.pageLength + pagination.gap - offset) / (pagination.pageLength + pagination.gap);
- else
- columnNumber = offset / (pagination.pageLength + pagination.gap);
- }
- return columnNumber;
-}
-
#if PLATFORM(IOS)
// This function is similar in spirit to RenderText::absoluteRectsForRange, but returns rectangles
// which are annotated with additional state which helps iOS draw selections in its unique way.
@@ -1133,7 +1113,7 @@
unsigned numberOfQuads = quads.size();
for (unsigned i = 0; i < numberOfQuads; ++i)
- rects.append(SelectionRect(quads[i].enclosingBoundingBox(), isHorizontalWritingMode(), columnNumberForOffset(quads[i].enclosingBoundingBox().x())));
+ rects.append(SelectionRect(quads[i].enclosingBoundingBox(), isHorizontalWritingMode(), view().pageNumberForBlockProgressionOffset(quads[i].enclosingBoundingBox().x())));
}
#endif
Modified: trunk/Source/WebCore/rendering/RenderObject.h (167443 => 167444)
--- trunk/Source/WebCore/rendering/RenderObject.h 2014-04-17 18:26:58 UTC (rev 167443)
+++ trunk/Source/WebCore/rendering/RenderObject.h 2014-04-17 18:48:15 UTC (rev 167444)
@@ -879,8 +879,6 @@
void drawLineForBoxSide(GraphicsContext*, float x1, float y1, float x2, float y2, BoxSide, Color, EBorderStyle, float adjbw1, float adjbw2, bool antialias = false);
protected:
- int columnNumberForOffset(int offset);
-
void paintFocusRing(PaintInfo&, const LayoutPoint&, RenderStyle*);
void paintOutline(PaintInfo&, const LayoutRect&);
void addPDFURLRect(GraphicsContext*, const LayoutRect&);
Modified: trunk/Source/WebCore/rendering/RenderText.cpp (167443 => 167444)
--- trunk/Source/WebCore/rendering/RenderText.cpp 2014-04-17 18:26:58 UTC (rev 167443)
+++ trunk/Source/WebCore/rendering/RenderText.cpp 2014-04-17 18:48:15 UTC (rev 167444)
@@ -391,7 +391,7 @@
}
}
- rects.append(SelectionRect(absRect, box->direction(), extentsRect.x(), extentsRect.maxX(), extentsRect.maxY(), 0, box->isLineBreak(), isFirstOnLine, isLastOnLine, containsStart, containsEnd, boxIsHorizontal, isFixed, containingBlock->isRubyText(), columnNumberForOffset(absRect.x())));
+ rects.append(SelectionRect(absRect, box->direction(), extentsRect.x(), extentsRect.maxX(), extentsRect.maxY(), 0, box->isLineBreak(), isFirstOnLine, isLastOnLine, containsStart, containsEnd, boxIsHorizontal, isFixed, containingBlock->isRubyText(), view().pageNumberForBlockProgressionOffset(absRect.x())));
}
}
#endif
Modified: trunk/Source/WebCore/rendering/RenderView.cpp (167443 => 167444)
--- trunk/Source/WebCore/rendering/RenderView.cpp 2014-04-17 18:26:58 UTC (rev 167443)
+++ trunk/Source/WebCore/rendering/RenderView.cpp 2014-04-17 18:48:15 UTC (rev 167444)
@@ -41,6 +41,7 @@
#include "RenderLayer.h"
#include "RenderLayerBacking.h"
#include "RenderLayerCompositor.h"
+#include "RenderMultiColumnFlowThread.h"
#include "RenderNamedFlowThread.h"
#include "RenderSelectionInfo.h"
#include "RenderWidget.h"
@@ -1224,4 +1225,36 @@
m_rootView->flushAccumulatedRepaintRegion();
}
+unsigned RenderView::pageNumberForBlockProgressionOffset(int offset) const
+{
+ int columnNumber = 0;
+ const Pagination& pagination = frameView().frame().page()->pagination();
+ if (pagination.mode == Pagination::Unpaginated)
+ return columnNumber;
+
+ bool progressionIsInline = false;
+ bool progressionIsReversed = false;
+
+ if (hasColumns()) {
+ ColumnInfo* colInfo = columnInfo();
+ if (!colInfo)
+ return columnNumber;
+ progressionIsInline = colInfo->progressionIsInline();
+ progressionIsReversed = colInfo->progressionIsReversed();
+ } else if (multiColumnFlowThread()) {
+ progressionIsInline = multiColumnFlowThread()->progressionIsInline();
+ progressionIsReversed = multiColumnFlowThread()->progressionIsReversed();
+ } else
+ return columnNumber;
+
+ if (!progressionIsInline) {
+ if (!progressionIsReversed)
+ columnNumber = (pagination.pageLength + pagination.gap - offset) / (pagination.pageLength + pagination.gap);
+ else
+ columnNumber = offset / (pagination.pageLength + pagination.gap);
+ }
+
+ return columnNumber;
+}
+
} // namespace WebCore
Modified: trunk/Source/WebCore/rendering/RenderView.h (167443 => 167444)
--- trunk/Source/WebCore/rendering/RenderView.h 2014-04-17 18:26:58 UTC (rev 167443)
+++ trunk/Source/WebCore/rendering/RenderView.h 2014-04-17 18:48:15 UTC (rev 167444)
@@ -154,6 +154,12 @@
}
LayoutUnit pageOrViewLogicalHeight() const;
+ // This method is used to assign a page number only when pagination modes have
+ // a block progression. This happens with vertical-rl books for example, but it
+ // doesn't happen for normal horizontal-tb books. This is a very specialized
+ // function and should not be mistaken for a general page number API.
+ unsigned pageNumberForBlockProgressionOffset(int offset) const;
+
// FIXME: These functions are deprecated. No code should be added that uses these.
int bestTruncatedAt() const { return m_legacyPrinting.m_bestTruncatedAt; }
void setBestTruncatedAt(int y, RenderBoxModelObject* forRenderer, bool forcedBreak = false);
@@ -238,7 +244,7 @@
virtual const RenderObject* pushMappingToContainer(const RenderLayerModelObject* ancestorToStopAt, RenderGeometryMap&) const override;
virtual void mapAbsoluteToLocalPoint(MapCoordinatesFlags, TransformState&) const override;
virtual bool requiresColumns(int desiredColumnCount) const override;
-
+
private:
void initializeLayoutState(LayoutState&);