[New Multicolumn] columnNumberForOffset is not patched for new multicolumn code yet.
[WebKit-https.git] / Source / WebCore / rendering / RenderView.cpp
index cc3b7d9c355c13ee9c726826a624cdc392c6a1d8..df40522441ee839c26d1b0747ecbfadb82b39329 100644 (file)
@@ -41,6 +41,7 @@
 #include "RenderLayer.h"
 #include "RenderLayerBacking.h"
 #include "RenderLayerCompositor.h"
 #include "RenderLayer.h"
 #include "RenderLayerBacking.h"
 #include "RenderLayerCompositor.h"
+#include "RenderMultiColumnFlowThread.h"
 #include "RenderNamedFlowThread.h"
 #include "RenderSelectionInfo.h"
 #include "RenderWidget.h"
 #include "RenderNamedFlowThread.h"
 #include "RenderSelectionInfo.h"
 #include "RenderWidget.h"
@@ -1224,4 +1225,36 @@ RenderView::RepaintRegionAccumulator::~RepaintRegionAccumulator()
     m_rootView->flushAccumulatedRepaintRegion();
 }
 
     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
 } // namespace WebCore