Skip to content

Commit

Permalink
Showing 5 changed files with 38 additions and 19 deletions.
Original file line number Diff line number Diff line change
@@ -125,12 +125,12 @@ public static BlockBox createRootBox(LayoutContext c, Document document) {
}

public static void createChildren(LayoutContext c, BlockBox parent) {
if (parent.isReplaced()) {

if (parent.shouldBeReplaced()) {
return;
}

List children = new ArrayList();
List children = new ArrayList();

ChildBoxInfo info = new ChildBoxInfo();

Original file line number Diff line number Diff line change
@@ -417,8 +417,12 @@ public void setStaticEquivalent(Box staticEquivalent) {
_staticEquivalent = staticEquivalent;
}

public boolean shouldBeReplaced() {
return _isReplaced;
}

public boolean isReplaced() {
return _replacedElement != null || _isReplaced;
return _replacedElement != null;
}

public void calcCanvasLocation() {
@@ -449,7 +453,7 @@ public void calcCanvasLocation() {
setAbsY(lineBox.getAbsY() + getY());
}

if (isReplaced() && getReplacedElement() != null) {
if (isReplaced()) {
Point location = getReplacedElement().getLocation();
if (location.x != getAbsX() || location.y != getAbsY()) {
getReplacedElement().setLocation(getAbsX(), getAbsY());
@@ -811,7 +815,6 @@ public void layout(LayoutContext c) {

public void layout(LayoutContext c, int contentStart) {
CalculatedStyle style = getStyle();

boolean pushedLayer = false;
if (isRoot() || style.requiresLayer()) {
pushedLayer = true;
@@ -1522,7 +1525,7 @@ public void calcMinMaxWidth(LayoutContext c) {
int width = getCSSWidth(c, true);

if (width == -1) {
if (isReplaced() && getReplacedElement() != null) {
if (getReplacedElement() != null) {
width = getReplacedElement().getIntrinsicWidth();
} else {
int height = getCSSHeight(c);
Original file line number Diff line number Diff line change
@@ -68,6 +68,11 @@ private void collect(RenderingContext c, Layer layer, DisplayListContainer dlPag
}

if (!layer.isInline() && ((BlockBox) layer.getMaster()).isReplaced()) {
if (((BlockBox) layer.getMaster()).getReplacedElement() == null) {
System.out.println(layer.getMaster().getElement().getAttribute("style"));
} else


collectReplacedElementLayer(c, layer, dlPages, pages);
} else {

@@ -175,17 +180,13 @@ private void collectLayerBackgroundAndBorder(RenderingContext c, Layer layer,
private void collectReplacedElementLayer(RenderingContext c, Layer layer,
DisplayListContainer dlPages, List<PageBox> pages) {

if (layer.getMaster() instanceof BlockBox) {
DisplayListOperation dlo = new PaintLayerBackgroundAndBorder(layer.getMaster());
int pgStart = PagedBoxCollector.findStartPage(c, layer.getMaster(), pages);
int pgEnd = PagedBoxCollector.findEndPage(c, layer.getMaster(), pages);
addItem(dlo, pgStart, pgEnd, dlPages);
}

DisplayListOperation dlo = new PaintReplacedElement((BlockBox) layer.getMaster());
DisplayListOperation dlo = new PaintLayerBackgroundAndBorder(layer.getMaster());
int pgStart = PagedBoxCollector.findStartPage(c, layer.getMaster(), pages);
int pgEnd = PagedBoxCollector.findEndPage(c, layer.getMaster(), pages);
addItem(dlo, pgStart, pgEnd, dlPages);

DisplayListOperation dlo2 = new PaintReplacedElement((BlockBox) layer.getMaster());
addItem(dlo2, pgStart, pgEnd, dlPages);
}

// Bit of a kludge here. We need to paint collapsed table borders according
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package com.openhtmltopdf.render.displaylist;

import java.awt.Point;
import java.awt.Rectangle;
import java.util.List;
import java.util.Map;

@@ -86,10 +88,25 @@ private void paintReplacedElements(RenderingContext c, List<DisplayListItem> rep
c.getOutputDevice().setClip(setClip.getSetClipShape());
} else {
BlockBox box = (BlockBox) dli;
c.getOutputDevice().paintReplacedElement(c, box);
paintReplacedElement(c, box);
}
}
}

private void paintReplacedElement(RenderingContext c, BlockBox replaced) {

Rectangle contentBounds = replaced.getContentAreaEdge(
replaced.getAbsX(), replaced.getAbsY(), c);

// Minor hack: It's inconvenient to adjust for margins, border, padding during
// layout so just do it here.
Point loc = replaced.getReplacedElement().getLocation();
if (contentBounds.x != loc.x || contentBounds.y != loc.y) {
replaced.getReplacedElement().setLocation(contentBounds.x, contentBounds.y);
}

c.getOutputDevice().paintReplacedElement(c, replaced);
}

public void paint(RenderingContext c, DisplayListPageContainer pageOperations) {
for (DisplayListOperation op : pageOperations.getOperations()) {
@@ -108,7 +125,7 @@ public void paint(RenderingContext c, DisplayListPageContainer pageOperations) {
} else if (op instanceof PaintReplacedElement) {

PaintReplacedElement dlo = (PaintReplacedElement) op;
c.getOutputDevice().paintReplacedElement(c, dlo.getMaster());
paintReplacedElement(c, dlo.getMaster());

} else if (op instanceof PaintBackgroundAndBorders) {

Original file line number Diff line number Diff line change
@@ -41,7 +41,6 @@
import com.openhtmltopdf.render.ViewportBox;
import com.openhtmltopdf.render.displaylist.DisplayListCollector;
import com.openhtmltopdf.render.displaylist.DisplayListContainer;
import com.openhtmltopdf.render.displaylist.DisplayListOperation;
import com.openhtmltopdf.render.displaylist.DisplayListPainter;
import com.openhtmltopdf.render.displaylist.DisplayListContainer.DisplayListPageContainer;
import com.openhtmltopdf.resource.XMLResource;
@@ -491,7 +490,6 @@ public void createPDF(OutputStream os, boolean finish, int initialPageNo) throws
* - inline-blocks
* - hidden overflow
* - transforms
* - fine positioning of replaced elements.
* - debugging everything
*/
public void createPdfFast(boolean finish) throws IOException {

0 comments on commit dc764cd

Please sign in to comment.