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

Side by Side Diff: third_party/WebKit/Source/core/paint/BackgroundImageGeometry.cpp

Issue 2874203002: Tweaking how background images interact with sub pixel borders. *** NOT FOR LANDING
Patch Set: Created 3 years, 7 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 | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "core/paint/BackgroundImageGeometry.h" 5 #include "core/paint/BackgroundImageGeometry.h"
6 6
7 #include "core/frame/FrameView.h" 7 #include "core/frame/FrameView.h"
8 #include "core/layout/LayoutBox.h" 8 #include "core/layout/LayoutBox.h"
9 #include "core/layout/LayoutBoxModelObject.h" 9 #include "core/layout/LayoutBoxModelObject.h"
10 #include "core/layout/LayoutTableCell.h" 10 #include "core/layout/LayoutTableCell.h"
(...skipping 449 matching lines...) Expand 10 before | Expand all | Expand 10 after
460 fixed_attachment = false; 460 fixed_attachment = false;
461 } 461 }
462 462
463 if (!fixed_attachment) { 463 if (!fixed_attachment) {
464 SetDestRect(paint_rect); 464 SetDestRect(paint_rect);
465 465
466 LayoutUnit right; 466 LayoutUnit right;
467 LayoutUnit bottom; 467 LayoutUnit bottom;
468 // Scroll and Local. 468 // Scroll and Local.
469 if (fill_layer.Origin() != kBorderFillBox) { 469 if (fill_layer.Origin() != kBorderFillBox) {
470 left = LayoutUnit(positioning_box.BorderLeft()); 470 left = LayoutUnit(positioning_box.BorderLeft().Round());
471 right = LayoutUnit(positioning_box.BorderRight()); 471 right = LayoutUnit(positioning_box.BorderRight().Round());
472 top = LayoutUnit(positioning_box.BorderTop()); 472 top = LayoutUnit(positioning_box.BorderTop().Round());
473 bottom = LayoutUnit(positioning_box.BorderBottom()); 473 bottom = LayoutUnit(positioning_box.BorderBottom().Round());
474 if (fill_layer.Origin() == kContentFillBox) { 474 if (fill_layer.Origin() == kContentFillBox) {
475 left += positioning_box.PaddingLeft(); 475 left = std::max(
476 right += positioning_box.PaddingRight(); 476 left, positioning_box.BorderLeft() + positioning_box.PaddingLeft());
477 top += positioning_box.PaddingTop(); 477 right = std::max(right, positioning_box.BorderRight() +
478 bottom += positioning_box.PaddingBottom(); 478 positioning_box.PaddingRight());
479 top = std::max(
480 top, positioning_box.BorderTop() + positioning_box.PaddingTop());
481 bottom = std::max(bottom, positioning_box.BorderBottom() +
482 positioning_box.PaddingBottom());
479 } 483 }
480 } 484 }
481 485
482 if (is_layout_view) { 486 if (is_layout_view) {
483 // The background of the box generated by the root element covers the 487 // The background of the box generated by the root element covers the
484 // entire canvas and will be painted by the view object, but the we should 488 // entire canvas and will be painted by the view object, but the we should
485 // still use the root element box for positioning. 489 // still use the root element box for positioning.
486 positioning_area.SetSize(root_box->Size()); 490 positioning_area.SetSize(root_box->Size());
487 positioning_area.ContractEdges(top, right, bottom, left); 491 positioning_area.ContractEdges(top, right, bottom, left);
488 492
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after
597 SetPhaseY(TileSize().Height() 601 SetPhaseY(TileSize().Height()
598 ? LayoutUnit(roundf(TileSize().Height() - 602 ? LayoutUnit(roundf(TileSize().Height() -
599 fmodf((computed_y_position + top), 603 fmodf((computed_y_position + top),
600 TileSize().Height()))) 604 TileSize().Height())))
601 : LayoutUnit()); 605 : LayoutUnit());
602 SetSpaceSize(LayoutSize()); 606 SetSpaceSize(LayoutSize());
603 } 607 }
604 608
605 if (background_repeat_x == kRepeatFill) { 609 if (background_repeat_x == kRepeatFill) {
606 SetRepeatX(fill_layer, fill_tile_size.Width(), available_width, 610 SetRepeatX(fill_layer, fill_tile_size.Width(), available_width,
607 unsnapped_available_width, left, offset_in_background.X()); 611 unsnapped_available_width,
612 LayoutUnit(SnapSizeToPixel(left, dest_rect_.X())),
613 offset_in_background.X());
608 } else if (background_repeat_x == kSpaceFill && 614 } else if (background_repeat_x == kSpaceFill &&
609 TileSize().Width() > LayoutUnit()) { 615 TileSize().Width() > LayoutUnit()) {
610 LayoutUnit space = GetSpaceBetweenImageTiles(positioning_area_size.Width(), 616 LayoutUnit space = GetSpaceBetweenImageTiles(positioning_area_size.Width(),
611 TileSize().Width()); 617 TileSize().Width());
612 if (space >= LayoutUnit()) 618 if (space >= LayoutUnit())
613 SetSpaceX(space, available_width, left); 619 SetSpaceX(space, available_width, left);
614 else 620 else
615 background_repeat_x = kNoRepeatFill; 621 background_repeat_x = kNoRepeatFill;
616 } 622 }
617 if (background_repeat_x == kNoRepeatFill) { 623 if (background_repeat_x == kNoRepeatFill) {
618 LayoutUnit x_offset = fill_layer.BackgroundXOrigin() == kRightEdge 624 LayoutUnit x_offset = fill_layer.BackgroundXOrigin() == kRightEdge
619 ? available_width - computed_x_position 625 ? available_width - computed_x_position
620 : computed_x_position; 626 : computed_x_position;
621 SetNoRepeatX(left + x_offset); 627 SetNoRepeatX(left + x_offset);
622 if (offset_in_background.X() > TileSize().Width()) 628 if (offset_in_background.X() > TileSize().Width())
623 SetDestRect(LayoutRect()); 629 SetDestRect(LayoutRect());
624 } 630 }
625 631
626 if (background_repeat_y == kRepeatFill) { 632 if (background_repeat_y == kRepeatFill) {
627 SetRepeatY(fill_layer, fill_tile_size.Height(), available_height, 633 SetRepeatY(fill_layer, fill_tile_size.Height(), available_height,
628 unsnapped_available_height, top, offset_in_background.Y()); 634 unsnapped_available_height,
635 LayoutUnit(SnapSizeToPixel(top, dest_rect_.Y())),
636 offset_in_background.Y());
629 } else if (background_repeat_y == kSpaceFill && 637 } else if (background_repeat_y == kSpaceFill &&
630 TileSize().Height() > LayoutUnit()) { 638 TileSize().Height() > LayoutUnit()) {
631 LayoutUnit space = GetSpaceBetweenImageTiles(positioning_area_size.Height(), 639 LayoutUnit space = GetSpaceBetweenImageTiles(positioning_area_size.Height(),
632 TileSize().Height()); 640 TileSize().Height());
633 if (space >= LayoutUnit()) 641 if (space >= LayoutUnit())
634 SetSpaceY(space, available_height, top); 642 SetSpaceY(space, available_height, top);
635 else 643 else
636 background_repeat_y = kNoRepeatFill; 644 background_repeat_y = kNoRepeatFill;
637 } 645 }
638 if (background_repeat_y == kNoRepeatFill) { 646 if (background_repeat_y == kNoRepeatFill) {
639 LayoutUnit y_offset = fill_layer.BackgroundYOrigin() == kBottomEdge 647 LayoutUnit y_offset = fill_layer.BackgroundYOrigin() == kBottomEdge
640 ? available_height - computed_y_position 648 ? available_height - computed_y_position
641 : computed_y_position; 649 : computed_y_position;
642 SetNoRepeatY(top + y_offset); 650 SetNoRepeatY(top + y_offset);
643 if (offset_in_background.Y() > TileSize().Height()) 651 if (offset_in_background.Y() > TileSize().Height())
644 SetDestRect(LayoutRect()); 652 SetDestRect(LayoutRect());
645 } 653 }
646 654
647 if (fixed_attachment) 655 if (fixed_attachment)
648 UseFixedAttachment(paint_rect.Location()); 656 UseFixedAttachment(paint_rect.Location());
649 657
650 // Clip the final output rect to the paint rect 658 // Clip the final output rect to the paint rect
651 dest_rect_.Intersect(paint_rect); 659 dest_rect_.Intersect(paint_rect);
652 660
653 // Snap as-yet unsnapped values. 661 // Snap as-yet unsnapped values.
654 SetDestRect(LayoutRect(PixelSnappedIntRect(dest_rect_))); 662 SetDestRect(LayoutRect(PixelSnappedIntRect(dest_rect_)));
655 } 663 }
656 664
657 } // namespace blink 665 } // namespace blink
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698