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

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

Issue 25668008: Make Document::caretRangeFromPoint() to work with :first-letter style (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: 2013-10-07T15:30:03 Created 7 years, 2 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
« no previous file with comments | « Source/core/rendering/HitTestResult.h ('k') | Source/core/rendering/RenderText.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/rendering/HitTestResult.cpp
diff --git a/Source/core/rendering/HitTestResult.cpp b/Source/core/rendering/HitTestResult.cpp
index dc40193f2d2de9f39292485dcfc4bfd518627525..bcfcd104f1edfc33dab4c64c7c79d9e6a79867f7 100644
--- a/Source/core/rendering/HitTestResult.cpp
+++ b/Source/core/rendering/HitTestResult.cpp
@@ -43,6 +43,7 @@
#include "core/platform/Scrollbar.h"
#include "core/rendering/HitTestLocation.h"
#include "core/rendering/RenderImage.h"
+#include "core/rendering/RenderTextFragment.h"
namespace WebCore {
@@ -51,6 +52,7 @@ using namespace HTMLNames;
HitTestResult::HitTestResult()
: m_isOverWidget(false)
, m_allowPseudoElements(false)
+ , m_isFirstLetter(false)
{
}
@@ -59,12 +61,14 @@ HitTestResult::HitTestResult(const LayoutPoint& point)
, m_pointInInnerNodeFrame(point)
, m_isOverWidget(false)
, m_allowPseudoElements(false)
+ , m_isFirstLetter(false)
{
}
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)
, m_allowPseudoElements(false)
{
@@ -73,6 +77,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)
, m_allowPseudoElements(false)
{
@@ -86,6 +91,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())
, m_allowPseudoElements(other.m_allowPseudoElements)
{
@@ -106,6 +112,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();
m_allowPseudoElements |= other.m_allowPseudoElements; // Do not lose the pseudo element tracking if allowed.
@@ -115,6 +122,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()) {
« no previous file with comments | « Source/core/rendering/HitTestResult.h ('k') | Source/core/rendering/RenderText.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698