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

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

Issue 2640143005: Support subpixel layout for borders. (Closed)
Patch Set: Rebaselined tests. Created 3 years, 10 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 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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/BoxPaintInvalidator.h" 5 #include "core/paint/BoxPaintInvalidator.h"
6 6
7 #include "core/frame/Settings.h" 7 #include "core/frame/Settings.h"
8 #include "core/layout/LayoutView.h" 8 #include "core/layout/LayoutView.h"
9 #include "core/layout/compositing/CompositedLayerMapping.h" 9 #include "core/layout/compositing/CompositedLayerMapping.h"
10 #include "core/paint/ObjectPaintInvalidator.h" 10 #include "core/paint/ObjectPaintInvalidator.h"
(...skipping 20 matching lines...) Expand all
31 void BoxPaintInvalidator::boxWillBeDestroyed(const LayoutBox& box) { 31 void BoxPaintInvalidator::boxWillBeDestroyed(const LayoutBox& box) {
32 DCHECK(box.hasPreviousBoxGeometries() == 32 DCHECK(box.hasPreviousBoxGeometries() ==
33 previousBoxGeometriesMap().contains(&box)); 33 previousBoxGeometriesMap().contains(&box));
34 if (box.hasPreviousBoxGeometries()) 34 if (box.hasPreviousBoxGeometries())
35 previousBoxGeometriesMap().erase(&box); 35 previousBoxGeometriesMap().erase(&box);
36 } 36 }
37 37
38 static LayoutRect computeRightDelta(const LayoutPoint& location, 38 static LayoutRect computeRightDelta(const LayoutPoint& location,
39 const LayoutSize& oldSize, 39 const LayoutSize& oldSize,
40 const LayoutSize& newSize, 40 const LayoutSize& newSize,
41 int extraWidth) { 41 const LayoutUnit& extraWidth) {
42 LayoutUnit delta = newSize.width() - oldSize.width(); 42 LayoutUnit delta = newSize.width() - oldSize.width();
43 if (delta > 0) { 43 if (delta > 0) {
44 return LayoutRect(location.x() + oldSize.width() - extraWidth, location.y(), 44 return LayoutRect(location.x() + oldSize.width() - extraWidth, location.y(),
45 delta + extraWidth, newSize.height()); 45 delta + extraWidth, newSize.height());
46 } 46 }
47 if (delta < 0) { 47 if (delta < 0) {
48 return LayoutRect(location.x() + newSize.width() - extraWidth, location.y(), 48 return LayoutRect(location.x() + newSize.width() - extraWidth, location.y(),
49 -delta + extraWidth, oldSize.height()); 49 -delta + extraWidth, oldSize.height());
50 } 50 }
51 return LayoutRect(); 51 return LayoutRect();
52 } 52 }
53 53
54 static LayoutRect computeBottomDelta(const LayoutPoint& location, 54 static LayoutRect computeBottomDelta(const LayoutPoint& location,
55 const LayoutSize& oldSize, 55 const LayoutSize& oldSize,
56 const LayoutSize& newSize, 56 const LayoutSize& newSize,
57 int extraHeight) { 57 const LayoutUnit& extraHeight) {
58 LayoutUnit delta = newSize.height() - oldSize.height(); 58 LayoutUnit delta = newSize.height() - oldSize.height();
59 if (delta > 0) { 59 if (delta > 0) {
60 return LayoutRect(location.x(), 60 return LayoutRect(location.x(),
61 location.y() + oldSize.height() - extraHeight, 61 location.y() + oldSize.height() - extraHeight,
62 newSize.width(), delta + extraHeight); 62 newSize.width(), delta + extraHeight);
63 } 63 }
64 if (delta < 0) { 64 if (delta < 0) {
65 return LayoutRect(location.x(), 65 return LayoutRect(location.x(),
66 location.y() + newSize.height() - extraHeight, 66 location.y() + newSize.height() - extraHeight,
67 oldSize.width(), -delta + extraHeight); 67 oldSize.width(), -delta + extraHeight);
68 } 68 }
69 return LayoutRect(); 69 return LayoutRect();
70 } 70 }
71 71
72 bool BoxPaintInvalidator::incrementallyInvalidatePaint( 72 bool BoxPaintInvalidator::incrementallyInvalidatePaint(
73 PaintInvalidationReason reason, 73 PaintInvalidationReason reason,
74 const LayoutRect& oldRect, 74 const LayoutRect& oldRect,
75 const LayoutRect& newRect) { 75 const LayoutRect& newRect) {
76 DCHECK(oldRect.location() == newRect.location()); 76 DCHECK(oldRect.location() == newRect.location());
77 LayoutRect rightDelta = computeRightDelta( 77 LayoutRect rightDelta = computeRightDelta(
78 newRect.location(), oldRect.size(), newRect.size(), 78 newRect.location(), oldRect.size(), newRect.size(),
79 reason == PaintInvalidationIncremental ? m_box.borderRight() : 0); 79 reason == PaintInvalidationIncremental ? m_box.borderRight()
80 : LayoutUnit());
80 LayoutRect bottomDelta = computeBottomDelta( 81 LayoutRect bottomDelta = computeBottomDelta(
81 newRect.location(), oldRect.size(), newRect.size(), 82 newRect.location(), oldRect.size(), newRect.size(),
82 reason == PaintInvalidationIncremental ? m_box.borderBottom() : 0); 83 reason == PaintInvalidationIncremental ? m_box.borderBottom()
84 : LayoutUnit());
83 85
84 if (rightDelta.isEmpty() && bottomDelta.isEmpty()) 86 if (rightDelta.isEmpty() && bottomDelta.isEmpty())
85 return false; 87 return false;
86 88
87 ObjectPaintInvalidator objectPaintInvalidator(m_box); 89 ObjectPaintInvalidator objectPaintInvalidator(m_box);
88 objectPaintInvalidator.invalidatePaintUsingContainer( 90 objectPaintInvalidator.invalidatePaintUsingContainer(
89 *m_context.paintInvalidationContainer, rightDelta, reason); 91 *m_context.paintInvalidationContainer, rightDelta, reason);
90 objectPaintInvalidator.invalidatePaintUsingContainer( 92 objectPaintInvalidator.invalidatePaintUsingContainer(
91 *m_context.paintInvalidationContainer, bottomDelta, reason); 93 *m_context.paintInvalidationContainer, bottomDelta, reason);
92 return true; 94 return true;
(...skipping 286 matching lines...) Expand 10 before | Expand all | Expand 10 after
379 381
380 LayoutRect BoxPaintInvalidator::previousLayoutOverflowRect() { 382 LayoutRect BoxPaintInvalidator::previousLayoutOverflowRect() {
381 DCHECK(m_box.hasPreviousBoxGeometries() == 383 DCHECK(m_box.hasPreviousBoxGeometries() ==
382 previousBoxGeometriesMap().contains(&m_box)); 384 previousBoxGeometriesMap().contains(&m_box));
383 return m_box.hasPreviousBoxGeometries() 385 return m_box.hasPreviousBoxGeometries()
384 ? previousBoxGeometriesMap().get(&m_box).layoutOverflowRect 386 ? previousBoxGeometriesMap().get(&m_box).layoutOverflowRect
385 : LayoutRect(); 387 : LayoutRect();
386 } 388 }
387 389
388 } // namespace blink 390 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/paint/BoxBorderPainter.cpp ('k') | third_party/WebKit/Source/core/paint/BoxPainter.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698