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

This commit is contained in:
Maksim Lebedev 2014-05-26 00:24:00 +02:00
parent f1e5d44011
commit 21164b9f75

View File

@ -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