| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2007 Alp Toker <alp@atoker.com> | 2 * Copyright (C) 2007 Alp Toker <alp@atoker.com> |
| 3 * Copyright (C) 2007 Apple Inc. | 3 * Copyright (C) 2007 Apple Inc. |
| 4 * | 4 * |
| 5 * This library is free software; you can redistribute it and/or | 5 * This library is free software; you can redistribute it and/or |
| 6 * modify it under the terms of the GNU Library General Public | 6 * modify it under the terms of the GNU Library General Public |
| 7 * License as published by the Free Software Foundation; either | 7 * License as published by the Free Software Foundation; either |
| 8 * version 2 of the License, or (at your option) any later version. | 8 * version 2 of the License, or (at your option) any later version. |
| 9 * | 9 * |
| 10 * This library is distributed in the hope that it will be useful, | 10 * This library is distributed in the hope that it will be useful, |
| (...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 181 | 181 |
| 182 while (object && !object->isBoxModelObject()) | 182 while (object && !object->isBoxModelObject()) |
| 183 object = object->parent(); | 183 object = object->parent(); |
| 184 if (!object) | 184 if (!object) |
| 185 return nullptr; | 185 return nullptr; |
| 186 return toLayoutBoxModelObject(object); | 186 return toLayoutBoxModelObject(object); |
| 187 } | 187 } |
| 188 | 188 |
| 189 int PrintContext::pageNumberForElement(Element* element, const FloatSize& pageSi
zeInPixels) | 189 int PrintContext::pageNumberForElement(Element* element, const FloatSize& pageSi
zeInPixels) |
| 190 { | 190 { |
| 191 element->document().updateLayout(); | 191 element->document().updateStyleAndLayout(); |
| 192 | 192 |
| 193 LayoutBoxModelObject* box = enclosingBoxModelObject(element->layoutObject())
; | 193 LayoutBoxModelObject* box = enclosingBoxModelObject(element->layoutObject())
; |
| 194 if (!box) | 194 if (!box) |
| 195 return -1; | 195 return -1; |
| 196 | 196 |
| 197 LocalFrame* frame = element->document().frame(); | 197 LocalFrame* frame = element->document().frame(); |
| 198 FloatRect pageRect(FloatPoint(0, 0), pageSizeInPixels); | 198 FloatRect pageRect(FloatPoint(0, 0), pageSizeInPixels); |
| 199 PrintContext printContext(frame); | 199 PrintContext printContext(frame); |
| 200 printContext.begin(pageRect.width(), pageRect.height()); | 200 printContext.begin(pageRect.width(), pageRect.height()); |
| 201 FloatSize scaledPageSize = pageSizeInPixels; | 201 FloatSize scaledPageSize = pageSizeInPixels; |
| (...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 295 { | 295 { |
| 296 IntSize pageSize(width, height); | 296 IntSize pageSize(width, height); |
| 297 frame->document()->pageSizeAndMarginsInPixels(pageNumber, pageSize, marginTo
p, marginRight, marginBottom, marginLeft); | 297 frame->document()->pageSizeAndMarginsInPixels(pageNumber, pageSize, marginTo
p, marginRight, marginBottom, marginLeft); |
| 298 | 298 |
| 299 return "(" + String::number(pageSize.width()) + ", " + String::number(pageSi
ze.height()) + ") " + | 299 return "(" + String::number(pageSize.width()) + ", " + String::number(pageSi
ze.height()) + ") " + |
| 300 String::number(marginTop) + ' ' + String::number(marginRight) + ' ' + St
ring::number(marginBottom) + ' ' + String::number(marginLeft); | 300 String::number(marginTop) + ' ' + String::number(marginRight) + ' ' + St
ring::number(marginBottom) + ' ' + String::number(marginLeft); |
| 301 } | 301 } |
| 302 | 302 |
| 303 int PrintContext::numberOfPages(LocalFrame* frame, const FloatSize& pageSizeInPi
xels) | 303 int PrintContext::numberOfPages(LocalFrame* frame, const FloatSize& pageSizeInPi
xels) |
| 304 { | 304 { |
| 305 frame->document()->updateLayout(); | 305 frame->document()->updateStyleAndLayout(); |
| 306 | 306 |
| 307 FloatRect pageRect(FloatPoint(0, 0), pageSizeInPixels); | 307 FloatRect pageRect(FloatPoint(0, 0), pageSizeInPixels); |
| 308 PrintContext printContext(frame); | 308 PrintContext printContext(frame); |
| 309 printContext.begin(pageRect.width(), pageRect.height()); | 309 printContext.begin(pageRect.width(), pageRect.height()); |
| 310 // Account for shrink-to-fit. | 310 // Account for shrink-to-fit. |
| 311 FloatSize scaledPageSize = pageSizeInPixels; | 311 FloatSize scaledPageSize = pageSizeInPixels; |
| 312 scaledPageSize.scale(frame->view()->contentsSize().width() / pageRect.width(
)); | 312 scaledPageSize.scale(frame->view()->contentsSize().width() / pageRect.width(
)); |
| 313 printContext.computePageRectsWithPageSize(scaledPageSize); | 313 printContext.computePageRectsWithPageSize(scaledPageSize); |
| 314 return printContext.pageCount(); | 314 return printContext.pageCount(); |
| 315 } | 315 } |
| 316 | 316 |
| 317 DEFINE_TRACE(PrintContext) | 317 DEFINE_TRACE(PrintContext) |
| 318 { | 318 { |
| 319 visitor->trace(m_frame); | 319 visitor->trace(m_frame); |
| 320 visitor->trace(m_linkedDestinations); | 320 visitor->trace(m_linkedDestinations); |
| 321 } | 321 } |
| 322 | 322 |
| 323 } // namespace blink | 323 } // namespace blink |
| OLD | NEW |