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

Unified Diff: Source/core/editing/PositionWithAffinity.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/PositionWithAffinity.cpp
diff --git a/Source/core/editing/PositionWithAffinity.cpp b/Source/core/editing/PositionWithAffinity.cpp
index 668c408b2f6810f9070bb40f3bfa3a69c9de4815..4f380394e07e4294837db3775c0dd80e1dc5d631 100644
--- a/Source/core/editing/PositionWithAffinity.cpp
+++ b/Source/core/editing/PositionWithAffinity.cpp
@@ -4,6 +4,7 @@
#include "config.h"
#include "core/editing/PositionWithAffinity.h"
+#include "core/rendering/InlineBox.h"
namespace blink {
@@ -22,6 +23,28 @@ PositionWithAffinity::~PositionWithAffinity()
{
}
+LayoutRect PositionWithAffinity::localCaretRect(RenderObject*& renderer) const
yosin_UTC9 2014/07/29 07:00:20 It seems we can return just renderer and computing
yoichio 2014/07/29 08:05:17 calling localCaretRect uses local variables |inlin
+{
+ if (m_position.isNull()) {
+ renderer = 0;
yosin_UTC9 2014/07/29 07:00:20 nit: Let's use |nullptr|.
yoichio 2014/07/29 08:05:17 Done.
+ return IntRect();
+ }
+ Node* node = m_position.anchorNode();
+
+ renderer = node->renderer();
+ if (!renderer)
+ return LayoutRect();
+
+ InlineBox* inlineBox;
+ int caretOffset;
+ m_position.getInlineBoxAndOffset(m_affinity, inlineBox, caretOffset);
+
+ if (inlineBox)
+ renderer = &inlineBox->renderer();
+
+ return renderer->localCaretRect(inlineBox, caretOffset);
+}
+
void PositionWithAffinity::trace(Visitor* visitor)
{
visitor->trace(m_position);

Powered by Google App Engine
This is Rietveld 408576698