- Revision
- 264372
- Author
- [email protected]
- Date
- 2020-07-14 13:45:50 -0700 (Tue, 14 Jul 2020)
Log Message
Drop cache of subframe count on the Page
https://bugs.webkit.org/show_bug.cgi?id=214312
<rdar://problem/65433615>
Reviewed by Geoffrey Garen.
Drop cache of subframe count on the Page as it is error-prone to keep it up to date and it is
not performance sensitive. We only need the subframe count when trying to load a new iframe
to see if we reached the maximum number of subframes (1000). Calculating this count is also
not very expensive since we merely need to iterate the frame tree, which is composed of at
most 1000 frames.
* history/CachedFrame.cpp:
(WebCore::CachedFrame::CachedFrame):
(WebCore::CachedFrame::open):
* loader/FrameLoader.cpp:
(WebCore::FrameLoader::closeAndRemoveChild):
* page/Frame.cpp:
(WebCore::Frame::Frame):
(WebCore::Frame::disconnectOwnerElement):
* page/FrameTree.cpp:
(WebCore::FrameTree::childCount const):
(WebCore::FrameTree::descendantCount const):
* page/FrameTree.h:
* page/Page.cpp:
(WebCore::Page::subframeCount const):
* page/Page.h:
Modified Paths
Diff
Modified: trunk/Source/WebCore/ChangeLog (264371 => 264372)
--- trunk/Source/WebCore/ChangeLog 2020-07-14 19:59:01 UTC (rev 264371)
+++ trunk/Source/WebCore/ChangeLog 2020-07-14 20:45:50 UTC (rev 264372)
@@ -1,3 +1,33 @@
+2020-07-14 Chris Dumez <[email protected]>
+
+ Drop cache of subframe count on the Page
+ https://bugs.webkit.org/show_bug.cgi?id=214312
+ <rdar://problem/65433615>
+
+ Reviewed by Geoffrey Garen.
+
+ Drop cache of subframe count on the Page as it is error-prone to keep it up to date and it is
+ not performance sensitive. We only need the subframe count when trying to load a new iframe
+ to see if we reached the maximum number of subframes (1000). Calculating this count is also
+ not very expensive since we merely need to iterate the frame tree, which is composed of at
+ most 1000 frames.
+
+ * history/CachedFrame.cpp:
+ (WebCore::CachedFrame::CachedFrame):
+ (WebCore::CachedFrame::open):
+ * loader/FrameLoader.cpp:
+ (WebCore::FrameLoader::closeAndRemoveChild):
+ * page/Frame.cpp:
+ (WebCore::Frame::Frame):
+ (WebCore::Frame::disconnectOwnerElement):
+ * page/FrameTree.cpp:
+ (WebCore::FrameTree::childCount const):
+ (WebCore::FrameTree::descendantCount const):
+ * page/FrameTree.h:
+ * page/Page.cpp:
+ (WebCore::Page::subframeCount const):
+ * page/Page.h:
+
2020-07-14 James Darpinian <[email protected]>
Implement uniform* and getUniform for WebGL 2 types
Modified: trunk/Source/WebCore/history/CachedFrame.cpp (264371 => 264372)
--- trunk/Source/WebCore/history/CachedFrame.cpp 2020-07-14 19:59:01 UTC (rev 264371)
+++ trunk/Source/WebCore/history/CachedFrame.cpp 2020-07-14 20:45:50 UTC (rev 264372)
@@ -194,9 +194,6 @@
for (unsigned i = 0; i < m_childFrames.size(); ++i)
frame.tree().removeChild(m_childFrames[i]->view()->frame());
- if (!m_isMainFrame)
- frame.page()->decrementSubframeCount();
-
#ifndef NDEBUG
if (m_isMainFrame)
LOG(BackForwardCache, "Finished creating CachedFrame for main frame url '%s' and DocumentLoader %p\n", m_url.string().utf8().data(), m_documentLoader.get());
@@ -223,8 +220,6 @@
{
ASSERT(m_view);
ASSERT(m_document);
- if (!m_isMainFrame)
- m_view->frame().page()->incrementSubframeCount();
m_view->frame().loader().open(*this);
}
Modified: trunk/Source/WebCore/loader/FrameLoader.cpp (264371 => 264372)
--- trunk/Source/WebCore/loader/FrameLoader.cpp 2020-07-14 19:59:01 UTC (rev 264371)
+++ trunk/Source/WebCore/loader/FrameLoader.cpp 2020-07-14 20:45:50 UTC (rev 264372)
@@ -2713,8 +2713,6 @@
child.tree().detachFromParent();
child.setView(nullptr);
- if (child.ownerElement() && child.page())
- child.page()->decrementSubframeCount();
child.willDetachPage();
child.detachFromPage();
Modified: trunk/Source/WebCore/page/Frame.cpp (264371 => 264372)
--- trunk/Source/WebCore/page/Frame.cpp 2020-07-14 19:59:01 UTC (rev 264371)
+++ trunk/Source/WebCore/page/Frame.cpp 2020-07-14 20:45:50 UTC (rev 264372)
@@ -165,7 +165,6 @@
if (ownerElement) {
m_mainFrame.selfOnlyRef();
- page.incrementSubframeCount();
ownerElement->setContentFrame(this);
}
@@ -774,10 +773,8 @@
{
if (m_ownerElement) {
m_ownerElement->clearContentFrame();
- if (m_page)
- m_page->decrementSubframeCount();
+ m_ownerElement = nullptr;
}
- m_ownerElement = nullptr;
if (auto* document = this->document())
document->frameWasDisconnectedFromOwner();
Modified: trunk/Source/WebCore/page/FrameTree.cpp (264371 => 264372)
--- trunk/Source/WebCore/page/FrameTree.cpp 2020-07-14 19:59:01 UTC (rev 264371)
+++ trunk/Source/WebCore/page/FrameTree.cpp 2020-07-14 20:45:50 UTC (rev 264372)
@@ -188,11 +188,19 @@
unsigned FrameTree::childCount() const
{
unsigned count = 0;
- for (Frame* result = firstChild(); result; result = result->tree().nextSibling())
+ for (auto* child = firstChild(); child; child = child->tree().nextSibling())
++count;
return count;
}
+unsigned FrameTree::descendantCount() const
+{
+ unsigned count = 0;
+ for (auto* child = firstChild(); child; child = child->tree().nextSibling())
+ count += 1 + child->tree().descendantCount();
+ return count;
+}
+
Frame* FrameTree::child(unsigned index) const
{
Frame* result = firstChild();
Modified: trunk/Source/WebCore/page/FrameTree.h (264371 => 264372)
--- trunk/Source/WebCore/page/FrameTree.h 2020-07-14 19:59:01 UTC (rev 264371)
+++ trunk/Source/WebCore/page/FrameTree.h 2020-07-14 20:45:50 UTC (rev 264372)
@@ -77,6 +77,7 @@
Frame* child(const AtomString& name) const;
WEBCORE_EXPORT Frame* find(const AtomString& name, Frame& activeFrame) const;
WEBCORE_EXPORT unsigned childCount() const;
+ unsigned descendantCount() const;
WEBCORE_EXPORT Frame& top() const;
WEBCORE_EXPORT Frame* scopedChild(unsigned index) const;
Modified: trunk/Source/WebCore/page/Page.cpp (264371 => 264372)
--- trunk/Source/WebCore/page/Page.cpp 2020-07-14 19:59:01 UTC (rev 264371)
+++ trunk/Source/WebCore/page/Page.cpp 2020-07-14 20:45:50 UTC (rev 264372)
@@ -2028,21 +2028,11 @@
#endif
-#if ASSERT_ENABLED
-
-void Page::checkSubframeCountConsistency() const
+unsigned Page::subframeCount() const
{
- ASSERT(m_subframeCount >= 0);
-
- int subframeCount = 0;
- for (const Frame* frame = &mainFrame(); frame; frame = frame->tree().traverseNext())
- ++subframeCount;
-
- ASSERT(m_subframeCount + 1 == subframeCount);
+ return mainFrame().tree().descendantCount();
}
-#endif // ASSERT_ENABLED
-
void Page::resumeAnimatingImages()
{
// Drawing models which cache painted content while out-of-window (WebKit2's composited drawing areas, etc.)
Modified: trunk/Source/WebCore/page/Page.h (264371 => 264372)
--- trunk/Source/WebCore/page/Page.h 2020-07-14 19:59:01 UTC (rev 264371)
+++ trunk/Source/WebCore/page/Page.h 2020-07-14 20:45:50 UTC (rev 264372)
@@ -224,9 +224,7 @@
WEBCORE_EXPORT static void forEachPage(const WTF::Function<void(Page&)>&);
- void incrementSubframeCount() { ++m_subframeCount; }
- void decrementSubframeCount() { ASSERT(m_subframeCount); --m_subframeCount; }
- int subframeCount() const { checkSubframeCountConsistency(); return m_subframeCount; }
+ unsigned subframeCount() const;
void incrementNestedRunLoopCount();
void decrementNestedRunLoopCount();
@@ -782,8 +780,6 @@
void setIsVisibleInternal(bool);
void setIsVisuallyIdleInternal(bool);
- void checkSubframeCountConsistency() const;
-
enum ShouldHighlightMatches { DoNotHighlightMatches, HighlightMatches };
enum ShouldMarkMatches { DoNotMarkMatches, MarkMatches };
@@ -860,7 +856,6 @@
int m_nestedRunLoopCount { 0 };
WTF::Function<void()> m_unnestCallback;
- int m_subframeCount { 0 };
String m_groupName;
bool m_openedByDOM { false };
bool m_openedByDOMWithOpener { false };
@@ -1072,12 +1067,4 @@
return *m_group;
}
-#if !ASSERT_ENABLED
-
-inline void Page::checkSubframeCountConsistency() const
-{
-}
-
-#endif // !ASSERT_ENABLED
-
} // namespace WebCore