Commit cecd9c05 authored by dpranke@chromium.org's avatar dpranke@chromium.org

Switch to new PseudoElement based :before and :after

https://bugs.webkit.org/show_bug.cgi?id=104462

Patch by Elliott Sprehn <esprehn@chromium.org> on 2012-12-11
Reviewed by Antti Koivisto.

Source/WebCore:

Switch to the new PseudoElement based generated content implementation
that moves :before and :after into the DOM. This also switches to using
the ComposedShadowTreeWalker for determining the siblings of PseudoElement's
making the new generated content implementation support adding :before
and :after into <input> elements.

Tests: fast/css-generated-content/block-inside-inline.html
       fast/css-generated-content/box-orient.html

* dom/ComposedShadowTreeWalker.cpp:
(WebCore::ComposedShadowTreeWalker::pseudoAwareNextSibling):
(WebCore):
(WebCore::ComposedShadowTreeWalker::pseudoAwarePreviousSibling):
(WebCore::ComposedShadowTreeWalker::traverseParent):
* dom/ComposedShadowTreeWalker.h:
(ComposedShadowTreeWalker):
* dom/Element.cpp:
(WebCore::Element::attach):
(WebCore::Element::recalcStyle):
* dom/Node.cpp:
* dom/Node.h:
(Node):
* dom/NodeRenderingContext.cpp:
(WebCore::NodeRenderingContext::nextRenderer):
(WebCore::NodeRenderingContext::previousRenderer):
(WebCore::NodeRenderingContext::createRendererForElementIfNeeded):
* dom/Position.cpp:
(WebCore::Position::Position):
(WebCore::Position::hasRenderedNonAnonymousDescendantsWithHeight):
* editing/visible_units.cpp:
(WebCore::logicallyPreviousBox):
(WebCore::logicallyNextBox):
(WebCore::startPositionForLine):
(WebCore::endPositionForLine):
* html/HTMLTextFormControlElement.cpp:
(WebCore::HTMLTextFormControlElement::childShouldCreateRenderer):
* page/DragController.cpp:
(WebCore::DragController::draggableNode):
* rendering/RenderBlock.cpp:
(WebCore::RenderBlock::styleDidChange):
(WebCore::RenderBlock::splitBlocks):
(WebCore::RenderBlock::addChildIgnoringAnonymousColumnBlocks):
(WebCore::RenderBlock::createReplacementRunIn):
(WebCore::RenderBlock::isSelectionRoot):
* rendering/RenderBlock.h:
(RenderBlock):
* rendering/RenderButton.cpp:
* rendering/RenderButton.h:
(RenderButton):
* rendering/RenderInline.cpp:
(WebCore::RenderInline::styleDidChange):
(WebCore::RenderInline::addChildIgnoringContinuation):
(WebCore::RenderInline::splitInlines):
* rendering/RenderListItem.cpp:
(WebCore::RenderListItem::updateMarkerLocation):
* rendering/RenderObject.cpp:
(WebCore::RenderObject::createVisiblePosition):
* rendering/RenderObject.h:
(WebCore::RenderObject::nonPseudoNode):
(RenderObject):
(WebCore::RenderObject::clearNode):
(WebCore::RenderObject::generatingNode):
* rendering/RenderObjectChildList.cpp:
* rendering/RenderObjectChildList.h:
(RenderObjectChildList):
* rendering/RenderRubyText.cpp:
* rendering/RenderRubyText.h:
(RenderRubyText):
* rendering/RenderTableRow.cpp:
(WebCore::RenderTableRow::styleDidChange):
* rendering/RenderTableRow.h:
* rendering/RenderTableSection.cpp:
(WebCore::RenderTableSection::addChild):
* rendering/RenderWidget.cpp:
(WebCore::RenderWidget::destroy):

LayoutTests:

Add test for block generated content inside inlines which is now supported
properly, and also for using box-orient and reordering.

before-content-continuation.html's expectations change because we now
support block content properly.

I skipped fast/css-generated-content/table-row-group-to-inline.html
which needs a rebaseline after this this lands. Unfortunately the test
output is still wrong because we leave an anonymous RenderTable in the
tree, but that bug has always been there.

