https://bugs.webkit.org/show_bug.cgi?id=121690
Reviewed by Enrica Casucci.
Merge https://chromium.googlesource.com/chromium/blink/+/
65f089545e8c18cb268dfcbe56cba1cd8045527a
When accessing a renderer editing should always make sure that the style has been updated for the node.
Editing calls splitTextNode in a number of places and then accesses the renderer later. This patch is
the first of many to make sure editing always updates the style before attempting to access the renderer
(or style) of a node after calling a mutation method.
* editing/ApplyBlockElementCommand.cpp:
(WebCore::ApplyBlockElementCommand::renderStyleOfEnclosingTextNode):
* editing/ApplyBlockElementCommand.h:
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@156180
268f45cc-cd09-0410-ab3c-
d52691b4dbfc
+2013-09-20 Ryosuke Niwa <rniwa@webkit.org>
+
+ renderStyleOfEnclosingTextNode should update style before using a renderer
+ https://bugs.webkit.org/show_bug.cgi?id=121690
+
+ Reviewed by Enrica Casucci.
+
+ Merge https://chromium.googlesource.com/chromium/blink/+/65f089545e8c18cb268dfcbe56cba1cd8045527a
+
+ When accessing a renderer editing should always make sure that the style has been updated for the node.
+ Editing calls splitTextNode in a number of places and then accesses the renderer later. This patch is
+ the first of many to make sure editing always updates the style before attempting to access the renderer
+ (or style) of a node after calling a mutation method.
+
+ * editing/ApplyBlockElementCommand.cpp:
+ (WebCore::ApplyBlockElementCommand::renderStyleOfEnclosingTextNode):
+ * editing/ApplyBlockElementCommand.h:
+
2013-09-20 Darin Adler <darin@apple.com>
Fix a couple more CSS leaks
return textAtPosition[0] == '\n';
}
-static RenderStyle* renderStyleOfEnclosingTextNode(const Position& position)
+RenderStyle* ApplyBlockElementCommand::renderStyleOfEnclosingTextNode(const Position& position)
{
if (position.anchorType() != Position::PositionIsOffsetInAnchor
|| !position.containerNode()
- || !position.containerNode()->isTextNode()
- || !position.containerNode()->renderer())
+ || !position.containerNode()->isTextNode())
return 0;
- return position.containerNode()->renderer()->style();
+
+ document().updateStyleIfNeeded();
+
+ RenderObject* renderer = position.containerNode()->renderer();
+ if (!renderer)
+ return 0;
+
+ return renderer->style();
}
void ApplyBlockElementCommand::rangeForParagraphSplittingTextNodesIfNeeded(const VisiblePosition& endOfCurrentParagraph, Position& start, Position& end)
private:
virtual void doApply();
virtual void formatRange(const Position& start, const Position& end, const Position& endOfSelection, RefPtr<Element>&) = 0;
+ RenderStyle* renderStyleOfEnclosingTextNode(const Position&);
void rangeForParagraphSplittingTextNodesIfNeeded(const VisiblePosition&, Position&, Position&);
VisiblePosition endOfNextParagrahSplittingTextNodesIfNeeded(VisiblePosition&, Position&, Position&);