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

Unified Diff: Source/core/editing/DOMSelection.cpp

Issue 879423003: Move Location to DOMWindow (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 5 years, 11 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/DOMSelection.cpp
diff --git a/Source/core/editing/DOMSelection.cpp b/Source/core/editing/DOMSelection.cpp
index 105c4445a2a77fb8f97943e3becce26adfca495b..5eb4b9107c532e0bfff1f84078399930841054bd 100644
--- a/Source/core/editing/DOMSelection.cpp
+++ b/Source/core/editing/DOMSelection.cpp
@@ -73,8 +73,8 @@ void DOMSelection::clearTreeScope()
const VisibleSelection& DOMSelection::visibleSelection() const
{
- ASSERT(m_frame);
- return m_frame->selection().selection();
+ ASSERT(localFrame());
+ return localFrame()->selection().selection();
}
static Position anchorPosition(const VisibleSelection& selection)
@@ -165,17 +165,17 @@ int DOMSelection::extentOffset() const
bool DOMSelection::isCollapsed() const
{
- if (!m_frame || selectionShadowAncestor(m_frame))
+ if (!localFrame() || selectionShadowAncestor(localFrame()))
return true;
- return !m_frame->selection().isRange();
+ return !localFrame()->selection().isRange();
}
String DOMSelection::type() const
{
- if (!m_frame)
+ if (!localFrame())
return String();
- FrameSelection& selection = m_frame->selection();
+ FrameSelection& selection = localFrame()->selection();
// This is a WebKit DOM extension, incompatible with an IE extension
// IE has this same attribute, but returns "none", "text" and "control"
@@ -189,18 +189,18 @@ String DOMSelection::type() const
int DOMSelection::rangeCount() const
{
- if (!m_frame)
+ if (!localFrame())
return 0;
- return m_frame->selection().isNone() ? 0 : 1;
+ return localFrame()->selection().isNone() ? 0 : 1;
}
void DOMSelection::collapse(Node* node, int offset, ExceptionState& exceptionState)
{
- if (!m_frame)
+ if (!localFrame())
return;
if (!node) {
- m_frame->selection().clear();
+ localFrame()->selection().clear();
return;
}
@@ -218,49 +218,49 @@ void DOMSelection::collapse(Node* node, int offset, ExceptionState& exceptionSta
range->setEnd(node, offset, exceptionState);
if (exceptionState.hadException())
return;
- m_frame->selection().setSelectedRange(range.get(), DOWNSTREAM, m_frame->selection().isDirectional() ? FrameSelection::Directional : FrameSelection::NonDirectional);
+ localFrame()->selection().setSelectedRange(range.get(), DOWNSTREAM, localFrame()->selection().isDirectional() ? FrameSelection::Directional : FrameSelection::NonDirectional);
}
void DOMSelection::collapseToEnd(ExceptionState& exceptionState)
{
- if (!m_frame)
+ if (!localFrame())
return;
- const VisibleSelection& selection = m_frame->selection().selection();
+ const VisibleSelection& selection = localFrame()->selection().selection();
if (selection.isNone()) {
exceptionState.throwDOMException(InvalidStateError, "there is no selection.");
return;
}
- m_frame->selection().moveTo(VisiblePosition(selection.end(), DOWNSTREAM));
+ localFrame()->selection().moveTo(VisiblePosition(selection.end(), DOWNSTREAM));
}
void DOMSelection::collapseToStart(ExceptionState& exceptionState)
{
- if (!m_frame)
+ if (!localFrame())
return;
- const VisibleSelection& selection = m_frame->selection().selection();
+ const VisibleSelection& selection = localFrame()->selection().selection();
if (selection.isNone()) {
exceptionState.throwDOMException(InvalidStateError, "there is no selection.");
return;
}
- m_frame->selection().moveTo(VisiblePosition(selection.start(), DOWNSTREAM));
+ localFrame()->selection().moveTo(VisiblePosition(selection.start(), DOWNSTREAM));
}
void DOMSelection::empty()
{
- if (!m_frame)
+ if (!localFrame())
return;
- m_frame->selection().clear();
+ localFrame()->selection().clear();
}
void DOMSelection::setBaseAndExtent(Node* baseNode, int baseOffset, Node* extentNode, int extentOffset, ExceptionState& exceptionState)
{
- if (!m_frame)
+ if (!localFrame())
return;
if (baseOffset < 0) {
@@ -280,12 +280,12 @@ void DOMSelection::setBaseAndExtent(Node* baseNode, int baseOffset, Node* extent
VisiblePosition visibleBase = VisiblePosition(createLegacyEditingPosition(baseNode, baseOffset), DOWNSTREAM);
VisiblePosition visibleExtent = VisiblePosition(createLegacyEditingPosition(extentNode, extentOffset), DOWNSTREAM);
- m_frame->selection().moveTo(visibleBase, visibleExtent);
+ localFrame()->selection().moveTo(visibleBase, visibleExtent);
}
void DOMSelection::modify(const String& alterString, const String& directionString, const String& granularityString)
{
- if (!m_frame)
+ if (!localFrame())
return;
FrameSelection::EAlteration alter;
@@ -330,14 +330,14 @@ void DOMSelection::modify(const String& alterString, const String& directionStri
else
return;
- m_frame->selection().modify(alter, direction, granularity);
+ localFrame()->selection().modify(alter, direction, granularity);
}
void DOMSelection::extend(Node* node, int offset, ExceptionState& exceptionState)
{
ASSERT(node);
- if (!m_frame)
+ if (!localFrame())
return;
if (offset < 0) {
@@ -353,12 +353,12 @@ void DOMSelection::extend(Node* node, int offset, ExceptionState& exceptionState
return;
// FIXME: Eliminate legacy editing positions
- m_frame->selection().setExtent(VisiblePosition(createLegacyEditingPosition(node, offset), DOWNSTREAM));
+ localFrame()->selection().setExtent(VisiblePosition(createLegacyEditingPosition(node, offset), DOWNSTREAM));
}
PassRefPtrWillBeRawPtr<Range> DOMSelection::getRangeAt(int index, ExceptionState& exceptionState)
{
- if (!m_frame)
+ if (!localFrame())
return nullptr;
if (index < 0 || index >= rangeCount()) {
@@ -371,7 +371,7 @@ PassRefPtrWillBeRawPtr<Range> DOMSelection::getRangeAt(int index, ExceptionState
Position anchor = anchorPosition(visibleSelection());
if (!anchor.anchorNode()->isInShadowTree())
- return m_frame->selection().firstRange();
+ return localFrame()->selection().firstRange();
if (!visibleSelection().isBaseFirst())
return Range::create(*anchor.document(), focusNode(), focusOffset(), shadowAdjustedNode(anchor), anchorOffset());
@@ -380,14 +380,14 @@ PassRefPtrWillBeRawPtr<Range> DOMSelection::getRangeAt(int index, ExceptionState
void DOMSelection::removeAllRanges()
{
- if (!m_frame)
+ if (!localFrame())
return;
- m_frame->selection().clear();
+ localFrame()->selection().clear();
}
void DOMSelection::addRange(Range* newRange)
{
- if (!m_frame)
+ if (!localFrame())
return;
// FIXME: Should we throw DOMException for error cases below?
@@ -401,7 +401,7 @@ void DOMSelection::addRange(Range* newRange)
return;
}
- FrameSelection& selection = m_frame->selection();
+ FrameSelection& selection = localFrame()->selection();
if (selection.isNone()) {
selection.setSelectedRange(newRange, VP_DEFAULT_AFFINITY);
@@ -439,10 +439,10 @@ void DOMSelection::addRange(Range* newRange)
void DOMSelection::deleteFromDocument()
{
- if (!m_frame)
+ if (!localFrame())
return;
- FrameSelection& selection = m_frame->selection();
+ FrameSelection& selection = localFrame()->selection();
if (selection.isNone())
return;
@@ -458,12 +458,12 @@ void DOMSelection::deleteFromDocument()
bool DOMSelection::containsNode(const Node* n, bool allowPartial) const
{
- if (!m_frame)
+ if (!localFrame())
return false;
- FrameSelection& selection = m_frame->selection();
+ FrameSelection& selection = localFrame()->selection();
- if (!n || m_frame->document() != n->document() || selection.isNone())
+ if (!n || localFrame()->document() != n->document() || selection.isNone())
return false;
unsigned nodeIndex = n->nodeIndex();
@@ -500,11 +500,11 @@ void DOMSelection::selectAllChildren(Node* n, ExceptionState& exceptionState)
String DOMSelection::toString()
{
- if (!m_frame)
+ if (!localFrame())
return String();
Position start, end;
- if (m_frame->selection().selection().toNormalizedPositions(start, end))
+ if (localFrame()->selection().selection().toNormalizedPositions(start, end))
return plainText(start, end);
return emptyString();
}
@@ -546,10 +546,10 @@ int DOMSelection::shadowAdjustedOffset(const Position& position) const
bool DOMSelection::isValidForPosition(Node* node) const
{
- ASSERT(m_frame);
+ ASSERT(localFrame());
if (!node)
return true;
- return node->document() == m_frame->document();
+ return node->document() == localFrame()->document();
}
void DOMSelection::addConsoleError(const String& message)

Powered by Google App Engine
This is Rietveld 408576698