[jira] [Commented] (FOP-2731) Position:fixed uses a bad reference area
[ https://issues.apache.org/jira/browse/FOP-2731?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16617441#comment-16617441 ] Dan Caprioara commented on FOP-2731: Added the XSL-FO file and the patch. I am not sure how/were to create a testcase. > 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 >Priority: Major > Attachments: fop.patch, position-fixed-bad-reference-area.png, > position.fo > > > 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" > border-left-style="solid" > border-left-width="2pt" > border-right-color="orange" > border-right-style="solid" > border-right-width="2pt" > border-top-color="orange" > border-top-style="solid" > border-top-width="2pt" > margin-bottom="1in" > margin-left="1in" > margin-right="1in" > margin-top="1in"/> > extent="1in" > region-name="sc-before"/> > extent="1in" > region-name="sc-after"/> > extent="1in" > region-name="sc-start"/> > extent="1in" > region-name="sc-end"/> > > > > xmlns:x="adobe:ns:meta/"> > xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#;> > > xmlns:xmp="http://ns.adobe.com/xap/1.0/;>oXygen PDF > Chemistry > > > > > force-page-count="no-force" > id="last-page-sequence" > line-height-shift-adjustment="disregard-shifts" > master-reference="css2fo-default"> > flow-name="xsl-region-body"> > font-family="serif" > font-size="12pt"> > font-size="larger" > font-style="oblique">An element with position: fixed is > positioned relative to its > page. > 1. Normal div. > border-bottom-color="red" > border-bottom-style="solid" > border-bottom-width="3pt" > border-left-color="red" > border-left-style="solid" > border-left-width="3pt" > border-right-color="red" > border-right-style="solid" > border-right-width="3pt" > border-top-color="red" > border-top-style="solid" > border-top-width="3pt" > height="100pt" > left="10pt" > position="fixed" > top="10pt" > width="100pt"> > end-indent="0" > start-indent="0">Fixed top left. > > border-bottom-color="red" > border-bottom-style="solid" > border-bottom-width="3pt" > border-left-color="red" > border-left-style="solid" > border-left-width="3pt" > border-right-color="red" > border-right-style="solid" > border-right-width="3pt" > border-top-color="red" > border-top-style="solid" > border-top-width="3pt" >
[jira] [Commented] (FOP-2731) Position:fixed uses a bad reference area
[ https://issues.apache.org/jira/browse/FOP-2731?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16138510#comment-16138510 ] Chris Bowditch commented on FOP-2731: - Hi [~dc33], Thanks for the suggested patch. In order for this to be consider, please can you do the following: 1. Attach an XSL-FO File (not XSLT) that demonstrates the issue 2. Attach the suggested code change as a .patch or .diff file 3. Update the changes to include a Unit Test. I suggest a Layout test, since this affects the layout. Thank you > 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" > border-left-style="solid" > border-left-width="2pt" > border-right-color="orange" > border-right-style="solid" > border-right-width="2pt" > border-top-color="orange" > border-top-style="solid" > border-top-width="2pt" > margin-bottom="1in" > margin-left="1in" > margin-right="1in" > margin-top="1in"/> > extent="1in" > region-name="sc-before"/> > extent="1in" > region-name="sc-after"/> > extent="1in" > region-name="sc-start"/> > extent="1in" > region-name="sc-end"/> > > > > xmlns:x="adobe:ns:meta/"> > xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#;> > > xmlns:xmp="http://ns.adobe.com/xap/1.0/;>oXygen PDF > Chemistry > > > > > force-page-count="no-force" > id="last-page-sequence" > line-height-shift-adjustment="disregard-shifts" > master-reference="css2fo-default"> > flow-name="xsl-region-body"> > font-family="serif" > font-size="12pt"> > font-size="larger" > font-style="oblique">An element with position: fixed is > positioned relative to its > page. > 1. Normal div. > border-bottom-color="red" > border-bottom-style="solid" > border-bottom-width="3pt" > border-left-color="red" > border-left-style="solid" > border-left-width="3pt" > border-right-color="red" > border-right-style="solid" > border-right-width="3pt" > border-top-color="red" > border-top-style="solid" > border-top-width="3pt" > height="100pt" > left="10pt" > position="fixed" > top="10pt" > width="100pt"> > end-indent="0" > start-indent="0">Fixed top left. > > border-bottom-color="red" > border-bottom-style="solid" > border-bottom-width="3pt" > border-left-color="red" > border-left-style="solid" > border-left-width="3pt" > border-right-color="red" >
[jira] [Commented] (FOP-2731) Position:fixed uses a bad reference area
[ 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" >