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

Side by Side Diff: Source/web/WebLocalFrameImpl.cpp

Issue 1220583004: Refactor DrawingRecorders to check for cached drawings earlier (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Fix some !'s and &&'s. De Morgan would be proud. Created 5 years, 5 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) 2009 Google Inc. All rights reserved. 2 * Copyright (C) 2009 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 377 matching lines...) Expand 10 before | Expand all | Expand 10 after
388 size_t numPages = pageRects().size(); 388 size_t numPages = pageRects().size();
389 int totalHeight = numPages * (pageSizeInPixels.height() + 1) - 1; 389 int totalHeight = numPages * (pageSizeInPixels.height() + 1) - 1;
390 IntRect allPagesRect(0, 0, pageWidth, totalHeight); 390 IntRect allPagesRect(0, 0, pageWidth, totalHeight);
391 391
392 SkPictureBuilder pictureBuilder(allPagesRect, &skia::getMetaData(*canvas )); 392 SkPictureBuilder pictureBuilder(allPagesRect, &skia::getMetaData(*canvas ));
393 pictureBuilder.context().setPrinting(true); 393 pictureBuilder.context().setPrinting(true);
394 394
395 GraphicsContext& context = pictureBuilder.context(); 395 GraphicsContext& context = pictureBuilder.context();
396 396
397 // Fill the whole background by white. 397 // Fill the whole background by white.
398 { 398 if (!DrawingRecorder::useCachedDrawingIfPossible(context, *this, Display Item::PrintedContentBackground)) {
399 DrawingRecorder backgroundRecorder(context, *this, DisplayItem::Prin tedContentBackground, allPagesRect); 399 DrawingRecorder backgroundRecorder(context, *this, DisplayItem::Prin tedContentBackground, allPagesRect);
400 if (!backgroundRecorder.canUseCachedDrawing()) 400 context.fillRect(FloatRect(0, 0, pageWidth, totalHeight), Color::whi te);
401 context.fillRect(FloatRect(0, 0, pageWidth, totalHeight), Color: :white);
402 } 401 }
403 402
404 int currentHeight = 0; 403 int currentHeight = 0;
405 for (size_t pageIndex = 0; pageIndex < numPages; pageIndex++) { 404 for (size_t pageIndex = 0; pageIndex < numPages; pageIndex++) {
406 ScopeRecorder scopeRecorder(context, *this); 405 ScopeRecorder scopeRecorder(context, *this);
407 // Draw a line for a page boundary if this isn't the first page. 406 // Draw a line for a page boundary if this isn't the first page.
408 if (pageIndex > 0) { 407 if (pageIndex > 0 && !DrawingRecorder::useCachedDrawingIfPossible(co ntext, *this, DisplayItem::PrintedContentLineBoundary)) {
409 DrawingRecorder lineBoundaryRecorder(context, *this, DisplayItem ::PrintedContentLineBoundary, allPagesRect); 408 DrawingRecorder lineBoundaryRecorder(context, *this, DisplayItem ::PrintedContentLineBoundary, allPagesRect);
410 if (!lineBoundaryRecorder.canUseCachedDrawing()) { 409 context.save();
411 context.save(); 410 context.setStrokeColor(Color(0, 0, 255));
412 context.setStrokeColor(Color(0, 0, 255)); 411 context.setFillColor(Color(0, 0, 255));
413 context.setFillColor(Color(0, 0, 255)); 412 context.drawLine(IntPoint(0, currentHeight), IntPoint(pageWidth, currentHeight));
414 context.drawLine(IntPoint(0, currentHeight), IntPoint(pageWi dth, currentHeight)); 413 context.restore();
415 context.restore();
416 }
417 } 414 }
418 415
419 AffineTransform transform; 416 AffineTransform transform;
420 transform.translate(0, currentHeight); 417 transform.translate(0, currentHeight);
421 #if OS(WIN) || OS(MACOSX) 418 #if OS(WIN) || OS(MACOSX)
422 // Account for the disabling of scaling in spoolPage. In the context 419 // Account for the disabling of scaling in spoolPage. In the context
423 // of spoolAllPagesWithBoundaries the scale HAS NOT been pre-applied . 420 // of spoolAllPagesWithBoundaries the scale HAS NOT been pre-applied .
424 float scale = getPageShrink(pageIndex); 421 float scale = getPageShrink(pageIndex);
425 transform.scale(scale, scale); 422 transform.scale(scale, scale);
426 #endif 423 #endif
(...skipping 1762 matching lines...) Expand 10 before | Expand all | Expand 10 after
2189 } 2186 }
2190 2187
2191 WebSandboxFlags WebLocalFrameImpl::effectiveSandboxFlags() const 2188 WebSandboxFlags WebLocalFrameImpl::effectiveSandboxFlags() const
2192 { 2189 {
2193 if (!frame()) 2190 if (!frame())
2194 return WebSandboxFlags::None; 2191 return WebSandboxFlags::None;
2195 return static_cast<WebSandboxFlags>(frame()->loader().effectiveSandboxFlags( )); 2192 return static_cast<WebSandboxFlags>(frame()->loader().effectiveSandboxFlags( ));
2196 } 2193 }
2197 2194
2198 } // namespace blink 2195 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698