From 3681ee88afffd9274bf948db205b5937378815d7 Mon Sep 17 00:00:00 2001 From: "roc+%cs.cmu.edu" Date: Mon, 30 Sep 2002 11:56:37 +0000 Subject: [PATCH] Bug 113083. Concentrate view setup code into a few shared functions in nsContainerFrame. Only change style-dependent view properties after style change, not during reflow, in response to nsChangeHint_SyncFrameView. Change 'clip' to only do SyncFrameView, not reflow. r=dbaron,sr=kin --- content/shared/public/nsCSSPropList.h | 388 ++++++------- content/shared/public/nsChangeHint.h | 5 + content/shared/src/nsCSSProps.cpp | 2 +- content/shared/src/nsStyleStruct.cpp | 37 +- layout/base/nsCSSFrameConstructor.cpp | 170 ++---- layout/base/nsChangeHint.h | 5 + layout/doc/adding-style-props.html | 7 +- layout/forms/nsImageControlFrame.cpp | 12 +- layout/generic/nsContainerFrame.cpp | 532 +++++++++++------- layout/generic/nsContainerFrame.h | 37 +- layout/generic/nsHTMLContainerFrame.cpp | 313 +++-------- layout/html/base/src/nsContainerFrame.cpp | 532 +++++++++++------- layout/html/base/src/nsContainerFrame.h | 37 +- layout/html/base/src/nsHTMLContainerFrame.cpp | 313 +++-------- layout/html/base/src/nsScrollFrame.cpp | 38 +- layout/html/base/src/nsScrollFrame.h | 2 + layout/html/forms/src/nsImageControlFrame.cpp | 12 +- .../html/style/src/nsCSSFrameConstructor.cpp | 170 ++---- layout/style/nsCSSPropList.h | 388 ++++++------- layout/style/nsCSSProps.cpp | 2 +- layout/style/nsStyleStruct.cpp | 37 +- layout/xul/base/src/nsBoxFrame.cpp | 10 +- layout/xul/base/src/nsScrollBoxFrame.cpp | 54 +- view/src/nsViewManager.cpp | 66 ++- 24 files changed, 1482 insertions(+), 1687 deletions(-) diff --git a/content/shared/public/nsCSSPropList.h b/content/shared/public/nsCSSPropList.h index 5615b637c2d..c7cb2ab9a81 100644 --- a/content/shared/public/nsCSSPropList.h +++ b/content/shared/public/nsCSSPropList.h @@ -95,203 +95,203 @@ // support them correctly the old constants need to be renamed and // new ones should be entered. -CSS_PROP(-moz-appearance, appearance, MozAppearance, REFLOW) -CSS_PROP(-moz-border-radius, _moz_border_radius, MozBorderRadius, VISUAL) -CSS_PROP(-moz-border-radius-topleft, _moz_border_radius_topLeft, MozBorderRadiusTopleft, VISUAL) -CSS_PROP(-moz-border-radius-topright, _moz_border_radius_topRight, MozBorderRadiusTopright, VISUAL) -CSS_PROP(-moz-border-radius-bottomleft, _moz_border_radius_bottomLeft, MozBorderRadiusBottomleft, VISUAL) -CSS_PROP(-moz-border-radius-bottomright, _moz_border_radius_bottomRight, MozBorderRadiusBottomright, VISUAL) -CSS_PROP(-moz-outline-radius, _moz_outline_radius, MozOutlineRadius, VISUAL) -CSS_PROP(-moz-outline-radius-topleft, _moz_outline_radius_topLeft, MozOutlineRadiusTopleft, VISUAL) -CSS_PROP(-moz-outline-radius-topright, _moz_outline_radius_topRight, MozOutlineRadiusTopright, VISUAL) -CSS_PROP(-moz-outline-radius-bottomleft, _moz_outline_radius_bottomLeft, MozOutlineRadiusBottomleft, VISUAL) -CSS_PROP(-moz-outline-radius-bottomright, _moz_outline_radius_bottomRight, MozOutlineRadiusBottomright, VISUAL) -CSS_PROP(azimuth, azimuth, Azimuth, AURAL) -CSS_PROP(background, background, Background, VISUAL) -CSS_PROP(background-attachment, background_attachment, BackgroundAttachment, FRAMECHANGE) -CSS_PROP(background-color, background_color, BackgroundColor, VISUAL) -CSS_PROP(background-image, background_image, BackgroundImage, VISUAL) -CSS_PROP(background-position, background_position, BackgroundPosition, VISUAL) -CSS_PROP(background-repeat, background_repeat, BackgroundRepeat, VISUAL) -CSS_PROP_INTERNAL(-x-background-x-position, background_x_position, BackgroundXPosition, VISUAL) // XXX bug 3935 -CSS_PROP_INTERNAL(-x-background-y-position, background_y_position, BackgroundYPosition, VISUAL) // XXX bug 3935 -CSS_PROP(-moz-binding, binding, MozBinding, FRAMECHANGE) // XXX bug 3935 -CSS_PROP(border, border, Border, REFLOW) -CSS_PROP(border-bottom, border_bottom, BorderBottom, REFLOW) -CSS_PROP(border-bottom-color, border_bottom_color, BorderBottomColor, VISUAL) -CSS_PROP(-moz-border-bottom-colors, border_bottom_colors, MozBorderBottomColors, VISUAL) -CSS_PROP(border-bottom-style, border_bottom_style, BorderBottomStyle, REFLOW) // on/off will need reflow -CSS_PROP(border-bottom-width, border_bottom_width, BorderBottomWidth, REFLOW) -CSS_PROP(border-collapse, border_collapse, BorderCollapse, FRAMECHANGE) -CSS_PROP(border-color, border_color, BorderColor, VISUAL) -CSS_PROP(border-left, border_left, BorderLeft, REFLOW) -CSS_PROP(border-left-color, border_left_color, BorderLeftColor, VISUAL) -CSS_PROP(-moz-border-left-colors, border_left_colors, MozBorderLeftColors, VISUAL) -CSS_PROP(border-left-style, border_left_style, BorderLeftStyle, REFLOW) // on/off will need reflow -CSS_PROP(border-left-width, border_left_width, BorderLeftWidth, REFLOW) -CSS_PROP(border-right, border_right, BorderRight, REFLOW) -CSS_PROP(border-right-color, border_right_color, BorderRightColor, VISUAL) -CSS_PROP(-moz-border-right-colors, border_right_colors, MozBorderRightColors, VISUAL) -CSS_PROP(border-right-style, border_right_style, BorderRightStyle, REFLOW) // on/off will need reflow -CSS_PROP(border-right-width, border_right_width, BorderRightWidth, REFLOW) -CSS_PROP(border-spacing, border_spacing, BorderSpacing, REFLOW) -CSS_PROP(border-style, border_style, BorderStyle, REFLOW) // on/off will need reflow -CSS_PROP(border-top, border_top, BorderTop, REFLOW) -CSS_PROP(border-top-color, border_top_color, BorderTopColor, VISUAL) -CSS_PROP(-moz-border-top-colors, border_top_colors, MozBorderTopColors, VISUAL) -CSS_PROP(border-top-style, border_top_style, BorderTopStyle, REFLOW) // on/off will need reflow -CSS_PROP(border-top-width, border_top_width, BorderTopWidth, REFLOW) -CSS_PROP(border-width, border_width, BorderWidth, REFLOW) -CSS_PROP_INTERNAL(-x-border-x-spacing, border_x_spacing, BorderXSpacing, REFLOW) // XXX bug 3935 -CSS_PROP_INTERNAL(-x-border-y-spacing, border_y_spacing, BorderYSpacing, REFLOW) // XXX bug 3935 -CSS_PROP(bottom, bottom, Bottom, REFLOW) -CSS_PROP(-moz-box-align, box_align, MozBoxAlign, REFLOW) // XXX bug 3935 -CSS_PROP(-moz-box-direction, box_direction, MozBoxDirection, REFLOW) // XXX bug 3935 -CSS_PROP(-moz-box-flex, box_flex, MozBoxFlex, REFLOW) // XXX bug 3935 -CSS_PROP(-moz-box-flex-group, box_flex_group, MozBoxFlexGroup, REFLOW) // XXX bug 3935 -CSS_PROP(-moz-box-orient, box_orient, MozBoxOrient, REFLOW) // XXX bug 3935 -CSS_PROP(-moz-box-pack, box_pack, MozBoxPack, REFLOW) // XXX bug 3935 -CSS_PROP(-moz-box-sizing, box_sizing, MozBoxSizing, REFLOW) // XXX bug 3935 -CSS_PROP(-moz-box-ordinal-group, box_ordinal_group, MozBoxOrdinalGroup, FRAMECHANGE) -CSS_PROP(caption-side, caption_side, CaptionSide, REFLOW) -CSS_PROP(clear, clear, Clear, REFLOW) -CSS_PROP(clip, clip, Clip, REFLOW) -CSS_PROP_INTERNAL(-x-clip-bottom, clip_bottom, ClipBottom, REFLOW) // XXX bug 3935 -CSS_PROP_INTERNAL(-x-clip-left, clip_left, ClipLeft, REFLOW) // XXX bug 3935 -CSS_PROP_INTERNAL(-x-clip-right, clip_right, ClipRight, REFLOW) // XXX bug 3935 -CSS_PROP_INTERNAL(-x-clip-top, clip_top, ClipTop, REFLOW) // XXX bug 3935 -CSS_PROP(color, color, Color, VISUAL) -CSS_PROP(content, content, Content, FRAMECHANGE) -CSS_PROP(counter-increment, counter_increment, CounterIncrement, REFLOW) -CSS_PROP(counter-reset, counter_reset, CounterReset, REFLOW) -CSS_PROP(-moz-counter-increment, _moz_counter_increment, MozCounterIncrement, REFLOW) // XXX bug 137285 -CSS_PROP(-moz-counter-reset, _moz_counter_reset, MozCounterReset, REFLOW) // XXX bug 137285 -CSS_PROP(cue, cue, Cue, AURAL) -CSS_PROP(cue-after, cue_after, CueAfter, AURAL) -CSS_PROP(cue-before, cue_before, CueBefore, AURAL) -CSS_PROP(cursor, cursor, Cursor, VISUAL) -CSS_PROP(direction, direction, Direction, REFLOW) -CSS_PROP(display, display, Display, FRAMECHANGE) -CSS_PROP(elevation, elevation, Elevation, AURAL) -CSS_PROP(empty-cells, empty_cells, EmptyCells, VISUAL) -CSS_PROP(float, float, CssFloat, FRAMECHANGE) -CSS_PROP(-moz-float-edge, float_edge, MozFloatEdge, REFLOW) // XXX bug 3935 -CSS_PROP(font, font, Font, REFLOW) -CSS_PROP(font-family, font_family, FontFamily, REFLOW) -CSS_PROP(font-size, font_size, FontSize, REFLOW) -CSS_PROP(font-size-adjust, font_size_adjust, FontSizeAdjust, REFLOW) -CSS_PROP(font-stretch, font_stretch, FontStretch, REFLOW) -CSS_PROP(font-style, font_style, FontStyle, REFLOW) -CSS_PROP(font-variant, font_variant, FontVariant, REFLOW) -CSS_PROP(font-weight, font_weight, FontWeight, REFLOW) -CSS_PROP(-moz-force-broken-image-icon, force_broken_image_icon, MozForceBrokenImageIcon, FRAMECHANGE) // bug 58646 -CSS_PROP(height, height, Height, REFLOW) -CSS_PROP(-moz-image-region, image_region, MozImageRegion, REFLOW) -CSS_PROP_INTERNAL(-x-image-region-bottom, image_region_bottom, MozImageRegionBottom, REFLOW) -CSS_PROP_INTERNAL(-x-image-region-left, image_region_left, MozImageRegionLeft, REFLOW) -CSS_PROP_INTERNAL(-x-image-region-right, image_region_right, MozImageRegionRight, REFLOW) -CSS_PROP_INTERNAL(-x-image-region-top, image_region_top, MozImageRegionTop, REFLOW) -CSS_PROP(-moz-key-equivalent, key_equivalent, MozKeyEquivalent, CONTENT) // This will need some other notification, but what? // XXX bug 3935 -CSS_PROP(left, left, Left, REFLOW) -CSS_PROP(letter-spacing, letter_spacing, LetterSpacing, REFLOW) -CSS_PROP(line-height, line_height, LineHeight, REFLOW) -CSS_PROP(list-style, list_style, ListStyle, REFLOW) -CSS_PROP(list-style-image, list_style_image, ListStyleImage, REFLOW) -CSS_PROP(list-style-position, list_style_position, ListStylePosition, REFLOW) -CSS_PROP(list-style-type, list_style_type, ListStyleType, REFLOW) -CSS_PROP(margin, margin, Margin, REFLOW) -CSS_PROP(margin-bottom, margin_bottom, MarginBottom, REFLOW) -CSS_PROP(margin-left, margin_left, MarginLeft, REFLOW) -CSS_PROP(margin-right, margin_right, MarginRight, REFLOW) -CSS_PROP(margin-top, margin_top, MarginTop, REFLOW) -CSS_PROP(marker-offset, marker_offset, MarkerOffset, REFLOW) -CSS_PROP(marks, marks, Marks, VISUAL) -CSS_PROP(max-height, max_height, MaxHeight, REFLOW) -CSS_PROP(max-width, max_width, MaxWidth, REFLOW) -CSS_PROP(min-height, min_height, MinHeight, REFLOW) -CSS_PROP(min-width, min_width, MinWidth, REFLOW) -CSS_PROP(-moz-opacity, opacity, MozOpacity, FRAMECHANGE) // XXX bug 3935 -CSS_PROP(orphans, orphans, Orphans, REFLOW) -CSS_PROP(outline, outline, Outline, VISUAL) -CSS_PROP(outline, outline_color, OutlineColor, VISUAL) -CSS_PROP(outline, outline_style, OutlineStyle, VISUAL) -CSS_PROP(outline, outline_width, OutlineWidth, VISUAL) -CSS_PROP(-moz-outline, _moz_outline, MozOutline, VISUAL) // XXX This is temporary fix for nsbeta3+ Bug 48973, turning outline into -moz-outline XXX bug 48973 -CSS_PROP(-moz-outline-color, _moz_outline_color, MozOutlineColor, VISUAL) // XXX bug 48973 -CSS_PROP(-moz-outline-style, _moz_outline_style, MozOutlineStyle, VISUAL) // XXX bug 48973 -CSS_PROP(-moz-outline-width, _moz_outline_width, MozOutlineWidth, VISUAL) // XXX bug 48973 -CSS_PROP(overflow, overflow, Overflow, FRAMECHANGE) -CSS_PROP(padding, padding, Padding, REFLOW) -CSS_PROP(padding-bottom, padding_bottom, PaddingBottom, REFLOW) -CSS_PROP(padding-left, padding_left, PaddingLeft, REFLOW) -CSS_PROP(padding-right, padding_right, PaddingRight, REFLOW) -CSS_PROP(padding-top, padding_top, PaddingTop, REFLOW) -CSS_PROP(page, page, Page, REFLOW) -CSS_PROP(page-break-after, page_break_after, PageBreakAfter, REFLOW) -CSS_PROP(page-break-before, page_break_before, PageBreakBefore, REFLOW) -CSS_PROP(page-break-inside, page_break_inside, PageBreakInside, REFLOW) -CSS_PROP(pause, pause, Pause, AURAL) -CSS_PROP(pause-after, pause_after, PauseAfter, AURAL) -CSS_PROP(pause-before, pause_before, PauseBefore, AURAL) -CSS_PROP(pitch, pitch, Pitch, AURAL) -CSS_PROP(pitch-range, pitch_range, PitchRange, AURAL) -CSS_PROP(play-during, play_during, PlayDuring, AURAL) -CSS_PROP_INTERNAL(-x-play-during-flags, play_during_flags, PlayDuringFlags, AURAL) // XXX why is this here? -CSS_PROP(position, position, Position, FRAMECHANGE) -CSS_PROP(quotes, quotes, Quotes, REFLOW) -CSS_PROP_INTERNAL(-x-quotes-close, quotes_close, QuotesClose, REFLOW) // XXX bug 3935 -CSS_PROP_INTERNAL(-x-quotes-open, quotes_open, QuotesOpen, REFLOW) // XXX bug 3935 -CSS_PROP(-moz-resizer, resizer, MozResizer, FRAMECHANGE) // XXX bug 3935 -CSS_PROP(richness, richness, Richness, AURAL) -CSS_PROP(right, right, Right, REFLOW) -CSS_PROP(size, size, Size, REFLOW) -CSS_PROP_INTERNAL(-x-size-height, size_height, SizeHeight, REFLOW) // XXX bug 3935 -CSS_PROP_INTERNAL(-x-size-width, size_width, SizeWidth, REFLOW) // XXX bug 3935 -CSS_PROP(speak, speak, Speak, AURAL) -CSS_PROP(speak-header, speak_header, SpeakHeader, AURAL) -CSS_PROP(speak-numeral, speak_numeral, SpeakNumeral, AURAL) -CSS_PROP(speak-punctuation, speak_punctuation, SpeakPunctuation, AURAL) -CSS_PROP(speech-rate, speech_rate, SpeechRate, AURAL) -CSS_PROP(stress, stress, Stress, AURAL) -CSS_PROP(table-layout, table_layout, TableLayout, REFLOW) -CSS_PROP(text-align, text_align, TextAlign, REFLOW) -CSS_PROP(text-decoration, text_decoration, TextDecoration, VISUAL) -CSS_PROP(text-indent, text_indent, TextIndent, REFLOW) -CSS_PROP(text-shadow, text_shadow, TextShadow, VISUAL) -CSS_PROP_INTERNAL(-x-text-shadow-color, text_shadow_color, TextShadowColor, VISUAL) // XXX bug 3935 -CSS_PROP_INTERNAL(-x-text-shadow-radius, text_shadow_radius, TextShadowRadius, VISUAL) // XXX bug 3935 -CSS_PROP_INTERNAL(-x-text-shadow-x, text_shadow_x, TextShadowX, VISUAL) // XXX bug 3935 -CSS_PROP_INTERNAL(-x-text-shadow-y, text_shadow_y, TextShadowY, VISUAL) // XXX bug 3935 -CSS_PROP(text-transform, text_transform, TextTransform, REFLOW) -CSS_PROP(top, top, Top, REFLOW) -CSS_PROP(unicode-bidi, unicode_bidi, UnicodeBidi, REFLOW) -CSS_PROP(-moz-user-focus, user_focus, MozUserFocus, CONTENT) // XXX bug 3935 -CSS_PROP(-moz-user-input, user_input, MozUserInput, FRAMECHANGE) // XXX ??? // XXX bug 3935 -CSS_PROP(-moz-user-modify, user_modify, MozUserModify, FRAMECHANGE) // XXX bug 3935 -CSS_PROP(-moz-user-select, user_select, MozUserSelect, CONTENT) // XXX bug 3935 -CSS_PROP(vertical-align, vertical_align, VerticalAlign, REFLOW) -CSS_PROP(visibility, visibility, Visibility, REFLOW) // reflow for collapse -CSS_PROP(voice-family, voice_family, VoiceFamily, AURAL) -CSS_PROP(volume, volume, Volume, AURAL) -CSS_PROP(white-space, white_space, WhiteSpace, REFLOW) -CSS_PROP(widows, widows, Widows, REFLOW) -CSS_PROP(width, width, Width, REFLOW) -CSS_PROP(word-spacing, word_spacing, WordSpacing, REFLOW) -CSS_PROP(z-index, z_index, ZIndex, REFLOW) +CSS_PROP(-moz-appearance, appearance, MozAppearance, NS_STYLE_HINT_REFLOW) +CSS_PROP(-moz-border-radius, _moz_border_radius, MozBorderRadius, NS_STYLE_HINT_VISUAL) +CSS_PROP(-moz-border-radius-topleft, _moz_border_radius_topLeft, MozBorderRadiusTopleft, NS_STYLE_HINT_VISUAL) +CSS_PROP(-moz-border-radius-topright, _moz_border_radius_topRight, MozBorderRadiusTopright, NS_STYLE_HINT_VISUAL) +CSS_PROP(-moz-border-radius-bottomleft, _moz_border_radius_bottomLeft, MozBorderRadiusBottomleft, NS_STYLE_HINT_VISUAL) +CSS_PROP(-moz-border-radius-bottomright, _moz_border_radius_bottomRight, MozBorderRadiusBottomright, NS_STYLE_HINT_VISUAL) +CSS_PROP(-moz-outline-radius, _moz_outline_radius, MozOutlineRadius, NS_STYLE_HINT_VISUAL) +CSS_PROP(-moz-outline-radius-topleft, _moz_outline_radius_topLeft, MozOutlineRadiusTopleft, NS_STYLE_HINT_VISUAL) +CSS_PROP(-moz-outline-radius-topright, _moz_outline_radius_topRight, MozOutlineRadiusTopright, NS_STYLE_HINT_VISUAL) +CSS_PROP(-moz-outline-radius-bottomleft, _moz_outline_radius_bottomLeft, MozOutlineRadiusBottomleft, NS_STYLE_HINT_VISUAL) +CSS_PROP(-moz-outline-radius-bottomright, _moz_outline_radius_bottomRight, MozOutlineRadiusBottomright, NS_STYLE_HINT_VISUAL) +CSS_PROP(azimuth, azimuth, Azimuth, NS_STYLE_HINT_AURAL) +CSS_PROP(background, background, Background, NS_STYLE_HINT_VISUAL) +CSS_PROP(background-attachment, background_attachment, BackgroundAttachment, NS_STYLE_HINT_FRAMECHANGE) +CSS_PROP(background-color, background_color, BackgroundColor, NS_STYLE_HINT_VISUAL) +CSS_PROP(background-image, background_image, BackgroundImage, NS_STYLE_HINT_VISUAL) +CSS_PROP(background-position, background_position, BackgroundPosition, NS_STYLE_HINT_VISUAL) +CSS_PROP(background-repeat, background_repeat, BackgroundRepeat, NS_STYLE_HINT_VISUAL) +CSS_PROP_INTERNAL(-x-background-x-position, background_x_position, BackgroundXPosition, NS_STYLE_HINT_VISUAL) // XXX bug 3935 +CSS_PROP_INTERNAL(-x-background-y-position, background_y_position, BackgroundYPosition, NS_STYLE_HINT_VISUAL) // XXX bug 3935 +CSS_PROP(-moz-binding, binding, MozBinding, NS_STYLE_HINT_FRAMECHANGE) // XXX bug 3935 +CSS_PROP(border, border, Border, NS_STYLE_HINT_REFLOW) +CSS_PROP(border-bottom, border_bottom, BorderBottom, NS_STYLE_HINT_REFLOW) +CSS_PROP(border-bottom-color, border_bottom_color, BorderBottomColor, NS_STYLE_HINT_VISUAL) +CSS_PROP(-moz-border-bottom-colors, border_bottom_colors, MozBorderBottomColors, NS_STYLE_HINT_VISUAL) +CSS_PROP(border-bottom-style, border_bottom_style, BorderBottomStyle, NS_STYLE_HINT_REFLOW) // on/off will need reflow +CSS_PROP(border-bottom-width, border_bottom_width, BorderBottomWidth, NS_STYLE_HINT_REFLOW) +CSS_PROP(border-collapse, border_collapse, BorderCollapse, NS_STYLE_HINT_FRAMECHANGE) +CSS_PROP(border-color, border_color, BorderColor, NS_STYLE_HINT_VISUAL) +CSS_PROP(border-left, border_left, BorderLeft, NS_STYLE_HINT_REFLOW) +CSS_PROP(border-left-color, border_left_color, BorderLeftColor, NS_STYLE_HINT_VISUAL) +CSS_PROP(-moz-border-left-colors, border_left_colors, MozBorderLeftColors, NS_STYLE_HINT_VISUAL) +CSS_PROP(border-left-style, border_left_style, BorderLeftStyle, NS_STYLE_HINT_REFLOW) // on/off will need reflow +CSS_PROP(border-left-width, border_left_width, BorderLeftWidth, NS_STYLE_HINT_REFLOW) +CSS_PROP(border-right, border_right, BorderRight, NS_STYLE_HINT_REFLOW) +CSS_PROP(border-right-color, border_right_color, BorderRightColor, NS_STYLE_HINT_VISUAL) +CSS_PROP(-moz-border-right-colors, border_right_colors, MozBorderRightColors, NS_STYLE_HINT_VISUAL) +CSS_PROP(border-right-style, border_right_style, BorderRightStyle, NS_STYLE_HINT_REFLOW) // on/off will need reflow +CSS_PROP(border-right-width, border_right_width, BorderRightWidth, NS_STYLE_HINT_REFLOW) +CSS_PROP(border-spacing, border_spacing, BorderSpacing, NS_STYLE_HINT_REFLOW) +CSS_PROP(border-style, border_style, BorderStyle, NS_STYLE_HINT_REFLOW) // on/off will need reflow +CSS_PROP(border-top, border_top, BorderTop, NS_STYLE_HINT_REFLOW) +CSS_PROP(border-top-color, border_top_color, BorderTopColor, NS_STYLE_HINT_VISUAL) +CSS_PROP(-moz-border-top-colors, border_top_colors, MozBorderTopColors, NS_STYLE_HINT_VISUAL) +CSS_PROP(border-top-style, border_top_style, BorderTopStyle, NS_STYLE_HINT_REFLOW) // on/off will need reflow +CSS_PROP(border-top-width, border_top_width, BorderTopWidth, NS_STYLE_HINT_REFLOW) +CSS_PROP(border-width, border_width, BorderWidth, NS_STYLE_HINT_REFLOW) +CSS_PROP_INTERNAL(-x-border-x-spacing, border_x_spacing, BorderXSpacing, NS_STYLE_HINT_REFLOW) // XXX bug 3935 +CSS_PROP_INTERNAL(-x-border-y-spacing, border_y_spacing, BorderYSpacing, NS_STYLE_HINT_REFLOW) // XXX bug 3935 +CSS_PROP(bottom, bottom, Bottom, NS_STYLE_HINT_REFLOW) +CSS_PROP(-moz-box-align, box_align, MozBoxAlign, NS_STYLE_HINT_REFLOW) // XXX bug 3935 +CSS_PROP(-moz-box-direction, box_direction, MozBoxDirection, NS_STYLE_HINT_REFLOW) // XXX bug 3935 +CSS_PROP(-moz-box-flex, box_flex, MozBoxFlex, NS_STYLE_HINT_REFLOW) // XXX bug 3935 +CSS_PROP(-moz-box-flex-group, box_flex_group, MozBoxFlexGroup, NS_STYLE_HINT_REFLOW) // XXX bug 3935 +CSS_PROP(-moz-box-orient, box_orient, MozBoxOrient, NS_STYLE_HINT_REFLOW) // XXX bug 3935 +CSS_PROP(-moz-box-pack, box_pack, MozBoxPack, NS_STYLE_HINT_REFLOW) // XXX bug 3935 +CSS_PROP(-moz-box-sizing, box_sizing, MozBoxSizing, NS_STYLE_HINT_REFLOW) // XXX bug 3935 +CSS_PROP(-moz-box-ordinal-group, box_ordinal_group, MozBoxOrdinalGroup, NS_STYLE_HINT_FRAMECHANGE) +CSS_PROP(caption-side, caption_side, CaptionSide, NS_STYLE_HINT_REFLOW) +CSS_PROP(clear, clear, Clear, NS_STYLE_HINT_REFLOW) +CSS_PROP(clip, clip, Clip, nsChangeHint_SyncFrameView) +CSS_PROP_INTERNAL(-x-clip-bottom, clip_bottom, ClipBottom, nsChangeHint_SyncFrameView) // XXX bug 3935 +CSS_PROP_INTERNAL(-x-clip-left, clip_left, ClipLeft, nsChangeHint_SyncFrameView) // XXX bug 3935 +CSS_PROP_INTERNAL(-x-clip-right, clip_right, ClipRight, nsChangeHint_SyncFrameView) // XXX bug 3935 +CSS_PROP_INTERNAL(-x-clip-top, clip_top, ClipTop, nsChangeHint_SyncFrameView) // XXX bug 3935 +CSS_PROP(color, color, Color, NS_STYLE_HINT_VISUAL) +CSS_PROP(content, content, Content, NS_STYLE_HINT_FRAMECHANGE) +CSS_PROP(counter-increment, counter_increment, CounterIncrement, NS_STYLE_HINT_REFLOW) +CSS_PROP(counter-reset, counter_reset, CounterReset, NS_STYLE_HINT_REFLOW) +CSS_PROP(-moz-counter-increment, _moz_counter_increment, MozCounterIncrement, NS_STYLE_HINT_REFLOW) // XXX bug 137285 +CSS_PROP(-moz-counter-reset, _moz_counter_reset, MozCounterReset, NS_STYLE_HINT_REFLOW) // XXX bug 137285 +CSS_PROP(cue, cue, Cue, NS_STYLE_HINT_AURAL) +CSS_PROP(cue-after, cue_after, CueAfter, NS_STYLE_HINT_AURAL) +CSS_PROP(cue-before, cue_before, CueBefore, NS_STYLE_HINT_AURAL) +CSS_PROP(cursor, cursor, Cursor, NS_STYLE_HINT_VISUAL) +CSS_PROP(direction, direction, Direction, NS_STYLE_HINT_REFLOW) +CSS_PROP(display, display, Display, NS_STYLE_HINT_FRAMECHANGE) +CSS_PROP(elevation, elevation, Elevation, NS_STYLE_HINT_AURAL) +CSS_PROP(empty-cells, empty_cells, EmptyCells, NS_STYLE_HINT_VISUAL) +CSS_PROP(float, float, CssFloat, NS_STYLE_HINT_FRAMECHANGE) +CSS_PROP(-moz-float-edge, float_edge, MozFloatEdge, NS_STYLE_HINT_REFLOW) // XXX bug 3935 +CSS_PROP(font, font, Font, NS_STYLE_HINT_REFLOW) +CSS_PROP(font-family, font_family, FontFamily, NS_STYLE_HINT_REFLOW) +CSS_PROP(font-size, font_size, FontSize, NS_STYLE_HINT_REFLOW) +CSS_PROP(font-size-adjust, font_size_adjust, FontSizeAdjust, NS_STYLE_HINT_REFLOW) +CSS_PROP(font-stretch, font_stretch, FontStretch, NS_STYLE_HINT_REFLOW) +CSS_PROP(font-style, font_style, FontStyle, NS_STYLE_HINT_REFLOW) +CSS_PROP(font-variant, font_variant, FontVariant, NS_STYLE_HINT_REFLOW) +CSS_PROP(font-weight, font_weight, FontWeight, NS_STYLE_HINT_REFLOW) +CSS_PROP(-moz-force-broken-image-icon, force_broken_image_icon, MozForceBrokenImageIcon, NS_STYLE_HINT_FRAMECHANGE) // bug 58646 +CSS_PROP(height, height, Height, NS_STYLE_HINT_REFLOW) +CSS_PROP(-moz-image-region, image_region, MozImageRegion, NS_STYLE_HINT_REFLOW) +CSS_PROP_INTERNAL(-x-image-region-bottom, image_region_bottom, MozImageRegionBottom, NS_STYLE_HINT_REFLOW) +CSS_PROP_INTERNAL(-x-image-region-left, image_region_left, MozImageRegionLeft, NS_STYLE_HINT_REFLOW) +CSS_PROP_INTERNAL(-x-image-region-right, image_region_right, MozImageRegionRight, NS_STYLE_HINT_REFLOW) +CSS_PROP_INTERNAL(-x-image-region-top, image_region_top, MozImageRegionTop, NS_STYLE_HINT_REFLOW) +CSS_PROP(-moz-key-equivalent, key_equivalent, MozKeyEquivalent, NS_STYLE_HINT_CONTENT) // This will need some other notification, but what? // XXX bug 3935 +CSS_PROP(left, left, Left, NS_STYLE_HINT_REFLOW) +CSS_PROP(letter-spacing, letter_spacing, LetterSpacing, NS_STYLE_HINT_REFLOW) +CSS_PROP(line-height, line_height, LineHeight, NS_STYLE_HINT_REFLOW) +CSS_PROP(list-style, list_style, ListStyle, NS_STYLE_HINT_REFLOW) +CSS_PROP(list-style-image, list_style_image, ListStyleImage, NS_STYLE_HINT_REFLOW) +CSS_PROP(list-style-position, list_style_position, ListStylePosition, NS_STYLE_HINT_REFLOW) +CSS_PROP(list-style-type, list_style_type, ListStyleType, NS_STYLE_HINT_REFLOW) +CSS_PROP(margin, margin, Margin, NS_STYLE_HINT_REFLOW) +CSS_PROP(margin-bottom, margin_bottom, MarginBottom, NS_STYLE_HINT_REFLOW) +CSS_PROP(margin-left, margin_left, MarginLeft, NS_STYLE_HINT_REFLOW) +CSS_PROP(margin-right, margin_right, MarginRight, NS_STYLE_HINT_REFLOW) +CSS_PROP(margin-top, margin_top, MarginTop, NS_STYLE_HINT_REFLOW) +CSS_PROP(marker-offset, marker_offset, MarkerOffset, NS_STYLE_HINT_REFLOW) +CSS_PROP(marks, marks, Marks, NS_STYLE_HINT_VISUAL) +CSS_PROP(max-height, max_height, MaxHeight, NS_STYLE_HINT_REFLOW) +CSS_PROP(max-width, max_width, MaxWidth, NS_STYLE_HINT_REFLOW) +CSS_PROP(min-height, min_height, MinHeight, NS_STYLE_HINT_REFLOW) +CSS_PROP(min-width, min_width, MinWidth, NS_STYLE_HINT_REFLOW) +CSS_PROP(-moz-opacity, opacity, MozOpacity, NS_STYLE_HINT_FRAMECHANGE) // XXX bug 3935 +CSS_PROP(orphans, orphans, Orphans, NS_STYLE_HINT_REFLOW) +CSS_PROP(outline, outline, Outline, NS_STYLE_HINT_VISUAL) +CSS_PROP(outline, outline_color, OutlineColor, NS_STYLE_HINT_VISUAL) +CSS_PROP(outline, outline_style, OutlineStyle, NS_STYLE_HINT_VISUAL) +CSS_PROP(outline, outline_width, OutlineWidth, NS_STYLE_HINT_VISUAL) +CSS_PROP(-moz-outline, _moz_outline, MozOutline, NS_STYLE_HINT_VISUAL) // XXX This is temporary fix for nsbeta3+ Bug 48973, turning outline into -moz-outline XXX bug 48973 +CSS_PROP(-moz-outline-color, _moz_outline_color, MozOutlineColor, NS_STYLE_HINT_VISUAL) // XXX bug 48973 +CSS_PROP(-moz-outline-style, _moz_outline_style, MozOutlineStyle, NS_STYLE_HINT_VISUAL) // XXX bug 48973 +CSS_PROP(-moz-outline-width, _moz_outline_width, MozOutlineWidth, NS_STYLE_HINT_VISUAL) // XXX bug 48973 +CSS_PROP(overflow, overflow, Overflow, NS_STYLE_HINT_FRAMECHANGE) +CSS_PROP(padding, padding, Padding, NS_STYLE_HINT_REFLOW) +CSS_PROP(padding-bottom, padding_bottom, PaddingBottom, NS_STYLE_HINT_REFLOW) +CSS_PROP(padding-left, padding_left, PaddingLeft, NS_STYLE_HINT_REFLOW) +CSS_PROP(padding-right, padding_right, PaddingRight, NS_STYLE_HINT_REFLOW) +CSS_PROP(padding-top, padding_top, PaddingTop, NS_STYLE_HINT_REFLOW) +CSS_PROP(page, page, Page, NS_STYLE_HINT_REFLOW) +CSS_PROP(page-break-after, page_break_after, PageBreakAfter, NS_STYLE_HINT_REFLOW) +CSS_PROP(page-break-before, page_break_before, PageBreakBefore, NS_STYLE_HINT_REFLOW) +CSS_PROP(page-break-inside, page_break_inside, PageBreakInside, NS_STYLE_HINT_REFLOW) +CSS_PROP(pause, pause, Pause, NS_STYLE_HINT_AURAL) +CSS_PROP(pause-after, pause_after, PauseAfter, NS_STYLE_HINT_AURAL) +CSS_PROP(pause-before, pause_before, PauseBefore, NS_STYLE_HINT_AURAL) +CSS_PROP(pitch, pitch, Pitch, NS_STYLE_HINT_AURAL) +CSS_PROP(pitch-range, pitch_range, PitchRange, NS_STYLE_HINT_AURAL) +CSS_PROP(play-during, play_during, PlayDuring, NS_STYLE_HINT_AURAL) +CSS_PROP_INTERNAL(-x-play-during-flags, play_during_flags, PlayDuringFlags, NS_STYLE_HINT_AURAL) // XXX why is this here? +CSS_PROP(position, position, Position, NS_STYLE_HINT_FRAMECHANGE) +CSS_PROP(quotes, quotes, Quotes, NS_STYLE_HINT_REFLOW) +CSS_PROP_INTERNAL(-x-quotes-close, quotes_close, QuotesClose, NS_STYLE_HINT_REFLOW) // XXX bug 3935 +CSS_PROP_INTERNAL(-x-quotes-open, quotes_open, QuotesOpen, NS_STYLE_HINT_REFLOW) // XXX bug 3935 +CSS_PROP(-moz-resizer, resizer, MozResizer, NS_STYLE_HINT_FRAMECHANGE) // XXX bug 3935 +CSS_PROP(richness, richness, Richness, NS_STYLE_HINT_AURAL) +CSS_PROP(right, right, Right, NS_STYLE_HINT_REFLOW) +CSS_PROP(size, size, Size, NS_STYLE_HINT_REFLOW) +CSS_PROP_INTERNAL(-x-size-height, size_height, SizeHeight, NS_STYLE_HINT_REFLOW) // XXX bug 3935 +CSS_PROP_INTERNAL(-x-size-width, size_width, SizeWidth, NS_STYLE_HINT_REFLOW) // XXX bug 3935 +CSS_PROP(speak, speak, Speak, NS_STYLE_HINT_AURAL) +CSS_PROP(speak-header, speak_header, SpeakHeader, NS_STYLE_HINT_AURAL) +CSS_PROP(speak-numeral, speak_numeral, SpeakNumeral, NS_STYLE_HINT_AURAL) +CSS_PROP(speak-punctuation, speak_punctuation, SpeakPunctuation, NS_STYLE_HINT_AURAL) +CSS_PROP(speech-rate, speech_rate, SpeechRate, NS_STYLE_HINT_AURAL) +CSS_PROP(stress, stress, Stress, NS_STYLE_HINT_AURAL) +CSS_PROP(table-layout, table_layout, TableLayout, NS_STYLE_HINT_REFLOW) +CSS_PROP(text-align, text_align, TextAlign, NS_STYLE_HINT_REFLOW) +CSS_PROP(text-decoration, text_decoration, TextDecoration, NS_STYLE_HINT_VISUAL) +CSS_PROP(text-indent, text_indent, TextIndent, NS_STYLE_HINT_REFLOW) +CSS_PROP(text-shadow, text_shadow, TextShadow, NS_STYLE_HINT_VISUAL) +CSS_PROP_INTERNAL(-x-text-shadow-color, text_shadow_color, TextShadowColor, NS_STYLE_HINT_VISUAL) // XXX bug 3935 +CSS_PROP_INTERNAL(-x-text-shadow-radius, text_shadow_radius, TextShadowRadius, NS_STYLE_HINT_VISUAL) // XXX bug 3935 +CSS_PROP_INTERNAL(-x-text-shadow-x, text_shadow_x, TextShadowX, NS_STYLE_HINT_VISUAL) // XXX bug 3935 +CSS_PROP_INTERNAL(-x-text-shadow-y, text_shadow_y, TextShadowY, NS_STYLE_HINT_VISUAL) // XXX bug 3935 +CSS_PROP(text-transform, text_transform, TextTransform, NS_STYLE_HINT_REFLOW) +CSS_PROP(top, top, Top, NS_STYLE_HINT_REFLOW) +CSS_PROP(unicode-bidi, unicode_bidi, UnicodeBidi, NS_STYLE_HINT_REFLOW) +CSS_PROP(-moz-user-focus, user_focus, MozUserFocus, NS_STYLE_HINT_CONTENT) // XXX bug 3935 +CSS_PROP(-moz-user-input, user_input, MozUserInput, NS_STYLE_HINT_FRAMECHANGE) // XXX ??? // XXX bug 3935 +CSS_PROP(-moz-user-modify, user_modify, MozUserModify, NS_STYLE_HINT_FRAMECHANGE) // XXX bug 3935 +CSS_PROP(-moz-user-select, user_select, MozUserSelect, NS_STYLE_HINT_CONTENT) // XXX bug 3935 +CSS_PROP(vertical-align, vertical_align, VerticalAlign, NS_STYLE_HINT_REFLOW) +CSS_PROP(visibility, visibility, Visibility, NS_STYLE_HINT_REFLOW) // reflow for collapse +CSS_PROP(voice-family, voice_family, VoiceFamily, NS_STYLE_HINT_AURAL) +CSS_PROP(volume, volume, Volume, NS_STYLE_HINT_AURAL) +CSS_PROP(white-space, white_space, WhiteSpace, NS_STYLE_HINT_REFLOW) +CSS_PROP(widows, widows, Widows, NS_STYLE_HINT_REFLOW) +CSS_PROP(width, width, Width, NS_STYLE_HINT_REFLOW) +CSS_PROP(word-spacing, word_spacing, WordSpacing, NS_STYLE_HINT_REFLOW) +CSS_PROP(z-index, z_index, ZIndex, NS_STYLE_HINT_REFLOW) #ifdef MOZ_SVG // XXX treat SVG's CSS Properties as internal for now. // Do we want to create an nsIDOMSVGCSS2Properties interface? -CSS_PROP_INTERNAL(fill, fill, Fill, VISUAL) -CSS_PROP_INTERNAL(fill-opacity, fill_opacity, FillOpacity, VISUAL) -CSS_PROP_INTERNAL(fill-rule, fill_rule, FillRule, VISUAL) -CSS_PROP_INTERNAL(stroke, stroke, Stroke, VISUAL) -CSS_PROP_INTERNAL(stroke-dasharray, stroke_dasharray, StrokeDasharray, VISUAL) -CSS_PROP_INTERNAL(stroke-dashoffset, stroke_dashoffset, StrokeDashoffset, VISUAL) -CSS_PROP_INTERNAL(stroke-linecap, stroke_linecap, StrokeLinecap, VISUAL) -CSS_PROP_INTERNAL(stroke-linejoin, stroke_linejoin, StrokeLinejoin, VISUAL) -CSS_PROP_INTERNAL(stroke-miterlimit, stroke_miterlimit, StrokeMiterlimit, VISUAL) -CSS_PROP_INTERNAL(stroke-opacity, stroke_opacity, StrokeOpacity, VISUAL) -CSS_PROP_INTERNAL(stroke-width, stroke_width, StrokeWidth, VISUAL) +CSS_PROP_INTERNAL(fill, fill, Fill, NS_STYLE_HINT_VISUAL) +CSS_PROP_INTERNAL(fill-opacity, fill_opacity, FillOpacity, NS_STYLE_HINT_VISUAL) +CSS_PROP_INTERNAL(fill-rule, fill_rule, FillRule, NS_STYLE_HINT_VISUAL) +CSS_PROP_INTERNAL(stroke, stroke, Stroke, NS_STYLE_HINT_VISUAL) +CSS_PROP_INTERNAL(stroke-dasharray, stroke_dasharray, StrokeDasharray, NS_STYLE_HINT_VISUAL) +CSS_PROP_INTERNAL(stroke-dashoffset, stroke_dashoffset, StrokeDashoffset, NS_STYLE_HINT_VISUAL) +CSS_PROP_INTERNAL(stroke-linecap, stroke_linecap, StrokeLinecap, NS_STYLE_HINT_VISUAL) +CSS_PROP_INTERNAL(stroke-linejoin, stroke_linejoin, StrokeLinejoin, NS_STYLE_HINT_VISUAL) +CSS_PROP_INTERNAL(stroke-miterlimit, stroke_miterlimit, StrokeMiterlimit, NS_STYLE_HINT_VISUAL) +CSS_PROP_INTERNAL(stroke-opacity, stroke_opacity, StrokeOpacity, NS_STYLE_HINT_VISUAL) +CSS_PROP_INTERNAL(stroke-width, stroke_width, StrokeWidth, NS_STYLE_HINT_VISUAL) #endif // Clean up after ourselves diff --git a/content/shared/public/nsChangeHint.h b/content/shared/public/nsChangeHint.h index 642424793df..b884d088340 100644 --- a/content/shared/public/nsChangeHint.h +++ b/content/shared/public/nsChangeHint.h @@ -79,6 +79,11 @@ inline nsChangeHint NS_CombineHint(nsChangeHint aH1, nsChangeHint aH2) { return (nsChangeHint)(aH1 | aH2); } +// Merge two hints, taking the union +inline nsChangeHint NS_SubtractHint(nsChangeHint aH1, nsChangeHint aH2) { + return (nsChangeHint)(aH1 & ~aH2); +} + // Merge the "src" hint into the "dst" hint // Returns true iff the destination changed inline PRBool NS_UpdateHint(nsChangeHint& aDest, nsChangeHint aSrc) { diff --git a/content/shared/src/nsCSSProps.cpp b/content/shared/src/nsCSSProps.cpp index 9bc1ef931b6..67e689779c6 100644 --- a/content/shared/src/nsCSSProps.cpp +++ b/content/shared/src/nsCSSProps.cpp @@ -1286,7 +1286,7 @@ PRBool nsCSSProps::GetColorName(PRInt32 aPropValue, nsCString &aStr) } // define array of all CSS property hints -#define CSS_PROP(_name, _id, _method, _hint) NS_STYLE_HINT_##_hint, +#define CSS_PROP(_name, _id, _method, _hint) _hint, const nsChangeHint nsCSSProps::kHintTable[eCSSProperty_COUNT] = { #include "nsCSSPropList.h" }; diff --git a/content/shared/src/nsStyleStruct.cpp b/content/shared/src/nsStyleStruct.cpp index d8f8cc5f026..2425a9f2442 100644 --- a/content/shared/src/nsStyleStruct.cpp +++ b/content/shared/src/nsStyleStruct.cpp @@ -1049,23 +1049,28 @@ nsStyleDisplay::nsStyleDisplay(const nsStyleDisplay& aSource) nsChangeHint nsStyleDisplay::CalcDifference(const nsStyleDisplay& aOther) const { - if (mBinding != aOther.mBinding || mPosition != aOther.mPosition) - return NS_STYLE_HINT_FRAMECHANGE; + nsChangeHint hint = nsChangeHint_None; - if ((mDisplay == aOther.mDisplay) && - (mFloats == aOther.mFloats) && - (mOverflow == aOther.mOverflow)) { - if ((mBreakType == aOther.mBreakType) && - (mBreakBefore == aOther.mBreakBefore) && - (mBreakAfter == aOther.mBreakAfter) && - (mClipFlags == aOther.mClipFlags) && - (mClip == aOther.mClip) && - (mAppearance == aOther.mAppearance)) { - return NS_STYLE_HINT_NONE; - } - return NS_STYLE_HINT_REFLOW; - } - return NS_STYLE_HINT_FRAMECHANGE; + if (mBinding != aOther.mBinding + || mPosition != aOther.mPosition + || mDisplay != aOther.mDisplay + || mFloats != aOther.mFloats + || mOverflow != aOther.mOverflow) + NS_UpdateHint(hint, nsChangeHint_ReconstructFrame); + + // XXX the following is conservative, for now: changing float breaking shouldn't + // necessarily require a repaint, reflow should suffice. + if (mBreakType != aOther.mBreakType + || mBreakBefore != aOther.mBreakBefore + || mBreakAfter != aOther.mBreakAfter + || mAppearance != aOther.mAppearance) + NS_UpdateHint(hint, NS_CombineHint(nsChangeHint_ReflowFrame, nsChangeHint_RepaintFrame)); + + if (mClipFlags != aOther.mClipFlags + || mClip != aOther.mClip) + NS_UpdateHint(hint, nsChangeHint_SyncFrameView); + + return hint; } // -------------------- diff --git a/layout/base/nsCSSFrameConstructor.cpp b/layout/base/nsCSSFrameConstructor.cpp index 708ea892244..23a8c0ac3a1 100644 --- a/layout/base/nsCSSFrameConstructor.cpp +++ b/layout/base/nsCSSFrameConstructor.cpp @@ -9930,111 +9930,13 @@ static PRBool gInApplyRenderingChangeToTree = PR_FALSE; static void DoApplyRenderingChangeToTree(nsIPresContext* aPresContext, nsIFrame* aFrame, - nsIViewManager* aViewManager); - -static void -SyncAndInvalidateView(nsIPresContext* aPresContext, - nsIView* aView, - nsIFrame* aFrame, - nsIViewManager* aViewManager) -{ - NS_PRECONDITION(gInApplyRenderingChangeToTree, - "should only be called within ApplyRenderingChangeToTree"); - - const nsStyleBackground* bg; - const nsStyleDisplay* disp; - const nsStyleVisibility* vis; - PRBool isCanvas; - PRBool hasBG = - nsCSSRendering::FindBackground(aPresContext, aFrame, &bg, &isCanvas); - aFrame->GetStyleData(eStyleStruct_Display, (const nsStyleStruct*&) disp); - aFrame->GetStyleData(eStyleStruct_Visibility, (const nsStyleStruct*&) vis); - - aViewManager->SetViewOpacity(aView, vis->mOpacity); - - // See if the view should be hidden or visible - PRBool viewIsVisible = PR_TRUE; - PRBool viewHasTransparentContent = - !isCanvas && - (!hasBG || - (bg->mBackgroundFlags & NS_STYLE_BG_COLOR_TRANSPARENT)); - - if (NS_STYLE_VISIBILITY_COLLAPSE == vis->mVisible) { - viewIsVisible = PR_FALSE; - } - else if (NS_STYLE_VISIBILITY_HIDDEN == vis->mVisible) { - // If it has a widget, hide the view because the widget can't deal with it - nsIWidget* widget = nsnull; - aView->GetWidget(widget); - if (widget) { - viewIsVisible = PR_FALSE; - NS_RELEASE(widget); - } - else { - // If it's a scroll frame, then hide the view. This means that - // child elements can't override their parent's visibility, but - // it's not practical to leave it visible in all cases because - // the scrollbars will be showing - nsIAtom* frameType; - aFrame->GetFrameType(&frameType); - - if (frameType == nsLayoutAtoms::scrollFrame) { - viewIsVisible = PR_FALSE; - } else { - // If it's a container element, then leave the view visible, but - // mark it as having transparent content. The reason we need to - // do this is that child elements can override their parent's - // hidden visibility and be visible anyway - nsIFrame* firstChild; - - aFrame->FirstChild(aPresContext, nsnull, &firstChild); - if (firstChild) { - // It's not a left frame, so the view needs to be visible, but - // marked as having transparent content - viewHasTransparentContent = PR_TRUE; - } else { - // It's a leaf frame so go ahead and hide the view - viewIsVisible = PR_FALSE; - } - } - NS_IF_RELEASE(frameType); - } - } else { - // if the view is for a popup, don't show the view if the popup is closed - nsCOMPtr widget; - aView->GetWidget(*getter_AddRefs(widget)); - if (widget) { - nsWindowType windowType; - widget->GetWindowType(windowType); - if (windowType == eWindowType_popup) - widget->IsVisible(viewIsVisible); - } - } - - // If the frame has visible content that overflows the content area, then we - // need the view marked as having transparent content - if (NS_STYLE_OVERFLOW_VISIBLE == disp->mOverflow) { - nsFrameState frameState; - - aFrame->GetFrameState(&frameState); - if (frameState & NS_FRAME_OUTSIDE_CHILDREN) { - viewHasTransparentContent = PR_TRUE; - } - } - - if (viewIsVisible) { - aViewManager->SetViewContentTransparency(aView, viewHasTransparentContent); - aViewManager->SetViewVisibility(aView, nsViewVisibility_kShow); - aViewManager->UpdateView(aView, NS_VMREFRESH_NO_SYNC); - } - else { - aViewManager->SetViewVisibility(aView, nsViewVisibility_kHide); - } -} + nsIViewManager* aViewManager, + nsChangeHint aChange); static void UpdateViewsForTree(nsIPresContext* aPresContext, nsIFrame* aFrame, - nsIViewManager* aViewManager, nsRect& aBoundsRect) + nsIViewManager* aViewManager, nsRect& aBoundsRect, + nsChangeHint aChange) { NS_PRECONDITION(gInApplyRenderingChangeToTree, "should only be called within ApplyRenderingChangeToTree"); @@ -10043,7 +9945,12 @@ UpdateViewsForTree(nsIPresContext* aPresContext, nsIFrame* aFrame, aFrame->GetView(aPresContext, &view); if (view) { - SyncAndInvalidateView(aPresContext, view, aFrame, aViewManager); + if (aChange & nsChangeHint_RepaintFrame) { + aViewManager->UpdateView(view, NS_VMREFRESH_NO_SYNC); + } + if (aChange & nsChangeHint_SyncFrameView) { + nsContainerFrame::SyncFrameViewProperties(aPresContext, aFrame, nsnull, view); + } } nsRect bounds; @@ -10071,11 +9978,11 @@ UpdateViewsForTree(nsIPresContext* aPresContext, nsIFrame* aFrame, nsIFrame* outOfFlowFrame = ((nsPlaceholderFrame*)child)->GetOutOfFlowFrame(); NS_ASSERTION(outOfFlowFrame, "no out-of-flow frame"); - DoApplyRenderingChangeToTree(aPresContext, outOfFlowFrame, aViewManager); + DoApplyRenderingChangeToTree(aPresContext, outOfFlowFrame, aViewManager, aChange); } else { // regular frame nsRect childBounds; - UpdateViewsForTree(aPresContext, child, aViewManager, childBounds); + UpdateViewsForTree(aPresContext, child, aViewManager, childBounds, aChange); bounds.UnionRect(bounds, childBounds); } NS_IF_RELEASE(frameType); @@ -10093,7 +10000,8 @@ UpdateViewsForTree(nsIPresContext* aPresContext, nsIFrame* aFrame, static void DoApplyRenderingChangeToTree(nsIPresContext* aPresContext, nsIFrame* aFrame, - nsIViewManager* aViewManager) + nsIViewManager* aViewManager, + nsChangeHint aChange) { NS_PRECONDITION(gInApplyRenderingChangeToTree, "should only be called within ApplyRenderingChangeToTree"); @@ -10114,9 +10022,9 @@ DoApplyRenderingChangeToTree(nsIPresContext* aPresContext, aFrame->GetOffsetFromView(aPresContext, viewOffset, &parentView); NS_ASSERTION(nsnull != parentView, "no view"); } - UpdateViewsForTree(aPresContext, aFrame, aViewManager, invalidRect); + UpdateViewsForTree(aPresContext, aFrame, aViewManager, invalidRect, aChange); - if (! view) { // if frame has view, will already be invalidated + if (! view && (aChange & nsChangeHint_RepaintFrame)) { // if frame has view, will already be invalidated // XXX Instead of calling this we should really be calling // Invalidate on on the nsFrame (which does this) const nsStyleOutline* outline; @@ -10138,14 +10046,20 @@ DoApplyRenderingChangeToTree(nsIPresContext* aPresContext, static void ApplyRenderingChangeToTree(nsIPresContext* aPresContext, nsIFrame* aFrame, - nsIViewManager* aViewManager) + nsIViewManager* aViewManager, + nsChangeHint aChange) { nsCOMPtr shell; aPresContext->GetShell(getter_AddRefs(shell)); PRBool isPaintingSuppressed = PR_FALSE; shell->IsPaintingSuppressed(&isPaintingSuppressed); - if (isPaintingSuppressed) - return; // Don't allow synchronous rendering changes when painting is turned off. + if (isPaintingSuppressed) { + // Don't allow synchronous rendering changes when painting is turned off. + aChange = NS_SubtractHint(aChange, nsChangeHint_RepaintFrame); + if (!aChange) { + return; + } + } // If the frame's background is propagated to an ancestor, walk up to // that ancestor. @@ -10179,7 +10093,7 @@ ApplyRenderingChangeToTree(nsIPresContext* aPresContext, #ifdef DEBUG gInApplyRenderingChangeToTree = PR_TRUE; #endif - DoApplyRenderingChangeToTree(aPresContext, aFrame, viewManager); + DoApplyRenderingChangeToTree(aPresContext, aFrame, viewManager, aChange); #ifdef DEBUG gInApplyRenderingChangeToTree = PR_FALSE; #endif @@ -10250,7 +10164,7 @@ nsCSSFrameConstructor::StyleChangeReflow(nsIPresContext* aPresContext, // This isn't the most efficient way to do it, but it saves code // size and doesn't add much cost compared to the reflow.. if (ancestor != aFrame) - ApplyRenderingChangeToTree(aPresContext, ancestor, nsnull); + ApplyRenderingChangeToTree(aPresContext, ancestor, nsnull, nsChangeHint_RepaintFrame); return NS_OK; } @@ -10349,11 +10263,8 @@ nsCSSFrameConstructor::ProcessRestyledFrames(nsStyleChangeList& aChangeList, if (hint & nsChangeHint_ReflowFrame) { StyleChangeReflow(aPresContext, frame, nsnull); } - if (hint & nsChangeHint_RepaintFrame) { - ApplyRenderingChangeToTree(aPresContext, frame, nsnull); - } - if (hint & nsChangeHint_SyncFrameView) { - // TBD: split out view sync from ApplyRenderingChange and friends + if (hint & (nsChangeHint_RepaintFrame | nsChangeHint_SyncFrameView)) { + ApplyRenderingChangeToTree(aPresContext, frame, nsnull, hint); } } } @@ -10463,7 +10374,7 @@ nsCSSFrameConstructor::ContentStatesChanged(nsIPresContext* aPresContext, if (theme && theme->ThemeSupportsWidget(aPresContext, primaryFrame1, app1)) theme->WidgetStateChanged(primaryFrame1, app1, nsnull, &repaint); if (repaint) - ApplyRenderingChangeToTree(aPresContext, primaryFrame1, nsnull); + ApplyRenderingChangeToTree(aPresContext, primaryFrame1, nsnull, nsChangeHint_RepaintFrame); } if (!(frameChange1 & nsChangeHint_ReconstructDoc) && (primaryFrame2)) { @@ -10477,7 +10388,7 @@ nsCSSFrameConstructor::ContentStatesChanged(nsIPresContext* aPresContext, if (theme && theme->ThemeSupportsWidget(aPresContext, primaryFrame2, app2)) theme->WidgetStateChanged(primaryFrame2, app2, nsnull, &repaint); if (repaint) - ApplyRenderingChangeToTree(aPresContext, primaryFrame2, nsnull); + ApplyRenderingChangeToTree(aPresContext, primaryFrame2, nsnull, nsChangeHint_RepaintFrame); } } @@ -10523,7 +10434,7 @@ nsCSSFrameConstructor::ContentStatesChanged(nsIPresContext* aPresContext, if (theme) theme->WidgetStateChanged(primaryFrame2, app2, nsnull, &repaint); if (repaint) - ApplyRenderingChangeToTree(aPresContext, primaryFrame2, nsnull); + ApplyRenderingChangeToTree(aPresContext, primaryFrame2, nsnull, nsChangeHint_RepaintFrame); } // max change needed for top level frames @@ -10701,7 +10612,7 @@ nsCSSFrameConstructor::AttributeChanged(nsIPresContext* aPresContext, PRBool repaint = PR_FALSE; theme->WidgetStateChanged(primaryFrame, disp->mAppearance, aAttribute, &repaint); if (repaint) - ApplyRenderingChangeToTree(aPresContext, primaryFrame, nsnull); + ApplyRenderingChangeToTree(aPresContext, primaryFrame, nsnull, nsChangeHint_RepaintFrame); } } } @@ -10791,11 +10702,6 @@ nsCSSFrameConstructor::StyleRuleChanged(nsIPresContext* aPresContext, PRBool reframe = (aHint & (nsChangeHint_ReconstructDoc | nsChangeHint_ReconstructFrame | nsChangeHint_Unknown)) != 0; - PRBool reflow = (aHint & (nsChangeHint_ReconstructDoc | nsChangeHint_ReconstructFrame - | nsChangeHint_ReflowFrame | nsChangeHint_Unknown)) != 0; - PRBool render = (aHint & (nsChangeHint_ReconstructDoc | nsChangeHint_ReconstructFrame - | nsChangeHint_ReflowFrame | nsChangeHint_RepaintFrame - | nsChangeHint_Unknown)) != 0; PRBool restyle = (aHint & ~(nsChangeHint_AttrChange)) != 0; // TBD: add "review" to update view? @@ -10809,14 +10715,20 @@ nsCSSFrameConstructor::StyleRuleChanged(nsIPresContext* aPresContext, result = ReconstructDocElementHierarchy(aPresContext); } else { + PRBool reflow = (aHint & (nsChangeHint_ReconstructDoc | nsChangeHint_ReconstructFrame + | nsChangeHint_ReflowFrame | nsChangeHint_Unknown)) != 0; + PRBool renderOrSync = (aHint & (nsChangeHint_ReconstructDoc | nsChangeHint_ReconstructFrame + | nsChangeHint_ReflowFrame | nsChangeHint_RepaintFrame + | nsChangeHint_Unknown | nsChangeHint_SyncFrameView)) != 0; + // XXX hack, skip the root and scrolling frames frame->FirstChild(aPresContext, nsnull, &frame); frame->FirstChild(aPresContext, nsnull, &frame); if (reflow) { StyleChangeReflow(aPresContext, frame, nsnull); } - else if (render) { - ApplyRenderingChangeToTree(aPresContext, frame, nsnull); + if (renderOrSync) { + ApplyRenderingChangeToTree(aPresContext, frame, nsnull, aHint); } } diff --git a/layout/base/nsChangeHint.h b/layout/base/nsChangeHint.h index 642424793df..b884d088340 100644 --- a/layout/base/nsChangeHint.h +++ b/layout/base/nsChangeHint.h @@ -79,6 +79,11 @@ inline nsChangeHint NS_CombineHint(nsChangeHint aH1, nsChangeHint aH2) { return (nsChangeHint)(aH1 | aH2); } +// Merge two hints, taking the union +inline nsChangeHint NS_SubtractHint(nsChangeHint aH1, nsChangeHint aH2) { + return (nsChangeHint)(aH1 & ~aH2); +} + // Merge the "src" hint into the "dst" hint // Returns true iff the destination changed inline PRBool NS_UpdateHint(nsChangeHint& aDest, nsChangeHint aSrc) { diff --git a/layout/doc/adding-style-props.html b/layout/doc/adding-style-props.html index 4cd85f99bed..fb5c5ba954f 100644 --- a/layout/doc/adding-style-props.html +++ b/layout/doc/adding-style-props.html @@ -91,15 +91,14 @@ nsCSSPropList.h  Insert the property in the list alphabetically, using the existing property names as a template. The format of the entry you will create is:

