diff --git a/widget/xpwidgets/ContentHelper.cpp b/widget/xpwidgets/ContentHelper.cpp index a56baaaba924..002c992a117a 100644 --- a/widget/xpwidgets/ContentHelper.cpp +++ b/widget/xpwidgets/ContentHelper.cpp @@ -18,18 +18,27 @@ namespace widget { uint32_t ContentHelper::GetTouchActionFromFrame(nsIFrame* aFrame) { - if (!aFrame || !aFrame->GetContent() || !aFrame->GetContent()->GetPrimaryFrame()) { - // If frame is invalid or null then return default value. + // If aFrame is null then return default value + if (!aFrame) { return NS_STYLE_TOUCH_ACTION_AUTO; } - if (!aFrame->IsFrameOfType(nsIFrame::eSVG) && !aFrame->IsFrameOfType(nsIFrame::eBlockFrame)) { - // Since touch-action property can be applied to only svg and block-level - // elements we ignore frames of other types. + // The touch-action CSS property applies to: all elements except: + // non-replaced inline elements, table rows, row groups, table columns, and column groups + bool isNonReplacedInlineElement = aFrame->IsFrameOfType(nsIFrame::eLineParticipant); + if (isNonReplacedInlineElement) { return NS_STYLE_TOUCH_ACTION_AUTO; } - return (aFrame->GetContent()->GetPrimaryFrame()->StyleDisplay()->mTouchAction); + const nsStyleDisplay* disp = aFrame->StyleDisplay(); + bool isTableElement = disp->IsInnerTableStyle() && + disp->mDisplay != NS_STYLE_DISPLAY_TABLE_CELL && + disp->mDisplay != NS_STYLE_DISPLAY_TABLE_CAPTION; + if (isTableElement) { + return NS_STYLE_TOUCH_ACTION_AUTO; + } + + return disp->mTouchAction; } void