summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorwangxianzhu <wangxianzhu@chromium.org>2016-09-21 05:28:46 (GMT)
committerCommit bot <commit-bot@chromium.org>2016-09-21 05:30:25 (GMT)
commit0c24cf8e3e453ac71f0c0a17988a887550ae7d01 (patch)
tree1454904062cd2850d15db7d1d7fbc94271bcf153
parent27bac7b1a96717471167acd71d9d8aa5624fa904 (diff)
downloadchromium-0c24cf8e3e453ac71f0c0a17988a887550ae7d01.tar.gz
chromium-0c24cf8e3e453ac71f0c0a17988a887550ae7d01.tar.xz
Fix caret invalidation in slimmingPaintInvalidation path
TEST=paint/invalidation/caret-color.html BUG=646176 CQ_INCLUDE_TRYBOTS=master.tryserver.chromium.linux:linux_layout_tests_slimming_paint_v2 Review-Url: https://codereview.chromium.org/2354023002 Cr-Commit-Position: refs/heads/master@{#419978}
-rw-r--r--third_party/WebKit/Source/core/layout/LayoutBlock.cpp14
-rw-r--r--third_party/WebKit/Source/core/layout/LayoutBlock.h1
-rw-r--r--third_party/WebKit/Source/core/paint/BUILD.gn2
-rw-r--r--third_party/WebKit/Source/core/paint/BlockPaintInvalidator.cpp27
-rw-r--r--third_party/WebKit/Source/core/paint/BlockPaintInvalidator.h31
5 files changed, 68 insertions, 7 deletions
diff --git a/third_party/WebKit/Source/core/layout/LayoutBlock.cpp b/third_party/WebKit/Source/core/layout/LayoutBlock.cpp
index 9d659ad..10fcc06 100644
--- a/third_party/WebKit/Source/core/layout/LayoutBlock.cpp
+++ b/third_party/WebKit/Source/core/layout/LayoutBlock.cpp
@@ -32,7 +32,6 @@
#include "core/editing/EditingUtilities.h"
#include "core/editing/FrameSelection.h"
#include "core/frame/FrameView.h"
-#include "core/frame/LocalFrame.h"
#include "core/frame/Settings.h"
#include "core/html/HTMLMarqueeElement.h"
#include "core/layout/HitTestLocation.h"
@@ -50,6 +49,7 @@
#include "core/layout/api/LineLayoutItem.h"
#include "core/layout/line/InlineTextBox.h"
#include "core/page/Page.h"
+#include "core/paint/BlockPaintInvalidator.h"
#include "core/paint/BlockPainter.h"
#include "core/paint/ObjectPaintInvalidator.h"
#include "core/paint/PaintLayer.h"
@@ -930,12 +930,12 @@ void LayoutBlock::removePositionedObject(LayoutBox* o)
PaintInvalidationReason LayoutBlock::invalidatePaintIfNeeded(const PaintInvalidationState& paintInvalidationState)
{
- PaintInvalidationReason reason = LayoutBox::invalidatePaintIfNeeded(paintInvalidationState);
- if (reason != PaintInvalidationNone && hasCaret()) {
- frame()->selection().setCaretRectNeedsUpdate();
- frame()->selection().invalidateCaretRect(true);
- }
- return reason;
+ return LayoutBox::invalidatePaintIfNeeded(paintInvalidationState);
+}
+
+PaintInvalidationReason LayoutBlock::invalidatePaintIfNeeded(const PaintInvalidatorContext& context) const
+{
+ return BlockPaintInvalidator(*this, context).invalidatePaintIfNeeded();
}
void LayoutBlock::removePositionedObjects(LayoutBlock* o, ContainingBlockState containingBlockState)
diff --git a/third_party/WebKit/Source/core/layout/LayoutBlock.h b/third_party/WebKit/Source/core/layout/LayoutBlock.h
index 723e398..a4322dd 100644
--- a/third_party/WebKit/Source/core/layout/LayoutBlock.h
+++ b/third_party/WebKit/Source/core/layout/LayoutBlock.h
@@ -364,6 +364,7 @@ public:
protected:
PaintInvalidationReason invalidatePaintIfNeeded(const PaintInvalidationState&) override;
+ PaintInvalidationReason invalidatePaintIfNeeded(const PaintInvalidatorContext&) const override;
private:
LayoutRect localCaretRect(InlineBox*, int caretOffset, LayoutUnit* extraWidthToEndOfLine = nullptr) final;
diff --git a/third_party/WebKit/Source/core/paint/BUILD.gn b/third_party/WebKit/Source/core/paint/BUILD.gn
index 93a4ef0..c20c9b5 100644
--- a/third_party/WebKit/Source/core/paint/BUILD.gn
+++ b/third_party/WebKit/Source/core/paint/BUILD.gn
@@ -13,6 +13,8 @@ blink_core_sources("paint") {
"BlockFlowPaintInvalidator.h",
"BlockFlowPainter.cpp",
"BlockFlowPainter.h",
+ "BlockPaintInvalidator.cpp",
+ "BlockPaintInvalidator.h",
"BlockPainter.cpp",
"BlockPainter.h",
"BoxBorderPainter.cpp",
diff --git a/third_party/WebKit/Source/core/paint/BlockPaintInvalidator.cpp b/third_party/WebKit/Source/core/paint/BlockPaintInvalidator.cpp
new file mode 100644
index 0000000..0819969
--- /dev/null
+++ b/third_party/WebKit/Source/core/paint/BlockPaintInvalidator.cpp
@@ -0,0 +1,27 @@
+// Copyright 2016 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "core/paint/BlockPaintInvalidator.h"
+
+#include "core/editing/FrameSelection.h"
+#include "core/frame/LocalFrame.h"
+#include "core/layout/LayoutBlock.h"
+#include "core/paint/BoxPaintInvalidator.h"
+#include "core/paint/PaintInvalidator.h"
+
+namespace blink {
+
+PaintInvalidationReason BlockPaintInvalidator::invalidatePaintIfNeeded()
+{
+ PaintInvalidationReason reason = BoxPaintInvalidator(m_block, m_context).invalidatePaintIfNeeded();
+
+ if (reason != PaintInvalidationNone && m_block.hasCaret()) {
+ FrameSelection& selection = m_block.frame()->selection();
+ selection.setCaretRectNeedsUpdate();
+ selection.invalidateCaretRect(true);
+ }
+ return reason;
+}
+
+}
diff --git a/third_party/WebKit/Source/core/paint/BlockPaintInvalidator.h b/third_party/WebKit/Source/core/paint/BlockPaintInvalidator.h
new file mode 100644
index 0000000..8625a56
--- /dev/null
+++ b/third_party/WebKit/Source/core/paint/BlockPaintInvalidator.h
@@ -0,0 +1,31 @@
+// Copyright 2016 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef BlockPaintInvalidator_h
+#define BlockPaintInvalidator_h
+
+#include "platform/graphics/PaintInvalidationReason.h"
+#include "wtf/Allocator.h"
+
+namespace blink {
+
+struct PaintInvalidatorContext;
+class LayoutBlock;
+
+class BlockPaintInvalidator {
+ STACK_ALLOCATED();
+public:
+ BlockPaintInvalidator(const LayoutBlock& block, const PaintInvalidatorContext& context)
+ : m_block(block), m_context(context) { }
+
+ PaintInvalidationReason invalidatePaintIfNeeded();
+
+private:
+ const LayoutBlock& m_block;
+ const PaintInvalidatorContext& m_context;
+};
+
+} // namespace blink
+
+#endif