OLD | NEW |
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 Loading... |
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 nodeAllowsAdjacentWhitespace(Node* node) | 254 static inline bool canHaveWhitespaceChildren(const LayoutObject& parent) |
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) | |
263 { | 255 { |
264 // <button> should allow whitespace even though LayoutFlexibleBox doesn't. | 256 // <button> should allow whitespace even though LayoutFlexibleBox doesn't. |
265 if (parent.isLayoutButton()) | 257 if (parent.isLayoutButton()) |
266 return true; | 258 return true; |
267 | 259 |
| 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 |
268 if (parent.isTable() || parent.isTableRow() || parent.isTableSection() | 265 if (parent.isTable() || parent.isTableRow() || parent.isTableSection() |
269 || parent.isLayoutTableCol() || parent.isFrameSet() | 266 || parent.isLayoutTableCol() || parent.isFrameSet() |
270 || parent.isFlexibleBox() || parent.isLayoutGrid() | 267 || parent.isFlexibleBox() || parent.isLayoutGrid() |
271 || parent.isSVGRoot() | 268 || parent.isSVGRoot() |
272 || parent.isSVGContainer() | 269 || parent.isSVGContainer() |
273 || parent.isSVGImage() | 270 || parent.isSVGImage() |
274 || parent.isSVGShape()) { | 271 || 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()); | |
279 return false; | 272 return false; |
280 } | |
281 return true; | 273 return true; |
282 } | 274 } |
283 | 275 |
284 bool Text::textLayoutObjectIsNeeded(const ComputedStyle& style, const LayoutObje
ct& parent) | 276 bool Text::textLayoutObjectIsNeeded(const ComputedStyle& style, const LayoutObje
ct& parent) |
285 { | 277 { |
286 if (!parent.canHaveChildren()) | 278 if (!parent.canHaveChildren()) |
287 return false; | 279 return false; |
288 | 280 |
289 if (isEditingText()) | 281 if (isEditingText()) |
290 return true; | 282 return true; |
291 | 283 |
292 if (!length()) | 284 if (!length()) |
293 return false; | 285 return false; |
294 | 286 |
295 if (style.display() == NONE) | 287 if (style.display() == NONE) |
296 return false; | 288 return false; |
297 | 289 |
298 if (!containsOnlyWhitespace()) | 290 if (!containsOnlyWhitespace()) |
299 return true; | 291 return true; |
300 | 292 |
301 if (!canHaveWhitespaceChildren(parent, this)) | 293 if (!canHaveWhitespaceChildren(parent)) |
302 return false; | 294 return false; |
303 | 295 |
304 // pre-wrap in SVG never makes layoutObject. | 296 // pre-wrap in SVG never makes layoutObject. |
305 if (style.whiteSpace() == PRE_WRAP && parent.isSVG()) | 297 if (style.whiteSpace() == PRE_WRAP && parent.isSVG()) |
306 return false; | 298 return false; |
307 | 299 |
308 // pre/pre-wrap/pre-line always make layoutObjects. | 300 // pre/pre-wrap/pre-line always make layoutObjects. |
309 if (style.preserveNewline()) | 301 if (style.preserveNewline()) |
310 return true; | 302 return true; |
311 | 303 |
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
460 result.appendLiteral("; "); | 452 result.appendLiteral("; "); |
461 result.appendLiteral("value="); | 453 result.appendLiteral("value="); |
462 result.append(s); | 454 result.append(s); |
463 } | 455 } |
464 | 456 |
465 strncpy(buffer, result.toString().utf8().data(), length - 1); | 457 strncpy(buffer, result.toString().utf8().data(), length - 1); |
466 } | 458 } |
467 #endif | 459 #endif |
468 | 460 |
469 } // namespace blink | 461 } // namespace blink |
OLD | NEW |