Remove the concept of document.documentElement

Now documents can have many element children, all created equal.

R=esprehn@chromium.org, ojan@chromium.org

Review URL: https://codereview.chromium.org/928393003
This commit is contained in:
Adam Barth 2015-02-17 16:20:07 -08:00
parent 4790abe2f7
commit dff66fb1b7
62 changed files with 162 additions and 822 deletions

View File

@ -578,8 +578,6 @@ sky_core_files = [
"editing/SplitElementCommand.h",
"editing/SplitTextNodeCommand.cpp",
"editing/SplitTextNodeCommand.h",
"editing/SurroundingText.cpp",
"editing/SurroundingText.h",
"editing/TextAffinity.h",
"editing/TextCheckingHelper.cpp",
"editing/TextCheckingHelper.h",

View File

@ -141,7 +141,7 @@ bool SharedStyleFinder::canShareStyleWithElement(Element& candidate) const
bool SharedStyleFinder::documentContainsValidCandidate() const
{
for (Element* element = document().documentElement(); element; element = ElementTraversal::next(*element)) {
for (Element* element = ElementTraversal::firstChild(document()); element; element = ElementTraversal::next(*element)) {
if (element->supportsStyleSharing() && canShareStyleWithElement(*element))
return true;
}

View File

@ -133,11 +133,7 @@ void StyleAdjuster::adjustRenderStyle(RenderStyle* style, RenderStyle* parentSty
ASSERT(parentStyle);
if (style->display() != NONE) {
// Absolute/fixed positioned elements, floating elements and the document element need block-like outside display.
if (style->hasOutOfFlowPosition() || element.document().documentElement() == element)
style->setDisplay(equivalentBlockDisplay(style->display()));
if (parentStyle->requiresOnlyBlockChildren())
if (style->hasOutOfFlowPosition() || parentStyle->requiresOnlyBlockChildren())
style->setDisplay(equivalentBlockDisplay(style->display()));
else
style->setDisplay(equivalentInlineDisplay(style->display()));
@ -147,15 +143,12 @@ void StyleAdjuster::adjustRenderStyle(RenderStyle* style, RenderStyle* parentSty
if (style->position() == StaticPosition && !parentStyleForcesZIndexToCreateStackingContext(parentStyle))
style->setHasAutoZIndex();
// Auto z-index becomes 0 for the root element and transparent objects. This prevents
// cases where objects that should be blended as a single unit end up with a non-transparent
// object wedged in between them. Auto z-index also becomes 0 for objects that specify transforms.
if (style->hasAutoZIndex() && ((element.document().documentElement() == element)
|| style->hasOpacity()
|| style->hasTransformRelatedProperty()
|| style->clipPath()
|| style->hasFilter()
|| hasWillChangeThatCreatesStackingContext(style)))
if (style->hasAutoZIndex()
&& (style->hasOpacity()
|| style->hasTransformRelatedProperty()
|| style->clipPath()
|| style->hasFilter()
|| hasWillChangeThatCreatesStackingContext(style)))
style->setZIndex(0);
// will-change:transform should result in the same rendering behavior as having a transform,

View File

@ -154,9 +154,6 @@ void StyleBuilderFunctions::applyValueCSSPropertyCursor(StyleResolverState& stat
void StyleBuilderFunctions::applyValueCSSPropertyDirection(StyleResolverState& state, CSSValue* value)
{
state.style()->setDirection(*toCSSPrimitiveValue(value));
Element* element = state.element();
if (element && element == element->document().documentElement())
element->document().setDirectionSetOnDocumentElement(true);
}
void StyleBuilderFunctions::applyInitialCSSPropertyFontFamily(StyleResolverState& state)

View File

@ -195,8 +195,6 @@ PassRefPtr<RenderStyle> StyleResolver::styleForElement(Element* element, RenderS
ASSERT(m_document.frame());
ASSERT(m_document.settings());
if (element == m_document.documentElement())
m_document.setDirectionSetOnDocumentElement(false);
StyleResolverState state(m_document, element, defaultParent);
if (state.parentStyle()) {
@ -272,7 +270,7 @@ PassRefPtr<AnimatableValue> StyleResolver::createAnimatableValueSnapshot(StyleRe
PassRefPtr<RenderStyle> StyleResolver::defaultStyleForElement()
{
StyleResolverState state(m_document, 0);
StyleResolverState state(m_document, nullptr);
state.setStyle(RenderStyle::create());
state.fontBuilder().initForStyleResolve(m_document, state.style());
state.style()->setLineHeight(RenderStyle::initialLineHeight());
@ -578,7 +576,7 @@ void StyleResolver::printStats()
void StyleResolver::applyPropertiesToStyle(const CSSPropertyValue* properties, size_t count, RenderStyle* style)
{
StyleResolverState state(m_document, m_document.documentElement(), style);
StyleResolverState state(m_document, nullptr, style);
state.setStyle(style);
state.fontBuilder().initForStyleResolve(m_document, style);

View File

@ -99,21 +99,6 @@ void ContainerNode::checkAcceptChildHierarchy(const Node& newChild, const Node*
exceptionState.ThrowDOMException(HierarchyRequestError, "The new child element contains the parent.");
return;
}
// TODO(esprehn): Remove this, sky should allow multiple top level elements.
if (isDocumentNode()) {
unsigned elementCount = 0;
if (newChild.isElementNode()) {
elementCount = 1;
} else if (newChild.isDocumentFragment()) {
for (Element* element = ElementTraversal::firstChild(newChild); element; element = ElementTraversal::nextSibling(*element))
++elementCount;
}
if (elementCount > 1 || ((!oldChild || !oldChild->isElementNode()) && elementCount && document().documentElement())) {
exceptionState.ThrowDOMException(HierarchyRequestError, "Document can only contain one Element.");
return;
}
}
}
PassRefPtr<Node> ContainerNode::insertBefore(PassRefPtr<Node> newChild, Node* refChild, ExceptionState& exceptionState)

View File

@ -250,7 +250,6 @@ Document::Document(const DocumentInit& initializer)
, m_loadEventDelayTimer(this, &Document::loadEventDelayTimerFired)
, m_didSetReferrerPolicy(false)
, m_referrerPolicy(ReferrerPolicyDefault)
, m_directionSetOnDocumentElement(false)
, m_registrationContext(initializer.registrationContext())
, m_elementDataCacheClearTimer(this, &Document::elementDataCacheClearTimerFired)
, m_timeline(AnimationTimeline::create(this))
@ -354,7 +353,6 @@ void Document::dispose()
m_hoverNode = nullptr;
m_activeHoverElement = nullptr;
m_titleElement = nullptr;
m_documentElement = nullptr;
m_userActionElements.documentDidRemoveLastRef();
detachParser();
@ -410,12 +408,6 @@ Location* Document::location() const
return &domWindow()->location();
}
void Document::childrenChanged(const ChildrenChange& change)
{
ContainerNode::childrenChanged(change);
m_documentElement = ElementTraversal::firstWithin(*this);
}
PassRefPtr<Element> Document::createElement(const AtomicString& name, ExceptionState& exceptionState)
{
if (!isValidName(name)) {
@ -1043,9 +1035,9 @@ void Document::updateStyle(StyleRecalcChange change)
if (StyleResolverStats* stats = styleResolver().stats())
stats->reset();
if (Element* documentElement = this->documentElement()) {
if (documentElement->shouldCallRecalcStyle(change))
documentElement->recalcStyle(change);
for (Element* element = ElementTraversal::firstChild(*this); element; element = ElementTraversal::nextSibling(*element)) {
if (element->shouldCallRecalcStyle(change))
element->recalcStyle(change);
}
styleResolver().printStats();
@ -2168,16 +2160,6 @@ IntSize Document::initialViewportSize() const
return view()->unscaledVisibleContentSize();
}
Node* eventTargetNodeForDocument(Document* doc)
{
if (!doc)
return 0;
Node* node = doc->focusedElement();
if (!node)
node = doc->documentElement();
return node;
}
void Document::decrementActiveParserCount()
{
--m_activeParserCount;
@ -2218,7 +2200,7 @@ Element* Document::activeElement() const
{
if (Element* element = treeScope().adjustedFocusedElement())
return element;
return documentElement();
return nullptr;
}
void Document::getTransitionElementData(Vector<TransitionElementData>& elementData)

View File

@ -165,11 +165,6 @@ public:
String outgoingReferrer();
Element* documentElement() const
{
return m_documentElement.get();
}
Location* location() const;
PassRefPtr<Element> createElement(const AtomicString& name, ExceptionState&);
@ -391,9 +386,6 @@ public:
DocumentMarkerController& markers() const { return *m_markers; }
bool directionSetOnDocumentElement() const { return m_directionSetOnDocumentElement; }
void setDirectionSetOnDocumentElement(bool b) { m_directionSetOnDocumentElement = b; }
KURL openSearchDescriptionURL();
Document& topDocument() const;
@ -548,8 +540,6 @@ private:
virtual bool isDocument() const override final { return true; }
virtual void childrenChanged(const ChildrenChange&) override;
virtual String nodeName() const override final;
virtual NodeType nodeType() const override final;
virtual PassRefPtr<Node> cloneNode(bool deep = true) override final;
@ -620,7 +610,6 @@ private:
RefPtr<Element> m_focusedElement;
RefPtr<Node> m_hoverNode;
RefPtr<Element> m_activeHoverElement;
RefPtr<Element> m_documentElement;
UserActionElementSet m_userActionElements;
typedef HashSet<RawPtr<Range> > AttachedRangeSet;
@ -670,8 +659,6 @@ private:
bool m_didSetReferrerPolicy;
ReferrerPolicy m_referrerPolicy;
bool m_directionSetOnDocumentElement;
RefPtr<MediaQueryMatcher> m_mediaQueryMatcher;
RefPtr<ScriptedAnimationController> m_scriptedAnimationController;
@ -726,8 +713,6 @@ inline bool Node::isDocumentNode() const
return this == document();
}
Node* eventTargetNodeForDocument(Document*);
} // namespace blink
#ifndef NDEBUG

View File

@ -26,8 +26,6 @@ typedef (CanvasRenderingContext2D or WebGLRenderingContext) RenderingContext;
Constructor(),
ConstructorCallWith=Document,
] interface Document : ParentNode {
readonly attribute Element documentElement;
[CustomElementCallbacks, RaisesException] Element createElement(DOMString tagName);
DocumentFragment createDocumentFragment();

View File

@ -371,12 +371,6 @@ int Element::clientWidth()
{
document().updateLayout();
// FIXME(sky): Can we just use getBoundingClientRect() instead?
if (document().documentElement() == this) {
if (FrameView* view = document().view())
return view->layoutSize().width();
}
if (RenderBox* renderer = renderBox())
return renderer->pixelSnappedClientWidth();
return 0;
@ -386,12 +380,6 @@ int Element::clientHeight()
{
document().updateLayout();
// FIXME(sky): Can we just use getBoundingClientRect() instead?
if (document().documentElement() == this) {
if (FrameView* view = document().view())
return view->layoutSize().height();
}
if (RenderBox* renderer = renderBox())
return renderer->pixelSnappedClientHeight();
return 0;

View File

@ -416,18 +416,16 @@ Node* Position::parentEditingBoundary() const
if (!m_anchorNode)
return 0;
Node* documentElement = m_anchorNode->document().documentElement();
if (!documentElement)
return 0;
// FIXME: Why does this look at parentNode?
Node* boundary = m_anchorNode.get();
while (boundary != documentElement && boundary->nonShadowBoundaryParentNode() && m_anchorNode->hasEditableStyle() == boundary->parentNode()->hasEditableStyle())
while (boundary->nonShadowBoundaryParentNode()
&& boundary->nonShadowBoundaryParentNode()->isElementNode()
&& m_anchorNode->hasEditableStyle() == boundary->parentNode()->hasEditableStyle())
boundary = boundary->nonShadowBoundaryParentNode();
return boundary;
}
bool Position::atStartOfTree() const
{
if (isNull())

View File

@ -273,7 +273,7 @@ void Editor::deleteSelectionWithSmartDelete(bool smartDelete)
void Editor::pasteAsPlainText(const String& pastingText, bool smartReplace)
{
Element* target = findEventTargetFromSelection();
ContainerNode* target = findEventTargetFromSelection();
if (!target)
return;
target->dispatchEvent(TextEvent::createForPlainTextPaste(m_frame.domWindow(), pastingText, smartReplace), IGNORE_EXCEPTION);
@ -281,7 +281,7 @@ void Editor::pasteAsPlainText(const String& pastingText, bool smartReplace)
void Editor::pasteAsFragment(PassRefPtr<DocumentFragment> pastingFragment, bool smartReplace, bool matchStyle)
{
Element* target = findEventTargetFromSelection();
ContainerNode* target = findEventTargetFromSelection();
if (!target)
return;
target->dispatchEvent(TextEvent::createForFragmentPaste(m_frame.domWindow(), pastingFragment, smartReplace, matchStyle), IGNORE_EXCEPTION);
@ -352,16 +352,14 @@ void Editor::clearLastEditCommand()
m_lastEditCommand.clear();
}
Element* Editor::findEventTargetFrom(const VisibleSelection& selection) const
ContainerNode* Editor::findEventTargetFrom(const VisibleSelection& selection) const
{
Element* target = selection.start().element();
if (!target)
target = m_frame.document()->documentElement();
return target;
if (Element* target = selection.start().element())
return target;
return m_frame.document();
}
Element* Editor::findEventTargetFromSelection() const
ContainerNode* Editor::findEventTargetFromSelection() const
{
return findEventTargetFrom(m_frame.selection().selection());
}

View File

@ -176,7 +176,7 @@ public:
void pasteAsFragment(PassRefPtr<DocumentFragment>, bool smartReplace, bool matchStyle);
void pasteAsPlainText(const String&, bool smartReplace);
Element* findEventTargetFrom(const VisibleSelection&) const;
ContainerNode* findEventTargetFrom(const VisibleSelection&) const;
bool findString(const String&, FindOptions);
// FIXME: Switch callers over to the FindOptions version and retire this one.
@ -235,7 +235,7 @@ private:
void changeSelectionAfterCommand(const VisibleSelection& newSelection, FrameSelection::SetSelectionOptions);
void notifyComponentsOnChangedSelection(const VisibleSelection& oldSelection, FrameSelection::SetSelectionOptions);
Element* findEventTargetFromSelection() const;
ContainerNode* findEventTargetFromSelection() const;
PassRefPtr<Range> rangeOfString(const String&, Range*, FindOptions);

View File

@ -101,12 +101,6 @@ FrameSelection::~FrameSelection()
#endif
}
Element* FrameSelection::rootEditableElementOrDocumentElement() const
{
Element* selectionRoot = m_selection.rootEditableElement();
return selectionRoot ? selectionRoot : m_frame->document()->documentElement();
}
ContainerNode* FrameSelection::rootEditableElementOrTreeScopeRootNode() const
{
Element* selectionRoot = m_selection.rootEditableElement();
@ -1252,11 +1246,11 @@ void FrameSelection::selectAll()
selectStartTarget = root.get();
} else {
root = m_selection.nonBoundaryShadowTreeRootNode();
if (root)
if (root) {
selectStartTarget = root->shadowHost();
else {
root = document->documentElement();
selectStartTarget = document->documentElement();
} else {
root = document;
selectStartTarget = document;
}
}
if (!root)

View File

@ -93,7 +93,6 @@ public:
};
Element* rootEditableElement() const { return m_selection.rootEditableElement(); }
Element* rootEditableElementOrDocumentElement() const;
ContainerNode* rootEditableElementOrTreeScopeRootNode() const;
bool hasEditableStyle() const { return m_selection.hasEditableStyle(); }

View File

@ -163,7 +163,7 @@ void SpellChecker::advanceToNextMisspelling(bool startBeforeSelection)
// when spell checking the whole document before sending the message.
// In that case the document might not be editable, but there are editable pockets that need to be spell checked.
position = firstEditableVisiblePositionAfterPositionInRoot(position, m_frame.document()->documentElement()).deepEquivalent();
position = firstEditableVisiblePositionAfterPositionInRoot(position, m_frame.document()).deepEquivalent();
if (position.isNull())
return;

View File

@ -1,142 +0,0 @@
/*
* Copyright (C) 2012 Google Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
* met:
*
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above
* copyright notice, this list of conditions and the following disclaimer
* in the documentation and/or other materials provided with the
* distribution.
* * Neither the name of Google Inc. nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "sky/engine/config.h"
#include "sky/engine/core/editing/SurroundingText.h"
#include "sky/engine/core/dom/Document.h"
#include "sky/engine/core/dom/Element.h"
#include "sky/engine/core/dom/Position.h"
#include "sky/engine/core/dom/Range.h"
#include "sky/engine/core/editing/TextIterator.h"
namespace blink {
SurroundingText::SurroundingText(const Range& range, unsigned maxLength)
: m_startOffsetInContent(0)
, m_endOffsetInContent(0)
{
initialize(range.startPosition(), range.endPosition(), maxLength);
}
SurroundingText::SurroundingText(const Position& position, unsigned maxLength)
: m_startOffsetInContent(0)
, m_endOffsetInContent(0)
{
initialize(position, position, maxLength);
}
void SurroundingText::initialize(const Position& startPosition, const Position& endPosition, unsigned maxLength)
{
ASSERT(startPosition.document() == endPosition.document());
const unsigned halfMaxLength = maxLength / 2;
Document* document = startPosition.document();
// The position will have no document if it is null (as in no position).
if (!document)
return;
// The forward range starts at the selection end and ends at the document's
// end. It will then be updated to only contain the text in the text in the
// right range around the selection.
RefPtr<Range> forwardRange = Range::create(*document, endPosition, lastPositionInNode(document->documentElement()).parentAnchoredEquivalent());
CharacterIterator forwardIterator(forwardRange.get());
// FIXME: why do we stop going trough the text if we were not able to select something on the right?
if (!forwardIterator.atEnd())
forwardIterator.advance(maxLength - halfMaxLength);
forwardRange = forwardIterator.range();
if (!forwardRange || !Range::create(*document, endPosition, forwardRange->startPosition())->text().length()) {
ASSERT(forwardRange);
return;
}
// Same as with the forward range but with the backward range. The range
// starts at the document's start and ends at the selection start and will
// be updated.
RefPtr<Range> backwardsRange = Range::create(*document, firstPositionInNode(document->documentElement()).parentAnchoredEquivalent(), startPosition);
BackwardsCharacterIterator backwardsIterator(backwardsRange.get());
if (!backwardsIterator.atEnd())
backwardsIterator.advance(halfMaxLength);
backwardsRange = backwardsIterator.range();
if (!backwardsRange) {
ASSERT(backwardsRange);
return;
}
m_startOffsetInContent = Range::create(*document, backwardsRange->endPosition(), startPosition)->text().length();
m_endOffsetInContent = Range::create(*document, backwardsRange->endPosition(), endPosition)->text().length();
m_contentRange = Range::create(*document, backwardsRange->endPosition(), forwardRange->startPosition());
ASSERT(m_contentRange);
}
PassRefPtr<Range> SurroundingText::rangeFromContentOffsets(unsigned startOffsetInContent, unsigned endOffsetInContent)
{
if (startOffsetInContent >= endOffsetInContent || endOffsetInContent > content().length())
return nullptr;
CharacterIterator iterator(m_contentRange.get());
ASSERT(!iterator.atEnd());
iterator.advance(startOffsetInContent);
ASSERT(iterator.range());
Position start = iterator.range()->startPosition();
ASSERT(!iterator.atEnd());
iterator.advance(endOffsetInContent - startOffsetInContent);
ASSERT(iterator.range());
Position end = iterator.range()->startPosition();
ASSERT(start.document());
return Range::create(*start.document(), start, end);
}
String SurroundingText::content() const
{
if (m_contentRange)
return m_contentRange->text();
return String();
}
unsigned SurroundingText::startOffsetInContent() const
{
return m_startOffsetInContent;
}
unsigned SurroundingText::endOffsetInContent() const
{
return m_endOffsetInContent;
}
} // namespace blink

View File

@ -1,65 +0,0 @@
/*
* Copyright (C) 2012 Google Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
* met:
*
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above
* copyright notice, this list of conditions and the following disclaimer
* in the documentation and/or other materials provided with the
* distribution.
* * Neither the name of Google Inc. nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef SKY_ENGINE_CORE_EDITING_SURROUNDINGTEXT_H_
#define SKY_ENGINE_CORE_EDITING_SURROUNDINGTEXT_H_
#include "sky/engine/platform/heap/Handle.h"
#include "sky/engine/wtf/text/WTFString.h"
namespace blink {
class Position;
class Range;
class SurroundingText {
WTF_MAKE_NONCOPYABLE(SurroundingText);
public:
SurroundingText(const Range&, unsigned maxLength);
SurroundingText(const Position&, unsigned maxLength);
String content() const;
unsigned startOffsetInContent() const;
unsigned endOffsetInContent() const;
PassRefPtr<Range> rangeFromContentOffsets(unsigned startOffsetInContent, unsigned endOffsetInContent);
private:
void initialize(const Position&, const Position&, unsigned maxLength);
RefPtr<Range> m_contentRange;
size_t m_startOffsetInContent;
size_t m_endOffsetInContent;
};
} // namespace blink
#endif // SKY_ENGINE_CORE_EDITING_SURROUNDINGTEXT_H_

View File

@ -264,52 +264,6 @@ bool VisibleSelection::expandUsingGranularity(TextGranularity granularity)
return true;
}
static PassRefPtr<Range> makeSearchRange(const Position& pos)
{
Node* node = pos.deprecatedNode();
if (!node)
return nullptr;
Document& document = node->document();
if (!document.documentElement())
return nullptr;
Element* boundary = enclosingBlockFlowElement(*node);
if (!boundary)
return nullptr;
RefPtr<Range> searchRange(Range::create(document));
TrackExceptionState exceptionState;
Position start(pos.parentAnchoredEquivalent());
searchRange->selectNodeContents(boundary, exceptionState);
searchRange->setStart(start.containerNode(), start.offsetInContainerNode(), exceptionState);
ASSERT(!exceptionState.had_exception());
if (exceptionState.had_exception())
return nullptr;
return searchRange.release();
}
void VisibleSelection::appendTrailingWhitespace()
{
RefPtr<Range> searchRange = makeSearchRange(m_end);
if (!searchRange)
return;
CharacterIterator charIt(searchRange.get(), TextIteratorEmitsCharactersBetweenAllVisiblePositions);
bool changed = false;
for (; charIt.length(); charIt.advance(1)) {
UChar c = charIt.characterAt(0);
if ((!isSpaceOrNewline(c) && c != noBreakSpace) || c == '\n')
break;
m_end = charIt.range()->endPosition();
changed = true;
}
if (changed)
didChange();
}
void VisibleSelection::setBaseAndExtentToDeepEquivalents()
{
// Move the selection to rendered positions, if possible.

View File

@ -89,8 +89,6 @@ public:
bool isDirectional() const { return m_isDirectional; }
void setIsDirectional(bool isDirectional) { m_isDirectional = isDirectional; }
void appendTrailingWhitespace();
bool expandUsingGranularity(TextGranularity granularity);
// We don't yet support multi-range selections, so we only ever have one range to return.

View File

@ -935,10 +935,12 @@ VisiblePosition previousLinePosition(const VisiblePosition &visiblePosition, int
// Could not find a previous line. This means we must already be on the first line.
// Move to the start of the content in this block, which effectively moves us
// to the start of the line we're on.
Element* rootElement = node->hasEditableStyle(editableType) ? node->rootEditableElement(editableType) : node->document().documentElement();
if (!rootElement)
ContainerNode* rootContainer = &node->document();
if (node->hasEditableStyle(editableType))
rootContainer = node->rootEditableElement(editableType);
if (!rootContainer)
return VisiblePosition();
return VisiblePosition(firstPositionInNode(rootElement), DOWNSTREAM);
return VisiblePosition(firstPositionInNode(rootContainer), DOWNSTREAM);
}
VisiblePosition nextLinePosition(const VisiblePosition &visiblePosition, int lineDirectionPoint, EditableType editableType)
@ -993,10 +995,12 @@ VisiblePosition nextLinePosition(const VisiblePosition &visiblePosition, int lin
// Could not find a next line. This means we must already be on the last line.
// Move to the end of the content in this block, which effectively moves us
// to the end of the line we're on.
Element* rootElement = node->hasEditableStyle(editableType) ? node->rootEditableElement(editableType) : node->document().documentElement();
if (!rootElement)
ContainerNode* rootContainer = &node->document();
if (node->hasEditableStyle(editableType))
rootContainer = node->rootEditableElement(editableType);
if (!rootContainer)
return VisiblePosition();
return VisiblePosition(lastPositionInNode(rootElement), DOWNSTREAM);
return VisiblePosition(lastPositionInNode(rootContainer), DOWNSTREAM);
}
// ---------
@ -1284,10 +1288,10 @@ bool isEndOfBlock(const VisiblePosition &pos)
VisiblePosition startOfDocument(const Node* node)
{
if (!node || !node->document().documentElement())
if (!node)
return VisiblePosition();
return VisiblePosition(firstPositionInNode(node->document().documentElement()), DOWNSTREAM);
return VisiblePosition(firstPositionInNode(&node->document()), DOWNSTREAM);
}
VisiblePosition startOfDocument(const VisiblePosition &c)
@ -1297,11 +1301,10 @@ VisiblePosition startOfDocument(const VisiblePosition &c)
VisiblePosition endOfDocument(const Node* node)
{
if (!node || !node->document().documentElement())
if (!node)
return VisiblePosition();
Element* doc = node->document().documentElement();
return VisiblePosition(lastPositionInNode(doc), DOWNSTREAM);
return VisiblePosition(lastPositionInNode(&node->document()), DOWNSTREAM);
}
VisiblePosition endOfDocument(const VisiblePosition &c)

View File

@ -837,7 +837,7 @@ int indexForVisiblePosition(const VisiblePosition& visiblePosition, RefPtr<Conta
if (shadowRoot)
scope = shadowRoot;
else
scope = document.documentElement();
scope = &document;
RefPtr<Range> range = Range::create(document, firstPositionInNode(scope.get()), p.parentAnchoredEquivalent());

View File

@ -621,31 +621,6 @@ float FrameView::inputEventsScaleFactor() const
return pageScale * m_inputEventsScaleFactorForEmulation;
}
Color FrameView::documentBackgroundColor() const
{
// <https://bugs.webkit.org/show_bug.cgi?id=59540> We blend the background color of
// the document and the body against the base background color of the frame view.
// Background images are unfortunately impractical to include.
Color result = baseBackgroundColor();
if (!frame().document())
return result;
Element* htmlElement = frame().document()->documentElement();
// We take the aggregate of the base background color
// the <html> background color, and the <body>
// background color to find the document color. The
// addition of the base background color is not
// technically part of the document background, but it
// otherwise poses problems when the aggregate is not
// fully opaque.
if (htmlElement && htmlElement->renderer())
result = result.blend(htmlElement->renderer()->style()->colorIncludingFallback(CSSPropertyBackgroundColor));
return result;
}
void FrameView::paint(GraphicsContext* context, const IntRect& rect)
{
#ifndef NDEBUG

View File

@ -128,8 +128,6 @@ public:
bool isPainting() const;
bool hasEverPainted() const { return m_lastPaintTime; }
Color documentBackgroundColor() const;
static double currentFrameTimeStamp() { return s_currentFrameTimeStamp; }
void updateLayoutAndStyleForPainting();

View File

@ -69,6 +69,7 @@
#include "sky/engine/platform/weborigin/KURL.h"
#include "sky/engine/platform/weborigin/SecurityPolicy.h"
#include "sky/engine/public/platform/Platform.h"
#include "sky/engine/tonic/dart_gc_visitor.h"
#include "sky/engine/wtf/MainThread.h"
#include "sky/engine/wtf/MathExtras.h"
#include "sky/engine/wtf/text/WTFString.h"
@ -310,6 +311,11 @@ LocalDOMWindow* LocalDOMWindow::toDOMWindow()
return this;
}
void LocalDOMWindow::AcceptDartGCVisitor(DartGCVisitor& visitor) const {
visitor.AddToSetForRoot(document(), dart_wrapper());
EventTarget::AcceptDartGCVisitor(visitor);
}
PassRefPtr<MediaQueryList> LocalDOMWindow::matchMedia(const String& media)
{
return document() ? document()->mediaQueryMatcher().matchMedia(media) : nullptr;

View File

@ -91,6 +91,7 @@ public:
virtual ExecutionContext* executionContext() const override;
virtual LocalDOMWindow* toDOMWindow() override;
void AcceptDartGCVisitor(DartGCVisitor& visitor) const override;
void registerProperty(DOMWindowProperty*);
void unregisterProperty(DOMWindowProperty*);

View File

@ -54,14 +54,14 @@ Node* NewEventHandler::targetForKeyboardEvent() const
Document* document = m_frame.document();
if (Node* focusedElement = document->focusedElement())
return focusedElement;
return document->documentElement();
return document;
}
Node* NewEventHandler::targetForHitTestResult(const HitTestResult& hitTestResult)
{
Node* node = hitTestResult.innerNode();
if (!node)
return m_frame.document()->documentElement();
return m_frame.document();
if (node->isTextNode())
return NodeRenderingTraversal::parent(node);
return node;

View File

@ -157,46 +157,6 @@ void EventHandler::nodeWillBeRemoved(Node& nodeToBeRemoved)
}
}
void EventHandler::selectClosestWordFromHitTestResult(const HitTestResult& result, AppendTrailingWhitespace appendTrailingWhitespace)
{
Node* innerNode = result.targetNode();
VisibleSelection newSelection;
if (innerNode && innerNode->renderer()) {
VisiblePosition pos(innerNode->renderer()->positionForPoint(result.localPoint()));
if (pos.isNotNull()) {
newSelection = VisibleSelection(pos);
newSelection.expandUsingGranularity(WordGranularity);
}
if (appendTrailingWhitespace == ShouldAppendTrailingWhitespace && newSelection.isRange())
newSelection.appendTrailingWhitespace();
}
}
void EventHandler::selectClosestMisspellingFromHitTestResult(const HitTestResult& result, AppendTrailingWhitespace appendTrailingWhitespace)
{
Node* innerNode = result.targetNode();
VisibleSelection newSelection;
if (innerNode && innerNode->renderer()) {
VisiblePosition pos(innerNode->renderer()->positionForPoint(result.localPoint()));
Position start = pos.deepEquivalent();
Position end = pos.deepEquivalent();
if (pos.isNotNull()) {
DocumentMarkerVector markers = innerNode->document().markers().markersInRange(makeRange(pos, pos).get(), DocumentMarker::MisspellingMarkers());
if (markers.size() == 1) {
start.moveToOffset(markers[0]->startOffset());
end.moveToOffset(markers[0]->endOffset());
newSelection = VisibleSelection(start, end);
}
}
if (appendTrailingWhitespace == ShouldAppendTrailingWhitespace && newSelection.isRange())
newSelection.appendTrailingWhitespace();
}
}
HitTestResult EventHandler::hitTestResultAtPoint(const LayoutPoint& point, HitTestRequest::HitTestRequestType hitType, const LayoutSize& padding)
{
TRACE_EVENT0("blink", "EventHandler::hitTestResultAtPoint");
@ -436,6 +396,14 @@ bool EventHandler::dragHysteresisExceeded(const IntPoint& dragViewportLocation)
return false;
}
// TODO(abarth): This should just be targetForKeyboardEvent
static Node* eventTargetNodeForDocument(Document* document)
{
if (Node* node = document->focusedElement())
return node;
return document;
}
bool EventHandler::handleTextInputEvent(const String& text, Event* underlyingEvent, TextEventInputType inputType)
{
// Platforms should differentiate real commands like selectAll from text input in disguise (like insertNewline),

View File

@ -90,9 +90,6 @@ public:
void notifyElementActivated();
private:
void selectClosestWordFromHitTestResult(const HitTestResult&, AppendTrailingWhitespace);
void selectClosestMisspellingFromHitTestResult(const HitTestResult&, AppendTrailingWhitespace);
OptionalCursor selectCursor(const HitTestResult&);
OptionalCursor selectAutoCursor(const HitTestResult&, Node*);

View File

@ -320,11 +320,6 @@ void RenderBlock::addOverflowFromPositionedObjects()
}
}
bool RenderBlock::createsBlockFormattingContext() const
{
return isInlineBlock() || isFloatingOrOutOfFlowPositioned() || hasOverflowClip() || isFlexItem() || isDocumentElement();
}
void RenderBlock::updateBlockChildDirtyBitsBeforeLayout(bool relayoutChildren, RenderBox* child)
{
// FIXME: Technically percentage height objects only need a relayout if their percentage isn't going to be turned into
@ -446,16 +441,10 @@ void RenderBlock::paint(PaintInfo& paintInfo, const LayoutPoint& paintOffset, Ve
{
LayoutPoint adjustedPaintOffset = paintOffset + location();
LayoutRect overflowBox;
// Check if we need to do anything at all.
// FIXME: Could eliminate the isDocumentElement() check if we fix background painting so that the RenderView
// paints the root's background.
if (!isDocumentElement()) {
overflowBox = visualOverflowRect();
overflowBox.moveBy(adjustedPaintOffset);
if (!overflowBox.intersects(paintInfo.rect))
return;
}
LayoutRect overflowBox = visualOverflowRect();
overflowBox.moveBy(adjustedPaintOffset);
if (!overflowBox.intersects(paintInfo.rect))
return;
// There are some cases where not all clipped visual overflow is accounted for.
// FIXME: reduce the number of such cases.
@ -531,7 +520,10 @@ bool RenderBlock::isSelectionRoot() const
{
ASSERT(node() || isAnonymous());
if (isDocumentElement() || hasOverflowClip()
if (node() && node()->parentNode() == document())
return true;
if (hasOverflowClip()
|| isPositioned()
|| isInlineBlock()
|| hasTransform()
@ -603,9 +595,6 @@ GapRects RenderBlock::selectionGaps(RenderBlock* rootBlock, const LayoutPoint& r
LayoutRect blockRect(offsetFromRootBlock.width(), offsetFromRootBlock.height(), width(), height());
blockRect.moveBy(rootBlockPhysicalPosition);
clipOutPositionedObjects(paintInfo, blockRect.location(), positionedObjects());
if (isDocumentElement()) // The <body> must make sure to examine its containingBlock's positioned objects.
for (RenderBlock* cb = containingBlock(); cb && !cb->isRenderView(); cb = cb->containingBlock())
clipOutPositionedObjects(paintInfo, LayoutPoint(cb->x(), cb->y()), cb->positionedObjects());
}
// FIXME: overflow: auto/scroll regions need more math here, since painting in the border box is different from painting in the padding box (one is scrolled, the other is

View File

@ -294,8 +294,6 @@ private:
bool widthAvailableToChildrenHasChanged();
protected:
bool createsBlockFormattingContext() const;
virtual bool updateLogicalWidthAndColumnWidth();
protected:

View File

@ -104,7 +104,7 @@ inline void RenderBlockFlow::layoutBlockFlow(SubtreeLayoutScope& layoutScope)
if (previousHeight != logicalHeight())
relayoutChildren = true;
layoutPositionedObjects(relayoutChildren || isDocumentElement(), oldLeft != logicalLeft() ? ForcedLayoutAfterContainingBlockMoved : DefaultLayout);
layoutPositionedObjects(relayoutChildren, oldLeft != logicalLeft() ? ForcedLayoutAfterContainingBlockMoved : DefaultLayout);
// Add overflow from children (unless we're multi-column, since in that case all our child overflow is clipped anyway).
computeOverflow(oldClientAfterEdge);

View File

@ -117,16 +117,13 @@ void RenderBox::updateFromStyle()
RenderBoxModelObject::updateFromStyle();
RenderStyle* styleToUse = style();
bool isRootObject = isDocumentElement();
bool isViewObject = isRenderView();
// The root and the RenderView always paint their backgrounds/borders.
if (isRootObject || isViewObject)
if (isRenderView()) {
setHasBoxDecorationBackground(true);
// TODO(esprehn): Why do we not want to set this on the RenderView?
if (isRenderBlock() && !isViewObject)
} else if (isRenderBlock()) {
// TODO(esprehn): Why do we not want to set this on the RenderView?
setHasOverflowClip(!styleToUse->isOverflowVisible());
}
setHasTransform(styleToUse->hasTransformRelatedProperty());
}
@ -678,10 +675,6 @@ void RenderBox::paintBoxDecorationBackgroundWithRect(PaintInfo& paintInfo, const
void RenderBox::paintBackground(const PaintInfo& paintInfo, const LayoutRect& paintRect, const Color& backgroundColor, BackgroundBleedAvoidance bleedAvoidance)
{
if (isDocumentElement()) {
paintRootBoxFillLayers(paintInfo);
return;
}
paintFillLayers(paintInfo, backgroundColor, style()->backgroundLayers(), paintRect, bleedAvoidance);
}
@ -737,18 +730,10 @@ void RenderBox::paintFillLayers(const PaintInfo& paintInfo, const Color& c, cons
if (!context)
shouldDrawBackgroundInSeparateBuffer = false;
// FIXME(sky): Propagate this constant.
bool skipBaseColor = false;
if (shouldDrawBackgroundInSeparateBuffer) {
bool isBaseColorVisible = !isBottomLayerOccluded && c.hasAlpha();
// Paint the document's base background color outside the transparency layer,
// so that the background images don't blend with this color: http://crbug.com/389039.
if (isBaseColorVisible && isDocumentElementWithOpaqueBackground()) {
paintRootBackgroundColor(paintInfo, rect, Color());
skipBaseColor = true;
}
if (shouldDrawBackgroundInSeparateBuffer)
context->beginTransparencyLayer(1);
}
Vector<const FillLayer*>::const_reverse_iterator topLayer = layers.rend();
for (Vector<const FillLayer*>::const_reverse_iterator it = layers.rbegin(); it != topLayer; ++it)
@ -1320,8 +1305,6 @@ LayoutUnit RenderBox::computePercentageLogicalHeight(const Length& height) const
const RenderBox* containingBlockChild = this;
LayoutUnit rootMarginBorderPaddingHeight = 0;
while (!cb->isRenderView() && skipContainingBlockForPercentHeightCalculation(cb)) {
if (cb->isDocumentElement())
rootMarginBorderPaddingHeight += cb->marginBefore() + cb->marginAfter() + cb->borderAndPaddingLogicalHeight();
skippedAutoHeightContainingBlock = true;
containingBlockChild = cb;
cb = cb->containingBlock();
@ -2812,12 +2795,6 @@ bool RenderBox::percentageLogicalHeightIsResolvableFromBlock(const RenderBlock*
return percentageLogicalHeightIsResolvableFromBlock(cb->containingBlock(), cb->isOutOfFlowPositioned());
if (cb->isRenderView() || isOutOfFlowPositionedWithSpecifiedHeight)
return true;
if (cb->isDocumentElement() && isOutOfFlowPositioned) {
// Match the positioned objects behavior, which is that positioned objects will fill their viewport
// always. Note we could only hit this case by recurring into computePercentageLogicalHeight on a positioned containing block.
return true;
}
return false;
}

View File

@ -119,47 +119,6 @@ bool RenderBoxModelObject::hasAutoHeightOrContainingBlockWithAutoHeight() const
return cb->hasAutoHeightOrContainingBlockWithAutoHeight();
}
bool RenderBoxModelObject::isDocumentElementWithOpaqueBackground() const
{
if (!isDocumentElement())
return false;
// The background is opaque only if we're the root document, since iframes with
// no background in the child document should show the parent's background.
// FIXME(sky): This used to check the <body> element and is now probably wrong.
if (view()->frameView())
return !view()->frameView()->isTransparent();
return true;
}
void RenderBoxModelObject::paintRootBackgroundColor(const PaintInfo& paintInfo, const LayoutRect& rect, const Color& bgColor)
{
GraphicsContext* context = paintInfo.context;
if (rect.isEmpty())
return;
ASSERT(isDocumentElement());
IntRect backgroundRect(pixelSnappedIntRect(rect));
backgroundRect.intersect(paintInfo.rect);
Color baseColor = view()->frameView()->baseBackgroundColor();
bool shouldClearDocumentBackground = document().settings() && document().settings()->shouldClearDocumentBackground();
CompositeOperator operation = shouldClearDocumentBackground ? CompositeCopy : context->compositeOperation();
// If we have an alpha go ahead and blend with the base background color.
if (baseColor.alpha()) {
if (bgColor.alpha())
baseColor = baseColor.blend(bgColor);
context->fillRect(backgroundRect, baseColor, operation);
} else if (bgColor.alpha()) {
context->fillRect(backgroundRect, bgColor, operation);
} else if (shouldClearDocumentBackground) {
context->clearRect(backgroundRect);
}
}
LayoutSize RenderBoxModelObject::relativePositionOffset() const
{
LayoutSize offset;
@ -371,7 +330,6 @@ void RenderBoxModelObject::paintFillLayerExtended(const PaintInfo& paintInfo, co
bool hasRoundedBorder = style()->hasBorderRadius() && (includeLeftEdge || includeRightEdge);
bool clippedWithLocalScrolling = hasOverflowClip() && bgLayer.attachment() == LocalBackgroundAttachment;
bool isBorderFill = bgLayer.clip() == BorderFillBox;
bool isDocumentElementRenderer = this->isDocumentElement();
bool isBottomLayer = !bgLayer.next();
Color bgColor = color;
@ -381,7 +339,7 @@ void RenderBoxModelObject::paintFillLayerExtended(const PaintInfo& paintInfo, co
bool colorVisible = bgColor.alpha();
// Fast path for drawing simple color backgrounds.
if (!isDocumentElementRenderer && !clippedWithLocalScrolling && !shouldPaintBackgroundImage && isBorderFill && isBottomLayer) {
if (!clippedWithLocalScrolling && !shouldPaintBackgroundImage && isBorderFill && isBottomLayer) {
if (!colorVisible)
return;
@ -472,8 +430,7 @@ void RenderBoxModelObject::paintFillLayerExtended(const PaintInfo& paintInfo, co
if (isBottomLayer) {
IntRect backgroundRect(pixelSnappedIntRect(scrolledPaintRect));
bool boxShadowShouldBeAppliedToBackground = this->boxShadowShouldBeAppliedToBackground(bleedAvoidance, box);
bool isOpaqueRoot = (isDocumentElementRenderer && !bgColor.hasAlpha()) || isDocumentElementWithOpaqueBackground();
if (boxShadowShouldBeAppliedToBackground || !shouldPaintBackgroundImage || !bgLayer.hasOpaqueImage(this) || !bgLayer.hasRepeatXY() || (isOpaqueRoot && !toRenderBox(this)->height())) {
if (boxShadowShouldBeAppliedToBackground || !shouldPaintBackgroundImage || !bgLayer.hasOpaqueImage(this) || !bgLayer.hasRepeatXY()) {
if (!boxShadowShouldBeAppliedToBackground)
backgroundRect.intersect(paintInfo.rect);
@ -481,11 +438,8 @@ void RenderBoxModelObject::paintFillLayerExtended(const PaintInfo& paintInfo, co
if (boxShadowShouldBeAppliedToBackground)
applyBoxShadowForBackground(context, this);
if (isOpaqueRoot && !skipBaseColor) {
paintRootBackgroundColor(paintInfo, rect, bgColor);
} else if (bgColor.alpha()) {
if (bgColor.alpha())
context->fillRect(backgroundRect, bgColor, context->compositeOperation());
}
}
}
@ -740,15 +694,7 @@ void RenderBoxModelObject::calculateBackgroundImageGeometry(const RenderLayerMod
}
}
// The background of the box generated by the root element covers the entire canvas including
// its margins. Since those were added in already, we have to factor them out when computing
// the background positioning area.
if (isDocumentElement()) {
positioningAreaSize = pixelSnappedIntSize(toRenderBox(this)->size() - LayoutSize(left + right, top + bottom), toRenderBox(this)->location());
left += marginLeft();
top += marginTop();
} else
positioningAreaSize = pixelSnappedIntSize(paintRect.size() - LayoutSize(left + right, top + bottom), paintRect.location());
positioningAreaSize = pixelSnappedIntSize(paintRect.size() - LayoutSize(left + right, top + bottom), paintRect.location());
} else {
geometry.setHasNonLocalGeometry();

View File

@ -246,8 +246,6 @@ protected:
bool hasAutoHeightOrContainingBlockWithAutoHeight() const;
bool isDocumentElementWithOpaqueBackground() const;
void paintRootBackgroundColor(const PaintInfo&, const LayoutRect&, const Color&);
public:

View File

@ -239,7 +239,7 @@ void RenderFlexibleBox::layout()
if (logicalHeight() != previousHeight)
relayoutChildren = true;
layoutPositionedObjects(relayoutChildren || isDocumentElement());
layoutPositionedObjects(relayoutChildren);
// FIXME: css3/flexbox/repaint-rtl-column.html seems to issue paint invalidations for more overflow than it needs to.
computeOverflow(clientLogicalBottomAfterRepositioning());

View File

@ -1128,9 +1128,7 @@ RenderLayer* RenderLayer::hitTestChildren(ChildrenIteration childrentoVisit, Ren
bool RenderLayer::intersectsDamageRect(const LayoutRect& layerBounds, const LayoutRect& damageRect, const RenderLayer* rootLayer, const LayoutPoint* offsetFromRoot) const
{
// Always examine the canvas and the root.
// FIXME: Could eliminate the isDocumentElement() check if we fix background painting so that the RenderView
// paints the root's background.
if (isRootLayer() || renderer()->isDocumentElement())
if (isRootLayer())
return true;
// If we aren't an inline flow, and our layer bounds do intersect the damage rect, then we

View File

@ -1842,9 +1842,6 @@ void RenderObject::imageChanged(WrappedImagePtr, const IntRect*)
Element* RenderObject::offsetParent() const
{
if (isDocumentElement())
return 0;
Node* node = 0;
for (RenderObject* ancestor = parent(); ancestor; ancestor = ancestor->parent()) {
// Spec: http://www.w3.org/TR/cssom-view/#offset-attributes

View File

@ -267,8 +267,6 @@ public:
virtual bool isRenderInline() const { return false; }
virtual bool isRenderView() const { return false; }
bool isDocumentElement() const { return document().documentElement() == m_node; }
bool everHadLayout() const { return m_bitfields.everHadLayout(); }
bool alwaysCreateLineBoxesForRenderInline() const

View File

@ -205,32 +205,11 @@ void RenderView::paint(PaintInfo& paintInfo, const LayoutPoint& paintOffset, Vec
paintObject(paintInfo, paintOffset, layers);
}
static inline bool rendererObscuresBackground(RenderBox* rootBox)
{
ASSERT(rootBox);
RenderStyle* style = rootBox->style();
if (style->opacity() != 1
|| style->hasFilter()
|| style->hasTransform())
return false;
return true;
}
void RenderView::paintBoxDecorationBackground(PaintInfo& paintInfo, const LayoutPoint&)
{
if (!view())
return;
bool shouldPaintBackground = true;
Node* documentElement = document().documentElement();
if (RenderBox* rootBox = documentElement ? toRenderBox(documentElement->renderer()) : 0)
shouldPaintBackground = !rendererObscuresBackground(rootBox);
// If painting will entirely fill the view, no need to fill the background.
if (!shouldPaintBackground)
return;
// This code typically only executes if the root element's visibility has been set to hidden,
// if there is a transform on the <html>, or if there is a page scale factor less than 1.
// Only fill with the base background color (typically white) if we're the root document,
@ -369,20 +348,6 @@ IntRect RenderView::unscaledDocumentRect() const
return pixelSnappedIntRect(layoutOverflowRect());
}
bool RenderView::rootBackgroundIsEntirelyFixed() const
{
if (RenderObject* backgroundRenderer = this->backgroundRenderer())
return backgroundRenderer->hasEntirelyFixedBackground();
return false;
}
RenderObject* RenderView::backgroundRenderer() const
{
if (Element* documentElement = document().documentElement())
return documentElement->renderer();
return 0;
}
LayoutRect RenderView::backgroundRect(RenderBox* backgroundRenderer) const
{
return unscaledDocumentRect();
@ -420,20 +385,6 @@ LayoutUnit RenderView::viewLogicalHeightForPercentages() const
return viewLogicalHeight();
}
void RenderView::updateHitTestResult(HitTestResult& result, const LayoutPoint& point)
{
if (result.innerNode())
return;
Node* node = document().documentElement();
if (node) {
result.setInnerNode(node);
if (!result.innerNonSharedNode())
result.setInnerNonSharedNode(node);
result.setLocalPoint(point);
}
}
void RenderView::pushLayoutState(LayoutState& layoutState)
{
m_layoutState = &layoutState;

View File

@ -84,16 +84,11 @@ public:
LayoutState* layoutState() const { return m_layoutState; }
virtual void updateHitTestResult(HitTestResult&, const LayoutPoint&) override;
IntRect unscaledDocumentRect() const;
LayoutRect backgroundRect(RenderBox* backgroundRenderer) const;
IntRect documentRect() const;
// Renderer that paints the root background has background-images which all have background-attachment: fixed.
bool rootBackgroundIsEntirelyFixed() const;
double layoutViewportWidth() const;
double layoutViewportHeight() const;
@ -117,8 +112,6 @@ private:
void positionDialog(RenderBox*);
void positionDialogs();
RenderObject* backgroundRenderer() const;
FrameView* m_frameView;
RawPtr<RenderObject> m_selectionStart;

View File

@ -78,7 +78,6 @@ public:
// Returns the frame the document belongs to or 0 if the document is frameless.
BLINK_EXPORT WebLocalFrame* frame() const;
BLINK_EXPORT WebElement documentElement() const;
BLINK_EXPORT WebString title() const;
BLINK_EXPORT WebURL completeURL(const WebString&) const;
BLINK_EXPORT WebElement getElementById(const WebString&) const;

View File

@ -148,17 +148,6 @@ public:
virtual void unmarkText() = 0;
virtual bool hasMarkedText() const = 0;
virtual WebRange markedRange() const = 0;
// Returns the frame rectangle in window coordinate space of the given text
// range.
virtual bool firstRectForCharacterRange(unsigned location, unsigned length, WebRect&) const = 0;
// Returns the index of a character in the Frame's text stream at the given
// point. The point is in the window coordinate space. Will return
// WTF::notFound if the point is invalid.
virtual size_t characterIndexForPoint(const WebPoint&) const = 0;
// Supports commands like Undo, Redo, Cut, Copy, Paste, SelectAll,
// Unselect, etc. See EditorCommand.cpp for the full list of supported
// commands.

View File

@ -111,18 +111,9 @@ public:
// Returns true if there is an ongoing composition or the text is inserted.
virtual bool confirmComposition(const WebString& text) = 0;
// Fetches the character range of the current composition, also called the
// "marked range." Returns true and fills the out-paramters on success;
// returns false on failure.
virtual bool compositionRange(size_t* location, size_t* length) = 0;
// Returns information about the current text input of this WebWidget.
virtual WebTextInputInfo textInputInfo() = 0;
// The page background color. Can be used for filling in areas without
// content.
virtual WebColor backgroundColor() const = 0;
protected:
~WebWidget() { }
};

View File

@ -78,11 +78,6 @@ WebLocalFrame* WebDocument::frame() const
return WebLocalFrameImpl::fromFrame(constUnwrap<Document>()->frame());
}
WebElement WebDocument::documentElement() const
{
return WebElement(constUnwrap<Document>()->documentElement());
}
WebString WebDocument::title() const
{
return WebString(constUnwrap<Document>()->title());

View File

@ -154,7 +154,7 @@ static void frameContentAsPlainText(size_t maxChars, LocalFrame* frame, StringBu
// Select the document body.
RefPtr<Range> range(document->createRange());
TrackExceptionState exceptionState;
range->selectNodeContents(document->documentElement(), exceptionState);
range->selectNodeContents(document, exceptionState);
if (!exceptionState.had_exception()) {
// The text iterator will walk nodes giving us text. This is similar to
@ -293,42 +293,6 @@ bool WebLocalFrameImpl::hasMarkedText() const
return frame()->inputMethodController().hasComposition();
}
WebRange WebLocalFrameImpl::markedRange() const
{
return frame()->inputMethodController().compositionRange();
}
bool WebLocalFrameImpl::firstRectForCharacterRange(unsigned location, unsigned length, WebRect& rect) const
{
if ((location + length < location) && (location + length))
length = 0;
Element* editable = frame()->selection().rootEditableElementOrDocumentElement();
ASSERT(editable);
RefPtr<Range> range = PlainTextRange(location, location + length).createRange(*editable);
if (!range)
return false;
IntRect intRect = frame()->editor().firstRectForRange(range.get());
rect = WebRect(intRect);
rect = frame()->view()->contentsToWindow(rect);
return true;
}
size_t WebLocalFrameImpl::characterIndexForPoint(const WebPoint& webPoint) const
{
if (!frame())
return kNotFound;
IntPoint point = frame()->view()->windowToContents(webPoint);
HitTestResult result = frame()->eventHandler().hitTestResultAtPoint(point, HitTestRequest::ReadOnly | HitTestRequest::Active);
RefPtr<Range> range = frame()->rangeForPoint(result.roundedPointInInnerNodeFrame());
if (!range)
return kNotFound;
Element* editable = frame()->selection().rootEditableElementOrDocumentElement();
ASSERT(editable);
return PlainTextRange::create(*editable, *range.get()).start();
}
bool WebLocalFrameImpl::executeCommand(const WebString& name, const WebNode& node)
{
ASSERT(frame());

View File

@ -76,9 +76,6 @@ public:
virtual void setMarkedText(const WebString&, unsigned location, unsigned length) override;
virtual void unmarkText() override;
virtual bool hasMarkedText() const override;
virtual WebRange markedRange() const override;
virtual bool firstRectForCharacterRange(unsigned location, unsigned length, WebRect&) const override;
virtual size_t characterIndexForPoint(const WebPoint&) const override;
virtual bool executeCommand(const WebString&, const WebNode& = WebNode()) override;
virtual bool executeCommand(const WebString&, const WebString& value, const WebNode& = WebNode()) override;
virtual bool isCommandEnabled(const WebString&) const override;

View File

@ -101,8 +101,8 @@ WebRange WebRange::expandedToParagraph() const
WebRange WebRange::fromDocumentRange(WebLocalFrame* frame, int start, int length)
{
LocalFrame* webFrame = toWebLocalFrameImpl(frame)->frame();
Element* selectionRoot = webFrame->selection().rootEditableElement();
ContainerNode* scope = selectionRoot ? selectionRoot : webFrame->document()->documentElement();
ContainerNode* selectionRoot = webFrame->selection().rootEditableElement();
ContainerNode* scope = selectionRoot ? selectionRoot : webFrame->document();
return PlainTextRange(start, start + length).createRange(*scope);
}

View File

@ -453,26 +453,6 @@ bool WebViewImpl::confirmComposition(const WebString& text, ConfirmCompositionBe
return focused->inputMethodController().confirmCompositionOrInsertText(text, selectionBehavior == KeepSelection ? InputMethodController::KeepSelection : InputMethodController::DoNotKeepSelection);
}
bool WebViewImpl::compositionRange(size_t* location, size_t* length)
{
LocalFrame* focused = focusedCoreFrame();
if (!focused || !m_imeAcceptEvents)
return false;
RefPtr<Range> range = focused->inputMethodController().compositionRange();
if (!range)
return false;
Element* editable = focused->selection().rootEditableElementOrDocumentElement();
ASSERT(editable);
PlainTextRange plainTextRange(PlainTextRange::create(*editable, *range.get()));
if (plainTextRange.isNull())
return false;
*location = plainTextRange.start();
*length = plainTextRange.length();
return true;
}
WebTextInputInfo WebViewImpl::textInputInfo()
{
WebTextInputInfo info;
@ -582,18 +562,6 @@ WebVector<WebCompositionUnderline> WebViewImpl::compositionUnderlines() const
return results;
}
WebColor WebViewImpl::backgroundColor() const
{
if (isTransparent())
return Color::transparent;
if (!m_page)
return m_baseBackgroundColor;
if (!m_page->mainFrame())
return m_baseBackgroundColor;
FrameView* view = m_page->mainFrame()->view();
return view->documentBackgroundColor().rgb();
}
// WebView --------------------------------------------------------------------
WebSettingsImpl* WebViewImpl::settingsImpl()
@ -624,9 +592,7 @@ void WebViewImpl::injectModule(const WebString& path)
RefPtr<Document> document = m_page->mainFrame()->document();
RefPtr<HTMLImportElement> import = HTMLImportElement::create(*document);
import->setAttribute(HTMLNames::srcAttr, path);
if (!document->documentElement())
return;
document->documentElement()->appendChild(import.release());
document->appendChild(import.release());
}
void WebViewImpl::setFocusedFrame(WebFrame* frame)

View File

@ -81,9 +81,7 @@ public:
virtual bool confirmComposition() override;
virtual bool confirmComposition(ConfirmCompositionBehavior selectionBehavior) override;
virtual bool confirmComposition(const WebString& text) override;
virtual bool compositionRange(size_t* location, size_t* length) override;
virtual WebTextInputInfo textInputInfo() override;
virtual WebColor backgroundColor() const override;
// WebView methods:
virtual void setMainFrame(WebFrame*) override;

View File

@ -1,10 +1,9 @@
layer at (0,0) size 800x600
RenderView {#document} at (0,0) size 800x600
layer at (0,0) size 800x238
RenderBlock {sky} at (0,0) size 800x238
RenderParagraph (anonymous) at (0,0) size 800x38
RenderText {#text} at (0,0) size 778x38
text run at (0,0) width 778: "Test passes if the image below shows nested green, blue and yellow squares with a dotted black"
text run at (0,19) width 59: "border."
RenderBlock {div} at (0,38) size 200x200 [border: (25px dotted #000000)]
RenderBlock {sky} at (0,0) size 800x238
RenderParagraph (anonymous) at (0,0) size 800x38
RenderText {#text} at (0,0) size 778x38
text run at (0,0) width 778: "Test passes if the image below shows nested green, blue and yellow squares with a dotted black"
text run at (0,19) width 59: "border."
RenderBlock {div} at (0,38) size 200x200 [border: (25px dotted #000000)]

View File

@ -1,24 +1,23 @@
layer at (0,0) size 800x600
RenderView {#document} at (0,0) size 800x600
layer at (0,0) size 800x353
RenderBlock {sky} at (0,0) size 800x353
RenderBlock {h3} at (0,0) size 800x19
RenderParagraph (anonymous) at (0,0) size 800x19
RenderText {#text} at (0,0) size 92x19
text run at (0,0) width 92: "It passes if:"
RenderBlock {ul} at (0,19) size 800x57
RenderBlock {li} at (0,0) size 800x19
RenderBlock {sky} at (0,0) size 800x353
RenderBlock {h3} at (0,0) size 800x19
RenderParagraph (anonymous) at (0,0) size 800x19
RenderText {#text} at (0,0) size 511x19
text run at (0,0) width 511: "the canvas content has rounded corners (top-left and top-right)"
RenderBlock {li} at (0,19) size 800x19
RenderParagraph (anonymous) at (0,0) size 800x19
RenderText {#text} at (0,0) size 457x19
text run at (0,0) width 457: "the 10px red border is visible around the canvas content"
RenderBlock {li} at (0,38) size 800x19
RenderParagraph (anonymous) at (0,0) size 800x19
RenderText {#text} at (0,0) size 200x19
text run at (0,0) width 200: "gray border is not visible"
RenderText {#text} at (0,0) size 92x19
text run at (0,0) width 92: "It passes if:"
RenderBlock {ul} at (0,19) size 800x57
RenderBlock {li} at (0,0) size 800x19
RenderParagraph (anonymous) at (0,0) size 800x19
RenderText {#text} at (0,0) size 511x19
text run at (0,0) width 511: "the canvas content has rounded corners (top-left and top-right)"
RenderBlock {li} at (0,19) size 800x19
RenderParagraph (anonymous) at (0,0) size 800x19
RenderText {#text} at (0,0) size 457x19
text run at (0,0) width 457: "the 10px red border is visible around the canvas content"
RenderBlock {li} at (0,38) size 800x19
RenderParagraph (anonymous) at (0,0) size 800x19
RenderText {#text} at (0,0) size 200x19
text run at (0,0) width 200: "gray border is not visible"
layer at (0,76) size 277x277
RenderHTMLCanvas {canvas} at (0,76) size 277x277 [bgcolor=#808080] [border: (10px solid #FF0000)]

View File

@ -1,13 +1,12 @@
layer at (0,0) size 800x600
RenderView {#document} at (0,0) size 800x600
layer at (0,0) size 800x19
RenderBlock {sky} at (0,0) size 800x19
RenderBlock {div} at (0,0) size 800x19
RenderParagraph {span} at (0,0) size 800x19
RenderBlock (inline-block) {div} at (0,0) size 25.22x19
RenderParagraph (anonymous) at (0,0) size 25.22x19
RenderText {#text} at (0,0) size 26x19
text run at (0,0) width 26: "foo"
RenderText {#text} at (25,0) size 27x19
text run at (25,0) width 27: "bar"
RenderBlock {sky} at (0,0) size 800x19
RenderBlock {div} at (0,0) size 800x19
RenderParagraph {span} at (0,0) size 800x19
RenderBlock (inline-block) {div} at (0,0) size 25.22x19
RenderParagraph (anonymous) at (0,0) size 25.22x19
RenderText {#text} at (0,0) size 26x19
text run at (0,0) width 26: "foo"
RenderText {#text} at (25,0) size 27x19
text run at (25,0) width 27: "bar"

View File

@ -1,7 +1,6 @@
layer at (0,0) size 800x600
RenderView {#document} at (0,0) size 800x600
layer at (0,0) size 800x94
RenderBlock {sky} at (0,0) size 800x94
RenderBlock {sky} at (0,0) size 800x94
layer at (0,0) size 56x69 clip at (3,3) size 50x63
RenderBlock {div} at (0,0) size 56x69 [border: (3px solid #0000FF)]
RenderParagraph (anonymous) at (3,3) size 50x19

View File

@ -1,6 +1,5 @@
layer at (0,0) size 800x600
RenderView {#document} at (0,0) size 800x600
layer at (0,0) size 800x50
RenderBlock {sky} at (0,0) size 800x50
RenderBlock {div} at (0,0) size 50x50 [bgcolor=#FFC0CB]
RenderBlock {sky} at (0,0) size 800x50
RenderBlock {div} at (0,0) size 50x50 [bgcolor=#FFC0CB]

View File

@ -9,7 +9,7 @@ void main () {
initUnit();
test('should have various casing', () {
expect(document.documentElement.tagName, equals('CamelCase'));
expect(document.firstElementChild.tagName, equals('CamelCase'));
var element = document.createElement('CamelCase');
expect(element.tagName, equals('CamelCase'));

View File

@ -1,8 +1,7 @@
layer at (0,0) size 800x600
RenderView {#document} at (0,0) size 800x600
layer at (0,0) size 800x19
RenderBlock {foo} at (0,0) size 800x19
RenderParagraph (anonymous) at (0,0) size 800x19
RenderText {#text} at (0,0) size 99x19
text run at (0,0) width 99: "Hello World!"
RenderBlock {foo} at (0,0) size 800x19
RenderParagraph (anonymous) at (0,0) size 800x19
RenderText {#text} at (0,0) size 99x19
text run at (0,0) width 99: "Hello World!"

View File

@ -1,13 +1,12 @@
layer at (0,0) size 800x600
RenderView {#document} at (0,0) size 800x600
layer at (0,0) size 800x137
RenderBlock {div} at (0,0) size 800x137
RenderBlock {div} at (32,32) size 736x38
RenderParagraph (anonymous) at (0,0) size 736x38
RenderText {#text} at (0,0) size 191x38
text run at (0,0) width 191: "about:blank"
RenderBlock {div} at (16,110) size 768x19 [color=#BCD8F5]
RenderParagraph (anonymous) at (0,0) size 768x19
RenderText {#text} at (0,0) size 152x19
text run at (0,0) width 152: "Welcome to Sky!"
RenderBlock {div} at (0,0) size 800x137
RenderBlock {div} at (32,32) size 736x38
RenderParagraph (anonymous) at (0,0) size 736x38
RenderText {#text} at (0,0) size 191x38
text run at (0,0) width 191: "about:blank"
RenderBlock {div} at (16,110) size 768x19 [color=#BCD8F5]
RenderParagraph (anonymous) at (0,0) size 768x19
RenderText {#text} at (0,0) size 152x19
text run at (0,0) width 152: "Welcome to Sky!"

View File

@ -1,25 +1,24 @@
layer at (0,0) size 800x600
RenderView {#document} at (0,0) size 800x600
layer at (0,0) size 800x506
RenderBlock {sky} at (0,0) size 800x506
RenderBlock {div} at (0,0) size 800x228
RenderParagraph (anonymous) at (0,0) size 800x19
RenderText {#text} at (0,0) size 76x19
text run at (0,0) width 76: "This is an"
RenderParagraph (anonymous) at (0,209) size 800x19
RenderText {#text} at (0,0) size 72x19
text run at (0,0) width 72: "element."
RenderBlock {div} at (0,228) size 800x200
RenderParagraph (anonymous) at (0,0) size 800x19
RenderText {#text} at (0,0) size 99x19
text run at (0,0) width 99: "Placeholder."
RenderBlock {div} at (0,428) size 800x78
RenderParagraph (anonymous) at (0,0) size 800x19
RenderText {#text} at (0,0) size 218x19
text run at (0,0) width 218: "Small iframe should render"
RenderParagraph (anonymous) at (0,59) size 800x19
RenderText {#text} at (0,0) size 76x19
text run at (0,0) width 76: "correctly."
RenderBlock {sky} at (0,0) size 800x506
RenderBlock {div} at (0,0) size 800x228
RenderParagraph (anonymous) at (0,0) size 800x19
RenderText {#text} at (0,0) size 76x19
text run at (0,0) width 76: "This is an"
RenderParagraph (anonymous) at (0,209) size 800x19
RenderText {#text} at (0,0) size 72x19
text run at (0,0) width 72: "element."
RenderBlock {div} at (0,228) size 800x200
RenderParagraph (anonymous) at (0,0) size 800x19
RenderText {#text} at (0,0) size 99x19
text run at (0,0) width 99: "Placeholder."
RenderBlock {div} at (0,428) size 800x78
RenderParagraph (anonymous) at (0,0) size 800x19
RenderText {#text} at (0,0) size 218x19
text run at (0,0) width 218: "Small iframe should render"
RenderParagraph (anonymous) at (0,59) size 800x19
RenderText {#text} at (0,0) size 76x19
text run at (0,0) width 76: "correctly."
layer at (0,19) size 340x190
RenderReplaced {iframe} at (0,19) size 340x190 [border: (20px solid #000000)]
layer at (0,447) size 300x40

View File

@ -1,7 +1,6 @@
layer at (0,0) size 800x600
RenderView {#document} at (0,0) size 800x600
layer at (0,0) size 800x89
RenderBlock {foo} at (0,0) size 800x89
RenderImage {img} at (0,0) size 256x64
RenderImage {img} at (0,64) size 100x25
RenderBlock {foo} at (0,0) size 800x89
RenderImage {img} at (0,0) size 256x64
RenderImage {img} at (0,64) size 100x25

View File

@ -9,7 +9,7 @@ element.setAttribute("as", "hello");
element.addEventListener("load", function() {
document.getElementById("result1").textContent = "PASS: Load event fired.";
});
document.documentElement.appendChild(element);
document.firstElementChild.appendChild(element);
</script>
<script>
document.getElementById("result2").textContent = hello;

View File

@ -13,8 +13,7 @@ void main() {
initUnit();
test('should be able to send events', () {
var sky = document.querySelector('sky');
sky.addEventListener('keypress', expectAsync((event) {
document.addEventListener('keypress', expectAsync((event) {
expect(event.type, equals('keypress'));
expect(event.key, equals(0));
expect(event.charCode, equals(0x41));