[
https://issues.apache.org/jira/browse/FOP-2731?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16101599#comment-16101599
]
Dan Caprioara commented on FOP-2731:
Possible fix:
{code}
Index: BlockContainerLayoutManager.java
===
--- BlockContainerLayoutManager.java(revision 161373)
+++ BlockContainerLayoutManager.java(working copy)
@@ -744,7 +744,57 @@
}
return new Point(x, y);
}
+
+// PATCH START - FOP-2731 Using the page as reference for fixed
positioning
+
+/**
+ * Gets the offset of the box, when having a position: fixed.
+ * The reference area is the page.
+ *
+ * @return The coordinate in the page.
+ */
+private Point getFixedOffset() {
+int x = 0;
+int y = 0;
+
+if (abProps.left.getEnum() != EN_AUTO) {
+x = abProps.left.getValue(this);
+} else if (abProps.right.getEnum() != EN_AUTO
+&& width.getEnum() != EN_AUTO) {
+x = getPageWidth()
+- abProps.right.getValue(this) - width.getValue(this);
+}
+if (abProps.top.getEnum() != EN_AUTO) {
+y = abProps.top.getValue(this);
+} else if (abProps.bottom.getEnum() != EN_AUTO
+&& height.getEnum() != EN_AUTO) {
+y = getReferenceAreaForFixedBPD()
+- abProps.bottom.getValue(this) - height.getValue(this);
+}
+return new Point(x, y);
+}
+
+/**
+ * Gets the width of the page.
+ *
+ * @return the width of the page.
+ */
+public int getPageWidth() {
+ return (int) getCurrentPV().getViewArea().getWidth();
+}
+
+/**
+ * Gets the height of the page.
+ *
+ * @return the height of the page.
+ */
+protected int getReferenceAreaForFixedBPD() {
+ return (int) getCurrentPV().getViewArea().getHeight();
+}
+
+// PATCH END
+
/** {@inheritDoc} */
@Override
public void addAreas(PositionIterator parentIter, LayoutContext
layoutContext) {
@@ -884,14 +934,29 @@
viewportBlockArea.setCTM(absoluteCTM);
viewportBlockArea.setClip(needClip());
-if (abProps.absolutePosition == EN_ABSOLUTE
-|| abProps.absolutePosition == EN_FIXED) {
+
+// PATCH START - FOP-2731 Using the page as reference for fixed
positioning
+
+//if (abProps.absolutePosition == EN_ABSOLUTE
+//|| abProps.absolutePosition == EN_FIXED) {
+//Point offset = getAbsOffset();
+//viewportBlockArea.setXOffset(offset.x);
+//viewportBlockArea.setYOffset(offset.y);
+//} else {
+////nop
+//}
+if (abProps.absolutePosition == EN_ABSOLUTE) {
Point offset = getAbsOffset();
viewportBlockArea.setXOffset(offset.x);
viewportBlockArea.setYOffset(offset.y);
+} else if (abProps.absolutePosition == EN_FIXED) {
+Point offset = getFixedOffset();
+viewportBlockArea.setXOffset(offset.x);
+viewportBlockArea.setYOffset(offset.y);
} else {
//nop
}
+// PATCH END
referenceArea = new Block();
referenceArea.addTrait(Trait.IS_REFERENCE_AREA, Boolean.TRUE);
{code}
> Position:fixed uses a bad reference area
>
>
> Key: FOP-2731
> URL: https://issues.apache.org/jira/browse/FOP-2731
> Project: FOP
> Issue Type: Bug
> Components: layout/block
>Affects Versions: 2.2
>Reporter: Dan Caprioara
> Attachments: position-fixed-bad-reference-area.png
>
>
> When trying to place some elements to the corners of the page, it seems that
> FOP uses some wrong dimensions. Take a look at the attached screenshot,
> showing the difference between FOP and AntennaHouse.
> {code}
>
> xml:lang="dflt"
> xmlns:css="http://www.w3.org/1998/CSS;
> xmlns:fo="http://www.w3.org/1999/XSL/Format;>
>
>
> master-name="css2fo-default">
>
> blank-or-not-blank="any"
> master-reference="spm-css2fo-default"
> odd-or-even="any"
> page-position="any"/>
>
>
> master-name="spm-css2fo-default"
> page-height="8.27in"
> page-width="5.83in">
> border-bottom-color="orange"
> border-bottom-style="solid"
> border-bottom-width="2pt"
> border-left-color="orange"
>