From dff66fb1b7c3cc05f6e52ed9dd428060db40d367 Mon Sep 17 00:00:00 2001 From: Adam Barth Date: Tue, 17 Feb 2015 16:20:07 -0800 Subject: [PATCH] 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 --- engine/core/core.gni | 2 - .../core/css/resolver/SharedStyleFinder.cpp | 2 +- engine/core/css/resolver/StyleAdjuster.cpp | 21 +-- .../core/css/resolver/StyleBuilderCustom.cpp | 3 - engine/core/css/resolver/StyleResolver.cpp | 6 +- engine/core/dom/ContainerNode.cpp | 15 -- engine/core/dom/Document.cpp | 26 +--- engine/core/dom/Document.h | 15 -- engine/core/dom/Document.idl | 2 - engine/core/dom/Element.cpp | 12 -- engine/core/dom/Position.cpp | 10 +- engine/core/editing/Editor.cpp | 16 +- engine/core/editing/Editor.h | 4 +- engine/core/editing/FrameSelection.cpp | 14 +- engine/core/editing/FrameSelection.h | 1 - engine/core/editing/SpellChecker.cpp | 2 +- engine/core/editing/SurroundingText.cpp | 142 ------------------ engine/core/editing/SurroundingText.h | 65 -------- engine/core/editing/VisibleSelection.cpp | 46 ------ engine/core/editing/VisibleSelection.h | 2 - engine/core/editing/VisibleUnits.cpp | 25 +-- engine/core/editing/htmlediting.cpp | 2 +- engine/core/frame/FrameView.cpp | 25 --- engine/core/frame/FrameView.h | 2 - engine/core/frame/LocalDOMWindow.cpp | 6 + engine/core/frame/LocalDOMWindow.h | 1 + engine/core/frame/NewEventHandler.cpp | 4 +- engine/core/page/EventHandler.cpp | 48 +----- engine/core/page/EventHandler.h | 3 - engine/core/rendering/RenderBlock.cpp | 27 +--- engine/core/rendering/RenderBlock.h | 2 - engine/core/rendering/RenderBlockFlow.cpp | 2 +- engine/core/rendering/RenderBox.cpp | 35 +---- .../core/rendering/RenderBoxModelObject.cpp | 62 +------- engine/core/rendering/RenderBoxModelObject.h | 2 - engine/core/rendering/RenderFlexibleBox.cpp | 2 +- engine/core/rendering/RenderLayer.cpp | 4 +- engine/core/rendering/RenderObject.cpp | 3 - engine/core/rendering/RenderObject.h | 2 - engine/core/rendering/RenderView.cpp | 49 ------ engine/core/rendering/RenderView.h | 7 - engine/public/web/WebDocument.h | 1 - engine/public/web/WebFrame.h | 11 -- engine/public/web/WebWidget.h | 9 -- engine/web/WebDocument.cpp | 5 - engine/web/WebLocalFrameImpl.cpp | 38 +---- engine/web/WebLocalFrameImpl.h | 3 - engine/web/WebRange.cpp | 4 +- engine/web/WebViewImpl.cpp | 36 +---- engine/web/WebViewImpl.h | 2 - ...ound-opaque-clipped-gradients-expected.txt | 13 +- .../canvas-rounded-corners-expected.txt | 35 +++-- tests/layout/continuations-expected.txt | 19 ++- tests/layout/ellipsis-expected.txt | 3 +- tests/layout/fixed-width-expected.txt | 5 +- tests/lowlevel/camel-case.sky | 2 +- tests/lowlevel/hello-world-expected.txt | 9 +- tests/lowlevel/home-expected.txt | 19 ++- tests/lowlevel/iframe-expected.txt | 39 +++-- tests/lowlevel/img-expected.txt | 7 +- tests/modules/load-event.sky | 2 +- tests/services/event-sender.sky | 3 +- 62 files changed, 162 insertions(+), 822 deletions(-) delete mode 100644 engine/core/editing/SurroundingText.cpp delete mode 100644 engine/core/editing/SurroundingText.h diff --git a/engine/core/core.gni b/engine/core/core.gni index 6f2a740fbee..8088c48d1ec 100644 --- a/engine/core/core.gni +++ b/engine/core/core.gni @@ -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", diff --git a/engine/core/css/resolver/SharedStyleFinder.cpp b/engine/core/css/resolver/SharedStyleFinder.cpp index 8ee85922e22..538e5f851bc 100644 --- a/engine/core/css/resolver/SharedStyleFinder.cpp +++ b/engine/core/css/resolver/SharedStyleFinder.cpp @@ -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; } diff --git a/engine/core/css/resolver/StyleAdjuster.cpp b/engine/core/css/resolver/StyleAdjuster.cpp index 3ca4fd0b15e..8e0110d5837 100644 --- a/engine/core/css/resolver/StyleAdjuster.cpp +++ b/engine/core/css/resolver/StyleAdjuster.cpp @@ -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, diff --git a/engine/core/css/resolver/StyleBuilderCustom.cpp b/engine/core/css/resolver/StyleBuilderCustom.cpp index 21977bac1c1..61a5fd50ba6 100644 --- a/engine/core/css/resolver/StyleBuilderCustom.cpp +++ b/engine/core/css/resolver/StyleBuilderCustom.cpp @@ -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) diff --git a/engine/core/css/resolver/StyleResolver.cpp b/engine/core/css/resolver/StyleResolver.cpp index ea8dbf71cc9..6bfa49fbc93 100644 --- a/engine/core/css/resolver/StyleResolver.cpp +++ b/engine/core/css/resolver/StyleResolver.cpp @@ -195,8 +195,6 @@ PassRefPtr 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 StyleResolver::createAnimatableValueSnapshot(StyleRe PassRefPtr 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); diff --git a/engine/core/dom/ContainerNode.cpp b/engine/core/dom/ContainerNode.cpp index 97f3708d037..ccdf11e9541 100644 --- a/engine/core/dom/ContainerNode.cpp +++ b/engine/core/dom/ContainerNode.cpp @@ -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 ContainerNode::insertBefore(PassRefPtr newChild, Node* refChild, ExceptionState& exceptionState) diff --git a/engine/core/dom/Document.cpp b/engine/core/dom/Document.cpp index 06b06c062a8..d742219eb11 100644 --- a/engine/core/dom/Document.cpp +++ b/engine/core/dom/Document.cpp @@ -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 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& elementData) diff --git a/engine/core/dom/Document.h b/engine/core/dom/Document.h index 08f73dafcf8..6555797191d 100644 --- a/engine/core/dom/Document.h +++ b/engine/core/dom/Document.h @@ -165,11 +165,6 @@ public: String outgoingReferrer(); - Element* documentElement() const - { - return m_documentElement.get(); - } - Location* location() const; PassRefPtr 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 cloneNode(bool deep = true) override final; @@ -620,7 +610,6 @@ private: RefPtr m_focusedElement; RefPtr m_hoverNode; RefPtr m_activeHoverElement; - RefPtr m_documentElement; UserActionElementSet m_userActionElements; typedef HashSet > AttachedRangeSet; @@ -670,8 +659,6 @@ private: bool m_didSetReferrerPolicy; ReferrerPolicy m_referrerPolicy; - bool m_directionSetOnDocumentElement; - RefPtr m_mediaQueryMatcher; RefPtr m_scriptedAnimationController; @@ -726,8 +713,6 @@ inline bool Node::isDocumentNode() const return this == document(); } -Node* eventTargetNodeForDocument(Document*); - } // namespace blink #ifndef NDEBUG diff --git a/engine/core/dom/Document.idl b/engine/core/dom/Document.idl index e8bd346c081..5b34c53b4d5 100644 --- a/engine/core/dom/Document.idl +++ b/engine/core/dom/Document.idl @@ -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(); diff --git a/engine/core/dom/Element.cpp b/engine/core/dom/Element.cpp index d97f2d2f221..276310d3893 100644 --- a/engine/core/dom/Element.cpp +++ b/engine/core/dom/Element.cpp @@ -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; diff --git a/engine/core/dom/Position.cpp b/engine/core/dom/Position.cpp index d7093bb4bb8..8cd1499aee4 100644 --- a/engine/core/dom/Position.cpp +++ b/engine/core/dom/Position.cpp @@ -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()) diff --git a/engine/core/editing/Editor.cpp b/engine/core/editing/Editor.cpp index 1eaed20ec81..ad478834d09 100644 --- a/engine/core/editing/Editor.cpp +++ b/engine/core/editing/Editor.cpp @@ -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 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()); } diff --git a/engine/core/editing/Editor.h b/engine/core/editing/Editor.h index cd7dc03e90f..d9e0cef70e2 100644 --- a/engine/core/editing/Editor.h +++ b/engine/core/editing/Editor.h @@ -176,7 +176,7 @@ public: void pasteAsFragment(PassRefPtr, 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 rangeOfString(const String&, Range*, FindOptions); diff --git a/engine/core/editing/FrameSelection.cpp b/engine/core/editing/FrameSelection.cpp index 17adda6653e..d24777918cd 100644 --- a/engine/core/editing/FrameSelection.cpp +++ b/engine/core/editing/FrameSelection.cpp @@ -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) diff --git a/engine/core/editing/FrameSelection.h b/engine/core/editing/FrameSelection.h index 4e8d1d233a3..ec5e8d1e9ab 100644 --- a/engine/core/editing/FrameSelection.h +++ b/engine/core/editing/FrameSelection.h @@ -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(); } diff --git a/engine/core/editing/SpellChecker.cpp b/engine/core/editing/SpellChecker.cpp index 6d01adbaa44..f3496631e7e 100644 --- a/engine/core/editing/SpellChecker.cpp +++ b/engine/core/editing/SpellChecker.cpp @@ -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; diff --git a/engine/core/editing/SurroundingText.cpp b/engine/core/editing/SurroundingText.cpp deleted file mode 100644 index dd23f2e355a..00000000000 --- a/engine/core/editing/SurroundingText.cpp +++ /dev/null @@ -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 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 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 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 diff --git a/engine/core/editing/SurroundingText.h b/engine/core/editing/SurroundingText.h deleted file mode 100644 index b46c6a5a3e4..00000000000 --- a/engine/core/editing/SurroundingText.h +++ /dev/null @@ -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 rangeFromContentOffsets(unsigned startOffsetInContent, unsigned endOffsetInContent); - -private: - void initialize(const Position&, const Position&, unsigned maxLength); - - RefPtr m_contentRange; - size_t m_startOffsetInContent; - size_t m_endOffsetInContent; -}; - -} // namespace blink - -#endif // SKY_ENGINE_CORE_EDITING_SURROUNDINGTEXT_H_ - diff --git a/engine/core/editing/VisibleSelection.cpp b/engine/core/editing/VisibleSelection.cpp index 0cc876374bf..2a8c977b352 100644 --- a/engine/core/editing/VisibleSelection.cpp +++ b/engine/core/editing/VisibleSelection.cpp @@ -264,52 +264,6 @@ bool VisibleSelection::expandUsingGranularity(TextGranularity granularity) return true; } -static PassRefPtr 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 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 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. diff --git a/engine/core/editing/VisibleSelection.h b/engine/core/editing/VisibleSelection.h index 8d67fe7d9f8..ab213ac36b6 100644 --- a/engine/core/editing/VisibleSelection.h +++ b/engine/core/editing/VisibleSelection.h @@ -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. diff --git a/engine/core/editing/VisibleUnits.cpp b/engine/core/editing/VisibleUnits.cpp index c6917bd66ac..847de738297 100644 --- a/engine/core/editing/VisibleUnits.cpp +++ b/engine/core/editing/VisibleUnits.cpp @@ -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) diff --git a/engine/core/editing/htmlediting.cpp b/engine/core/editing/htmlediting.cpp index 7eca4ecad0c..369121b493b 100644 --- a/engine/core/editing/htmlediting.cpp +++ b/engine/core/editing/htmlediting.cpp @@ -837,7 +837,7 @@ int indexForVisiblePosition(const VisiblePosition& visiblePosition, RefPtr range = Range::create(document, firstPositionInNode(scope.get()), p.parentAnchoredEquivalent()); diff --git a/engine/core/frame/FrameView.cpp b/engine/core/frame/FrameView.cpp index 13efb7d9152..78824ceb484 100644 --- a/engine/core/frame/FrameView.cpp +++ b/engine/core/frame/FrameView.cpp @@ -621,31 +621,6 @@ float FrameView::inputEventsScaleFactor() const return pageScale * m_inputEventsScaleFactorForEmulation; } -Color FrameView::documentBackgroundColor() const -{ - // 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 background color, and the - // 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 diff --git a/engine/core/frame/FrameView.h b/engine/core/frame/FrameView.h index 40a8b3707aa..bcf7b4abad7 100644 --- a/engine/core/frame/FrameView.h +++ b/engine/core/frame/FrameView.h @@ -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(); diff --git a/engine/core/frame/LocalDOMWindow.cpp b/engine/core/frame/LocalDOMWindow.cpp index fc35a2003f4..8960f7ba1bb 100644 --- a/engine/core/frame/LocalDOMWindow.cpp +++ b/engine/core/frame/LocalDOMWindow.cpp @@ -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 LocalDOMWindow::matchMedia(const String& media) { return document() ? document()->mediaQueryMatcher().matchMedia(media) : nullptr; diff --git a/engine/core/frame/LocalDOMWindow.h b/engine/core/frame/LocalDOMWindow.h index bc13a4f4300..4a03070bbd9 100644 --- a/engine/core/frame/LocalDOMWindow.h +++ b/engine/core/frame/LocalDOMWindow.h @@ -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*); diff --git a/engine/core/frame/NewEventHandler.cpp b/engine/core/frame/NewEventHandler.cpp index 1f546958e44..9154289fa31 100644 --- a/engine/core/frame/NewEventHandler.cpp +++ b/engine/core/frame/NewEventHandler.cpp @@ -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; diff --git a/engine/core/page/EventHandler.cpp b/engine/core/page/EventHandler.cpp index 57cdddee619..085d29e51e9 100644 --- a/engine/core/page/EventHandler.cpp +++ b/engine/core/page/EventHandler.cpp @@ -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), diff --git a/engine/core/page/EventHandler.h b/engine/core/page/EventHandler.h index f1cb859f4e3..9c8f66f0151 100644 --- a/engine/core/page/EventHandler.h +++ b/engine/core/page/EventHandler.h @@ -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*); diff --git a/engine/core/rendering/RenderBlock.cpp b/engine/core/rendering/RenderBlock.cpp index 6510e9a3b41..d2a203a5ae7 100644 --- a/engine/core/rendering/RenderBlock.cpp +++ b/engine/core/rendering/RenderBlock.cpp @@ -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 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 diff --git a/engine/core/rendering/RenderBlock.h b/engine/core/rendering/RenderBlock.h index 6ef5757d304..729b8ea2544 100644 --- a/engine/core/rendering/RenderBlock.h +++ b/engine/core/rendering/RenderBlock.h @@ -294,8 +294,6 @@ private: bool widthAvailableToChildrenHasChanged(); protected: - bool createsBlockFormattingContext() const; - virtual bool updateLogicalWidthAndColumnWidth(); protected: diff --git a/engine/core/rendering/RenderBlockFlow.cpp b/engine/core/rendering/RenderBlockFlow.cpp index a55be0e8030..dffde38cce7 100644 --- a/engine/core/rendering/RenderBlockFlow.cpp +++ b/engine/core/rendering/RenderBlockFlow.cpp @@ -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); diff --git a/engine/core/rendering/RenderBox.cpp b/engine/core/rendering/RenderBox.cpp index 71e8f4907e5..8a0b39b6ae4 100644 --- a/engine/core/rendering/RenderBox.cpp +++ b/engine/core/rendering/RenderBox.cpp @@ -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_reverse_iterator topLayer = layers.rend(); for (Vector::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; } diff --git a/engine/core/rendering/RenderBoxModelObject.cpp b/engine/core/rendering/RenderBoxModelObject.cpp index a0322779efe..bfa618e6b6a 100644 --- a/engine/core/rendering/RenderBoxModelObject.cpp +++ b/engine/core/rendering/RenderBoxModelObject.cpp @@ -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 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(); diff --git a/engine/core/rendering/RenderBoxModelObject.h b/engine/core/rendering/RenderBoxModelObject.h index 75529d8aa80..5b6afacb3f0 100644 --- a/engine/core/rendering/RenderBoxModelObject.h +++ b/engine/core/rendering/RenderBoxModelObject.h @@ -246,8 +246,6 @@ protected: bool hasAutoHeightOrContainingBlockWithAutoHeight() const; - bool isDocumentElementWithOpaqueBackground() const; - void paintRootBackgroundColor(const PaintInfo&, const LayoutRect&, const Color&); public: diff --git a/engine/core/rendering/RenderFlexibleBox.cpp b/engine/core/rendering/RenderFlexibleBox.cpp index d7dfbdba77f..e50ed6ea4a6 100644 --- a/engine/core/rendering/RenderFlexibleBox.cpp +++ b/engine/core/rendering/RenderFlexibleBox.cpp @@ -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()); diff --git a/engine/core/rendering/RenderLayer.cpp b/engine/core/rendering/RenderLayer.cpp index deecbfdad92..a3e8e8e4efb 100644 --- a/engine/core/rendering/RenderLayer.cpp +++ b/engine/core/rendering/RenderLayer.cpp @@ -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 diff --git a/engine/core/rendering/RenderObject.cpp b/engine/core/rendering/RenderObject.cpp index 56635652efb..00e3215cc82 100644 --- a/engine/core/rendering/RenderObject.cpp +++ b/engine/core/rendering/RenderObject.cpp @@ -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 diff --git a/engine/core/rendering/RenderObject.h b/engine/core/rendering/RenderObject.h index 19775d31d55..49343f18c76 100644 --- a/engine/core/rendering/RenderObject.h +++ b/engine/core/rendering/RenderObject.h @@ -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 diff --git a/engine/core/rendering/RenderView.cpp b/engine/core/rendering/RenderView.cpp index 869d0f41bdb..312b654e0fe 100644 --- a/engine/core/rendering/RenderView.cpp +++ b/engine/core/rendering/RenderView.cpp @@ -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 , 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; diff --git a/engine/core/rendering/RenderView.h b/engine/core/rendering/RenderView.h index f3f40bf034e..463eaac783f 100644 --- a/engine/core/rendering/RenderView.h +++ b/engine/core/rendering/RenderView.h @@ -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 m_selectionStart; diff --git a/engine/public/web/WebDocument.h b/engine/public/web/WebDocument.h index 9ec60a61e65..1645619f899 100644 --- a/engine/public/web/WebDocument.h +++ b/engine/public/web/WebDocument.h @@ -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; diff --git a/engine/public/web/WebFrame.h b/engine/public/web/WebFrame.h index 81e79a5884a..df747da8279 100644 --- a/engine/public/web/WebFrame.h +++ b/engine/public/web/WebFrame.h @@ -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. diff --git a/engine/public/web/WebWidget.h b/engine/public/web/WebWidget.h index 4a394aa61b9..7c7fd4006a6 100644 --- a/engine/public/web/WebWidget.h +++ b/engine/public/web/WebWidget.h @@ -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() { } }; diff --git a/engine/web/WebDocument.cpp b/engine/web/WebDocument.cpp index 2c247d5771a..0d3a7f9d913 100644 --- a/engine/web/WebDocument.cpp +++ b/engine/web/WebDocument.cpp @@ -78,11 +78,6 @@ WebLocalFrame* WebDocument::frame() const return WebLocalFrameImpl::fromFrame(constUnwrap()->frame()); } -WebElement WebDocument::documentElement() const -{ - return WebElement(constUnwrap()->documentElement()); -} - WebString WebDocument::title() const { return WebString(constUnwrap()->title()); diff --git a/engine/web/WebLocalFrameImpl.cpp b/engine/web/WebLocalFrameImpl.cpp index 94d5c6480c0..08e46fd0f2d 100644 --- a/engine/web/WebLocalFrameImpl.cpp +++ b/engine/web/WebLocalFrameImpl.cpp @@ -154,7 +154,7 @@ static void frameContentAsPlainText(size_t maxChars, LocalFrame* frame, StringBu // Select the document body. RefPtr 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 = 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 = 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()); diff --git a/engine/web/WebLocalFrameImpl.h b/engine/web/WebLocalFrameImpl.h index 6081fc07adb..9d31f669665 100644 --- a/engine/web/WebLocalFrameImpl.h +++ b/engine/web/WebLocalFrameImpl.h @@ -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; diff --git a/engine/web/WebRange.cpp b/engine/web/WebRange.cpp index 6de48a2016e..08ac78be14d 100644 --- a/engine/web/WebRange.cpp +++ b/engine/web/WebRange.cpp @@ -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); } diff --git a/engine/web/WebViewImpl.cpp b/engine/web/WebViewImpl.cpp index d5e71577ddc..d6463bc78ce 100644 --- a/engine/web/WebViewImpl.cpp +++ b/engine/web/WebViewImpl.cpp @@ -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 = 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 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 = m_page->mainFrame()->document(); RefPtr 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) diff --git a/engine/web/WebViewImpl.h b/engine/web/WebViewImpl.h index a85effc27a2..bf88e5dac6b 100644 --- a/engine/web/WebViewImpl.h +++ b/engine/web/WebViewImpl.h @@ -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; diff --git a/tests/clipping/background-opaque-clipped-gradients-expected.txt b/tests/clipping/background-opaque-clipped-gradients-expected.txt index 0f6aeeba80f..b127eb99028 100644 --- a/tests/clipping/background-opaque-clipped-gradients-expected.txt +++ b/tests/clipping/background-opaque-clipped-gradients-expected.txt @@ -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)] diff --git a/tests/clipping/canvas-rounded-corners-expected.txt b/tests/clipping/canvas-rounded-corners-expected.txt index 2300d1950cd..01d6d2f8476 100644 --- a/tests/clipping/canvas-rounded-corners-expected.txt +++ b/tests/clipping/canvas-rounded-corners-expected.txt @@ -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)] diff --git a/tests/layout/continuations-expected.txt b/tests/layout/continuations-expected.txt index 34f1562ab31..2cac6bbe3e0 100644 --- a/tests/layout/continuations-expected.txt +++ b/tests/layout/continuations-expected.txt @@ -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" diff --git a/tests/layout/ellipsis-expected.txt b/tests/layout/ellipsis-expected.txt index 05d448345c2..49d181b8a06 100644 --- a/tests/layout/ellipsis-expected.txt +++ b/tests/layout/ellipsis-expected.txt @@ -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 diff --git a/tests/layout/fixed-width-expected.txt b/tests/layout/fixed-width-expected.txt index 42df0542211..b855b90467b 100644 --- a/tests/layout/fixed-width-expected.txt +++ b/tests/layout/fixed-width-expected.txt @@ -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] diff --git a/tests/lowlevel/camel-case.sky b/tests/lowlevel/camel-case.sky index 72cd7eea838..f307ef0b33f 100644 --- a/tests/lowlevel/camel-case.sky +++ b/tests/lowlevel/camel-case.sky @@ -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')); diff --git a/tests/lowlevel/hello-world-expected.txt b/tests/lowlevel/hello-world-expected.txt index 39a622929ec..6ba5ffa3d10 100644 --- a/tests/lowlevel/hello-world-expected.txt +++ b/tests/lowlevel/hello-world-expected.txt @@ -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!" diff --git a/tests/lowlevel/home-expected.txt b/tests/lowlevel/home-expected.txt index d5f7a8a0c4c..d2ebc314a0c 100644 --- a/tests/lowlevel/home-expected.txt +++ b/tests/lowlevel/home-expected.txt @@ -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!" diff --git a/tests/lowlevel/iframe-expected.txt b/tests/lowlevel/iframe-expected.txt index 2a7bc89522e..f279d2d70dd 100644 --- a/tests/lowlevel/iframe-expected.txt +++ b/tests/lowlevel/iframe-expected.txt @@ -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 diff --git a/tests/lowlevel/img-expected.txt b/tests/lowlevel/img-expected.txt index 329fb598e62..4017549890f 100644 --- a/tests/lowlevel/img-expected.txt +++ b/tests/lowlevel/img-expected.txt @@ -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 diff --git a/tests/modules/load-event.sky b/tests/modules/load-event.sky index f49c45faae5..f3515319731 100644 --- a/tests/modules/load-event.sky +++ b/tests/modules/load-event.sky @@ -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);