Commit 754ee5c8 authored by mihnea@adobe.com's avatar mihnea@adobe.com

Replace node() calls with generatingNode() for RenderRegion code

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

Reviewed by Darin Adler.

As regions will become anonymous blocks nested inside elements with the flow-from property, a first step
would be to change the calls to node() with calls to generatingNode(). In the case of regions, generatingNode()
will always return an Element* and not a Node*. Therefore, to get rid of toElement() casts, i created
a specific method RenderRegion::generatingElement that will return the generating node as Element.
No new tests as no functional change was introduced.

Original patch by Catalin Badea.

* css/ElementRuleCollector.cpp:
(WebCore::ElementRuleCollector::collectMatchingRulesForRegion):
* dom/WebKitNamedFlow.cpp:
(WebCore::WebKitNamedFlow::getRegionsByContent):
(WebCore::WebKitNamedFlow::getRegions):
* rendering/RenderRegion.cpp:
(WebCore::RenderRegion::regionOversetState):
(WebCore::RenderRegion::setRegionOversetState):
(WebCore::RenderRegion::checkRegionStyle):
* rendering/RenderRegion.h:
(WebCore::RenderRegion::generatingElement):
* rendering/RenderTreeAsText.cpp:
(WebCore::writeRenderRegionList): For pseudo-elements as regions, i want to print
{pseudo} instead of {div} marker for the parent.


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@155109 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 202ca8e7
2013-09-05 Mihnea Ovidenie <mihnea@adobe.com>
Replace node() calls with generatingNode() for RenderRegion code
https://bugs.webkit.org/show_bug.cgi?id=120397
Reviewed by Darin Adler.
As regions will become anonymous blocks nested inside elements with the flow-from property, a first step
would be to change the calls to node() with calls to generatingNode(). In the case of regions, generatingNode()
will always return an Element* and not a Node*. Therefore, to get rid of toElement() casts, i created
a specific method RenderRegion::generatingElement that will return the generating node as Element.
No new tests as no functional change was introduced.
Original patch by Catalin Badea.
* css/ElementRuleCollector.cpp:
(WebCore::ElementRuleCollector::collectMatchingRulesForRegion):
* dom/WebKitNamedFlow.cpp:
(WebCore::WebKitNamedFlow::getRegionsByContent):
(WebCore::WebKitNamedFlow::getRegions):
* rendering/RenderRegion.cpp:
(WebCore::RenderRegion::regionOversetState):
(WebCore::RenderRegion::setRegionOversetState):
(WebCore::RenderRegion::checkRegionStyle):
* rendering/RenderRegion.h:
(WebCore::RenderRegion::generatingElement):
* rendering/RenderTreeAsText.cpp:
(WebCore::writeRenderRegionList): For pseudo-elements as regions, i want to print
{pseudo} instead of {div} marker for the parent.
2013-09-05 Csaba Osztrogonác <ossy@webkit.org>
Fix SynchronousLoaderClient class for !USE(CFNETWORK) platforms
......@@ -182,7 +182,7 @@ void ElementRuleCollector::collectMatchingRulesForRegion(const MatchRequest& mat
unsigned size = matchRequest.ruleSet->regionSelectorsAndRuleSets().size();
for (unsigned i = 0; i < size; ++i) {
const CSSSelector* regionSelector = matchRequest.ruleSet->regionSelectorsAndRuleSets().at(i).selector;
if (checkRegionSelector(regionSelector, toElement(m_regionForStyling->node()))) {
if (checkRegionSelector(regionSelector, m_regionForStyling->generatingElement())) {
RuleSet* regionRules = matchRequest.ruleSet->regionSelectorsAndRuleSets().at(i).ruleSet.get();
ASSERT(regionRules);
collectMatchingRules(MatchRequest(regionRules, matchRequest.includeEmptyRules, matchRequest.scope), ruleRange);
......
......@@ -140,7 +140,7 @@ PassRefPtr<NodeList> WebKitNamedFlow::getRegionsByContent(Node* contentNode)
if (renderRegion->isPseudoElement())
continue;
if (m_parentFlowThread->objectInFlowRegion(contentNode->renderer(), renderRegion))
regionNodes.append(renderRegion->node());
regionNodes.append(renderRegion->generatingElement());
}
}
......@@ -167,7 +167,7 @@ PassRefPtr<NodeList> WebKitNamedFlow::getRegions()
// http://dev.w3.org/csswg/css-regions/#the-region-interface
if (renderRegion->isPseudoElement())
continue;
regionNodes.append(renderRegion->node());
regionNodes.append(renderRegion->generatingElement());
}
return StaticNodeList::adopt(regionNodes);
......
......@@ -139,23 +139,19 @@ LayoutRect RenderRegion::overflowRectForFlowThreadPortion(const LayoutRect& flow
RegionOversetState RenderRegion::regionOversetState() const
{
ASSERT(node());
ASSERT(generatingElement());
if (!isValid())
return RegionUndefined;
if (Element* element = toElement(node()))
return element->regionOversetState();
return RegionUndefined;
return generatingElement()->regionOversetState();
}
void RenderRegion::setRegionOversetState(RegionOversetState state)
{
ASSERT(node());
ASSERT(generatingElement());
if (Element* element = toElement(node()))
element->setRegionOversetState(state);
generatingElement()->setRegionOversetState(state);
}
LayoutUnit RenderRegion::pageLogicalTopForOffset(LayoutUnit /* offset */) const
......@@ -231,10 +227,8 @@ void RenderRegion::checkRegionStyle()
bool customRegionStyle = false;
// FIXME: Region styling doesn't work for pseudo elements.
if (node()) {
Element* regionElement = toElement(node());
customRegionStyle = view().document().ensureStyleResolver().checkRegionStyle(regionElement);
}
if (!isPseudoElement())
customRegionStyle = view().document().ensureStyleResolver().checkRegionStyle(generatingElement());
setHasCustomRegionStyle(customRegionStyle);
m_flowThread->checkRegionsWithStyling();
}
......
......@@ -35,6 +35,7 @@
namespace WebCore {
class Element;
struct LayerFragment;
typedef Vector<LayerFragment, 1> LayerFragments;
class RenderBox;
......@@ -152,6 +153,8 @@ public:
LayoutRect rectFlowPortionForBox(const RenderBox*, const LayoutRect&) const;
Element* generatingElement() const { return toElement(RenderObject::generatingNode()); }
protected:
RenderOverflow* ensureOverflowForBox(const RenderBox*);
......
......@@ -669,14 +669,12 @@ static void writeRenderRegionList(const RenderRegionList& flowThreadRegionList,
RenderRegion* renderRegion = *itRR;
writeIndent(ts, indent + 2);
ts << "RenderRegion";
if (renderRegion->generatingNode()) {
String tagName = getTagName(renderRegion->generatingNode());
if (renderRegion->generatingElement()) {
String tagName = getTagName(renderRegion->node());
if (!tagName.isEmpty())
ts << " {" << tagName << "}";
if (renderRegion->generatingNode()->isElementNode() && toElement(renderRegion->generatingNode())->hasID()) {
Element* element = toElement(renderRegion->generatingNode());
ts << " #" << element->idForStyleResolution();
}
if (renderRegion->generatingElement()->hasID())
ts << " #" << renderRegion->generatingElement()->idForStyleResolution();
if (renderRegion->hasLayer())
ts << " hasLayer";
if (renderRegion->hasCustomRegionStyle())
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment