From da58719217c460b5331dc0232e494fc1b8959a5c Mon Sep 17 00:00:00 2001 From: Maksim Lebedev Date: Mon, 26 May 2014 00:24:00 +0200 Subject: [PATCH] Bug 1005937 - Make the 'touch-action' CSS property apply to all elements except non-replaced inline elements and table rows, columns, and row/column-groups. r=dbaron --- widget/xpwidgets/ContentHelper.cpp | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) 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