| Index: Source/core/editing/EditingTestBase.cpp
|
| diff --git a/Source/core/editing/EditingTestBase.cpp b/Source/core/editing/EditingTestBase.cpp
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..d22b8d7e0fb046feb7439be5d14418472fa7a593
|
| --- /dev/null
|
| +++ b/Source/core/editing/EditingTestBase.cpp
|
| @@ -0,0 +1,61 @@
|
| +// Copyright 2015 The Chromium Authors. All rights reserved.
|
| +// Use of this source code is governed by a BSD-style license that can be
|
| +// found in the LICENSE file.
|
| +
|
| +#include "config.h"
|
| +#include "core/editing/EditingTestBase.h"
|
| +
|
| +#include "core/dom/Document.h"
|
| +#include "core/dom/Range.h"
|
| +#include "core/dom/Text.h"
|
| +#include "core/html/HTMLElement.h"
|
| +#include "core/testing/DummyPageHolder.h"
|
| +
|
| +namespace blink {
|
| +
|
| +EditingTestBase::EditingTestBase()
|
| +{
|
| +}
|
| +
|
| +EditingTestBase::~EditingTestBase()
|
| +{
|
| +}
|
| +
|
| +Document& EditingTestBase::document() const
|
| +{
|
| + return m_dummyPageHolder->document();
|
| +}
|
| +
|
| +void EditingTestBase::SetUp()
|
| +{
|
| + m_dummyPageHolder = DummyPageHolder::create(IntSize(800, 600));
|
| +}
|
| +
|
| +PassRefPtrWillBeRawPtr<ShadowRoot> EditingTestBase::createShadowRootForElementWithIDAndSetInnerHTML(TreeScope& scope, const char* hostElementID, const char* shadowRootContent)
|
| +{
|
| + RefPtrWillBeRawPtr<ShadowRoot> shadowRoot = scope.getElementById(AtomicString::fromUTF8(hostElementID))->createShadowRoot(ASSERT_NO_EXCEPTION);
|
| + shadowRoot->setInnerHTML(String::fromUTF8(shadowRootContent), ASSERT_NO_EXCEPTION);
|
| + return shadowRoot.release();
|
| +}
|
| +
|
| +void EditingTestBase::setBodyContent(const char* bodyContent)
|
| +{
|
| + document().body()->setInnerHTML(String::fromUTF8(bodyContent), ASSERT_NO_EXCEPTION);
|
| +}
|
| +
|
| +PassRefPtrWillBeRawPtr<ShadowRoot> EditingTestBase::setShadowContent(const char* shadowContent)
|
| +{
|
| + return createShadowRootForElementWithIDAndSetInnerHTML(document(), "host", shadowContent);
|
| +}
|
| +
|
| +Position EditingTestBase::positionInDOMTree(Node& anchor, int offset)
|
| +{
|
| + return Position(&anchor, offset, Position::PositionIsOffsetInAnchor);
|
| +}
|
| +
|
| +PositionInComposedTree EditingTestBase::positionInComposedTree(Node& anchor, int offset)
|
| +{
|
| + return PositionInComposedTree(&anchor, offset, PositionInComposedTree::PositionIsOffsetInAnchor);
|
| +}
|
| +
|
| +} // namespace blink
|
|
|