summaryrefslogtreecommitdiff
path: root/Source/WebCore/dom/WebKitNamedFlow.cpp
diff options
context:
space:
mode:
authorLorry Tar Creator <lorry-tar-importer@lorry>2017-06-27 06:07:23 +0000
committerLorry Tar Creator <lorry-tar-importer@lorry>2017-06-27 06:07:23 +0000
commit1bf1084f2b10c3b47fd1a588d85d21ed0eb41d0c (patch)
tree46dcd36c86e7fbc6e5df36deb463b33e9967a6f7 /Source/WebCore/dom/WebKitNamedFlow.cpp
parent32761a6cee1d0dee366b885b7b9c777e67885688 (diff)
downloadWebKitGtk-tarball-master.tar.gz
Diffstat (limited to 'Source/WebCore/dom/WebKitNamedFlow.cpp')
-rw-r--r--Source/WebCore/dom/WebKitNamedFlow.cpp83
1 files changed, 39 insertions, 44 deletions
diff --git a/Source/WebCore/dom/WebKitNamedFlow.cpp b/Source/WebCore/dom/WebKitNamedFlow.cpp
index cff2dd659..f4cc9f224 100644
--- a/Source/WebCore/dom/WebKitNamedFlow.cpp
+++ b/Source/WebCore/dom/WebKitNamedFlow.cpp
@@ -30,7 +30,9 @@
#include "config.h"
#include "WebKitNamedFlow.h"
+#include "EventNames.h"
#include "NamedFlowCollection.h"
+#include "NoEventDispatchAssertion.h"
#include "RenderNamedFlowFragment.h"
#include "RenderNamedFlowThread.h"
#include "RenderRegion.h"
@@ -39,10 +41,10 @@
namespace WebCore {
-WebKitNamedFlow::WebKitNamedFlow(PassRefPtr<NamedFlowCollection> manager, const AtomicString& flowThreadName)
+WebKitNamedFlow::WebKitNamedFlow(NamedFlowCollection& manager, const AtomicString& flowThreadName)
: m_flowThreadName(flowThreadName)
- , m_flowManager(manager)
- , m_parentFlowThread(0)
+ , m_flowManager(&manager)
+ , m_parentFlowThread(nullptr)
{
}
@@ -52,9 +54,9 @@ WebKitNamedFlow::~WebKitNamedFlow()
m_flowManager->discardNamedFlow(this);
}
-PassRefPtr<WebKitNamedFlow> WebKitNamedFlow::create(PassRefPtr<NamedFlowCollection> manager, const AtomicString& flowThreadName)
+Ref<WebKitNamedFlow> WebKitNamedFlow::create(NamedFlowCollection& manager, const AtomicString& flowThreadName)
{
- return adoptRef(new WebKitNamedFlow(manager, flowThreadName));
+ return adoptRef(*new WebKitNamedFlow(manager, flowThreadName));
}
const AtomicString& WebKitNamedFlow::name() const
@@ -69,7 +71,11 @@ bool WebKitNamedFlow::overset() const
// The renderer may be destroyed or created after the style update.
// Because this is called from JS, where the wrapper keeps a reference to the NamedFlow, no guard is necessary.
- return m_parentFlowThread ? m_parentFlowThread->overset() : true;
+ if (!m_parentFlowThread || !m_parentFlowThread->hasRegions())
+ return true;
+
+ const auto& namedFlowFragment = downcast<RenderNamedFlowFragment>(*m_parentFlowThread->lastRegion());
+ return namedFlowFragment.regionOversetState() == RegionOverset;
}
static inline bool inFlowThread(RenderObject* renderer, RenderNamedFlowThread* flowThread)
@@ -100,23 +106,23 @@ int WebKitNamedFlow::firstEmptyRegionIndex() const
int countNonPseudoRegions = -1;
for (const auto& renderRegion : regionList) {
- const RenderNamedFlowFragment* namedFlowFragment = toRenderNamedFlowFragment(renderRegion);
+ const auto& namedFlowFragment = downcast<RenderNamedFlowFragment>(*renderRegion);
// FIXME: Pseudo-elements are not included in the list.
// They will be included when we will properly support the Region interface
// http://dev.w3.org/csswg/css-regions/#the-region-interface
- if (namedFlowFragment->isPseudoElementRegion())
+ if (namedFlowFragment.isPseudoElementRegion())
continue;
- countNonPseudoRegions++;
- if (namedFlowFragment->regionOversetState() == RegionEmpty)
+ ++countNonPseudoRegions;
+ if (namedFlowFragment.regionOversetState() == RegionEmpty)
return countNonPseudoRegions;
}
return -1;
}
-PassRefPtr<NodeList> WebKitNamedFlow::getRegionsByContent(Node* contentNode)
+Ref<NodeList> WebKitNamedFlow::getRegionsByContent(Node* contentNode)
{
if (!contentNode)
- return StaticElementList::createEmpty();
+ return StaticElementList::create();
if (m_flowManager->document())
m_flowManager->document()->updateLayoutIgnorePendingStylesheets();
@@ -124,30 +130,30 @@ PassRefPtr<NodeList> WebKitNamedFlow::getRegionsByContent(Node* contentNode)
// The renderer may be destroyed or created after the style update.
// Because this is called from JS, where the wrapper keeps a reference to the NamedFlow, no guard is necessary.
if (!m_parentFlowThread)
- return StaticElementList::createEmpty();
+ return StaticElementList::create();
Vector<Ref<Element>> regionElements;
if (inFlowThread(contentNode->renderer(), m_parentFlowThread)) {
const RenderRegionList& regionList = m_parentFlowThread->renderRegionList();
for (const auto& renderRegion : regionList) {
- const RenderNamedFlowFragment* namedFlowFragment = toRenderNamedFlowFragment(renderRegion);
+ const auto& namedFlowFragment = downcast<RenderNamedFlowFragment>(*renderRegion);
// FIXME: Pseudo-elements are not included in the list.
// They will be included when we will properly support the Region interface
// http://dev.w3.org/csswg/css-regions/#the-region-interface
- if (namedFlowFragment->isPseudoElementRegion())
+ if (namedFlowFragment.isPseudoElementRegion())
continue;
- if (m_parentFlowThread->objectInFlowRegion(contentNode->renderer(), namedFlowFragment)) {
- ASSERT(namedFlowFragment->generatingElement());
- regionElements.append(*namedFlowFragment->generatingElement());
+ if (m_parentFlowThread->objectInFlowRegion(contentNode->renderer(), &namedFlowFragment)) {
+ ASSERT(namedFlowFragment.generatingElement());
+ regionElements.append(*namedFlowFragment.generatingElement());
}
}
}
- return StaticElementList::adopt(regionElements);
+ return StaticElementList::create(WTFMove(regionElements));
}
-PassRefPtr<NodeList> WebKitNamedFlow::getRegions()
+Ref<NodeList> WebKitNamedFlow::getRegions()
{
if (m_flowManager->document())
m_flowManager->document()->updateLayoutIgnorePendingStylesheets();
@@ -155,26 +161,26 @@ PassRefPtr<NodeList> WebKitNamedFlow::getRegions()
// The renderer may be destroyed or created after the style update.
// Because this is called from JS, where the wrapper keeps a reference to the NamedFlow, no guard is necessary.
if (!m_parentFlowThread)
- return StaticElementList::createEmpty();
+ return StaticElementList::create();
Vector<Ref<Element>> regionElements;
const RenderRegionList& regionList = m_parentFlowThread->renderRegionList();
for (const auto& renderRegion : regionList) {
- const RenderNamedFlowFragment* namedFlowFragment = toRenderNamedFlowFragment(renderRegion);
+ const auto& namedFlowFragment = downcast<RenderNamedFlowFragment>(*renderRegion);
// FIXME: Pseudo-elements are not included in the list.
// They will be included when we will properly support the Region interface
// http://dev.w3.org/csswg/css-regions/#the-region-interface
- if (namedFlowFragment->isPseudoElementRegion())
+ if (namedFlowFragment.isPseudoElementRegion())
continue;
- ASSERT(namedFlowFragment->generatingElement());
- regionElements.append(*namedFlowFragment->generatingElement());
+ ASSERT(namedFlowFragment.generatingElement());
+ regionElements.append(*namedFlowFragment.generatingElement());
}
- return StaticElementList::adopt(regionElements);
+ return StaticElementList::create(WTFMove(regionElements));
}
-PassRefPtr<NodeList> WebKitNamedFlow::getContent()
+Ref<NodeList> WebKitNamedFlow::getContent()
{
if (m_flowManager->document())
m_flowManager->document()->updateLayoutIgnorePendingStylesheets();
@@ -182,17 +188,17 @@ PassRefPtr<NodeList> WebKitNamedFlow::getContent()
// The renderer may be destroyed or created after the style update.
// Because this is called from JS, where the wrapper keeps a reference to the NamedFlow, no guard is necessary.
if (!m_parentFlowThread)
- return StaticElementList::createEmpty();
+ return StaticElementList::create();
+ auto& contentElementsList = m_parentFlowThread->contentElements();
Vector<Ref<Element>> contentElements;
-
- const NamedFlowContentElements& contentElementsList = m_parentFlowThread->contentElements();
+ contentElements.reserveInitialCapacity(contentElementsList.size());
for (auto& element : contentElementsList) {
ASSERT(element->computedStyle()->flowThread() == m_parentFlowThread->flowThreadName());
- contentElements.append(*element);
+ contentElements.uncheckedAppend(*element);
}
- return StaticElementList::adopt(contentElements);
+ return StaticElementList::create(WTFMove(contentElements));
}
void WebKitNamedFlow::setRenderer(RenderNamedFlowThread* parentFlowThread)
@@ -204,20 +210,9 @@ void WebKitNamedFlow::setRenderer(RenderNamedFlowThread* parentFlowThread)
m_parentFlowThread = parentFlowThread;
}
-void WebKitNamedFlow::dispatchRegionLayoutUpdateEvent()
-{
- ASSERT(!NoEventDispatchAssertion::isEventDispatchForbidden());
-
- // If the flow is in the "NULL" state the event should not be dispatched any more.
- if (flowState() == FlowStateNull)
- return;
-
- dispatchEvent(UIEvent::create(eventNames().webkitregionlayoutupdateEvent, false, false, m_flowManager->document()->defaultView(), 0));
-}
-
void WebKitNamedFlow::dispatchRegionOversetChangeEvent()
{
- ASSERT(!NoEventDispatchAssertion::isEventDispatchForbidden());
+ ASSERT_WITH_SECURITY_IMPLICATION(NoEventDispatchAssertion::isEventAllowedInMainThread());
// If the flow is in the "NULL" state the event should not be dispatched any more.
if (flowState() == FlowStateNull)