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

Side by Side Diff: Source/core/dom/Text.cpp

Issue 1334373002: Don't allow whitespace between elements with display:table-cell (Closed) Base URL: svn://svn.chromium.org/blink/branches/chromium/2454
Patch Set: Created 5 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « LayoutTests/platform/linux/tables/mozilla/bugs/bug2479-1-expected.txt ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org)
3 * (C) 1999 Antti Koivisto (koivisto@kde.org) 3 * (C) 1999 Antti Koivisto (koivisto@kde.org)
4 * Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights reserved. 4 * Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights reserved.
5 * 5 *
6 * This library is free software; you can redistribute it and/or 6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Library General Public 7 * modify it under the terms of the GNU Library General Public
8 * License as published by the Free Software Foundation; either 8 * License as published by the Free Software Foundation; either
9 * version 2 of the License, or (at your option) any later version. 9 * version 2 of the License, or (at your option) any later version.
10 * 10 *
(...skipping 233 matching lines...) Expand 10 before | Expand all | Expand 10 after
244 LayoutObject* child = parent.slowFirstChild(); 244 LayoutObject* child = parent.slowFirstChild();
245 if (!child || !child->isAnonymous()) 245 if (!child || !child->isAnonymous())
246 return false; 246 return false;
247 if (child->isTableCell()) 247 if (child->isTableCell())
248 return true; 248 return true;
249 if (child->isTableSection() || child->isTableRow()) 249 if (child->isTableSection() || child->isTableRow())
250 return hasGeneratedAnonymousTableCells(*child); 250 return hasGeneratedAnonymousTableCells(*child);
251 return false; 251 return false;
252 } 252 }
253 253
254 static inline bool canHaveWhitespaceChildren(const LayoutObject& parent) 254 static inline bool nodeAllowsAdjacentWhitespace(Node* node)
255 {
256 if (!node)
257 return true;
258 const ComputedStyle* style = node->ensureComputedStyle();
259 return style && style->originalDisplay() != TABLE_CELL && !isHTMLTableCellEl ement(node);
260 }
261
262 static inline bool canHaveWhitespaceChildren(const LayoutObject& parent, Text* t ext)
255 { 263 {
256 // <button> should allow whitespace even though LayoutFlexibleBox doesn't. 264 // <button> should allow whitespace even though LayoutFlexibleBox doesn't.
257 if (parent.isLayoutButton()) 265 if (parent.isLayoutButton())
258 return true; 266 return true;
259 267
260 // Allow whitespace when the text is inside a table, section or row element that
261 // has generated anonymous table cells to hold its contents.
262 if (hasGeneratedAnonymousTableCells(parent))
263 return true;
264
265 if (parent.isTable() || parent.isTableRow() || parent.isTableSection() 268 if (parent.isTable() || parent.isTableRow() || parent.isTableSection()
266 || parent.isLayoutTableCol() || parent.isFrameSet() 269 || parent.isLayoutTableCol() || parent.isFrameSet()
267 || parent.isFlexibleBox() || parent.isLayoutGrid() 270 || parent.isFlexibleBox() || parent.isLayoutGrid()
268 || parent.isSVGRoot() 271 || parent.isSVGRoot()
269 || parent.isSVGContainer() 272 || parent.isSVGContainer()
270 || parent.isSVGImage() 273 || parent.isSVGImage()
271 || parent.isSVGShape()) 274 || parent.isSVGShape()) {
275 // Allow whitespace when the text is inside a table, section or row elem ent that
276 // has generated anonymous table cells to hold its contents.
277 if (hasGeneratedAnonymousTableCells(parent))
278 return nodeAllowsAdjacentWhitespace(text->previousSibling()) && node AllowsAdjacentWhitespace(text->nextSibling());
272 return false; 279 return false;
280 }
273 return true; 281 return true;
274 } 282 }
275 283
276 bool Text::textLayoutObjectIsNeeded(const ComputedStyle& style, const LayoutObje ct& parent) 284 bool Text::textLayoutObjectIsNeeded(const ComputedStyle& style, const LayoutObje ct& parent)
277 { 285 {
278 if (!parent.canHaveChildren()) 286 if (!parent.canHaveChildren())
279 return false; 287 return false;
280 288
281 if (isEditingText()) 289 if (isEditingText())
282 return true; 290 return true;
283 291
284 if (!length()) 292 if (!length())
285 return false; 293 return false;
286 294
287 if (style.display() == NONE) 295 if (style.display() == NONE)
288 return false; 296 return false;
289 297
290 if (!containsOnlyWhitespace()) 298 if (!containsOnlyWhitespace())
291 return true; 299 return true;
292 300
293 if (!canHaveWhitespaceChildren(parent)) 301 if (!canHaveWhitespaceChildren(parent, this))
294 return false; 302 return false;
295 303
296 // pre-wrap in SVG never makes layoutObject. 304 // pre-wrap in SVG never makes layoutObject.
297 if (style.whiteSpace() == PRE_WRAP && parent.isSVG()) 305 if (style.whiteSpace() == PRE_WRAP && parent.isSVG())
298 return false; 306 return false;
299 307
300 // pre/pre-wrap/pre-line always make layoutObjects. 308 // pre/pre-wrap/pre-line always make layoutObjects.
301 if (style.preserveNewline()) 309 if (style.preserveNewline())
302 return true; 310 return true;
303 311
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after
452 result.appendLiteral("; "); 460 result.appendLiteral("; ");
453 result.appendLiteral("value="); 461 result.appendLiteral("value=");
454 result.append(s); 462 result.append(s);
455 } 463 }
456 464
457 strncpy(buffer, result.toString().utf8().data(), length - 1); 465 strncpy(buffer, result.toString().utf8().data(), length - 1);
458 } 466 }
459 #endif 467 #endif
460 468
461 } // namespace blink 469 } // namespace blink
OLDNEW
« no previous file with comments | « LayoutTests/platform/linux/tables/mozilla/bugs/bug2479-1-expected.txt ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698