I also skipped fast/css/empty-generated-content.html which needs rebaselines
as we no longer create extra anonymous blocks, though the reason is not clear
to me.

* fast/css-generated-content/before-content-continuation-chain-expected.txt:
* fast/css-generated-content/block-inside-inline-expected.html: Added.
* fast/css-generated-content/block-inside-inline.html: Added.
* fast/css-generated-content/box-orient-expected.html: Added.
* fast/css-generated-content/box-orient.html: Added.
* platform/chromium/TestExpectations:
* platform/mac/TestExpectations:

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@137336 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 4cbe38ce
2012-12-11 Elliott Sprehn <esprehn@chromium.org>
Switch to new PseudoElement based :before and :after
https://bugs.webkit.org/show_bug.cgi?id=104462
Reviewed by Antti Koivisto.
Add test for block generated content inside inlines which is now supported
properly, and also for using box-orient and reordering.
before-content-continuation.html's expectations change because we now
support block content properly.
I skipped fast/css-generated-content/table-row-group-to-inline.html
which needs a rebaseline after this this lands. Unfortunately the test
output is still wrong because we leave an anonymous RenderTable in the
tree, but that bug has always been there.
I also skipped fast/css/empty-generated-content.html which needs rebaselines
as we no longer create extra anonymous blocks, though the reason is not clear
to me.
* fast/css-generated-content/before-content-continuation-chain-expected.txt:
* fast/css-generated-content/block-inside-inline-expected.html: Added.
* fast/css-generated-content/block-inside-inline.html: Added.
* fast/css-generated-content/box-orient-expected.html: Added.
* fast/css-generated-content/box-orient.html: Added.
* platform/chromium/TestExpectations:
* platform/mac/TestExpectations:
2012-12-11 Nate Chapin <japhet@chromium.org>
Route main resource loads through the memory cache.
......@@ -3,13 +3,13 @@ layer at (0,0) size 800x600
layer at (0,0) size 800x416
RenderBlock {HTML} at (0,0) size 800x416
RenderBody {BODY} at (8,8) size 784x400
RenderBlock (anonymous) at (0,0) size 784x0
RenderInline {SPAN} at (0,0) size 0x0 [color=#008000]
RenderBlock (anonymous) at (0,0) size 784x200
RenderInline {SPAN} at (0,0) size 200x200 [color=#008000]
RenderInline (generated) at (0,0) size 200x200 [color=#0000FF]
RenderText at (0,0) size 200x200
text run at (0,0) width 200: "A"
RenderBlock (anonymous) at (0,200) size 784x0
RenderBlock {DIV} at (0,0) size 784x0 [color=#008000]
RenderBlock (generated) at (0,0) size 784x200 [color=#0000FF]
RenderText at (0,0) size 200x200
text run at (0,0) width 200: "A"
RenderBlock {DIV} at (0,200) size 784x0 [color=#008000]
RenderBlock (anonymous) at (0,200) size 784x200
RenderInline {SPAN} at (0,0) size 200x200 [color=#008000]
RenderText {#text} at (0,0) size 200x200
......
<!DOCTYPE html>
<span>
<div>Should be on it's own line, </div>
and this too.
</span>
<!DOCTYPE html>
<style>
span:before {
display: block;
content: "Should be on it's own line, ";
}
</style>
<span>and this too.</span>
<!DOCTYPE html>
<style>
.before {
background:red;
}
</style>
<h1>Normal</h1>
<div>
<div class="before">Before content</div>
<div>1st in code - 1nd in order</div>
<div>2nd in code - 2nd in order</div>
</div>
<h1>Reordered</h1>
<div>
<div class="before">Before content</div>
<div>2nd in code - 1st in order</div>
<div>1st in code - 2nd in order</div>
</div>
<!DOCTYPE html>
<style>
.container {
display: box;
display: -moz-box;
display: -webkit-box;
box-orient: vertical;
-moz-box-orient: vertical;
-webkit-box-orient: vertical;
}
.container:before {
display: block;
content: "Before content";
background:red;
}
.c1o2 {
-moz-box-ordinal-group: 2;
-webkit-box-ordinal-group: 2;
box-ordinal-group: 2;
}
.c2o1 {
-moz-box-ordinal-group: 1;
-webkit-box-ordinal-group: 1;
box-ordinal-group: 1;
}
</style>
<h1>Normal</h1>
<div class="container">
<div>1st in code - 1nd in order</div>
<div>2nd in code - 2nd in order</div>
</div>
<h1>Reordered</h1>
<div class="container">
<div class="c1o2">1st in code - 2nd in order</div>
<div class="c2o1">2nd in code - 1st in order</div>
</div>
......@@ -3901,6 +3901,10 @@ webkit.org/b/11645 [ Mac Android ] fast/table/025.html [ Failure ]
webkit.org/b/101177 svg/dynamic-updates/SVGUseElement-dom-requiredFeatures.html [ ImageOnlyFailure Pass ]
webkit.org/b/101177 svg/repaint/inner-svg-change-viewBox.svg [ ImageOnlyFailure Pass ]
# Needs rebaseline after bug https://bugs.webkit.org/show_bug.cgi?id=104462
webkit.org/b/98687 fast/css-generated-content/table-row-group-to-inline.html [ Failure ]
webkit.org/b/104595 fast/css/empty-generated-content.html [ Failure ]
# These are real failues due to 95121.
# This is spilling caused by LANCZOS3 scaling algorithm that samples outside the source rect.
webkit.org/b/95121 [ Win Mac Android ] fast/images/pixel-crack-image-background-webkit-transform-scale.html [ ImageOnlyFailure ]
......
......@@ -1153,6 +1153,10 @@ webkit.org/b/90951 fast/text/shaping
webkit.org/b/101177 svg/dynamic-updates/SVGUseElement-dom-requiredFeatures.html [ ImageOnlyFailure Pass ]
webkit.org/b/101177 svg/repaint/inner-svg-change-viewBox.svg [ ImageOnlyFailure Pass ]
# Needs rebaseline after bug https://bugs.webkit.org/show_bug.cgi?id=104462
webkit.org/b/98687 fast/css-generated-content/table-row-group-to-inline.html [ Failure ]
webkit.org/b/104595 fast/css/empty-generated-content.html [ Failure ]
webkit.org/b/93247 [ Debug ] fast/lists/list-marker-remove-crash.html [ Crash ]
# (r124484) inspector/device-orientation-success.html failing on Mac ports
......
2012-12-11 Elliott Sprehn <esprehn@chromium.org>
Switch to new PseudoElement based :before and :after
https://bugs.webkit.org/show_bug.cgi?id=104462
Reviewed by Antti Koivisto.
Switch to the new PseudoElement based generated content implementation
that moves :before and :after into the DOM. This also switches to using
the ComposedShadowTreeWalker for determining the siblings of PseudoElement's
making the new generated content implementation support adding :before
and :after into <input> elements.
Tests: fast/css-generated-content/block-inside-inline.html
fast/css-generated-content/box-orient.html
* dom/ComposedShadowTreeWalker.cpp:
(WebCore::ComposedShadowTreeWalker::pseudoAwareNextSibling):
(WebCore):
(WebCore::ComposedShadowTreeWalker::pseudoAwarePreviousSibling):
(WebCore::ComposedShadowTreeWalker::traverseParent):
* dom/ComposedShadowTreeWalker.h:
(ComposedShadowTreeWalker):
* dom/Element.cpp:
(WebCore::Element::attach):
(WebCore::Element::recalcStyle):
* dom/Node.cpp:
* dom/Node.h:
(Node):
* dom/NodeRenderingContext.cpp:
(WebCore::NodeRenderingContext::nextRenderer):
(WebCore::NodeRenderingContext::previousRenderer):
(WebCore::NodeRenderingContext::createRendererForElementIfNeeded):
* dom/Position.cpp:
(WebCore::Position::Position):
(WebCore::Position::hasRenderedNonAnonymousDescendantsWithHeight):
* editing/visible_units.cpp:
(WebCore::logicallyPreviousBox):
(WebCore::logicallyNextBox):
(WebCore::startPositionForLine):
(WebCore::endPositionForLine):
* html/HTMLTextFormControlElement.cpp:
(WebCore::HTMLTextFormControlElement::childShouldCreateRenderer):
* page/DragController.cpp:
(WebCore::DragController::draggableNode):
* rendering/RenderBlock.cpp:
(WebCore::RenderBlock::styleDidChange):
(WebCore::RenderBlock::splitBlocks):
(WebCore::RenderBlock::addChildIgnoringAnonymousColumnBlocks):
(WebCore::RenderBlock::createReplacementRunIn):
(WebCore::RenderBlock::isSelectionRoot):
* rendering/RenderBlock.h:
(RenderBlock):
* rendering/RenderButton.cpp:
* rendering/RenderButton.h:
(RenderButton):
* rendering/RenderInline.cpp:
(WebCore::RenderInline::styleDidChange):
(WebCore::RenderInline::addChildIgnoringContinuation):
(WebCore::RenderInline::splitInlines):
* rendering/RenderListItem.cpp:
(WebCore::RenderListItem::updateMarkerLocation):
* rendering/RenderObject.cpp:
(WebCore::RenderObject::createVisiblePosition):
* rendering/RenderObject.h:
(WebCore::RenderObject::nonPseudoNode):
(RenderObject):
(WebCore::RenderObject::clearNode):
(WebCore::RenderObject::generatingNode):
* rendering/RenderObjectChildList.cpp:
* rendering/RenderObjectChildList.h:
(RenderObjectChildList):
* rendering/RenderRubyText.cpp:
* rendering/RenderRubyText.h:
(RenderRubyText):
* rendering/RenderTableRow.cpp:
(WebCore::RenderTableRow::styleDidChange):
* rendering/RenderTableRow.h:
* rendering/RenderTableSection.cpp:
(WebCore::RenderTableSection::addChild):
* rendering/RenderWidget.cpp:
(WebCore::RenderWidget::destroy):
2012-12-11 Jacky Jiang <zhajiang@rim.com>
[BlackBerry] Clean up unused defaultViewportArguments in RenderThemeBlackBerry.cpp
......@@ -33,6 +33,7 @@
#include "HTMLContentElement.h"
#include "HTMLShadowElement.h"
#include "InsertionPoint.h"
#include "PseudoElement.h"
namespace WebCore {
......@@ -180,6 +181,46 @@ void ComposedShadowTreeWalker::previousSibling()
assertPostcondition();
}
void ComposedShadowTreeWalker::pseudoAwareNextSibling()
{
assertPrecondition();
const Node* node = m_node;
if (node->isBeforePseudoElement())
m_node = traverseFirstChild(traverseParent(node));
else
m_node = traverseSiblingOrBackToInsertionPoint(node, TraversalDirectionForward);
if (!m_node && !node->isAfterPseudoElement()) {
Node* parent = traverseParent(node);
if (parent && parent->isElementNode())
m_node = toElement(parent)->afterPseudoElement();
}
assertPostcondition();
}
void ComposedShadowTreeWalker::pseudoAwarePreviousSibling()
{
assertPrecondition();
const Node* node = m_node;
if (node->isAfterPseudoElement())
m_node = traverseLastChild(traverseParent(node));
else
m_node = traverseSiblingOrBackToInsertionPoint(node, TraversalDirectionBackward);
if (!m_node && !node->isBeforePseudoElement()) {
Node* parent = traverseParent(node);
if (parent && parent->isElementNode())
m_node = toElement(parent)->beforePseudoElement();
}
assertPostcondition();
}
Node* ComposedShadowTreeWalker::traverseDistributedNodes(const Node* node, const InsertionPoint* insertionPoint, TraversalDirection direction)
{
for (const Node* next = node; next; next = (direction == TraversalDirectionForward ? insertionPoint->nextTo(next) : insertionPoint->previousTo(next))) {
......@@ -258,6 +299,9 @@ void ComposedShadowTreeWalker::parent()
// https://bugs.webkit.org/show_bug.cgi?id=90415
Node* ComposedShadowTreeWalker::traverseParent(const Node* node, ParentTraversalDetails* details) const
{
if (node->isPseudoElement())
return node->parentOrHostNode();
if (!canCrossUpperBoundary() && node->isShadowRoot()) {
ASSERT(toShadowRoot(node)->isYoungest());
return 0;
......
......@@ -90,6 +90,9 @@ public:
void nextSibling();
void previousSibling();
void pseudoAwareNextSibling();
void pseudoAwarePreviousSibling();
void parent();
void next();
......
......@@ -1168,6 +1168,8 @@ void Element::attach()
if (parentElement() && parentElement()->isInCanvasSubtree())
setIsInCanvasSubtree(true);
updatePseudoElement(BEFORE);
// When a shadow root exists, it does the work of attaching the children.
if (ElementShadow* shadow = this->shadow()) {
parentPusher.push();
......@@ -1177,6 +1179,8 @@ void Element::attach()
ContainerNode::attach();
updatePseudoElement(AFTER);
if (hasRareData()) {
ElementRareData* data = elementRareData();
if (data->needsFocusAppearanceUpdateSoonAfterAttach()) {
......@@ -1329,6 +1333,8 @@ void Element::recalcStyle(StyleChange change)
}
}
updatePseudoElement(BEFORE, change);
// FIXME: This check is good enough for :hover + foo, but it is not good enough for :hover + foo + bar.
// For now we will just worry about the common case, since it's a lot trickier to get the second case right
// without doing way too much re-resolution.
......@@ -1353,6 +1359,8 @@ void Element::recalcStyle(StyleChange change)
forceCheckOfAnyElementSibling = forceCheckOfAnyElementSibling || (childRulesChanged && hasIndirectAdjacentRules);
}
updatePseudoElement(AFTER, change);
clearNeedsStyleRecalc();
clearChildNeedsStyleRecalc();
......
......@@ -40,6 +40,7 @@
#include "CSSStyleSheet.h"
#include "ChildNodeList.h"
#include "ClassNodeList.h"
#include "ComposedShadowTreeWalker.h"
#include "ContainerNodeAlgorithms.h"
#include "ContextMenuController.h"
#include "DOMImplementation.h"
......@@ -449,34 +450,6 @@ void Node::setTreeScope(TreeScope* scope)
ensureRareData()->setTreeScope(scope);
}
Node* Node::pseudoAwarePreviousSibling() const
{
if (isElementNode() && !previousSibling()) {
Element* parent = parentOrHostElement();
if (!parent)
return 0;
if (isAfterPseudoElement() && parent->lastChild())
return parent->lastChild();
if (!isBeforePseudoElement())
return parent->beforePseudoElement();
}
return previousSibling();
}
Node* Node::pseudoAwareNextSibling() const
{
if (isElementNode() && !nextSibling()) {
Element* parent = parentOrHostElement();
if (!parent)
return 0;
if (isBeforePseudoElement() && parent->firstChild())
return parent->firstChild();
if (!isAfterPseudoElement())
return parent->afterPseudoElement();
}
return nextSibling();
}
NodeRareData* Node::rareData() const
{
ASSERT(hasRareData());
......
......@@ -190,9 +190,6 @@ public:
bool hasAttributes() const;
NamedNodeMap* attributes() const;
Node* pseudoAwarePreviousSibling() const;
Node* pseudoAwareNextSibling() const;
virtual KURL baseURI() const;
void getSubresourceURLs(ListHashSet<KURL>&) const;
......
......@@ -32,9 +32,11 @@
#include "ElementShadow.h"
#include "FlowThreadController.h"
#include "HTMLContentElement.h"
#include "HTMLInputElement.h"
#include "HTMLNames.h"
#include "HTMLShadowElement.h"
#include "Node.h"
#include "PseudoElement.h"
#include "RenderFullScreen.h"
#include "RenderNamedFlowThread.h"
#include "RenderObject.h"
......@@ -83,17 +85,8 @@ RenderObject* NodeRenderingContext::nextRenderer() const
if (m_parentDetails.node() && !m_parentDetails.node()->attached())
return 0;
// FIXME: This is wrong when the next sibling was actually moved around by shadow insertion points.
if (m_node->isPseudoElement()) {
for (Node* sibling = m_node->pseudoAwareNextSibling(); sibling; sibling = sibling->pseudoAwareNextSibling()) {
if (RenderObject* renderer = sibling->renderer())
return renderer;
}
return 0;
}
ComposedShadowTreeWalker walker(m_node);
for (walker.nextSibling(); walker.get(); walker.nextSibling()) {
for (walker.pseudoAwareNextSibling(); walker.get(); walker.pseudoAwareNextSibling()) {
if (RenderObject* renderer = walker.get()->renderer()) {
// Renderers for elements attached to a flow thread should be skipped because they are parented differently.
if (renderer->node()->isElementNode() && renderer->style() && !renderer->style()->flowThread().isEmpty())
......@@ -110,10 +103,6 @@ RenderObject* NodeRenderingContext::previousRenderer() const
if (RenderObject* renderer = m_node->renderer())
return renderer->previousSibling();
// FIXME: This method doesn't support pseudo elements since nothing needs
// previousRenderer() support for them yet.
ASSERT(!m_node->isPseudoElement());
if (m_parentFlowRenderer)
return m_parentFlowRenderer->previousRendererForNode(m_node);
......@@ -121,7 +110,7 @@ RenderObject* NodeRenderingContext::previousRenderer() const
// however, when I tried adding it, several tests failed.
ComposedShadowTreeWalker walker(m_node);
for (walker.previousSibling(); walker.get(); walker.previousSibling()) {
for (walker.pseudoAwarePreviousSibling(); walker.get(); walker.pseudoAwarePreviousSibling()) {
if (RenderObject* renderer = walker.get()->renderer()) {
// Renderers for elements attached to a flow thread should be skipped because they are parented differently.
if (renderer->node()->isElementNode() && renderer->style() && !renderer->style()->flowThread().isEmpty())
......@@ -235,7 +224,7 @@ void NodeRenderingContext::createRendererForElementIfNeeded()
RenderObject* parentRenderer = this->parentRenderer();
RenderObject* nextRenderer = this->nextRenderer();
#if ENABLE(DIALOG_ELEMENT)
if (element->isInTopLayer())
adjustInsertionPointForTopLayerElement(element, parentRenderer, nextRenderer);
......
......@@ -87,6 +87,7 @@ Position::Position(PassRefPtr<Node> anchorNode, LegacyEditingOffset offset)
#else
ASSERT(!m_anchorNode || !m_anchorNode->isShadowRoot());
#endif
ASSERT(!m_anchorNode || !m_anchorNode->isPseudoElement());
}
Position::Position(PassRefPtr<Node> anchorNode, AnchorType anchorType)
......@@ -102,6 +103,8 @@ Position::Position(PassRefPtr<Node> anchorNode, AnchorType anchorType)
ASSERT(!m_anchorNode || !m_anchorNode->isShadowRoot());
#endif
ASSERT(!m_anchorNode || !m_anchorNode->isPseudoElement());
ASSERT(anchorType != PositionIsOffsetInAnchor);
ASSERT(!((anchorType == PositionIsBeforeChildren || anchorType == PositionIsAfterChildren)
&& (m_anchorNode->isTextNode() || editingIgnoresContent(m_anchorNode.get()))));
......@@ -120,6 +123,8 @@ Position::Position(PassRefPtr<Node> anchorNode, int offset, AnchorType anchorTyp
ASSERT(!m_anchorNode || !editingIgnoresContent(m_anchorNode.get()) || !m_anchorNode->isShadowRoot());
#endif
ASSERT(!m_anchorNode || !m_anchorNode->isPseudoElement());
ASSERT(anchorType == PositionIsOffsetInAnchor);
}
......@@ -840,7 +845,7 @@ bool Position::hasRenderedNonAnonymousDescendantsWithHeight(RenderObject* render
{
RenderObject* stop = renderer->nextInPreOrderAfterChildren();
for (RenderObject *o = renderer->firstChild(); o && o != stop; o = o->nextInPreOrder())
if (o->node() && !o->node()->isPseudoElement()) {
if (o->nonPseudoNode()) {
if ((o->isText() && toRenderText(o)->linesBoundingBox().height()) ||
(o->isBox() && toRenderBox(o)->borderBoundingBox().height()))
return true;
......
......@@ -215,8 +215,8 @@ static const InlineTextBox* logicallyPreviousBox(const VisiblePosition& visibleP
return previousBox;
while (1) {
Node* startNode = startBox->renderer() ? startBox->renderer()->node() : 0;
if (!startNode || startNode->isPseudoElement())
Node* startNode = startBox->renderer() ? startBox->renderer()->nonPseudoNode() : 0;
if (!startNode)
break;
Position position = previousRootInlineBoxCandidatePosition(startNode, visiblePosition, ContentIsEditable);
......@@ -256,8 +256,8 @@ static const InlineTextBox* logicallyNextBox(const VisiblePosition& visiblePosit
return nextBox;
while (1) {
Node* startNode = startBox->renderer() ? startBox->renderer()->node() : 0;
if (!startNode || startNode->isPseudoElement())
Node* startNode = startBox->renderer() ? startBox->renderer()->nonPseudoNode() : 0;
if (!startNode)
break;
Position position = nextRootInlineBoxCandidatePosition(startNode, visiblePosition, ContentIsEditable);
......@@ -744,8 +744,8 @@ static VisiblePosition startPositionForLine(const VisiblePosition& c, LineEndpoi
if (!startRenderer)
return VisiblePosition();
startNode = startRenderer->node();
if (startNode && !startNode->isPseudoElement())
startNode = startRenderer->nonPseudoNode();
if (startNode)
break;
startBox = startBox->nextLeafChild();
......@@ -816,8 +816,8 @@ static VisiblePosition endPositionForLine(const VisiblePosition& c, LineEndpoint
if (!endRenderer)
return VisiblePosition();
endNode = endRenderer->node();
if (endNode && !endNode->isPseudoElement())
endNode = endRenderer->nonPseudoNode();
if (endNode)
break;
endBox = endBox->prevLeafChild();
......
......@@ -66,6 +66,10 @@ HTMLTextFormControlElement::~HTMLTextFormControlElement()
bool HTMLTextFormControlElement::childShouldCreateRenderer(const NodeRenderingContext& childContext) const
{
// FIXME: We shouldn't force the pseudo elements down into the shadow, but
// this perserves the current behavior of WebKit.
if (childContext.node()->isPseudoElement())
return HTMLFormControlElementWithState::childShouldCreateRenderer(childContext);
return childContext.isOnEncapsulationBoundary() && HTMLFormControlElementWithState::childShouldCreateRenderer(childContext);
}
......
......@@ -625,7 +625,7 @@ Node* DragController::draggableNode(const Frame* src, Node* startNode, const Int
state.m_dragType = (src->selection()->contains(dragOrigin)) ? DragSourceActionSelection : DragSourceActionNone;
for (const RenderObject* renderer = startNode->renderer(); renderer; renderer = renderer->parent()) {
Node* node = renderer->node();
Node* node = renderer->nonPseudoNode();
if (!node)
// Anonymous render blocks don't correspond to actual DOM nodes, so we skip over them
// for the purposes of finding a draggable node.
......
......@@ -344,12 +344,6 @@ void RenderBlock::styleDidChange(StyleDifference diff, const RenderStyle* oldSty
propagateStyleToAnonymousChildren(true);
m_lineHeight = -1;
// Update pseudos for :before and :after now.
if (!isAnonymous() && document()->styleSheetCollection()->usesBeforeAfterRules() && canHaveGeneratedChildren()) {
updateBeforeAfterContent(BEFORE);
updateBeforeAfterContent(AFTER);
}
// After our style changed, if we lose our ability to propagate floats into next sibling
// blocks, then we need to find the top most parent containing that overhanging float and
// then mark its descendants with floats for layout and clear all floats from its next
......@@ -381,14 +375,6 @@ void RenderBlock::styleDidChange(StyleDifference diff, const RenderStyle* oldSty
}
}
void RenderBlock::updateBeforeAfterContent(PseudoId pseudoId)
{
// If this is an anonymous wrapper, then the parent applies its own pseudo-element style to it.
if (parent() && parent()->createsAnonymousWrapper())
return;
children()->updateBeforeAfterContent(this, pseudoId);
}
RenderBlock* RenderBlock::continuationBefore(RenderObject* beforeChild)
{
if (beforeChild && beforeChild->parent() == this)
......@@ -603,13 +589,7 @@ void RenderBlock::splitBlocks(RenderBlock* fromBlock, RenderBlock* toBlock,
RenderBoxModelObject* curr = toRenderBoxModelObject(parent());
RenderBoxModelObject* currChild = this;
RenderObject* currChildNextSibling = currChild->nextSibling();
bool documentUsesBeforeAfterRules = document()->styleSheetCollection()->usesBeforeAfterRules();
// Note: |this| can be destroyed inside this loop if it is an empty anonymous
// block and we try to call updateBeforeAfterContent inside which removes the
// generated content and additionally cleans up |this| empty anonymous block.
// See RenderBlock::removeChild(). DO NOT reference any local variables to |this|
// after this point.
while (curr && curr != fromBlock) {
ASSERT(curr->isRenderBlock());
......@@ -632,16 +612,6 @@ void RenderBlock::splitBlocks(RenderBlock* fromBlock, RenderBlock* toBlock,
cloneBlock->setContinuation(oldCont);
}
// Someone may have indirectly caused a <q> to split. When this happens, the :after content
// has to move into the inline continuation. Call updateBeforeAfterContent to ensure that the inline's :after
// content gets properly destroyed.
bool isLastChild = (currChildNextSibling == blockCurr->lastChild());
if (documentUsesBeforeAfterRules)
blockCurr->children()->updateBeforeAfterContent(blockCurr, AFTER);
if (isLastChild && currChildNextSibling != blockCurr->lastChild())
currChildNextSibling = 0; // We destroyed the last child, so now we need to update
// the value of currChildNextSibling.
// Now we need to take all of the children starting from the first child
// *after* currChild and append them all to the clone.
blockCurr->moveChildrenTo(cloneBlock, currChildNextSibling, 0, true);
......@@ -874,23 +844,6 @@ void RenderBlock::addChildIgnoringAnonymousColumnBlocks(RenderObject* newChild,
if (!isAnonymousBlock())
setContinuation(newBox);
// Someone may have put a <p> inside a <q>, causing a split. When this happens, the :after content
// has to move into the inline continuation. Call updateBeforeAfterContent to ensure that our :after
// content gets properly destroyed.
bool isFirstChild = (beforeChild == firstChild());
bool isLastChild = (beforeChild == lastChild());
if (document()->styleSheetCollection()->usesBeforeAfterRules())
children()->updateBeforeAfterContent(this, AFTER);
if (isLastChild && beforeChild != lastChild()) {
// We destroyed the last child, so now we need to update our insertion
// point to be 0. It's just a straight append now.
beforeChild = 0;
} else if (isFirstChild && beforeChild != firstChild()) {
// If beforeChild was the last anonymous block that collapsed,
// then we need to update its value.
beforeChild = firstChild();
}
splitFlow(beforeChild, newBox, newChild, oldContinuation);
return;
}
......@@ -1878,16 +1831,6 @@ RenderBoxModelObject* RenderBlock::createReplacementRunIn(RenderBoxModelObject*
{
ASSERT(runIn->isRunIn());
// First we destroy any :before/:after content. It will be regenerated by the new run-in.
// Exception is if the run-in itself is generated.
if (runIn->style()->styleType() != BEFORE && runIn->style()->styleType() != AFTER) {
RenderObject* generatedContent;
if (runIn->getCachedPseudoStyle(BEFORE) && (generatedContent = runIn->beforePseudoElementRenderer()))
generatedContent->destroy();
if (runIn->getCachedPseudoStyle(AFTER) && (generatedContent = runIn->afterPseudoElementRenderer()))
generatedContent->destroy();
}