Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1358)

Unified Diff: Source/core/rendering/style/RenderStyle.h

Issue 43873004: Relayout RenderObjects with viewport-percentage CSS properties when viewport size changes (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 7 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: Source/core/rendering/style/RenderStyle.h
diff --git a/Source/core/rendering/style/RenderStyle.h b/Source/core/rendering/style/RenderStyle.h
index 843774d22134090d0ff993aa7fd8b8b6cd65a9ed..a3cac9c9b7368809202886651b61a97b0bb32338 100644
--- a/Source/core/rendering/style/RenderStyle.h
+++ b/Source/core/rendering/style/RenderStyle.h
@@ -77,8 +77,12 @@
template<typename T, typename U> inline bool compareEqual(const T& t, const U& u) { return t == static_cast<T>(u); }
#define SET_VAR(group, variable, value) \
- if (!compareEqual(group->variable, value)) \
- group.access()->variable = value
+ do { \
+ if (!compareEqual(group->variable, value)) { \
+ group.access()->variable = value; \
+ updateMayHaveViewportPercentage(value); \
leviw_travelin_and_unemployed 2013/10/25 20:30:35 I'm a little worried that this could be expensive,
+ } \
+ } while (0)
#define SET_BORDERVALUE_COLOR(group, variable, value) \
if (!compareEqual(group->variable.color(), value)) \
@@ -122,6 +126,24 @@ class RenderStyle: public RefCounted<RenderStyle> {
friend class CachedUAStyle; // Saves Border/Background information for later comparison.
protected:
+ // Called from SET_VAR macro and setters with Length* arguments not using SET_VAR.
+ void updateMayHaveViewportPercentage(Length t)
+ {
+ if (t.isViewportPercentage())
+ inherited_flags.m_mayHaveViewportPercentageProperty = true;
+ }
+ void updateMayHaveViewportPercentage(LengthSize t)
+ {
+ if (t.width().isViewportPercentage() || t.height().isViewportPercentage())
+ inherited_flags.m_mayHaveViewportPercentageProperty = true;
+ }
+ void updateMayHaveViewportPercentage(LengthBox t)
+ {
+ if (t.top().isViewportPercentage() || t.left().isViewportPercentage() || t.right().isViewportPercentage() || t.bottom().isViewportPercentage())
+ inherited_flags.m_mayHaveViewportPercentageProperty = true;
+ }
+ template <typename T> void updateMayHaveViewportPercentage(T) { }
+
// non-inherited attributes
DataRef<StyleBoxData> m_box;
DataRef<StyleVisualData> visual;
@@ -161,7 +183,8 @@ protected:
&& (m_printColorAdjust == other.m_printColorAdjust)
&& (_pointerEvents == other._pointerEvents)
&& (_insideLink == other._insideLink)
- && (m_writingMode == other.m_writingMode);
+ && (m_writingMode == other.m_writingMode)
+ && (m_mayHaveViewportPercentageProperty == other.m_mayHaveViewportPercentageProperty);
}
bool operator!=(const InheritedFlags& other) const { return !(*this == other); }
@@ -191,6 +214,13 @@ protected:
// CSS Text Layout Module Level 3: Vertical writing support
unsigned m_writingMode : 2; // WritingMode
// 45 bits
+
+ // Not a CSS property. It's set to true when any property is set to a viewport-percentage length value.
+ // As a performance trade-off, it's not strictly accurate. It may be still true when there is no longer
+ // viewport-percentage properties. It's inherited to make sure it's set whenever there is possibility
+ // of viewport-percentage properties.
+ unsigned m_mayHaveViewportPercentageProperty : 1; // bool
+ // 46 bits
} inherited_flags;
// don't inherit
@@ -291,6 +321,7 @@ protected:
inherited_flags._pointerEvents = initialPointerEvents();
inherited_flags._insideLink = NotInsideLink;
inherited_flags.m_writingMode = initialWritingMode();
+ inherited_flags.m_mayHaveViewportPercentageProperty = false;
noninherited_flags._effectiveDisplay = noninherited_flags._originalDisplay = initialDisplay();
noninherited_flags._overflowX = initialOverflowX();
@@ -416,6 +447,8 @@ public:
void setHasPseudoStyle(PseudoId pseudo);
bool hasUniquePseudoStyle() const;
+ bool mayHaveViewportPercentageProperty() const { return inherited_flags.m_mayHaveViewportPercentageProperty; }
+
// attribute getter methods
EDisplay display() const { return static_cast<EDisplay>(noninherited_flags._effectiveDisplay); }
@@ -1043,7 +1076,13 @@ public:
void setClipRight(Length v) { SET_VAR(visual, clip.m_right, v); }
void setClipTop(Length v) { SET_VAR(visual, clip.m_top, v); }
void setClipBottom(Length v) { SET_VAR(visual, clip.m_bottom, v); }
- void setClip(Length top, Length right, Length bottom, Length left);
+ void setClip(Length top, Length right, Length bottom, Length left)
+ {
+ setClipTop(top);
+ setClipRight(right);
+ setClipBottom(bottom);
+ setClipLeft(left);
esprehn 2013/10/25 22:25:51 Can you put these at the bottom of the file (and t
+ }
void setClip(LengthBox box) { SET_VAR(visual, clip, box); }
void setUnicodeBidi(EUnicodeBidi b) { noninherited_flags._unicodeBidi = b; }
@@ -1117,6 +1156,7 @@ public:
void setMaskBoxImageSlices(LengthBox slices)
{
rareNonInheritedData.access()->m_maskBoxImage.setImageSlices(slices);
+ updateMayHaveViewportPercentage(slices);
}
void setMaskBoxImageSlicesFill(bool fill)
{
@@ -1125,10 +1165,12 @@ public:
void setMaskBoxImageWidth(LengthBox slices)
{
rareNonInheritedData.access()->m_maskBoxImage.setBorderSlices(slices);
+ updateMayHaveViewportPercentage(slices);
}
void setMaskBoxImageOutset(LengthBox outset)
{
rareNonInheritedData.access()->m_maskBoxImage.setOutset(outset);
+ updateMayHaveViewportPercentage(outset);
}
void setMaskXPosition(Length length) { SET_VAR(rareNonInheritedData, m_mask.m_xPosition, length); }
void setMaskYPosition(Length length) { SET_VAR(rareNonInheritedData, m_mask.m_yPosition, length); }

Powered by Google App Engine
This is Rietveld 408576698