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

Unified Diff: Source/core/rendering/HitTestResult.cpp

Issue 20681004: Make first-letter style to work with editing Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: 2013-09-20T18:27:32 Created 7 years, 3 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/rendering/HitTestResult.cpp
diff --git a/Source/core/rendering/HitTestResult.cpp b/Source/core/rendering/HitTestResult.cpp
index 0feaf2437fc351ae3c6e5ce1d80e8ffdd6a20f72..685442d6644833c8b99e0e3f242964cc1672a735 100644
--- a/Source/core/rendering/HitTestResult.cpp
+++ b/Source/core/rendering/HitTestResult.cpp
@@ -43,19 +43,22 @@
#include "core/platform/Scrollbar.h"
#include "core/rendering/HitTestLocation.h"
#include "core/rendering/RenderImage.h"
+#include "core/rendering/RenderTextFragment.h"
namespace WebCore {
using namespace HTMLNames;
HitTestResult::HitTestResult()
- : m_isOverWidget(false)
+ : m_isFirstLetter(false)
+ , m_isOverWidget(false)
{
}
HitTestResult::HitTestResult(const LayoutPoint& point)
: m_hitTestLocation(point)
, m_pointInInnerNodeFrame(point)
+ , m_isFirstLetter(false)
, m_isOverWidget(false)
{
}
@@ -63,6 +66,7 @@ HitTestResult::HitTestResult(const LayoutPoint& point)
HitTestResult::HitTestResult(const LayoutPoint& centerPoint, unsigned topPadding, unsigned rightPadding, unsigned bottomPadding, unsigned leftPadding)
: m_hitTestLocation(centerPoint, topPadding, rightPadding, bottomPadding, leftPadding)
, m_pointInInnerNodeFrame(centerPoint)
+ , m_isFirstLetter(false)
, m_isOverWidget(false)
{
}
@@ -70,6 +74,7 @@ HitTestResult::HitTestResult(const LayoutPoint& centerPoint, unsigned topPadding
HitTestResult::HitTestResult(const HitTestLocation& other)
: m_hitTestLocation(other)
, m_pointInInnerNodeFrame(m_hitTestLocation.point())
+ , m_isFirstLetter(false)
, m_isOverWidget(false)
{
}
@@ -82,6 +87,7 @@ HitTestResult::HitTestResult(const HitTestResult& other)
, m_localPoint(other.localPoint())
, m_innerURLElement(other.URLElement())
, m_scrollbar(other.scrollbar())
+ , m_isFirstLetter(other.m_isFirstLetter)
, m_isOverWidget(other.isOverWidget())
{
// Only copy the NodeSet in case of rect hit test.
@@ -101,6 +107,7 @@ HitTestResult& HitTestResult::operator=(const HitTestResult& other)
m_localPoint = other.localPoint();
m_innerURLElement = other.URLElement();
m_scrollbar = other.scrollbar();
+ m_isFirstLetter = other.m_isFirstLetter;
m_isOverWidget = other.isOverWidget();
// Only copy the NodeSet in case of rect hit test.
@@ -109,6 +116,16 @@ HitTestResult& HitTestResult::operator=(const HitTestResult& other)
return *this;
}
+RenderObject* HitTestResult::renderer() const
+{
+ if (!m_innerNode)
+ return 0;
+ RenderObject* renderer = m_innerNode->renderer();
+ if (!m_isFirstLetter || !renderer || !renderer->isText() || !toRenderText(renderer)->isTextFragment())
+ return renderer;
+ return toRenderTextFragment(renderer)->firstRenderTextInFirstLetter();
+}
+
void HitTestResult::setToNodesInDocumentTreeScope()
{
if (Node* node = innerNode()) {

Powered by Google App Engine
This is Rietveld 408576698