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 179 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
190 return nullptr; | 190 return nullptr; |
191 return toLayoutBoxModelObject(object); | 191 return toLayoutBoxModelObject(object); |
192 } | 192 } |
193 | 193 |
194 int PrintContext::pageNumberForElement(Element* element, const FloatSize& pageSi
zeInPixels) | 194 int PrintContext::pageNumberForElement(Element* element, const FloatSize& pageSi
zeInPixels) |
195 { | 195 { |
196 // Make sure the element is not freed during the layout. | 196 // Make sure the element is not freed during the layout. |
197 RefPtrWillBeRawPtr<Element> protect(element); | 197 RefPtrWillBeRawPtr<Element> protect(element); |
198 element->document().updateLayout(); | 198 element->document().updateLayout(); |
199 | 199 |
200 LayoutBoxModelObject* box = enclosingBoxModelObject(element->renderer()); | 200 LayoutBoxModelObject* box = enclosingBoxModelObject(element->layoutObject())
; |
201 if (!box) | 201 if (!box) |
202 return -1; | 202 return -1; |
203 | 203 |
204 LocalFrame* frame = element->document().frame(); | 204 LocalFrame* frame = element->document().frame(); |
205 FloatRect pageRect(FloatPoint(0, 0), pageSizeInPixels); | 205 FloatRect pageRect(FloatPoint(0, 0), pageSizeInPixels); |
206 PrintContext printContext(frame); | 206 PrintContext printContext(frame); |
207 printContext.begin(pageRect.width(), pageRect.height()); | 207 printContext.begin(pageRect.width(), pageRect.height()); |
208 FloatSize scaledPageSize = pageSizeInPixels; | 208 FloatSize scaledPageSize = pageSizeInPixels; |
209 scaledPageSize.scale(frame->view()->contentsSize().width() / pageRect.width(
)); | 209 scaledPageSize.scale(frame->view()->contentsSize().width() / pageRect.width(
)); |
210 printContext.computePageRectsWithPageSize(scaledPageSize, false); | 210 printContext.computePageRectsWithPageSize(scaledPageSize, false); |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
257 { | 257 { |
258 if (!m_linkAndLinkedDestinationsValid) { | 258 if (!m_linkAndLinkedDestinationsValid) { |
259 for (Frame* currentFrame = frame(); currentFrame; currentFrame = current
Frame->tree().traverseNext(frame())) { | 259 for (Frame* currentFrame = frame(); currentFrame; currentFrame = current
Frame->tree().traverseNext(frame())) { |
260 if (currentFrame->isLocalFrame()) | 260 if (currentFrame->isLocalFrame()) |
261 collectLinkAndLinkedDestinations(toLocalFrame(currentFrame)->doc
ument()); | 261 collectLinkAndLinkedDestinations(toLocalFrame(currentFrame)->doc
ument()); |
262 } | 262 } |
263 m_linkAndLinkedDestinationsValid = true; | 263 m_linkAndLinkedDestinationsValid = true; |
264 } | 264 } |
265 | 265 |
266 for (const auto& entry : m_linkDestinations) { | 266 for (const auto& entry : m_linkDestinations) { |
267 LayoutObject* renderer = entry.key->renderer(); | 267 LayoutObject* renderer = entry.key->layoutObject(); |
268 if (!renderer) | 268 if (!renderer) |
269 continue; | 269 continue; |
270 KURL url = entry.value; | 270 KURL url = entry.value; |
271 IntRect boundingBox = renderer->absoluteBoundingBoxRect(); | 271 IntRect boundingBox = renderer->absoluteBoundingBoxRect(); |
272 if (!pageRect.intersects(boundingBox)) | 272 if (!pageRect.intersects(boundingBox)) |
273 continue; | 273 continue; |
274 if (url.hasFragmentIdentifier() && equalIgnoringFragmentIdentifier(url,
renderer->document().baseURL())) { | 274 if (url.hasFragmentIdentifier() && equalIgnoringFragmentIdentifier(url,
renderer->document().baseURL())) { |
275 String name = url.fragmentIdentifier(); | 275 String name = url.fragmentIdentifier(); |
276 ASSERT(renderer->document().findAnchor(name)); | 276 ASSERT(renderer->document().findAnchor(name)); |
277 graphicsContext.setURLFragmentForRect(name, boundingBox); | 277 graphicsContext.setURLFragmentForRect(name, boundingBox); |
278 } else { | 278 } else { |
279 graphicsContext.setURLForRect(url, boundingBox); | 279 graphicsContext.setURLForRect(url, boundingBox); |
280 } | 280 } |
281 } | 281 } |
282 | 282 |
283 for (const auto& entry : m_linkedDestinations) { | 283 for (const auto& entry : m_linkedDestinations) { |
284 LayoutObject* renderer = entry.value->renderer(); | 284 LayoutObject* renderer = entry.value->layoutObject(); |
285 if (!renderer) | 285 if (!renderer) |
286 continue; | 286 continue; |
287 IntRect boundingBox = renderer->absoluteBoundingBoxRect(); | 287 IntRect boundingBox = renderer->absoluteBoundingBoxRect(); |
288 if (!pageRect.intersects(boundingBox)) | 288 if (!pageRect.intersects(boundingBox)) |
289 continue; | 289 continue; |
290 IntPoint point = boundingBox.minXMinYCorner(); | 290 IntPoint point = boundingBox.minXMinYCorner(); |
291 point.clampNegativeToZero(); | 291 point.clampNegativeToZero(); |
292 graphicsContext.addURLTargetAtPoint(entry.key, point); | 292 graphicsContext.addURLTargetAtPoint(entry.key, point); |
293 } | 293 } |
294 } | 294 } |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
350 DEFINE_TRACE(PrintContext) | 350 DEFINE_TRACE(PrintContext) |
351 { | 351 { |
352 #if ENABLE(OILPAN) | 352 #if ENABLE(OILPAN) |
353 visitor->trace(m_frame); | 353 visitor->trace(m_frame); |
354 visitor->trace(m_linkDestinations); | 354 visitor->trace(m_linkDestinations); |
355 visitor->trace(m_linkedDestinations); | 355 visitor->trace(m_linkedDestinations); |
356 #endif | 356 #endif |
357 } | 357 } |
358 | 358 |
359 } | 359 } |
OLD | NEW |