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

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

Issue 323013004: Clean up transform methods in GraphicsContext. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: 2nd Attempt Mac build fix Created 6 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
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,
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after
171 m_frame->setPrinting(true, minLayoutSize, originalPageSize, printingMaximumS hrinkFactor / printingMinimumShrinkFactor); 171 m_frame->setPrinting(true, minLayoutSize, originalPageSize, printingMaximumS hrinkFactor / printingMinimumShrinkFactor);
172 } 172 }
173 173
174 void PrintContext::spoolPage(GraphicsContext& ctx, int pageNumber, float width) 174 void PrintContext::spoolPage(GraphicsContext& ctx, int pageNumber, float width)
175 { 175 {
176 // FIXME: Not correct for vertical text. 176 // FIXME: Not correct for vertical text.
177 IntRect pageRect = m_pageRects[pageNumber]; 177 IntRect pageRect = m_pageRects[pageNumber];
178 float scale = width / pageRect.width(); 178 float scale = width / pageRect.width();
179 179
180 ctx.save(); 180 ctx.save();
181 ctx.scale(FloatSize(scale, scale)); 181 ctx.scale(scale, scale);
182 ctx.translate(-pageRect.x(), -pageRect.y()); 182 ctx.translate(-pageRect.x(), -pageRect.y());
183 ctx.clip(pageRect); 183 ctx.clip(pageRect);
184 m_frame->view()->paintContents(&ctx, pageRect); 184 m_frame->view()->paintContents(&ctx, pageRect);
185 if (ctx.supportsURLFragments()) 185 if (ctx.supportsURLFragments())
186 outputLinkedDestinations(ctx, m_frame->document(), pageRect); 186 outputLinkedDestinations(ctx, m_frame->document(), pageRect);
187 ctx.restore(); 187 ctx.restore();
188 } 188 }
189 189
190 void PrintContext::end() 190 void PrintContext::end()
191 { 191 {
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after
347 const float pageWidth = pageSizeInPixels.width(); 347 const float pageWidth = pageSizeInPixels.width();
348 const Vector<IntRect>& pageRects = printContext.pageRects(); 348 const Vector<IntRect>& pageRects = printContext.pageRects();
349 int totalHeight = pageRects.size() * (pageSizeInPixels.height() + 1) - 1; 349 int totalHeight = pageRects.size() * (pageSizeInPixels.height() + 1) - 1;
350 350
351 // Fill the whole background by white. 351 // Fill the whole background by white.
352 graphicsContext.setFillColor(Color(255, 255, 255)); 352 graphicsContext.setFillColor(Color(255, 255, 255));
353 graphicsContext.fillRect(FloatRect(0, 0, pageWidth, totalHeight)); 353 graphicsContext.fillRect(FloatRect(0, 0, pageWidth, totalHeight));
354 354
355 graphicsContext.save(); 355 graphicsContext.save();
356 graphicsContext.translate(0, totalHeight); 356 graphicsContext.translate(0, totalHeight);
357 graphicsContext.scale(FloatSize(1, -1)); 357 graphicsContext.scale(1, -1);
358 358
359 int currentHeight = 0; 359 int currentHeight = 0;
360 for (size_t pageIndex = 0; pageIndex < pageRects.size(); pageIndex++) { 360 for (size_t pageIndex = 0; pageIndex < pageRects.size(); pageIndex++) {
361 // Draw a line for a page boundary if this isn't the first page. 361 // Draw a line for a page boundary if this isn't the first page.
362 if (pageIndex > 0) { 362 if (pageIndex > 0) {
363 graphicsContext.save(); 363 graphicsContext.save();
364 graphicsContext.setStrokeColor(Color(0, 0, 255)); 364 graphicsContext.setStrokeColor(Color(0, 0, 255));
365 graphicsContext.setFillColor(Color(0, 0, 255)); 365 graphicsContext.setFillColor(Color(0, 0, 255));
366 graphicsContext.drawLine(IntPoint(0, currentHeight), 366 graphicsContext.drawLine(IntPoint(0, currentHeight),
367 IntPoint(pageWidth, currentHeight)); 367 IntPoint(pageWidth, currentHeight));
368 graphicsContext.restore(); 368 graphicsContext.restore();
369 } 369 }
370 370
371 graphicsContext.save(); 371 graphicsContext.save();
372 graphicsContext.translate(0, currentHeight); 372 graphicsContext.translate(0, currentHeight);
373 printContext.spoolPage(graphicsContext, pageIndex, pageWidth); 373 printContext.spoolPage(graphicsContext, pageIndex, pageWidth);
374 graphicsContext.restore(); 374 graphicsContext.restore();
375 375
376 currentHeight += pageSizeInPixels.height() + 1; 376 currentHeight += pageSizeInPixels.height() + 1;
377 } 377 }
378 378
379 graphicsContext.restore(); 379 graphicsContext.restore();
380 } 380 }
381 381
382 } 382 }
OLDNEW
« no previous file with comments | « Source/core/html/canvas/CanvasRenderingContext2D.cpp ('k') | Source/core/rendering/ImageQualityController.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698