Commit 4a9e4e47 authored by wangxianzhu's avatar wangxianzhu Committed by Commit bot

Treat zero-width collapsed borders as invisible

We have fast-path for invisible collapsed borders. Treating zero-
width as invisible can improve performance in the case.

Also move core/style/CollapsedBorderValue.h to core/layout because
the structure is not used by any style code.

This CL will reduce frame time of PerformanceTests/Mutation/background-change-with-zero-width-collapsed-borders.html (in
https://codereview.chromium.org/2842313002/) by about 50%.

Review-Url: https://codereview.chromium.org/2842323002
Cr-Commit-Position: refs/heads/master@{#467741}
parent e1fa8fc5
...@@ -14,6 +14,7 @@ blink_core_sources("layout") { ...@@ -14,6 +14,7 @@ blink_core_sources("layout") {
"BidiRun.h", "BidiRun.h",
"BidiRunForLine.cpp", "BidiRunForLine.cpp",
"BidiRunForLine.h", "BidiRunForLine.h",
"CollapsedBorderValue.h",
"ColumnBalancer.cpp", "ColumnBalancer.cpp",
"ColumnBalancer.h", "ColumnBalancer.h",
"ContentChangeType.h", "ContentChangeType.h",
......
...@@ -30,10 +30,21 @@ ...@@ -30,10 +30,21 @@
namespace blink { namespace blink {
enum EBorderPrecedence {
kBorderPrecedenceOff,
kBorderPrecedenceTable,
kBorderPrecedenceColumnGroup,
kBorderPrecedenceColumn,
kBorderPrecedenceRowGroup,
kBorderPrecedenceRow,
kBorderPrecedenceCell
};
class CollapsedBorderValue { class CollapsedBorderValue {
DISALLOW_NEW_EXCEPT_PLACEMENT_NEW(); DISALLOW_NEW_EXCEPT_PLACEMENT_NEW();
public: public:
// Constructs a CollapsedBorderValue for non-existence border.
CollapsedBorderValue() CollapsedBorderValue()
: color_(0), : color_(0),
width_(0), width_(0),
...@@ -48,7 +59,9 @@ class CollapsedBorderValue { ...@@ -48,7 +59,9 @@ class CollapsedBorderValue {
width_(border.NonZero() ? border.Width() : 0), width_(border.NonZero() ? border.Width() : 0),
style_(border.Style()), style_(border.Style()),
precedence_(precedence), precedence_(precedence),
transparent_(border.IsTransparent()) {} transparent_(border.IsTransparent()) {
DCHECK(precedence != kBorderPrecedenceOff);
}
unsigned Width() const { return style_ > kBorderStyleHidden ? width_ : 0; } unsigned Width() const { return style_ > kBorderStyleHidden ? width_ : 0; }
EBorderStyle Style() const { return static_cast<EBorderStyle>(style_); } EBorderStyle Style() const { return static_cast<EBorderStyle>(style_); }
...@@ -71,9 +84,7 @@ class CollapsedBorderValue { ...@@ -71,9 +84,7 @@ class CollapsedBorderValue {
IsSameIgnoringColor(o); IsSameIgnoringColor(o);
} }
bool IsVisible() const { bool IsVisible() const { return Width() && !IsTransparent(); }
return Style() > kBorderStyleHidden && !IsTransparent() && Exists();
}
bool ShouldPaint( bool ShouldPaint(
const CollapsedBorderValue& table_current_border_value) const { const CollapsedBorderValue& table_current_border_value) const {
......
...@@ -29,8 +29,8 @@ ...@@ -29,8 +29,8 @@
#include <memory> #include <memory>
#include "core/CSSPropertyNames.h" #include "core/CSSPropertyNames.h"
#include "core/CoreExport.h" #include "core/CoreExport.h"
#include "core/layout/CollapsedBorderValue.h"
#include "core/layout/LayoutBlock.h" #include "core/layout/LayoutBlock.h"
#include "core/style/CollapsedBorderValue.h"
#include "platform/wtf/Vector.h" #include "platform/wtf/Vector.h"
namespace blink { namespace blink {
......
...@@ -29,13 +29,13 @@ ...@@ -29,13 +29,13 @@
#include "core/css/StylePropertySet.h" #include "core/css/StylePropertySet.h"
#include "core/editing/EditingUtilities.h" #include "core/editing/EditingUtilities.h"
#include "core/html/HTMLTableCellElement.h" #include "core/html/HTMLTableCellElement.h"
#include "core/layout/CollapsedBorderValue.h"
#include "core/layout/LayoutAnalyzer.h" #include "core/layout/LayoutAnalyzer.h"
#include "core/layout/LayoutTableCol.h" #include "core/layout/LayoutTableCol.h"
#include "core/layout/SubtreeLayoutScope.h" #include "core/layout/SubtreeLayoutScope.h"
#include "core/paint/ObjectPaintInvalidator.h" #include "core/paint/ObjectPaintInvalidator.h"
#include "core/paint/PaintLayer.h" #include "core/paint/PaintLayer.h"
#include "core/paint/TableCellPainter.h" #include "core/paint/TableCellPainter.h"
#include "core/style/CollapsedBorderValue.h"
#include "platform/geometry/FloatQuad.h" #include "platform/geometry/FloatQuad.h"
#include "platform/geometry/TransformState.h" #include "platform/geometry/TransformState.h"
#include "platform/wtf/PtrUtil.h" #include "platform/wtf/PtrUtil.h"
......
...@@ -5,7 +5,6 @@ ...@@ -5,7 +5,6 @@
#ifndef TableCellPainter_h #ifndef TableCellPainter_h
#define TableCellPainter_h #define TableCellPainter_h
#include "core/style/CollapsedBorderValue.h"
#include "platform/graphics/paint/DisplayItem.h" #include "platform/graphics/paint/DisplayItem.h"
#include "platform/wtf/Allocator.h" #include "platform/wtf/Allocator.h"
......
...@@ -4,9 +4,9 @@ ...@@ -4,9 +4,9 @@
#include "core/paint/TablePainter.h" #include "core/paint/TablePainter.h"
#include "core/layout/CollapsedBorderValue.h"
#include "core/layout/LayoutTable.h" #include "core/layout/LayoutTable.h"
#include "core/layout/LayoutTableSection.h" #include "core/layout/LayoutTableSection.h"
#include "core/style/CollapsedBorderValue.h"
#include "core/paint/BoxClipper.h" #include "core/paint/BoxClipper.h"
#include "core/paint/BoxPainter.h" #include "core/paint/BoxPainter.h"
#include "core/paint/LayoutObjectDrawingRecorder.h" #include "core/paint/LayoutObjectDrawingRecorder.h"
......
...@@ -21,7 +21,6 @@ blink_core_sources("rendering") { ...@@ -21,7 +21,6 @@ blink_core_sources("rendering") {
"CachedUAStyle.h", "CachedUAStyle.h",
"ClipPathOperation.cpp", "ClipPathOperation.cpp",
"ClipPathOperation.h", "ClipPathOperation.h",
"CollapsedBorderValue.h",
"ComputedStyle.cpp", "ComputedStyle.cpp",
"ComputedStyle.h", "ComputedStyle.h",
"ComputedStyleConstants.h", "ComputedStyleConstants.h",
......
...@@ -106,16 +106,6 @@ enum EBorderStyle { ...@@ -106,16 +106,6 @@ enum EBorderStyle {
kBorderStyleDouble kBorderStyleDouble
}; };
enum EBorderPrecedence {
kBorderPrecedenceOff,
kBorderPrecedenceTable,
kBorderPrecedenceColumnGroup,
kBorderPrecedenceColumn,
kBorderPrecedenceRowGroup,
kBorderPrecedenceRow,
kBorderPrecedenceCell
};
enum OutlineIsAuto { kOutlineIsAutoOff = 0, kOutlineIsAutoOn }; enum OutlineIsAuto { kOutlineIsAutoOff = 0, kOutlineIsAutoOn };
enum EMarginCollapse { enum EMarginCollapse {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment