Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file./* | 3 // found in the LICENSE file./* |
| 4 | 4 |
| 5 #include "config.h" | 5 #include "config.h" |
| 6 #include "core/editing/PositionWithAffinity.h" | 6 #include "core/editing/PositionWithAffinity.h" |
| 7 #include "core/rendering/InlineBox.h" | |
| 7 | 8 |
| 8 namespace blink { | 9 namespace blink { |
| 9 | 10 |
| 10 PositionWithAffinity::PositionWithAffinity(const Position& position, EAffinity a ffinity) | 11 PositionWithAffinity::PositionWithAffinity(const Position& position, EAffinity a ffinity) |
| 11 : m_position(position) | 12 : m_position(position) |
| 12 , m_affinity(affinity) | 13 , m_affinity(affinity) |
| 13 { | 14 { |
| 14 } | 15 } |
| 15 | 16 |
| 16 PositionWithAffinity::PositionWithAffinity() | 17 PositionWithAffinity::PositionWithAffinity() |
| 17 : m_affinity(DOWNSTREAM) | 18 : m_affinity(DOWNSTREAM) |
| 18 { | 19 { |
| 19 } | 20 } |
| 20 | 21 |
| 21 PositionWithAffinity::~PositionWithAffinity() | 22 PositionWithAffinity::~PositionWithAffinity() |
| 22 { | 23 { |
| 23 } | 24 } |
| 24 | 25 |
| 26 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
| |
| 27 { | |
| 28 if (m_position.isNull()) { | |
| 29 renderer = 0; | |
|
yosin_UTC9
2014/07/29 07:00:20
nit: Let's use |nullptr|.
yoichio
2014/07/29 08:05:17
Done.
| |
| 30 return IntRect(); | |
| 31 } | |
| 32 Node* node = m_position.anchorNode(); | |
| 33 | |
| 34 renderer = node->renderer(); | |
| 35 if (!renderer) | |
| 36 return LayoutRect(); | |
| 37 | |
| 38 InlineBox* inlineBox; | |
| 39 int caretOffset; | |
| 40 m_position.getInlineBoxAndOffset(m_affinity, inlineBox, caretOffset); | |
| 41 | |
| 42 if (inlineBox) | |
| 43 renderer = &inlineBox->renderer(); | |
| 44 | |
| 45 return renderer->localCaretRect(inlineBox, caretOffset); | |
| 46 } | |
| 47 | |
| 25 void PositionWithAffinity::trace(Visitor* visitor) | 48 void PositionWithAffinity::trace(Visitor* visitor) |
| 26 { | 49 { |
| 27 visitor->trace(m_position); | 50 visitor->trace(m_position); |
| 28 } | 51 } |
| 29 | 52 |
| 30 } // namespace blink | 53 } // namespace blink |
| OLD | NEW |