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

Unified Diff: third_party/WebKit/Source/web/WebRange.cpp

Issue 2199523002: Convert WebRange to be a simple pair of numbers. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Forgot the exports. Created 4 years, 4 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: third_party/WebKit/Source/web/WebRange.cpp
diff --git a/third_party/WebKit/Source/web/WebRange.cpp b/third_party/WebKit/Source/web/WebRange.cpp
index 49cd2fa9642bf65d64d1b5b2eafa76b480a1d787..b659375b30dd94bffb3c15cca2be0f49bb16b8b9 100644
--- a/third_party/WebKit/Source/web/WebRange.cpp
+++ b/third_party/WebKit/Source/web/WebRange.cpp
@@ -30,71 +30,36 @@
#include "public/web/WebRange.h"
-#include "bindings/core/v8/ExceptionState.h"
-#include "bindings/core/v8/ExceptionStatePlaceholder.h"
#include "core/dom/Document.h"
-#include "core/dom/Element.h"
#include "core/dom/Range.h"
-#include "core/dom/shadow/ShadowRoot.h"
#include "core/editing/FrameSelection.h"
#include "core/editing/PlainTextRange.h"
-#include "core/frame/FrameView.h"
#include "core/frame/LocalFrame.h"
-#include "public/platform/WebString.h"
-#include "public/web/WebExceptionCode.h"
-#include "public/web/WebNode.h"
-#include "web/WebLocalFrameImpl.h"
-#include "wtf/PassRefPtr.h"
namespace blink {
-void WebRange::reset()
+WebRange::WebRange(int start, int length)
+ : m_start(start)
+ , m_end(start + length)
{
- m_private.reset();
+ DCHECK(start != -1 && length != 0) << "These values are reserved to indicate that the range is null";
}
-void WebRange::assign(const WebRange& other)
+WebRange::WebRange(Range* range)
{
- m_private = other.m_private;
-}
-
-int WebRange::startOffset() const
-{
- return m_private->startOffset();
-}
+ if (!range)
+ return;
-int WebRange::endOffset() const
-{
- return m_private->endOffset();
-}
-
-WebString WebRange::toPlainText() const
-{
- return m_private->text();
+ m_start = range->startOffset();
+ m_end = range->endOffset();
}
-// static
-WebRange WebRange::fromDocumentRange(WebLocalFrame* frame, int start, int length)
+Range* WebRange::createRange(LocalFrame* frame) const
{
- LocalFrame* webFrame = toWebLocalFrameImpl(frame)->frame();
- Element* selectionRoot = webFrame->selection().rootEditableElement();
- ContainerNode* scope = selectionRoot ? selectionRoot : webFrame->document()->documentElement();
+ Element* selectionRoot = frame->selection().rootEditableElement();
+ ContainerNode* scope = selectionRoot ? selectionRoot : frame->document()->documentElement();
- // TODO(dglazkov): The use of updateStyleAndLayoutIgnorePendingStylesheets needs to be audited.
- // see http://crbug.com/590369 for more details.
- scope->document().updateStyleAndLayoutIgnorePendingStylesheets();
-
- return createRange(PlainTextRange(start, start + length).createRange(*scope));
-}
-
-WebRange::WebRange(Range*range)
- : m_private(range)
-{
-}
-
-WebRange::operator Range*() const
-{
- return m_private.get();
+ return blink::createRange(PlainTextRange(m_start, m_end).createRange(*scope));
}
} // namespace blink
« no previous file with comments | « third_party/WebKit/Source/web/WebLocalFrameImpl.cpp ('k') | third_party/WebKit/Source/web/WebSurroundingText.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698