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

Side by Side Diff: third_party/WebKit/Source/core/layout/LayoutBlock.h

Issue 2665823002: Invalidate caret during paint invalidation (Closed)
Patch Set: Rebaseline 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 /* 1 /*
2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org)
3 * (C) 1999 Antti Koivisto (koivisto@kde.org) 3 * (C) 1999 Antti Koivisto (koivisto@kde.org)
4 * (C) 2007 David Smith (catfish.man@gmail.com) 4 * (C) 2007 David Smith (catfish.man@gmail.com)
5 * Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010 Apple Inc. 5 * Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010 Apple Inc.
6 * All rights reserved. 6 * All rights reserved.
7 * 7 *
8 * This library is free software; you can redistribute it and/or 8 * This library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Library General Public 9 * modify it under the terms of the GNU Library General Public
10 * License as published by the Free Software Foundation; either 10 * License as published by the Free Software Foundation; either
(...skipping 472 matching lines...) Expand 10 before | Expand all | Expand 10 after
483 void computeBlockPreferredLogicalWidths(LayoutUnit& minLogicalWidth, 483 void computeBlockPreferredLogicalWidths(LayoutUnit& minLogicalWidth,
484 LayoutUnit& maxLogicalWidth) const; 484 LayoutUnit& maxLogicalWidth) const;
485 485
486 bool isSelectionRoot() const; 486 bool isSelectionRoot() const;
487 487
488 public: 488 public:
489 bool hasCursorCaret() const; 489 bool hasCursorCaret() const;
490 bool hasDragCaret() const; 490 bool hasDragCaret() const;
491 bool hasCaret() const { return hasCursorCaret() || hasDragCaret(); } 491 bool hasCaret() const { return hasCursorCaret() || hasDragCaret(); }
492 492
493 class MutableForPainting : public LayoutBox::MutableForPainting {
494 public:
495 void setHasPreviousCaretVisualRects(bool b) {
496 static_cast<LayoutBlock&>(m_layoutObject).m_hasPreviousCaretVisualRects =
497 b;
498 }
499
500 protected:
501 friend class LayoutBlock;
502 MutableForPainting(const LayoutBlock& layoutBlock)
503 : LayoutBox::MutableForPainting(layoutBlock) {}
504 };
505
506 MutableForPainting getMutableForPainting() const {
507 return MutableForPainting(*this);
508 }
509
510 // Called when a cursor caret or drag caret in this LayoutBlock need paint
chrishtr 2017/01/31 22:51:04 Nit: "needs"
511 // invalidation, e.g. when its color or visibility changes. When a caret
512 // just changes location, use setMayNeedPaintInvalidation() instead.
513 void setCaretsNeedPaintInvalidation() {
514 if (m_caretsNeedPaintInvalidation)
515 return;
516 m_caretsNeedPaintInvalidation = true;
517 setMayNeedPaintInvalidation();
518 }
519 bool caretsNeedPaintInvalidation() const {
520 return m_caretsNeedPaintInvalidation;
521 }
522
523 bool hasPreviousCaretVisualRects() const {
524 return m_hasPreviousCaretVisualRects;
525 }
526
493 protected: 527 protected:
494 PaintInvalidationReason invalidatePaintIfNeeded( 528 PaintInvalidationReason invalidatePaintIfNeeded(
495 const PaintInvalidationState&) override; 529 const PaintInvalidationState&) override;
496 PaintInvalidationReason invalidatePaintIfNeeded( 530 PaintInvalidationReason invalidatePaintIfNeeded(
497 const PaintInvalidatorContext&) const override; 531 const PaintInvalidatorContext&) const override;
498 532
533 void clearPaintInvalidationFlags() override {
534 LayoutBox::clearPaintInvalidationFlags();
535 m_caretsNeedPaintInvalidation = false;
536 }
537
538 void clearPreviousVisualRects() override;
539
540 #if DCHECK_IS_ON()
541 bool paintInvalidationStateIsDirty() const override {
542 return LayoutBox::paintInvalidationStateIsDirty() ||
543 m_caretsNeedPaintInvalidation;
544 }
545 #endif
546
499 private: 547 private:
500 LayoutRect localCaretRect(InlineBox*, 548 LayoutRect localCaretRect(InlineBox*,
501 int caretOffset, 549 int caretOffset,
502 LayoutUnit* extraWidthToEndOfLine = nullptr) final; 550 LayoutUnit* extraWidthToEndOfLine = nullptr) final;
503 bool isInlineBoxWrapperActuallyChild() const; 551 bool isInlineBoxWrapperActuallyChild() const;
504 552
505 Position positionForBox(InlineBox*, bool start = true) const; 553 Position positionForBox(InlineBox*, bool start = true) const;
506 554
507 // End helper functions and structs used by layoutBlockChildren. 555 // End helper functions and structs used by layoutBlockChildren.
508 556
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
545 unsigned m_hasPercentHeightDescendants : 1; 593 unsigned m_hasPercentHeightDescendants : 1;
546 594
547 // When an object ceases to establish a fragmentation context (e.g. the 595 // When an object ceases to establish a fragmentation context (e.g. the
548 // LayoutView when we're no longer printing), we need a deep layout 596 // LayoutView when we're no longer printing), we need a deep layout
549 // afterwards, to clear all pagination struts. Likewise, when an object 597 // afterwards, to clear all pagination struts. Likewise, when an object
550 // becomes fragmented, we need to re-lay out the entire subtree. There might 598 // becomes fragmented, we need to re-lay out the entire subtree. There might
551 // be forced breaks somewhere in there that we suddenly have to pay attention 599 // be forced breaks somewhere in there that we suddenly have to pay attention
552 // to, for all we know. 600 // to, for all we know.
553 unsigned m_paginationStateChanged : 1; 601 unsigned m_paginationStateChanged : 1;
554 602
603 // Indicates if we have saved previous cursor and/or drag caret visual rects
604 // for the LayoutBlock in BlockPaintInvalidator.
605 unsigned m_hasPreviousCaretVisualRects : 1;
606
607 unsigned m_caretsNeedPaintInvalidation : 1;
608
555 // FIXME: This is temporary as we move code that accesses block flow 609 // FIXME: This is temporary as we move code that accesses block flow
556 // member variables out of LayoutBlock and into LayoutBlockFlow. 610 // member variables out of LayoutBlock and into LayoutBlockFlow.
557 friend class LayoutBlockFlow; 611 friend class LayoutBlockFlow;
558 612
559 // This is necessary for now for interoperability between the old and new 613 // This is necessary for now for interoperability between the old and new
560 // layout code. Primarily for calling layoutPositionedObjects at the moment. 614 // layout code. Primarily for calling layoutPositionedObjects at the moment.
561 friend class NGBlockNode; 615 friend class NGBlockNode;
562 616
563 public: 617 public:
564 // TODO(lunalu): Temporary in order to ensure compatibility with existing 618 // TODO(lunalu): Temporary in order to ensure compatibility with existing
565 // layout test results. 619 // layout test results.
566 virtual void adjustChildDebugRect(LayoutRect&) const {} 620 virtual void adjustChildDebugRect(LayoutRect&) const {}
567 }; 621 };
568 622
569 DEFINE_LAYOUT_OBJECT_TYPE_CASTS(LayoutBlock, isLayoutBlock()); 623 DEFINE_LAYOUT_OBJECT_TYPE_CASTS(LayoutBlock, isLayoutBlock());
570 624
571 } // namespace blink 625 } // namespace blink
572 626
573 #endif // LayoutBlock_h 627 #endif // LayoutBlock_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698