LayoutTests/ChangeLog

 12011-11-03 Mihnea Ovidenie <mihnea@adobe.com>
 2
 3 [CSSRegions]Add support for background-color in region styling
 4 https://bugs.webkit.org/show_bug.cgi?id=71488
 5
 6 Reviewed by NOBODY (OOPS!).
 7
 8 * fast/regions/region-style-background-color.html: Added.
 9 * platform/chromium/test_expectations.txt:
 10 * platform/mac-snowleopard/fast/regions/region-style-background-color-expected.png: Added.
 11 * platform/mac-snowleopard/fast/regions/region-style-background-color-expected.txt: Added.
 12
1132011-11-03 Andrey Kosyakov <caseq@chromium.org>
214
315 Unreviewed expectations update.

LayoutTests/fast/regions/region-style-background-color.html

 1<!doctype html>
 2<html>
 3 <!--
 4 Test setting the background-color property using region styling.
 5 You should not see any red background below.
 6 -->
 7 <head>
 8 <style>
 9 p { background-color: red; }
 10 .regionBox { width: 250px; height: 50px; }
 11
 12 #article1 { -webkit-flow-into: flow1; }
 13 #region1 { -webkit-flow-from: flow1; }
 14 @-webkit-region #region1 { p { background-color: green; } }
 15
 16 #article2 { -webkit-flow-into: flow2; }
 17 #region21, #region22 { -webkit-flow-from: flow2; }
 18 @-webkit-region #region21 { p { background-color: green; } }
 19 @-webkit-region #region22 { p { background-color: lime; } }
 20
 21 #article3 { -webkit-flow-into: flow3; }
 22 #region31, #region32 { -webkit-flow-from: flow3; }
 23 @-webkit-region #region31 { p { background-color: green; } }
 24 @-webkit-region #region32 { p { background-color: lime; } }
 25 </style>
 26 </head>
 27 <body class="body">
 28 <!-- Style a single paragraph in a single region -->
 29 <div id="article1">
 30 <p>Paragraph text styled in region1.</p>
 31 </div>
 32 <div id="region1" class="regionBox"></div>
 33 <!-- Style separate paragraphs in different regions -->
 34 <div id="article2">
 35 <p>Paragraph text styled in region21.</p>
 36 <p>Paragraph text styled in region22.</p>
 37 </div>
 38 <div id="region21" class="regionBox"></div>
 39 <div id="region22" class="regionBox"></div>
 40 <!-- Style a single paragraph in different regions -->
 41 <div id="article3">
 42 <p>Paragraph text styled in region31. Paragraph text styled in region32.</p>
 43 </div>
 44 <div id="region31" class="regionBox"></div>
 45 <div id="region32" class="regionBox"></div>
 46 </body>
 47</html>

LayoutTests/platform/chromium/test_expectations.txt

@@BUGWK62048 SKIP : css3/flexbox = PASS
33083308// CSS Regions support not yet enabled.
33093309BUGWK57312 SKIP : fast/regions = PASS
33103310BUGWK70733 SKIP : fast/regions/render-region-custom-style-mark.html = FAIL
 3311BUGWK71488 SKIP : fast/regions/region-style-background-color.html = FAIL
33113312
33123313// CSS Exclusions support not yet enabled.
33133314BUGWK57311 SKIP : fast/exclusions = PASS

LayoutTests/platform/mac-snowleopard/fast/regions/region-style-background-color-expected.png


Added

3ed589bdd692d34818dce19a89e5e093

