Chromium Code Reviews| 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 227 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 238 return cloneWithData(data()); | 238 return cloneWithData(data()); |
| 239 } | 239 } |
| 240 | 240 |
| 241 static inline bool hasGeneratedAnonymousTableCells(const LayoutObject& parent) | 241 static inline bool hasGeneratedAnonymousTableCells(const LayoutObject& parent) |
| 242 { | 242 { |
| 243 // We're checking whether the table part has generated anonymous table | 243 // We're checking whether the table part has generated anonymous table |
| 244 // part wrappers to hold its contents, so inspecting its first child will su ffice. | 244 // part wrappers to hold its contents, so inspecting its first child will su ffice. |
| 245 LayoutObject* child = parent.slowFirstChild(); | 245 LayoutObject* child = parent.slowFirstChild(); |
| 246 if (!child || !child->isAnonymous()) | 246 if (!child || !child->isAnonymous()) |
| 247 return false; | 247 return false; |
| 248 if (child->isTableCell()) { | 248 if (child->isTableCell()) |
| 249 LayoutObject* firstChild = child->slowFirstChild(); | 249 return true; |
| 250 // Ignore the anonymous table cell if it is wrapping a table cell elemen t (e.g. because of <td style="display:block;">). | |
| 251 return !firstChild || !firstChild->node() || !isHTMLTableCellElement(fir stChild->node()); | |
| 252 } | |
| 253 if (child->isTableSection() || child->isTableRow()) | 250 if (child->isTableSection() || child->isTableRow()) |
| 254 return hasGeneratedAnonymousTableCells(*child); | 251 return hasGeneratedAnonymousTableCells(*child); |
| 255 return false; | 252 return false; |
| 256 } | 253 } |
| 257 | 254 |
| 258 static inline bool canHaveWhitespaceChildren(const LayoutObject& parent) | 255 static inline bool nodeAllowsWhitespace(Node* node) |
|
mstensho (USE GERRIT)
2015/08/26 18:45:56
How about nodeAllowsAdjacentWhitespace() or someth
| |
| 256 { | |
| 257 if (!node) | |
| 258 return true; | |
| 259 const ComputedStyle* style = node->ensureComputedStyle(); | |
| 260 return style && style->originalDisplay() != TABLE_CELL && !isHTMLTableCellEl ement(node); | |
| 261 } | |
| 262 | |
| 263 static inline bool canHaveWhitespaceChildren(const LayoutObject& parent, Node* n ode) | |
|
mstensho (USE GERRIT)
2015/08/26 18:45:56
|node| should be of type Text* (and probably be na
| |
| 259 { | 264 { |
| 260 // <button> should allow whitespace even though LayoutFlexibleBox doesn't. | 265 // <button> should allow whitespace even though LayoutFlexibleBox doesn't. |
| 261 if (parent.isLayoutButton()) | 266 if (parent.isLayoutButton()) |
| 262 return true; | 267 return true; |
| 263 | 268 |
| 264 // Allow whitespace when the text is inside a table, section or row element that | 269 // Allow whitespace when the text is inside a table, section or row element that |
| 265 // has generated anonymous table cells to hold its contents. | 270 // has generated anonymous table cells to hold its contents. |
| 266 if (hasGeneratedAnonymousTableCells(parent)) | 271 if (hasGeneratedAnonymousTableCells(parent)) |
|
mstensho (USE GERRIT)
2015/08/26 18:45:56
Can we move this block inside the "if (parent.isTa
| |
| 267 return true; | 272 return nodeAllowsWhitespace(node->previousSibling()) && nodeAllowsWhites pace(node->nextSibling()); |
| 268 | 273 |
| 269 if (parent.isTable() || parent.isTableRow() || parent.isTableSection() | 274 if (parent.isTable() || parent.isTableRow() || parent.isTableSection() |
| 270 || parent.isLayoutTableCol() || parent.isFrameSet() | 275 || parent.isLayoutTableCol() || parent.isFrameSet() |
| 271 || parent.isFlexibleBox() || parent.isLayoutGrid() | 276 || parent.isFlexibleBox() || parent.isLayoutGrid() |
| 272 || parent.isSVGRoot() | 277 || parent.isSVGRoot() |
| 273 || parent.isSVGContainer() | 278 || parent.isSVGContainer() |
| 274 || parent.isSVGImage() | 279 || parent.isSVGImage() |
| 275 || parent.isSVGShape()) | 280 || parent.isSVGShape()) |
| 276 return false; | 281 return false; |
| 277 return true; | 282 return true; |
| 278 } | 283 } |
| 279 | 284 |
| 280 bool Text::textLayoutObjectIsNeeded(const ComputedStyle& style, const LayoutObje ct& parent) | 285 bool Text::textLayoutObjectIsNeeded(const ComputedStyle& style, const LayoutObje ct& parent) |
| 281 { | 286 { |
| 282 if (!parent.canHaveChildren()) | 287 if (!parent.canHaveChildren()) |
| 283 return false; | 288 return false; |
| 284 | 289 |
| 285 if (isEditingText()) | 290 if (isEditingText()) |
| 286 return true; | 291 return true; |
| 287 | 292 |
| 288 if (!length()) | 293 if (!length()) |
| 289 return false; | 294 return false; |
| 290 | 295 |
| 291 if (style.display() == NONE) | 296 if (style.display() == NONE) |
| 292 return false; | 297 return false; |
| 293 | 298 |
| 294 if (!containsOnlyWhitespace()) | 299 if (!containsOnlyWhitespace()) |
| 295 return true; | 300 return true; |
| 296 | 301 |
| 297 if (!canHaveWhitespaceChildren(parent)) | 302 if (!canHaveWhitespaceChildren(parent, this)) |
| 298 return false; | 303 return false; |
| 299 | 304 |
| 300 // pre-wrap in SVG never makes layoutObject. | 305 // pre-wrap in SVG never makes layoutObject. |
| 301 if (style.whiteSpace() == PRE_WRAP && parent.isSVG()) | 306 if (style.whiteSpace() == PRE_WRAP && parent.isSVG()) |
| 302 return false; | 307 return false; |
| 303 | 308 |
| 304 // pre/pre-wrap/pre-line always make layoutObjects. | 309 // pre/pre-wrap/pre-line always make layoutObjects. |
| 305 if (style.preserveNewline()) | 310 if (style.preserveNewline()) |
| 306 return true; | 311 return true; |
| 307 | 312 |
| (...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 456 result.appendLiteral("; "); | 461 result.appendLiteral("; "); |
| 457 result.appendLiteral("value="); | 462 result.appendLiteral("value="); |
| 458 result.append(s); | 463 result.append(s); |
| 459 } | 464 } |
| 460 | 465 |
| 461 strncpy(buffer, result.toString().utf8().data(), length - 1); | 466 strncpy(buffer, result.toString().utf8().data(), length - 1); |
| 462 } | 467 } |
| 463 #endif | 468 #endif |
| 464 | 469 |
| 465 } // namespace blink | 470 } // namespace blink |
| OLD | NEW |