-
CSS_PROP(-moz-force-broken-image-iconst, force_broken_image_icons, FRAMECHANGE) // bug 58646
+
CSS_PROP(-moz-force-broken-image-iconst, force_broken_image_icons, NS_STYLE_HINT_FRAMECHANGE) // bug 58646

The first value is the formal property name, in other words the property name as it is seen by the CSS parser.
The second value is the name of the property as it will appear internally.
The last value indicates what must change when the value of the property -changes. It should be one of ( -VISUAL, AURAL, REFLOW, CONTENT, FRAMECHANGE -).

+changes. It should be an +nsChangeHint.

If you need to introduce new constants for the values of the property, they must be added to diff --git a/layout/forms/nsImageControlFrame.cpp b/layout/forms/nsImageControlFrame.cpp index 02a788de49a..4d1d0f8e6f7 100644 --- a/layout/forms/nsImageControlFrame.cpp +++ b/layout/forms/nsImageControlFrame.cpp @@ -60,6 +60,7 @@ #include "nsGUIEvent.h" #include "nsLayoutAtoms.h" #include "nsIServiceManager.h" +#include "nsContainerFrame.h" #ifdef ACCESSIBILITY #include "nsIAccessibilityService.h" #endif @@ -283,14 +284,15 @@ nsImageControlFrame::Init(nsIPresContext* aPresContext, // the view's size is not know yet, but its size will be kept in synch with our frame. nsRect boundBox(0, 0, 0, 0); result = view->Init(viewMan, boundBox, parView); - viewMan->SetViewContentTransparency(view, PR_TRUE); + + nsContainerFrame::SyncFrameViewProperties(aPresContext, this, aContext, view); + + // this gets reset during reflow anyway + // viewMan->SetViewContentTransparency(view, PR_TRUE); + // XXX put the view last in document order until we know how to do better viewMan->InsertChild(parView, view, nsnull, PR_TRUE); SetView(aPresContext, view); - - const nsStyleVisibility* vis = (const nsStyleVisibility*) mStyleContext->GetStyleData(eStyleStruct_Visibility); - // set the opacity - viewMan->SetViewOpacity(view, vis->mOpacity); } return rv; diff --git a/layout/generic/nsContainerFrame.cpp b/layout/generic/nsContainerFrame.cpp index ce856f5a7e3..95f4d86f089 100644 --- a/layout/generic/nsContainerFrame.cpp +++ b/layout/generic/nsContainerFrame.cpp @@ -504,77 +504,266 @@ nsContainerFrame::SyncFrameViewAfterReflow(nsIPresContext* aPresContext, const nsRect* aCombinedArea, PRUint32 aFlags) { - if (aView) { + if (!aView) { + return; + } + + // Make sure the view is sized and positioned correctly + if (0 == (aFlags & NS_FRAME_NO_MOVE_VIEW)) { + PositionFrameView(aPresContext, aFrame); + } + + if (0 == (aFlags & NS_FRAME_NO_SIZE_VIEW)) { nsCOMPtr vm; - nsFrameState kidState; - nsSize frameSize; - aView->GetViewManager(*getter_AddRefs(vm)); + nsRect oldBounds; + aView->GetBounds(oldBounds); + nsFrameState kidState; aFrame->GetFrameState(&kidState); - aFrame->GetSize(frameSize); - - // Make sure the view is sized and positioned correctly - if (0 == (aFlags & NS_FRAME_NO_MOVE_VIEW)) { - PositionFrameView(aPresContext, aFrame); + + // If the frame has child frames that stick outside the content + // area, then size the view large enough to include those child + // frames + if ((kidState & NS_FRAME_OUTSIDE_CHILDREN) && aCombinedArea) { + vm->ResizeView(aView, *aCombinedArea); + } else { + // If the width is unchanged and the height is not decreased then repaint only the + // newly exposed or contracted area, otherwise repaint the union of the old and new areas + + // XXX: We currently invalidate the newly exposed areas only when the + // container frame's width is unchanged and the height is either unchanged or increased + // This is because some frames do not invalidate themselves properly. see bug 73825. + // Once bug 73825 is fixed, we should always pass PR_TRUE instead of + // frameSize.width == width && frameSize.height >= height. + nsSize frameSize; + aFrame->GetSize(frameSize); + nsRect newSize(0, 0, frameSize.width, frameSize.height); + vm->ResizeView(aView, newSize, + (frameSize.width == oldBounds.width && frameSize.height >= oldBounds.height)); } - nsRect newSize(0, 0, frameSize.width, frameSize.height); - if (0 == (aFlags & NS_FRAME_NO_SIZE_VIEW)) { - // If the frame has child frames that stick outside the content - // area, then size the view large enough to include those child - // frames - if ((kidState & NS_FRAME_OUTSIDE_CHILDREN) && aCombinedArea) { - vm->ResizeView(aView, *aCombinedArea); - newSize = *aCombinedArea; - } else { - nsRect bounds; - aView->GetBounds(bounds); - // If the width is unchanged and the height is not decreased then repaint only the - // newly exposed or contracted area, otherwise repaint the union of the old and new areas + nsRect newBounds; + aView->GetBounds(newBounds); - // XXX: We currently invalidate the newly exposed areas only when the - // container frame's width is unchanged and the height is either unchanged or increased - // This is because some frames do not invalidate themselves properly. see bug 73825. - // Once bug 73825 is fixed, we should always pass PR_TRUE instead of - // frameSize.width == width && frameSize.height >= height. - vm->ResizeView(aView, newSize, - (frameSize.width == bounds.width && frameSize.height >= bounds.height)); + // if the bounds have changed and clipping is enabled, we need to update the clip area + // and also possibly the transparency (in case the view grew bigger than the clip area + // so clipping is now cutting out part of the view) + if (oldBounds != newBounds) { + SyncFrameViewAfterSizeChange(aPresContext, aFrame, nsnull, aView, aFlags); + } + } +} + +static void +SyncFrameViewGeometryDependentProperties(nsIPresContext* aPresContext, + nsIFrame* aFrame, + nsIStyleContext* aStyleContext, + nsIView* aView, + PRUint32 aFlags) +{ + nsCOMPtr vm; + aView->GetViewManager(*getter_AddRefs(vm)); + + PRBool isCanvas; + const nsStyleBackground* bg; + PRBool hasBG = + nsCSSRendering::FindBackground(aPresContext, aFrame, &bg, &isCanvas); + + // background-attachment: fixed is not really geometry dependent, but + // we set it here because it's cheap to do so + PRBool fixedBackground = hasBG && + NS_STYLE_BG_ATTACHMENT_FIXED == bg->mBackgroundAttachment; + // If the frame has a fixed background attachment, then indicate that the + // view's contents should be repainted and not bitblt'd + vm->SetViewBitBltEnabled(aView, !fixedBackground); + + PRBool viewHasTransparentContent = + !hasBG || + (bg->mBackgroundFlags & NS_STYLE_BG_COLOR_TRANSPARENT) || + !aFrame->CanPaintBackground(); + if (isCanvas && viewHasTransparentContent) { + nsIView* rootView; + vm->GetRootView(rootView); + nsIView* rootParent; + rootView->GetParent(rootParent); + if (nsnull == rootParent) { + viewHasTransparentContent = PR_FALSE; + } + } + + const nsStyleDisplay* display; + ::GetStyleData(aStyleContext, &display); + nsFrameState kidState; + aFrame->GetFrameState(&kidState); + + if (!viewHasTransparentContent) { + // If we're showing the view but the frame is hidden, then the view is transparent + nsViewVisibility visibility; + aView->GetVisibility(visibility); + const nsStyleVisibility* vis; + ::GetStyleData(aStyleContext, &vis); + if ((nsViewVisibility_kShow == visibility + && NS_STYLE_VISIBILITY_HIDDEN == vis->mVisible) + || (NS_STYLE_OVERFLOW_VISIBLE == display->mOverflow + && (kidState & NS_FRAME_OUTSIDE_CHILDREN) != 0)) { + viewHasTransparentContent = PR_TRUE; + } + } + + // If the frame has visible content that overflows the content area, then we + // need the view marked as having transparent content + + // There are two types of clipping: + // - 'clip' which only applies to absolutely positioned elements, and is + // relative to the element's border edge. 'clip' applies to the entire + // element + // - 'overflow-clip' which only applies to block-level elements and replaced + // elements that have 'overflow' set to 'hidden'. 'overflow-clip' is relative + // to the content area and applies to content only (not border or background). + // Note that out-of-flow frames like floated or absolutely positioned frames + // are block-level, but we can't rely on the 'display' value being set correctly + // in the style context... + PRBool isBlockLevel = display->IsBlockLevel() || (kidState & NS_FRAME_OUT_OF_FLOW); + PRBool hasClip = display->IsAbsolutelyPositioned() && (display->mClipFlags & NS_STYLE_CLIP_RECT); + PRBool hasOverflowClip = isBlockLevel && (display->mOverflow == NS_STYLE_OVERFLOW_HIDDEN); + if (hasClip || hasOverflowClip) { + nsSize frameSize; + aFrame->GetSize(frameSize); + nsRect clipRect; + + if (hasClip) { + // Start with the 'auto' values and then factor in user specified values + clipRect.SetRect(0, 0, frameSize.width, frameSize.height); + + if (display->mClipFlags & NS_STYLE_CLIP_RECT) { + if (0 == (NS_STYLE_CLIP_TOP_AUTO & display->mClipFlags)) { + clipRect.y = display->mClip.y; + } + if (0 == (NS_STYLE_CLIP_LEFT_AUTO & display->mClipFlags)) { + clipRect.x = display->mClip.x; + } + if (0 == (NS_STYLE_CLIP_RIGHT_AUTO & display->mClipFlags)) { + clipRect.width = display->mClip.width; + } + if (0 == (NS_STYLE_CLIP_BOTTOM_AUTO & display->mClipFlags)) { + clipRect.height = display->mClip.height; + } + } + } + + if (hasOverflowClip) { + const nsStyleBorder* borderStyle; + ::GetStyleData(aStyleContext, &borderStyle); + const nsStylePadding* paddingStyle; + ::GetStyleData(aStyleContext, &paddingStyle); + + nsMargin border, padding; + // XXX We don't support the 'overflow-clip' property yet so just use the + // content area (which is the default value) as the clip shape + nsRect overflowClipRect(0, 0, frameSize.width, frameSize.height); + borderStyle->GetBorder(border); + overflowClipRect.Deflate(border); + // XXX We need to handle percentage padding + if (paddingStyle->GetPadding(padding)) { + overflowClipRect.Deflate(padding); + } + + if (hasClip) { + // If both 'clip' and 'overflow-clip' apply then use the intersection + // of the two + clipRect.IntersectRect(clipRect, overflowClipRect); + } else { + clipRect = overflowClipRect; } - } else { - aView->GetBounds(newSize); - nscoord x, y; - aView->GetPosition(&x, &y); - newSize.x -= x; - newSize.y -= y; } - const nsStyleBackground* bg; - const nsStyleVisibility* vis; - const nsStyleDisplay* display; - PRBool isCanvas; - PRBool hasBG = - nsCSSRendering::FindBackground(aPresContext, aFrame, &bg, &isCanvas); - aFrame->GetStyleData(eStyleStruct_Visibility, (const nsStyleStruct*&)vis); - aFrame->GetStyleData(eStyleStruct_Display, (const nsStyleStruct*&)display); + nsRect newSize; + aView->GetBounds(newSize); + nscoord x, y; + aView->GetPosition(&x, &y); + newSize.x -= x; + newSize.y -= y; - // Set the view's opacity - vm->SetViewOpacity(aView, vis->mOpacity); + // If part of the view is being clipped out, then mark it transparent + if (clipRect.y > newSize.y + || clipRect.x > newSize.x + || clipRect.XMost() < newSize.XMost() + || clipRect.YMost() < newSize.YMost()) { + viewHasTransparentContent = PR_TRUE; + } + // Set clipping of child views. + nsRegion region; + region.Copy(nsRectFast(clipRect)); + vm->SetViewChildClipRegion(aView, ®ion); + } else { + // Remove clipping of child views. + vm->SetViewChildClipRegion(aView, nsnull); + } + + vm->SetViewContentTransparency(aView, viewHasTransparentContent); +} + +void +nsContainerFrame::SyncFrameViewAfterSizeChange(nsIPresContext* aPresContext, + nsIFrame* aFrame, + nsIStyleContext* aStyleContext, + nsIView* aView, + PRUint32 aFlags) +{ + if (!aView) { + return; + } + + nsCOMPtr savedStyleContext; + if (nsnull == aStyleContext) { + aFrame->GetStyleContext(getter_AddRefs(savedStyleContext)); + aStyleContext = savedStyleContext; + } + + const nsStyleDisplay* display; + ::GetStyleData(aStyleContext, &display); + nsFrameState kidState; + aFrame->GetFrameState(&kidState); + + PRBool isBlockLevel = display->IsBlockLevel() || (kidState & NS_FRAME_OUT_OF_FLOW); + PRBool hasClip = display->IsAbsolutelyPositioned() && (display->mClipFlags & NS_STYLE_CLIP_RECT); + PRBool hasOverflowClip = isBlockLevel && (display->mOverflow == NS_STYLE_OVERFLOW_HIDDEN); + if (hasClip || hasOverflowClip) { + SyncFrameViewGeometryDependentProperties(aPresContext, aFrame, aStyleContext, aView, aFlags); + } +} + +void +nsContainerFrame::SyncFrameViewProperties(nsIPresContext* aPresContext, + nsIFrame* aFrame, + nsIStyleContext* aStyleContext, + nsIView* aView, + PRUint32 aFlags) +{ + if (!aView) { + return; + } + + nsCOMPtr vm; + aView->GetViewManager(*getter_AddRefs(vm)); + + nsCOMPtr savedStyleContext; + if (nsnull == aStyleContext) { + aFrame->GetStyleContext(getter_AddRefs(savedStyleContext)); + aStyleContext = savedStyleContext; + } + + const nsStyleVisibility* vis; + ::GetStyleData(aStyleContext, &vis); + + // Set the view's opacity + vm->SetViewOpacity(aView, vis->mOpacity); + + // Make sure visibility is correct + if (0 == (aFlags & NS_FRAME_NO_VISIBILITY)) { // See if the view should be hidden or visible PRBool viewIsVisible = PR_TRUE; - PRBool viewHasTransparentContent = - (!hasBG || - (bg->mBackgroundFlags & NS_STYLE_BG_COLOR_TRANSPARENT) || - !aFrame->CanPaintBackground()); - if (isCanvas && viewHasTransparentContent) { - nsIView* rootView; - vm->GetRootView(rootView); - nsIView* rootParent; - rootView->GetParent(rootParent); - if (nsnull == rootParent) { - viewHasTransparentContent = PR_FALSE; - } - } if (NS_STYLE_VISIBILITY_COLLAPSE == vis->mVisible) { viewIsVisible = PR_FALSE; @@ -597,147 +786,106 @@ nsContainerFrame::SyncFrameViewAfterReflow(nsIPresContext* aPresContext, if (frameType == nsLayoutAtoms::scrollFrame || frameType == nsLayoutAtoms::listControlFrame) { viewIsVisible = PR_FALSE; - - } else { - // If we're a container element, then leave the view visible, but - // mark it as having transparent content. The reason we need to - // do this is that child elements can override their parent's - // hidden visibility and be visible anyway - nsIFrame* firstChild; - - aFrame->FirstChild(aPresContext, nsnull, &firstChild); - if (firstChild) { - // Not a left frame, so the view needs to be visible, but marked - // as having transparent content - viewHasTransparentContent = PR_TRUE; - } else { - // Leaf frame so go ahead and hide the view - viewIsVisible = PR_FALSE; - } } } - } - - // If the frame has visible content that overflows the content area, then we - // need the view marked as having transparent content - if (NS_STYLE_OVERFLOW_VISIBLE == display->mOverflow) { - if (kidState & NS_FRAME_OUTSIDE_CHILDREN) { - viewHasTransparentContent = PR_TRUE; - } - } - - // Make sure visibility is correct - if (0 == (aFlags & NS_FRAME_NO_VISIBILITY)) { - vm->SetViewVisibility(aView, viewIsVisible ? nsViewVisibility_kShow : - nsViewVisibility_kHide); - } - - // Make sure z-index is correct - PRInt32 zIndex = 0; - PRInt32 oldZIndex; - PRBool oldAutoZIndex; - PRBool oldTopMost; - PRBool autoZIndex = PR_FALSE; - const nsStylePosition* position; - - aView->GetZIndex(oldZIndex, oldAutoZIndex, oldTopMost); - - aFrame->GetStyleData(eStyleStruct_Position, (const nsStyleStruct*&)position); - if (position->mZIndex.GetUnit() == eStyleUnit_Integer) { - zIndex = position->mZIndex.GetIntValue(); - - } else if (position->mZIndex.GetUnit() == eStyleUnit_Auto) { - autoZIndex = PR_TRUE; - } - - vm->SetViewZIndex(aView, autoZIndex, zIndex, oldTopMost); - - // There are two types of clipping: - // - 'clip' which only applies to absolutely positioned elements, and is - // relative to the element's border edge. 'clip' applies to the entire - // element - // - 'overflow-clip' which only applies to block-level elements and replaced - // elements that have 'overflow' set to 'hidden'. 'overflow-clip' is relative - // to the content area and applies to content only (not border or background). - // Note that out-of-flow frames like floated or absolutely positioned frames - // are block-level, but we can't rely on the 'display' value being set correctly - // in the style context... - PRBool hasClip, hasOverflowClip; - PRBool isBlockLevel = display->IsBlockLevel() || (0 != (kidState & NS_FRAME_OUT_OF_FLOW)); - hasClip = display->IsAbsolutelyPositioned() && (display->mClipFlags & NS_STYLE_CLIP_RECT); - hasOverflowClip = isBlockLevel && (display->mOverflow == NS_STYLE_OVERFLOW_HIDDEN); - if (hasClip || hasOverflowClip) { - nsRect clipRect; - - if (hasClip) { - // Start with the 'auto' values and then factor in user specified values - clipRect.SetRect(0, 0, frameSize.width, frameSize.height); - - if (display->mClipFlags & NS_STYLE_CLIP_RECT) { - if (0 == (NS_STYLE_CLIP_TOP_AUTO & display->mClipFlags)) { - clipRect.y = display->mClip.y; - } - if (0 == (NS_STYLE_CLIP_LEFT_AUTO & display->mClipFlags)) { - clipRect.x = display->mClip.x; - } - if (0 == (NS_STYLE_CLIP_RIGHT_AUTO & display->mClipFlags)) { - clipRect.width = display->mClip.width; - } - if (0 == (NS_STYLE_CLIP_BOTTOM_AUTO & display->mClipFlags)) { - clipRect.height = display->mClip.height; - } - } - } - - if (hasOverflowClip) { - const nsStyleBorder* borderStyle; - const nsStylePadding* paddingStyle; - nsMargin border, padding; - - aFrame->GetStyleData(eStyleStruct_Border, (const nsStyleStruct*&)borderStyle); - aFrame->GetStyleData(eStyleStruct_Padding, (const nsStyleStruct*&)paddingStyle); - - // XXX We don't support the 'overflow-clip' property yet so just use the - // content area (which is the default value) as the clip shape - nsRect overflowClipRect(0, 0, frameSize.width, frameSize.height); - borderStyle->GetBorder(border); - overflowClipRect.Deflate(border); - // XXX We need to handle percentage padding - if (paddingStyle->GetPadding(padding)) { - overflowClipRect.Deflate(padding); - } - - if (hasClip) { - // If both 'clip' and 'overflow-clip' apply then use the intersection - // of the two - clipRect.IntersectRect(clipRect, overflowClipRect); - } else { - clipRect = overflowClipRect; - } - } - - // If part of the view is being clipped out, then mark it transparent - if (clipRect.y > newSize.y - || clipRect.x > newSize.x - || clipRect.XMost() < newSize.XMost() - || clipRect.YMost() < newSize.YMost()) { - viewHasTransparentContent = PR_TRUE; - } - - // Set clipping of child views. - nsRegion region; - region.Copy(clipRect); - vm->SetViewChildClipRegion(aView, ®ion); } else { - // Remove clipping of child views. - vm->SetViewChildClipRegion(aView, nsnull); + // if the view is for a popup, don't show the view if the popup is closed + nsCOMPtr widget; + aView->GetWidget(*getter_AddRefs(widget)); + if (widget) { + nsWindowType windowType; + widget->GetWindowType(windowType); + if (windowType == eWindowType_popup) { + widget->IsVisible(viewIsVisible); + } + } } - // Make sure content transparency is correct - if (viewIsVisible) { - vm->SetViewContentTransparency(aView, viewHasTransparentContent); + vm->SetViewVisibility(aView, viewIsVisible ? nsViewVisibility_kShow : + nsViewVisibility_kHide); + } + + const nsStyleDisplay* display; + ::GetStyleData(aStyleContext, &display); + // See if the frame is being relatively positioned or absolutely + // positioned + PRBool isTopMostView = display->IsPositioned(); + + // Make sure z-index is correct + const nsStylePosition* position; + ::GetStyleData(aStyleContext, &position); + + PRInt32 zIndex = 0; + PRBool autoZIndex = PR_FALSE; + + if (position->mZIndex.GetUnit() == eStyleUnit_Integer) { + zIndex = position->mZIndex.GetIntValue(); + } else if (position->mZIndex.GetUnit() == eStyleUnit_Auto) { + autoZIndex = PR_TRUE; + } + + vm->SetViewZIndex(aView, autoZIndex, zIndex, isTopMostView); + + SyncFrameViewGeometryDependentProperties(aPresContext, aFrame, aStyleContext, aView, aFlags); +} + +PRBool +nsContainerFrame::FrameNeedsView(nsIPresContext* aPresContext, + nsIFrame* aFrame, + nsIStyleContext* aStyleContext) +{ + const nsStyleVisibility* vis; + ::GetStyleData(aStyleContext, &vis); + + if (vis->mOpacity != 1.0f) { + return PR_TRUE; + } + + // See if the frame has a fixed background attachment + const nsStyleBackground *color; + PRBool isCanvas; + PRBool hasBackground = + nsCSSRendering::FindBackground(aPresContext, aFrame, &color, &isCanvas); + if (hasBackground && + NS_STYLE_BG_ATTACHMENT_FIXED == color->mBackgroundAttachment) { + return PR_TRUE; + } + + const nsStyleDisplay* display; + ::GetStyleData(aStyleContext, &display); + + if (NS_STYLE_POSITION_RELATIVE == display->mPosition) { + return PR_TRUE; + } else if (display->IsAbsolutelyPositioned()) { + return PR_TRUE; + } + + nsCOMPtr pseudoTag; + aStyleContext->GetPseudoType(*getter_AddRefs(pseudoTag)); + if (pseudoTag == nsLayoutAtoms::scrolledContentPseudo) { + return PR_TRUE; + } + + // See if the frame is block-level and has 'overflow' set to 'hidden'. If + // so, then we need to give it a view so clipping + // of any child views works correctly. Note that if it's floated it is also + // block-level, but we can't trust that the style context 'display' value is + // set correctly + if ((display->IsBlockLevel() || display->IsFloating()) && + (display->mOverflow == NS_STYLE_OVERFLOW_HIDDEN)) { + // XXX Check for the frame being a block frame and only force a view + // in that case, because adding a view for box frames seems to cause + // problems for XUL... + nsCOMPtr frameType; + + aFrame->GetFrameType(getter_AddRefs(frameType)); + if ((frameType == nsLayoutAtoms::blockFrame) || + (frameType == nsLayoutAtoms::areaFrame)) { + return PR_TRUE; } } + + return PR_FALSE; } /** diff --git a/layout/generic/nsContainerFrame.h b/layout/generic/nsContainerFrame.h index c398fdbb8cc..fc05068ac63 100644 --- a/layout/generic/nsContainerFrame.h +++ b/layout/generic/nsContainerFrame.h @@ -100,14 +100,7 @@ public: static void PositionFrameView(nsIPresContext* aPresContext, nsIFrame* aKidFrame); - // Sets several view attributes: - // - if requested sizes the frame's view based on the current size and origin. - // Takes into account the combined area and (if overflow is visible) whether - // the frame has children that extend outside - // - opacity - // - visibility - // - content transparency - // - clip + // Set the view's size and position after its frame has been reflowed. // // Flags: // NS_FRAME_NO_MOVE_VIEW - don't position the frame's view. Set this if you @@ -119,6 +112,34 @@ public: const nsRect* aCombinedArea, PRUint32 aFlags = 0); + // Sets view attributes from the frame style that depend on the view's size + // (clip, transparency). This needs to be called if you change the size of + // a view and the view's frame could have clipping set on it. + // @param aStyleContext can be null, in which case the frame's style context is used + static void SyncFrameViewAfterSizeChange(nsIPresContext* aPresContext, + nsIFrame* aFrame, + nsIStyleContext* aStyleContext, + nsIView* aView, + PRUint32 aFlags = 0); + + // Sets the view's attributes from the frame style. + // - opacity + // - visibility + // - content transparency + // - clip + // Call this when one of these styles changes or when the view has just + // been created. + // @param aStyleContext can be null, in which case the frame's style context is used + static void SyncFrameViewProperties(nsIPresContext* aPresContext, + nsIFrame* aFrame, + nsIStyleContext* aStyleContext, + nsIView* aView, + PRUint32 aFlags = 0); + + // Returns PR_TRUE if the frame requires a view + static PRBool FrameNeedsView(nsIPresContext* aPresContext, + nsIFrame* aFrame, nsIStyleContext* aStyleContext); + /** * Invokes the WillReflow() function, positions the frame and its view (if * requested), and then calls Reflow(). If the reflow succeeds and the child diff --git a/layout/generic/nsHTMLContainerFrame.cpp b/layout/generic/nsHTMLContainerFrame.cpp index 9b84b7f13a0..44e73d6f2d8 100644 --- a/layout/generic/nsHTMLContainerFrame.cpp +++ b/layout/generic/nsHTMLContainerFrame.cpp @@ -427,21 +427,6 @@ nsHTMLContainerFrame::ReparentFrameViewList(nsIPresContext* aPresContext, return NS_OK; } -static PRBool -IsContainerContent(nsIFrame* aFrame) -{ - nsIContent* content; - PRBool result = PR_FALSE; - - aFrame->GetContent(&content); - if (content) { - content->CanContainChildren(result); - NS_RELEASE(content); - } - - return result; -} - nsresult nsHTMLContainerFrame::CreateViewForFrame(nsIPresContext* aPresContext, nsIFrame* aFrame, @@ -449,244 +434,92 @@ nsHTMLContainerFrame::CreateViewForFrame(nsIPresContext* aPresContext, nsIFrame* aContentParentFrame, PRBool aForce) { - PRBool isTopMostView = PR_FALSE; nsIView* view; aFrame->GetView(aPresContext, &view); + if (nsnull != view) { + return NS_OK; + } + // If we don't yet have a view, see if we need a view - if (nsnull == view) { - PRBool fixedBackgroundAttachment = PR_FALSE; + if (!(aForce || FrameNeedsView(aPresContext, aFrame, aStyleContext))) { + // don't need a view + return NS_OK; + } - // Get nsStyleColor and nsStyleDisplay - const nsStyleDisplay* display = (const nsStyleDisplay*) - aStyleContext->GetStyleData(eStyleStruct_Display); - const nsStylePosition* position = (const nsStylePosition*) - aStyleContext->GetStyleData(eStyleStruct_Position); - const nsStyleVisibility* vis = (const nsStyleVisibility*) - aStyleContext->GetStyleData(eStyleStruct_Visibility); + // Create a view + nsIFrame* parent = nsnull; + aFrame->GetParentWithView(aPresContext, &parent); + NS_ASSERTION(parent, "GetParentWithView failed"); + + nsIView* parentView = nsnull; + parent->GetView(aPresContext, &parentView); + NS_ASSERTION(parentView, "no parent with view"); + + // Create a view + static NS_DEFINE_CID(kViewCID, NS_VIEW_CID); + nsresult result = CallCreateInstance(kViewCID, &view); + if (NS_FAILED(result)) { + return result; + } - if (vis->mOpacity != 1.0f) { - NS_FRAME_LOG(NS_FRAME_TRACE_CALLS, - ("nsHTMLContainerFrame::CreateViewForFrame: frame=%p opacity=%g", - aFrame, vis->mOpacity)); - aForce = PR_TRUE; - } - - // See if the frame has a fixed background attachment - const nsStyleBackground *color; - PRBool isCanvas; - PRBool hasBackground = - nsCSSRendering::FindBackground(aPresContext, aFrame, &color, &isCanvas); - if (hasBackground && - NS_STYLE_BG_ATTACHMENT_FIXED == color->mBackgroundAttachment) { - aForce = PR_TRUE; - fixedBackgroundAttachment = PR_TRUE; - } + nsCOMPtr viewManager; + parentView->GetViewManager(*getter_AddRefs(viewManager)); + NS_ASSERTION(nsnull != viewManager, "null view manager"); - // See if the frame is being relatively positioned or absolutely - // positioned - if (!aForce) { - if (NS_STYLE_POSITION_RELATIVE == display->mPosition) { - NS_FRAME_LOG(NS_FRAME_TRACE_CALLS, - ("nsHTMLContainerFrame::CreateViewForFrame: frame=%p relatively positioned", - aFrame)); - aForce = PR_TRUE; - isTopMostView = PR_TRUE; - } else if (display->IsAbsolutelyPositioned()) { - NS_FRAME_LOG(NS_FRAME_TRACE_CALLS, - ("nsHTMLContainerFrame::CreateViewForFrame: frame=%p absolutely positioned", - aFrame)); - aForce = PR_TRUE; - isTopMostView = PR_TRUE; - } - } + // Initialize the view + nsRect bounds; + aFrame->GetRect(bounds); + view->Init(viewManager, bounds, parentView); - if (NS_STYLE_POSITION_FIXED == display->mPosition) { - isTopMostView = PR_TRUE; - } + SyncFrameViewProperties(aPresContext, aFrame, aStyleContext, view); - // See if the frame is a scrolled frame - if (!aForce) { - nsIAtom* pseudoTag; - aStyleContext->GetPseudoType(pseudoTag); - if (pseudoTag == nsLayoutAtoms::scrolledContentPseudo) { - NS_FRAME_LOG(NS_FRAME_TRACE_CALLS, - ("nsHTMLContainerFrame::CreateViewForFrame: scrolled frame=%p", aFrame)); - aForce = PR_TRUE; - } - NS_IF_RELEASE(pseudoTag); - } + // Insert the view into the view hierarchy. If the parent view is a + // scrolling view we need to do this differently + nsIScrollableView* scrollingView; + if (NS_SUCCEEDED(CallQueryInterface(parentView, &scrollingView))) { + scrollingView->SetScrolledView(view); + } else { + // XXX Drop it at the end of the document order until we can do better + viewManager->InsertChild(parentView, view, nsnull, PR_TRUE); - // See if the frame is block-level and has 'overflow' set to 'hidden'. If - // so and it can have child frames, then we need to give it a view so clipping - // of any child views works correctly. Note that if it's floated it is also - // block-level, but we can't trust that the style context 'display' value is - // set correctly - if (!aForce) { - if ((display->IsBlockLevel() || display->IsFloating()) && - (display->mOverflow == NS_STYLE_OVERFLOW_HIDDEN)) { - - // The reason for the check of whether it can contain children is just - // to avoid giving it a view unnecessarily - if (::IsContainerContent(aFrame)) { - // XXX Check for the frame being a block frame and only force a view - // in that case, because adding a view for box frames seems to cause - // problems for XUL... - nsIAtom* frameType; - - aFrame->GetFrameType(&frameType); - if ((frameType == nsLayoutAtoms::blockFrame) || - (frameType == nsLayoutAtoms::areaFrame)) { - aForce = PR_TRUE; - } - NS_IF_RELEASE(frameType); - } - } - } - - if (aForce) { - // Create a view - nsIFrame* parent = nsnull; - nsIView* parentView = nsnull; - - aFrame->GetParentWithView(aPresContext, &parent); - NS_ASSERTION(parent, "GetParentWithView failed"); - parent->GetView(aPresContext, &parentView); - NS_ASSERTION(parentView, "no parent with view"); - - // Create a view - static NS_DEFINE_CID(kViewCID, NS_VIEW_CID); - - nsresult result = nsComponentManager::CreateInstance(kViewCID, - nsnull, - NS_GET_IID(nsIView), - (void **)&view); - if (NS_OK == result) { - nsIViewManager* viewManager; - parentView->GetViewManager(viewManager); - NS_ASSERTION(nsnull != viewManager, "null view manager"); - - // Initialize the view - nsRect bounds; - aFrame->GetRect(bounds); - view->Init(viewManager, bounds, parentView); - - // If the frame has a fixed background attachment, then indicate that the - // view's contents should be repainted and not bitblt'd - if (fixedBackgroundAttachment) { - viewManager->SetViewBitBltEnabled(view, PR_FALSE); - } + if (nsnull != aContentParentFrame) { + // If, for some reason, GetView below fails to initialize zParentView, + // then ensure that we completely bypass InsertZPlaceholder below. + // The effect will be as if we never knew about aContentParentFrame + // in the first place, so at least this code won't be doing any damage. + nsIView* zParentView = parentView; + + aContentParentFrame->GetView(aPresContext, &zParentView); + + if (nsnull == zParentView) { + nsIFrame* zParentFrame = nsnull; - // Insert the view into the view hierarchy. If the parent view is a - // scrolling view we need to do this differently - nsIScrollableView* scrollingView; - if (NS_SUCCEEDED(parentView->QueryInterface(NS_GET_IID(nsIScrollableView), (void**)&scrollingView))) { - scrollingView->SetScrolledView(view); - } else { - PRInt32 zIndex = 0; - PRBool autoZIndex = PR_FALSE; - - // Get the z-index to use - if (position->mZIndex.GetUnit() == eStyleUnit_Integer) { - zIndex = position->mZIndex.GetIntValue(); - } else if (position->mZIndex.GetUnit() == eStyleUnit_Auto) { - autoZIndex = PR_TRUE; - } - - viewManager->SetViewZIndex(view, autoZIndex, zIndex, isTopMostView); - // XXX Drop it at the end of the document order until we can do better - viewManager->InsertChild(parentView, view, nsnull, PR_TRUE); - - if (nsnull != aContentParentFrame) { - // If, for some reason, GetView below fails to initialize zParentView, - // then ensure that we completely bypass InsertZPlaceholder below. - // The effect will be as if we never knew about aContentParentFrame - // in the first place, so at least this code won't be doing any damage. - nsIView* zParentView = parentView; - - aContentParentFrame->GetView(aPresContext, &zParentView); - - if (nsnull == zParentView) { - nsIFrame* zParentFrame = nsnull; - - aContentParentFrame->GetParentWithView(aPresContext, &zParentFrame); - NS_ASSERTION(zParentFrame, "GetParentWithView failed"); - zParentFrame->GetView(aPresContext, &zParentView); - NS_ASSERTION(zParentView, "no parent with view"); - } - - if (zParentView != parentView) { - viewManager->InsertZPlaceholder(zParentView, view, nsnull, PR_TRUE); - } - } - } - - // See if the view should be hidden - PRBool viewIsVisible = PR_TRUE; - PRBool viewHasTransparentContent = - !isCanvas && - (!hasBackground || - (color->mBackgroundFlags & NS_STYLE_BG_COLOR_TRANSPARENT)); - - - if (NS_STYLE_VISIBILITY_COLLAPSE == vis->mVisible) { - viewIsVisible = PR_FALSE; - } - else if (NS_STYLE_VISIBILITY_HIDDEN == vis->mVisible) { - // If it has a widget, hide the view because the widget can't deal with it - nsIWidget* widget = nsnull; - view->GetWidget(widget); - if (widget) { - viewIsVisible = PR_FALSE; - NS_RELEASE(widget); - } - else { - // If it's a container element, then leave the view visible, but - // mark it as having transparent content. The reason we need to - // do this is that child elements can override their parent's - // hidden visibility and be visible anyway. - // - // Because this function is called before processing the content - // object's child elements, we can't tell if it's a leaf by looking - // at whether the frame has any child frames - if (::IsContainerContent(aFrame)) { - // The view needs to be visible, but marked as having transparent - // content - viewHasTransparentContent = PR_TRUE; - } else { - // Go ahead and hide the view - viewIsVisible = PR_FALSE; - } - } - } - - if (viewIsVisible) { - if (viewHasTransparentContent) { - viewManager->SetViewContentTransparency(view, PR_TRUE); - } - - } else { - viewManager->SetViewVisibility(view, nsViewVisibility_kHide); - } - - // XXX If it's fixed positioned, then create a widget so it floats - // above the scrolling area - if (NS_STYLE_POSITION_FIXED == display->mPosition) { - view->CreateWidget(kCChildCID); - } - - viewManager->SetViewOpacity(view, vis->mOpacity); - NS_RELEASE(viewManager); + aContentParentFrame->GetParentWithView(aPresContext, &zParentFrame); + NS_ASSERTION(zParentFrame, "GetParentWithView failed"); + zParentFrame->GetView(aPresContext, &zParentView); + NS_ASSERTION(zParentView, "no parent with view"); + } + + if (zParentView != parentView) { + viewManager->InsertZPlaceholder(zParentView, view, nsnull, PR_TRUE); } - - // Remember our view - aFrame->SetView(aPresContext, view); - - NS_FRAME_LOG(NS_FRAME_TRACE_CALLS, - ("nsHTMLContainerFrame::CreateViewForFrame: frame=%p view=%p", - aFrame)); - return result; } } + + // XXX If it's fixed positioned, then create a widget so it floats + // above the scrolling area + const nsStyleDisplay* display; + ::GetStyleData(aStyleContext, &display); + if (NS_STYLE_POSITION_FIXED == display->mPosition) { + view->CreateWidget(kCChildCID); + } + + // Remember our view + aFrame->SetView(aPresContext, view); + + NS_FRAME_LOG(NS_FRAME_TRACE_CALLS, + ("nsHTMLContainerFrame::CreateViewForFrame: frame=%p view=%p", + aFrame)); return NS_OK; } diff --git a/layout/html/base/src/nsContainerFrame.cpp b/layout/html/base/src/nsContainerFrame.cpp index ce856f5a7e3..95f4d86f089 100644 --- a/layout/html/base/src/nsContainerFrame.cpp +++ b/layout/html/base/src/nsContainerFrame.cpp @@ -504,77 +504,266 @@ nsContainerFrame::SyncFrameViewAfterReflow(nsIPresContext* aPresContext, const nsRect* aCombinedArea, PRUint32 aFlags) { - if (aView) { + if (!aView) { + return; + } + + // Make sure the view is sized and positioned correctly + if (0 == (aFlags & NS_FRAME_NO_MOVE_VIEW)) { + PositionFrameView(aPresContext, aFrame); + } + + if (0 == (aFlags & NS_FRAME_NO_SIZE_VIEW)) { nsCOMPtr vm; - nsFrameState kidState; - nsSize frameSize; - aView->GetViewManager(*getter_AddRefs(vm)); + nsRect oldBounds; + aView->GetBounds(oldBounds); + nsFrameState kidState; aFrame->GetFrameState(&kidState); - aFrame->GetSize(frameSize); - - // Make sure the view is sized and positioned correctly - if (0 == (aFlags & NS_FRAME_NO_MOVE_VIEW)) { - PositionFrameView(aPresContext, aFrame); + + // If the frame has child frames that stick outside the content + // area, then size the view large enough to include those child + // frames + if ((kidState & NS_FRAME_OUTSIDE_CHILDREN) && aCombinedArea) { + vm->ResizeView(aView, *aCombinedArea); + } else { + // If the width is unchanged and the height is not decreased then repaint only the + // newly exposed or contracted area, otherwise repaint the union of the old and new areas + + // XXX: We currently invalidate the newly exposed areas only when the + // container frame's width is unchanged and the height is either unchanged or increased + // This is because some frames do not invalidate themselves properly. see bug 73825. + // Once bug 73825 is fixed, we should always pass PR_TRUE instead of + // frameSize.width == width && frameSize.height >= height. + nsSize frameSize; + aFrame->GetSize(frameSize); + nsRect newSize(0, 0, frameSize.width, frameSize.height); + vm->ResizeView(aView, newSize, + (frameSize.width == oldBounds.width && frameSize.height >= oldBounds.height)); } - nsRect newSize(0, 0, frameSize.width, frameSize.height); - if (0 == (aFlags & NS_FRAME_NO_SIZE_VIEW)) { - // If the frame has child frames that stick outside the content - // area, then size the view large enough to include those child - // frames - if ((kidState & NS_FRAME_OUTSIDE_CHILDREN) && aCombinedArea) { - vm->ResizeView(aView, *aCombinedArea); - newSize = *aCombinedArea; - } else { - nsRect bounds; - aView->GetBounds(bounds); - // If the width is unchanged and the height is not decreased then repaint only the - // newly exposed or contracted area, otherwise repaint the union of the old and new areas + nsRect newBounds; + aView->GetBounds(newBounds); - // XXX: We currently invalidate the newly exposed areas only when the - // container frame's width is unchanged and the height is either unchanged or increased - // This is because some frames do not invalidate themselves properly. see bug 73825. - // Once bug 73825 is fixed, we should always pass PR_TRUE instead of - // frameSize.width == width && frameSize.height >= height. - vm->ResizeView(aView, newSize, - (frameSize.width == bounds.width && frameSize.height >= bounds.height)); + // if the bounds have changed and clipping is enabled, we need to update the clip area + // and also possibly the transparency (in case the view grew bigger than the clip area + // so clipping is now cutting out part of the view) + if (oldBounds != newBounds) { + SyncFrameViewAfterSizeChange(aPresContext, aFrame, nsnull, aView, aFlags); + } + } +} + +static void +SyncFrameViewGeometryDependentProperties(nsIPresContext* aPresContext, + nsIFrame* aFrame, + nsIStyleContext* aStyleContext, + nsIView* aView, + PRUint32 aFlags) +{ + nsCOMPtr vm; + aView->GetViewManager(*getter_AddRefs(vm)); + + PRBool isCanvas; + const nsStyleBackground* bg; + PRBool hasBG = + nsCSSRendering::FindBackground(aPresContext, aFrame, &bg, &isCanvas); + + // background-attachment: fixed is not really geometry dependent, but + // we set it here because it's cheap to do so + PRBool fixedBackground = hasBG && + NS_STYLE_BG_ATTACHMENT_FIXED == bg->mBackgroundAttachment; + // If the frame has a fixed background attachment, then indicate that the + // view's contents should be repainted and not bitblt'd + vm->SetViewBitBltEnabled(aView, !fixedBackground); + + PRBool viewHasTransparentContent = + !hasBG || + (bg->mBackgroundFlags & NS_STYLE_BG_COLOR_TRANSPARENT) || + !aFrame->CanPaintBackground(); + if (isCanvas && viewHasTransparentContent) { + nsIView* rootView; + vm->GetRootView(rootView); + nsIView* rootParent; + rootView->GetParent(rootParent); + if (nsnull == rootParent) { + viewHasTransparentContent = PR_FALSE; + } + } + + const nsStyleDisplay* display; + ::GetStyleData(aStyleContext, &display); + nsFrameState kidState; + aFrame->GetFrameState(&kidState); + + if (!viewHasTransparentContent) { + // If we're showing the view but the frame is hidden, then the view is transparent + nsViewVisibility visibility; + aView->GetVisibility(visibility); + const nsStyleVisibility* vis; + ::GetStyleData(aStyleContext, &vis); + if ((nsViewVisibility_kShow == visibility + && NS_STYLE_VISIBILITY_HIDDEN == vis->mVisible) + || (NS_STYLE_OVERFLOW_VISIBLE == display->mOverflow + && (kidState & NS_FRAME_OUTSIDE_CHILDREN) != 0)) { + viewHasTransparentContent = PR_TRUE; + } + } + + // If the frame has visible content that overflows the content area, then we + // need the view marked as having transparent content + + // There are two types of clipping: + // - 'clip' which only applies to absolutely positioned elements, and is + // relative to the element's border edge. 'clip' applies to the entire + // element + // - 'overflow-clip' which only applies to block-level elements and replaced + // elements that have 'overflow' set to 'hidden'. 'overflow-clip' is relative + // to the content area and applies to content only (not border or background). + // Note that out-of-flow frames like floated or absolutely positioned frames + // are block-level, but we can't rely on the 'display' value being set correctly + // in the style context... + PRBool isBlockLevel = display->IsBlockLevel() || (kidState & NS_FRAME_OUT_OF_FLOW); + PRBool hasClip = display->IsAbsolutelyPositioned() && (display->mClipFlags & NS_STYLE_CLIP_RECT); + PRBool hasOverflowClip = isBlockLevel && (display->mOverflow == NS_STYLE_OVERFLOW_HIDDEN); + if (hasClip || hasOverflowClip) { + nsSize frameSize; + aFrame->GetSize(frameSize); + nsRect clipRect; + + if (hasClip) { + // Start with the 'auto' values and then factor in user specified values + clipRect.SetRect(0, 0, frameSize.width, frameSize.height); + + if (display->mClipFlags & NS_STYLE_CLIP_RECT) { + if (0 == (NS_STYLE_CLIP_TOP_AUTO & display->mClipFlags)) { + clipRect.y = display->mClip.y; + } + if (0 == (NS_STYLE_CLIP_LEFT_AUTO & display->mClipFlags)) { + clipRect.x = display->mClip.x; + } + if (0 == (NS_STYLE_CLIP_RIGHT_AUTO & display->mClipFlags)) { + clipRect.width = display->mClip.width; + } + if (0 == (NS_STYLE_CLIP_BOTTOM_AUTO & display->mClipFlags)) { + clipRect.height = display->mClip.height; + } + } + } + + if (hasOverflowClip) { + const nsStyleBorder* borderStyle; + ::GetStyleData(aStyleContext, &borderStyle); + const nsStylePadding* paddingStyle; + ::GetStyleData(aStyleContext, &paddingStyle); + + nsMargin border, padding; + // XXX We don't support the 'overflow-clip' property yet so just use the + // content area (which is the default value) as the clip shape + nsRect overflowClipRect(0, 0, frameSize.width, frameSize.height); + borderStyle->GetBorder(border); + overflowClipRect.Deflate(border); + // XXX We need to handle percentage padding + if (paddingStyle->GetPadding(padding)) { + overflowClipRect.Deflate(padding); + } + + if (hasClip) { + // If both 'clip' and 'overflow-clip' apply then use the intersection + // of the two + clipRect.IntersectRect(clipRect, overflowClipRect); + } else { + clipRect = overflowClipRect; } - } else { - aView->GetBounds(newSize); - nscoord x, y; - aView->GetPosition(&x, &y); - newSize.x -= x; - newSize.y -= y; } - const nsStyleBackground* bg; - const nsStyleVisibility* vis; - const nsStyleDisplay* display; - PRBool isCanvas; - PRBool hasBG = - nsCSSRendering::FindBackground(aPresContext, aFrame, &bg, &isCanvas); - aFrame->GetStyleData(eStyleStruct_Visibility, (const nsStyleStruct*&)vis); - aFrame->GetStyleData(eStyleStruct_Display, (const nsStyleStruct*&)display); + nsRect newSize; + aView->GetBounds(newSize); + nscoord x, y; + aView->GetPosition(&x, &y); + newSize.x -= x; + newSize.y -= y; - // Set the view's opacity - vm->SetViewOpacity(aView, vis->mOpacity); + // If part of the view is being clipped out, then mark it transparent + if (clipRect.y > newSize.y + || clipRect.x > newSize.x + || clipRect.XMost() < newSize.XMost() + || clipRect.YMost() < newSize.YMost()) { + viewHasTransparentContent = PR_TRUE; + } + // Set clipping of child views. + nsRegion region; + region.Copy(nsRectFast(clipRect)); + vm->SetViewChildClipRegion(aView, ®ion); + } else { + // Remove clipping of child views. + vm->SetViewChildClipRegion(aView, nsnull); + } + + vm->SetViewContentTransparency(aView, viewHasTransparentContent); +} + +void +nsContainerFrame::SyncFrameViewAfterSizeChange(nsIPresContext* aPresContext, + nsIFrame* aFrame, + nsIStyleContext* aStyleContext, + nsIView* aView, + PRUint32 aFlags) +{ + if (!aView) { + return; + } + + nsCOMPtr savedStyleContext; + if (nsnull == aStyleContext) { + aFrame->GetStyleContext(getter_AddRefs(savedStyleContext)); + aStyleContext = savedStyleContext; + } + + const nsStyleDisplay* display; + ::GetStyleData(aStyleContext, &display); + nsFrameState kidState; + aFrame->GetFrameState(&kidState); + + PRBool isBlockLevel = display->IsBlockLevel() || (kidState & NS_FRAME_OUT_OF_FLOW); + PRBool hasClip = display->IsAbsolutelyPositioned() && (display->mClipFlags & NS_STYLE_CLIP_RECT); + PRBool hasOverflowClip = isBlockLevel && (display->mOverflow == NS_STYLE_OVERFLOW_HIDDEN); + if (hasClip || hasOverflowClip) { + SyncFrameViewGeometryDependentProperties(aPresContext, aFrame, aStyleContext, aView, aFlags); + } +} + +void +nsContainerFrame::SyncFrameViewProperties(nsIPresContext* aPresContext, + nsIFrame* aFrame, + nsIStyleContext* aStyleContext, + nsIView* aView, + PRUint32 aFlags) +{ + if (!aView) { + return; + } + + nsCOMPtr vm; + aView->GetViewManager(*getter_AddRefs(vm)); + + nsCOMPtr savedStyleContext; + if (nsnull == aStyleContext) { + aFrame->GetStyleContext(getter_AddRefs(savedStyleContext)); + aStyleContext = savedStyleContext; + } + + const nsStyleVisibility* vis; + ::GetStyleData(aStyleContext, &vis); + + // Set the view's opacity + vm->SetViewOpacity(aView, vis->mOpacity); + + // Make sure visibility is correct + if (0 == (aFlags & NS_FRAME_NO_VISIBILITY)) { // See if the view should be hidden or visible PRBool viewIsVisible = PR_TRUE; - PRBool viewHasTransparentContent = - (!hasBG || - (bg->mBackgroundFlags & NS_STYLE_BG_COLOR_TRANSPARENT) || - !aFrame->CanPaintBackground()); - if (isCanvas && viewHasTransparentContent) { - nsIView* rootView; - vm->GetRootView(rootView); - nsIView* rootParent; - rootView->GetParent(rootParent); - if (nsnull == rootParent) { - viewHasTransparentContent = PR_FALSE; - } - } if (NS_STYLE_VISIBILITY_COLLAPSE == vis->mVisible) { viewIsVisible = PR_FALSE; @@ -597,147 +786,106 @@ nsContainerFrame::SyncFrameViewAfterReflow(nsIPresContext* aPresContext, if (frameType == nsLayoutAtoms::scrollFrame || frameType == nsLayoutAtoms::listControlFrame) { viewIsVisible = PR_FALSE; - - } else { - // If we're a container element, then leave the view visible, but - // mark it as having transparent content. The reason we need to - // do this is that child elements can override their parent's - // hidden visibility and be visible anyway - nsIFrame* firstChild; - - aFrame->FirstChild(aPresContext, nsnull, &firstChild); - if (firstChild) { - // Not a left frame, so the view needs to be visible, but marked - // as having transparent content - viewHasTransparentContent = PR_TRUE; - } else { - // Leaf frame so go ahead and hide the view - viewIsVisible = PR_FALSE; - } } } - } - - // If the frame has visible content that overflows the content area, then we - // need the view marked as having transparent content - if (NS_STYLE_OVERFLOW_VISIBLE == display->mOverflow) { - if (kidState & NS_FRAME_OUTSIDE_CHILDREN) { - viewHasTransparentContent = PR_TRUE; - } - } - - // Make sure visibility is correct - if (0 == (aFlags & NS_FRAME_NO_VISIBILITY)) { - vm->SetViewVisibility(aView, viewIsVisible ? nsViewVisibility_kShow : - nsViewVisibility_kHide); - } - - // Make sure z-index is correct - PRInt32 zIndex = 0; - PRInt32 oldZIndex; - PRBool oldAutoZIndex; - PRBool oldTopMost; - PRBool autoZIndex = PR_FALSE; - const nsStylePosition* position; - - aView->GetZIndex(oldZIndex, oldAutoZIndex, oldTopMost); - - aFrame->GetStyleData(eStyleStruct_Position, (const nsStyleStruct*&)position); - if (position->mZIndex.GetUnit() == eStyleUnit_Integer) { - zIndex = position->mZIndex.GetIntValue(); - - } else if (position->mZIndex.GetUnit() == eStyleUnit_Auto) { - autoZIndex = PR_TRUE; - } - - vm->SetViewZIndex(aView, autoZIndex, zIndex, oldTopMost); - - // There are two types of clipping: - // - 'clip' which only applies to absolutely positioned elements, and is - // relative to the element's border edge. 'clip' applies to the entire - // element - // - 'overflow-clip' which only applies to block-level elements and replaced - // elements that have 'overflow' set to 'hidden'. 'overflow-clip' is relative - // to the content area and applies to content only (not border or background). - // Note that out-of-flow frames like floated or absolutely positioned frames - // are block-level, but we can't rely on the 'display' value being set correctly - // in the style context... - PRBool hasClip, hasOverflowClip; - PRBool isBlockLevel = display->IsBlockLevel() || (0 != (kidState & NS_FRAME_OUT_OF_FLOW)); - hasClip = display->IsAbsolutelyPositioned() && (display->mClipFlags & NS_STYLE_CLIP_RECT); - hasOverflowClip = isBlockLevel && (display->mOverflow == NS_STYLE_OVERFLOW_HIDDEN); - if (hasClip || hasOverflowClip) { - nsRect clipRect; - - if (hasClip) { - // Start with the 'auto' values and then factor in user specified values - clipRect.SetRect(0, 0, frameSize.width, frameSize.height); - - if (display->mClipFlags & NS_STYLE_CLIP_RECT) { - if (0 == (NS_STYLE_CLIP_TOP_AUTO & display->mClipFlags)) { - clipRect.y = display->mClip.y; - } - if (0 == (NS_STYLE_CLIP_LEFT_AUTO & display->mClipFlags)) { - clipRect.x = display->mClip.x; - } - if (0 == (NS_STYLE_CLIP_RIGHT_AUTO & display->mClipFlags)) { - clipRect.width = display->mClip.width; - } - if (0 == (NS_STYLE_CLIP_BOTTOM_AUTO & display->mClipFlags)) { - clipRect.height = display->mClip.height; - } - } - } - - if (hasOverflowClip) { - const nsStyleBorder* borderStyle; - const nsStylePadding* paddingStyle; - nsMargin border, padding; - - aFrame->GetStyleData(eStyleStruct_Border, (const nsStyleStruct*&)borderStyle); - aFrame->GetStyleData(eStyleStruct_Padding, (const nsStyleStruct*&)paddingStyle); - - // XXX We don't support the 'overflow-clip' property yet so just use the - // content area (which is the default value) as the clip shape - nsRect overflowClipRect(0, 0, frameSize.width, frameSize.height); - borderStyle->GetBorder(border); - overflowClipRect.Deflate(border); - // XXX We need to handle percentage padding - if (paddingStyle->GetPadding(padding)) { - overflowClipRect.Deflate(padding); - } - - if (hasClip) { - // If both 'clip' and 'overflow-clip' apply then use the intersection - // of the two - clipRect.IntersectRect(clipRect, overflowClipRect); - } else { - clipRect = overflowClipRect; - } - } - - // If part of the view is being clipped out, then mark it transparent - if (clipRect.y > newSize.y - || clipRect.x > newSize.x - || clipRect.XMost() < newSize.XMost() - || clipRect.YMost() < newSize.YMost()) { - viewHasTransparentContent = PR_TRUE; - } - - // Set clipping of child views. - nsRegion region; - region.Copy(clipRect); - vm->SetViewChildClipRegion(aView, ®ion); } else { - // Remove clipping of child views. - vm->SetViewChildClipRegion(aView, nsnull); + // if the view is for a popup, don't show the view if the popup is closed + nsCOMPtr widget; + aView->GetWidget(*getter_AddRefs(widget)); + if (widget) { + nsWindowType windowType; + widget->GetWindowType(windowType); + if (windowType == eWindowType_popup) { + widget->IsVisible(viewIsVisible); + } + } } - // Make sure content transparency is correct - if (viewIsVisible) { - vm->SetViewContentTransparency(aView, viewHasTransparentContent); + vm->SetViewVisibility(aView, viewIsVisible ? nsViewVisibility_kShow : + nsViewVisibility_kHide); + } + + const nsStyleDisplay* display; + ::GetStyleData(aStyleContext, &display); + // See if the frame is being relatively positioned or absolutely + // positioned + PRBool isTopMostView = display->IsPositioned(); + + // Make sure z-index is correct + const nsStylePosition* position; + ::GetStyleData(aStyleContext, &position); + + PRInt32 zIndex = 0; + PRBool autoZIndex = PR_FALSE; + + if (position->mZIndex.GetUnit() == eStyleUnit_Integer) { + zIndex = position->mZIndex.GetIntValue(); + } else if (position->mZIndex.GetUnit() == eStyleUnit_Auto) { + autoZIndex = PR_TRUE; + } + + vm->SetViewZIndex(aView, autoZIndex, zIndex, isTopMostView); + + SyncFrameViewGeometryDependentProperties(aPresContext, aFrame, aStyleContext, aView, aFlags); +} + +PRBool +nsContainerFrame::FrameNeedsView(nsIPresContext* aPresContext, + nsIFrame* aFrame, + nsIStyleContext* aStyleContext) +{ + const nsStyleVisibility* vis; + ::GetStyleData(aStyleContext, &vis); + + if (vis->mOpacity != 1.0f) { + return PR_TRUE; + } + + // See if the frame has a fixed background attachment + const nsStyleBackground *color; + PRBool isCanvas; + PRBool hasBackground = + nsCSSRendering::FindBackground(aPresContext, aFrame, &color, &isCanvas); + if (hasBackground && + NS_STYLE_BG_ATTACHMENT_FIXED == color->mBackgroundAttachment) { + return PR_TRUE; + } + + const nsStyleDisplay* display; + ::GetStyleData(aStyleContext, &display); + + if (NS_STYLE_POSITION_RELATIVE == display->mPosition) { + return PR_TRUE; + } else if (display->IsAbsolutelyPositioned()) { + return PR_TRUE; + } + + nsCOMPtr pseudoTag; + aStyleContext->GetPseudoType(*getter_AddRefs(pseudoTag)); + if (pseudoTag == nsLayoutAtoms::scrolledContentPseudo) { + return PR_TRUE; + } + + // See if the frame is block-level and has 'overflow' set to 'hidden'. If + // so, then we need to give it a view so clipping + // of any child views works correctly. Note that if it's floated it is also + // block-level, but we can't trust that the style context 'display' value is + // set correctly + if ((display->IsBlockLevel() || display->IsFloating()) && + (display->mOverflow == NS_STYLE_OVERFLOW_HIDDEN)) { + // XXX Check for the frame being a block frame and only force a view + // in that case, because adding a view for box frames seems to cause + // problems for XUL... + nsCOMPtr frameType; + + aFrame->GetFrameType(getter_AddRefs(frameType)); + if ((frameType == nsLayoutAtoms::blockFrame) || + (frameType == nsLayoutAtoms::areaFrame)) { + return PR_TRUE; } } + + return PR_FALSE; } /** diff --git a/layout/html/base/src/nsContainerFrame.h b/layout/html/base/src/nsContainerFrame.h index c398fdbb8cc..fc05068ac63 100644 --- a/layout/html/base/src/nsContainerFrame.h +++ b/layout/html/base/src/nsContainerFrame.h @@ -100,14 +100,7 @@ public: static void PositionFrameView(nsIPresContext* aPresContext, nsIFrame* aKidFrame); - // Sets several view attributes: - // - if requested sizes the frame's view based on the current size and origin. - // Takes into account the combined area and (if overflow is visible) whether - // the frame has children that extend outside - // - opacity - // - visibility - // - content transparency - // - clip + // Set the view's size and position after its frame has been reflowed. // // Flags: // NS_FRAME_NO_MOVE_VIEW - don't position the frame's view. Set this if you @@ -119,6 +112,34 @@ public: const nsRect* aCombinedArea, PRUint32 aFlags = 0); + // Sets view attributes from the frame style that depend on the view's size + // (clip, transparency). This needs to be called if you change the size of + // a view and the view's frame could have clipping set on it. + // @param aStyleContext can be null, in which case the frame's style context is used + static void SyncFrameViewAfterSizeChange(nsIPresContext* aPresContext, + nsIFrame* aFrame, + nsIStyleContext* aStyleContext, + nsIView* aView, + PRUint32 aFlags = 0); + + // Sets the view's attributes from the frame style. + // - opacity + // - visibility + // - content transparency + // - clip + // Call this when one of these styles changes or when the view has just + // been created. + // @param aStyleContext can be null, in which case the frame's style context is used + static void SyncFrameViewProperties(nsIPresContext* aPresContext, + nsIFrame* aFrame, + nsIStyleContext* aStyleContext, + nsIView* aView, + PRUint32 aFlags = 0); + + // Returns PR_TRUE if the frame requires a view + static PRBool FrameNeedsView(nsIPresContext* aPresContext, + nsIFrame* aFrame, nsIStyleContext* aStyleContext); + /** * Invokes the WillReflow() function, positions the frame and its view (if * requested), and then calls Reflow(). If the reflow succeeds and the child diff --git a/layout/html/base/src/nsHTMLContainerFrame.cpp b/layout/html/base/src/nsHTMLContainerFrame.cpp index 9b84b7f13a0..44e73d6f2d8 100644 --- a/layout/html/base/src/nsHTMLContainerFrame.cpp +++ b/layout/html/base/src/nsHTMLContainerFrame.cpp @@ -427,21 +427,6 @@ nsHTMLContainerFrame::ReparentFrameViewList(nsIPresContext* aPresContext, return NS_OK; } -static PRBool -IsContainerContent(nsIFrame* aFrame) -{ - nsIContent* content; - PRBool result = PR_FALSE; - - aFrame->GetContent(&content); - if (content) { - content->CanContainChildren(result); - NS_RELEASE(content); - } - - return result; -} - nsresult nsHTMLContainerFrame::CreateViewForFrame(nsIPresContext* aPresContext, nsIFrame* aFrame, @@ -449,244 +434,92 @@ nsHTMLContainerFrame::CreateViewForFrame(nsIPresContext* aPresContext, nsIFrame* aContentParentFrame, PRBool aForce) { - PRBool isTopMostView = PR_FALSE; nsIView* view; aFrame->GetView(aPresContext, &view); + if (nsnull != view) { + return NS_OK; + } + // If we don't yet have a view, see if we need a view - if (nsnull == view) { - PRBool fixedBackgroundAttachment = PR_FALSE; + if (!(aForce || FrameNeedsView(aPresContext, aFrame, aStyleContext))) { + // don't need a view + return NS_OK; + } - // Get nsStyleColor and nsStyleDisplay - const nsStyleDisplay* display = (const nsStyleDisplay*) - aStyleContext->GetStyleData(eStyleStruct_Display); - const nsStylePosition* position = (const nsStylePosition*) - aStyleContext->GetStyleData(eStyleStruct_Position); - const nsStyleVisibility* vis = (const nsStyleVisibility*) - aStyleContext->GetStyleData(eStyleStruct_Visibility); + // Create a view + nsIFrame* parent = nsnull; + aFrame->GetParentWithView(aPresContext, &parent); + NS_ASSERTION(parent, "GetParentWithView failed"); + + nsIView* parentView = nsnull; + parent->GetView(aPresContext, &parentView); + NS_ASSERTION(parentView, "no parent with view"); + + // Create a view + static NS_DEFINE_CID(kViewCID, NS_VIEW_CID); + nsresult result = CallCreateInstance(kViewCID, &view); + if (NS_FAILED(result)) { + return result; + } - if (vis->mOpacity != 1.0f) { - NS_FRAME_LOG(NS_FRAME_TRACE_CALLS, - ("nsHTMLContainerFrame::CreateViewForFrame: frame=%p opacity=%g", - aFrame, vis->mOpacity)); - aForce = PR_TRUE; - } - - // See if the frame has a fixed background attachment - const nsStyleBackground *color; - PRBool isCanvas; - PRBool hasBackground = - nsCSSRendering::FindBackground(aPresContext, aFrame, &color, &isCanvas); - if (hasBackground && - NS_STYLE_BG_ATTACHMENT_FIXED == color->mBackgroundAttachment) { - aForce = PR_TRUE; - fixedBackgroundAttachment = PR_TRUE; - } + nsCOMPtr viewManager; + parentView->GetViewManager(*getter_AddRefs(viewManager)); + NS_ASSERTION(nsnull != viewManager, "null view manager"); - // See if the frame is being relatively positioned or absolutely - // positioned - if (!aForce) { - if (NS_STYLE_POSITION_RELATIVE == display->mPosition) { - NS_FRAME_LOG(NS_FRAME_TRACE_CALLS, - ("nsHTMLContainerFrame::CreateViewForFrame: frame=%p relatively positioned", - aFrame)); - aForce = PR_TRUE; - isTopMostView = PR_TRUE; - } else if (display->IsAbsolutelyPositioned()) { - NS_FRAME_LOG(NS_FRAME_TRACE_CALLS, - ("nsHTMLContainerFrame::CreateViewForFrame: frame=%p absolutely positioned", - aFrame)); - aForce = PR_TRUE; - isTopMostView = PR_TRUE; - } - } + // Initialize the view + nsRect bounds; + aFrame->GetRect(bounds); + view->Init(viewManager, bounds, parentView); - if (NS_STYLE_POSITION_FIXED == display->mPosition) { - isTopMostView = PR_TRUE; - } + SyncFrameViewProperties(aPresContext, aFrame, aStyleContext, view); - // See if the frame is a scrolled frame - if (!aForce) { - nsIAtom* pseudoTag; - aStyleContext->GetPseudoType(pseudoTag); - if (pseudoTag == nsLayoutAtoms::scrolledContentPseudo) { - NS_FRAME_LOG(NS_FRAME_TRACE_CALLS, - ("nsHTMLContainerFrame::CreateViewForFrame: scrolled frame=%p", aFrame)); - aForce = PR_TRUE; - } - NS_IF_RELEASE(pseudoTag); - } + // Insert the view into the view hierarchy. If the parent view is a + // scrolling view we need to do this differently + nsIScrollableView* scrollingView; + if (NS_SUCCEEDED(CallQueryInterface(parentView, &scrollingView))) { + scrollingView->SetScrolledView(view); + } else { + // XXX Drop it at the end of the document order until we can do better + viewManager->InsertChild(parentView, view, nsnull, PR_TRUE); - // See if the frame is block-level and has 'overflow' set to 'hidden'. If - // so and it can have child frames, then we need to give it a view so clipping - // of any child views works correctly. Note that if it's floated it is also - // block-level, but we can't trust that the style context 'display' value is - // set correctly - if (!aForce) { - if ((display->IsBlockLevel() || display->IsFloating()) && - (display->mOverflow == NS_STYLE_OVERFLOW_HIDDEN)) { - - // The reason for the check of whether it can contain children is just - // to avoid giving it a view unnecessarily - if (::IsContainerContent(aFrame)) { - // XXX Check for the frame being a block frame and only force a view - // in that case, because adding a view for box frames seems to cause - // problems for XUL... - nsIAtom* frameType; - - aFrame->GetFrameType(&frameType); - if ((frameType == nsLayoutAtoms::blockFrame) || - (frameType == nsLayoutAtoms::areaFrame)) { - aForce = PR_TRUE; - } - NS_IF_RELEASE(frameType); - } - } - } - - if (aForce) { - // Create a view - nsIFrame* parent = nsnull; - nsIView* parentView = nsnull; - - aFrame->GetParentWithView(aPresContext, &parent); - NS_ASSERTION(parent, "GetParentWithView failed"); - parent->GetView(aPresContext, &parentView); - NS_ASSERTION(parentView, "no parent with view"); - - // Create a view - static NS_DEFINE_CID(kViewCID, NS_VIEW_CID); - - nsresult result = nsComponentManager::CreateInstance(kViewCID, - nsnull, - NS_GET_IID(nsIView), - (void **)&view); - if (NS_OK == result) { - nsIViewManager* viewManager; - parentView->GetViewManager(viewManager); - NS_ASSERTION(nsnull != viewManager, "null view manager"); - - // Initialize the view - nsRect bounds; - aFrame->GetRect(bounds); - view->Init(viewManager, bounds, parentView); - - // If the frame has a fixed background attachment, then indicate that the - // view's contents should be repainted and not bitblt'd - if (fixedBackgroundAttachment) { - viewManager->SetViewBitBltEnabled(view, PR_FALSE); - } + if (nsnull != aContentParentFrame) { + // If, for some reason, GetView below fails to initialize zParentView, + // then ensure that we completely bypass InsertZPlaceholder below. + // The effect will be as if we never knew about aContentParentFrame + // in the first place, so at least this code won't be doing any damage. + nsIView* zParentView = parentView; + + aContentParentFrame->GetView(aPresContext, &zParentView); + + if (nsnull == zParentView) { + nsIFrame* zParentFrame = nsnull; - // Insert the view into the view hierarchy. If the parent view is a - // scrolling view we need to do this differently - nsIScrollableView* scrollingView; - if (NS_SUCCEEDED(parentView->QueryInterface(NS_GET_IID(nsIScrollableView), (void**)&scrollingView))) { - scrollingView->SetScrolledView(view); - } else { - PRInt32 zIndex = 0; - PRBool autoZIndex = PR_FALSE; - - // Get the z-index to use - if (position->mZIndex.GetUnit() == eStyleUnit_Integer) { - zIndex = position->mZIndex.GetIntValue(); - } else if (position->mZIndex.GetUnit() == eStyleUnit_Auto) { - autoZIndex = PR_TRUE; - } - - viewManager->SetViewZIndex(view, autoZIndex, zIndex, isTopMostView); - // XXX Drop it at the end of the document order until we can do better - viewManager->InsertChild(parentView, view, nsnull, PR_TRUE); - - if (nsnull != aContentParentFrame) { - // If, for some reason, GetView below fails to initialize zParentView, - // then ensure that we completely bypass InsertZPlaceholder below. - // The effect will be as if we never knew about aContentParentFrame - // in the first place, so at least this code won't be doing any damage. - nsIView* zParentView = parentView; - - aContentParentFrame->GetView(aPresContext, &zParentView); - - if (nsnull == zParentView) { - nsIFrame* zParentFrame = nsnull; - - aContentParentFrame->GetParentWithView(aPresContext, &zParentFrame); - NS_ASSERTION(zParentFrame, "GetParentWithView failed"); - zParentFrame->GetView(aPresContext, &zParentView); - NS_ASSERTION(zParentView, "no parent with view"); - } - - if (zParentView != parentView) { - viewManager->InsertZPlaceholder(zParentView, view, nsnull, PR_TRUE); - } - } - } - - // See if the view should be hidden - PRBool viewIsVisible = PR_TRUE; - PRBool viewHasTransparentContent = - !isCanvas && - (!hasBackground || - (color->mBackgroundFlags & NS_STYLE_BG_COLOR_TRANSPARENT)); - - - if (NS_STYLE_VISIBILITY_COLLAPSE == vis->mVisible) { - viewIsVisible = PR_FALSE; - } - else if (NS_STYLE_VISIBILITY_HIDDEN == vis->mVisible) { - // If it has a widget, hide the view because the widget can't deal with it - nsIWidget* widget = nsnull; - view->GetWidget(widget); - if (widget) { - viewIsVisible = PR_FALSE; - NS_RELEASE(widget); - } - else { - // If it's a container element, then leave the view visible, but - // mark it as having transparent content. The reason we need to - // do this is that child elements can override their parent's - // hidden visibility and be visible anyway. - // - // Because this function is called before processing the content - // object's child elements, we can't tell if it's a leaf by looking - // at whether the frame has any child frames - if (::IsContainerContent(aFrame)) { - // The view needs to be visible, but marked as having transparent - // content - viewHasTransparentContent = PR_TRUE; - } else { - // Go ahead and hide the view - viewIsVisible = PR_FALSE; - } - } - } - - if (viewIsVisible) { - if (viewHasTransparentContent) { - viewManager->SetViewContentTransparency(view, PR_TRUE); - } - - } else { - viewManager->SetViewVisibility(view, nsViewVisibility_kHide); - } - - // XXX If it's fixed positioned, then create a widget so it floats - // above the scrolling area - if (NS_STYLE_POSITION_FIXED == display->mPosition) { - view->CreateWidget(kCChildCID); - } - - viewManager->SetViewOpacity(view, vis->mOpacity); - NS_RELEASE(viewManager); + aContentParentFrame->GetParentWithView(aPresContext, &zParentFrame); + NS_ASSERTION(zParentFrame, "GetParentWithView failed"); + zParentFrame->GetView(aPresContext, &zParentView); + NS_ASSERTION(zParentView, "no parent with view"); + } + + if (zParentView != parentView) { + viewManager->InsertZPlaceholder(zParentView, view, nsnull, PR_TRUE); } - - // Remember our view - aFrame->SetView(aPresContext, view); - - NS_FRAME_LOG(NS_FRAME_TRACE_CALLS, - ("nsHTMLContainerFrame::CreateViewForFrame: frame=%p view=%p", - aFrame)); - return result; } } + + // XXX If it's fixed positioned, then create a widget so it floats + // above the scrolling area + const nsStyleDisplay* display; + ::GetStyleData(aStyleContext, &display); + if (NS_STYLE_POSITION_FIXED == display->mPosition) { + view->CreateWidget(kCChildCID); + } + + // Remember our view + aFrame->SetView(aPresContext, view); + + NS_FRAME_LOG(NS_FRAME_TRACE_CALLS, + ("nsHTMLContainerFrame::CreateViewForFrame: frame=%p view=%p", + aFrame)); return NS_OK; } diff --git a/layout/html/base/src/nsScrollFrame.cpp b/layout/html/base/src/nsScrollFrame.cpp index 49c553a4444..a89987a1a94 100644 --- a/layout/html/base/src/nsScrollFrame.cpp +++ b/layout/html/base/src/nsScrollFrame.cpp @@ -419,45 +419,17 @@ nsScrollFrame::CreateScrollingView(nsIPresContext* aPresContext) nsresult rv = CallCreateInstance(kScrollingViewCID, &view); if (NS_OK == rv) { - const nsStylePosition* position = (const nsStylePosition*) - mStyleContext->GetStyleData(eStyleStruct_Position); - const nsStyleBorder* borderStyle = (const nsStyleBorder*) - mStyleContext->GetStyleData(eStyleStruct_Border); - const nsStyleDisplay* display = (const nsStyleDisplay*) - mStyleContext->GetStyleData(eStyleStruct_Display); - const nsStyleVisibility* vis = - (const nsStyleVisibility*)mStyleContext->GetStyleData(eStyleStruct_Visibility); - - // Get the z-index - PRInt32 zIndex = 0; - PRBool autoZIndex = PR_FALSE; - - if (eStyleUnit_Integer == position->mZIndex.GetUnit()) { - zIndex = position->mZIndex.GetIntValue(); - } else if (position->mZIndex.GetUnit() == eStyleUnit_Auto) { - autoZIndex = PR_TRUE; - } - // Initialize the scrolling view - view->Init(viewManager, mRect, parentView, - vis->IsVisible() ? - nsViewVisibility_kShow : - nsViewVisibility_kHide); + view->Init(viewManager, mRect, parentView); - // Initialize the view's z-index - viewManager->SetViewZIndex(view, autoZIndex, zIndex); + SyncFrameViewProperties(aPresContext, this, mStyleContext, view); // Insert the view into the view hierarchy // XXX Put it last in document order, until we can do better viewManager->InsertChild(parentView, view, nsnull, PR_TRUE); - // Set the view's opacity - viewManager->SetViewOpacity(view, vis->mOpacity); - - // Because we only paint the border and we don't paint a background, - // inform the view manager that we have transparent content - viewManager->SetViewContentTransparency(view, PR_TRUE); - + const nsStyleDisplay* display; + ::GetStyleData(mStyleContext, &display); // If it's fixed positioned, then create a widget too CreateScrollingViewWidget(view, display); @@ -520,6 +492,8 @@ nsScrollFrame::CreateScrollingView(nsIPresContext* aPresContext) } scrollingView->SetScrollPreference(scrollPref); + const nsStyleBorder* borderStyle; + ::GetStyleData(mStyleContext, &borderStyle); // Set the scrolling view's insets to whatever our border is nsMargin border; if (!borderStyle->GetBorder(border)) { diff --git a/layout/html/base/src/nsScrollFrame.h b/layout/html/base/src/nsScrollFrame.h index 34494218cae..6949811492c 100644 --- a/layout/html/base/src/nsScrollFrame.h +++ b/layout/html/base/src/nsScrollFrame.h @@ -103,6 +103,8 @@ public: nsFramePaintLayer aWhichLayer, PRUint32 aFlags = 0); + virtual PRBool CanPaintBackground() { return PR_FALSE; } + NS_IMETHOD GetFrameForPoint(nsIPresContext* aPresContext, const nsPoint& aPoint, nsFramePaintLayer aWhichLayer, diff --git a/layout/html/forms/src/nsImageControlFrame.cpp b/layout/html/forms/src/nsImageControlFrame.cpp index 02a788de49a..4d1d0f8e6f7 100644 --- a/layout/html/forms/src/nsImageControlFrame.cpp +++ b/layout/html/forms/src/nsImageControlFrame.cpp @@ -60,6 +60,7 @@ #include "nsGUIEvent.h" #include "nsLayoutAtoms.h" #include "nsIServiceManager.h" +#include "nsContainerFrame.h" #ifdef ACCESSIBILITY #include "nsIAccessibilityService.h" #endif @@ -283,14 +284,15 @@ nsImageControlFrame::Init(nsIPresContext* aPresContext, // the view's size is not know yet, but its size will be kept in synch with our frame. nsRect boundBox(0, 0, 0, 0); result = view->Init(viewMan, boundBox, parView); - viewMan->SetViewContentTransparency(view, PR_TRUE); + + nsContainerFrame::SyncFrameViewProperties(aPresContext, this, aContext, view); + + // this gets reset during reflow anyway + // viewMan->SetViewContentTransparency(view, PR_TRUE); + // XXX put the view last in document order until we know how to do better viewMan->InsertChild(parView, view, nsnull, PR_TRUE); SetView(aPresContext, view); - - const nsStyleVisibility* vis = (const nsStyleVisibility*) mStyleContext->GetStyleData(eStyleStruct_Visibility); - // set the opacity - viewMan->SetViewOpacity(view, vis->mOpacity); } return rv; diff --git a/layout/html/style/src/nsCSSFrameConstructor.cpp b/layout/html/style/src/nsCSSFrameConstructor.cpp index 708ea892244..23a8c0ac3a1 100644 --- a/layout/html/style/src/nsCSSFrameConstructor.cpp +++ b/layout/html/style/src/nsCSSFrameConstructor.cpp @@ -9930,111 +9930,13 @@ static PRBool gInApplyRenderingChangeToTree = PR_FALSE; static void DoApplyRenderingChangeToTree(nsIPresContext* aPresContext, nsIFrame* aFrame, - nsIViewManager* aViewManager); - -static void -SyncAndInvalidateView(nsIPresContext* aPresContext, - nsIView* aView, - nsIFrame* aFrame, - nsIViewManager* aViewManager) -{ - NS_PRECONDITION(gInApplyRenderingChangeToTree, - "should only be called within ApplyRenderingChangeToTree"); - - const nsStyleBackground* bg; - const nsStyleDisplay* disp; - const nsStyleVisibility* vis; - PRBool isCanvas; - PRBool hasBG = - nsCSSRendering::FindBackground(aPresContext, aFrame, &bg, &isCanvas); - aFrame->GetStyleData(eStyleStruct_Display, (const nsStyleStruct*&) disp); - aFrame->GetStyleData(eStyleStruct_Visibility, (const nsStyleStruct*&) vis); - - aViewManager->SetViewOpacity(aView, vis->mOpacity); - - // See if the view should be hidden or visible - PRBool viewIsVisible = PR_TRUE; - PRBool viewHasTransparentContent = - !isCanvas && - (!hasBG || - (bg->mBackgroundFlags & NS_STYLE_BG_COLOR_TRANSPARENT)); - - if (NS_STYLE_VISIBILITY_COLLAPSE == vis->mVisible) { - viewIsVisible = PR_FALSE; - } - else if (NS_STYLE_VISIBILITY_HIDDEN == vis->mVisible) { - // If it has a widget, hide the view because the widget can't deal with it - nsIWidget* widget = nsnull; - aView->GetWidget(widget); - if (widget) { - viewIsVisible = PR_FALSE; - NS_RELEASE(widget); - } - else { - // If it's a scroll frame, then hide the view. This means that - // child elements can't override their parent's visibility, but - // it's not practical to leave it visible in all cases because - // the scrollbars will be showing - nsIAtom* frameType; - aFrame->GetFrameType(&frameType); - - if (frameType == nsLayoutAtoms::scrollFrame) { - viewIsVisible = PR_FALSE; - } else { - // If it's a container element, then leave the view visible, but - // mark it as having transparent content. The reason we need to - // do this is that child elements can override their parent's - // hidden visibility and be visible anyway - nsIFrame* firstChild; - - aFrame->FirstChild(aPresContext, nsnull, &firstChild); - if (firstChild) { - // It's not a left frame, so the view needs to be visible, but - // marked as having transparent content - viewHasTransparentContent = PR_TRUE; - } else { - // It's a leaf frame so go ahead and hide the view - viewIsVisible = PR_FALSE; - } - } - NS_IF_RELEASE(frameType); - } - } else { - // if the view is for a popup, don't show the view if the popup is closed - nsCOMPtr widget; - aView->GetWidget(*getter_AddRefs(widget)); - if (widget) { - nsWindowType windowType; - widget->GetWindowType(windowType); - if (windowType == eWindowType_popup) - widget->IsVisible(viewIsVisible); - } - } - - // If the frame has visible content that overflows the content area, then we - // need the view marked as having transparent content - if (NS_STYLE_OVERFLOW_VISIBLE == disp->mOverflow) { - nsFrameState frameState; - - aFrame->GetFrameState(&frameState); - if (frameState & NS_FRAME_OUTSIDE_CHILDREN) { - viewHasTransparentContent = PR_TRUE; - } - } - - if (viewIsVisible) { - aViewManager->SetViewContentTransparency(aView, viewHasTransparentContent); - aViewManager->SetViewVisibility(aView, nsViewVisibility_kShow); - aViewManager->UpdateView(aView, NS_VMREFRESH_NO_SYNC); - } - else { - aViewManager->SetViewVisibility(aView, nsViewVisibility_kHide); - } -} + nsIViewManager* aViewManager, + nsChangeHint aChange); static void UpdateViewsForTree(nsIPresContext* aPresContext, nsIFrame* aFrame, - nsIViewManager* aViewManager, nsRect& aBoundsRect) + nsIViewManager* aViewManager, nsRect& aBoundsRect, + nsChangeHint aChange) { NS_PRECONDITION(gInApplyRenderingChangeToTree, "should only be called within ApplyRenderingChangeToTree"); @@ -10043,7 +9945,12 @@ UpdateViewsForTree(nsIPresContext* aPresContext, nsIFrame* aFrame, aFrame->GetView(aPresContext, &view); if (view) { - SyncAndInvalidateView(aPresContext, view, aFrame, aViewManager); + if (aChange & nsChangeHint_RepaintFrame) { + aViewManager->UpdateView(view, NS_VMREFRESH_NO_SYNC); + } + if (aChange & nsChangeHint_SyncFrameView) { + nsContainerFrame::SyncFrameViewProperties(aPresContext, aFrame, nsnull, view); + } } nsRect bounds; @@ -10071,11 +9978,11 @@ UpdateViewsForTree(nsIPresContext* aPresContext, nsIFrame* aFrame, nsIFrame* outOfFlowFrame = ((nsPlaceholderFrame*)child)->GetOutOfFlowFrame(); NS_ASSERTION(outOfFlowFrame, "no out-of-flow frame"); - DoApplyRenderingChangeToTree(aPresContext, outOfFlowFrame, aViewManager); + DoApplyRenderingChangeToTree(aPresContext, outOfFlowFrame, aViewManager, aChange); } else { // regular frame nsRect childBounds; - UpdateViewsForTree(aPresContext, child, aViewManager, childBounds); + UpdateViewsForTree(aPresContext, child, aViewManager, childBounds, aChange); bounds.UnionRect(bounds, childBounds); } NS_IF_RELEASE(frameType); @@ -10093,7 +10000,8 @@ UpdateViewsForTree(nsIPresContext* aPresContext, nsIFrame* aFrame, static void DoApplyRenderingChangeToTree(nsIPresContext* aPresContext, nsIFrame* aFrame, - nsIViewManager* aViewManager) + nsIViewManager* aViewManager, + nsChangeHint aChange) { NS_PRECONDITION(gInApplyRenderingChangeToTree, "should only be called within ApplyRenderingChangeToTree"); @@ -10114,9 +10022,9 @@ DoApplyRenderingChangeToTree(nsIPresContext* aPresContext, aFrame->GetOffsetFromView(aPresContext, viewOffset, &parentView); NS_ASSERTION(nsnull != parentView, "no view"); } - UpdateViewsForTree(aPresContext, aFrame, aViewManager, invalidRect); + UpdateViewsForTree(aPresContext, aFrame, aViewManager, invalidRect, aChange); - if (! view) { // if frame has view, will already be invalidated + if (! view && (aChange & nsChangeHint_RepaintFrame)) { // if frame has view, will already be invalidated // XXX Instead of calling this we should really be calling // Invalidate on on the nsFrame (which does this) const nsStyleOutline* outline; @@ -10138,14 +10046,20 @@ DoApplyRenderingChangeToTree(nsIPresContext* aPresContext, static void ApplyRenderingChangeToTree(nsIPresContext* aPresContext, nsIFrame* aFrame, - nsIViewManager* aViewManager) + nsIViewManager* aViewManager, + nsChangeHint aChange) { nsCOMPtr shell; aPresContext->GetShell(getter_AddRefs(shell)); PRBool isPaintingSuppressed = PR_FALSE; shell->IsPaintingSuppressed(&isPaintingSuppressed); - if (isPaintingSuppressed) - return; // Don't allow synchronous rendering changes when painting is turned off. + if (isPaintingSuppressed) { + // Don't allow synchronous rendering changes when painting is turned off. + aChange = NS_SubtractHint(aChange, nsChangeHint_RepaintFrame); + if (!aChange) { + return; + } + } // If the frame's background is propagated to an ancestor, walk up to // that ancestor. @@ -10179,7 +10093,7 @@ ApplyRenderingChangeToTree(nsIPresContext* aPresContext, #ifdef DEBUG gInApplyRenderingChangeToTree = PR_TRUE; #endif - DoApplyRenderingChangeToTree(aPresContext, aFrame, viewManager); + DoApplyRenderingChangeToTree(aPresContext, aFrame, viewManager, aChange); #ifdef DEBUG gInApplyRenderingChangeToTree = PR_FALSE; #endif @@ -10250,7 +10164,7 @@ nsCSSFrameConstructor::StyleChangeReflow(nsIPresContext* aPresContext, // This isn't the most efficient way to do it, but it saves code // size and doesn't add much cost compared to the reflow.. if (ancestor != aFrame) - ApplyRenderingChangeToTree(aPresContext, ancestor, nsnull); + ApplyRenderingChangeToTree(aPresContext, ancestor, nsnull, nsChangeHint_RepaintFrame); return NS_OK; } @@ -10349,11 +10263,8 @@ nsCSSFrameConstructor::ProcessRestyledFrames(nsStyleChangeList& aChangeList, if (hint & nsChangeHint_ReflowFrame) { StyleChangeReflow(aPresContext, frame, nsnull); } - if (hint & nsChangeHint_RepaintFrame) { - ApplyRenderingChangeToTree(aPresContext, frame, nsnull); - } - if (hint & nsChangeHint_SyncFrameView) { - // TBD: split out view sync from ApplyRenderingChange and friends + if (hint & (nsChangeHint_RepaintFrame | nsChangeHint_SyncFrameView)) { + ApplyRenderingChangeToTree(aPresContext, frame, nsnull, hint); } } } @@ -10463,7 +10374,7 @@ nsCSSFrameConstructor::ContentStatesChanged(nsIPresContext* aPresContext, if (theme && theme->ThemeSupportsWidget(aPresContext, primaryFrame1, app1)) theme->WidgetStateChanged(primaryFrame1, app1, nsnull, &repaint); if (repaint) - ApplyRenderingChangeToTree(aPresContext, primaryFrame1, nsnull); + ApplyRenderingChangeToTree(aPresContext, primaryFrame1, nsnull, nsChangeHint_RepaintFrame); } if (!(frameChange1 & nsChangeHint_ReconstructDoc) && (primaryFrame2)) { @@ -10477,7 +10388,7 @@ nsCSSFrameConstructor::ContentStatesChanged(nsIPresContext* aPresContext, if (theme && theme->ThemeSupportsWidget(aPresContext, primaryFrame2, app2)) theme->WidgetStateChanged(primaryFrame2, app2, nsnull, &repaint); if (repaint) - ApplyRenderingChangeToTree(aPresContext, primaryFrame2, nsnull); + ApplyRenderingChangeToTree(aPresContext, primaryFrame2, nsnull, nsChangeHint_RepaintFrame); } } @@ -10523,7 +10434,7 @@ nsCSSFrameConstructor::ContentStatesChanged(nsIPresContext* aPresContext, if (theme) theme->WidgetStateChanged(primaryFrame2, app2, nsnull, &repaint); if (repaint) - ApplyRenderingChangeToTree(aPresContext, primaryFrame2, nsnull); + ApplyRenderingChangeToTree(aPresContext, primaryFrame2, nsnull, nsChangeHint_RepaintFrame); } // max change needed for top level frames @@ -10701,7 +10612,7 @@ nsCSSFrameConstructor::AttributeChanged(nsIPresContext* aPresContext, PRBool repaint = PR_FALSE; theme->WidgetStateChanged(primaryFrame, disp->mAppearance, aAttribute, &repaint); if (repaint) - ApplyRenderingChangeToTree(aPresContext, primaryFrame, nsnull); + ApplyRenderingChangeToTree(aPresContext, primaryFrame, nsnull, nsChangeHint_RepaintFrame); } } } @@ -10791,11 +10702,6 @@ nsCSSFrameConstructor::StyleRuleChanged(nsIPresContext* aPresContext, PRBool reframe = (aHint & (nsChangeHint_ReconstructDoc | nsChangeHint_ReconstructFrame | nsChangeHint_Unknown)) != 0; - PRBool reflow = (aHint & (nsChangeHint_ReconstructDoc | nsChangeHint_ReconstructFrame - | nsChangeHint_ReflowFrame | nsChangeHint_Unknown)) != 0; - PRBool render = (aHint & (nsChangeHint_ReconstructDoc | nsChangeHint_ReconstructFrame - | nsChangeHint_ReflowFrame | nsChangeHint_RepaintFrame - | nsChangeHint_Unknown)) != 0; PRBool restyle = (aHint & ~(nsChangeHint_AttrChange)) != 0; // TBD: add "review" to update view? @@ -10809,14 +10715,20 @@ nsCSSFrameConstructor::StyleRuleChanged(nsIPresContext* aPresContext, result = ReconstructDocElementHierarchy(aPresContext); } else { + PRBool reflow = (aHint & (nsChangeHint_ReconstructDoc | nsChangeHint_ReconstructFrame + | nsChangeHint_ReflowFrame | nsChangeHint_Unknown)) != 0; + PRBool renderOrSync = (aHint & (nsChangeHint_ReconstructDoc | nsChangeHint_ReconstructFrame + | nsChangeHint_ReflowFrame | nsChangeHint_RepaintFrame + | nsChangeHint_Unknown | nsChangeHint_SyncFrameView)) != 0; + // XXX hack, skip the root and scrolling frames frame->FirstChild(aPresContext, nsnull, &frame); frame->FirstChild(aPresContext, nsnull, &frame); if (reflow) { StyleChangeReflow(aPresContext, frame, nsnull); } - else if (render) { - ApplyRenderingChangeToTree(aPresContext, frame, nsnull); + if (renderOrSync) { + ApplyRenderingChangeToTree(aPresContext, frame, nsnull, aHint); } } diff --git a/layout/style/nsCSSPropList.h b/layout/style/nsCSSPropList.h index 5615b637c2d..c7cb2ab9a81 100644 --- a/layout/style/nsCSSPropList.h +++ b/layout/style/nsCSSPropList.h @@ -95,203 +95,203 @@ // support them correctly the old constants need to be renamed and // new ones should be entered. -CSS_PROP(-moz-appearance, appearance, MozAppearance, REFLOW) -CSS_PROP(-moz-border-radius, _moz_border_radius, MozBorderRadius, VISUAL) -CSS_PROP(-moz-border-radius-topleft, _moz_border_radius_topLeft, MozBorderRadiusTopleft, VISUAL) -CSS_PROP(-moz-border-radius-topright, _moz_border_radius_topRight, MozBorderRadiusTopright, VISUAL) -CSS_PROP(-moz-border-radius-bottomleft, _moz_border_radius_bottomLeft, MozBorderRadiusBottomleft, VISUAL) -CSS_PROP(-moz-border-radius-bottomright, _moz_border_radius_bottomRight, MozBorderRadiusBottomright, VISUAL) -CSS_PROP(-moz-outline-radius, _moz_outline_radius, MozOutlineRadius, VISUAL) -CSS_PROP(-moz-outline-radius-topleft, _moz_outline_radius_topLeft, MozOutlineRadiusTopleft, VISUAL) -CSS_PROP(-moz-outline-radius-topright, _moz_outline_radius_topRight, MozOutlineRadiusTopright, VISUAL) -CSS_PROP(-moz-outline-radius-bottomleft, _moz_outline_radius_bottomLeft, MozOutlineRadiusBottomleft, VISUAL) -CSS_PROP(-moz-outline-radius-bottomright, _moz_outline_radius_bottomRight, MozOutlineRadiusBottomright, VISUAL) -CSS_PROP(azimuth, azimuth, Azimuth, AURAL) -CSS_PROP(background, background, Background, VISUAL) -CSS_PROP(background-attachment, background_attachment, BackgroundAttachment, FRAMECHANGE) -CSS_PROP(background-color, background_color, BackgroundColor, VISUAL) -CSS_PROP(background-image, background_image, BackgroundImage, VISUAL) -CSS_PROP(background-position, background_position, BackgroundPosition, VISUAL) -CSS_PROP(background-repeat, background_repeat, BackgroundRepeat, VISUAL) -CSS_PROP_INTERNAL(-x-background-x-position, background_x_position, BackgroundXPosition, VISUAL) // XXX bug 3935 -CSS_PROP_INTERNAL(-x-background-y-position, background_y_position, BackgroundYPosition, VISUAL) // XXX bug 3935 -CSS_PROP(-moz-binding, binding, MozBinding, FRAMECHANGE) // XXX bug 3935 -CSS_PROP(border, border, Border, REFLOW) -CSS_PROP(border-bottom, border_bottom, BorderBottom, REFLOW) -CSS_PROP(border-bottom-color, border_bottom_color, BorderBottomColor, VISUAL) -CSS_PROP(-moz-border-bottom-colors, border_bottom_colors, MozBorderBottomColors, VISUAL) -CSS_PROP(border-bottom-style, border_bottom_style, BorderBottomStyle, REFLOW) // on/off will need reflow -CSS_PROP(border-bottom-width, border_bottom_width, BorderBottomWidth, REFLOW) -CSS_PROP(border-collapse, border_collapse, BorderCollapse, FRAMECHANGE) -CSS_PROP(border-color, border_color, BorderColor, VISUAL) -CSS_PROP(border-left, border_left, BorderLeft, REFLOW) -CSS_PROP(border-left-color, border_left_color, BorderLeftColor, VISUAL) -CSS_PROP(-moz-border-left-colors, border_left_colors, MozBorderLeftColors, VISUAL) -CSS_PROP(border-left-style, border_left_style, BorderLeftStyle, REFLOW) // on/off will need reflow -CSS_PROP(border-left-width, border_left_width, BorderLeftWidth, REFLOW) -CSS_PROP(border-right, border_right, BorderRight, REFLOW) -CSS_PROP(border-right-color, border_right_color, BorderRightColor, VISUAL) -CSS_PROP(-moz-border-right-colors, border_right_colors, MozBorderRightColors, VISUAL) -CSS_PROP(border-right-style, border_right_style, BorderRightStyle, REFLOW) // on/off will need reflow -CSS_PROP(border-right-width, border_right_width, BorderRightWidth, REFLOW) -CSS_PROP(border-spacing, border_spacing, BorderSpacing, REFLOW) -CSS_PROP(border-style, border_style, BorderStyle, REFLOW) // on/off will need reflow -CSS_PROP(border-top, border_top, BorderTop, REFLOW) -CSS_PROP(border-top-color, border_top_color, BorderTopColor, VISUAL) -CSS_PROP(-moz-border-top-colors, border_top_colors, MozBorderTopColors, VISUAL) -CSS_PROP(border-top-style, border_top_style, BorderTopStyle, REFLOW) // on/off will need reflow -CSS_PROP(border-top-width, border_top_width, BorderTopWidth, REFLOW) -CSS_PROP(border-width, border_width, BorderWidth, REFLOW) -CSS_PROP_INTERNAL(-x-border-x-spacing, border_x_spacing, BorderXSpacing, REFLOW) // XXX bug 3935 -CSS_PROP_INTERNAL(-x-border-y-spacing, border_y_spacing, BorderYSpacing, REFLOW) // XXX bug 3935 -CSS_PROP(bottom, bottom, Bottom, REFLOW) -CSS_PROP(-moz-box-align, box_align, MozBoxAlign, REFLOW) // XXX bug 3935 -CSS_PROP(-moz-box-direction, box_direction, MozBoxDirection, REFLOW) // XXX bug 3935 -CSS_PROP(-moz-box-flex, box_flex, MozBoxFlex, REFLOW) // XXX bug 3935 -CSS_PROP(-moz-box-flex-group, box_flex_group, MozBoxFlexGroup, REFLOW) // XXX bug 3935 -CSS_PROP(-moz-box-orient, box_orient, MozBoxOrient, REFLOW) // XXX bug 3935 -CSS_PROP(-moz-box-pack, box_pack, MozBoxPack, REFLOW) // XXX bug 3935 -CSS_PROP(-moz-box-sizing, box_sizing, MozBoxSizing, REFLOW) // XXX bug 3935 -CSS_PROP(-moz-box-ordinal-group, box_ordinal_group, MozBoxOrdinalGroup, FRAMECHANGE) -CSS_PROP(caption-side, caption_side, CaptionSide, REFLOW) -CSS_PROP(clear, clear, Clear, REFLOW) -CSS_PROP(clip, clip, Clip, REFLOW) -CSS_PROP_INTERNAL(-x-clip-bottom, clip_bottom, ClipBottom, REFLOW) // XXX bug 3935 -CSS_PROP_INTERNAL(-x-clip-left, clip_left, ClipLeft, REFLOW) // XXX bug 3935 -CSS_PROP_INTERNAL(-x-clip-right, clip_right, ClipRight, REFLOW) // XXX bug 3935 -CSS_PROP_INTERNAL(-x-clip-top, clip_top, ClipTop, REFLOW) // XXX bug 3935 -CSS_PROP(color, color, Color, VISUAL) -CSS_PROP(content, content, Content, FRAMECHANGE) -CSS_PROP(counter-increment, counter_increment, CounterIncrement, REFLOW) -CSS_PROP(counter-reset, counter_reset, CounterReset, REFLOW) -CSS_PROP(-moz-counter-increment, _moz_counter_increment, MozCounterIncrement, REFLOW) // XXX bug 137285 -CSS_PROP(-moz-counter-reset, _moz_counter_reset, MozCounterReset, REFLOW) // XXX bug 137285 -CSS_PROP(cue, cue, Cue, AURAL) -CSS_PROP(cue-after, cue_after, CueAfter, AURAL) -CSS_PROP(cue-before, cue_before, CueBefore, AURAL) -CSS_PROP(cursor, cursor, Cursor, VISUAL) -CSS_PROP(direction, direction, Direction, REFLOW) -CSS_PROP(display, display, Display, FRAMECHANGE) -CSS_PROP(elevation, elevation, Elevation, AURAL) -CSS_PROP(empty-cells, empty_cells, EmptyCells, VISUAL) -CSS_PROP(float, float, CssFloat, FRAMECHANGE) -CSS_PROP(-moz-float-edge, float_edge, MozFloatEdge, REFLOW) // XXX bug 3935 -CSS_PROP(font, font, Font, REFLOW) -CSS_PROP(font-family, font_family, FontFamily, REFLOW) -CSS_PROP(font-size, font_size, FontSize, REFLOW) -CSS_PROP(font-size-adjust, font_size_adjust, FontSizeAdjust, REFLOW) -CSS_PROP(font-stretch, font_stretch, FontStretch, REFLOW) -CSS_PROP(font-style, font_style, FontStyle, REFLOW) -CSS_PROP(font-variant, font_variant, FontVariant, REFLOW) -CSS_PROP(font-weight, font_weight, FontWeight, REFLOW) -CSS_PROP(-moz-force-broken-image-icon, force_broken_image_icon, MozForceBrokenImageIcon, FRAMECHANGE) // bug 58646 -CSS_PROP(height, height, Height, REFLOW) -CSS_PROP(-moz-image-region, image_region, MozImageRegion, REFLOW) -CSS_PROP_INTERNAL(-x-image-region-bottom, image_region_bottom, MozImageRegionBottom, REFLOW) -CSS_PROP_INTERNAL(-x-image-region-left, image_region_left, MozImageRegionLeft, REFLOW) -CSS_PROP_INTERNAL(-x-image-region-right, image_region_right, MozImageRegionRight, REFLOW) -CSS_PROP_INTERNAL(-x-image-region-top, image_region_top, MozImageRegionTop, REFLOW) -CSS_PROP(-moz-key-equivalent, key_equivalent, MozKeyEquivalent, CONTENT) // This will need some other notification, but what? // XXX bug 3935 -CSS_PROP(left, left, Left, REFLOW) -CSS_PROP(letter-spacing, letter_spacing, LetterSpacing, REFLOW) -CSS_PROP(line-height, line_height, LineHeight, REFLOW) -CSS_PROP(list-style, list_style, ListStyle, REFLOW) -CSS_PROP(list-style-image, list_style_image, ListStyleImage, REFLOW) -CSS_PROP(list-style-position, list_style_position, ListStylePosition, REFLOW) -CSS_PROP(list-style-type, list_style_type, ListStyleType, REFLOW) -CSS_PROP(margin, margin, Margin, REFLOW) -CSS_PROP(margin-bottom, margin_bottom, MarginBottom, REFLOW) -CSS_PROP(margin-left, margin_left, MarginLeft, REFLOW) -CSS_PROP(margin-right, margin_right, MarginRight, REFLOW) -CSS_PROP(margin-top, margin_top, MarginTop, REFLOW) -CSS_PROP(marker-offset, marker_offset, MarkerOffset, REFLOW) -CSS_PROP(marks, marks, Marks, VISUAL) -CSS_PROP(max-height, max_height, MaxHeight, REFLOW) -CSS_PROP(max-width, max_width, MaxWidth, REFLOW) -CSS_PROP(min-height, min_height, MinHeight, REFLOW) -CSS_PROP(min-width, min_width, MinWidth, REFLOW) -CSS_PROP(-moz-opacity, opacity, MozOpacity, FRAMECHANGE) // XXX bug 3935 -CSS_PROP(orphans, orphans, Orphans, REFLOW) -CSS_PROP(outline, outline, Outline, VISUAL) -CSS_PROP(outline, outline_color, OutlineColor, VISUAL) -CSS_PROP(outline, outline_style, OutlineStyle, VISUAL) -CSS_PROP(outline, outline_width, OutlineWidth, VISUAL) -CSS_PROP(-moz-outline, _moz_outline, MozOutline, VISUAL) // XXX This is temporary fix for nsbeta3+ Bug 48973, turning outline into -moz-outline XXX bug 48973 -CSS_PROP(-moz-outline-color, _moz_outline_color, MozOutlineColor, VISUAL) // XXX bug 48973 -CSS_PROP(-moz-outline-style, _moz_outline_style, MozOutlineStyle, VISUAL) // XXX bug 48973 -CSS_PROP(-moz-outline-width, _moz_outline_width, MozOutlineWidth, VISUAL) // XXX bug 48973 -CSS_PROP(overflow, overflow, Overflow, FRAMECHANGE) -CSS_PROP(padding, padding, Padding, REFLOW) -CSS_PROP(padding-bottom, padding_bottom, PaddingBottom, REFLOW) -CSS_PROP(padding-left, padding_left, PaddingLeft, REFLOW) -CSS_PROP(padding-right, padding_right, PaddingRight, REFLOW) -CSS_PROP(padding-top, padding_top, PaddingTop, REFLOW) -CSS_PROP(page, page, Page, REFLOW) -CSS_PROP(page-break-after, page_break_after, PageBreakAfter, REFLOW) -CSS_PROP(page-break-before, page_break_before, PageBreakBefore, REFLOW) -CSS_PROP(page-break-inside, page_break_inside, PageBreakInside, REFLOW) -CSS_PROP(pause, pause, Pause, AURAL) -CSS_PROP(pause-after, pause_after, PauseAfter, AURAL) -CSS_PROP(pause-before, pause_before, PauseBefore, AURAL) -CSS_PROP(pitch, pitch, Pitch, AURAL) -CSS_PROP(pitch-range, pitch_range, PitchRange, AURAL) -CSS_PROP(play-during, play_during, PlayDuring, AURAL) -CSS_PROP_INTERNAL(-x-play-during-flags, play_during_flags, PlayDuringFlags, AURAL) // XXX why is this here? -CSS_PROP(position, position, Position, FRAMECHANGE) -CSS_PROP(quotes, quotes, Quotes, REFLOW) -CSS_PROP_INTERNAL(-x-quotes-close, quotes_close, QuotesClose, REFLOW) // XXX bug 3935 -CSS_PROP_INTERNAL(-x-quotes-open, quotes_open, QuotesOpen, REFLOW) // XXX bug 3935 -CSS_PROP(-moz-resizer, resizer, MozResizer, FRAMECHANGE) // XXX bug 3935 -CSS_PROP(richness, richness, Richness, AURAL) -CSS_PROP(right, right, Right, REFLOW) -CSS_PROP(size, size, Size, REFLOW) -CSS_PROP_INTERNAL(-x-size-height, size_height, SizeHeight, REFLOW) // XXX bug 3935 -CSS_PROP_INTERNAL(-x-size-width, size_width, SizeWidth, REFLOW) // XXX bug 3935 -CSS_PROP(speak, speak, Speak, AURAL) -CSS_PROP(speak-header, speak_header, SpeakHeader, AURAL) -CSS_PROP(speak-numeral, speak_numeral, SpeakNumeral, AURAL) -CSS_PROP(speak-punctuation, speak_punctuation, SpeakPunctuation, AURAL) -CSS_PROP(speech-rate, speech_rate, SpeechRate, AURAL) -CSS_PROP(stress, stress, Stress, AURAL) -CSS_PROP(table-layout, table_layout, TableLayout, REFLOW) -CSS_PROP(text-align, text_align, TextAlign, REFLOW) -CSS_PROP(text-decoration, text_decoration, TextDecoration, VISUAL) -CSS_PROP(text-indent, text_indent, TextIndent, REFLOW) -CSS_PROP(text-shadow, text_shadow, TextShadow, VISUAL) -CSS_PROP_INTERNAL(-x-text-shadow-color, text_shadow_color, TextShadowColor, VISUAL) // XXX bug 3935 -CSS_PROP_INTERNAL(-x-text-shadow-radius, text_shadow_radius, TextShadowRadius, VISUAL) // XXX bug 3935 -CSS_PROP_INTERNAL(-x-text-shadow-x, text_shadow_x, TextShadowX, VISUAL) // XXX bug 3935 -CSS_PROP_INTERNAL(-x-text-shadow-y, text_shadow_y, TextShadowY, VISUAL) // XXX bug 3935 -CSS_PROP(text-transform, text_transform, TextTransform, REFLOW) -CSS_PROP(top, top, Top, REFLOW) -CSS_PROP(unicode-bidi, unicode_bidi, UnicodeBidi, REFLOW) -CSS_PROP(-moz-user-focus, user_focus, MozUserFocus, CONTENT) // XXX bug 3935 -CSS_PROP(-moz-user-input, user_input, MozUserInput, FRAMECHANGE) // XXX ??? // XXX bug 3935 -CSS_PROP(-moz-user-modify, user_modify, MozUserModify, FRAMECHANGE) // XXX bug 3935 -CSS_PROP(-moz-user-select, user_select, MozUserSelect, CONTENT) // XXX bug 3935 -CSS_PROP(vertical-align, vertical_align, VerticalAlign, REFLOW) -CSS_PROP(visibility, visibility, Visibility, REFLOW) // reflow for collapse -CSS_PROP(voice-family, voice_family, VoiceFamily, AURAL) -CSS_PROP(volume, volume, Volume, AURAL) -CSS_PROP(white-space, white_space, WhiteSpace, REFLOW) -CSS_PROP(widows, widows, Widows, REFLOW) -CSS_PROP(width, width, Width, REFLOW) -CSS_PROP(word-spacing, word_spacing, WordSpacing, REFLOW) -CSS_PROP(z-index, z_index, ZIndex, REFLOW) +CSS_PROP(-moz-appearance, appearance, MozAppearance, NS_STYLE_HINT_REFLOW) +CSS_PROP(-moz-border-radius, _moz_border_radius, MozBorderRadius, NS_STYLE_HINT_VISUAL) +CSS_PROP(-moz-border-radius-topleft, _moz_border_radius_topLeft, MozBorderRadiusTopleft, NS_STYLE_HINT_VISUAL) +CSS_PROP(-moz-border-radius-topright, _moz_border_radius_topRight, MozBorderRadiusTopright, NS_STYLE_HINT_VISUAL) +CSS_PROP(-moz-border-radius-bottomleft, _moz_border_radius_bottomLeft, MozBorderRadiusBottomleft, NS_STYLE_HINT_VISUAL) +CSS_PROP(-moz-border-radius-bottomright, _moz_border_radius_bottomRight, MozBorderRadiusBottomright, NS_STYLE_HINT_VISUAL) +CSS_PROP(-moz-outline-radius, _moz_outline_radius, MozOutlineRadius, NS_STYLE_HINT_VISUAL) +CSS_PROP(-moz-outline-radius-topleft, _moz_outline_radius_topLeft, MozOutlineRadiusTopleft, NS_STYLE_HINT_VISUAL) +CSS_PROP(-moz-outline-radius-topright, _moz_outline_radius_topRight, MozOutlineRadiusTopright, NS_STYLE_HINT_VISUAL) +CSS_PROP(-moz-outline-radius-bottomleft, _moz_outline_radius_bottomLeft, MozOutlineRadiusBottomleft, NS_STYLE_HINT_VISUAL) +CSS_PROP(-moz-outline-radius-bottomright, _moz_outline_radius_bottomRight, MozOutlineRadiusBottomright, NS_STYLE_HINT_VISUAL) +CSS_PROP(azimuth, azimuth, Azimuth, NS_STYLE_HINT_AURAL) +CSS_PROP(background, background, Background, NS_STYLE_HINT_VISUAL) +CSS_PROP(background-attachment, background_attachment, BackgroundAttachment, NS_STYLE_HINT_FRAMECHANGE) +CSS_PROP(background-color, background_color, BackgroundColor, NS_STYLE_HINT_VISUAL) +CSS_PROP(background-image, background_image, BackgroundImage, NS_STYLE_HINT_VISUAL) +CSS_PROP(background-position, background_position, BackgroundPosition, NS_STYLE_HINT_VISUAL) +CSS_PROP(background-repeat, background_repeat, BackgroundRepeat, NS_STYLE_HINT_VISUAL) +CSS_PROP_INTERNAL(-x-background-x-position, background_x_position, BackgroundXPosition, NS_STYLE_HINT_VISUAL) // XXX bug 3935 +CSS_PROP_INTERNAL(-x-background-y-position, background_y_position, BackgroundYPosition, NS_STYLE_HINT_VISUAL) // XXX bug 3935 +CSS_PROP(-moz-binding, binding, MozBinding, NS_STYLE_HINT_FRAMECHANGE) // XXX bug 3935 +CSS_PROP(border, border, Border, NS_STYLE_HINT_REFLOW) +CSS_PROP(border-bottom, border_bottom, BorderBottom, NS_STYLE_HINT_REFLOW) +CSS_PROP(border-bottom-color, border_bottom_color, BorderBottomColor, NS_STYLE_HINT_VISUAL) +CSS_PROP(-moz-border-bottom-colors, border_bottom_colors, MozBorderBottomColors, NS_STYLE_HINT_VISUAL) +CSS_PROP(border-bottom-style, border_bottom_style, BorderBottomStyle, NS_STYLE_HINT_REFLOW) // on/off will need reflow +CSS_PROP(border-bottom-width, border_bottom_width, BorderBottomWidth, NS_STYLE_HINT_REFLOW) +CSS_PROP(border-collapse, border_collapse, BorderCollapse, NS_STYLE_HINT_FRAMECHANGE) +CSS_PROP(border-color, border_color, BorderColor, NS_STYLE_HINT_VISUAL) +CSS_PROP(border-left, border_left, BorderLeft, NS_STYLE_HINT_REFLOW) +CSS_PROP(border-left-color, border_left_color, BorderLeftColor, NS_STYLE_HINT_VISUAL) +CSS_PROP(-moz-border-left-colors, border_left_colors, MozBorderLeftColors, NS_STYLE_HINT_VISUAL) +CSS_PROP(border-left-style, border_left_style, BorderLeftStyle, NS_STYLE_HINT_REFLOW) // on/off will need reflow +CSS_PROP(border-left-width, border_left_width, BorderLeftWidth, NS_STYLE_HINT_REFLOW) +CSS_PROP(border-right, border_right, BorderRight, NS_STYLE_HINT_REFLOW) +CSS_PROP(border-right-color, border_right_color, BorderRightColor, NS_STYLE_HINT_VISUAL) +CSS_PROP(-moz-border-right-colors, border_right_colors, MozBorderRightColors, NS_STYLE_HINT_VISUAL) +CSS_PROP(border-right-style, border_right_style, BorderRightStyle, NS_STYLE_HINT_REFLOW) // on/off will need reflow +CSS_PROP(border-right-width, border_right_width, BorderRightWidth, NS_STYLE_HINT_REFLOW) +CSS_PROP(border-spacing, border_spacing, BorderSpacing, NS_STYLE_HINT_REFLOW) +CSS_PROP(border-style, border_style, BorderStyle, NS_STYLE_HINT_REFLOW) // on/off will need reflow +CSS_PROP(border-top, border_top, BorderTop, NS_STYLE_HINT_REFLOW) +CSS_PROP(border-top-color, border_top_color, BorderTopColor, NS_STYLE_HINT_VISUAL) +CSS_PROP(-moz-border-top-colors, border_top_colors, MozBorderTopColors, NS_STYLE_HINT_VISUAL) +CSS_PROP(border-top-style, border_top_style, BorderTopStyle, NS_STYLE_HINT_REFLOW) // on/off will need reflow +CSS_PROP(border-top-width, border_top_width, BorderTopWidth, NS_STYLE_HINT_REFLOW) +CSS_PROP(border-width, border_width, BorderWidth, NS_STYLE_HINT_REFLOW) +CSS_PROP_INTERNAL(-x-border-x-spacing, border_x_spacing, BorderXSpacing, NS_STYLE_HINT_REFLOW) // XXX bug 3935 +CSS_PROP_INTERNAL(-x-border-y-spacing, border_y_spacing, BorderYSpacing, NS_STYLE_HINT_REFLOW) // XXX bug 3935 +CSS_PROP(bottom, bottom, Bottom, NS_STYLE_HINT_REFLOW) +CSS_PROP(-moz-box-align, box_align, MozBoxAlign, NS_STYLE_HINT_REFLOW) // XXX bug 3935 +CSS_PROP(-moz-box-direction, box_direction, MozBoxDirection, NS_STYLE_HINT_REFLOW) // XXX bug 3935 +CSS_PROP(-moz-box-flex, box_flex, MozBoxFlex, NS_STYLE_HINT_REFLOW) // XXX bug 3935 +CSS_PROP(-moz-box-flex-group, box_flex_group, MozBoxFlexGroup, NS_STYLE_HINT_REFLOW) // XXX bug 3935 +CSS_PROP(-moz-box-orient, box_orient, MozBoxOrient, NS_STYLE_HINT_REFLOW) // XXX bug 3935 +CSS_PROP(-moz-box-pack, box_pack, MozBoxPack, NS_STYLE_HINT_REFLOW) // XXX bug 3935 +CSS_PROP(-moz-box-sizing, box_sizing, MozBoxSizing, NS_STYLE_HINT_REFLOW) // XXX bug 3935 +CSS_PROP(-moz-box-ordinal-group, box_ordinal_group, MozBoxOrdinalGroup, NS_STYLE_HINT_FRAMECHANGE) +CSS_PROP(caption-side, caption_side, CaptionSide, NS_STYLE_HINT_REFLOW) +CSS_PROP(clear, clear, Clear, NS_STYLE_HINT_REFLOW) +CSS_PROP(clip, clip, Clip, nsChangeHint_SyncFrameView) +CSS_PROP_INTERNAL(-x-clip-bottom, clip_bottom, ClipBottom, nsChangeHint_SyncFrameView) // XXX bug 3935 +CSS_PROP_INTERNAL(-x-clip-left, clip_left, ClipLeft, nsChangeHint_SyncFrameView) // XXX bug 3935 +CSS_PROP_INTERNAL(-x-clip-right, clip_right, ClipRight, nsChangeHint_SyncFrameView) // XXX bug 3935 +CSS_PROP_INTERNAL(-x-clip-top, clip_top, ClipTop, nsChangeHint_SyncFrameView) // XXX bug 3935 +CSS_PROP(color, color, Color, NS_STYLE_HINT_VISUAL) +CSS_PROP(content, content, Content, NS_STYLE_HINT_FRAMECHANGE) +CSS_PROP(counter-increment, counter_increment, CounterIncrement, NS_STYLE_HINT_REFLOW) +CSS_PROP(counter-reset, counter_reset, CounterReset, NS_STYLE_HINT_REFLOW) +CSS_PROP(-moz-counter-increment, _moz_counter_increment, MozCounterIncrement, NS_STYLE_HINT_REFLOW) // XXX bug 137285 +CSS_PROP(-moz-counter-reset, _moz_counter_reset, MozCounterReset, NS_STYLE_HINT_REFLOW) // XXX bug 137285 +CSS_PROP(cue, cue, Cue, NS_STYLE_HINT_AURAL) +CSS_PROP(cue-after, cue_after, CueAfter, NS_STYLE_HINT_AURAL) +CSS_PROP(cue-before, cue_before, CueBefore, NS_STYLE_HINT_AURAL) +CSS_PROP(cursor, cursor, Cursor, NS_STYLE_HINT_VISUAL) +CSS_PROP(direction, direction, Direction, NS_STYLE_HINT_REFLOW) +CSS_PROP(display, display, Display, NS_STYLE_HINT_FRAMECHANGE) +CSS_PROP(elevation, elevation, Elevation, NS_STYLE_HINT_AURAL) +CSS_PROP(empty-cells, empty_cells, EmptyCells, NS_STYLE_HINT_VISUAL) +CSS_PROP(float, float, CssFloat, NS_STYLE_HINT_FRAMECHANGE) +CSS_PROP(-moz-float-edge, float_edge, MozFloatEdge, NS_STYLE_HINT_REFLOW) // XXX bug 3935 +CSS_PROP(font, font, Font, NS_STYLE_HINT_REFLOW) +CSS_PROP(font-family, font_family, FontFamily, NS_STYLE_HINT_REFLOW) +CSS_PROP(font-size, font_size, FontSize, NS_STYLE_HINT_REFLOW) +CSS_PROP(font-size-adjust, font_size_adjust, FontSizeAdjust, NS_STYLE_HINT_REFLOW) +CSS_PROP(font-stretch, font_stretch, FontStretch, NS_STYLE_HINT_REFLOW) +CSS_PROP(font-style, font_style, FontStyle, NS_STYLE_HINT_REFLOW) +CSS_PROP(font-variant, font_variant, FontVariant, NS_STYLE_HINT_REFLOW) +CSS_PROP(font-weight, font_weight, FontWeight, NS_STYLE_HINT_REFLOW) +CSS_PROP(-moz-force-broken-image-icon, force_broken_image_icon, MozForceBrokenImageIcon, NS_STYLE_HINT_FRAMECHANGE) // bug 58646 +CSS_PROP(height, height, Height, NS_STYLE_HINT_REFLOW) +CSS_PROP(-moz-image-region, image_region, MozImageRegion, NS_STYLE_HINT_REFLOW) +CSS_PROP_INTERNAL(-x-image-region-bottom, image_region_bottom, MozImageRegionBottom, NS_STYLE_HINT_REFLOW) +CSS_PROP_INTERNAL(-x-image-region-left, image_region_left, MozImageRegionLeft, NS_STYLE_HINT_REFLOW) +CSS_PROP_INTERNAL(-x-image-region-right, image_region_right, MozImageRegionRight, NS_STYLE_HINT_REFLOW) +CSS_PROP_INTERNAL(-x-image-region-top, image_region_top, MozImageRegionTop, NS_STYLE_HINT_REFLOW) +CSS_PROP(-moz-key-equivalent, key_equivalent, MozKeyEquivalent, NS_STYLE_HINT_CONTENT) // This will need some other notification, but what? // XXX bug 3935 +CSS_PROP(left, left, Left, NS_STYLE_HINT_REFLOW) +CSS_PROP(letter-spacing, letter_spacing, LetterSpacing, NS_STYLE_HINT_REFLOW) +CSS_PROP(line-height, line_height, LineHeight, NS_STYLE_HINT_REFLOW) +CSS_PROP(list-style, list_style, ListStyle, NS_STYLE_HINT_REFLOW) +CSS_PROP(list-style-image, list_style_image, ListStyleImage, NS_STYLE_HINT_REFLOW) +CSS_PROP(list-style-position, list_style_position, ListStylePosition, NS_STYLE_HINT_REFLOW) +CSS_PROP(list-style-type, list_style_type, ListStyleType, NS_STYLE_HINT_REFLOW) +CSS_PROP(margin, margin, Margin, NS_STYLE_HINT_REFLOW) +CSS_PROP(margin-bottom, margin_bottom, MarginBottom, NS_STYLE_HINT_REFLOW) +CSS_PROP(margin-left, margin_left, MarginLeft, NS_STYLE_HINT_REFLOW) +CSS_PROP(margin-right, margin_right, MarginRight, NS_STYLE_HINT_REFLOW) +CSS_PROP(margin-top, margin_top, MarginTop, NS_STYLE_HINT_REFLOW) +CSS_PROP(marker-offset, marker_offset, MarkerOffset, NS_STYLE_HINT_REFLOW) +CSS_PROP(marks, marks, Marks, NS_STYLE_HINT_VISUAL) +CSS_PROP(max-height, max_height, MaxHeight, NS_STYLE_HINT_REFLOW) +CSS_PROP(max-width, max_width, MaxWidth, NS_STYLE_HINT_REFLOW) +CSS_PROP(min-height, min_height, MinHeight, NS_STYLE_HINT_REFLOW) +CSS_PROP(min-width, min_width, MinWidth, NS_STYLE_HINT_REFLOW) +CSS_PROP(-moz-opacity, opacity, MozOpacity, NS_STYLE_HINT_FRAMECHANGE) // XXX bug 3935 +CSS_PROP(orphans, orphans, Orphans, NS_STYLE_HINT_REFLOW) +CSS_PROP(outline, outline, Outline, NS_STYLE_HINT_VISUAL) +CSS_PROP(outline, outline_color, OutlineColor, NS_STYLE_HINT_VISUAL) +CSS_PROP(outline, outline_style, OutlineStyle, NS_STYLE_HINT_VISUAL) +CSS_PROP(outline, outline_width, OutlineWidth, NS_STYLE_HINT_VISUAL) +CSS_PROP(-moz-outline, _moz_outline, MozOutline, NS_STYLE_HINT_VISUAL) // XXX This is temporary fix for nsbeta3+ Bug 48973, turning outline into -moz-outline XXX bug 48973 +CSS_PROP(-moz-outline-color, _moz_outline_color, MozOutlineColor, NS_STYLE_HINT_VISUAL) // XXX bug 48973 +CSS_PROP(-moz-outline-style, _moz_outline_style, MozOutlineStyle, NS_STYLE_HINT_VISUAL) // XXX bug 48973 +CSS_PROP(-moz-outline-width, _moz_outline_width, MozOutlineWidth, NS_STYLE_HINT_VISUAL) // XXX bug 48973 +CSS_PROP(overflow, overflow, Overflow, NS_STYLE_HINT_FRAMECHANGE) +CSS_PROP(padding, padding, Padding, NS_STYLE_HINT_REFLOW) +CSS_PROP(padding-bottom, padding_bottom, PaddingBottom, NS_STYLE_HINT_REFLOW) +CSS_PROP(padding-left, padding_left, PaddingLeft, NS_STYLE_HINT_REFLOW) +CSS_PROP(padding-right, padding_right, PaddingRight, NS_STYLE_HINT_REFLOW) +CSS_PROP(padding-top, padding_top, PaddingTop, NS_STYLE_HINT_REFLOW) +CSS_PROP(page, page, Page, NS_STYLE_HINT_REFLOW) +CSS_PROP(page-break-after, page_break_after, PageBreakAfter, NS_STYLE_HINT_REFLOW) +CSS_PROP(page-break-before, page_break_before, PageBreakBefore, NS_STYLE_HINT_REFLOW) +CSS_PROP(page-break-inside, page_break_inside, PageBreakInside, NS_STYLE_HINT_REFLOW) +CSS_PROP(pause, pause, Pause, NS_STYLE_HINT_AURAL) +CSS_PROP(pause-after, pause_after, PauseAfter, NS_STYLE_HINT_AURAL) +CSS_PROP(pause-before, pause_before, PauseBefore, NS_STYLE_HINT_AURAL) +CSS_PROP(pitch, pitch, Pitch, NS_STYLE_HINT_AURAL) +CSS_PROP(pitch-range, pitch_range, PitchRange, NS_STYLE_HINT_AURAL) +CSS_PROP(play-during, play_during, PlayDuring, NS_STYLE_HINT_AURAL) +CSS_PROP_INTERNAL(-x-play-during-flags, play_during_flags, PlayDuringFlags, NS_STYLE_HINT_AURAL) // XXX why is this here? +CSS_PROP(position, position, Position, NS_STYLE_HINT_FRAMECHANGE) +CSS_PROP(quotes, quotes, Quotes, NS_STYLE_HINT_REFLOW) +CSS_PROP_INTERNAL(-x-quotes-close, quotes_close, QuotesClose, NS_STYLE_HINT_REFLOW) // XXX bug 3935 +CSS_PROP_INTERNAL(-x-quotes-open, quotes_open, QuotesOpen, NS_STYLE_HINT_REFLOW) // XXX bug 3935 +CSS_PROP(-moz-resizer, resizer, MozResizer, NS_STYLE_HINT_FRAMECHANGE) // XXX bug 3935 +CSS_PROP(richness, richness, Richness, NS_STYLE_HINT_AURAL) +CSS_PROP(right, right, Right, NS_STYLE_HINT_REFLOW) +CSS_PROP(size, size, Size, NS_STYLE_HINT_REFLOW) +CSS_PROP_INTERNAL(-x-size-height, size_height, SizeHeight, NS_STYLE_HINT_REFLOW) // XXX bug 3935 +CSS_PROP_INTERNAL(-x-size-width, size_width, SizeWidth, NS_STYLE_HINT_REFLOW) // XXX bug 3935 +CSS_PROP(speak, speak, Speak, NS_STYLE_HINT_AURAL) +CSS_PROP(speak-header, speak_header, SpeakHeader, NS_STYLE_HINT_AURAL) +CSS_PROP(speak-numeral, speak_numeral, SpeakNumeral, NS_STYLE_HINT_AURAL) +CSS_PROP(speak-punctuation, speak_punctuation, SpeakPunctuation, NS_STYLE_HINT_AURAL) +CSS_PROP(speech-rate, speech_rate, SpeechRate, NS_STYLE_HINT_AURAL) +CSS_PROP(stress, stress, Stress, NS_STYLE_HINT_AURAL) +CSS_PROP(table-layout, table_layout, TableLayout, NS_STYLE_HINT_REFLOW) +CSS_PROP(text-align, text_align, TextAlign, NS_STYLE_HINT_REFLOW) +CSS_PROP(text-decoration, text_decoration, TextDecoration, NS_STYLE_HINT_VISUAL) +CSS_PROP(text-indent, text_indent, TextIndent, NS_STYLE_HINT_REFLOW) +CSS_PROP(text-shadow, text_shadow, TextShadow, NS_STYLE_HINT_VISUAL) +CSS_PROP_INTERNAL(-x-text-shadow-color, text_shadow_color, TextShadowColor, NS_STYLE_HINT_VISUAL) // XXX bug 3935 +CSS_PROP_INTERNAL(-x-text-shadow-radius, text_shadow_radius, TextShadowRadius, NS_STYLE_HINT_VISUAL) // XXX bug 3935 +CSS_PROP_INTERNAL(-x-text-shadow-x, text_shadow_x, TextShadowX, NS_STYLE_HINT_VISUAL) // XXX bug 3935 +CSS_PROP_INTERNAL(-x-text-shadow-y, text_shadow_y, TextShadowY, NS_STYLE_HINT_VISUAL) // XXX bug 3935 +CSS_PROP(text-transform, text_transform, TextTransform, NS_STYLE_HINT_REFLOW) +CSS_PROP(top, top, Top, NS_STYLE_HINT_REFLOW) +CSS_PROP(unicode-bidi, unicode_bidi, UnicodeBidi, NS_STYLE_HINT_REFLOW) +CSS_PROP(-moz-user-focus, user_focus, MozUserFocus, NS_STYLE_HINT_CONTENT) // XXX bug 3935 +CSS_PROP(-moz-user-input, user_input, MozUserInput, NS_STYLE_HINT_FRAMECHANGE) // XXX ??? // XXX bug 3935 +CSS_PROP(-moz-user-modify, user_modify, MozUserModify, NS_STYLE_HINT_FRAMECHANGE) // XXX bug 3935 +CSS_PROP(-moz-user-select, user_select, MozUserSelect, NS_STYLE_HINT_CONTENT) // XXX bug 3935 +CSS_PROP(vertical-align, vertical_align, VerticalAlign, NS_STYLE_HINT_REFLOW) +CSS_PROP(visibility, visibility, Visibility, NS_STYLE_HINT_REFLOW) // reflow for collapse +CSS_PROP(voice-family, voice_family, VoiceFamily, NS_STYLE_HINT_AURAL) +CSS_PROP(volume, volume, Volume, NS_STYLE_HINT_AURAL) +CSS_PROP(white-space, white_space, WhiteSpace, NS_STYLE_HINT_REFLOW) +CSS_PROP(widows, widows, Widows, NS_STYLE_HINT_REFLOW) +CSS_PROP(width, width, Width, NS_STYLE_HINT_REFLOW) +CSS_PROP(word-spacing, word_spacing, WordSpacing, NS_STYLE_HINT_REFLOW) +CSS_PROP(z-index, z_index, ZIndex, NS_STYLE_HINT_REFLOW) #ifdef MOZ_SVG // XXX treat SVG's CSS Properties as internal for now. // Do we want to create an nsIDOMSVGCSS2Properties interface? -CSS_PROP_INTERNAL(fill, fill, Fill, VISUAL) -CSS_PROP_INTERNAL(fill-opacity, fill_opacity, FillOpacity, VISUAL) -CSS_PROP_INTERNAL(fill-rule, fill_rule, FillRule, VISUAL) -CSS_PROP_INTERNAL(stroke, stroke, Stroke, VISUAL) -CSS_PROP_INTERNAL(stroke-dasharray, stroke_dasharray, StrokeDasharray, VISUAL) -CSS_PROP_INTERNAL(stroke-dashoffset, stroke_dashoffset, StrokeDashoffset, VISUAL) -CSS_PROP_INTERNAL(stroke-linecap, stroke_linecap, StrokeLinecap, VISUAL) -CSS_PROP_INTERNAL(stroke-linejoin, stroke_linejoin, StrokeLinejoin, VISUAL) -CSS_PROP_INTERNAL(stroke-miterlimit, stroke_miterlimit, StrokeMiterlimit, VISUAL) -CSS_PROP_INTERNAL(stroke-opacity, stroke_opacity, StrokeOpacity, VISUAL) -CSS_PROP_INTERNAL(stroke-width, stroke_width, StrokeWidth, VISUAL) +CSS_PROP_INTERNAL(fill, fill, Fill, NS_STYLE_HINT_VISUAL) +CSS_PROP_INTERNAL(fill-opacity, fill_opacity, FillOpacity, NS_STYLE_HINT_VISUAL) +CSS_PROP_INTERNAL(fill-rule, fill_rule, FillRule, NS_STYLE_HINT_VISUAL) +CSS_PROP_INTERNAL(stroke, stroke, Stroke, NS_STYLE_HINT_VISUAL) +CSS_PROP_INTERNAL(stroke-dasharray, stroke_dasharray, StrokeDasharray, NS_STYLE_HINT_VISUAL) +CSS_PROP_INTERNAL(stroke-dashoffset, stroke_dashoffset, StrokeDashoffset, NS_STYLE_HINT_VISUAL) +CSS_PROP_INTERNAL(stroke-linecap, stroke_linecap, StrokeLinecap, NS_STYLE_HINT_VISUAL) +CSS_PROP_INTERNAL(stroke-linejoin, stroke_linejoin, StrokeLinejoin, NS_STYLE_HINT_VISUAL) +CSS_PROP_INTERNAL(stroke-miterlimit, stroke_miterlimit, StrokeMiterlimit, NS_STYLE_HINT_VISUAL) +CSS_PROP_INTERNAL(stroke-opacity, stroke_opacity, StrokeOpacity, NS_STYLE_HINT_VISUAL) +CSS_PROP_INTERNAL(stroke-width, stroke_width, StrokeWidth, NS_STYLE_HINT_VISUAL) #endif // Clean up after ourselves diff --git a/layout/style/nsCSSProps.cpp b/layout/style/nsCSSProps.cpp index 9bc1ef931b6..67e689779c6 100644 --- a/layout/style/nsCSSProps.cpp +++ b/layout/style/nsCSSProps.cpp @@ -1286,7 +1286,7 @@ PRBool nsCSSProps::GetColorName(PRInt32 aPropValue, nsCString &aStr) } // define array of all CSS property hints -#define CSS_PROP(_name, _id, _method, _hint) NS_STYLE_HINT_##_hint, +#define CSS_PROP(_name, _id, _method, _hint) _hint, const nsChangeHint nsCSSProps::kHintTable[eCSSProperty_COUNT] = { #include "nsCSSPropList.h" }; diff --git a/layout/style/nsStyleStruct.cpp b/layout/style/nsStyleStruct.cpp index d8f8cc5f026..2425a9f2442 100644 --- a/layout/style/nsStyleStruct.cpp +++ b/layout/style/nsStyleStruct.cpp @@ -1049,23 +1049,28 @@ nsStyleDisplay::nsStyleDisplay(const nsStyleDisplay& aSource) nsChangeHint nsStyleDisplay::CalcDifference(const nsStyleDisplay& aOther) const { - if (mBinding != aOther.mBinding || mPosition != aOther.mPosition) - return NS_STYLE_HINT_FRAMECHANGE; + nsChangeHint hint = nsChangeHint_None; - if ((mDisplay == aOther.mDisplay) && - (mFloats == aOther.mFloats) && - (mOverflow == aOther.mOverflow)) { - if ((mBreakType == aOther.mBreakType) && - (mBreakBefore == aOther.mBreakBefore) && - (mBreakAfter == aOther.mBreakAfter) && - (mClipFlags == aOther.mClipFlags) && - (mClip == aOther.mClip) && - (mAppearance == aOther.mAppearance)) { - return NS_STYLE_HINT_NONE; - } - return NS_STYLE_HINT_REFLOW; - } - return NS_STYLE_HINT_FRAMECHANGE; + if (mBinding != aOther.mBinding + || mPosition != aOther.mPosition + || mDisplay != aOther.mDisplay + || mFloats != aOther.mFloats + || mOverflow != aOther.mOverflow) + NS_UpdateHint(hint, nsChangeHint_ReconstructFrame); + + // XXX the following is conservative, for now: changing float breaking shouldn't + // necessarily require a repaint, reflow should suffice. + if (mBreakType != aOther.mBreakType + || mBreakBefore != aOther.mBreakBefore + || mBreakAfter != aOther.mBreakAfter + || mAppearance != aOther.mAppearance) + NS_UpdateHint(hint, NS_CombineHint(nsChangeHint_ReflowFrame, nsChangeHint_RepaintFrame)); + + if (mClipFlags != aOther.mClipFlags + || mClip != aOther.mClip) + NS_UpdateHint(hint, nsChangeHint_SyncFrameView); + + return hint; } // -------------------- diff --git a/layout/xul/base/src/nsBoxFrame.cpp b/layout/xul/base/src/nsBoxFrame.cpp index e91f1ce497f..ca38a7165da 100644 --- a/layout/xul/base/src/nsBoxFrame.cpp +++ b/layout/xul/base/src/nsBoxFrame.cpp @@ -2736,12 +2736,8 @@ nsBoxFrame::CreateViewForFrame(nsIPresContext* aPresContext, // Create a view static NS_DEFINE_IID(kViewCID, NS_VIEW_CID); - - nsresult result = nsComponentManager::CreateInstance(kViewCID, - nsnull, - NS_GET_IID(nsIView), - (void **)&view); - if (NS_OK == result) { + nsresult result = CallCreateInstance(kViewCID, &view); + if (NS_SUCCEEDED(result)) { nsIViewManager* viewManager; parentView->GetViewManager(viewManager); NS_ASSERTION(nsnull != viewManager, "null view manager"); @@ -2760,7 +2756,7 @@ nsBoxFrame::CreateViewForFrame(nsIPresContext* aPresContext, // Insert the view into the view hierarchy. If the parent view is a // scrolling view we need to do this differently nsIScrollableView* scrollingView; - if (NS_SUCCEEDED(parentView->QueryInterface(NS_GET_IID(nsIScrollableView), (void**)&scrollingView))) { + if (NS_SUCCEEDED(CallQueryInterface(parentView, &scrollingView))) { scrollingView->SetScrolledView(view); } else { viewManager->SetViewZIndex(view, autoZIndex, zIndex); diff --git a/layout/xul/base/src/nsScrollBoxFrame.cpp b/layout/xul/base/src/nsScrollBoxFrame.cpp index b3bd6902152..3c4d0b8c184 100644 --- a/layout/xul/base/src/nsScrollBoxFrame.cpp +++ b/layout/xul/base/src/nsScrollBoxFrame.cpp @@ -243,57 +243,23 @@ nsScrollBoxFrame::CreateScrollingView(nsIPresContext* aPresContext) GetScrollingParentView(aPresContext, parent, &parentView); // Get the view manager - nsIViewManager* viewManager; - parentView->GetViewManager(viewManager); + nsCOMPtr viewManager; + parentView->GetViewManager(*getter_AddRefs(viewManager)); - // Create the scrolling view - nsresult rv = nsComponentManager::CreateInstance(kScrollBoxViewCID, - nsnull, - NS_GET_IID(nsIView), - (void **)&view); - - - - - - - if (NS_OK == rv) { - const nsStyleDisplay* display = (const nsStyleDisplay*) - mStyleContext->GetStyleData(eStyleStruct_Display); - const nsStylePosition* position = (const nsStylePosition*) - mStyleContext->GetStyleData(eStyleStruct_Position); - const nsStyleBorder* borderStyle = (const nsStyleBorder*) - mStyleContext->GetStyleData(eStyleStruct_Border); - const nsStyleVisibility* vis = - (const nsStyleVisibility*)mStyleContext->GetStyleData(eStyleStruct_Visibility); - - // Get the z-index - PRInt32 zIndex = 0; - PRBool autoZIndex = PR_FALSE; - if (eStyleUnit_Integer == position->mZIndex.GetUnit()) { - zIndex = position->mZIndex.GetIntValue(); - } else if (eStyleUnit_Auto == position->mZIndex.GetUnit()) { - autoZIndex = PR_TRUE; - } - + nsresult rv = CallCreateInstance(kScrollBoxViewCID, &view); + if (NS_SUCCEEDED(rv)) { // Initialize the scrolling view - view->Init(viewManager, mRect, parentView, vis->IsVisibleOrCollapsed() ? - nsViewVisibility_kShow : nsViewVisibility_kHide); + view->Init(viewManager, mRect, parentView); - viewManager->SetViewZIndex(view, autoZIndex, zIndex); + SyncFrameViewProperties(aPresContext, this, mStyleContext, view); // Insert the view into the view hierarchy // XXX Put view last in document order until we know how to do better viewManager->InsertChild(parentView, view, nsnull, PR_TRUE); - // Set the view's opacity - viewManager->SetViewOpacity(view, vis->mOpacity); - - // Because we only paint the border and we don't paint a background, - // inform the view manager that we have transparent content - viewManager->SetViewContentTransparency(view, PR_TRUE); - + const nsStyleDisplay* display; + ::GetStyleData(mStyleContext, &display); // If it's fixed positioned, then create a widget too CreateScrollingViewWidget(view, display); @@ -308,6 +274,8 @@ nsScrollBoxFrame::CreateScrollingView(nsIPresContext* aPresContext) scrollingView->CreateScrollControls(); } + const nsStyleBorder* borderStyle; + ::GetStyleData(mStyleContext, &borderStyle); // Set the scrolling view's insets to whatever our border is nsMargin border; if (!borderStyle->GetBorder(border)) { @@ -319,8 +287,6 @@ nsScrollBoxFrame::CreateScrollingView(nsIPresContext* aPresContext) // Remember our view SetView(aPresContext, view); } - - NS_RELEASE(viewManager); return rv; } diff --git a/view/src/nsViewManager.cpp b/view/src/nsViewManager.cpp index 912c7b5db01..ce7ad6b83b5 100644 --- a/view/src/nsViewManager.cpp +++ b/view/src/nsViewManager.cpp @@ -2553,15 +2553,17 @@ NS_IMETHODIMP nsViewManager::SetViewChildClipRegion(nsIView *aView, const nsRegi view->SetClipChildren(newClipFlag); view->SetChildClip(newClipRect); - // Invalidate changed areas - // Paint (new - old) in the current view - InvalidateRectDifference(view, newClipRect, oldClipRect, NS_VMREFRESH_NO_SYNC); - // Paint (old - new) in the parent view, since it'll be clipped out of the current view - nsView* parent = view->GetParent(); - if (parent != nsnull) { - view->ConvertToParentCoords(&oldClipRect.x, &oldClipRect.y); - view->ConvertToParentCoords(&newClipRect.x, &newClipRect.y); - InvalidateRectDifference(parent, oldClipRect, newClipRect, NS_VMREFRESH_NO_SYNC); + if (IsViewInserted(view)) { + // Invalidate changed areas + // Paint (new - old) in the current view + InvalidateRectDifference(view, newClipRect, oldClipRect, NS_VMREFRESH_NO_SYNC); + // Paint (old - new) in the parent view, since it'll be clipped out of the current view + nsView* parent = view->GetParent(); + if (parent != nsnull) { + view->ConvertToParentCoords(&oldClipRect.x, &oldClipRect.y); + view->ConvertToParentCoords(&newClipRect.x, &newClipRect.y); + InvalidateRectDifference(parent, oldClipRect, newClipRect, NS_VMREFRESH_NO_SYNC | NS_VMREFRESH_FORCHILD); + } } return NS_OK; @@ -2850,9 +2852,9 @@ NS_IMETHODIMP nsViewManager::SetViewZIndex(nsIView *aView, PRBool aAutoZIndex, P PRInt32 oldidx = view->GetZIndex(); view->SetZIndex(aAutoZIndex, aZIndex, aTopMost); - if (IsViewInserted(view)) { - if (CompareZIndex(oldidx, oldTopMost, oldIsAuto, - aZIndex, aTopMost, aAutoZIndex) != 0) { + if (CompareZIndex(oldidx, oldTopMost, oldIsAuto, + aZIndex, aTopMost, aAutoZIndex) != 0) { + if (IsViewInserted(view)) { nsView *parent = view->GetParent(); if (nsnull != parent) { //we don't just call the view manager's RemoveChild() @@ -2862,20 +2864,19 @@ NS_IMETHODIMP nsViewManager::SetViewZIndex(nsIView *aView, PRBool aAutoZIndex, P UpdateTransCnt(view, nsnull); rv = InsertChild(parent, view, aZIndex); } - // XXX The following else block is a workaround and should be cleaned up (bug 43410) - } else { - nsCOMPtr widget; - view->GetWidget(*getter_AddRefs(widget)); - if (widget) { - widget->SetZIndex(aZIndex); - } } + } else { + nsCOMPtr widget; + view->GetWidget(*getter_AddRefs(widget)); + if (widget) { + widget->SetZIndex(aZIndex); + } + } - nsZPlaceholderView* zParentView = view->GetZParent(); - if (nsnull != zParentView) { - SetViewZIndex(zParentView, aAutoZIndex, aZIndex, aTopMost); - } + nsZPlaceholderView* zParentView = view->GetZParent(); + if (nsnull != zParentView) { + SetViewZIndex(zParentView, aAutoZIndex, aZIndex, aTopMost); } return rv; @@ -2888,13 +2889,15 @@ NS_IMETHODIMP nsViewManager::SetViewContentTransparency(nsIView *aView, PRBool a view->HasTransparency(trans); - if (trans != aTransparent && IsViewInserted(view)) - { - UpdateTransCnt(view, nsnull); - view->SetContentTransparency(aTransparent); - UpdateTransCnt(nsnull, view); + if (trans != aTransparent) { + UpdateTransCnt(view, nsnull); + view->SetContentTransparency(aTransparent); + UpdateTransCnt(nsnull, view); + + if (IsViewInserted(view)) { UpdateView(view, NS_VMREFRESH_NO_SYNC); } + } return NS_OK; } @@ -2906,12 +2909,15 @@ NS_IMETHODIMP nsViewManager::SetViewOpacity(nsIView *aView, float aOpacity) view->GetOpacity(opacity); - if (opacity != aOpacity && IsViewInserted(view)) + if (opacity != aOpacity) { UpdateTransCnt(view, nsnull); view->SetOpacity(aOpacity); UpdateTransCnt(nsnull, view); - UpdateView(view, NS_VMREFRESH_NO_SYNC); + + if (IsViewInserted(view)) { + UpdateView(view, NS_VMREFRESH_NO_SYNC); + } } return NS_OK;