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

Unified Diff: Source/core/editing/Caret.cpp

Issue 429453004: Let FrameSelection::localCaretRect on a text input field avoid synchronous layout. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: fix Created 6 years, 5 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 side-by-side diff with in-line comments
Download patch
Index: Source/core/editing/Caret.cpp
diff --git a/Source/core/editing/Caret.cpp b/Source/core/editing/Caret.cpp
index e2528135ca3fb27c3eeb1a0b479d8db15507a059..ea872d215da6cffa3b9046cf12856af35c3dafe6 100644
--- a/Source/core/editing/Caret.cpp
+++ b/Source/core/editing/Caret.cpp
@@ -30,6 +30,7 @@
#include "core/editing/htmlediting.h"
#include "core/frame/LocalFrame.h"
#include "core/frame/Settings.h"
+#include "core/html/HTMLTextFormControlElement.h"
#include "core/rendering/RenderBlock.h"
#include "core/rendering/RenderView.h"
#include "platform/graphics/GraphicsContext.h"
@@ -130,17 +131,17 @@ RenderBlock* CaretBase::caretRenderer(Node* node)
return paintedByBlock ? toRenderBlock(renderer) : renderer->containingBlock();
}
-bool CaretBase::updateCaretRect(Document* document, const VisiblePosition& caretPosition)
+bool CaretBase::updateCaretRect(Document* document, const PositionWithAffinity& caretPosition)
{
document->updateRenderTreeIfNeeded();
m_caretLocalRect = LayoutRect();
m_caretRectNeedsUpdate = false;
- if (caretPosition.isNull())
+ if (caretPosition.position().isNull())
return false;
- ASSERT(caretPosition.deepEquivalent().deprecatedNode()->renderer());
+ ASSERT(caretPosition.position().deprecatedNode()->renderer());
// First compute a rect local to the renderer at the selection start.
RenderObject* renderer;
@@ -148,7 +149,7 @@ bool CaretBase::updateCaretRect(Document* document, const VisiblePosition& caret
// Get the renderer that will be responsible for painting the caret
// (which is either the renderer we just found, or one of its containers).
- RenderBlock* caretPainter = caretRenderer(caretPosition.deepEquivalent().deprecatedNode());
+ RenderBlock* caretPainter = caretRenderer(caretPosition.position().deprecatedNode());
// Compute an offset between the renderer and the caretPainter.
bool unrooted = false;
@@ -168,6 +169,11 @@ bool CaretBase::updateCaretRect(Document* document, const VisiblePosition& caret
return true;
}
+bool CaretBase::updateCaretRect(Document* document, const VisiblePosition& caretPosition)
+{
+ return updateCaretRect(document, PositionWithAffinity(caretPosition.deepEquivalent(), caretPosition.affinity()));
+}
+
RenderBlock* DragCaretController::caretRenderer() const
{
return CaretBase::caretRenderer(m_position.deepEquivalent().deprecatedNode());

Powered by Google App Engine
This is Rietveld 408576698