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

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: Nits 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..8a7e3e784ce2ecc7346a246527d8d9df91a5c78d 100644
--- a/Source/core/editing/Caret.cpp
+++ b/Source/core/editing/Caret.cpp
@@ -27,9 +27,11 @@
#include "core/editing/Caret.h"
#include "core/dom/Document.h"
+#include "core/editing/VisibleUnits.h"
#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,25 +132,25 @@ 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;
- LayoutRect localRect = caretPosition.localCaretRect(renderer);
+ LayoutRect localRect = localCaretRectOfPosition(caretPosition, renderer);
// 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 +170,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