Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(117)

Side by Side Diff: Source/core/page/PrintContext.cpp

Issue 1172463002: Fix print context to work under slimming paint. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Remove unnecessary RuntimeEnabledFeatures include. Created 5 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « Source/core/page/PrintContext.h ('k') | Source/core/page/PrintContextTest.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Library General Public License for more details. 13 * Library General Public License for more details.
14 * 14 *
15 * You should have received a copy of the GNU Library General Public License 15 * You should have received a copy of the GNU Library General Public License
16 * along with this library; see the file COPYING.LIB. If not, write to 16 * along with this library; see the file COPYING.LIB. If not, write to
17 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 17 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
18 * Boston, MA 02110-1301, USA. 18 * Boston, MA 02110-1301, USA.
19 */ 19 */
20 20
21 #include "config.h" 21 #include "config.h"
22 #include "core/page/PrintContext.h" 22 #include "core/page/PrintContext.h"
23 23
24 #include "core/frame/FrameView.h" 24 #include "core/frame/FrameView.h"
25 #include "core/frame/LocalFrame.h" 25 #include "core/frame/LocalFrame.h"
26 #include "core/layout/LayoutView.h" 26 #include "core/layout/LayoutView.h"
27 #include "platform/graphics/GraphicsContext.h" 27 #include "third_party/skia/include/core/SkAnnotation.h"
28 28
29 namespace blink { 29 namespace blink {
30 30
31 // By imaging to a width a little wider than the available pixels, 31 // By imaging to a width a little wider than the available pixels,
32 // thin pages will be scaled down a little, matching the way they 32 // thin pages will be scaled down a little, matching the way they
33 // print in IE and Camino. This lets them use fewer sheets than they 33 // print in IE and Camino. This lets them use fewer sheets than they
34 // would otherwise, which is presumably why other browsers do this. 34 // would otherwise, which is presumably why other browsers do this.
35 // Wide pages will be scaled down more than this. 35 // Wide pages will be scaled down more than this.
36 const float printingMinimumShrinkFactor = 1.25f; 36 const float printingMinimumShrinkFactor = 1.25f;
37 37
(...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after
223 if (!url.isValid()) 223 if (!url.isValid())
224 return; 224 return;
225 225
226 if (url.hasFragmentIdentifier() && equalIgnoringFragmentIdentifier(url, node ->document().baseURL())) { 226 if (url.hasFragmentIdentifier() && equalIgnoringFragmentIdentifier(url, node ->document().baseURL())) {
227 String name = url.fragmentIdentifier(); 227 String name = url.fragmentIdentifier();
228 if (Element* element = node->document().findAnchor(name)) 228 if (Element* element = node->document().findAnchor(name))
229 m_linkedDestinations.set(name, element); 229 m_linkedDestinations.set(name, element);
230 } 230 }
231 } 231 }
232 232
233 void PrintContext::outputLinkedDestinations(GraphicsContext& graphicsContext, co nst IntRect& pageRect) 233 void PrintContext::outputLinkedDestinations(SkCanvas* canvas, const IntRect& pag eRect)
234 { 234 {
235 if (!m_linkedDestinationsValid) { 235 if (!m_linkedDestinationsValid) {
236 // Collect anchors in the top-level frame only because our PrintContext 236 // Collect anchors in the top-level frame only because our PrintContext
237 // supports only one namespace for the anchors. 237 // supports only one namespace for the anchors.
238 collectLinkedDestinations(frame()->document()); 238 collectLinkedDestinations(frame()->document());
239 m_linkedDestinationsValid = true; 239 m_linkedDestinationsValid = true;
240 } 240 }
241 241
242 for (const auto& entry : m_linkedDestinations) { 242 for (const auto& entry : m_linkedDestinations) {
243 LayoutObject* layoutObject = entry.value->layoutObject(); 243 LayoutObject* layoutObject = entry.value->layoutObject();
244 if (!layoutObject || !layoutObject->frameView()) 244 if (!layoutObject || !layoutObject->frameView())
245 continue; 245 continue;
246 IntRect boundingBox = layoutObject->absoluteBoundingBoxRect(); 246 IntRect boundingBox = layoutObject->absoluteBoundingBoxRect();
247 boundingBox = layoutObject->frameView()->convertToContainingWindow(bound ingBox); 247 boundingBox = layoutObject->frameView()->convertToContainingWindow(bound ingBox);
248 if (!pageRect.intersects(boundingBox)) 248 if (!pageRect.intersects(boundingBox))
249 continue; 249 continue;
250 IntPoint point = boundingBox.minXMinYCorner(); 250 IntPoint point = boundingBox.minXMinYCorner();
251 point.clampNegativeToZero(); 251 point.clampNegativeToZero();
252 graphicsContext.addURLTargetAtPoint(entry.key, point); 252 SkAutoDataUnref nameData(SkData::NewWithCString(entry.key.utf8().data()) );
253 SkAnnotateNamedDestination(canvas, SkPoint::Make(point.x(), point.y()), nameData);
253 } 254 }
254 } 255 }
255 256
256 String PrintContext::pageProperty(LocalFrame* frame, const char* propertyName, i nt pageNumber) 257 String PrintContext::pageProperty(LocalFrame* frame, const char* propertyName, i nt pageNumber)
257 { 258 {
258 Document* document = frame->document(); 259 Document* document = frame->document();
259 PrintContext printContext(frame); 260 PrintContext printContext(frame);
260 printContext.begin(800); // Any width is OK here. 261 printContext.begin(800); // Any width is OK here.
261 document->updateLayout(); 262 document->updateLayout();
262 RefPtr<ComputedStyle> style = document->styleForPage(pageNumber); 263 RefPtr<ComputedStyle> style = document->styleForPage(pageNumber);
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
309 310
310 DEFINE_TRACE(PrintContext) 311 DEFINE_TRACE(PrintContext)
311 { 312 {
312 #if ENABLE(OILPAN) 313 #if ENABLE(OILPAN)
313 visitor->trace(m_frame); 314 visitor->trace(m_frame);
314 visitor->trace(m_linkedDestinations); 315 visitor->trace(m_linkedDestinations);
315 #endif 316 #endif
316 } 317 }
317 318
318 } 319 }
OLDNEW
« no previous file with comments | « Source/core/page/PrintContext.h ('k') | Source/core/page/PrintContextTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698