- Revision
- 109704
- Author
- [email protected]
- Date
- 2012-03-04 22:30:22 -0800 (Sun, 04 Mar 2012)
Log Message
Source/WebCore: Methods like firstRendererOf of NodeRenderingContext should be extracted.
https://bugs.webkit.org/show_bug.cgi?id=79902
Reviewed by Hajime Morita.
firstRendererOfInsertionPoint should return the first renderer of its child, however
it returns next renderer of parent. The same thing happens lastRendererOfInsertionPoint.
Test: content-element-move.html has another test case.
* dom/NodeRenderingContext.cpp:
(WebCore):
(WebCore::nextRendererOfInsertionPoint):
(WebCore::previousRendererOfInsertionPoint):
(WebCore::firstRendererOfInsertionPoint):
(WebCore::lastRendererOfInsertionPoint):
(WebCore::firstRendererOf):
(WebCore::lastRendererOf):
(WebCore::NodeRenderingContext::nextRenderer):
(WebCore::NodeRenderingContext::previousRenderer):
LayoutTests: Refactoring: Methods like firstRendererOf of NodeRenderingContext should be extracted.
https://bugs.webkit.org/show_bug.cgi?id=79902
Reviewed by Hajime Morita.
Added a new test case.
* fast/dom/shadow/content-element-move-expected.txt:
* fast/dom/shadow/content-element-move.html:
Modified Paths
Diff
Modified: trunk/LayoutTests/ChangeLog (109703 => 109704)
--- trunk/LayoutTests/ChangeLog 2012-03-05 04:43:00 UTC (rev 109703)
+++ trunk/LayoutTests/ChangeLog 2012-03-05 06:30:22 UTC (rev 109704)
@@ -1,3 +1,15 @@
+2012-03-04 Shinya Kawanaka <[email protected]>
+
+ Refactoring: Methods like firstRendererOf of NodeRenderingContext should be extracted.
+ https://bugs.webkit.org/show_bug.cgi?id=79902
+
+ Reviewed by Hajime Morita.
+
+ Added a new test case.
+
+ * fast/dom/shadow/content-element-move-expected.txt:
+ * fast/dom/shadow/content-element-move.html:
+
2012-03-04 Kent Tamura <[email protected]>
[Chromium] We should reset mouse position before calling eventSender.mouseMove in LayoutTest
Modified: trunk/LayoutTests/fast/dom/shadow/content-element-move-expected.txt (109703 => 109704)
--- trunk/LayoutTests/fast/dom/shadow/content-element-move-expected.txt 2012-03-05 04:43:00 UTC (rev 109703)
+++ trunk/LayoutTests/fast/dom/shadow/content-element-move-expected.txt 2012-03-05 06:30:22 UTC (rev 109704)
@@ -20,5 +20,7 @@
PASS
testMoveLightChildOut
PASS
+testInsertBeforeFallback
+PASS
TEST COMPLETED
Modified: trunk/LayoutTests/fast/dom/shadow/content-element-move.html (109703 => 109704)
--- trunk/LayoutTests/fast/dom/shadow/content-element-move.html 2012-03-05 04:43:00 UTC (rev 109703)
+++ trunk/LayoutTests/fast/dom/shadow/content-element-move.html 2012-03-05 06:30:22 UTC (rev 109704)
@@ -358,6 +358,29 @@
setTimeout(f, 0);
}
+function testInsertBeforeFallback(callIfDone) {
+ document.getElementById('expect-container').innerHTML =
+ "<div><span>BEFORE</span><span>HOGE</span><span>FALLBACK</span><span>AFTER</span></div>";
+
+ var target = document.createElement('div');
+ document.getElementById('actual-container').appendChild(target);
+
+ var span1 = document.createElement('span');
+ var root = new WebKitShadowRoot(span1);
+ root.innerHTML = "<content>FALLBACK</content>";
+
+ target.appendChild(createSpanWithText('BEFORE'));
+ target.appendChild(span1);
+ target.appendChild(createSpanWithText('AFTER'));
+
+ var f = (function(target, span1, callIfDone) { return function() {
+ target.insertBefore(createSpanWithText('HOGE'), span1);
+ callIfDone();
+ };})(target, span1, callIfDone);
+
+ setTimeout(f, 0);
+}
+
var testFuncs = [
testRemoveContent,
testRemoveContentToRecalc1,
@@ -369,7 +392,8 @@
testAppendContent2,
testAppendContent3,
testChangeOrderOfContent,
- testMoveLightChildOut
+ testMoveLightChildOut,
+ testInsertBeforeFallback
];
</script>
Modified: trunk/Source/WebCore/ChangeLog (109703 => 109704)
--- trunk/Source/WebCore/ChangeLog 2012-03-05 04:43:00 UTC (rev 109703)
+++ trunk/Source/WebCore/ChangeLog 2012-03-05 06:30:22 UTC (rev 109704)
@@ -1,3 +1,26 @@
+2012-03-04 Shinya Kawanaka <[email protected]>
+
+ Methods like firstRendererOf of NodeRenderingContext should be extracted.
+ https://bugs.webkit.org/show_bug.cgi?id=79902
+
+ Reviewed by Hajime Morita.
+
+ firstRendererOfInsertionPoint should return the first renderer of its child, however
+ it returns next renderer of parent. The same thing happens lastRendererOfInsertionPoint.
+
+ Test: content-element-move.html has another test case.
+
+ * dom/NodeRenderingContext.cpp:
+ (WebCore):
+ (WebCore::nextRendererOfInsertionPoint):
+ (WebCore::previousRendererOfInsertionPoint):
+ (WebCore::firstRendererOfInsertionPoint):
+ (WebCore::lastRendererOfInsertionPoint):
+ (WebCore::firstRendererOf):
+ (WebCore::lastRendererOf):
+ (WebCore::NodeRenderingContext::nextRenderer):
+ (WebCore::NodeRenderingContext::previousRenderer):
+
2012-03-04 MORITA Hajime <[email protected]>
Unreviewed build fix for ENABLE(MATHML).
Modified: trunk/Source/WebCore/dom/NodeRenderingContext.cpp (109703 => 109704)
--- trunk/Source/WebCore/dom/NodeRenderingContext.cpp 2012-03-05 04:43:00 UTC (rev 109703)
+++ trunk/Source/WebCore/dom/NodeRenderingContext.cpp 2012-03-05 06:30:22 UTC (rev 109704)
@@ -43,6 +43,9 @@
namespace WebCore {
+static RenderObject* firstRendererOf(Node*);
+static RenderObject* lastRendererOf(Node*);
+
NodeRenderingContext::NodeRenderingContext(Node* node)
: m_phase(AttachingNotInTree)
, m_node(node)
@@ -135,7 +138,7 @@
return m_style.release();
}
-static RenderObject* nextRendererOf(InsertionPoint* parent, Node* current)
+static inline RenderObject* nextRendererOfInsertionPoint(InsertionPoint* parent, Node* current)
{
HTMLContentSelection* currentSelection = parent->selections()->find(current);
if (!currentSelection)
@@ -149,7 +152,7 @@
return 0;
}
-static RenderObject* previousRendererOf(InsertionPoint* parent, Node* current)
+static inline RenderObject* previousRendererOfInsertionPoint(InsertionPoint* parent, Node* current)
{
RenderObject* lastRenderer = 0;
@@ -163,7 +166,7 @@
return lastRenderer;
}
-static RenderObject* firstRendererOf(InsertionPoint* parent)
+static inline RenderObject* firstRendererOfInsertionPoint(InsertionPoint* parent)
{
if (parent->hasSelection()) {
for (HTMLContentSelection* selection = parent->selections()->first(); selection; selection = selection->next()) {
@@ -174,10 +177,10 @@
return 0;
}
- return NodeRenderingContext(parent).nextRenderer();
+ return firstRendererOf(parent->firstChild());
}
-static RenderObject* lastRendererOf(InsertionPoint* parent)
+static inline RenderObject* lastRendererOfInsertionPoint(InsertionPoint* parent)
{
if (parent->hasSelection()) {
for (HTMLContentSelection* selection = parent->selections()->last(); selection; selection = selection->previous()) {
@@ -188,9 +191,46 @@
return 0;
}
- return NodeRenderingContext(parent).previousRenderer();
+ return lastRendererOf(parent->lastChild());
}
+static inline RenderObject* firstRendererOf(Node* node)
+{
+ for (; node; node = node->nextSibling()) {
+ if (node->renderer()) {
+ // Do not return elements that are attached to a different flow-thread.
+ if (node->renderer()->style() && !node->renderer()->style()->flowThread().isEmpty())
+ continue;
+ return node->renderer();
+ }
+
+ if (isInsertionPoint(node)) {
+ if (RenderObject* first = firstRendererOfInsertionPoint(toInsertionPoint(node)))
+ return first;
+ }
+ }
+
+ return 0;
+}
+
+static inline RenderObject* lastRendererOf(Node* node)
+{
+ for (; node; node = node->previousSibling()) {
+ if (node->renderer()) {
+ // Do not return elements that are attached to a different flow-thread.
+ if (node->renderer()->style() && !node->renderer()->style()->flowThread().isEmpty())
+ continue;
+ return node->renderer();
+ }
+ if (isInsertionPoint(node)) {
+ if (RenderObject* last = lastRendererOfInsertionPoint(toInsertionPoint(node)))
+ return last;
+ }
+ }
+
+ return 0;
+}
+
RenderObject* NodeRenderingContext::nextRenderer() const
{
ASSERT(m_node->renderer() || m_phase != Calculating);
@@ -201,7 +241,7 @@
return m_parentFlowRenderer->nextRendererForNode(m_node);
if (m_phase == AttachingDistributed) {
- if (RenderObject* found = nextRendererOf(m_insertionPoint, m_node))
+ if (RenderObject* found = nextRendererOfInsertionPoint(m_insertionPoint, m_node))
return found;
return NodeRenderingContext(m_insertionPoint).nextRenderer();
}
@@ -211,21 +251,7 @@
if (m_node->parentOrHostNode() && !m_node->parentOrHostNode()->attached())
return 0;
- for (Node* node = m_node->nextSibling(); node; node = node->nextSibling()) {
- if (node->renderer()) {
- // Do not return elements that are attached to a different flow-thread.
- if (node->renderer()->style() && !node->renderer()->style()->flowThread().isEmpty())
- continue;
- return node->renderer();
- }
-
- if (isInsertionPoint(node)) {
- if (RenderObject* first = firstRendererOf(toInsertionPoint(node)))
- return first;
- }
- }
-
- return 0;
+ return firstRendererOf(m_node->nextSibling());
}
RenderObject* NodeRenderingContext::previousRenderer() const
@@ -239,27 +265,14 @@
return m_parentFlowRenderer->previousRendererForNode(m_node);
if (m_phase == AttachingDistributed) {
- if (RenderObject* found = previousRendererOf(m_insertionPoint, m_node))
+ if (RenderObject* found = previousRendererOfInsertionPoint(m_insertionPoint, m_node))
return found;
return NodeRenderingContext(m_insertionPoint).previousRenderer();
}
// FIXME: We should have the same O(N^2) avoidance as nextRenderer does
// however, when I tried adding it, several tests failed.
- for (Node* node = m_node->previousSibling(); node; node = node->previousSibling()) {
- if (node->renderer()) {
- // Do not return elements that are attached to a different flow-thread.
- if (node->renderer()->style() && !node->renderer()->style()->flowThread().isEmpty())
- continue;
- return node->renderer();
- }
- if (isInsertionPoint(node)) {
- if (RenderObject* last = lastRendererOf(toInsertionPoint(node)))
- return last;
- }
- }
-
- return 0;
+ return lastRendererOf(m_node->previousSibling());
}
RenderObject* NodeRenderingContext::parentRenderer() const