LayoutTests/platform/mac-snowleopard/fast/regions/region-style-background-color-expected.txt

 1layer at (0,0) size 800x600
 2 RenderView at (0,0) size 800x600
 3layer at (0,0) size 800x266
 4 RenderBlock {HTML} at (0,0) size 800x266
 5 RenderBody {BODY} at (8,8) size 784x250
 6 RenderRegion {DIV} at (0,0) size 250x50
 7 RenderRegion {DIV} at (0,50) size 250x50
 8 RenderRegion {DIV} at (0,100) size 250x50
 9 RenderRegion {DIV} at (0,150) size 250x50
 10 RenderRegion {DIV} at (0,200) size 250x50
 11Flow Threads
 12 Thread with flow-name 'flow1'
 13 layer at (0,0) size 250x50
 14 RenderFlowThread at (0,0) size 250x50
 15 RenderBlock {DIV} at (0,16) size 250x18
 16 RenderBlock {P} at (0,0) size 250x18 [bgcolor=#FF0000]
 17 RenderText {#text} at (0,0) size 204x18
 18 text run at (0,0) width 204: "Paragraph text styled in region1."
 19 Regions for flow 'flow1'
 20 RenderRegion {DIV} #region1 region style: 1
 21 Thread with flow-name 'flow2'
 22 layer at (0,0) size 250x100
 23 RenderFlowThread at (0,0) size 250x100
 24 RenderBlock {DIV} at (0,16) size 250x52
 25 RenderBlock {P} at (0,0) size 250x18 [bgcolor=#FF0000]
 26 RenderText {#text} at (0,0) size 212x18
 27 text run at (0,0) width 212: "Paragraph text styled in region21."
 28 RenderBlock {P} at (0,34) size 250x18 [bgcolor=#FF0000]
 29 RenderText {#text} at (0,0) size 212x18
 30 text run at (0,0) width 212: "Paragraph text styled in region22."
 31 Regions for flow 'flow2'
 32 RenderRegion {DIV} #region21 region style: 1
 33 RenderRegion {DIV} #region22 region style: 1
 34 Thread with flow-name 'flow3'
 35 layer at (0,0) size 250x100
 36 RenderFlowThread at (0,0) size 250x100
 37 RenderBlock {DIV} at (0,16) size 250x52
 38 RenderBlock {P} at (0,0) size 250x52 [bgcolor=#00FF00]
 39 RenderText {#text} at (0,0) size 212x52
 40 text run at (0,0) width 212: "Paragraph text styled in region31."
 41 text run at (0,34) width 212: "Paragraph text styled in region32."
 42 Regions for flow 'flow3'
 43 RenderRegion {DIV} #region31 region style: 1
 44 RenderRegion {DIV} #region32 region style: 1

Source/WebCore/CMakeLists.txt

@@SET(WebCore_SOURCES
12321232 rendering/RenderBlockLineLayout.cpp
12331233 rendering/RenderBox.cpp
12341234 rendering/RenderBoxModelObject.cpp
 1235 rendering/RenderBoxRegionInfo.cpp
12351236 rendering/RenderButton.cpp
12361237 rendering/RenderCombineText.cpp
12371238 rendering/RenderCounter.cpp

Source/WebCore/ChangeLog

 12011-11-03 Mihnea Ovidenie <mihnea@adobe.com>
 2
 3 [CSSRegions]Add support for background-color in region styling
 4 https://bugs.webkit.org/show_bug.cgi?id=71488
 5
 6 Reviewed by NOBODY (OOPS!).
 7
 8 Test: fast/regions/region-style-background-color.html
 9
 10 * CMakeLists.txt:
 11 * GNUmakefile.list.am:
 12 * WebCore.exp.in:
 13 * WebCore.gypi:
 14 * WebCore.pro:
 15 * WebCore.vcproj/WebCore.vcproj:
 16 * WebCore.xcodeproj/project.pbxproj:
 17 * css/CSSStyleSelector.cpp:
 18 (WebCore::RuleData::regionStyleRule):
 19 (WebCore::CSSStyleSelector::CSSStyleSelector):
 20 (WebCore::CSSStyleSelector::addMatchedDeclaration):
 21 (WebCore::CSSStyleSelector::matchRules):
 22 (WebCore::CSSStyleSelector::matchAllRules):
 23 (WebCore::CSSStyleSelector::initForRegionStyling):
 24 (WebCore::CSSStyleSelector::styleForElement):
 25 (WebCore::CSSStyleSelector::pseudoStyleForElement):
 26 (WebCore::RuleData::RuleData):
 27 (WebCore::RuleSet::RuleSet):
 28 (WebCore::RuleSet::addToRuleSet):
 29 (WebCore::CSSStyleSelector::applyDeclarations):
 30 (WebCore::isValidRegionStyleProperty):
 31 (WebCore::CSSStyleSelector::applyProperty):
 32 * css/CSSStyleSelector.h:
 33 (WebCore::CSSStyleSelector::setRegionForStyling):
 34 (WebCore::CSSStyleSelector::regionForStyling):
 35 (WebCore::CSSStyleSelector::applyPropertyToRegionStyle):
 36 * rendering/RenderBox.h:
 37 * rendering/RenderBoxRegionInfo.cpp: Added.
 38 (WebCore::RenderBoxRegionInfo::setRegionStyle):
 39 (WebCore::RenderBoxRegionInfo::computeStyleInRegion):
 40 * rendering/RenderBoxRegionInfo.h:
 41 (WebCore::RenderBoxRegionInfo::RenderBoxRegionInfo):
 42 (WebCore::RenderBoxRegionInfo::regionStyle):
 43 * rendering/RenderFlowThread.cpp:
 44 (WebCore::RenderFlowThread::setRegionRangeForBox):
 45 * rendering/RenderLayer.cpp:
 46 (WebCore::RenderLayer::paint):
 47 * rendering/RenderObject.cpp:
 48 (WebCore::RenderObject::style):
 49 * rendering/RenderObject.h:
 50 * rendering/RenderView.cpp:
 51 (WebCore::RenderView::RenderView):
 52 * rendering/RenderView.h:
 53 (WebCore::RenderView::currentRenderRegion):
 54 (WebCore::RenderView::setCurrentRenderRegion):
 55
1562011-11-03 Andreas Kling <kling@webkit.org>
257
358 CSSRuleList: Move rule orphaning from deleteRule() out to callers.

Source/WebCore/GNUmakefile.list.am

@@webcore_sources += \
30373037 Source/WebCore/rendering/RenderBlockLineLayout.cpp \
30383038 Source/WebCore/rendering/RenderBox.cpp \
30393039 Source/WebCore/rendering/RenderBox.h \
 3040 Source/WebCore/rendering/RenderBoxRegionInfo.cpp \
30403041 Source/WebCore/rendering/RenderBoxRegionInfo.h \
30413042 Source/WebCore/rendering/RenderBoxModelObject.cpp \
30423043 Source/WebCore/rendering/RenderBoxModelObject.h \

Source/WebCore/WebCore.exp.in

@@__ZNK7WebCore12RenderObject14enclosingLayerEv
11651165__ZNK7WebCore12RenderObject15localToAbsoluteERKNS_10FloatPointEbb
11661166__ZNK7WebCore12RenderObject4viewEv
11671167__ZNK7WebCore12RenderObject7childAtEj
 1168__ZNK7WebCore12RenderObject5styleEv
11681169__ZNK7WebCore12RenderWidget14windowClipRectEv
11691170__ZNK7WebCore12SharedBuffer11getSomeDataERPKcj
11701171__ZNK7WebCore12SharedBuffer4dataEv

Source/WebCore/WebCore.gypi

905905 'rendering/RenderBlock.h',
906906 'rendering/RenderBox.h',
907907 'rendering/RenderBoxModelObject.h',
 908 'rendering/RenderBoxRegionInfo.h',
908909 'rendering/RenderEmbeddedObject.h',
909910 'rendering/RenderFlowThread.h',
910911 'rendering/RenderImage.h',

45494550 'rendering/RenderBlockLineLayout.cpp',
45504551 'rendering/RenderBox.cpp',
45514552 'rendering/RenderBoxModelObject.cpp',
 4553 'rendering/RenderBoxRegionInfo.cpp',
45524554 'rendering/RenderButton.cpp',
45534555 'rendering/RenderButton.h',
45544556 'rendering/RenderCombineText.cpp',

Source/WebCore/WebCore.pro

@@SOURCES += \
11601160 rendering/RenderBlockLineLayout.cpp \
11611161 rendering/RenderBox.cpp \
11621162 rendering/RenderBoxModelObject.cpp \
 1163 rendering/RenderBoxRegionInfo.cpp \
11631164 rendering/RenderBR.cpp \
11641165 rendering/RenderButton.cpp \
11651166 rendering/RenderCombineText.cpp \

@@HEADERS += \
22632264 rendering/RenderBlock.h \
22642265 rendering/RenderBox.h \
22652266 rendering/RenderBoxModelObject.h \
 2267 rendering/RenderBoxRegionInfo.h \
22662268 rendering/RenderBR.h \
22672269 rendering/RenderButton.h \
22682270 rendering/RenderCombineText.h \

Source/WebCore/WebCore.vcproj/WebCore.vcproj

3417034170 >
3417134171 </File>
3417234172 <File
 34173 RelativePath="..\rendering\RenderBoxRegionInfo.cpp"
 34174 >
 34175 </File>
 34176 <File
 34177 RelativePath="..\rendering\RenderBoxRegionInfo.h"
 34178 >
 34179 </File>
 34180 <File
3417334181 RelativePath="..\rendering\RenderBR.cpp"
3417434182 >
3417534183 <FileConfiguration

Source/WebCore/WebCore.xcodeproj/project.pbxproj

28922892 8A81BF8511DCFD9000DA2B98 /* ResourceLoadTiming.h in Headers */ = {isa = PBXBuildFile; fileRef = 8A81BF8411DCFD9000DA2B98 /* ResourceLoadTiming.h */; settings = {ATTRIBUTES = (Private, ); }; };
28932893 8A844D0411D3C18E0014065C /* Performance.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 8A844D0111D3C18E0014065C /* Performance.cpp */; };
28942894 8A844D0511D3C18E0014065C /* Performance.h in Headers */ = {isa = PBXBuildFile; fileRef = 8A844D0211D3C18E0014065C /* Performance.h */; };
 2895 8A94293D14613A8C002AAF1B /* RenderBoxRegionInfo.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 8A94293C14613A8C002AAF1B /* RenderBoxRegionInfo.cpp */; };
28952896 8A9A587011E84C36008ACFD1 /* JSPerformanceNavigation.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 8A9A586E11E84C35008ACFD1 /* JSPerformanceNavigation.cpp */; };
28962897 8A9A587111E84C36008ACFD1 /* JSPerformanceNavigation.h in Headers */ = {isa = PBXBuildFile; fileRef = 8A9A586F11E84C36008ACFD1 /* JSPerformanceNavigation.h */; };
28972898 8A9A587411E84C81008ACFD1 /* JSPerformance.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 8A9A587211E84C81008ACFD1 /* JSPerformance.cpp */; };

1003910040 8A844D0111D3C18E0014065C /* Performance.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Performance.cpp; sourceTree = "<group>"; };
1004010041 8A844D0211D3C18E0014065C /* Performance.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Performance.h; sourceTree = "<group>"; };
1004110042 8A844D0311D3C18E0014065C /* Performance.idl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = Performance.idl; sourceTree = "<group>"; };
 10043 8A94293C14613A8C002AAF1B /* RenderBoxRegionInfo.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = RenderBoxRegionInfo.cpp; sourceTree = "<group>"; };
1004210044 8A9A586E11E84C35008ACFD1 /* JSPerformanceNavigation.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSPerformanceNavigation.cpp; sourceTree = "<group>"; };
1004310045 8A9A586F11E84C36008ACFD1 /* JSPerformanceNavigation.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSPerformanceNavigation.h; sourceTree = "<group>"; };
1004410046 8A9A587211E84C81008ACFD1 /* JSPerformance.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSPerformance.cpp; sourceTree = "<group>"; };

2071220714 BC96DB450F3A882200573CB3 /* RenderBoxModelObject.cpp */,
2071320715 BC96DB420F3A880E00573CB3 /* RenderBoxModelObject.h */,
2071420716 BCEB179B143379F50052EAE9 /* RenderBoxRegionInfo.h */,
 20717 8A94293C14613A8C002AAF1B /* RenderBoxRegionInfo.cpp */,
2071520718 BCEA4824097D93020094C9E4 /* RenderBR.cpp */,
2071620719 BCEA4825097D93020094C9E4 /* RenderBR.h */,
2071720720 BCEA4826097D93020094C9E4 /* RenderButton.cpp */,

2739127394 A0EE0DF7144F825500F80B0D /* WebGLDebugShaders.cpp in Sources */,
2739227395 A3BB59F31457A40D00AC56FE /* DocumentEventQueue.cpp in Sources */,
2739327396 2D8FEBDC143E3EF70072502B /* CSSCrossfadeValue.cpp in Sources */,
 27397 8A94293D14613A8C002AAF1B /* RenderBoxRegionInfo.cpp in Sources */,
2739427398 );
2739527399 runOnlyForDeploymentPostprocessing = 0;
2739627400 };

Source/WebCore/css/CSSStyleSelector.cpp

8484#include "PerspectiveTransformOperation.h"
8585#include "QuotesData.h"
8686#include "Rect.h"
 87#include "RenderRegion.h"
8788#include "RenderScrollbar.h"
8889#include "RenderScrollbarTheme.h"
8990#include "RenderStyleConstants.h"

@@if (id == propID) { \
187188
188189class RuleData {
189190public:
190  RuleData(CSSStyleRule*, CSSSelector*, unsigned position);
 191 RuleData(CSSStyleRule*, CSSSelector*, unsigned position, bool regionStyleRule = false);
191192
192193 unsigned position() const { return m_position; }
193194 CSSStyleRule* rule() const { return m_rule; }

@@public:
199200 bool containsUncommonAttributeSelector() const { return m_containsUncommonAttributeSelector; }
200201 unsigned specificity() const { return m_specificity; }
201202 unsigned linkMatchType() const { return m_linkMatchType; }
 203 bool regionStyleRule() const { return m_regionStyleRule; }
202204
203205 // Try to balance between memory usage (there can be lots of RuleData objects) and good filtering performance.
204206 static const unsigned maximumIdentifierCount = 4;

@@private:
214216 bool m_hasRightmostSelectorMatchingHTMLBasedOnRuleHash : 1;
215217 bool m_containsUncommonAttributeSelector : 1;
216218 unsigned m_linkMatchType : 2; // SelectorChecker::LinkMatchMask
 219 bool m_regionStyleRule : 1;
217220 // Use plain array instead of a Vector to minimize memory overhead.
218221 unsigned m_descendantSelectorIdentifierHashes[maximumIdentifierCount];
219222};

@@private:
221224class RuleSet {
222225 WTF_MAKE_NONCOPYABLE(RuleSet);
223226public:
224  RuleSet();
 227 RuleSet(bool regionStyleRules = false);
225228 ~RuleSet();
226229
227230 typedef HashMap<AtomicStringImpl*, Vector<RuleData>*> AtomRuleMap;

@@public:
258261 Vector<RuleData> m_pageRules;
259262 unsigned m_ruleCount;
260263 bool m_autoShrinkToFitEnabled;
 264 bool m_regionStyleRules;
261265};
262266
263267static RuleSet* defaultStyle;

@@CSSStyleSelector::CSSStyleSelector(Document* document, StyleSheetList* styleShee
341345 , m_checker(document, strictParsing)
342346 , m_element(0)
343347 , m_styledElement(0)
 348 , m_regionForStyling(0)
344349 , m_elementLinkState(NotInsideLink)
345350 , m_fontDirty(false)
346351 , m_matchAuthorAndUserStyles(matchAuthorAndUserStyles)

@@CSSStyleSelector::CSSStyleSelector(Document* document, StyleSheetList* styleShee
348353 , m_fontSelector(CSSFontSelector::create(document))
349354 , m_applyPropertyToRegularStyle(true)
350355 , m_applyPropertyToVisitedLinkStyle(false)
 356 , m_applyPropertyToRegionStyle(false)
351357 , m_applyProperty(CSSStyleApplyProperty::sharedCSSStyleApplyProperty())
352358{
353359 Element* root = document->documentElement();

@@CSSStyleSelector::MatchedStyleDeclaration::MatchedStyleDeclaration()
599605 memset(this, 0, sizeof(*this));
600606}
601607
602 void CSSStyleSelector::addMatchedDeclaration(CSSMutableStyleDeclaration* styleDeclaration, unsigned linkMatchType)
 608void CSSStyleSelector::addMatchedDeclaration(CSSMutableStyleDeclaration* styleDeclaration, unsigned linkMatchType, bool regionStyleRule)
603609{
604610 m_matchedDecls.grow(m_matchedDecls.size() + 1);
605611 MatchedStyleDeclaration& newDeclaration = m_matchedDecls.last();
606612 newDeclaration.styleDeclaration = styleDeclaration;
607613 newDeclaration.linkMatchType = linkMatchType;
 614 newDeclaration.regionStyleRule = regionStyleRule;
608615}
609616
610617void CSSStyleSelector::matchRules(RuleSet* rules, int& firstRuleIndex, int& lastRuleIndex, bool includeEmptyRules)

@@void CSSStyleSelector::matchRules(RuleSet* rules, int& firstRuleIndex, int& last
654661 unsigned linkMatchType = m_matchedRules[i]->linkMatchType();
655662 if (swapVisitedUnvisited && linkMatchType && linkMatchType != SelectorChecker::MatchAll)
656663 linkMatchType = (linkMatchType == SelectorChecker::MatchVisited) ? SelectorChecker::MatchLink : SelectorChecker::MatchVisited;
657  addMatchedDeclaration(m_matchedRules[i]->rule()->declaration(), linkMatchType);
 664 addMatchedDeclaration(m_matchedRules[i]->rule()->declaration(), linkMatchType, m_matchedRules[i]->regionStyleRule());
658665 }
659666 } else {
660667 for (unsigned i = 0; i < m_matchedRules.size(); i++) {

@@void CSSStyleSelector::matchAllRules(MatchResult& result)
807814 // Check the rules in author sheets next.
808815 if (m_matchAuthorAndUserStyles)
809816 matchRules(m_authorStyle.get(), result.firstAuthorRule, result.lastAuthorRule, false);
 817
 818 if (m_regionForStyling)
 819 matchRules(m_regionRules.get(), result.firstAuthorRule, result.lastAuthorRule, false);
810820
811821 // Now check our inline style attribute.
812822 if (m_matchAuthorAndUserStyles && m_styledElement) {

@@inline void CSSStyleSelector::initForStyleResolve(Element* e, RenderStyle* paren
860870 m_fontDirty = false;
861871}
862872
 873void CSSStyleSelector::initForRegionStyling(RenderRegion* region)
 874{
 875 setRegionForStyling(region);
 876 // Mark that the set of rules comes from region styling since we need to filter
 877 // the properties that can be applied.
 878 m_regionRules = adoptPtr(new RuleSet(true));
 879
 880 if (!region)
 881 return;
 882
 883 // From all the region style rules, select those that apply to the specified region.
 884 for (Vector<RefPtr<CSSRegionStyleRule> >::iterator it = m_regionStyleRules.begin(); it != m_regionStyleRules.end(); ++it) {
 885 const CSSSelectorList& regionSelectorList = (*it)->selectorList();
 886 for (CSSSelector* s = regionSelectorList.first(); s; s = regionSelectorList.next(s)) {
 887 if (!m_checker.checkSelector(s, static_cast<Element*>(region->node())))
 888 continue;
 889 CSSRuleList* regionStylingRules = (*it)->cssRules();
 890 for (unsigned index = 0; index < regionStylingRules->length(); ++index) {
 891 CSSRule* regionStylingRule = regionStylingRules->item(index);
 892 if (regionStylingRule->isStyleRule())
 893 m_regionRules->addStyleRule(static_cast<CSSStyleRule*>(regionStylingRule));
 894 }
 895 }
 896 }
 897}
 898
863899static const unsigned cStyleSearchThreshold = 10;
864900static const unsigned cStyleSearchLevelThreshold = 10;
865901

@@static inline bool isAtShadowBoundary(Element* element)
11971233// If resolveForRootDefault is true, style based on user agent style sheet only. This is used in media queries, where
11981234// relative units are interpreted according to document root element style, styled only with UA stylesheet
11991235
1200 PassRefPtr<RenderStyle> CSSStyleSelector::styleForElement(Element* element, RenderStyle* defaultParent, bool allowSharing, bool resolveForRootDefault)
 1236PassRefPtr<RenderStyle> CSSStyleSelector::styleForElement(Element* element, RenderStyle* defaultParent, bool allowSharing, bool resolveForRootDefault, RenderRegion* regionForStyling)
12011237{
12021238 // Once an element has a renderer, we don't try to destroy it, since otherwise the renderer
12031239 // will vanish if a style recalc happens during loading.

@@PassRefPtr<RenderStyle> CSSStyleSelector::styleForElement(Element* element, Rend
12131249
12141250 initElement(element);
12151251 initForStyleResolve(element, defaultParent);
 1252 initForRegionStyling(regionForStyling);
 1253
12161254 if (allowSharing) {
12171255 RenderStyle* sharedStyle = locateSharedStyle();
12181256 if (sharedStyle)

@@void CSSStyleSelector::keyframeStylesForAnimation(Element* e, const RenderStyle*
13631401 }
13641402}
13651403
1366 PassRefPtr<RenderStyle> CSSStyleSelector::pseudoStyleForElement(PseudoId pseudo, Element* e, RenderStyle* parentStyle)
 1404PassRefPtr<RenderStyle> CSSStyleSelector::pseudoStyleForElement(PseudoId pseudo, Element* e, RenderStyle* parentStyle, RenderRegion* regionForStyling)
13671405{
13681406 if (!e)
13691407 return 0;

@@PassRefPtr<RenderStyle> CSSStyleSelector::pseudoStyleForElement(PseudoId pseudo,
13711409 initElement(e);
13721410
13731411 initForStyleResolve(e, parentStyle, pseudo);
 1412
 1413 initForRegionStyling(regionForStyling);
13741414 m_style = RenderStyle::create();
13751415
13761416 if (m_parentStyle)

@@static inline bool containsUncommonAttributeSelector(const CSSSelector* selector
18171857 return false;
18181858}
18191859
1820 RuleData::RuleData(CSSStyleRule* rule, CSSSelector* selector, unsigned position)
 1860RuleData::RuleData(CSSStyleRule* rule, CSSSelector* selector, unsigned position, bool regionStyleRule)
18211861 : m_rule(rule)
18221862 , m_selector(selector)
18231863 , m_specificity(selector->specificity())

@@RuleData::RuleData(CSSStyleRule* rule, CSSSelector* selector, unsigned position)
18271867 , m_hasRightmostSelectorMatchingHTMLBasedOnRuleHash(isSelectorMatchingHTMLBasedOnRuleHash(selector))
18281868 , m_containsUncommonAttributeSelector(WebCore::containsUncommonAttributeSelector(selector))
18291869 , m_linkMatchType(SelectorChecker::determineLinkMatchType(selector))
 1870 , m_regionStyleRule(regionStyleRule)
18301871{
18311872 SelectorChecker::collectIdentifierHashes(m_selector, m_descendantSelectorIdentifierHashes, maximumIdentifierCount);
18321873}
18331874
1834 RuleSet::RuleSet()
 1875RuleSet::RuleSet(bool regionStyleRules)
18351876 : m_ruleCount(0)
18361877 , m_autoShrinkToFitEnabled(true)
 1878 , m_regionStyleRules(regionStyleRules)
18371879{
18381880}
18391881

@@void RuleSet::addToRuleSet(AtomicStringImpl* key, AtomRuleMap& map,
18551897 rules = new Vector<RuleData>;
18561898 map.set(key, rules);
18571899 }
1858  rules->append(RuleData(rule, sel, m_ruleCount++));
 1900 rules->append(RuleData(rule, sel, m_ruleCount++, m_regionStyleRules));
18591901}
18601902
18611903void RuleSet::addRule(CSSStyleRule* rule, CSSSelector* sel)

@@void CSSStyleSelector::applyDeclarations(bool isImportant, int startIndex, int e
21592201 m_applyPropertyToVisitedLinkStyle = false;
21602202 return;
21612203 }
2162  for (int i = startIndex; i <= endIndex; ++i)
 2204 for (int i = startIndex; i <= endIndex; ++i) {
 2205 m_applyPropertyToRegionStyle = m_matchedDecls[i].regionStyleRule;
21632206 applyDeclaration<applyFirst>(m_matchedDecls[i].styleDeclaration, isImportant, inheritedOnly);
 2207 m_applyPropertyToRegionStyle = false;
 2208 }
21642209}
21652210
21662211unsigned CSSStyleSelector::computeDeclarationHash(MatchedStyleDeclaration* declarations, unsigned size)

@@inline bool isValidVisitedLinkProperty(int id)
24132458 return false;
24142459}
24152460
 2461// http://dev.w3.org/csswg/css3-regions/#the-at-region-style-rule
 2462// FIXME: add incremental support for other region styling properties.
 2463inline bool isValidRegionStyleProperty(int id)
 2464{
 2465 switch (static_cast<CSSPropertyID>(id)) {
 2466 case CSSPropertyBackgroundColor:
 2467 return true;
 2468 default:
 2469 break;
 2470 }
 2471
 2472 return false;
 2473}
 2474
24162475class SVGDisplayPropertyGuard {
24172476 WTF_MAKE_NONCOPYABLE(SVGDisplayPropertyGuard);
24182477public:

@@void CSSStyleSelector::applyProperty(int id, CSSValue *value)
24892548 return;
24902549 }
24912550
 2551 // Filter region style property
 2552 if (applyPropertyToRegionStyle() && !isValidRegionStyleProperty(id))
 2553 return;
 2554
24922555 CSSPropertyID property = static_cast<CSSPropertyID>(id);
24932556
24942557 if (isInherit && m_parentStyle && !m_parentStyle->hasExplicitlyInheritedProperties() && !CSSProperty::isInheritedProperty(property))

Source/WebCore/css/CSSStyleSelector.h

@@class KeyframeList;
6262class KeyframeValue;
6363class MediaQueryEvaluator;
6464class Node;
 65class RenderRegion;
6566class RuleData;
6667class RuleSet;
6768class Settings;

@@public:
9899 void pushParent(Element* parent) { m_checker.pushParent(parent); }
99100 void popParent(Element* parent) { m_checker.popParent(parent); }
100101
101  PassRefPtr<RenderStyle> styleForElement(Element*, RenderStyle* parentStyle = 0, bool allowSharing = true, bool resolveForRootDefault = false);
 102 PassRefPtr<RenderStyle> styleForElement(Element*, RenderStyle* parentStyle = 0, bool allowSharing = true, bool resolveForRootDefault = false, RenderRegion* regionForStyling = 0);
102103
103104 void keyframeStylesForAnimation(Element*, const RenderStyle*, KeyframeList&);
104105
105  PassRefPtr<RenderStyle> pseudoStyleForElement(PseudoId, Element*, RenderStyle* parentStyle = 0);
 106 PassRefPtr<RenderStyle> pseudoStyleForElement(PseudoId, Element*, RenderStyle* parentStyle = 0, RenderRegion* regionForStyling = 0);
106107
107108 PassRefPtr<RenderStyle> styleForPage(int pageIndex);
108109

@@public:
122123private:
123124 void initForStyleResolve(Element*, RenderStyle* parentStyle = 0, PseudoId = NOPSEUDO);
124125 void initElement(Element*);
 126 void initForRegionStyling(RenderRegion*);
125127 RenderStyle* locateSharedStyle();
126128 bool matchesRuleSet(RuleSet*);
127129 Node* locateCousinList(Element* parent, unsigned& visitedNodeCount) const;

@@private:
130132
131133 PassRefPtr<RenderStyle> styleForKeyframe(const RenderStyle*, const WebKitCSSKeyframeRule*, KeyframeValue&);
132134
 135 void setRegionForStyling(RenderRegion* region) { m_regionForStyling = region; }
 136 RenderRegion* regionForStyling() const { return m_regionForStyling; }
 137
133138public:
134139 // These methods will give back the set of rules that matched for a given element (or a pseudo-element).
135140 enum CSSRuleFilter {

@@private:
225230 void adjustRenderStyle(RenderStyle* styleToAdjust, RenderStyle* parentStyle, Element*);
226231
227232 void addMatchedRule(const RuleData* rule) { m_matchedRules.append(rule); }
228  void addMatchedDeclaration(CSSMutableStyleDeclaration*, unsigned linkMatchType = SelectorChecker::MatchAll);
 233 void addMatchedDeclaration(CSSMutableStyleDeclaration*, unsigned linkMatchType = SelectorChecker::MatchAll, bool regionStyleRule = false);
229234
230235 struct MatchResult {
231236 MatchResult() : firstUARule(-1), lastUARule(-1), firstAuthorRule(-1), lastAuthorRule(-1), firstUserRule(-1), lastUserRule(-1), isCacheable(true) { }

@@private:
261266
262267 OwnPtr<RuleSet> m_authorStyle;
263268 OwnPtr<RuleSet> m_userStyle;
 269 OwnPtr<RuleSet> m_regionRules;
264270
265271 Features m_features;
266272

@@public:
283289
284290 bool applyPropertyToRegularStyle() const { return m_applyPropertyToRegularStyle; }
285291 bool applyPropertyToVisitedLinkStyle() const { return m_applyPropertyToVisitedLinkStyle; }
 292 bool applyPropertyToRegionStyle() const { return m_applyPropertyToRegionStyle; }
286293
287294private:
288295 static RenderStyle* s_styleNotYetAvailable;

@@private:
329336
330337 void loadPendingImages();
331338
 339 bool isRegionStyleValidRule(CSSStyleRule*) const;
 340
332341 struct MatchedStyleDeclaration {
333342 MatchedStyleDeclaration();
334343 CSSMutableStyleDeclaration* styleDeclaration;
335344 unsigned linkMatchType;
 345 bool regionStyleRule;
336346 };
337347 static unsigned computeDeclarationHash(MatchedStyleDeclaration*, unsigned size);
338348 const RenderStyle* findFromMatchedDeclarationCache(unsigned hash, const MatchResult&);

@@private:
372382 RenderStyle* m_rootElementStyle;
373383 Element* m_element;
374384 StyledElement* m_styledElement;
 385 RenderRegion* m_regionForStyling;
375386 EInsideLink m_elementLinkState;
376387 ContainerNode* m_parentNode;
377388 CSSValue* m_lineHeightValue;

@@private:
385396
386397 bool m_applyPropertyToRegularStyle;
387398 bool m_applyPropertyToVisitedLinkStyle;
 399 bool m_applyPropertyToRegionStyle;
388400 const CSSStyleApplyProperty& m_applyProperty;
389401
390402 friend class CSSStyleApplyProperty;

Source/WebCore/rendering/RenderBox.h

@@enum OverlayScrollbarSizeRelevancy { IgnoreOverlayScrollbarSize, IncludeOverlayS
3939
4040class RenderBox : public RenderBoxModelObject {
4141public:
 42 friend class RenderBoxRegionInfo;
 43
4244 RenderBox(Node*);
4345 virtual ~RenderBox();
4446

Source/WebCore/rendering/RenderBoxRegionInfo.cpp

 1/*
 2 * Copyright 2011 Adobe Systems Incorporated. All Rights Reserved.
 3 *
 4 * Redistribution and use in source and binary forms, with or without
 5 * modification, are permitted provided that the following conditions
 6 * are met:
 7 *
 8 * 1. Redistributions of source code must retain the above
 9 * copyright notice, this list of conditions and the following
 10 * disclaimer.
 11 * 2. Redistributions in binary form must reproduce the above
 12 * copyright notice, this list of conditions and the following
 13 * disclaimer in the documentation and/or other materials
 14 * provided with the distribution.
 15 *
 16 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER “AS IS” AND ANY
 17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
 18 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
 19 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE
 20 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
 21 * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
 22 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
 23 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
 24 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
 25 * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
 26 * THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
 27 * SUCH DAMAGE.
 28 */
 29
 30#include "config.h"
 31
 32#include "RenderBoxRegionInfo.h"
 33
 34#include "CSSStyleSelector.h"
 35#include "RenderBox.h"
 36#include "RenderRegion.h"
 37#include "RenderView.h"
 38
 39namespace WebCore {
 40
 41void RenderBoxRegionInfo::setRegionStyle(PassRefPtr<RenderStyle> regionStyle)
 42{
 43 if (m_regionStyle == regionStyle)
 44 return;
 45 m_regionStyle = regionStyle;
 46}
 47
 48void RenderBoxRegionInfo::computeStyleInRegion(const RenderBox* box, RenderRegion* region)
 49{
 50 ASSERT(region);
 51 ASSERT(box);
 52 ASSERT(box->view());
 53 ASSERT(box->view()->document());
 54
 55 Element* element = static_cast<Element*>(box->node());
 56 if (element) {
 57 setRegionStyle(box->view()->document()->styleSelector()->styleForElement(element, 0, false, false, region));
 58 // FIXME: assume for now that a box with region styling always has box decorations.
 59 (const_cast<RenderBox*>(box))->setHasBoxDecorations(true);
 60 }
 61}
 62
 63} // namespace WebCore

Source/WebCore/rendering/RenderBoxRegionInfo.h

2727#ifndef RenderBoxRegionInfo_h
2828#define RenderBoxRegionInfo_h
2929
 30#include "RenderStyle.h"
 31#include <wtf/RefPtr.h>
 32
3033namespace WebCore {
3134
 35class RenderBox;
 36class RenderRegion;
 37
3238class RenderBoxRegionInfo {
3339public:
3440 RenderBoxRegionInfo(LayoutUnit logicalLeft, LayoutUnit logicalWidth, bool isShifted)
3541 : m_logicalLeft(logicalLeft)
3642 , m_logicalWidth(logicalWidth)
3743 , m_isShifted(isShifted)
 44 , m_regionStyle(0)
3845 { }
3946
4047 LayoutUnit logicalLeft() const { return m_logicalLeft; }

@@public:
4451
4552 bool isShifted() const { return m_isShifted; }
4653
 54 RenderStyle* regionStyle() const { return m_regionStyle.get(); }
 55 void setRegionStyle(PassRefPtr<RenderStyle>);
 56 void computeStyleInRegion(const RenderBox*, RenderRegion*);
 57
4758private:
4859 LayoutUnit m_logicalLeft;
4960 LayoutUnit m_logicalWidth;
5061 bool m_isShifted;
 62 RefPtr<RenderStyle> m_regionStyle;
5163};
5264
5365} // namespace WebCore

Source/WebCore/rendering/RenderFlowThread.cpp

@@void RenderFlowThread::setRegionRangeForBox(const RenderBox* box, LayoutUnit off
747747 RenderRegionRange* range = m_regionRangeMap.get(box);
748748 if (range) {
749749 // If nothing changed, just bail.
750  if (range->startRegion() == startRegion && range->endRegion() == endRegion)
 750 if (range->startRegion() == startRegion && range->endRegion() == endRegion) {
 751 view()->setCurrentRenderRegion(startRegion);
751752 return;
 753 }
752754
753755 // Delete any info that we find before our new startRegion and after our new endRegion.
754756 for (RenderRegionList::iterator iter = m_regionList.begin(); iter != m_regionList.end(); ++iter) {

@@void RenderFlowThread::setRegionRangeForBox(const RenderBox* box, LayoutUnit off
763765 if (region == range->endRegion())
764766 break;
765767 }
766 
 768
 769 view()->setCurrentRenderRegion(startRegion);
767770 range->setRange(startRegion, endRegion);
768771 return;
769772 }
 773
 774 view()->setCurrentRenderRegion(startRegion);
770775 range = new RenderRegionRange(startRegion, endRegion);
771776 m_regionRangeMap.set(box, range);
772777}

Source/WebCore/rendering/RenderLayer.cpp

@@bool RenderLayer::scroll(ScrollDirection direction, ScrollGranularity granularit
25452545void RenderLayer::paint(GraphicsContext* p, const LayoutRect& damageRect, PaintBehavior paintBehavior, RenderObject *paintingRoot,
25462546 RenderRegion* region, PaintLayerFlags paintFlags)
25472547{
 2548 renderer()->view()->setCurrentRenderRegion(region);
 2549
25482550 OverlapTestRequestMap overlapTestRequests;
25492551 paintLayer(this, p, damageRect, paintBehavior, paintingRoot, region, &overlapTestRequests, paintFlags);
25502552 OverlapTestRequestMap::iterator end = overlapTestRequests.end();

Source/WebCore/rendering/RenderObject.cpp

4242#include "HitTestResult.h"
4343#include "Page.h"
4444#include "RenderArena.h"
 45#include "RenderBoxRegionInfo.h"
4546#include "RenderCounter.h"
4647#include "RenderDeprecatedFlexibleBox.h"
4748#include "RenderFlexibleBox.h"

@@StyleDifference RenderObject::adjustStyleDifference(StyleDifference diff, unsign
16901691 return diff;
16911692}
16921693
 1694RenderStyle* RenderObject::style() const
 1695{
 1696 if (view() && view()->currentRenderRegion() && view()->currentRenderRegion()->hasCustomRegionStyle() && isBox() && !isAnonymous()) {
 1697 const RenderBox* box = toRenderBox(this);
 1698 RenderBoxRegionInfo* info = view()->currentRenderRegion()->renderBoxRegionInfo(box);
 1699 if (info) {
 1700 if (!info->regionStyle())
 1701 info->computeStyleInRegion(box, view()->currentRenderRegion());
 1702 return info->regionStyle();
 1703 }
 1704 }
 1705
 1706 return m_style.get();
 1707}
 1708
16931709void RenderObject::setStyle(PassRefPtr<RenderStyle> style)
16941710{
16951711 if (m_style == style) {

Source/WebCore/rendering/RenderObject.h

@@public:
660660 virtual LayoutUnit minPreferredLogicalWidth() const { return 0; }
661661 virtual LayoutUnit maxPreferredLogicalWidth() const { return 0; }
662662
663  RenderStyle* style() const { return m_style.get(); }
 663 RenderStyle* style() const;
664664 RenderStyle* firstLineStyle() const { return document()->usesFirstLineRules() ? firstLineStyleSlowCase() : style(); }
665665 RenderStyle* style(bool firstLine) const { return firstLine ? firstLineStyle() : style(); }
666666

Source/WebCore/rendering/RenderView.cpp

@@RenderView::RenderView(Node* node, FrameView* view)
5757 , m_layoutState(0)
5858 , m_layoutStateDisableCount(0)
5959 , m_currentRenderFlowThread(0)
 60 , m_currentRenderRegion(0)
6061{
6162 // Clear our anonymous bit, set because RenderObject assumes
6263 // any renderer with document as the node is anonymous.

Source/WebCore/rendering/RenderView.h

3131namespace WebCore {
3232
3333class RenderFlowThread;
 34class RenderRegion;
3435class RenderWidget;
3536
3637#if USE(ACCELERATED_COMPOSITING)

@@public:
185186 RenderFlowThread* currentRenderFlowThread() const { return m_currentRenderFlowThread; }
186187 void setCurrentRenderFlowThread(RenderFlowThread* flowThread) { m_currentRenderFlowThread = flowThread; }
187188
 189 RenderRegion* currentRenderRegion() const { return m_currentRenderRegion; }
 190 void setCurrentRenderRegion(RenderRegion* region) { m_currentRenderRegion = region; }
 191
188192 void styleDidChange(StyleDifference, const RenderStyle* oldStyle);
189193
190194protected:

@@private:
269273#endif
270274 OwnPtr<RenderFlowThreadList> m_renderFlowThreadList;
271275 RenderFlowThread* m_currentRenderFlowThread;
 276 RenderRegion* m_currentRenderRegion;
272277};
273278
274279inline RenderView* toRenderView(RenderObject* object)